0031148: Modeling Algorithms - Offset adjacent co-planar faces with different offset...
[occt.git] / src / BRepOffset / BRepOffset_MakeOffset.hxx
1 // Created on: 1995-10-26
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_MakeOffset_HeaderFile
18 #define _BRepOffset_MakeOffset_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Real.hxx>
25 #include <TopoDS_Shape.hxx>
26 #include <BRepOffset_Mode.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <GeomAbs_JoinType.hxx>
29 #include <TopTools_DataMapOfShapeReal.hxx>
30 #include <TopTools_IndexedMapOfShape.hxx>
31 #include <BRepOffset_Analyse.hxx>
32 #include <BRepAlgo_Image.hxx>
33 #include <TopTools_ListOfShape.hxx>
34 #include <BRepOffset_Error.hxx>
35 #include <BRepOffset_MakeLoops.hxx>
36 #include <TopTools_MapOfShape.hxx>
37 #include <BRepOffset_DataMapOfShapeOffset.hxx>
38 class BRepAlgo_AsDes;
39 class TopoDS_Shape;
40 class TopoDS_Face;
41 class BRepOffset_Analyse;
42 class BRepAlgo_Image;
43 class BRepOffset_Inter3d;
44
45
46
47 class BRepOffset_MakeOffset 
48 {
49 public:
50
51   DEFINE_STANDARD_ALLOC
52
53   
54   Standard_EXPORT BRepOffset_MakeOffset();
55   
56   Standard_EXPORT BRepOffset_MakeOffset(const TopoDS_Shape& S,
57                                         const Standard_Real Offset,
58                                         const Standard_Real Tol,
59                                         const BRepOffset_Mode Mode = BRepOffset_Skin,
60                                         const Standard_Boolean Intersection = Standard_False,
61                                         const Standard_Boolean SelfInter = Standard_False,
62                                         const GeomAbs_JoinType Join = GeomAbs_Arc,
63                                         const Standard_Boolean Thickening = Standard_False,
64                                         const Standard_Boolean RemoveIntEdges = Standard_False);
65   
66   Standard_EXPORT void Initialize (const TopoDS_Shape& S,
67                                    const Standard_Real Offset,
68                                    const Standard_Real Tol,
69                                    const BRepOffset_Mode Mode = BRepOffset_Skin,
70                                    const Standard_Boolean Intersection = Standard_False,
71                                    const Standard_Boolean SelfInter = Standard_False,
72                                    const GeomAbs_JoinType Join = GeomAbs_Arc,
73                                    const Standard_Boolean Thickening = Standard_False,
74                                    const Standard_Boolean RemoveIntEdges = Standard_False);
75   
76   Standard_EXPORT void Clear();
77   
78   //! Add Closing Faces,  <F>  has to be  in  the initial
79   //! shape S.
80   Standard_EXPORT void AddFace (const TopoDS_Face& F);
81   
82   //! set the offset <Off> on the Face <F>
83   Standard_EXPORT void SetOffsetOnFace (const TopoDS_Face& F, const Standard_Real Off);
84   
85   Standard_EXPORT void MakeOffsetShape();
86   
87   Standard_EXPORT void MakeThickSolid();
88   
89   Standard_EXPORT const BRepOffset_Analyse& GetAnalyse() const;
90   
91   Standard_EXPORT Standard_Boolean IsDone() const;
92   
93   Standard_EXPORT const TopoDS_Shape& Shape() const;
94   
95   const TopoDS_Shape& InitShape() const
96   {
97     return myShape;
98   }
99
100   //! returns information about offset state.
101   Standard_EXPORT BRepOffset_Error Error() const;
102   
103   //! Returns <Image> containing links between initials
104   //! shapes and offset faces.
105   Standard_EXPORT const BRepAlgo_Image& OffsetFacesFromShapes() const;
106   
107   //! Returns myJoin.
108   Standard_EXPORT GeomAbs_JoinType GetJoinType() const;
109   
110   //! Returns <Image> containing links between initials
111   //! shapes and offset edges.
112   Standard_EXPORT const BRepAlgo_Image& OffsetEdgesFromShapes() const;
113   
114   //! Returns the list of closing faces stores by AddFace
115   Standard_EXPORT const TopTools_IndexedMapOfShape& ClosingFaces() const;
116
117   //! Makes pre analysis of possibility offset perform. Use method Error() to get more information.
118   //! Finds first error. List of checks:
119   //! 1) Check for existence object with non-null offset.
120   //! 2) Check for connectivity in offset shell.
121   //! 3) Check continuity of input surfaces.
122   //! 4) Check for normals existence on grid.
123   //! @return True if possible make computations and false otherwise.
124   Standard_EXPORT Standard_Boolean CheckInputData();
125
126   //! Return bad shape, which obtained in CheckInputData.
127   Standard_EXPORT const TopoDS_Shape& GetBadShape() const;
128
129 public: //! @name History methods
130
131   //! Returns the  list of shapes generated from the shape <S>.
132   Standard_EXPORT const TopTools_ListOfShape& Generated (const TopoDS_Shape& theS);
133   
134   //! Returns the list of shapes modified from the shape <S>.
135   Standard_EXPORT const TopTools_ListOfShape& Modified (const TopoDS_Shape& theS);
136   
137   //! Returns true if the shape S has been deleted.
138   Standard_EXPORT Standard_Boolean IsDeleted (const TopoDS_Shape& S);
139
140
141 protected:
142
143
144 private:
145
146   Standard_EXPORT void BuildOffsetByArc();
147   
148   Standard_EXPORT void BuildOffsetByInter();
149
150   //! Make Offset faces
151   Standard_EXPORT void MakeOffsetFaces(BRepOffset_DataMapOfShapeOffset& theMapSF);
152
153   Standard_EXPORT void SelfInter (TopTools_MapOfShape& Modif);
154   
155   Standard_EXPORT void Intersection3D (BRepOffset_Inter3d& Inter);
156   
157   Standard_EXPORT void Intersection2D (const TopTools_IndexedMapOfShape& Modif, const TopTools_IndexedMapOfShape& NewEdges);
158   
159   Standard_EXPORT void MakeLoops (TopTools_IndexedMapOfShape& Modif);
160   
161   Standard_EXPORT void MakeLoopsOnContext (TopTools_MapOfShape& Modif);
162   
163   Standard_EXPORT void MakeFaces (TopTools_IndexedMapOfShape& Modif);
164   
165   Standard_EXPORT void MakeShells();
166   
167   Standard_EXPORT void SelectShells();
168   
169   Standard_EXPORT void EncodeRegularity();
170   
171   //! Replace roots in history maps
172   Standard_EXPORT void ReplaceRoots();
173
174   Standard_EXPORT void MakeSolid();
175   
176   Standard_EXPORT void ToContext (BRepOffset_DataMapOfShapeOffset& MapSF);
177   
178   //! Private method use to update the map face<->offset
179   Standard_EXPORT void UpdateFaceOffset();
180   
181   //! Private method used to correct degenerated edges on conical faces
182   Standard_EXPORT void CorrectConicalFaces();
183   
184   //! Private method used to build walls for thickening the shell
185   Standard_EXPORT void MakeMissingWalls();
186
187   //! Removes INTERNAL edges from the result
188   Standard_EXPORT void RemoveInternalEdges();
189
190   //! Intersects edges
191   Standard_EXPORT void IntersectEdges (const TopTools_ListOfShape& theFaces,
192                                        BRepOffset_DataMapOfShapeOffset& theMapSF,
193                                        TopTools_DataMapOfShapeShape& theMES,
194                                        TopTools_DataMapOfShapeShape& theBuild,
195                                        Handle(BRepAlgo_AsDes)& theAsDes,
196                                        Handle(BRepAlgo_AsDes)& theAsDes2d);
197
198   //! Building of the splits of the offset faces for mode Complete
199   //! and joint type Intersection. This method is an advanced alternative
200   //! for BRepOffset_MakeLoops::Build method.
201   //! Currently the Complete intersection mode is limited to work only on planar cases.
202   Standard_EXPORT void BuildSplitsOfExtendedFaces(const TopTools_ListOfShape& theLF,
203                                                   const BRepOffset_Analyse& theAnalyse,
204                                                   Handle(BRepAlgo_AsDes)& theAsDes,
205                                                   TopTools_DataMapOfShapeListOfShape& theEdgesOrigins,
206                                                   TopTools_DataMapOfShapeShape& theFacesOrigins,
207                                                   TopTools_DataMapOfShapeShape& theETrimEInf,
208                                                   BRepAlgo_Image& theImage);
209
210   //! Building of the splits of the already trimmed offset faces for mode Complete
211   //! and joint type Intersection.
212   Standard_EXPORT void BuildSplitsOfTrimmedFaces(const TopTools_ListOfShape& theLF,
213                                                  Handle(BRepAlgo_AsDes)& theAsDes,
214                                                  BRepAlgo_Image& theImage);
215
216   Standard_Real myOffset;
217   Standard_Real myTol;
218   TopoDS_Shape myShape;
219   BRepOffset_Mode myMode;
220   Standard_Boolean myInter;
221   Standard_Boolean mySelfInter;
222   GeomAbs_JoinType myJoin;
223   Standard_Boolean myThickening;
224   Standard_Boolean myRemoveIntEdges;
225   TopTools_DataMapOfShapeReal myFaceOffset;
226   TopTools_IndexedMapOfShape myFaces;
227   BRepOffset_Analyse myAnalyse;
228   TopoDS_Shape myOffsetShape;
229   BRepAlgo_Image myInitOffsetFace;
230   BRepAlgo_Image myInitOffsetEdge;
231   BRepAlgo_Image myImageOffset;
232   TopTools_ListOfShape myWalls;
233   Handle(BRepAlgo_AsDes) myAsDes;
234   Standard_Boolean myDone;
235   BRepOffset_Error myError;
236   BRepOffset_MakeLoops myMakeLoops;
237   Standard_Boolean myIsPerformSewing; // Handle bad walls in thicksolid mode.
238   Standard_Boolean myIsPlanar;
239   TopoDS_Shape myBadShape;
240   TopTools_ListOfShape myGenerated;
241   TopTools_MapOfShape myResMap;
242 };
243
244 #endif // _BRepOffset_MakeOffset_HeaderFile