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 <IntTools_Context.hxx>
37 #include <BOPInt_Context.hxx>
39 #include <Standard_Integer.hxx>
42 #include <gp_Pnt2d.hxx>
44 #include <Geom_Surface.hxx>
46 #include <TopAbs_ShapeEnum.hxx>
48 #include <TopoDS_Face.hxx>
49 #include <TopoDS_Shape.hxx>
50 #include <TopoDS_Edge.hxx>
52 #include <TopTools_ListOfShape.hxx>
53 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
54 #include <TopTools_ListOfShape.hxx>
55 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
57 #include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>
58 #include <GEOMAlgo_ListOfCoupleOfShapes.hxx>
59 #include <GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
61 //! Auxiliary tools for Algorithms <br>
62 //=======================================================================
63 //class : GEOMAlgo_AlgoTools
65 //=======================================================================
66 class GEOMAlgo_AlgoTools {
70 static void FaceNormal (const TopoDS_Face& aF,
71 const Standard_Real U,
72 const Standard_Real V,
75 //! Computes a point <theP> inside the face <theF>. <br>
76 //! <theP2D> - 2D representation of <theP> <br>
77 //! on the surface of <theF> <br>
78 //! Returns 0 in case of success. <br>
80 static Standard_Integer PntInFace(const TopoDS_Face& theF,
85 static Standard_Boolean IsCompositeShape(const TopoDS_Shape& aS) ;
89 static Standard_Boolean BuildTriangulation(const TopoDS_Shape& aS) ;
92 static Standard_Integer RefineSDShapes
93 (GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape& aMSD,
94 const Standard_Real aTol,
95 #if OCC_VERSION_LARGE > 0x06070100
96 const Handle(IntTools_Context)& aCtx
98 const Handle(BOPInt_Context)& aCtx
103 static Standard_Integer FindSDShapes(const TopTools_ListOfShape& aLE,
104 const Standard_Real aTol,
105 TopTools_IndexedDataMapOfShapeListOfShape& aMEE,
106 #if OCC_VERSION_LARGE > 0x06070100
107 const Handle(IntTools_Context)& aCtx
109 const Handle(BOPInt_Context)& aCtx
113 static Standard_Integer FindSDShapes(const TopoDS_Shape& aE1,
114 const TopTools_ListOfShape& aLE,
115 const Standard_Real aTol,
116 TopTools_ListOfShape& aLESD,
117 #if OCC_VERSION_LARGE > 0x06070100
118 const Handle(IntTools_Context)& aCtx
120 const Handle(BOPInt_Context)& aCtx
125 static void PointOnShape(const TopoDS_Shape& aS,
129 static void PointOnEdge(const TopoDS_Edge& aE,
133 static void PointOnEdge(const TopoDS_Edge& aE,
134 const Standard_Real aT,gp_Pnt& aP3D) ;
137 static void PointOnFace(const TopoDS_Face& aF,
141 static void PointOnFace(const TopoDS_Face& aF,
142 const Standard_Real aU,
143 const Standard_Real aV,
146 static Standard_Boolean ProjectPointOnShape(const gp_Pnt& aP1,
147 const TopoDS_Shape& aS,
149 #if OCC_VERSION_LARGE > 0x06070100
150 const Handle(IntTools_Context)& aCtx
152 const Handle(BOPInt_Context)& aCtx
157 static void CorrectTolerances(const TopoDS_Shape& aShape,
158 const Standard_Real aMaxTol=0.0001);
161 static void CorrectPointOnCurve(const TopoDS_Shape& S,
162 const Standard_Real aMaxTol=0.0001);
165 static void CorrectCurveOnSurface(const TopoDS_Shape& S,
166 const Standard_Real aMaxTol=0.0001);
170 static Standard_Boolean IsSplitToReverse1 (const TopoDS_Edge& aEF1,
171 const TopoDS_Edge& aEF2,
172 #if OCC_VERSION_LARGE > 0x06070100
173 const Handle(IntTools_Context)& aCtx
175 const Handle(BOPInt_Context)& aCtx
179 static void RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE,
180 const TopoDS_Face& aF,
181 const Standard_Real aUMin,
182 const Standard_Real aUMax);
185 static Standard_Boolean IsUPeriodic(const Handle(Geom_Surface) &aS);
188 static void MakeContainer(const TopAbs_ShapeEnum theType,
192 static Standard_Boolean IsSplitToReverse(const TopoDS_Edge& theSplit,
193 const TopoDS_Edge& theEdge,
194 #if OCC_VERSION_LARGE > 0x06070100
195 const Handle(IntTools_Context)& theCtx
197 const Handle(BOPInt_Context)& theCtx
202 static Standard_Boolean IsSplitToReverse (const TopoDS_Face& theFSp,
203 const TopoDS_Face& theFSr,
204 #if OCC_VERSION_LARGE > 0x06070100
205 const Handle(IntTools_Context)& theCtx
207 const Handle(BOPInt_Context)& theCtx
212 static Standard_Boolean IsSplitToReverse (const TopoDS_Shape& theSp,
213 const TopoDS_Shape& theSr,
214 #if OCC_VERSION_LARGE > 0x06070100
215 const Handle(IntTools_Context)& theCtx
217 const Handle(BOPInt_Context)& theCtx
221 static Standard_Integer BuildPCurveForEdgeOnFace (const TopoDS_Edge& aEold,
222 const TopoDS_Edge& aEnew,
223 const TopoDS_Face& aF,
224 #if OCC_VERSION_LARGE > 0x06070100
225 const Handle(IntTools_Context)& aCtx
227 const Handle(BOPInt_Context)& aCtx
233 static void FindChains(const GEOMAlgo_ListOfCoupleOfShapes& aLCS,
234 GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains);
237 static void FindChains(const GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMCV,
238 GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains);
241 static void CopyShape(const TopoDS_Shape& aS,
245 static void CopyShape(const TopoDS_Shape& aS,
247 TopTools_IndexedDataMapOfShapeShape& aMSS) ;