Salome HOME
Merge from BR_new_bop4 (porting to new OCCT BOP) 13/09/2013
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_AlgoTools.hxx
1 // Copyright (C) 2007-2012  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.
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 <Standard.hxx>
30 #include <Standard_Macro.hxx>
31 #include <Standard_Boolean.hxx>
32 #include <Handle_BOPInt_Context.hxx>
33 #include <Standard_Integer.hxx>
34
35 #include <gp_Pnt.hxx>
36 #include <gp_Pnt2d.hxx>
37
38 #include <Geom_Surface.hxx>
39
40 #include <TopAbs_ShapeEnum.hxx>
41
42 #include <TopoDS_Face.hxx>
43 #include <TopoDS_Shape.hxx>
44 #include <TopoDS_Edge.hxx>
45
46 #include <BOPInt_Context.hxx>
47
48 #include <TopTools_ListOfShape.hxx>
49 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
50 #include <TopTools_ListOfShape.hxx>
51 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
52
53 #include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>
54 #include <GEOMAlgo_ListOfCoupleOfShapes.hxx>
55 #include <GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
56
57 //!  Auxiliary tools for Algorithms <br>
58 //=======================================================================
59 //class    : GEOMAlgo_AlgoTools
60 //purpose  :
61 //=======================================================================
62 class GEOMAlgo_AlgoTools  {
63  public:
64
65   Standard_EXPORT
66     static void FaceNormal (const TopoDS_Face& aF,
67                             const Standard_Real U,
68                             const Standard_Real V,
69                             gp_Vec& aN);
70
71   //! Computes a point <theP> inside the face <theF>. <br>
72   //!          <theP2D> -  2D  representation of <theP> <br>
73   //!          on the surface of <theF> <br>
74   //!          Returns 0 in case of success. <br>
75   Standard_EXPORT
76     static  Standard_Integer PntInFace(const TopoDS_Face& theF,
77                                        gp_Pnt& theP,
78                                        gp_Pnt2d& theP2D) ;
79
80   Standard_EXPORT
81     static  Standard_Boolean IsCompositeShape(const TopoDS_Shape& aS) ;
82
83
84   Standard_EXPORT
85     static  Standard_Boolean BuildTriangulation(const TopoDS_Shape& aS) ;
86
87   Standard_EXPORT
88     static  Standard_Integer RefineSDShapes
89       (GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape& aMSD,
90        const Standard_Real aTol,
91        const Handle(BOPInt_Context)& aCtx) ;
92
93   Standard_EXPORT
94     static  Standard_Integer FindSDShapes(const TopTools_ListOfShape& aLE,
95                                           const Standard_Real aTol,
96                                           TopTools_IndexedDataMapOfShapeListOfShape& aMEE,
97                                           const Handle(BOPInt_Context)& aCtx) ;
98
99   Standard_EXPORT
100     static  Standard_Integer FindSDShapes(const TopoDS_Shape& aE1,
101                                           const TopTools_ListOfShape& aLE,
102                                           const Standard_Real aTol,
103                                           TopTools_ListOfShape& aLESD,
104                                           const Handle(BOPInt_Context)& aCtx) ;
105
106   Standard_EXPORT
107     static  void PointOnShape(const TopoDS_Shape& aS,
108                               gp_Pnt& aP3D) ;
109
110   Standard_EXPORT
111     static  void PointOnEdge(const TopoDS_Edge& aE,
112                              gp_Pnt& aP3D) ;
113
114   Standard_EXPORT
115     static  void PointOnEdge(const TopoDS_Edge& aE,
116                              const Standard_Real aT,gp_Pnt& aP3D) ;
117
118   Standard_EXPORT
119     static  void PointOnFace(const TopoDS_Face& aF,
120                              gp_Pnt& aP3D) ;
121
122   Standard_EXPORT
123     static  void PointOnFace(const TopoDS_Face& aF,
124                              const Standard_Real aU,
125                              const Standard_Real aV,
126                              gp_Pnt& aP3D) ;
127   Standard_EXPORT
128     static  Standard_Boolean ProjectPointOnShape(const gp_Pnt& aP1,
129                                                  const TopoDS_Shape& aS,
130                                                  gp_Pnt& aP2,
131                                                  const Handle(BOPInt_Context)& aCtx) ;
132
133   Standard_EXPORT
134     static void CorrectTolerances(const TopoDS_Shape& aShape,
135                                   const Standard_Real aMaxTol=0.0001);
136
137   Standard_EXPORT
138     static void CorrectPointOnCurve(const TopoDS_Shape& S,
139                                     const Standard_Real aMaxTol=0.0001);
140
141   Standard_EXPORT
142     static void CorrectCurveOnSurface(const TopoDS_Shape& S,
143                                       const Standard_Real aMaxTol=0.0001);
144
145
146   Standard_EXPORT
147     static Standard_Boolean IsSplitToReverse1 (const TopoDS_Edge& aEF1,
148                                                const TopoDS_Edge& aEF2,
149                                                const Handle(BOPInt_Context)& aContext);
150   Standard_EXPORT
151     static void RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE,
152                                           const TopoDS_Face& aF,
153                                           const Standard_Real aUMin,
154                                           const Standard_Real aUMax);
155
156   Standard_EXPORT
157     static Standard_Boolean IsUPeriodic(const Handle(Geom_Surface) &aS);
158   
159   Standard_EXPORT
160     static void MakeContainer(const TopAbs_ShapeEnum theType,
161                               TopoDS_Shape& theC);
162
163   Standard_EXPORT
164     static Standard_Boolean IsSplitToReverse(const TopoDS_Edge& theSplit,
165                                              const TopoDS_Edge& theEdge,
166                                              const Handle(BOPInt_Context)& theContext);
167   
168   Standard_EXPORT
169     static Standard_Boolean IsSplitToReverse  (const TopoDS_Face& theFSp,
170                                                const TopoDS_Face& theFSr,
171                                                const Handle(BOPInt_Context)& theContext);
172   
173   Standard_EXPORT
174     static Standard_Boolean IsSplitToReverse  (const TopoDS_Shape& theSp,
175                                                const TopoDS_Shape& theSr,
176                                                const Handle(BOPInt_Context)& theCtx);
177   Standard_EXPORT
178     static Standard_Integer BuildPCurveForEdgeOnFace  (const TopoDS_Edge& aEold,
179                                                        const TopoDS_Edge& aEnew,
180                                                        const TopoDS_Face& aF,
181                                                        const Handle(BOPInt_Context)& aCtx);
182
183 //
184   Standard_EXPORT
185     static void FindChains(const GEOMAlgo_ListOfCoupleOfShapes& aLCS,
186                            GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains);
187
188   Standard_EXPORT
189     static void FindChains(const GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMCV,
190                            GEOMAlgo_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains);
191
192   Standard_EXPORT
193     static  void CopyShape(const TopoDS_Shape& aS,
194                            TopoDS_Shape& aSC) ;
195   
196   Standard_EXPORT
197     static  void CopyShape(const TopoDS_Shape& aS,
198                            TopoDS_Shape& aSC,
199                            TopTools_IndexedDataMapOfShapeShape& aMSS) ;
200 };
201 #endif