1 // Created by: Peter KURNEV 2 // Copyright (c) 1999-2014 OPEN CASCADE SAS 3 // 4 // This file is part of Open CASCADE Technology software library. 5 // 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. 11 // 12 // Alternatively, this file may be used under the terms of Open CASCADE 13 // commercial license or contractual agreement. 14 15 #ifndef _BOPDS_DS_HeaderFile 16 #define _BOPDS_DS_HeaderFile 17 18 #include <Standard.hxx> 19 #include <Standard_DefineAlloc.hxx> 20 #include <Standard_Handle.hxx> 21 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> 53 54 class BOPDS_IndexRange; 55 class BOPDS_ShapeInfo; 56 class TopoDS_Shape; 57 class BOPDS_PaveBlock; 58 class BOPDS_CommonBlock; 59 class BOPDS_FaceInfo; 60 class Bnd_Box; 61 62 63 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> 68 //! 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] 81 class BOPDS_DS 82 { 83 public: 84 85 DEFINE_STANDARD_ALLOC 86 87 88 89 //! Empty constructor 90 Standard_EXPORT BOPDS_DS(); 91 92 Standard_EXPORT virtual ~BOPDS_DS(); 93 94 //! Constructor 95 //! @param theAllocator the allocator to manage the memory 96 Standard_EXPORT BOPDS_DS(const Handle(NCollection_BaseAllocator)& theAllocator); 97 98 99 //! Clears the contents 100 Standard_EXPORT void Clear(); 101 102 103 //! Selector 104 Standard_EXPORT const Handle(NCollection_BaseAllocator)& Allocator() const; 105 106 107 //! Modifier 108 //! Sets the arguments [theLS] of an operation 109 Standard_EXPORT void SetArguments (const TopTools_ListOfShape& theLS); 110 111 112 //! Selector 113 //! Returns the arguments of an operation 114 Standard_EXPORT const TopTools_ListOfShape& Arguments() const; 115 116 117 //! Initializes the data structure for 118 //! the arguments 119 Standard_EXPORT void Init(const Standard_Real theFuzz = Precision::Confusion()); 120 121 122 //! Selector 123 //! Returns the total number of shapes stored 124 Standard_EXPORT Standard_Integer NbShapes() const; 125 126 127 //! Selector 128 //! Returns the total number of source shapes stored 129 Standard_EXPORT Standard_Integer NbSourceShapes() const; 130 131 132 //! Selector 133 //! Returns the number of index ranges 134 Standard_EXPORT Standard_Integer NbRanges() const; 135 136 137 //! Selector 138 //! Returns the index range "i" 139 Standard_EXPORT const BOPDS_IndexRange& Range (const Standard_Integer theIndex) const; 140 141 142 //! Selector 143 //! Returns the rank of the shape of index "i" 144 Standard_EXPORT Standard_Integer Rank (const Standard_Integer theIndex) const; 145 146 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; 150 151 152 //! Modifier 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); 157 158 159 //! Modifier 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); 164 165 166 //! Selector 167 //! Returns the information about the shape 168 //! with index theIndex 169 Standard_EXPORT const BOPDS_ShapeInfo& ShapeInfo (const Standard_Integer theIndex) const; 170 171 172 //! Selector/Modifier 173 //! Returns the information about the shape 174 //! with index theIndex 175 Standard_EXPORT BOPDS_ShapeInfo& ChangeShapeInfo (const Standard_Integer theIndex); 176 177 178 //! Selector 179 //! Returns the shape 180 //! with index theIndex 181 Standard_EXPORT const TopoDS_Shape& Shape (const Standard_Integer theIndex) const; 182 183 184 //! Selector 185 //! Returns the index of the shape theS 186 Standard_EXPORT Standard_Integer Index (const TopoDS_Shape& theS) const; 187 188 189 //! Selector 190 //! Returns the information about pave blocks on source edges 191 Standard_EXPORT const BOPDS_VectorOfListOfPaveBlock& PaveBlocksPool() const; 192 193 194 //! Selector/Modifier 195 //! Returns the information about pave blocks on source edges 196 Standard_EXPORT BOPDS_VectorOfListOfPaveBlock& ChangePaveBlocksPool(); 197 198 199 //! Query 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; 203 204 205 //! Selector 206 //! Returns the pave blocks for the shape with index theIndex 207 Standard_EXPORT const BOPDS_ListOfPaveBlock& PaveBlocks (const Standard_Integer theIndex) const; 208 209 210 //! Selector/Modifier 211 //! Returns the pave blocks for the shape with index theIndex 212 Standard_EXPORT BOPDS_ListOfPaveBlock& ChangePaveBlocks (const Standard_Integer theIndex); 213 214 215 //! Update the pave blocks for the all shapes in data structure 216 Standard_EXPORT void UpdatePaveBlocks(); 217 218 219 //! Update the pave block thePB 220 Standard_EXPORT void UpdatePaveBlock (const Handle(BOPDS_PaveBlock)& thePB); 221 222 223 //! Update the common block theCB 224 Standard_EXPORT void UpdateCommonBlock (const Handle(BOPDS_CommonBlock)& theCB, 225 const Standard_Real theFuzz); 226 227 228 //! Query 229 //! Returns true if the pave block is common block 230 Standard_EXPORT Standard_Boolean IsCommonBlock (const Handle(BOPDS_PaveBlock)& thePB) const; 231 232 233 //! Selector 234 //! Returns the common block 235 Standard_EXPORT Handle(BOPDS_CommonBlock) CommonBlock (const Handle(BOPDS_PaveBlock)& thePB) const; 236 237 238 //! Modifier 239 //! Sets the common block <theCB> 240 Standard_EXPORT void SetCommonBlock (const Handle(BOPDS_PaveBlock)& thePB, const Handle(BOPDS_CommonBlock)& theCB); 241 242 243 //! Selector 244 //! Returns the real first pave block 245 Standard_EXPORT Handle(BOPDS_PaveBlock) RealPaveBlock (const Handle(BOPDS_PaveBlock)& thePB) const; 246 247 248 //! Query 249 //! Returns true if common block contains more then one pave block 250 Standard_EXPORT Standard_Boolean IsCommonBlockOnEdge (const Handle(BOPDS_PaveBlock)& thePB) const; 251 252 253 //! Selector 254 //! Returns the information about state of faces 255 Standard_EXPORT const BOPDS_VectorOfFaceInfo& FaceInfoPool() const; 256 257 258 //! Query 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; 262 263 264 //! Selector 265 //! Returns the state of face with index theIndex 266 Standard_EXPORT const BOPDS_FaceInfo& FaceInfo (const Standard_Integer theIndex) const; 267 268 269 //! Selector/Modifier 270 //! Returns the state of face with index theIndex 271 Standard_EXPORT BOPDS_FaceInfo& ChangeFaceInfo (const Standard_Integer theIndex); 272 273 274 //! Update the state In of face with index theIndex 275 Standard_EXPORT void UpdateFaceInfoIn (const Standard_Integer theIndex); 276 277 //! Update the state IN for all faces in the given map 278 Standard_EXPORT void UpdateFaceInfoIn (const TColStd_MapOfInteger& theFaces); 279 280 //! Update the state On of face with index theIndex 281 Standard_EXPORT void UpdateFaceInfoOn (const Standard_Integer theIndex); 282 283 //! Update the state ON for all faces in the given map 284 Standard_EXPORT void UpdateFaceInfoOn (const TColStd_MapOfInteger& theFaces); 285 286 //! Selector 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); 290 291 292 //! Selector 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); 296 297 298 //! Selector 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; 302 303 304 //! Refine the state On for the all faces having 305 //! state information 306 //! 307 //! ++ 308 Standard_EXPORT void RefineFaceInfoOn(); 309 310 //! Removes any pave block from list of having IN state if it has also the state ON. 311 Standard_EXPORT void RefineFaceInfoIn(); 312 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; 324 325 326 //! Returns the indices of edges that are shared 327 //! for the faces with indices theF1, theF2 328 //! 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); 331 332 333 //! Selector 334 //! Returns the collection same domain shapes 335 Standard_EXPORT TColStd_DataMapOfIntegerInteger& ShapesSD(); 336 337 338 //! Modifier 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); 342 343 344 //! Query 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 348 //! 349 //! interferences 350 Standard_EXPORT Standard_Boolean HasShapeSD (const Standard_Integer theIndex, Standard_Integer& theIndexSD) const; 351 352 353 //! Selector/Modifier 354 //! Returns the collection of interferences Vertex/Vertex 355 BOPDS_VectorOfInterfVV& InterfVV(); 356 357 358 //! Selector/Modifier 359 //! Returns the collection of interferences Vertex/Edge 360 BOPDS_VectorOfInterfVE& InterfVE(); 361 362 363 //! Selector/Modifier 364 //! Returns the collection of interferences Vertex/Face 365 BOPDS_VectorOfInterfVF& InterfVF(); 366 367 368 //! Selector/Modifier 369 //! Returns the collection of interferences Edge/Edge 370 BOPDS_VectorOfInterfEE& InterfEE(); 371 372 373 //! Selector/Modifier 374 //! Returns the collection of interferences Edge/Face 375 BOPDS_VectorOfInterfEF& InterfEF(); 376 377 378 //! Selector/Modifier 379 //! Returns the collection of interferences Face/Face 380 BOPDS_VectorOfInterfFF& InterfFF(); 381 382 383 //! Selector/Modifier 384 //! Returns the collection of interferences Vertex/Solid 385 BOPDS_VectorOfInterfVZ& InterfVZ(); 386 387 388 //! Selector/Modifier 389 //! Returns the collection of interferences Edge/Solid 390 BOPDS_VectorOfInterfEZ& InterfEZ(); 391 392 393 //! Selector/Modifier 394 //! Returns the collection of interferences Face/Solid 395 BOPDS_VectorOfInterfFZ& InterfFZ(); 396 397 398 //! Selector/Modifier 399 //! Returns the collection of interferences Solid/Solid 400 BOPDS_VectorOfInterfZZ& InterfZZ(); 401 402 403 //! Returns the number of types of the interferences 404 static Standard_Integer NbInterfTypes(); 405 406 //! Modifier 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); 411 412 //! Query 413 //! Returns true if the shape with index theI 414 //! is interferred 415 Standard_Boolean HasInterf (const Standard_Integer theI) const; 416 417 //! Query 418 //! Returns true if the shapes with indices theI1, theI2 419 //! are interferred 420 Standard_Boolean HasInterf (const Standard_Integer theI1, const Standard_Integer theI2) const; 421 422 //! Query 423 //! Returns true if the shape with index theI1 is interfered 424 //! with 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; 428 429 430 //! Query 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; 434 435 436 //! Selector 437 //! Returns the table of interferences 438 //! 439 //! debug 440 const BOPDS_MapOfPair& Interferences() const; 441 442 Standard_EXPORT void Dump() const; 443 444 Standard_EXPORT Standard_Boolean IsSubShape (const Standard_Integer theI1, const Standard_Integer theI2); 445 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); 449 450 //! Update the pave blocks for all shapes in data structure 451 Standard_EXPORT void UpdatePaveBlocksWithSDVertices(); 452 453 //! Update the pave block for all shapes in data structure 454 Standard_EXPORT void UpdatePaveBlockWithSDVertices(const Handle(BOPDS_PaveBlock)& thePB); 455 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); 458 459 Standard_EXPORT void InitPaveBlocksForVertex(const Standard_Integer theNV); 460 461 //! Clears information about PaveBlocks for the untouched edges 462 Standard_EXPORT void ReleasePaveBlocks(); 463 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); 469 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, 474 Bnd_Box& theBox, 475 const Standard_Boolean theCheckInverted = Standard_True); 476 477 protected: 478 479 480 481 //! Initializes the pave blocks for the shape with index theIndex 482 Standard_EXPORT void InitPaveBlocks (const Standard_Integer theIndex); 483 484 //! Initializes the state of face with index theIndex 485 Standard_EXPORT void InitFaceInfo (const Standard_Integer theIndex); 486 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); 490 491 Standard_EXPORT void InitShape (const Standard_Integer theIndex, const TopoDS_Shape& theS); 492 493 Standard_EXPORT Standard_Boolean CheckCoincidence (const Handle(BOPDS_PaveBlock)& thePB1, 494 const Handle(BOPDS_PaveBlock)& thePB2, 495 const Standard_Real theFuzz); 496 497 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; 522 523 524 private: 525 526 527 528 529 530 }; 531 532 533 #include <BOPDS_DS.lxx> 534 535 536 537 538 539 #endif // _BOPDS_DS_HeaderFile 540