5ce1bc2704dfd036f2640f40c6980e9f6493f34f
[occt.git] / src / BRepOffset / BRepOffset_Tool.hxx
1 // Created on: 1995-10-23
2 // Created by: Yves FRICAUD
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _BRepOffset_Tool_HeaderFile
18 #define _BRepOffset_Tool_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <TopAbs_Orientation.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <TopTools_ListOfShape.hxx>
27 #include <TopAbs_State.hxx>
28 #include <Standard_Real.hxx>
29 #include <TopTools_DataMapOfShapeShape.hxx>
30 #include <TopTools_DataMapOfShapeListOfShape.hxx>
31 #include <TopTools_MapOfShape.hxx>
32 #include <TopTools_IndexedMapOfShape.hxx>
33 class TopoDS_Edge;
34 class TopoDS_Vertex;
35 class TopoDS_Face;
36 class BRepOffset_Analyse;
37 class TopoDS_Wire;
38 class TopoDS_Shape;
39 class BRepAlgo_AsDes;
40 class BRepAlgo_Image;
41 class Geom_Curve;
42
43
44
45 class BRepOffset_Tool 
46 {
47 public:
48
49   DEFINE_STANDARD_ALLOC
50
51   
52   //! <V1> is the FirstVertex ,<V2> is the Last Vertex of <Edge>
53   //! taking account the orientation of Edge.
54   Standard_EXPORT static void EdgeVertices (const TopoDS_Edge& E, TopoDS_Vertex& V1, TopoDS_Vertex& V2);
55   
56   //! returns the cumul  of the orientation  of <Edge>
57   //! and thc containing wire in <Face>
58   Standard_EXPORT static TopAbs_Orientation OriEdgeInFace (const TopoDS_Edge& E, const TopoDS_Face& F);
59   
60   //! <E> is a section  between <F1> and <F2>.  Computes
61   //! <O1> the orientation of <E> in <F1> influenced by <F2>.
62   //! idem for <O2>.
63   Standard_EXPORT static void OrientSection (const TopoDS_Edge& E,
64                                              const TopoDS_Face& F1,
65                                              const TopoDS_Face& F2,
66                                              TopAbs_Orientation& O1,
67                                              TopAbs_Orientation& O2);
68   
69   //! Looks for the common Vertices and Edges between faces <theF1> and <theF2>.<br>
70   //! Returns TRUE if common shapes have been found.<br>
71   //! <theLE> will contain the found common edges;<br>
72   //! <theLV> will contain the found common vertices.
73   Standard_EXPORT static Standard_Boolean FindCommonShapes(const TopoDS_Face& theF1,
74                                                            const TopoDS_Face& theF2,
75                                                            TopTools_ListOfShape& theLE,
76                                                            TopTools_ListOfShape& theLV);
77
78   //! Looks for the common shapes of type <theType> between shapes <theS1> and <theS2>.<br>
79   //! Returns TRUE if common shapes have been found.<br>
80   //! <theLSC> will contain the found common shapes.
81   Standard_EXPORT static Standard_Boolean FindCommonShapes(const TopoDS_Shape& theS1,
82                                                            const TopoDS_Shape& theS2,
83                                                            const TopAbs_ShapeEnum theType,
84                                                            TopTools_ListOfShape& theLSC);
85
86   //! Computes the   Section betwwen  <F1> and  <F2> the
87   //! edges solution   are  stored in <LInt1>  with  the
88   //! orientation on <F1>, the sames edges are stored in
89   //! <Lint2> with the orientation on <F2>.
90   Standard_EXPORT static void Inter3D (const TopoDS_Face& F1,
91                                        const TopoDS_Face& F2,
92                                        TopTools_ListOfShape& LInt1,
93                                        TopTools_ListOfShape& LInt2,
94                                        const TopAbs_State Side,
95                                        const TopoDS_Edge& RefEdge,
96                                        const Standard_Boolean IsRefEdgeDefined = Standard_False);
97   
98   //! Find if the edges <Edges> of the face <F2> are on
99   //! the face <F1>.
100   //! Set in <LInt1> <LInt2> the updated edges.
101   //! If all the edges are computed, returns true.
102   Standard_EXPORT static Standard_Boolean TryProject (const TopoDS_Face& F1,
103                                                       const TopoDS_Face& F2,
104                                                       const TopTools_ListOfShape& Edges,
105                                                       TopTools_ListOfShape& LInt1,
106                                                       TopTools_ListOfShape& LInt2,
107                                                       const TopAbs_State Side,
108                                                       const Standard_Real TolConf);
109   
110   Standard_EXPORT static void PipeInter (const TopoDS_Face& F1,
111                                          const TopoDS_Face& F2,
112                                          TopTools_ListOfShape& LInt1,
113                                          TopTools_ListOfShape& LInt2,
114                                          const TopAbs_State Side);
115   
116   Standard_EXPORT static void Inter2d (const TopoDS_Face& F,
117                                        const TopoDS_Edge& E1,
118                                        const TopoDS_Edge& E2,
119                                        TopTools_ListOfShape& LV,
120                                        const Standard_Real Tol);
121   
122   Standard_EXPORT static void InterOrExtent (const TopoDS_Face& F1,
123                                              const TopoDS_Face& F2,
124                                              TopTools_ListOfShape& LInt1,
125                                              TopTools_ListOfShape& LInt2,
126                                              const TopAbs_State Side);
127   
128   Standard_EXPORT static void CheckBounds (const TopoDS_Face& F,
129                                            const BRepOffset_Analyse& Analyse,
130                                            Standard_Boolean& enlargeU,
131                                            Standard_Boolean& enlargeVfirst,
132                                            Standard_Boolean& enlargeVlast);
133   
134   //! if <ChangeGeom> is TRUE  ,   the surface  can  be
135   //! changed .
136   //! if <UpdatePCurve>  is  TRUE, update the  pcurves of the
137   //! edges of <F> on   the new surface.if the surface has  been changed,
138   //! Returns  True if The Surface of  <NF> has changed.
139   //! <ExtensionMode> is a mode of extension of the surface of the face:
140   //! if <ExtensionMode> equals 1, potentially infinite surfaces are extended by maximum value,
141   //! and limited surfaces are extended by 25%.
142   //! if <ExtensionMode> equals 2, potentially infinite surfaces are extended by
143   //! 10*(correspondent size of face),
144   //! and limited surfaces are extended by 100%.
145   Standard_EXPORT static Standard_Boolean EnLargeFace (const TopoDS_Face& F,
146                                                        TopoDS_Face& NF,
147                                                        const Standard_Boolean ChangeGeom,
148                                                        const Standard_Boolean UpDatePCurve = Standard_False,
149                                                        const Standard_Boolean enlargeU = Standard_True,
150                                                        const Standard_Boolean enlargeVfirst = Standard_True,
151                                                        const Standard_Boolean enlargeVlast = Standard_True,
152                                                        const Standard_Integer ExtensionMode = 1);
153   
154   Standard_EXPORT static void ExtentFace (const TopoDS_Face& F,
155                                           TopTools_DataMapOfShapeShape& ConstShapes,
156                                           TopTools_DataMapOfShapeShape& ToBuild,
157                                           const TopAbs_State Side,
158                                           const Standard_Real TolConf,
159                                           TopoDS_Face& NF);
160   
161   //! Via the wire explorer store in <NOnV1> for
162   //! an Edge <E> of <W> his Edge neighbour on the first
163   //! vertex <V1> of <E>.
164   //! Store in NOnV2 the Neighbour of <E>on the last
165   //! vertex <V2> of <E>.
166   Standard_EXPORT static void BuildNeighbour (const TopoDS_Wire& W,
167                                               const TopoDS_Face& F,
168                                               TopTools_DataMapOfShapeShape& NOnV1,
169                                               TopTools_DataMapOfShapeShape& NOnV2);
170   
171   //! Store in MVE for a vertex <V>  in <S> the incident
172   //! edges <E> in <S>.
173   //! An Edge is Store only one Time for a vertex.
174   Standard_EXPORT static void MapVertexEdges (const TopoDS_Shape& S,
175                                               TopTools_DataMapOfShapeListOfShape& MVE);
176   
177   //! Remove the non valid   part of an offsetshape
178   //! 1 - Remove all the free boundary  and the faces
179   //! connex to such edges.
180   //! 2 - Remove all the shapes not  valid in the result
181   //! (according to the side of offseting)
182   //! in this verion only the first point is implemented.
183   Standard_EXPORT static TopoDS_Shape Deboucle3D (const TopoDS_Shape& S,
184                                                   const TopTools_MapOfShape& Boundary);
185   
186   Standard_EXPORT static void CorrectOrientation (const TopoDS_Shape& SI,
187                                                   const TopTools_IndexedMapOfShape& NewEdges,
188                                                   Handle(BRepAlgo_AsDes)& AsDes,
189                                                   BRepAlgo_Image& InitOffset,
190                                                   const Standard_Real Offset);
191   
192   Standard_EXPORT static Standard_Real Gabarit (const Handle(Geom_Curve)& aCurve);
193
194   //! Compares the normal directions of the planar faces and returns
195   //! TRUE if the directions are the same with the given precision.<br>
196   Standard_EXPORT static Standard_Boolean CheckPlanesNormals(const TopoDS_Face& theFace1,
197                                                              const TopoDS_Face& theFace2,
198                                                              const Standard_Real theTolAng = 1.e-8);
199
200 protected:
201
202 private:
203
204 };
205
206 #endif // _BRepOffset_Tool_HeaderFile