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_MapOfPair.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 //! of data structure for the algorithms in the
65 //! Boolean Component such as General Fuse, Boolean operations,
66 //! Section, Maker Volume, Splitter and Cells Builder.<br>
68 //! The data structure has the following contents:<br>
69 //! 1. the arguments of an operation [myArguments];<br>
70 //! 2 the information about arguments/new shapes
71 //! and their sub-shapes (type of the shape,
72 //! bounding box, etc) [myLines];<br>
73 //! 3. each argument shape(and its subshapes)
74 //! has/have own range of indices (rank);<br>
75 //! 4. pave blocks on source edges [myPaveBlocksPool];<br>
76 //! 5. the state of source faces [myFaceInfoPool];<br>
77 //! 6 the collection of same domain shapes [myShapesSD];<br>
78 //! 7 the collection of interferences [myInterfTB,
79 //! myInterfVV,..myInterfFF]
89 Standard_EXPORT BOPDS_DS();
90 Standard_EXPORT virtual ~BOPDS_DS();
94 //! theAllocator - the allocator to manage the memory
95 Standard_EXPORT BOPDS_DS(const BOPCol_BaseAllocator& theAllocator);
98 //! Clears the contents
99 Standard_EXPORT void Clear();
103 Standard_EXPORT const BOPCol_BaseAllocator& Allocator() const;
107 //! Sets the arguments [theLS] of an operation
108 Standard_EXPORT void SetArguments (const BOPCol_ListOfShape& theLS);
112 //! Returns the arguments of an operation
113 Standard_EXPORT const BOPCol_ListOfShape& Arguments() const;
116 //! Initializes the data structure for
118 Standard_EXPORT void Init(const Standard_Real theFuzz = Precision::Confusion());
122 //! Returns the total number of shapes stored
123 Standard_EXPORT Standard_Integer NbShapes() const;
127 //! Returns the total number of source shapes stored
128 Standard_EXPORT Standard_Integer NbSourceShapes() const;
132 //! Returns the number of index ranges
133 Standard_EXPORT Standard_Integer NbRanges() const;
137 //! Returns the index range "i"
138 Standard_EXPORT const BOPDS_IndexRange& Range (const Standard_Integer theIndex) const;
142 //! Returns the rank of the shape of index "i"
143 Standard_EXPORT Standard_Integer Rank (const Standard_Integer theIndex) const;
146 //! Returns true if the shape of index "i" is not
147 //! the source shape/sub-shape
148 Standard_EXPORT Standard_Boolean IsNewShape (const Standard_Integer theIndex) const;
152 //! Appends the information about the shape [theSI]
153 //! to the data structure
154 //! Returns the index of theSI in the data structure
155 Standard_EXPORT Standard_Integer Append (const BOPDS_ShapeInfo& theSI);
159 //! Appends the default information about the shape [theS]
160 //! to the data structure
161 //! Returns the index of theS in the data structure
162 Standard_EXPORT Standard_Integer Append (const TopoDS_Shape& theS);
166 //! Returns the information about the shape
167 //! with index theIndex
168 Standard_EXPORT const BOPDS_ShapeInfo& ShapeInfo (const Standard_Integer theIndex) const;
171 //! Selector/Modifier
172 //! Returns the information about the shape
173 //! with index theIndex
174 Standard_EXPORT BOPDS_ShapeInfo& ChangeShapeInfo (const Standard_Integer theIndex);
178 //! Returns the shape
179 //! with index theIndex
180 Standard_EXPORT const TopoDS_Shape& Shape (const Standard_Integer theIndex) const;
184 //! Returns the index of the shape theS
185 Standard_EXPORT Standard_Integer Index (const TopoDS_Shape& theS) const;
189 //! Returns the information about pave blocks on source edges
190 Standard_EXPORT const BOPDS_VectorOfListOfPaveBlock& PaveBlocksPool() const;
193 //! Selector/Modifier
194 //! Returns the information about pave blocks on source edges
195 Standard_EXPORT BOPDS_VectorOfListOfPaveBlock& ChangePaveBlocksPool();
199 //! Returns true if the shape with index theIndex has the
200 //! information about pave blocks
201 Standard_EXPORT Standard_Boolean HasPaveBlocks (const Standard_Integer theIndex) const;
205 //! Returns the pave blocks for the shape with index theIndex
206 Standard_EXPORT const BOPDS_ListOfPaveBlock& PaveBlocks (const Standard_Integer theIndex) const;
209 //! Selector/Modifier
210 //! Returns the pave blocks for the shape with index theIndex
211 Standard_EXPORT BOPDS_ListOfPaveBlock& ChangePaveBlocks (const Standard_Integer theIndex);
214 //! Update the pave blocks for the all shapes in data structure
215 Standard_EXPORT void UpdatePaveBlocks();
218 //! Update the pave block thePB
219 Standard_EXPORT void UpdatePaveBlock (const Handle(BOPDS_PaveBlock)& thePB);
222 //! Update the common block theCB
223 Standard_EXPORT void UpdateCommonBlock (const Handle(BOPDS_CommonBlock)& theCB,
224 const Standard_Real theFuzz);
228 //! Returns true if the pave block is common block
229 Standard_EXPORT Standard_Boolean IsCommonBlock (const Handle(BOPDS_PaveBlock)& thePB) const;
233 //! Returns the common block
234 Standard_EXPORT Handle(BOPDS_CommonBlock) CommonBlock (const Handle(BOPDS_PaveBlock)& thePB) const;
238 //! Sets the common block <theCB>
239 Standard_EXPORT void SetCommonBlock (const Handle(BOPDS_PaveBlock)& thePB, const Handle(BOPDS_CommonBlock)& theCB);
243 //! Returns the real first pave block
244 Standard_EXPORT Handle(BOPDS_PaveBlock) RealPaveBlock (const Handle(BOPDS_PaveBlock)& thePB) const;
248 //! Returns true if common block contains more then one pave block
249 Standard_EXPORT Standard_Boolean IsCommonBlockOnEdge (const Handle(BOPDS_PaveBlock)& thePB) const;
253 //! Returns the information about state of faces
254 Standard_EXPORT const BOPDS_VectorOfFaceInfo& FaceInfoPool() const;
258 //! Returns true if the shape with index theIndex has the
259 //! information about state of face
260 Standard_EXPORT Standard_Boolean HasFaceInfo (const Standard_Integer theIndex) const;
264 //! Returns the state of face with index theIndex
265 Standard_EXPORT const BOPDS_FaceInfo& FaceInfo (const Standard_Integer theIndex) const;
268 //! Selector/Modifier
269 //! Returns the state of face with index theIndex
270 Standard_EXPORT BOPDS_FaceInfo& ChangeFaceInfo (const Standard_Integer theIndex);
273 //! Update the state In of face with index theIndex
274 Standard_EXPORT void UpdateFaceInfoIn (const Standard_Integer theIndex);
277 //! Update the state On of face with index theIndex
278 Standard_EXPORT void UpdateFaceInfoOn (const Standard_Integer theIndex);
282 //! Returns the state On
283 //! [theMPB,theMVP] of face with index theIndex
284 Standard_EXPORT void FaceInfoOn (const Standard_Integer theIndex, BOPDS_IndexedMapOfPaveBlock& theMPB, BOPCol_MapOfInteger& theMVP);
288 //! Returns the state In
289 //! [theMPB,theMVP] of face with index theIndex
290 Standard_EXPORT void FaceInfoIn (const Standard_Integer theIndex, BOPDS_IndexedMapOfPaveBlock& theMPB, BOPCol_MapOfInteger& theMVP);
294 //! Returns the indices of alone vertices
295 //! for the face with index theIndex
296 Standard_EXPORT void AloneVertices (const Standard_Integer theF, BOPCol_ListOfInteger& theLI) const;
299 //! Refine the state On for the all faces having
300 //! state information
303 Standard_EXPORT void RefineFaceInfoOn();
306 //! Returns information about ON/IN subshapes of the given faces.
307 //! @param theMVOnIn the indices of ON/IN vertices from both faces
308 //! @param thePBOnIn all On/In pave blocks from both faces
309 //! @param theCommonPB the common pave blocks (that are shared by both faces).
310 Standard_EXPORT void SubShapesOnIn (const Standard_Integer theF1,
311 const Standard_Integer theF2,
312 BOPCol_MapOfInteger& theMVOnIn,
313 BOPDS_IndexedMapOfPaveBlock& thePBOnIn,
314 BOPDS_MapOfPaveBlock& theCommonPB) const;
317 //! Returns the indices of edges that are shared
318 //! for the faces with indices theF1, theF2
320 //! same domain shapes
321 Standard_EXPORT void SharedEdges (const Standard_Integer theF1, const Standard_Integer theF2, BOPCol_ListOfInteger& theLI, const BOPCol_BaseAllocator& theAllocator);
325 //! Returns the collection same domain shapes
326 Standard_EXPORT BOPCol_DataMapOfIntegerInteger& ShapesSD();
330 //! Adds the information about same domain shapes
331 //! with indices theIndex, theIndexSD
332 Standard_EXPORT void AddShapeSD (const Standard_Integer theIndex, const Standard_Integer theIndexSD);
336 //! Returns true if the shape with index theIndex has the
337 //! same domain shape. In this case theIndexSD will contain
338 //! the index of same domain shape found
341 Standard_EXPORT Standard_Boolean HasShapeSD (const Standard_Integer theIndex, Standard_Integer& theIndexSD) const;
344 //! Selector/Modifier
345 //! Returns the collection of interferences Vertex/Vertex
346 BOPDS_VectorOfInterfVV& InterfVV();
349 //! Selector/Modifier
350 //! Returns the collection of interferences Vertex/Edge
351 BOPDS_VectorOfInterfVE& InterfVE();
354 //! Selector/Modifier
355 //! Returns the collection of interferences Vertex/Face
356 BOPDS_VectorOfInterfVF& InterfVF();
359 //! Selector/Modifier
360 //! Returns the collection of interferences Edge/Edge
361 BOPDS_VectorOfInterfEE& InterfEE();
364 //! Selector/Modifier
365 //! Returns the collection of interferences Edge/Face
366 BOPDS_VectorOfInterfEF& InterfEF();
369 //! Selector/Modifier
370 //! Returns the collection of interferences Face/Face
371 BOPDS_VectorOfInterfFF& InterfFF();
374 //! Selector/Modifier
375 //! Returns the collection of interferences Vertex/Solid
376 BOPDS_VectorOfInterfVZ& InterfVZ();
379 //! Selector/Modifier
380 //! Returns the collection of interferences Edge/Solid
381 BOPDS_VectorOfInterfEZ& InterfEZ();
384 //! Selector/Modifier
385 //! Returns the collection of interferences Face/Solid
386 BOPDS_VectorOfInterfFZ& InterfFZ();
389 //! Selector/Modifier
390 //! Returns the collection of interferences Solid/Solid
391 BOPDS_VectorOfInterfZZ& InterfZZ();
394 //! Returns the number of types of the interferences
395 static Standard_Integer NbInterfTypes();
399 //! Adds the information about an interference between
400 //! shapes with indices theI1, theI2 to the summary
401 //! table of interferences
402 void AddInterf (const Standard_Integer theI1, const Standard_Integer theI2);
406 //! Returns true if the shape with index theI
408 Standard_EXPORT Standard_Boolean HasInterf (const Standard_Integer theI) const;
412 //! Returns true if the shapes with indices theI1, theI2
414 Standard_Boolean HasInterf (const Standard_Integer theI1, const Standard_Integer theI2) const;
418 //! Returns true if the shape with index theI1 is interfered
420 //! any sub-shape of the shape with index theI2 (theFlag=true)
421 //! all sub-shapes of the shape with index theI2 (theFlag=false)
422 Standard_EXPORT Standard_Boolean HasInterfShapeSubShapes (const Standard_Integer theI1, const Standard_Integer theI2, const Standard_Boolean theFlag = Standard_True) const;
426 //! Returns true if the shapes with indices theI1, theI2
427 //! have interferred sub-shapes
428 Standard_EXPORT Standard_Boolean HasInterfSubShapes (const Standard_Integer theI1, const Standard_Integer theI2) const;
432 //! Returns the table of interferences
435 const BOPDS_MapOfPair& Interferences() const;
437 Standard_EXPORT void Dump() const;
439 Standard_EXPORT Standard_Boolean IsSubShape (const Standard_Integer theI1, const Standard_Integer theI2);
441 //! Fills theLP with sorted paves
442 //! of the shape with index theIndex
443 Standard_EXPORT void Paves (const Standard_Integer theIndex, BOPDS_ListOfPave& theLP);
446 //! Updates tolerance of the sub-shapes of the shape with index <theIndex>.
447 Standard_EXPORT void UpdateEdgeTolerance (const Standard_Integer theIndex,
448 const Standard_Real theTolerance,
449 const Standard_Real theFuzz = Precision::Confusion());
451 //! Update the pave blocks for all shapes in data structure
452 Standard_EXPORT void UpdatePaveBlocksWithSDVertices();
454 //! Update the pave block for all shapes in data structure
455 Standard_EXPORT void UpdatePaveBlockWithSDVertices(const Handle(BOPDS_PaveBlock)& thePB);
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);
462 //! Clears information about PaveBlocks for the untouched edges
463 Standard_EXPORT void ReleasePaveBlocks();
465 //! Checks if the existing shrunk data of the pave block is still valid.<br>
466 //! The shrunk data may become invalid if e.g. the vertices of the pave block
467 //! have been replaced with the new one with bigger tolerances, or the tolerances
468 //! of the existing vertices have been increased.
469 Standard_EXPORT Standard_Boolean IsValidShrunkData(const Handle(BOPDS_PaveBlock)& thePB);
475 //! Initializes the pave blocks for the shape with index theIndex
476 Standard_EXPORT void InitPaveBlocks (const Standard_Integer theIndex);
478 //! Initializes the state of face with index theIndex
479 Standard_EXPORT void InitFaceInfo (const Standard_Integer theIndex);
481 Standard_EXPORT void InitShape (const Standard_Integer theIndex, const TopoDS_Shape& theS);
483 Standard_EXPORT Standard_Boolean CheckCoincidence (const Handle(BOPDS_PaveBlock)& thePB1,
484 const Handle(BOPDS_PaveBlock)& thePB2,
485 const Standard_Real theFuzz);
488 //! Computes bouding box <theBox> for the solid with DS-index <theIndex>
489 Standard_EXPORT void BuildBndBoxSolid (const Standard_Integer theIndex, Bnd_Box& theBox);
492 BOPCol_BaseAllocator myAllocator;
493 BOPCol_ListOfShape myArguments;
494 Standard_Integer myNbShapes;
495 Standard_Integer myNbSourceShapes;
496 BOPDS_VectorOfIndexRange myRanges;
497 BOPDS_VectorOfShapeInfo myLines;
498 BOPCol_DataMapOfShapeInteger myMapShapeIndex;
499 BOPDS_VectorOfListOfPaveBlock myPaveBlocksPool;
500 BOPDS_DataMapOfPaveBlockCommonBlock myMapPBCB;
501 BOPDS_VectorOfFaceInfo myFaceInfoPool;
502 BOPCol_DataMapOfIntegerInteger myShapesSD;
503 BOPCol_DataMapOfIntegerListOfInteger myMapVE;
504 BOPDS_MapOfPair myInterfTB;
505 BOPDS_VectorOfInterfVV myInterfVV;
506 BOPDS_VectorOfInterfVE myInterfVE;
507 BOPDS_VectorOfInterfVF myInterfVF;
508 BOPDS_VectorOfInterfEE myInterfEE;
509 BOPDS_VectorOfInterfEF myInterfEF;
510 BOPDS_VectorOfInterfFF myInterfFF;
511 BOPDS_VectorOfInterfVZ myInterfVZ;
512 BOPDS_VectorOfInterfEZ myInterfEZ;
513 BOPDS_VectorOfInterfFZ myInterfFZ;
514 BOPDS_VectorOfInterfZZ myInterfZZ;
526 #include <BOPDS_DS.lxx>
532 #endif // _BOPDS_DS_HeaderFile