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 <BOPDS_DataMapOfPaveBlockCommonBlock.hxx>
23 #include <BOPDS_IndexedMapOfPaveBlock.hxx>
24 #include <BOPDS_ListOfPave.hxx>
25 #include <BOPDS_ListOfPaveBlock.hxx>
26 #include <BOPDS_MapOfPair.hxx>
27 #include <BOPDS_MapOfPaveBlock.hxx>
28 #include <BOPDS_VectorOfFaceInfo.hxx>
29 #include <BOPDS_VectorOfIndexRange.hxx>
30 #include <BOPDS_VectorOfInterfEE.hxx>
31 #include <BOPDS_VectorOfInterfEF.hxx>
32 #include <BOPDS_VectorOfInterfEZ.hxx>
33 #include <BOPDS_VectorOfInterfFF.hxx>
34 #include <BOPDS_VectorOfInterfFZ.hxx>
35 #include <BOPDS_VectorOfInterfVE.hxx>
36 #include <BOPDS_VectorOfInterfVF.hxx>
37 #include <BOPDS_VectorOfInterfVV.hxx>
38 #include <BOPDS_VectorOfInterfVZ.hxx>
39 #include <BOPDS_VectorOfInterfZZ.hxx>
40 #include <BOPDS_VectorOfListOfPaveBlock.hxx>
41 #include <BOPDS_VectorOfShapeInfo.hxx>
42 #include <NCollection_BaseAllocator.hxx>
43 #include <Precision.hxx>
44 #include <Standard_Boolean.hxx>
45 #include <Standard_Integer.hxx>
46 #include <Standard_Real.hxx>
47 #include <TColStd_DataMapOfIntegerInteger.hxx>
48 #include <TColStd_DataMapOfIntegerListOfInteger.hxx>
49 #include <TColStd_ListOfInteger.hxx>
50 #include <TColStd_MapOfInteger.hxx>
51 #include <TopTools_DataMapOfShapeInteger.hxx>
52 #include <TopTools_ListOfShape.hxx>
54 class BOPDS_IndexRange;
55 class BOPDS_ShapeInfo;
57 class BOPDS_PaveBlock;
58 class BOPDS_CommonBlock;
64 //! The class BOPDS_DS provides the control
65 //! of data structure for the algorithms in the
66 //! Boolean Component such as General Fuse, Boolean operations,
67 //! Section, Maker Volume, Splitter and Cells Builder.<br>
69 //! The data structure has the following contents:<br>
70 //! 1. the arguments of an operation [myArguments];<br>
71 //! 2 the information about arguments/new shapes
72 //! and their sub-shapes (type of the shape,
73 //! bounding box, etc) [myLines];<br>
74 //! 3. each argument shape(and its subshapes)
75 //! has/have own range of indices (rank);<br>
76 //! 4. pave blocks on source edges [myPaveBlocksPool];<br>
77 //! 5. the state of source faces [myFaceInfoPool];<br>
78 //! 6 the collection of same domain shapes [myShapesSD];<br>
79 //! 7 the collection of interferences [myInterfTB,
80 //! myInterfVV,..myInterfFF]
90 Standard_EXPORT BOPDS_DS();
91 Standard_EXPORT virtual ~BOPDS_DS();
95 //! theAllocator - the allocator to manage the memory
96 Standard_EXPORT BOPDS_DS(const Handle(NCollection_BaseAllocator)& theAllocator);
99 //! Clears the contents
100 Standard_EXPORT void Clear();
104 Standard_EXPORT const Handle(NCollection_BaseAllocator)& Allocator() const;
108 //! Sets the arguments [theLS] of an operation
109 Standard_EXPORT void SetArguments (const TopTools_ListOfShape& theLS);
113 //! Returns the arguments of an operation
114 Standard_EXPORT const TopTools_ListOfShape& Arguments() const;
117 //! Initializes the data structure for
119 Standard_EXPORT void Init(const Standard_Real theFuzz = Precision::Confusion());
123 //! Returns the total number of shapes stored
124 Standard_EXPORT Standard_Integer NbShapes() const;
128 //! Returns the total number of source shapes stored
129 Standard_EXPORT Standard_Integer NbSourceShapes() const;
133 //! Returns the number of index ranges
134 Standard_EXPORT Standard_Integer NbRanges() const;
138 //! Returns the index range "i"
139 Standard_EXPORT const BOPDS_IndexRange& Range (const Standard_Integer theIndex) const;
143 //! Returns the rank of the shape of index "i"
144 Standard_EXPORT Standard_Integer Rank (const Standard_Integer theIndex) const;
147 //! Returns true if the shape of index "i" is not
148 //! the source shape/sub-shape
149 Standard_EXPORT Standard_Boolean IsNewShape (const Standard_Integer theIndex) const;
153 //! Appends the information about the shape [theSI]
154 //! to the data structure
155 //! Returns the index of theSI in the data structure
156 Standard_EXPORT Standard_Integer Append (const BOPDS_ShapeInfo& theSI);
160 //! Appends the default information about the shape [theS]
161 //! to the data structure
162 //! Returns the index of theS in the data structure
163 Standard_EXPORT Standard_Integer Append (const TopoDS_Shape& theS);
167 //! Returns the information about the shape
168 //! with index theIndex
169 Standard_EXPORT const BOPDS_ShapeInfo& ShapeInfo (const Standard_Integer theIndex) const;
172 //! Selector/Modifier
173 //! Returns the information about the shape
174 //! with index theIndex
175 Standard_EXPORT BOPDS_ShapeInfo& ChangeShapeInfo (const Standard_Integer theIndex);
179 //! Returns the shape
180 //! with index theIndex
181 Standard_EXPORT const TopoDS_Shape& Shape (const Standard_Integer theIndex) const;
185 //! Returns the index of the shape theS
186 Standard_EXPORT Standard_Integer Index (const TopoDS_Shape& theS) const;
190 //! Returns the information about pave blocks on source edges
191 Standard_EXPORT const BOPDS_VectorOfListOfPaveBlock& PaveBlocksPool() const;
194 //! Selector/Modifier
195 //! Returns the information about pave blocks on source edges
196 Standard_EXPORT BOPDS_VectorOfListOfPaveBlock& ChangePaveBlocksPool();
200 //! Returns true if the shape with index theIndex has the
201 //! information about pave blocks
202 Standard_EXPORT Standard_Boolean HasPaveBlocks (const Standard_Integer theIndex) const;
206 //! Returns the pave blocks for the shape with index theIndex
207 Standard_EXPORT const BOPDS_ListOfPaveBlock& PaveBlocks (const Standard_Integer theIndex) const;
210 //! Selector/Modifier
211 //! Returns the pave blocks for the shape with index theIndex
212 Standard_EXPORT BOPDS_ListOfPaveBlock& ChangePaveBlocks (const Standard_Integer theIndex);
215 //! Update the pave blocks for the all shapes in data structure
216 Standard_EXPORT void UpdatePaveBlocks();
219 //! Update the pave block thePB
220 Standard_EXPORT void UpdatePaveBlock (const Handle(BOPDS_PaveBlock)& thePB);
223 //! Update the common block theCB
224 Standard_EXPORT void UpdateCommonBlock (const Handle(BOPDS_CommonBlock)& theCB,
225 const Standard_Real theFuzz);
229 //! Returns true if the pave block is common block
230 Standard_EXPORT Standard_Boolean IsCommonBlock (const Handle(BOPDS_PaveBlock)& thePB) const;
234 //! Returns the common block
235 Standard_EXPORT Handle(BOPDS_CommonBlock) CommonBlock (const Handle(BOPDS_PaveBlock)& thePB) const;
239 //! Sets the common block <theCB>
240 Standard_EXPORT void SetCommonBlock (const Handle(BOPDS_PaveBlock)& thePB, const Handle(BOPDS_CommonBlock)& theCB);
244 //! Returns the real first pave block
245 Standard_EXPORT Handle(BOPDS_PaveBlock) RealPaveBlock (const Handle(BOPDS_PaveBlock)& thePB) const;
249 //! Returns true if common block contains more then one pave block
250 Standard_EXPORT Standard_Boolean IsCommonBlockOnEdge (const Handle(BOPDS_PaveBlock)& thePB) const;
254 //! Returns the information about state of faces
255 Standard_EXPORT const BOPDS_VectorOfFaceInfo& FaceInfoPool() const;
259 //! Returns true if the shape with index theIndex has the
260 //! information about state of face
261 Standard_EXPORT Standard_Boolean HasFaceInfo (const Standard_Integer theIndex) const;
265 //! Returns the state of face with index theIndex
266 Standard_EXPORT const BOPDS_FaceInfo& FaceInfo (const Standard_Integer theIndex) const;
269 //! Selector/Modifier
270 //! Returns the state of face with index theIndex
271 Standard_EXPORT BOPDS_FaceInfo& ChangeFaceInfo (const Standard_Integer theIndex);
274 //! Update the state In of face with index theIndex
275 Standard_EXPORT void UpdateFaceInfoIn (const Standard_Integer theIndex);
277 //! Update the state IN for all faces in the given map
278 Standard_EXPORT void UpdateFaceInfoIn (const TColStd_MapOfInteger& theFaces);
280 //! Update the state On of face with index theIndex
281 Standard_EXPORT void UpdateFaceInfoOn (const Standard_Integer theIndex);
283 //! Update the state ON for all faces in the given map
284 Standard_EXPORT void UpdateFaceInfoOn (const TColStd_MapOfInteger& theFaces);
287 //! Returns the state On
288 //! [theMPB,theMVP] of face with index theIndex
289 Standard_EXPORT void FaceInfoOn (const Standard_Integer theIndex, BOPDS_IndexedMapOfPaveBlock& theMPB, TColStd_MapOfInteger& theMVP);
293 //! Returns the state In
294 //! [theMPB,theMVP] of face with index theIndex
295 Standard_EXPORT void FaceInfoIn (const Standard_Integer theIndex, BOPDS_IndexedMapOfPaveBlock& theMPB, TColStd_MapOfInteger& theMVP);
299 //! Returns the indices of alone vertices
300 //! for the face with index theIndex
301 Standard_EXPORT void AloneVertices (const Standard_Integer theF, TColStd_ListOfInteger& theLI) const;
304 //! Refine the state On for the all faces having
305 //! state information
308 Standard_EXPORT void RefineFaceInfoOn();
310 //! Removes any pave block from list of having IN state if it has also the state ON.
311 Standard_EXPORT void RefineFaceInfoIn();
313 //! Returns information about ON/IN sub-shapes of the given faces.
314 //! @param theMVOnIn the indices of ON/IN vertices from both faces
315 //! @param theMVCommon the indices of common vertices for both faces
316 //! @param thePBOnIn all On/In pave blocks from both faces
317 //! @param theCommonPB the common pave blocks (that are shared by both faces).
318 Standard_EXPORT void SubShapesOnIn(const Standard_Integer theNF1,
319 const Standard_Integer theNF2,
320 TColStd_MapOfInteger& theMVOnIn,
321 TColStd_MapOfInteger& theMVCommon,
322 BOPDS_IndexedMapOfPaveBlock& thePBOnIn,
323 BOPDS_MapOfPaveBlock& theCommonPB) const;
326 //! Returns the indices of edges that are shared
327 //! for the faces with indices theF1, theF2
329 //! same domain shapes
330 Standard_EXPORT void SharedEdges (const Standard_Integer theF1, const Standard_Integer theF2, TColStd_ListOfInteger& theLI, const Handle(NCollection_BaseAllocator)& theAllocator);
334 //! Returns the collection same domain shapes
335 Standard_EXPORT TColStd_DataMapOfIntegerInteger& ShapesSD();
339 //! Adds the information about same domain shapes
340 //! with indices theIndex, theIndexSD
341 Standard_EXPORT void AddShapeSD (const Standard_Integer theIndex, const Standard_Integer theIndexSD);
345 //! Returns true if the shape with index theIndex has the
346 //! same domain shape. In this case theIndexSD will contain
347 //! the index of same domain shape found
350 Standard_EXPORT Standard_Boolean HasShapeSD (const Standard_Integer theIndex, Standard_Integer& theIndexSD) const;
353 //! Selector/Modifier
354 //! Returns the collection of interferences Vertex/Vertex
355 BOPDS_VectorOfInterfVV& InterfVV();
358 //! Selector/Modifier
359 //! Returns the collection of interferences Vertex/Edge
360 BOPDS_VectorOfInterfVE& InterfVE();
363 //! Selector/Modifier
364 //! Returns the collection of interferences Vertex/Face
365 BOPDS_VectorOfInterfVF& InterfVF();
368 //! Selector/Modifier
369 //! Returns the collection of interferences Edge/Edge
370 BOPDS_VectorOfInterfEE& InterfEE();
373 //! Selector/Modifier
374 //! Returns the collection of interferences Edge/Face
375 BOPDS_VectorOfInterfEF& InterfEF();
378 //! Selector/Modifier
379 //! Returns the collection of interferences Face/Face
380 BOPDS_VectorOfInterfFF& InterfFF();
383 //! Selector/Modifier
384 //! Returns the collection of interferences Vertex/Solid
385 BOPDS_VectorOfInterfVZ& InterfVZ();
388 //! Selector/Modifier
389 //! Returns the collection of interferences Edge/Solid
390 BOPDS_VectorOfInterfEZ& InterfEZ();
393 //! Selector/Modifier
394 //! Returns the collection of interferences Face/Solid
395 BOPDS_VectorOfInterfFZ& InterfFZ();
398 //! Selector/Modifier
399 //! Returns the collection of interferences Solid/Solid
400 BOPDS_VectorOfInterfZZ& InterfZZ();
403 //! Returns the number of types of the interferences
404 static Standard_Integer NbInterfTypes();
407 //! Adds the information about an interference between
408 //! shapes with indices theI1, theI2 to the summary
409 //! table of interferences
410 Standard_Boolean AddInterf (const Standard_Integer theI1, const Standard_Integer theI2);
413 //! Returns true if the shape with index theI
415 Standard_Boolean HasInterf (const Standard_Integer theI) const;
418 //! Returns true if the shapes with indices theI1, theI2
420 Standard_Boolean HasInterf (const Standard_Integer theI1, const Standard_Integer theI2) const;
423 //! Returns true if the shape with index theI1 is interfered
425 //! any sub-shape of the shape with index theI2 (theFlag=true)
426 //! all sub-shapes of the shape with index theI2 (theFlag=false)
427 Standard_EXPORT Standard_Boolean HasInterfShapeSubShapes (const Standard_Integer theI1, const Standard_Integer theI2, const Standard_Boolean theFlag = Standard_True) const;
431 //! Returns true if the shapes with indices theI1, theI2
432 //! have interferred sub-shapes
433 Standard_EXPORT Standard_Boolean HasInterfSubShapes (const Standard_Integer theI1, const Standard_Integer theI2) const;
437 //! Returns the table of interferences
440 const BOPDS_MapOfPair& Interferences() const;
442 Standard_EXPORT void Dump() const;
444 Standard_EXPORT Standard_Boolean IsSubShape (const Standard_Integer theI1, const Standard_Integer theI2);
446 //! Fills theLP with sorted paves
447 //! of the shape with index theIndex
448 Standard_EXPORT void Paves (const Standard_Integer theIndex, BOPDS_ListOfPave& theLP);
450 //! Update the pave blocks for all shapes in data structure
451 Standard_EXPORT void UpdatePaveBlocksWithSDVertices();
453 //! Update the pave block for all shapes in data structure
454 Standard_EXPORT void UpdatePaveBlockWithSDVertices(const Handle(BOPDS_PaveBlock)& thePB);
456 //! Update the pave block of the common block for all shapes in data structure
457 Standard_EXPORT void UpdateCommonBlockWithSDVertices(const Handle(BOPDS_CommonBlock)& theCB);
459 Standard_EXPORT void InitPaveBlocksForVertex(const Standard_Integer theNV);
461 //! Clears information about PaveBlocks for the untouched edges
462 Standard_EXPORT void ReleasePaveBlocks();
464 //! Checks if the existing shrunk data of the pave block is still valid.<br>
465 //! The shrunk data may become invalid if e.g. the vertices of the pave block
466 //! have been replaced with the new one with bigger tolerances, or the tolerances
467 //! of the existing vertices have been increased.
468 Standard_EXPORT Standard_Boolean IsValidShrunkData(const Handle(BOPDS_PaveBlock)& thePB);
470 //! Computes bounding box <theBox> for the solid with DS-index <theIndex>.
471 //! The flag <theCheckInverted> enables/disables the check of the solid
472 //! for inverted status. By default the solids will be checked.
473 Standard_EXPORT void BuildBndBoxSolid (const Standard_Integer theIndex,
475 const Standard_Boolean theCheckInverted = Standard_True);
481 //! Initializes the pave blocks for the shape with index theIndex
482 Standard_EXPORT void InitPaveBlocks (const Standard_Integer theIndex);
484 //! Initializes the state of face with index theIndex
485 Standard_EXPORT void InitFaceInfo (const Standard_Integer theIndex);
487 //! Initializes the FaceInfo structure for face with index theIndex with elements
488 //! having IN state for the face
489 Standard_EXPORT void InitFaceInfoIn (const Standard_Integer theIndex);
491 Standard_EXPORT void InitShape (const Standard_Integer theIndex, const TopoDS_Shape& theS);
493 Standard_EXPORT Standard_Boolean CheckCoincidence (const Handle(BOPDS_PaveBlock)& thePB1,
494 const Handle(BOPDS_PaveBlock)& thePB2,
495 const Standard_Real theFuzz);
498 Handle(NCollection_BaseAllocator) myAllocator;
499 TopTools_ListOfShape myArguments;
500 Standard_Integer myNbShapes;
501 Standard_Integer myNbSourceShapes;
502 BOPDS_VectorOfIndexRange myRanges;
503 BOPDS_VectorOfShapeInfo myLines;
504 TopTools_DataMapOfShapeInteger myMapShapeIndex;
505 BOPDS_VectorOfListOfPaveBlock myPaveBlocksPool;
506 BOPDS_DataMapOfPaveBlockCommonBlock myMapPBCB;
507 BOPDS_VectorOfFaceInfo myFaceInfoPool;
508 TColStd_DataMapOfIntegerInteger myShapesSD;
509 TColStd_DataMapOfIntegerListOfInteger myMapVE;
510 BOPDS_MapOfPair myInterfTB;
511 BOPDS_VectorOfInterfVV myInterfVV;
512 BOPDS_VectorOfInterfVE myInterfVE;
513 BOPDS_VectorOfInterfVF myInterfVF;
514 BOPDS_VectorOfInterfEE myInterfEE;
515 BOPDS_VectorOfInterfEF myInterfEF;
516 BOPDS_VectorOfInterfFF myInterfFF;
517 BOPDS_VectorOfInterfVZ myInterfVZ;
518 BOPDS_VectorOfInterfEZ myInterfEZ;
519 BOPDS_VectorOfInterfFZ myInterfFZ;
520 BOPDS_VectorOfInterfZZ myInterfZZ;
521 TColStd_MapOfInteger myInterfered;
533 #include <BOPDS_DS.lxx>
539 #endif // _BOPDS_DS_HeaderFile