b311480e |
1 | // Created on: 1998-10-29 |
2 | // Created by: Jean Yves LEBEY |
3 | // Copyright (c) 1998-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <BRepAdaptor_HSurface.hxx> |
19 | #include <Standard_Type.hxx> |
7fd59977 |
20 | #include <TopAbs.hxx> |
21 | #include <TopoDS.hxx> |
42cf5bc1 |
22 | #include <TopoDS_Face.hxx> |
23 | #include <TopOpeBRep_define.hxx> |
24 | #include <TopOpeBRep_Hctxff2d.hxx> |
25 | #include <TopOpeBRepTool_ShapeTool.hxx> |
7fd59977 |
26 | |
25e59720 |
27 | IMPLEMENT_STANDARD_RTTIEXT(TopOpeBRep_Hctxff2d,Standard_Transient) |
92efcf78 |
28 | |
7fd59977 |
29 | //======================================================================= |
30 | //function : TopOpeBRep_Hctxff2d |
31 | //purpose : |
32 | //======================================================================= |
33 | TopOpeBRep_Hctxff2d::TopOpeBRep_Hctxff2d() |
34 | { |
35 | myf1surf1F_sameoriented = Standard_True; |
36 | myf2surf1F_sameoriented = Standard_True; |
37 | mySurfacesSameOriented = Standard_False; |
38 | myFacesSameOriented = Standard_False; |
39 | myTol1 = 0.; |
40 | myTol2 = 0.; |
41 | } |
42 | |
43 | //======================================================================= |
44 | //function : SetFaces |
45 | //purpose : |
46 | //======================================================================= |
47 | void TopOpeBRep_Hctxff2d::SetFaces(const TopoDS_Face& F1,const TopoDS_Face& F2) |
48 | { |
49 | Standard_Boolean newf1 = !F1.IsEqual(myFace1); |
50 | Standard_Boolean newf2 = !F2.IsEqual(myFace2); |
51 | Standard_Boolean yaduneuf = (newf1 || newf2); if (!yaduneuf) return; |
52 | |
53 | Standard_Boolean computerestriction = Standard_False; |
54 | if (newf1) { |
55 | if (mySurface1.IsNull()) mySurface1 = new BRepAdaptor_HSurface(); |
56 | mySurface1->ChangeSurface().Initialize(F1,computerestriction); |
57 | } |
58 | if (newf2) { |
59 | if (mySurface2.IsNull()) mySurface2 = new BRepAdaptor_HSurface(); |
60 | mySurface2->ChangeSurface().Initialize(F2,computerestriction); |
61 | } |
62 | SetHSurfacesPrivate(); |
63 | } // SetFaces |
64 | |
65 | |
66 | //======================================================================= |
67 | //function : SetHSurfaces |
68 | //purpose : |
69 | //======================================================================= |
70 | void TopOpeBRep_Hctxff2d::SetHSurfaces(const Handle(BRepAdaptor_HSurface)& HS1, |
71 | const Handle(BRepAdaptor_HSurface)& HS2) |
72 | { |
73 | Standard_Boolean newf1 = Standard_False; Standard_Boolean newf2 = Standard_False; |
74 | if (!HS1.IsNull()) newf1 = !HS1->ChangeSurface().Face().IsEqual(myFace1); |
75 | if (!HS2.IsNull()) newf2 = !HS2->ChangeSurface().Face().IsEqual(myFace2); |
76 | Standard_Boolean yaduneuf = (newf1 || newf2); if (!yaduneuf) return; |
77 | |
78 | mySurface1 = HS1; |
79 | mySurface2 = HS2; |
80 | SetHSurfacesPrivate(); |
81 | } // SetHSurfaces |
82 | |
83 | //======================================================================= |
84 | //function : SetHSurfacesPrivate |
85 | //purpose : |
86 | //======================================================================= |
87 | void TopOpeBRep_Hctxff2d::SetHSurfacesPrivate() |
88 | { |
89 | BRepAdaptor_Surface& S1 = mySurface1->ChangeSurface(); |
90 | myFace1 = S1.Face(); |
91 | mySurfaceType1 = S1.GetType(); |
92 | |
93 | BRepAdaptor_Surface& S2 = mySurface2->ChangeSurface(); |
94 | myFace2 = S2.Face(); |
95 | mySurfaceType2 = S2.GetType(); |
96 | |
97 | mySurfacesSameOriented = Standard_True; |
98 | myFacesSameOriented = Standard_True; |
99 | Standard_Boolean so11 = Standard_True; myf1surf1F_sameoriented = so11; |
100 | Standard_Boolean so21 = Standard_True; myf2surf1F_sameoriented = so21; |
101 | |
102 | TopoDS_Face face1forward = myFace1; face1forward.Orientation(TopAbs_FORWARD); |
103 | so11 = TopOpeBRepTool_ShapeTool::FacesSameOriented(face1forward,myFace1); |
104 | myf1surf1F_sameoriented = so11; |
105 | so21 = TopOpeBRepTool_ShapeTool::FacesSameOriented(face1forward,myFace2); |
106 | myf2surf1F_sameoriented = so21; |
107 | |
108 | mySurfacesSameOriented = TopOpeBRepTool_ShapeTool::SurfacesSameOriented(S1,S2); |
109 | myFacesSameOriented = TopOpeBRepTool_ShapeTool::FacesSameOriented(myFace1,myFace2); |
110 | |
0797d9d3 |
111 | #ifdef OCCT_DEBUG |
7fd59977 |
112 | Standard_Integer DEBi = 0; |
113 | if ( DEBi ) { |
04232180 |
114 | std::cout<<"TopOpeBRep_Hctxff2d::SetSurfacesPrivate : "; |
115 | std::cout<<"f1 "; TopAbs::Print(myFace1.Orientation(),std::cout); |
116 | std::cout<< " / f1F : "; |
117 | if (so11) std::cout<<"sameoriented"; else std::cout<<"difforiented"; std::cout<<std::endl; |
118 | std::cout <<" "; |
119 | std::cout<<"f2 "; TopAbs::Print(myFace2.Orientation(),std::cout); |
120 | std::cout<< " / f1F : "; |
121 | if (so21) std::cout<<"sameoriented"; else std::cout<<"difforiented"; std::cout<<std::endl; |
7fd59977 |
122 | } |
123 | #endif |
124 | } // SetHSurfacesPrivate |
125 | |
126 | //======================================================================= |
127 | //function : SetTolerances |
128 | //purpose : |
129 | //======================================================================= |
130 | |
131 | void TopOpeBRep_Hctxff2d::SetTolerances(const Standard_Real Tol1,const Standard_Real Tol2) |
132 | { |
133 | myTol1 = Tol1; |
134 | myTol2 = Tol2; |
135 | } |
136 | |
137 | //======================================================================= |
138 | //function : GetTolerances |
139 | //purpose : |
140 | //======================================================================= |
141 | |
142 | void TopOpeBRep_Hctxff2d::GetTolerances(Standard_Real& Tol1,Standard_Real& Tol2) const |
143 | { |
144 | Tol1 = myTol1; |
145 | Tol2 = myTol2; |
146 | } |
147 | |
148 | //======================================================================= |
149 | //function : GetMaxTolerance |
150 | //purpose : |
151 | //======================================================================= |
152 | Standard_Real TopOpeBRep_Hctxff2d::GetMaxTolerance() const |
153 | { |
154 | Standard_Real tol = Max(myTol1,myTol2); |
155 | return tol; |
156 | } |
157 | |
158 | //======================================================================= |
159 | //function : Face |
160 | //purpose : |
161 | //======================================================================= |
162 | const TopoDS_Face& TopOpeBRep_Hctxff2d::Face(const Standard_Integer Index) const |
163 | { |
164 | if ( Index == 1 ) return myFace1; |
165 | else if ( Index == 2 ) return myFace2; |
9775fa61 |
166 | else throw Standard_Failure("TopOpeBRep_Hctxff2d::Face"); |
7fd59977 |
167 | } |
168 | |
169 | //======================================================================= |
170 | //function : Surface |
171 | //purpose : |
172 | //======================================================================= |
173 | Handle(BRepAdaptor_HSurface) TopOpeBRep_Hctxff2d::HSurface(const Standard_Integer Index) const |
174 | { |
175 | if ( Index == 1 ) return mySurface1; |
176 | else if ( Index == 2 ) return mySurface2; |
9775fa61 |
177 | else throw Standard_Failure("TopOpeBRep_Hctxff2d::HSurface"); |
7fd59977 |
178 | } |
179 | |
180 | //======================================================================= |
181 | //function : SurfacesSameOriented |
182 | //purpose : |
183 | //======================================================================= |
184 | Standard_Boolean TopOpeBRep_Hctxff2d::SurfacesSameOriented () const |
185 | { |
186 | return mySurfacesSameOriented; |
187 | } |
188 | |
189 | //======================================================================= |
190 | //function : FacesSameOriented |
191 | //purpose : |
192 | //======================================================================= |
193 | Standard_Boolean TopOpeBRep_Hctxff2d::FacesSameOriented () const |
194 | { |
195 | return myFacesSameOriented; |
196 | } |
197 | |
198 | //======================================================================= |
199 | //function : FaceSameOrientedwithNatural1 |
200 | //purpose : |
201 | //======================================================================= |
202 | Standard_Boolean TopOpeBRep_Hctxff2d::FaceSameOrientedWithRef (const Standard_Integer Index) const |
203 | { |
204 | if ( Index == 1 ) return myf1surf1F_sameoriented; |
205 | else if ( Index == 2 ) return myf2surf1F_sameoriented; |
9775fa61 |
206 | else throw Standard_Failure("TopOpeBRep_Hctxff2d::FSO"); |
7fd59977 |
207 | } |