Salome HOME
0023505: Sigsegv with fuse on cylinder and cone
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_AlgoTools.hxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File    : GEOMAlgo_AlgoTools.hxx
23 //  Created :
24 //  Author  : Peter KURNEV
25
26 #ifndef _GEOMAlgo_AlgoTools_HeaderFile
27 #define _GEOMAlgo_AlgoTools_HeaderFile
28
29 #include <Basics_OCCTVersion.hxx>
30
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>
36 #else
37 #include <BOPInt_Context.hxx>
38 #endif
39 #include <Standard_Integer.hxx>
40
41 #include <gp_Pnt.hxx>
42 #include <gp_Pnt2d.hxx>
43
44 #include <Geom_Surface.hxx>
45
46 #include <TopAbs_ShapeEnum.hxx>
47
48 #include <TopoDS_Face.hxx>
49 #include <TopoDS_Shape.hxx>
50 #include <TopoDS_Edge.hxx>
51
52 #include <TopTools_ListOfShape.hxx>
53 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
54 #include <TopTools_ListOfShape.hxx>
55 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
56
57 #include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>
58 #include <GEOMAlgo_ListOfCoupleOfShapes.hxx>
59 #include <GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
60
61 //!  Auxiliary tools for Algorithms <br>
62 //=======================================================================
63 //class    : GEOMAlgo_AlgoTools
64 //purpose  :
65 //=======================================================================
66 class GEOMAlgo_AlgoTools  {
67  public:
68
69   Standard_EXPORT
70     static void FaceNormal (const TopoDS_Face& aF,
71                             const Standard_Real U,
72                             const Standard_Real V,
73                             gp_Vec& aN);
74
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>
79   Standard_EXPORT
80     static  Standard_Integer PntInFace(const TopoDS_Face& theF,
81                                        gp_Pnt& theP,
82                                        gp_Pnt2d& theP2D) ;
83
84   Standard_EXPORT
85     static  Standard_Boolean IsCompositeShape(const TopoDS_Shape& aS) ;
86
87
88   Standard_EXPORT
89     static  Standard_Boolean BuildTriangulation(const TopoDS_Shape& aS) ;
90
91   Standard_EXPORT
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
97 #else
98        const Handle(BOPInt_Context)& aCtx
99 #endif
100        ) ;
101
102   Standard_EXPORT
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
108 #else
109                                           const Handle(BOPInt_Context)& aCtx
110 #endif
111                                           ) ;
112   Standard_EXPORT
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
119 #else
120                                           const Handle(BOPInt_Context)& aCtx
121 #endif
122                                           ) ;
123
124   Standard_EXPORT
125     static  void PointOnShape(const TopoDS_Shape& aS,
126                               gp_Pnt& aP3D) ;
127
128   Standard_EXPORT
129     static  void PointOnEdge(const TopoDS_Edge& aE,
130                              gp_Pnt& aP3D) ;
131
132   Standard_EXPORT
133     static  void PointOnEdge(const TopoDS_Edge& aE,
134                              const Standard_Real aT,gp_Pnt& aP3D) ;
135
136   Standard_EXPORT
137     static  void PointOnFace(const TopoDS_Face& aF,
138                              gp_Pnt& aP3D) ;
139
140   Standard_EXPORT
141     static  void PointOnFace(const TopoDS_Face& aF,
142                              const Standard_Real aU,
143                              const Standard_Real aV,
144                              gp_Pnt& aP3D) ;
145   Standard_EXPORT
146     static  Standard_Boolean ProjectPointOnShape(const gp_Pnt& aP1,
147                                                  const TopoDS_Shape& aS,
148                                                  gp_Pnt& aP2,
149 #if OCC_VERSION_LARGE > 0x06070100
150                                                  const Handle(IntTools_Context)& aCtx
151 #else
152                                                  const Handle(BOPInt_Context)& aCtx
153 #endif
154                                                  ) ;
155
156   Standard_EXPORT
157     static void CorrectTolerances(const TopoDS_Shape& aShape,
158                                   const Standard_Real aMaxTol=0.0001);
159
160   Standard_EXPORT
161     static void CorrectPointOnCurve(const TopoDS_Shape& S,
162                                     const Standard_Real aMaxTol=0.0001);
163
164   Standard_EXPORT
165     static void CorrectCurveOnSurface(const TopoDS_Shape& S,
166                                       const Standard_Real aMaxTol=0.0001);
167
168
169   Standard_EXPORT
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
174 #else
175                                                const Handle(BOPInt_Context)& aCtx
176 #endif
177                                                ) ;
178   Standard_EXPORT
179     static void RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE,
180                                           const TopoDS_Face& aF,
181                                           const Standard_Real aUMin,
182                                           const Standard_Real aUMax);
183
184   Standard_EXPORT
185     static Standard_Boolean IsUPeriodic(const Handle(Geom_Surface) &aS);
186   
187   Standard_EXPORT
188     static void MakeContainer(const TopAbs_ShapeEnum theType,
189                               TopoDS_Shape& theC);
190
191   Standard_EXPORT
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
196 #else
197                                              const Handle(BOPInt_Context)& theCtx
198 #endif
199                                              ) ;
200   
201   Standard_EXPORT
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
206 #else
207                                                const Handle(BOPInt_Context)& theCtx
208 #endif
209                                                ) ;
210   
211   Standard_EXPORT
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
216 #else
217                                                const Handle(BOPInt_Context)& theCtx
218 #endif
219                                                ) ;
220   Standard_EXPORT
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
226 #else
227                                                        const Handle(BOPInt_Context)& aCtx
228 #endif
229                                                        ) ;
230
231 //
232   Standard_EXPORT
233     static void FindChains(const GEOMAlgo_ListOfCoupleOfShapes& aLCS,
234                            GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains);
235
236   Standard_EXPORT
237     static void FindChains(const GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMCV,
238                            GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains);
239
240   Standard_EXPORT
241     static  void CopyShape(const TopoDS_Shape& aS,
242                            TopoDS_Shape& aSC) ;
243   
244   Standard_EXPORT
245     static  void CopyShape(const TopoDS_Shape& aS,
246                            TopoDS_Shape& aSC,
247                            TopTools_IndexedDataMapOfShapeShape& aMSS) ;
248 };
249 #endif