62399568f9535c6c22a92687955385c9b7d7bce5
[occt.git] / src / BOPAlgo / BOPAlgo_PaveFiller.hxx
1 // Created by: Peter KURNEV
2 // Copyright (c) 2010-2014 OPEN CASCADE SAS
3 // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
5 //                         EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 //
7 // This file is part of Open CASCADE Technology software library.
8 //
9 // This library is free software; you can redistribute it and/or modify it under
10 // the terms of the GNU Lesser General Public License version 2.1 as published
11 // by the Free Software Foundation, with special exception defined in the file
12 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
13 // distribution for complete text of the license and disclaimer of any warranty.
14 //
15 // Alternatively, this file may be used under the terms of Open CASCADE
16 // commercial license or contractual agreement.
17
18 #ifndef _BOPAlgo_PaveFiller_HeaderFile
19 #define _BOPAlgo_PaveFiller_HeaderFile
20
21 #include <Standard.hxx>
22 #include <Standard_DefineAlloc.hxx>
23 #include <Standard_Handle.hxx>
24
25 #include <BOPCol_ListOfShape.hxx>
26 #include <BOPDS_PDS.hxx>
27 #include <BOPDS_PIterator.hxx>
28 #include <BOPAlgo_SectionAttribute.hxx>
29 #include <Standard_Real.hxx>
30 #include <BOPAlgo_Algo.hxx>
31 #include <BOPCol_BaseAllocator.hxx>
32 #include <TopAbs_ShapeEnum.hxx>
33 #include <Standard_Integer.hxx>
34 #include <BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks.hxx>
35 #include <Standard_Boolean.hxx>
36 #include <BOPCol_MapOfInteger.hxx>
37 #include <BOPCol_DataMapOfIntegerReal.hxx>
38 #include <BOPCol_ListOfInteger.hxx>
39 #include <BOPDS_IndexedMapOfPaveBlock.hxx>
40 #include <BOPCol_DataMapOfShapeInteger.hxx>
41 #include <BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx>
42 #include <BOPCol_DataMapOfIntegerInteger.hxx>
43 #include <BOPDS_ListOfPaveBlock.hxx>
44 #include <IntSurf_ListOfPntOn2S.hxx>
45 #include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
46 #include <BOPDS_MapOfPaveBlock.hxx>
47 #include <BOPCol_IndexedDataMapOfShapeInteger.hxx>
48 #include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
49 class IntTools_Context;
50 class BOPDS_DS;
51 class BOPAlgo_SectionAttribute;
52 class BOPDS_PaveBlock;
53 class TopoDS_Vertex;
54 class gp_Pnt;
55 class BOPDS_Curve;
56 class TopoDS_Face;
57
58
59
60 class BOPAlgo_PaveFiller  : public BOPAlgo_Algo
61 {
62 public:
63
64   DEFINE_STANDARD_ALLOC
65
66   
67   Standard_EXPORT BOPAlgo_PaveFiller();
68 Standard_EXPORT virtual ~BOPAlgo_PaveFiller();
69   
70   Standard_EXPORT BOPAlgo_PaveFiller(const BOPCol_BaseAllocator& theAllocator);
71   
72   Standard_EXPORT const BOPDS_DS& DS();
73   
74   Standard_EXPORT BOPDS_PDS PDS();
75   
76   Standard_EXPORT const BOPDS_PIterator& Iterator();
77   
78   Standard_EXPORT void SetArguments (const BOPCol_ListOfShape& theLS);
79   
80   Standard_EXPORT const BOPCol_ListOfShape& Arguments() const;
81   
82   Standard_EXPORT Handle(IntTools_Context) Context();
83   
84   Standard_EXPORT void SetSectionAttribute (const BOPAlgo_SectionAttribute& theSecAttr);
85   
86   Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
87   
88   //! Sets the additional tolerance
89   Standard_EXPORT void SetFuzzyValue (const Standard_Real theFuzz);
90   
91   //! Returns the additional tolerance
92   Standard_EXPORT Standard_Real FuzzyValue() const;
93
94
95
96
97 protected:
98
99   
100   Standard_EXPORT virtual void PerformInternal();
101   
102   Standard_EXPORT virtual void Clear();
103   
104   Standard_EXPORT virtual void Init();
105   
106   Standard_EXPORT void Prepare();
107   
108   Standard_EXPORT virtual void PerformVV();
109   
110   Standard_EXPORT virtual void PerformVE();
111   
112   Standard_EXPORT virtual void PerformVF();
113   
114   Standard_EXPORT virtual void PerformEE();
115   
116   Standard_EXPORT virtual void PerformEF();
117   
118   Standard_EXPORT virtual void PerformFF();
119   
120   Standard_EXPORT virtual void PerformVZ();
121   
122   Standard_EXPORT virtual void PerformEZ();
123   
124   Standard_EXPORT virtual void PerformFZ();
125   
126   Standard_EXPORT virtual void PerformZZ();
127
128   Standard_EXPORT virtual void PerformSZ(const TopAbs_ShapeEnum aTS);
129   
130   Standard_EXPORT void TreatVerticesEE();
131   
132   Standard_EXPORT void MakeSplitEdges();
133   
134   Standard_EXPORT void MakeBlocks();
135   
136   Standard_EXPORT void MakePCurves();
137   
138   Standard_EXPORT void ProcessDE();
139   
140   Standard_EXPORT void FillShrunkData (Handle(BOPDS_PaveBlock)& thePB);
141   
142   Standard_EXPORT void FillShrunkData (const TopAbs_ShapeEnum theType1, const TopAbs_ShapeEnum theType2);
143   
144   Standard_EXPORT Standard_Integer PerformVerticesEE (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB, const BOPCol_BaseAllocator& theAllocator);
145   
146   Standard_EXPORT Standard_Integer PerformVerticesEF (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB, const BOPCol_BaseAllocator& theAllocator);
147   
148   Standard_EXPORT Standard_Boolean CheckFacePaves (const TopoDS_Vertex& theVnew, const BOPCol_MapOfInteger& theMIF);
149   
150   Standard_EXPORT static Standard_Boolean CheckFacePaves (const Standard_Integer theN, const BOPCol_MapOfInteger& theMIFOn, const BOPCol_MapOfInteger& theMIFIn);
151   
152   Standard_EXPORT Standard_Boolean IsExistingVertex (const gp_Pnt& theP, const Standard_Real theTol, const BOPCol_MapOfInteger& theMVOn) const;
153   
154
155   //! Checks and puts paves from <theMVOn> on the curve <theNC>.
156   Standard_EXPORT void PutPavesOnCurve (const BOPCol_MapOfInteger& theMVOn, const Standard_Real theTolR3D, BOPDS_Curve& theNC, const Standard_Integer nF1, const Standard_Integer nF2, const BOPCol_MapOfInteger& theMI, const BOPCol_MapOfInteger& theMVEF, BOPCol_DataMapOfIntegerReal& theMVTol);
157   
158
159   //! Depending on the parameter aType it checks whether
160   //! the vertex nV was created in EE or EF intersections.
161   //! If so, it increases aTolVExt from tolerance value of vertex to
162   //! the max distance from vertex nV to the ends of the range of common part.
163   //! Possible values of aType:
164   //! 1 - checks only EE;
165   //! 2 - checks only EF;
166   //! other - checks both types of intersections.
167   Standard_EXPORT Standard_Boolean ExtendedTolerance (const Standard_Integer nV, const BOPCol_MapOfInteger& aMI, Standard_Real& aTolVExt, const Standard_Integer aType = 0);
168   
169   Standard_EXPORT void PutBoundPaveOnCurve (const TopoDS_Face& theF1, const TopoDS_Face& theF2, const Standard_Real theTolR3D, BOPDS_Curve& theNC, BOPCol_ListOfInteger& theLBV);
170   
171   Standard_EXPORT Standard_Boolean IsExistingPaveBlock (const Handle(BOPDS_PaveBlock)& thePB, const BOPDS_Curve& theNC, const Standard_Real theTolR3D, const BOPDS_IndexedMapOfPaveBlock& theMPB, Handle(BOPDS_PaveBlock)& thePBOut);
172   
173   Standard_EXPORT Standard_Boolean IsExistingPaveBlock (const Handle(BOPDS_PaveBlock)& thePB, const BOPDS_Curve& theNC, const Standard_Real theTolR3D, const BOPCol_ListOfInteger& theLSE);
174   
175
176   //! Treatment of section edges.
177   Standard_EXPORT Standard_Integer PostTreatFF (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB, BOPCol_DataMapOfShapeInteger& theMVI, BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDMExEdges, BOPCol_DataMapOfIntegerInteger& theDMI, const BOPCol_BaseAllocator& theAllocator);
178   
179   Standard_EXPORT void FindPaveBlocks (const Standard_Integer theV, const Standard_Integer theF, BOPDS_ListOfPaveBlock& theLPB);
180   
181   Standard_EXPORT void FillPaves (const Standard_Integer theV, const Standard_Integer theE, const Standard_Integer theF, const BOPDS_ListOfPaveBlock& theLPB, const Handle(BOPDS_PaveBlock)& thePB);
182   
183   Standard_EXPORT void MakeSplitEdge (const Standard_Integer theV, const Standard_Integer theF);
184   
185   Standard_EXPORT void GetEFPnts (const Standard_Integer nF1, const Standard_Integer nF2, IntSurf_ListOfPntOn2S& aListOfPnts);
186   
187
188   //! Checks and puts paves created in EF intersections on the curve <theNC>.
189   Standard_EXPORT void PutEFPavesOnCurve (BOPDS_Curve& theNC, const BOPCol_MapOfInteger& theMI, const BOPCol_MapOfInteger& theMVEF, BOPCol_DataMapOfIntegerReal& theMVTol);
190   
191
192   //! Puts stick paves on the curve <theNC>
193   Standard_EXPORT void PutStickPavesOnCurve (const TopoDS_Face& aF1, const TopoDS_Face& aF2, const BOPCol_MapOfInteger& theMI, BOPDS_Curve& theNC, const BOPCol_MapOfInteger& theMVStick, BOPCol_DataMapOfIntegerReal& theMVTol);
194   
195
196   //! Collects indices of vertices created in all intersections between
197   //! two faces (<nF1> and <nF2>) to the map <theMVStick>.
198   //! Also, it collects indices of EF vertices to the <theMVEF> map
199   //! and indices of all subshapes of these two faces to the <theMI> map.
200   Standard_EXPORT void GetStickVertices (const Standard_Integer nF1, const Standard_Integer nF2, BOPCol_MapOfInteger& theMVStick, BOPCol_MapOfInteger& theMVEF, BOPCol_MapOfInteger& theMI);
201   
202
203   //! Collects index nF and indices of all subshapes of the shape with index <nF>
204   //! to the map <theMI>.
205   Standard_EXPORT void GetFullShapeMap (const Standard_Integer nF, BOPCol_MapOfInteger& theMI);
206   
207
208   //! Removes indices of vertices that are already on the
209   //! curve <theNC> from the map <theMV>.
210   //! It is used in PutEFPavesOnCurve and PutStickPavesOnCurve methods.
211   Standard_EXPORT void RemoveUsedVertices (BOPDS_Curve& theNC, BOPCol_MapOfInteger& theMV);
212   
213
214   //! Puts the pave nV on the curve theNC.
215   //! Parameter aType defines whether to check the pave with
216   //! extended tolerance:
217   //! 0 - do not perform the check;
218   //! other - perform the check (aType goes to ExtendedTolerance).
219   Standard_EXPORT void PutPaveOnCurve (const Standard_Integer nV, const Standard_Real theTolR3D, BOPDS_Curve& theNC, const BOPCol_MapOfInteger& theMI, BOPCol_DataMapOfIntegerReal& theMVTol, const Standard_Integer aType = 0);
220   
221
222   //! Adds the existing edges from the map <theMPBOnIn> which interfere
223   //! with the vertices from <theMVB> map to the post treatment of section edges.
224   Standard_EXPORT void ProcessExistingPaveBlocks (const Standard_Integer theInt, const BOPDS_IndexedMapOfPaveBlock& theMPBOnIn, const BOPCol_DataMapOfIntegerListOfInteger& theDMBV, BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB, BOPCol_DataMapOfShapeInteger& theMVI, BOPDS_MapOfPaveBlock& theMPB);
225   
226
227   //! Replaces existing pave block <thePB> with new pave blocks <theLPB>.
228   //! The list <theLPB> contains images of <thePB> which were created in
229   //! the post treatment of section edges.
230   Standard_EXPORT void UpdateExistingPaveBlocks (const Handle(BOPDS_PaveBlock)& thePB, BOPDS_ListOfPaveBlock& theLPB, const Standard_Integer nF1, const Standard_Integer nF2);
231   
232
233   //! Treatment of vertices that were created in EE intersections.
234   Standard_EXPORT void TreatNewVertices (const BOPCol_IndexedDataMapOfShapeInteger& theMVI, BOPCol_IndexedDataMapOfShapeListOfShape& theImages);
235   
236
237   //! Put paves on the curve <aBC> in case when <aBC>
238   //! is closed 3D-curve
239   Standard_EXPORT void PutClosingPaveOnCurve (BOPDS_Curve& aNC);
240   
241
242   //! Keeps data for post treatment
243   Standard_EXPORT void PreparePostTreatFF (const Standard_Integer aInt, const Standard_Integer aCur, const Handle(BOPDS_PaveBlock)& aPB, BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB, BOPCol_DataMapOfShapeInteger& aMVI, BOPDS_ListOfPaveBlock& aLPB);
244   
245
246   //! Refines the state On for the all faces having
247   //! state information
248   Standard_EXPORT void RefineFaceInfoOn();
249   
250
251   //! Updates the information about faces
252   Standard_EXPORT void UpdateFaceInfo (BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDME, const BOPCol_DataMapOfIntegerInteger& theDMV);
253   
254
255   //! Updates tolerance of vertex with index <nV>
256   //! to make it interfere with edge
257   Standard_EXPORT void ForceInterfVE (const Standard_Integer nV, Handle(BOPDS_PaveBlock)& aPB, BOPDS_MapOfPaveBlock& aMPB);
258   
259
260   //! Updates tolerance of vertex with index <nV>
261   //! to make it interfere with face with index <nF>
262   Standard_EXPORT Standard_Boolean ForceInterfVF (const Standard_Integer nV, const Standard_Integer nF);
263   
264
265   //! Checks if there are any common or intersecting sub shapes
266   //! between two planar faces.
267   Standard_EXPORT Standard_Boolean CheckPlanes (const Standard_Integer nF1, const Standard_Integer nF2) const;
268   
269
270   //! Creates new edge from the edge nE with vertices nV1 and nV2
271   //! and returns the index of that new edge in the DS.
272   Standard_EXPORT Standard_Integer SplitEdge (const Standard_Integer nE, const Standard_Integer nV1, const Standard_Real aT1, const Standard_Integer nV2, const Standard_Real aT2);
273   
274
275   //! Updates pave blocks which have the paves with indices contained
276   //! in the map <theDMI>.
277   Standard_EXPORT void UpdatePaveBlocks (const BOPCol_DataMapOfIntegerInteger& theDMI);
278
279
280   BOPCol_ListOfShape myArguments;
281   BOPDS_PDS myDS;
282   BOPDS_PIterator myIterator;
283   Handle(IntTools_Context) myContext;
284   BOPAlgo_SectionAttribute mySectionAttribute;
285   Standard_Real myFuzzyValue;
286
287
288 private:
289
290
291
292
293
294 };
295
296
297
298
299
300
301
302 #endif // _BOPAlgo_PaveFiller_HeaderFile