1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : GEOMAlgo_AlgoTools.hxx
24 // Author : Peter KURNEV
26 #ifndef _GEOMAlgo_AlgoTools_HeaderFile
27 #define _GEOMAlgo_AlgoTools_HeaderFile
29 #include <Basics_OCCTVersion.hxx>
31 #include <Standard.hxx>
32 #include <Standard_Macro.hxx>
33 #include <Standard_Boolean.hxx>
34 #if OCC_VERSION_LARGE > 0x06070100
35 #include <Handle_IntTools_Context.hxx>
36 #include <IntTools_Context.hxx>
38 #include <Handle_BOPInt_Context.hxx>
39 #include <BOPInt_Context.hxx>
41 #include <Standard_Integer.hxx>
44 #include <gp_Pnt2d.hxx>
46 #include <Geom_Surface.hxx>
48 #include <TopAbs_ShapeEnum.hxx>
50 #include <TopoDS_Face.hxx>
51 #include <TopoDS_Shape.hxx>
52 #include <TopoDS_Edge.hxx>
54 #include <TopTools_ListOfShape.hxx>
55 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
56 #include <TopTools_ListOfShape.hxx>
57 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
59 #include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>
60 #include <GEOMAlgo_ListOfCoupleOfShapes.hxx>
61 #include <GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
63 //! Auxiliary tools for Algorithms <br>
64 //=======================================================================
65 //class : GEOMAlgo_AlgoTools
67 //=======================================================================
68 class GEOMAlgo_AlgoTools {
72 static void FaceNormal (const TopoDS_Face& aF,
73 const Standard_Real U,
74 const Standard_Real V,
77 //! Computes a point <theP> inside the face <theF>. <br>
78 //! <theP2D> - 2D representation of <theP> <br>
79 //! on the surface of <theF> <br>
80 //! Returns 0 in case of success. <br>
82 static Standard_Integer PntInFace(const TopoDS_Face& theF,
87 static Standard_Boolean IsCompositeShape(const TopoDS_Shape& aS) ;
91 static Standard_Boolean BuildTriangulation(const TopoDS_Shape& aS) ;
94 static Standard_Integer RefineSDShapes
95 (GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape& aMSD,
96 const Standard_Real aTol,
97 #if OCC_VERSION_LARGE > 0x06070100
98 const Handle(IntTools_Context)& aCtx
100 const Handle(BOPInt_Context)& aCtx
105 static Standard_Integer FindSDShapes(const TopTools_ListOfShape& aLE,
106 const Standard_Real aTol,
107 TopTools_IndexedDataMapOfShapeListOfShape& aMEE,
108 #if OCC_VERSION_LARGE > 0x06070100
109 const Handle(IntTools_Context)& aCtx
111 const Handle(BOPInt_Context)& aCtx
115 static Standard_Integer FindSDShapes(const TopoDS_Shape& aE1,
116 const TopTools_ListOfShape& aLE,
117 const Standard_Real aTol,
118 TopTools_ListOfShape& aLESD,
119 #if OCC_VERSION_LARGE > 0x06070100
120 const Handle(IntTools_Context)& aCtx
122 const Handle(BOPInt_Context)& aCtx
127 static void PointOnShape(const TopoDS_Shape& aS,
131 static void PointOnEdge(const TopoDS_Edge& aE,
135 static void PointOnEdge(const TopoDS_Edge& aE,
136 const Standard_Real aT,gp_Pnt& aP3D) ;
139 static void PointOnFace(const TopoDS_Face& aF,
143 static void PointOnFace(const TopoDS_Face& aF,
144 const Standard_Real aU,
145 const Standard_Real aV,
148 static Standard_Boolean ProjectPointOnShape(const gp_Pnt& aP1,
149 const TopoDS_Shape& aS,
151 #if OCC_VERSION_LARGE > 0x06070100
152 const Handle(IntTools_Context)& aCtx
154 const Handle(BOPInt_Context)& aCtx
159 static void CorrectTolerances(const TopoDS_Shape& aShape,
160 const Standard_Real aMaxTol=0.0001);
163 static void CorrectPointOnCurve(const TopoDS_Shape& S,
164 const Standard_Real aMaxTol=0.0001);
167 static void CorrectCurveOnSurface(const TopoDS_Shape& S,
168 const Standard_Real aMaxTol=0.0001);
172 static Standard_Boolean IsSplitToReverse1 (const TopoDS_Edge& aEF1,
173 const TopoDS_Edge& aEF2,
174 #if OCC_VERSION_LARGE > 0x06070100
175 const Handle(IntTools_Context)& aCtx
177 const Handle(BOPInt_Context)& aCtx
181 static void RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE,
182 const TopoDS_Face& aF,
183 const Standard_Real aUMin,
184 const Standard_Real aUMax);
187 static Standard_Boolean IsUPeriodic(const Handle(Geom_Surface) &aS);
190 static void MakeContainer(const TopAbs_ShapeEnum theType,
194 static Standard_Boolean IsSplitToReverse(const TopoDS_Edge& theSplit,
195 const TopoDS_Edge& theEdge,
196 #if OCC_VERSION_LARGE > 0x06070100
197 const Handle(IntTools_Context)& theCtx
199 const Handle(BOPInt_Context)& theCtx
204 static Standard_Boolean IsSplitToReverse (const TopoDS_Face& theFSp,
205 const TopoDS_Face& theFSr,
206 #if OCC_VERSION_LARGE > 0x06070100
207 const Handle(IntTools_Context)& theCtx
209 const Handle(BOPInt_Context)& theCtx
214 static Standard_Boolean IsSplitToReverse (const TopoDS_Shape& theSp,
215 const TopoDS_Shape& theSr,
216 #if OCC_VERSION_LARGE > 0x06070100
217 const Handle(IntTools_Context)& theCtx
219 const Handle(BOPInt_Context)& theCtx
223 static Standard_Integer BuildPCurveForEdgeOnFace (const TopoDS_Edge& aEold,
224 const TopoDS_Edge& aEnew,
225 const TopoDS_Face& aF,
226 #if OCC_VERSION_LARGE > 0x06070100
227 const Handle(IntTools_Context)& aCtx
229 const Handle(BOPInt_Context)& aCtx
235 static void FindChains(const GEOMAlgo_ListOfCoupleOfShapes& aLCS,
236 GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains);
239 static void FindChains(const GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMCV,
240 GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains);
243 static void CopyShape(const TopoDS_Shape& aS,
247 static void CopyShape(const TopoDS_Shape& aS,
249 TopTools_IndexedDataMapOfShapeShape& aMSS) ;