1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _BOPDS_DS_HeaderFile
16 #define _BOPDS_DS_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
22 #include <BOPCol_BaseAllocator.hxx>
23 #include <BOPCol_ListOfShape.hxx>
24 #include <Standard_Integer.hxx>
25 #include <BOPDS_VectorOfIndexRange.hxx>
26 #include <BOPDS_VectorOfShapeInfo.hxx>
27 #include <BOPCol_DataMapOfShapeInteger.hxx>
28 #include <BOPDS_VectorOfListOfPaveBlock.hxx>
29 #include <BOPDS_DataMapOfPaveBlockCommonBlock.hxx>
30 #include <BOPDS_VectorOfFaceInfo.hxx>
31 #include <BOPCol_DataMapOfIntegerInteger.hxx>
32 #include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
33 #include <BOPDS_MapOfPassKey.hxx>
34 #include <BOPDS_VectorOfInterfVV.hxx>
35 #include <BOPDS_VectorOfInterfVE.hxx>
36 #include <BOPDS_VectorOfInterfVF.hxx>
37 #include <BOPDS_VectorOfInterfEE.hxx>
38 #include <BOPDS_VectorOfInterfEF.hxx>
39 #include <BOPDS_VectorOfInterfFF.hxx>
40 #include <BOPDS_VectorOfInterfVZ.hxx>
41 #include <BOPDS_VectorOfInterfEZ.hxx>
42 #include <BOPDS_VectorOfInterfFZ.hxx>
43 #include <BOPDS_VectorOfInterfZZ.hxx>
44 #include <Standard_Real.hxx>
45 #include <Standard_Boolean.hxx>
46 #include <BOPDS_ListOfPaveBlock.hxx>
47 #include <BOPDS_IndexedMapOfPaveBlock.hxx>
48 #include <BOPDS_MapOfPaveBlock.hxx>
49 #include <BOPCol_MapOfInteger.hxx>
50 #include <BOPCol_ListOfInteger.hxx>
51 #include <BOPDS_ListOfPave.hxx>
52 #include <Precision.hxx>
53 class BOPDS_IndexRange;
54 class BOPDS_ShapeInfo;
56 class BOPDS_PaveBlock;
57 class BOPDS_CommonBlock;
63 //! The class BOPDS_DS provides the control
64 //! the data structure for
65 //! partition and boolean operation algorithms
67 //! The data structure has the following contents:
68 //! 1. the arguments of an operation [myArguments];
69 //! 2 the information about arguments/new shapes
70 //! and their sub-shapes (type of the shape,
71 //! bounding box, etc) [myLines];
72 //! 3. each argument shape(and its subshapes)
73 //! has/have own range of indices (rank)
74 //! 4. pave blocks on source edges [myPaveBlocksPool];
75 //! 5. the state of source faces [myFaceInfoPool]
76 //! 6 the collection of same domain shapes [myShapesSD]
77 //! 7 the collection of interferences [myInterfTB,
78 //! myInterfVV,..myInterfFF]
88 Standard_EXPORT BOPDS_DS();
89 Standard_EXPORT virtual ~BOPDS_DS();
93 //! theAllocator - the allocator to manage the memory
94 Standard_EXPORT BOPDS_DS(const BOPCol_BaseAllocator& theAllocator);
97 //! Clears the contents
98 Standard_EXPORT void Clear();
102 Standard_EXPORT const BOPCol_BaseAllocator& Allocator() const;
106 //! Sets the arguments [theLS] of an operation
107 Standard_EXPORT void SetArguments (const BOPCol_ListOfShape& theLS);
111 //! Returns the arguments of an operation
112 Standard_EXPORT const BOPCol_ListOfShape& Arguments() const;
115 //! Initializes the data structure for
117 Standard_EXPORT void Init(const Standard_Real theFuzz = Precision::Confusion());
121 //! Returns the total number of shapes stored
122 Standard_EXPORT Standard_Integer NbShapes() const;
126 //! Returns the total number of source shapes stored
127 Standard_EXPORT Standard_Integer NbSourceShapes() const;
131 //! Returns the number of index ranges
132 Standard_EXPORT Standard_Integer NbRanges() const;
136 //! Returns the index range "i"
137 Standard_EXPORT const BOPDS_IndexRange& Range (const Standard_Integer theIndex) const;
141 //! Returns the rank of the shape of index "i"
142 Standard_EXPORT Standard_Integer Rank (const Standard_Integer theIndex) const;
145 //! Returns true if the shape of index "i" is not
146 //! the source shape/sub-shape
147 Standard_EXPORT Standard_Boolean IsNewShape (const Standard_Integer theIndex) const;
151 //! Appends the information about the shape [theSI]
152 //! to the data structure
153 //! Returns the index of theSI in the data structure
154 Standard_EXPORT Standard_Integer Append (const BOPDS_ShapeInfo& theSI);
158 //! Appends the default information about the shape [theS]
159 //! to the data structure
160 //! Returns the index of theS in the data structure
161 Standard_EXPORT Standard_Integer Append (const TopoDS_Shape& theS);
165 //! Returns the information about the shape
166 //! with index theIndex
167 Standard_EXPORT const BOPDS_ShapeInfo& ShapeInfo (const Standard_Integer theIndex) const;
170 //! Selector/Modifier
171 //! Returns the information about the shape
172 //! with index theIndex
173 Standard_EXPORT BOPDS_ShapeInfo& ChangeShapeInfo (const Standard_Integer theIndex);
177 //! Returns the shape
178 //! with index theIndex
179 Standard_EXPORT const TopoDS_Shape& Shape (const Standard_Integer theIndex) const;
183 //! Returns the index of the shape theS
184 Standard_EXPORT Standard_Integer Index (const TopoDS_Shape& theS) const;
188 //! Returns the information about pave blocks on source edges
189 Standard_EXPORT const BOPDS_VectorOfListOfPaveBlock& PaveBlocksPool() const;
192 //! Selector/Modifier
193 //! Returns the information about pave blocks on source edges
194 Standard_EXPORT BOPDS_VectorOfListOfPaveBlock& ChangePaveBlocksPool();
198 //! Returns true if the shape with index theIndex has the
199 //! information about pave blocks
200 Standard_EXPORT Standard_Boolean HasPaveBlocks (const Standard_Integer theIndex) const;
204 //! Returns the pave blocks for the shape with index theIndex
205 Standard_EXPORT const BOPDS_ListOfPaveBlock& PaveBlocks (const Standard_Integer theIndex) const;
208 //! Selector/Modifier
209 //! Returns the pave blocks for the shape with index theIndex
210 Standard_EXPORT BOPDS_ListOfPaveBlock& ChangePaveBlocks (const Standard_Integer theIndex);
213 //! Update the pave blocks for the all shapes in data structure
214 Standard_EXPORT void UpdatePaveBlocks();
217 //! Update the pave block thePB
218 Standard_EXPORT void UpdatePaveBlock (const Handle(BOPDS_PaveBlock)& thePB);
221 //! Update the common block theCB
222 Standard_EXPORT void UpdateCommonBlock (const Handle(BOPDS_CommonBlock)& theCB,
223 const Standard_Real theFuzz);
227 //! Returns true if the pave block is common block
228 Standard_EXPORT Standard_Boolean IsCommonBlock (const Handle(BOPDS_PaveBlock)& thePB) const;
232 //! Returns the common block
233 Standard_EXPORT Handle(BOPDS_CommonBlock) CommonBlock (const Handle(BOPDS_PaveBlock)& thePB) const;
237 //! Sets the common block <theCB>
238 Standard_EXPORT void SetCommonBlock (const Handle(BOPDS_PaveBlock)& thePB, const Handle(BOPDS_CommonBlock)& theCB);
242 //! Returns the real first pave block
243 Standard_EXPORT Handle(BOPDS_PaveBlock) RealPaveBlock (const Handle(BOPDS_PaveBlock)& thePB) const;
247 //! Returns true if common block contains more then one pave block
248 Standard_EXPORT Standard_Boolean IsCommonBlockOnEdge (const Handle(BOPDS_PaveBlock)& thePB) const;
252 //! Returns the information about state of faces
253 Standard_EXPORT const BOPDS_VectorOfFaceInfo& FaceInfoPool() const;
257 //! Returns true if the shape with index theIndex has the
258 //! information about state of face
259 Standard_EXPORT Standard_Boolean HasFaceInfo (const Standard_Integer theIndex) const;
263 //! Returns the state of face with index theIndex
264 Standard_EXPORT const BOPDS_FaceInfo& FaceInfo (const Standard_Integer theIndex) const;
267 //! Selector/Modifier
268 //! Returns the state of face with index theIndex
269 Standard_EXPORT BOPDS_FaceInfo& ChangeFaceInfo (const Standard_Integer theIndex);
272 //! Update the state In of face with index theIndex
273 Standard_EXPORT void UpdateFaceInfoIn (const Standard_Integer theIndex);
276 //! Update the state On of face with index theIndex
277 Standard_EXPORT void UpdateFaceInfoOn (const Standard_Integer theIndex);
281 //! Returns the state On
282 //! [theMPB,theMVP] of face with index theIndex
283 Standard_EXPORT void FaceInfoOn (const Standard_Integer theIndex, BOPDS_IndexedMapOfPaveBlock& theMPB, BOPCol_MapOfInteger& theMVP);
287 //! Returns the state In
288 //! [theMPB,theMVP] of face with index theIndex
289 Standard_EXPORT void FaceInfoIn (const Standard_Integer theIndex, BOPDS_IndexedMapOfPaveBlock& theMPB, BOPCol_MapOfInteger& theMVP);
293 //! Returns the indices of alone vertices
294 //! for the face with index theIndex
295 Standard_EXPORT void AloneVertices (const Standard_Integer theF, BOPCol_ListOfInteger& theLI) const;
298 //! Refine the state On for the all faces having
299 //! state information
302 Standard_EXPORT void RefineFaceInfoOn();
305 //! Returns information about ON/IN subshapes of the given faces.
306 //! @param theMVOnIn the indices of ON/IN vertices from both faces
307 //! @param thePBOnIn all On/In pave blocks from both faces
308 //! @param theCommonPB the common pave blocks (that are shared by both faces).
309 Standard_EXPORT void SubShapesOnIn (const Standard_Integer theF1,
310 const Standard_Integer theF2,
311 BOPCol_MapOfInteger& theMVOnIn,
312 BOPDS_IndexedMapOfPaveBlock& thePBOnIn,
313 BOPDS_MapOfPaveBlock& theCommonPB) const;
316 //! Returns the indices of edges that are shared
317 //! for the faces with indices theF1, theF2
319 //! same domain shapes
320 Standard_EXPORT void SharedEdges (const Standard_Integer theF1, const Standard_Integer theF2, BOPCol_ListOfInteger& theLI, const BOPCol_BaseAllocator& theAllocator);
324 //! Returns the collection same domain shapes
325 Standard_EXPORT BOPCol_DataMapOfIntegerInteger& ShapesSD();
329 //! Adds the information about same domain shapes
330 //! with indices theIndex, theIndexSD
331 Standard_EXPORT void AddShapeSD (const Standard_Integer theIndex, const Standard_Integer theIndexSD);
335 //! Returns true if the shape with index theIndex has the
336 //! same domain shape. In this case theIndexSD will contain
337 //! the index of same domain shape found
340 Standard_EXPORT Standard_Boolean HasShapeSD (const Standard_Integer theIndex, Standard_Integer& theIndexSD) const;
343 //! Selector/Modifier
344 //! Returns the collection of interferences Vertex/Vertex
345 BOPDS_VectorOfInterfVV& InterfVV();
348 //! Selector/Modifier
349 //! Returns the collection of interferences Vertex/Edge
350 BOPDS_VectorOfInterfVE& InterfVE();
353 //! Selector/Modifier
354 //! Returns the collection of interferences Vertex/Face
355 BOPDS_VectorOfInterfVF& InterfVF();
358 //! Selector/Modifier
359 //! Returns the collection of interferences Edge/Edge
360 BOPDS_VectorOfInterfEE& InterfEE();
363 //! Selector/Modifier
364 //! Returns the collection of interferences Edge/Face
365 BOPDS_VectorOfInterfEF& InterfEF();
368 //! Selector/Modifier
369 //! Returns the collection of interferences Face/Face
370 BOPDS_VectorOfInterfFF& InterfFF();
373 //! Selector/Modifier
374 //! Returns the collection of interferences Vertex/Solid
375 BOPDS_VectorOfInterfVZ& InterfVZ();
378 //! Selector/Modifier
379 //! Returns the collection of interferences Edge/Solid
380 BOPDS_VectorOfInterfEZ& InterfEZ();
383 //! Selector/Modifier
384 //! Returns the collection of interferences Face/Solid
385 BOPDS_VectorOfInterfFZ& InterfFZ();
388 //! Selector/Modifier
389 //! Returns the collection of interferences Solid/Solid
390 BOPDS_VectorOfInterfZZ& InterfZZ();
393 //! Returns the number of types of the interferences
394 static Standard_Integer NbInterfTypes();
398 //! Adds the information about an interference between
399 //! shapes with indices theI1, theI2 to the summary
400 //! table of interferences
401 void AddInterf (const Standard_Integer theI1, const Standard_Integer theI2);
405 //! Returns true if the shape with index theI
407 Standard_EXPORT Standard_Boolean HasInterf (const Standard_Integer theI) const;
411 //! Returns true if the shapes with indices theI1, theI2
413 Standard_Boolean HasInterf (const Standard_Integer theI1, const Standard_Integer theI2) const;
417 //! Returns true if the shape with index theI1 is interfered
419 //! any sub-shape of the shape with index theI2 (theFlag=true)
420 //! all sub-shapes of the shape with index theI2 (theFlag=false)
421 Standard_EXPORT Standard_Boolean HasInterfShapeSubShapes (const Standard_Integer theI1, const Standard_Integer theI2, const Standard_Boolean theFlag = Standard_True) const;
425 //! Returns true if the shapes with indices theI1, theI2
426 //! have interferred sub-shapes
427 Standard_EXPORT Standard_Boolean HasInterfSubShapes (const Standard_Integer theI1, const Standard_Integer theI2) const;
431 //! Returns the table of interferences
434 const BOPDS_MapOfPassKey& Interferences() const;
436 Standard_EXPORT void Dump() const;
438 Standard_EXPORT void SortPaveBlocks (const Handle(BOPDS_CommonBlock)& theCB);
440 Standard_EXPORT Standard_Boolean IsToSort (const Handle(BOPDS_CommonBlock)& theCB, Standard_Integer& theI);
442 Standard_EXPORT Standard_Boolean IsSubShape (const Standard_Integer theI1, const Standard_Integer theI2);
444 //! Fills theLP with sorted paves
445 //! of the shape with index theIndex
446 Standard_EXPORT void Paves (const Standard_Integer theIndex, BOPDS_ListOfPave& theLP);
449 //! Updates tolerance of the sub-shapes of the shape with index <theIndex>.
450 Standard_EXPORT void UpdateEdgeTolerance (const Standard_Integer theIndex,
451 const Standard_Real theTolerance,
452 const Standard_Real theFuzz = Precision::Confusion());
454 //! Update the pave blocks for all shapes in data structure
455 Standard_EXPORT void UpdatePaveBlocksWithSDVertices();
457 //! Update the pave block of the common block for all shapes in data structure
458 Standard_EXPORT void UpdateCommonBlockWithSDVertices(const Handle(BOPDS_CommonBlock)& theCB);
460 Standard_EXPORT void InitPaveBlocksForVertex(const Standard_Integer theNV);
466 //! Initializes the pave blocks for the shape with index theIndex
467 Standard_EXPORT void InitPaveBlocks (const Standard_Integer theIndex);
469 //! Update the pave block for all shapes in data structure
470 Standard_EXPORT void UpdatePaveBlockWithSDVertices(const Handle(BOPDS_PaveBlock)& thePB);
472 //! Initializes the state of face with index theIndex
473 Standard_EXPORT void InitFaceInfo (const Standard_Integer theIndex);
475 Standard_EXPORT void InitShape (const Standard_Integer theIndex, const TopoDS_Shape& theS);
477 Standard_EXPORT Standard_Boolean CheckCoincidence (const Handle(BOPDS_PaveBlock)& thePB1,
478 const Handle(BOPDS_PaveBlock)& thePB2,
479 const Standard_Real theFuzz);
482 //! Computes bouding box <theBox> for the solid with DS-index <theIndex>
483 Standard_EXPORT void BuildBndBoxSolid (const Standard_Integer theIndex, Bnd_Box& theBox);
486 BOPCol_BaseAllocator myAllocator;
487 BOPCol_ListOfShape myArguments;
488 Standard_Integer myNbShapes;
489 Standard_Integer myNbSourceShapes;
490 BOPDS_VectorOfIndexRange myRanges;
491 BOPDS_VectorOfShapeInfo myLines;
492 BOPCol_DataMapOfShapeInteger myMapShapeIndex;
493 BOPDS_VectorOfListOfPaveBlock myPaveBlocksPool;
494 BOPDS_DataMapOfPaveBlockCommonBlock myMapPBCB;
495 BOPDS_VectorOfFaceInfo myFaceInfoPool;
496 BOPCol_DataMapOfIntegerInteger myShapesSD;
497 BOPCol_DataMapOfIntegerListOfInteger myMapVE;
498 BOPDS_MapOfPassKey myInterfTB;
499 BOPDS_VectorOfInterfVV myInterfVV;
500 BOPDS_VectorOfInterfVE myInterfVE;
501 BOPDS_VectorOfInterfVF myInterfVF;
502 BOPDS_VectorOfInterfEE myInterfEE;
503 BOPDS_VectorOfInterfEF myInterfEF;
504 BOPDS_VectorOfInterfFF myInterfFF;
505 BOPDS_VectorOfInterfVZ myInterfVZ;
506 BOPDS_VectorOfInterfEZ myInterfEZ;
507 BOPDS_VectorOfInterfFZ myInterfFZ;
508 BOPDS_VectorOfInterfZZ myInterfZZ;
520 #include <BOPDS_DS.lxx>
526 #endif // _BOPDS_DS_HeaderFile