1 // Copyright (C) 2007-2024 CEA, EDF, 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_Integer RefineSDShapes(GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape& aMSD,
95 const Standard_Real aTol,
96 const Handle(IntTools_Context)& aCtx);
99 static Standard_Integer FindSDShapes(const TopTools_ListOfShape& aLE,
100 const Standard_Real aTol,
101 TopTools_IndexedDataMapOfShapeListOfShape& aMEE,
102 const Handle(IntTools_Context)& aCtx);
105 static Standard_Integer FindSDShapes(const TopoDS_Shape& aE1,
106 const TopTools_ListOfShape& aLE,
107 const Standard_Real aTol,
108 TopTools_ListOfShape& aLESD,
109 const Handle(IntTools_Context)& aCtx);
112 static void PointOnShape(const TopoDS_Shape& aS,
116 static void PointOnEdge(const TopoDS_Edge& aE,
120 static void PointOnEdge(const TopoDS_Edge& aE,
121 const Standard_Real aT,gp_Pnt& aP3D);
124 static void PointOnFace(const TopoDS_Face& aF,
128 static void PointOnFace(const TopoDS_Face& aF,
129 const Standard_Real aU,
130 const Standard_Real aV,
134 static Standard_Boolean ProjectPointOnShape(const gp_Pnt& aP1,
135 const TopoDS_Shape& aS,
137 const Handle(IntTools_Context)& aCtx);
140 static void CorrectTolerances(const TopoDS_Shape& aShape,
141 const Standard_Real aMaxTol=0.0001);
144 static void CorrectPointOnCurve(const TopoDS_Shape& S,
145 const Standard_Real aMaxTol=0.0001);
148 static void CorrectCurveOnSurface(const TopoDS_Shape& S,
149 const Standard_Real aMaxTol=0.0001);
153 static Standard_Boolean IsSplitToReverse1(const TopoDS_Edge& aEF1,
154 const TopoDS_Edge& aEF2,
155 const Handle(IntTools_Context)& aCtx);
158 static void RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE,
159 const TopoDS_Face& aF,
160 const Standard_Real aUMin,
161 const Standard_Real aUMax);
164 static Standard_Boolean IsUPeriodic(const Handle(Geom_Surface) &aS);
167 static void MakeContainer(const TopAbs_ShapeEnum theType,
171 static Standard_Boolean IsSplitToReverse(const TopoDS_Edge& theSplit,
172 const TopoDS_Edge& theEdge,
173 const Handle(IntTools_Context)& theCtx);
176 static Standard_Boolean IsSplitToReverse(const TopoDS_Face& theFSp,
177 const TopoDS_Face& theFSr,
178 const Handle(IntTools_Context)& theCtx);
181 static Standard_Boolean IsSplitToReverse(const TopoDS_Shape& theSp,
182 const TopoDS_Shape& theSr,
183 const Handle(IntTools_Context)& theCtx);
186 static Standard_Integer BuildPCurveForEdgeOnFace(const TopoDS_Edge& aEold,
187 const TopoDS_Edge& aEnew,
188 const TopoDS_Face& aF,
189 const Handle(IntTools_Context)& aCtx);
193 static void FindChains(const GEOMAlgo_ListOfCoupleOfShapes& aLCS,
194 GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains);
197 static void FindChains(const GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMCV,
198 GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains);
201 static void CopyShape(const TopoDS_Shape& aS,
205 static void CopyShape(const TopoDS_Shape& aS,
207 TopTools_IndexedDataMapOfShapeShape& aMSS);