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
7 // This file is part of Open CASCADE Technology software library.
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.
15 // Alternatively, this file may be used under the terms of Open CASCADE
16 // commercial license or contractual agreement.
18 #ifndef _BOPAlgo_PaveFiller_HeaderFile
19 #define _BOPAlgo_PaveFiller_HeaderFile
21 #include <Standard.hxx>
22 #include <Standard_DefineAlloc.hxx>
23 #include <Standard_Handle.hxx>
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_IndexedMapOfShape.hxx>
37 #include <BOPCol_MapOfInteger.hxx>
38 #include <BOPCol_DataMapOfIntegerReal.hxx>
39 #include <BOPCol_ListOfInteger.hxx>
40 #include <BOPDS_IndexedMapOfPaveBlock.hxx>
41 #include <BOPCol_DataMapOfShapeInteger.hxx>
42 #include <BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx>
43 #include <BOPCol_DataMapOfIntegerInteger.hxx>
44 #include <BOPDS_ListOfPaveBlock.hxx>
45 #include <IntSurf_ListOfPntOn2S.hxx>
46 #include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
47 #include <BOPDS_MapOfPaveBlock.hxx>
48 #include <BOPCol_IndexedDataMapOfShapeInteger.hxx>
49 #include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
50 class IntTools_Context;
52 class BOPAlgo_SectionAttribute;
53 class BOPDS_PaveBlock;
54 class BOPDS_CommonBlock;
62 class BOPAlgo_PaveFiller : public BOPAlgo_Algo
69 Standard_EXPORT BOPAlgo_PaveFiller();
71 Standard_EXPORT virtual ~BOPAlgo_PaveFiller();
73 Standard_EXPORT BOPAlgo_PaveFiller(const BOPCol_BaseAllocator& theAllocator);
75 Standard_EXPORT const BOPDS_DS& DS();
77 Standard_EXPORT BOPDS_PDS PDS();
79 Standard_EXPORT const BOPDS_PIterator& Iterator();
81 Standard_EXPORT void SetArguments (const BOPCol_ListOfShape& theLS);
83 Standard_EXPORT const BOPCol_ListOfShape& Arguments() const;
85 Standard_EXPORT Handle(IntTools_Context) Context();
87 Standard_EXPORT void SetSectionAttribute (const BOPAlgo_SectionAttribute& theSecAttr);
89 //! Sets the flag that defines the mode of treatment.
90 //! In non-destructive mode the argument shapes are not modified. Instead
91 //! a copy of a sub-shape is created in the result if it is needed to be updated.
92 Standard_EXPORT void SetNonDestructive(const Standard_Boolean theFlag);
94 //! Returns the flag that defines the mode of treatment.
95 //! In non-destructive mode the argument shapes are not modified. Instead
96 //! a copy of a sub-shape is created in the result if it is needed to be updated.
97 Standard_EXPORT Standard_Boolean NonDestructive() const;
99 Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
101 //! Sets the additional tolerance
102 Standard_EXPORT void SetFuzzyValue (const Standard_Real theFuzz);
104 //! Returns the additional tolerance
105 Standard_EXPORT Standard_Real FuzzyValue() const;
112 typedef NCollection_DataMap
113 <Handle(BOPDS_PaveBlock),
115 TColStd_MapTransientHasher> BOPAlgo_DataMapOfPaveBlockBndBox;
118 //! Sets non-destructive mode automatically if an argument
119 //! contains a locked sub-shape (see TopoDS_Shape::Locked()).
120 Standard_EXPORT void SetNonDestructive();
122 Standard_EXPORT void SetIsPrimary(const Standard_Boolean theFlag);
124 Standard_EXPORT Standard_Boolean IsPrimary() const;
126 Standard_EXPORT virtual void PerformInternal();
128 Standard_EXPORT virtual void Clear();
130 Standard_EXPORT virtual void Init();
132 Standard_EXPORT void Prepare();
134 Standard_EXPORT virtual void PerformVV();
136 Standard_EXPORT virtual void PerformVE();
138 Standard_EXPORT virtual void PerformVF();
140 Standard_EXPORT virtual void PerformEE();
142 Standard_EXPORT virtual void PerformEF();
144 Standard_EXPORT virtual void PerformFF();
146 Standard_EXPORT virtual void PerformVZ();
148 Standard_EXPORT virtual void PerformEZ();
150 Standard_EXPORT virtual void PerformFZ();
152 Standard_EXPORT virtual void PerformZZ();
154 Standard_EXPORT virtual void PerformSZ(const TopAbs_ShapeEnum aTS);
156 Standard_EXPORT void TreatVerticesEE();
158 Standard_EXPORT void MakeSplitEdges();
160 Standard_EXPORT void MakeBlocks();
162 Standard_EXPORT void MakePCurves();
164 Standard_EXPORT void MakeSDVertices(const BOPCol_ListOfInteger& theVertIndices);
166 Standard_EXPORT void ProcessDE();
168 Standard_EXPORT void FillShrunkData (Handle(BOPDS_PaveBlock)& thePB);
170 Standard_EXPORT void FillShrunkData (const TopAbs_ShapeEnum theType1, const TopAbs_ShapeEnum theType2);
172 Standard_EXPORT Standard_Integer PerformVerticesEE (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB, const BOPCol_BaseAllocator& theAllocator);
174 Standard_EXPORT Standard_Integer PerformVerticesEF (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB, const BOPCol_BaseAllocator& theAllocator);
176 Standard_EXPORT Standard_Boolean CheckFacePaves (const TopoDS_Vertex& theVnew, const BOPCol_MapOfInteger& theMIF);
178 Standard_EXPORT static Standard_Boolean CheckFacePaves (const Standard_Integer theN, const BOPCol_MapOfInteger& theMIFOn, const BOPCol_MapOfInteger& theMIFIn);
180 Standard_EXPORT Standard_Boolean IsExistingVertex (const gp_Pnt& theP, const Standard_Real theTol, const BOPCol_MapOfInteger& theMVOn) const;
183 //! Checks and puts paves from <theMVOn> on the curve <theNC>.
184 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);
187 //! Depending on the parameter aType it checks whether
188 //! the vertex nV was created in EE or EF intersections.
189 //! If so, it increases aTolVExt from tolerance value of vertex to
190 //! the max distance from vertex nV to the ends of the range of common part.
191 //! Possible values of aType:
192 //! 1 - checks only EE;
193 //! 2 - checks only EF;
194 //! other - checks both types of intersections.
195 Standard_EXPORT Standard_Boolean ExtendedTolerance (const Standard_Integer nV, const BOPCol_MapOfInteger& aMI, Standard_Real& aTolVExt, const Standard_Integer aType = 0);
197 Standard_EXPORT void PutBoundPaveOnCurve (const TopoDS_Face& theF1, const TopoDS_Face& theF2, const Standard_Real theTolR3D, BOPDS_Curve& theNC, BOPCol_ListOfInteger& theLBV);
199 Standard_EXPORT Standard_Boolean IsExistingPaveBlock
200 (const Handle(BOPDS_PaveBlock)& thePB, const BOPDS_Curve& theNC,
201 const Standard_Real theTolR3D, const BOPDS_IndexedMapOfPaveBlock& theMPB,
202 Handle(BOPDS_PaveBlock)& thePBOut, Standard_Real& theTolNew);
204 Standard_EXPORT Standard_Boolean IsExistingPaveBlock (const Handle(BOPDS_PaveBlock)& thePB, const BOPDS_Curve& theNC, const BOPCol_ListOfInteger& theLSE);
207 //! Treatment of section edges.
208 Standard_EXPORT Standard_Integer PostTreatFF (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB,
209 BOPCol_DataMapOfShapeInteger& theMVI,
210 BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDMExEdges,
211 BOPCol_DataMapOfIntegerInteger& theDMI,
212 const BOPCol_IndexedMapOfShape& theMicroEdges,
213 const BOPCol_BaseAllocator& theAllocator);
215 Standard_EXPORT void FindPaveBlocks (const Standard_Integer theV, const Standard_Integer theF, BOPDS_ListOfPaveBlock& theLPB);
217 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);
219 Standard_EXPORT void MakeSplitEdge (const Standard_Integer theV, const Standard_Integer theF);
221 Standard_EXPORT void GetEFPnts (const Standard_Integer nF1, const Standard_Integer nF2, IntSurf_ListOfPntOn2S& aListOfPnts);
224 //! Checks and puts paves created in EF intersections on the curve <theNC>.
225 Standard_EXPORT void PutEFPavesOnCurve (BOPDS_Curve& theNC, const BOPCol_MapOfInteger& theMI, const BOPCol_MapOfInteger& theMVEF, BOPCol_DataMapOfIntegerReal& theMVTol);
228 //! Puts stick paves on the curve <theNC>
229 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);
232 //! Collects indices of vertices created in all intersections between
233 //! two faces (<nF1> and <nF2>) to the map <theMVStick>.
234 //! Also, it collects indices of EF vertices to the <theMVEF> map
235 //! and indices of all subshapes of these two faces to the <theMI> map.
236 Standard_EXPORT void GetStickVertices (const Standard_Integer nF1, const Standard_Integer nF2, BOPCol_MapOfInteger& theMVStick, BOPCol_MapOfInteger& theMVEF, BOPCol_MapOfInteger& theMI);
239 //! Collects index nF and indices of all subshapes of the shape with index <nF>
240 //! to the map <theMI>.
241 Standard_EXPORT void GetFullShapeMap (const Standard_Integer nF, BOPCol_MapOfInteger& theMI);
244 //! Removes indices of vertices that are already on the
245 //! curve <theNC> from the map <theMV>.
246 //! It is used in PutEFPavesOnCurve and PutStickPavesOnCurve methods.
247 Standard_EXPORT void RemoveUsedVertices (BOPDS_Curve& theNC, BOPCol_MapOfInteger& theMV);
250 //! Puts the pave nV on the curve theNC.
251 //! Parameter aType defines whether to check the pave with
252 //! extended tolerance:
253 //! 0 - do not perform the check;
254 //! other - perform the check (aType goes to ExtendedTolerance).
255 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);
258 //! Adds the existing edges from the map <theMPBOnIn> which interfere
259 //! with the vertices from <theMVB> map to the post treatment of section edges.
260 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);
263 //! Replaces existing pave block <thePB> with new pave blocks <theLPB>.
264 //! The list <theLPB> contains images of <thePB> which were created in
265 //! the post treatment of section edges.
266 Standard_EXPORT void UpdateExistingPaveBlocks (const Handle(BOPDS_PaveBlock)& thePB, BOPDS_ListOfPaveBlock& theLPB, const Standard_Integer nF1, const Standard_Integer nF2);
269 //! Treatment of vertices that were created in EE intersections.
270 Standard_EXPORT void TreatNewVertices(const BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB, BOPCol_IndexedDataMapOfShapeListOfShape& theImages);
273 //! Put paves on the curve <aBC> in case when <aBC>
274 //! is closed 3D-curve
275 Standard_EXPORT void PutClosingPaveOnCurve (BOPDS_Curve& aNC);
278 //! Keeps data for post treatment
279 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);
282 //! Refines the state On for the all faces having
283 //! state information
284 Standard_EXPORT void RefineFaceInfoOn();
287 //! Updates the information about faces
288 Standard_EXPORT void UpdateFaceInfo (BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDME, const BOPCol_DataMapOfIntegerInteger& theDMV);
291 //! Updates tolerance of vertex with index <nV>
292 //! to make it interfere with edge
293 Standard_EXPORT void ForceInterfVE (const Standard_Integer nV, Handle(BOPDS_PaveBlock)& aPB, BOPDS_MapOfPaveBlock& aMPB);
296 //! Updates tolerance of vertex with index <nV>
297 //! to make it interfere with face with index <nF>
298 Standard_EXPORT Standard_Boolean ForceInterfVF (const Standard_Integer nV, const Standard_Integer nF);
301 //! Checks if there are any common or intersecting sub shapes
302 //! between two planar faces.
303 Standard_EXPORT Standard_Boolean CheckPlanes (const Standard_Integer nF1, const Standard_Integer nF2) const;
306 //! Creates new edge from the edge nE with vertices nV1 and nV2
307 //! and returns the index of that new edge in the DS.
308 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);
311 //! Updates pave blocks which have the paves with indices contained
312 //! in the map <theDMI>.
313 Standard_EXPORT void UpdatePaveBlocks (const BOPCol_DataMapOfIntegerInteger& theDMI);
315 //! Updates tolerance vertex nV due to V/E interference.
316 //! It always creates new vertex if nV is from arguments.
317 //! @return DS index of updated vertex.
318 Standard_EXPORT Standard_Integer UpdateVertex(const Standard_Integer nV,
319 const Standard_Real aTolNew);
321 Standard_EXPORT void UpdatePaveBlocksWithSDVertices();
323 Standard_EXPORT void UpdateCommonBlocksWithSDVertices();
325 Standard_EXPORT void UpdateBlocksWithSharedVertices();
327 Standard_EXPORT Standard_Boolean EstimatePaveOnCurve(const Standard_Integer nV,
328 const BOPDS_Curve& theNC,
329 const Standard_Real theTolR3D);
331 Standard_EXPORT void UpdateEdgeTolerance(const Standard_Integer nE,
332 const Standard_Real aTolNew);
334 Standard_EXPORT void RemovePaveBlocks(const BOPCol_MapOfInteger theEdges);
336 Standard_EXPORT void CorrectToleranceOfSE();
338 //! Reduce the intersection range using the common ranges of
339 //! Edge/Edge interferences to avoid creation of close
340 //! intersection vertices
341 Standard_EXPORT void ReduceIntersectionRange(const Standard_Integer theV1,
342 const Standard_Integer theV2,
343 const Standard_Integer theE,
344 const Standard_Integer theF,
345 Standard_Real& theTS1,
346 Standard_Real& theTS2);
348 //! Gets the bounding box for the given Pave Block.
349 //! If Pave Block has shrunk data it will be used to get the box,
350 //! and the Shrunk Range (<theSFirst>, <theSLast>).
351 //! Otherwise the box will be computed using BndLib_Add3dCurve method,
352 //! and the Shrunk Range will be equal to the PB's range.
353 //! To avoid re-computation of the bounding box for the same Pave Block
354 //! it will be saved in the map <thePBBox>.
355 //! Returns FALSE in case the PB's range is less than the
356 //! Precision::PConfusion(), otherwise returns TRUE.
357 Standard_EXPORT Standard_Boolean GetPBBox(const TopoDS_Edge& theE,
358 const Handle(BOPDS_PaveBlock)& thePB,
359 BOPAlgo_DataMapOfPaveBlockBndBox& thePBBox,
360 Standard_Real& theFirst,
361 Standard_Real& theLast,
362 Standard_Real& theSFirst,
363 Standard_Real& theSLast,
366 BOPCol_ListOfShape myArguments;
368 BOPDS_PIterator myIterator;
369 Handle(IntTools_Context) myContext;
370 BOPAlgo_SectionAttribute mySectionAttribute;
371 Standard_Real myFuzzyValue;
372 Standard_Boolean myNonDestructive;
373 Standard_Boolean myIsPrimary;
390 #endif // _BOPAlgo_PaveFiller_HeaderFile