summaryrefslogtreecommitdiff
path: root/src/TopOpeBRep/TopOpeBRep_Hctxff2d.cxx
blob: 55c1f4ce1a41575180492a6105a199a8cdbdc23a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// File:	TopOpeBRep_Hctxff2d.cxx
// Created:	Thu Oct 29 12:46:21 1998
// Author:	Jean Yves LEBEY
//		<jyl@langdox.paris1.matra-dtv.fr>

#include <TopOpeBRep_Hctxff2d.ixx>
#include <TopOpeBRep_define.hxx>
#include <TopOpeBRepTool_ShapeTool.hxx>
#include <TopAbs.hxx>
#include <TopoDS.hxx>

//=======================================================================
//function : TopOpeBRep_Hctxff2d
//purpose  : 
//=======================================================================
TopOpeBRep_Hctxff2d::TopOpeBRep_Hctxff2d() 
{
  myf1surf1F_sameoriented = Standard_True;
  myf2surf1F_sameoriented = Standard_True;
  mySurfacesSameOriented = Standard_False;
  myFacesSameOriented = Standard_False;
  myTol1 = 0.;
  myTol2 = 0.;
}

//=======================================================================
//function : SetFaces
//purpose  : 
//=======================================================================
void TopOpeBRep_Hctxff2d::SetFaces(const TopoDS_Face& F1,const TopoDS_Face& F2)
{
  Standard_Boolean newf1 = !F1.IsEqual(myFace1);
  Standard_Boolean newf2 = !F2.IsEqual(myFace2);
  Standard_Boolean yaduneuf = (newf1 || newf2); if (!yaduneuf) return;

  Standard_Boolean computerestriction = Standard_False;
  if (newf1) {
    if (mySurface1.IsNull()) mySurface1 = new BRepAdaptor_HSurface();
    mySurface1->ChangeSurface().Initialize(F1,computerestriction);
  }
  if (newf2) {
    if (mySurface2.IsNull()) mySurface2 = new BRepAdaptor_HSurface();
    mySurface2->ChangeSurface().Initialize(F2,computerestriction);
  }
  SetHSurfacesPrivate();
} // SetFaces


//=======================================================================
//function : SetHSurfaces
//purpose  : 
//=======================================================================
void TopOpeBRep_Hctxff2d::SetHSurfaces(const Handle(BRepAdaptor_HSurface)& HS1,
				       const Handle(BRepAdaptor_HSurface)& HS2)
{
  Standard_Boolean newf1 = Standard_False; Standard_Boolean newf2 = Standard_False;
  if (!HS1.IsNull()) newf1 = !HS1->ChangeSurface().Face().IsEqual(myFace1);
  if (!HS2.IsNull()) newf2 = !HS2->ChangeSurface().Face().IsEqual(myFace2);
  Standard_Boolean yaduneuf = (newf1 || newf2); if (!yaduneuf) return;
  
  mySurface1 = HS1;
  mySurface2 = HS2;
  SetHSurfacesPrivate();
} // SetHSurfaces

