1 // Created on: 1998-10-29
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <BRepAdaptor_HSurface.hxx>
19 #include <Standard_Type.hxx>
22 #include <TopoDS_Face.hxx>
23 #include <TopOpeBRep_define.hxx>
24 #include <TopOpeBRep_Hctxff2d.hxx>
25 #include <TopOpeBRepTool_ShapeTool.hxx>
27 IMPLEMENT_STANDARD_RTTIEXT(TopOpeBRep_Hctxff2d,MMgt_TShared)
29 //=======================================================================
30 //function : TopOpeBRep_Hctxff2d
32 //=======================================================================
33 TopOpeBRep_Hctxff2d::TopOpeBRep_Hctxff2d()
35 myf1surf1F_sameoriented = Standard_True;
36 myf2surf1F_sameoriented = Standard_True;
37 mySurfacesSameOriented = Standard_False;
38 myFacesSameOriented = Standard_False;
43 //=======================================================================
46 //=======================================================================
47 void TopOpeBRep_Hctxff2d::SetFaces(const TopoDS_Face& F1,const TopoDS_Face& F2)
49 Standard_Boolean newf1 = !F1.IsEqual(myFace1);
50 Standard_Boolean newf2 = !F2.IsEqual(myFace2);
51 Standard_Boolean yaduneuf = (newf1 || newf2); if (!yaduneuf) return;
53 Standard_Boolean computerestriction = Standard_False;
55 if (mySurface1.IsNull()) mySurface1 = new BRepAdaptor_HSurface();
56 mySurface1->ChangeSurface().Initialize(F1,computerestriction);
59 if (mySurface2.IsNull()) mySurface2 = new BRepAdaptor_HSurface();
60 mySurface2->ChangeSurface().Initialize(F2,computerestriction);
62 SetHSurfacesPrivate();
66 //=======================================================================
67 //function : SetHSurfaces
69 //=======================================================================
70 void TopOpeBRep_Hctxff2d::SetHSurfaces(const Handle(BRepAdaptor_HSurface)& HS1,
71 const Handle(BRepAdaptor_HSurface)& HS2)
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;
80 SetHSurfacesPrivate();
83 //=======================================================================
84 //function : SetHSurfacesPrivate
86 //=======================================================================
87 void TopOpeBRep_Hctxff2d::SetHSurfacesPrivate()
89 BRepAdaptor_Surface& S1 = mySurface1->ChangeSurface();
91 mySurfaceType1 = S1.GetType();
93 BRepAdaptor_Surface& S2 = mySurface2->ChangeSurface();
95 mySurfaceType2 = S2.GetType();
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;
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;
108 mySurfacesSameOriented = TopOpeBRepTool_ShapeTool::SurfacesSameOriented(S1,S2);
109 myFacesSameOriented = TopOpeBRepTool_ShapeTool::FacesSameOriented(myFace1,myFace2);
112 Standard_Integer DEBi = 0;
114 cout<<"TopOpeBRep_Hctxff2d::SetSurfacesPrivate : ";
115 cout<<"f1 "; TopAbs::Print(myFace1.Orientation(),cout);
117 if (so11) cout<<"sameoriented"; else cout<<"difforiented"; cout<<endl;
119 cout<<"f2 "; TopAbs::Print(myFace2.Orientation(),cout);
121 if (so21) cout<<"sameoriented"; else cout<<"difforiented"; cout<<endl;
124 } // SetHSurfacesPrivate
126 //=======================================================================
127 //function : SetTolerances
129 //=======================================================================
131 void TopOpeBRep_Hctxff2d::SetTolerances(const Standard_Real Tol1,const Standard_Real Tol2)
137 //=======================================================================
138 //function : GetTolerances
140 //=======================================================================
142 void TopOpeBRep_Hctxff2d::GetTolerances(Standard_Real& Tol1,Standard_Real& Tol2) const
148 //=======================================================================
149 //function : GetMaxTolerance
151 //=======================================================================
152 Standard_Real TopOpeBRep_Hctxff2d::GetMaxTolerance() const
154 Standard_Real tol = Max(myTol1,myTol2);
158 //=======================================================================
161 //=======================================================================
162 const TopoDS_Face& TopOpeBRep_Hctxff2d::Face(const Standard_Integer Index) const
164 if ( Index == 1 ) return myFace1;
165 else if ( Index == 2 ) return myFace2;
166 else throw Standard_Failure("TopOpeBRep_Hctxff2d::Face");
169 //=======================================================================
172 //=======================================================================
173 Handle(BRepAdaptor_HSurface) TopOpeBRep_Hctxff2d::HSurface(const Standard_Integer Index) const
175 if ( Index == 1 ) return mySurface1;
176 else if ( Index == 2 ) return mySurface2;
177 else throw Standard_Failure("TopOpeBRep_Hctxff2d::HSurface");
180 //=======================================================================
181 //function : SurfacesSameOriented
183 //=======================================================================
184 Standard_Boolean TopOpeBRep_Hctxff2d::SurfacesSameOriented () const
186 return mySurfacesSameOriented;
189 //=======================================================================
190 //function : FacesSameOriented
192 //=======================================================================
193 Standard_Boolean TopOpeBRep_Hctxff2d::FacesSameOriented () const
195 return myFacesSameOriented;
198 //=======================================================================
199 //function : FaceSameOrientedwithNatural1
201 //=======================================================================
202 Standard_Boolean TopOpeBRep_Hctxff2d::FaceSameOrientedWithRef (const Standard_Integer Index) const
204 if ( Index == 1 ) return myf1surf1F_sameoriented;
205 else if ( Index == 2 ) return myf2surf1F_sameoriented;
206 else throw Standard_Failure("TopOpeBRep_Hctxff2d::FSO");