1 // Copyright (C) 2007-2022 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 <GeomAlgoImpl.h>
31 #include <Standard.hxx>
32 #include <Standard_Macro.hxx>
33 #include <Standard_Boolean.hxx>
34 #include <IntTools_Context.hxx>
35 #include <Standard_Integer.hxx>
38 #include <gp_Pnt2d.hxx>
40 #include <Geom_Surface.hxx>
42 #include <TopAbs_ShapeEnum.hxx>
44 #include <TopoDS_Face.hxx>
45 #include <TopoDS_Shape.hxx>
46 #include <TopoDS_Edge.hxx>
47 #include <TopoDS_Compound.hxx>
49 #include <TopTools_ListOfShape.hxx>
50 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
51 #include <TopTools_ListOfShape.hxx>
52 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
54 #include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>
55 #include <GEOMAlgo_ListOfCoupleOfShapes.hxx>
56 #include <GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
59 //! Auxiliary tools for Algorithms <br>
60 //=======================================================================
61 //class : GEOMAlgo_AlgoTools
63 //=======================================================================
64 class GEOMAlgo_AlgoTools {
68 static void FaceNormal(const TopoDS_Face& aF,
69 const Standard_Real U,
70 const Standard_Real V,
73 //! Computes a point <theP> inside the face <theF>. <br>
74 //! <theP2D> - 2D representation of <theP> <br>
75 //! on the surface of <theF> <br>
76 //! Returns 0 in case of success. <br>
78 static Standard_Integer PntInFace(const TopoDS_Face& theF,
82 //! Computes a set of points inside the face <theF>. <br>
83 //! Returns 0 in case of success. <br>
85 static Standard_Integer PointCloudInFace(const TopoDS_Face& theF,
87 TopoDS_Compound& theCompound);
90 static Standard_Boolean IsCompositeShape(const TopoDS_Shape& aS);
94 static Standard_Boolean BuildTriangulation(const TopoDS_Shape& aS);
97 static Standard_Integer RefineSDShapes(GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape& aMSD,
98 const Standard_Real aTol,
99 const Handle(IntTools_Context)& aCtx);
102 static Standard_Integer FindSDShapes(const TopTools_ListOfShape& aLE,
103 const Standard_Real aTol,
104 TopTools_IndexedDataMapOfShapeListOfShape& aMEE,
105 const Handle(IntTools_Context)& aCtx);
108 static Standard_Integer FindSDShapes(const TopoDS_Shape& aE1,
109 const TopTools_ListOfShape& aLE,
110 const Standard_Real aTol,
111 TopTools_ListOfShape& aLESD,
112 const Handle(IntTools_Context)& aCtx);
115 static void PointOnShape(const TopoDS_Shape& aS,
119 static void PointOnEdge(const TopoDS_Edge& aE,
123 static void PointOnEdge(const TopoDS_Edge& aE,
124 const Standard_Real aT,gp_Pnt& aP3D);
127 static void PointOnFace(const TopoDS_Face& aF,
131 static void PointOnFace(const TopoDS_Face& aF,
132 const Standard_Real aU,
133 const Standard_Real aV,
137 static Standard_Boolean ProjectPointOnShape(const gp_Pnt& aP1,
138 const TopoDS_Shape& aS,
140 const Handle(IntTools_Context)& aCtx);
143 static void CorrectTolerances(const TopoDS_Shape& aShape,
144 const Standard_Real aMaxTol=0.0001);
147 static void CorrectPointOnCurve(const TopoDS_Shape& S,
148 const Standard_Real aMaxTol=0.0001);
151 static void CorrectCurveOnSurface(const TopoDS_Shape& S,
152 const Standard_Real aMaxTol=0.0001);
156 static Standard_Boolean IsSplitToReverse1(const TopoDS_Edge& aEF1,
157 const TopoDS_Edge& aEF2,
158 const Handle(IntTools_Context)& aCtx);
161 static void RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE,
162 const TopoDS_Face& aF,
163 const Standard_Real aUMin,
164 const Standard_Real aUMax);
167 static Standard_Boolean IsUPeriodic(const Handle(Geom_Surface) &aS);
170 static void MakeContainer(const TopAbs_ShapeEnum theType,
174 static Standard_Boolean IsSplitToReverse(const TopoDS_Edge& theSplit,
175 const TopoDS_Edge& theEdge,
176 const Handle(IntTools_Context)& theCtx);
179 static Standard_Boolean IsSplitToReverse(const TopoDS_Face& theFSp,
180 const TopoDS_Face& theFSr,
181 const Handle(IntTools_Context)& theCtx);
184 static Standard_Boolean IsSplitToReverse(const TopoDS_Shape& theSp,
185 const TopoDS_Shape& theSr,
186 const Handle(IntTools_Context)& theCtx);
189 static Standard_Integer BuildPCurveForEdgeOnFace(const TopoDS_Edge& aEold,
190 const TopoDS_Edge& aEnew,
191 const TopoDS_Face& aF,
192 const Handle(IntTools_Context)& aCtx);
196 static void FindChains(const GEOMAlgo_ListOfCoupleOfShapes& aLCS,
197 GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains);
200 static void FindChains(const GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMCV,
201 GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains);
204 static void CopyShape(const TopoDS_Shape& aS,
208 static void CopyShape(const TopoDS_Shape& aS,
210 TopTools_IndexedDataMapOfShapeShape& aMSS);