//=======================================================================
//function : SetHSurfacesPrivate
//purpose  : 
//=======================================================================
void TopOpeBRep_Hctxff2d::SetHSurfacesPrivate()
{
  BRepAdaptor_Surface& S1 = mySurface1->ChangeSurface();
  myFace1 = S1.Face();
  mySurfaceType1 = S1.GetType();

  BRepAdaptor_Surface& S2 = mySurface2->ChangeSurface(); 
  myFace2 = S2.Face(); 
  mySurfaceType2 = S2.GetType();
  
  mySurfacesSameOriented = Standard_True;
  myFacesSameOriented = Standard_True;  
  Standard_Boolean so11 = Standard_True; myf1surf1F_sameoriented = so11;
  Standard_Boolean so21 = Standard_True; myf2surf1F_sameoriented = so21;
  
  TopoDS_Face face1forward = myFace1; face1forward.Orientation(TopAbs_FORWARD);
  so11 = TopOpeBRepTool_ShapeTool::FacesSameOriented(face1forward,myFace1);
  myf1surf1F_sameoriented = so11; 
  so21 = TopOpeBRepTool_ShapeTool::FacesSameOriented(face1forward,myFace2);
  myf2surf1F_sameoriented = so21;
  
  mySurfacesSameOriented = TopOpeBRepTool_ShapeTool::SurfacesSameOriented(S1,S2);
  myFacesSameOriented = TopOpeBRepTool_ShapeTool::FacesSameOriented(myFace1,myFace2);
  
#ifdef DEB
  Standard_Integer DEBi = 0;
  if ( DEBi ) {
    cout<<"TopOpeBRep_Hctxff2d::SetSurfacesPrivate : ";
    cout<<"f1 "; TopAbs::Print(myFace1.Orientation(),cout);
    cout<< " / f1F : ";
    if (so11) cout<<"sameoriented"; else cout<<"difforiented"; cout<<endl;
    cout <<"  ";
    cout<<"f2 "; TopAbs::Print(myFace2.Orientation(),cout);
    cout<< " / f1F : ";
    if (so21) cout<<"sameoriented"; else cout<<"difforiented"; cout<<endl;
  }
#endif
} // SetHSurfacesPrivate

//=======================================================================
//function : SetTolerances
//purpose  : 
//=======================================================================

void TopOpeBRep_Hctxff2d::SetTolerances(const Standard_Real Tol1,const Standard_Real Tol2)
{
  myTol1 = Tol1;
  myTol2 = Tol2;
}

//=======================================================================
//function : GetTolerances
//purpose  : 
//=======================================================================

void TopOpeBRep_Hctxff2d::GetTolerances(Standard_Real& Tol1,Standard_Real& Tol2) const
{
  Tol1 = myTol1;
  Tol2 = myTol2;
}

//=======================================================================
//function : GetMaxTolerance
//purpose  : 
//=======================================================================
Standard_Real TopOpeBRep_Hctxff2d::GetMaxTolerance() const 
{
  Standard_Real tol = Max(myTol1,myTol2);
  return tol;
}

//=======================================================================
//function : Face
//purpose  : 
//=======================================================================
const TopoDS_Face& TopOpeBRep_Hctxff2d::Face(const Standard_Integer Index) const 
{
  if      ( Index == 1 ) return myFace1;
  else if ( Index == 2 ) return myFace2;
  else Standard_Failure::Raise("TopOpeBRep_Hctxff2d::Face");
  
  return myFace1;
}

//=======================================================================
//function : Surface
//purpose  : 
//=======================================================================
Handle(BRepAdaptor_HSurface) TopOpeBRep_Hctxff2d::HSurface(const Standard_Integer Index) const 
{
  if      ( Index == 1 ) return mySurface1;
  else if ( Index == 2 ) return mySurface2;
  else Standard_Failure::Raise("TopOpeBRep_Hctxff2d::HSurface");
  
  return mySurface1;
}

//=======================================================================
//function : SurfacesSameOriented
//purpose  : 
//=======================================================================
Standard_Boolean TopOpeBRep_Hctxff2d::SurfacesSameOriented () const
{
  return mySurfacesSameOriented;
}

//=======================================================================
//function : FacesSameOriented
//purpose  : 
//=======================================================================
Standard_Boolean TopOpeBRep_Hctxff2d::FacesSameOriented () const
{
  return myFacesSameOriented;
}

//=======================================================================
//function : FaceSameOrientedwithNatural1
//purpose  : 
//=======================================================================
Standard_Boolean TopOpeBRep_Hctxff2d::FaceSameOrientedWithRef (const Standard_Integer Index) const
{
  if      ( Index == 1 ) return myf1surf1F_sameoriented;
  else if ( Index == 2 ) return myf2surf1F_sameoriented;
  else Standard_Failure::Raise("TopOpeBRep_Hctxff2d::FSO");

  return Standard_True;
}