Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:04

0001 // Created by: Peter KURNEV
0002 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _BOPDS_DS_HeaderFile
0016 #define _BOPDS_DS_HeaderFile
0017 
0018 #include <Standard.hxx>
0019 #include <Standard_DefineAlloc.hxx>
0020 #include <Standard_Handle.hxx>
0021 
0022 #include <BOPDS_DataMapOfPaveBlockCommonBlock.hxx>
0023 #include <BOPDS_ListOfPaveBlock.hxx>
0024 #include <BOPDS_MapOfPair.hxx>
0025 #include <BOPDS_MapOfPaveBlock.hxx>
0026 #include <BOPDS_VectorOfFaceInfo.hxx>
0027 #include <BOPDS_VectorOfIndexRange.hxx>
0028 #include <BOPDS_VectorOfInterfEE.hxx>
0029 #include <BOPDS_VectorOfInterfEF.hxx>
0030 #include <BOPDS_VectorOfInterfEZ.hxx>
0031 #include <BOPDS_VectorOfInterfFF.hxx>
0032 #include <BOPDS_VectorOfInterfFZ.hxx>
0033 #include <BOPDS_VectorOfInterfVE.hxx>
0034 #include <BOPDS_VectorOfInterfVF.hxx>
0035 #include <BOPDS_VectorOfInterfVV.hxx>
0036 #include <BOPDS_VectorOfInterfVZ.hxx>
0037 #include <BOPDS_VectorOfInterfZZ.hxx>
0038 #include <BOPDS_VectorOfListOfPaveBlock.hxx>
0039 #include <BOPDS_VectorOfShapeInfo.hxx>
0040 #include <NCollection_BaseAllocator.hxx>
0041 #include <Precision.hxx>
0042 #include <Standard_Integer.hxx>
0043 #include <Standard_Real.hxx>
0044 #include <TColStd_DataMapOfIntegerInteger.hxx>
0045 #include <TColStd_DataMapOfIntegerListOfInteger.hxx>
0046 #include <TColStd_ListOfInteger.hxx>
0047 #include <TColStd_MapOfInteger.hxx>
0048 #include <TopTools_DataMapOfShapeInteger.hxx>
0049 #include <TopTools_ListOfShape.hxx>
0050 
0051 class BOPDS_IndexRange;
0052 class BOPDS_ShapeInfo;
0053 class TopoDS_Shape;
0054 class BOPDS_PaveBlock;
0055 class BOPDS_CommonBlock;
0056 class BOPDS_FaceInfo;
0057 class Bnd_Box;
0058 
0059 
0060 
0061 //! The class BOPDS_DS provides the control
0062 //! of data structure for the algorithms in the
0063 //! Boolean Component such as General Fuse, Boolean operations,
0064 //! Section, Maker Volume, Splitter and Cells Builder.<br>
0065 //!
0066 //! The data structure has the  following contents:<br>
0067 //! 1. the arguments of an operation [myArguments];<br>
0068 //! 2  the information about arguments/new shapes
0069 //! and their sub-shapes (type of the shape,
0070 //! bounding box, etc) [myLines];<br>
0071 //! 3. each argument shape(and its subshapes)
0072 //! has/have own range of indices (rank);<br>
0073 //! 4. pave blocks on source edges [myPaveBlocksPool];<br>
0074 //! 5. the state of source faces  [myFaceInfoPool];<br>
0075 //! 6  the collection of same domain shapes [myShapesSD];<br>
0076 //! 7  the collection of interferences  [myInterfTB,
0077 //! myInterfVV,..myInterfFF]
0078 class BOPDS_DS 
0079 {
0080 public:
0081 
0082   DEFINE_STANDARD_ALLOC
0083 
0084   
0085 
0086   //! Empty constructor
0087   Standard_EXPORT BOPDS_DS();
0088 
0089   Standard_EXPORT virtual ~BOPDS_DS();
0090 
0091   //! Constructor
0092   //! @param theAllocator the allocator to manage the memory
0093   Standard_EXPORT BOPDS_DS(const Handle(NCollection_BaseAllocator)& theAllocator);
0094   
0095 
0096   //! Clears the contents
0097   Standard_EXPORT void Clear();
0098   
0099 
0100   //! Selector
0101   Standard_EXPORT const Handle(NCollection_BaseAllocator)& Allocator() const;
0102   
0103 
0104   //! Modifier
0105   //! Sets the arguments [theLS] of an operation
0106   Standard_EXPORT void SetArguments (const TopTools_ListOfShape& theLS);
0107   
0108 
0109   //! Selector
0110   //! Returns the arguments of an operation
0111   Standard_EXPORT const TopTools_ListOfShape& Arguments() const;
0112   
0113 
0114   //! Initializes the data structure for
0115   //! the arguments
0116   Standard_EXPORT void Init(const Standard_Real theFuzz = Precision::Confusion());
0117   
0118 
0119   //! Selector
0120   //! Returns the total number of shapes stored
0121   Standard_EXPORT Standard_Integer NbShapes() const;
0122   
0123 
0124   //! Selector
0125   //! Returns the total number of source shapes stored
0126   Standard_EXPORT Standard_Integer NbSourceShapes() const;
0127   
0128 
0129   //! Selector
0130   //! Returns the number of index ranges
0131   Standard_EXPORT Standard_Integer NbRanges() const;
0132   
0133 
0134   //! Selector
0135   //! Returns the index range "i"
0136   Standard_EXPORT const BOPDS_IndexRange& Range (const Standard_Integer theIndex) const;
0137   
0138 
0139   //! Selector
0140   //! Returns the rank of the shape of index "i"
0141   Standard_EXPORT Standard_Integer Rank (const Standard_Integer theIndex) const;
0142   
0143 
0144   //! Returns true if the shape of index "i" is not
0145   //! the source shape/sub-shape
0146   Standard_EXPORT Standard_Boolean IsNewShape (const Standard_Integer theIndex) const;
0147   
0148 
0149   //! Modifier
0150   //! Appends the information about the shape [theSI]
0151   //! to the data structure
0152   //! Returns the index of theSI in the data structure
0153   Standard_EXPORT Standard_Integer Append (const BOPDS_ShapeInfo& theSI);
0154   
0155 
0156   //! Modifier
0157   //! Appends the default information about the shape [theS]
0158   //! to the data structure
0159   //! Returns the index of theS in the data structure
0160   Standard_EXPORT Standard_Integer Append (const TopoDS_Shape& theS);
0161   
0162 
0163   //! Selector
0164   //! Returns the information about the shape
0165   //! with index theIndex
0166   Standard_EXPORT const BOPDS_ShapeInfo& ShapeInfo (const Standard_Integer theIndex) const;
0167   
0168 
0169   //! Selector/Modifier
0170   //! Returns the information about the shape
0171   //! with index theIndex
0172   Standard_EXPORT BOPDS_ShapeInfo& ChangeShapeInfo (const Standard_Integer theIndex);
0173   
0174 
0175   //! Selector
0176   //! Returns the shape
0177   //! with index theIndex
0178   Standard_EXPORT const TopoDS_Shape& Shape (const Standard_Integer theIndex) const;
0179   
0180 
0181   //! Selector
0182   //! Returns the index  of the shape theS
0183   Standard_EXPORT Standard_Integer Index (const TopoDS_Shape& theS) const;
0184   
0185 
0186   //! Selector
0187   //! Returns the information about pave blocks on source edges
0188   Standard_EXPORT const BOPDS_VectorOfListOfPaveBlock& PaveBlocksPool() const;
0189   
0190 
0191   //! Selector/Modifier
0192   //! Returns the information about pave blocks on source edges
0193   Standard_EXPORT BOPDS_VectorOfListOfPaveBlock& ChangePaveBlocksPool();
0194   
0195 
0196   //! Query
0197   //! Returns true if the shape with index theIndex has the
0198   //! information about pave blocks
0199   Standard_EXPORT Standard_Boolean HasPaveBlocks (const Standard_Integer theIndex) const;
0200   
0201 
0202   //! Selector
0203   //! Returns the pave blocks for the shape with index theIndex
0204   Standard_EXPORT const BOPDS_ListOfPaveBlock& PaveBlocks (const Standard_Integer theIndex) const;
0205   
0206 
0207   //! Selector/Modifier
0208   //! Returns the pave blocks for the shape with index theIndex
0209   Standard_EXPORT BOPDS_ListOfPaveBlock& ChangePaveBlocks (const Standard_Integer theIndex);
0210   
0211 
0212   //! Update the pave blocks for the all shapes in data structure
0213   Standard_EXPORT void UpdatePaveBlocks();
0214   
0215 
0216   //! Update the pave block thePB
0217   Standard_EXPORT void UpdatePaveBlock (const Handle(BOPDS_PaveBlock)& thePB);
0218   
0219 
0220   //! Update the common block theCB
0221   Standard_EXPORT void UpdateCommonBlock (const Handle(BOPDS_CommonBlock)& theCB,
0222                                           const Standard_Real theFuzz);
0223   
0224 
0225   //! Query
0226   //! Returns true if the pave block is common block
0227   Standard_EXPORT Standard_Boolean IsCommonBlock (const Handle(BOPDS_PaveBlock)& thePB) const;
0228   
0229 
0230   //! Selector
0231   //! Returns the common block
0232   Standard_EXPORT Handle(BOPDS_CommonBlock) CommonBlock (const Handle(BOPDS_PaveBlock)& thePB) const;
0233   
0234 
0235   //! Modifier
0236   //! Sets the common block <theCB>
0237   Standard_EXPORT void SetCommonBlock (const Handle(BOPDS_PaveBlock)& thePB, const Handle(BOPDS_CommonBlock)& theCB);
0238   
0239 
0240   //! Selector
0241   //! Returns the real first pave block
0242   Standard_EXPORT Handle(BOPDS_PaveBlock) RealPaveBlock (const Handle(BOPDS_PaveBlock)& thePB) const;
0243   
0244 
0245   //! Query
0246   //! Returns true if common block contains more then one pave block
0247   Standard_EXPORT Standard_Boolean IsCommonBlockOnEdge (const Handle(BOPDS_PaveBlock)& thePB) const;
0248   
0249 
0250   //! Selector
0251   //! Returns the information about state of faces
0252   Standard_EXPORT const BOPDS_VectorOfFaceInfo& FaceInfoPool() const;
0253   
0254 
0255   //! Query
0256   //! Returns true if the shape with index theIndex has the
0257   //! information about state of face
0258   Standard_EXPORT Standard_Boolean HasFaceInfo (const Standard_Integer theIndex) const;
0259   
0260 
0261   //! Selector
0262   //! Returns the state of face with index theIndex
0263   Standard_EXPORT const BOPDS_FaceInfo& FaceInfo (const Standard_Integer theIndex) const;
0264   
0265 
0266   //! Selector/Modifier
0267   //! Returns the state of face with index theIndex
0268   Standard_EXPORT BOPDS_FaceInfo& ChangeFaceInfo (const Standard_Integer theIndex);
0269   
0270 
0271   //! Update the state In of face with index theIndex
0272   Standard_EXPORT void UpdateFaceInfoIn (const Standard_Integer theIndex);
0273   
0274   //! Update the state IN for all faces in the given map
0275   Standard_EXPORT void UpdateFaceInfoIn (const TColStd_MapOfInteger& theFaces);
0276 
0277   //! Update the state On of face with index theIndex
0278   Standard_EXPORT void UpdateFaceInfoOn (const Standard_Integer theIndex);
0279   
0280   //! Update the state ON for all faces in the given map
0281   Standard_EXPORT void UpdateFaceInfoOn (const TColStd_MapOfInteger& theFaces);
0282 
0283   //! Selector
0284   //! Returns the state On
0285   //! [theMPB,theMVP] of face with index theIndex
0286   Standard_EXPORT void FaceInfoOn (const Standard_Integer theIndex, BOPDS_IndexedMapOfPaveBlock& theMPB, TColStd_MapOfInteger& theMVP);
0287   
0288 
0289   //! Selector
0290   //! Returns the state In
0291   //! [theMPB,theMVP] of face with index theIndex
0292   Standard_EXPORT void FaceInfoIn (const Standard_Integer theIndex, BOPDS_IndexedMapOfPaveBlock& theMPB, TColStd_MapOfInteger& theMVP);
0293   
0294 
0295   //! Selector
0296   //! Returns the indices of alone vertices
0297   //! for the face with index theIndex
0298   Standard_EXPORT void AloneVertices (const Standard_Integer theF, TColStd_ListOfInteger& theLI) const;
0299   
0300 
0301   //! Refine the state On for the all faces having
0302   //! state information
0303   //!
0304   //! ++
0305   Standard_EXPORT void RefineFaceInfoOn();
0306   
0307   //! Removes any pave block from list of having IN state if it has also the state ON.
0308   Standard_EXPORT void RefineFaceInfoIn();
0309 
0310   //! Returns information about ON/IN sub-shapes of the given faces.
0311   //! @param theMVOnIn  the indices of ON/IN vertices from both faces
0312   //! @param theMVCommon the indices of common vertices for both faces
0313   //! @param thePBOnIn  all On/In pave blocks from both faces
0314   //! @param theCommonPB  the common pave blocks (that are shared by both faces).
0315   Standard_EXPORT void SubShapesOnIn(const Standard_Integer theNF1,
0316                                      const Standard_Integer theNF2,
0317                                      TColStd_MapOfInteger& theMVOnIn,
0318                                      TColStd_MapOfInteger& theMVCommon,
0319                                      BOPDS_IndexedMapOfPaveBlock& thePBOnIn,
0320                                      BOPDS_MapOfPaveBlock& theCommonPB) const;
0321   
0322 
0323   //! Returns the indices of edges that are  shared
0324   //! for the faces with indices theF1, theF2
0325   //!
0326   //! same domain shapes
0327   Standard_EXPORT void SharedEdges (const Standard_Integer theF1, const Standard_Integer theF2, TColStd_ListOfInteger& theLI, const Handle(NCollection_BaseAllocator)& theAllocator);
0328   
0329 
0330   //! Selector
0331   //! Returns the collection same domain shapes
0332   Standard_EXPORT TColStd_DataMapOfIntegerInteger& ShapesSD();
0333   
0334 
0335   //! Modifier
0336   //! Adds the information about same domain shapes
0337   //! with indices theIndex, theIndexSD
0338   Standard_EXPORT void AddShapeSD (const Standard_Integer theIndex, const Standard_Integer theIndexSD);
0339   
0340 
0341   //! Query
0342   //! Returns true if the shape with index theIndex has the
0343   //! same domain shape. In this case theIndexSD will contain
0344   //! the index of same domain shape found
0345   //!
0346   //! interferences
0347   Standard_EXPORT Standard_Boolean HasShapeSD (const Standard_Integer theIndex, Standard_Integer& theIndexSD) const;
0348   
0349 
0350   //! Selector/Modifier
0351   //! Returns the collection of interferences Vertex/Vertex
0352     BOPDS_VectorOfInterfVV& InterfVV();
0353   
0354 
0355   //! Selector/Modifier
0356   //! Returns the collection of interferences Vertex/Edge
0357     BOPDS_VectorOfInterfVE& InterfVE();
0358   
0359 
0360   //! Selector/Modifier
0361   //! Returns the collection of interferences Vertex/Face
0362     BOPDS_VectorOfInterfVF& InterfVF();
0363   
0364 
0365   //! Selector/Modifier
0366   //! Returns the collection of interferences Edge/Edge
0367     BOPDS_VectorOfInterfEE& InterfEE();
0368   
0369 
0370   //! Selector/Modifier
0371   //! Returns the collection of interferences Edge/Face
0372     BOPDS_VectorOfInterfEF& InterfEF();
0373   
0374 
0375   //! Selector/Modifier
0376   //! Returns the collection of interferences Face/Face
0377     BOPDS_VectorOfInterfFF& InterfFF();
0378   
0379 
0380   //! Selector/Modifier
0381   //! Returns the collection of interferences Vertex/Solid
0382     BOPDS_VectorOfInterfVZ& InterfVZ();
0383   
0384 
0385   //! Selector/Modifier
0386   //! Returns the collection of interferences Edge/Solid
0387     BOPDS_VectorOfInterfEZ& InterfEZ();
0388   
0389 
0390   //! Selector/Modifier
0391   //! Returns the collection of interferences Face/Solid
0392     BOPDS_VectorOfInterfFZ& InterfFZ();
0393   
0394 
0395   //! Selector/Modifier
0396   //! Returns the collection of interferences Solid/Solid
0397     BOPDS_VectorOfInterfZZ& InterfZZ();
0398   
0399 
0400   //! Returns the number of types of the interferences
0401   static Standard_Integer NbInterfTypes();
0402 
0403   //! Modifier
0404   //! Adds the information about an interference between
0405   //! shapes with indices theI1, theI2 to the summary
0406   //! table of interferences
0407   Standard_Boolean AddInterf (const Standard_Integer theI1, const Standard_Integer theI2);
0408 
0409   //! Query
0410   //! Returns true if the shape with index theI
0411   //! is interferred
0412   Standard_Boolean HasInterf (const Standard_Integer theI) const;
0413 
0414   //! Query
0415   //! Returns true if the shapes with indices theI1, theI2
0416   //! are interferred
0417   Standard_Boolean HasInterf (const Standard_Integer theI1, const Standard_Integer theI2) const;
0418 
0419   //! Query
0420   //! Returns true if the shape with index theI1 is interfered
0421   //! with
0422   //! any sub-shape of the shape with index theI2  (theFlag=true)
0423   //! all sub-shapes of the shape with index theI2 (theFlag=false)
0424   Standard_EXPORT Standard_Boolean HasInterfShapeSubShapes (const Standard_Integer theI1, const Standard_Integer theI2, const Standard_Boolean theFlag = Standard_True) const;
0425   
0426 
0427   //! Query
0428   //! Returns true if the shapes with indices theI1, theI2
0429   //! have interferred sub-shapes
0430   Standard_EXPORT Standard_Boolean HasInterfSubShapes (const Standard_Integer theI1, const Standard_Integer theI2) const;
0431   
0432 
0433   //! Selector
0434   //! Returns the table of interferences
0435   //!
0436   //! debug
0437     const BOPDS_MapOfPair& Interferences() const;
0438   
0439   Standard_EXPORT void Dump() const;
0440   
0441   Standard_EXPORT Standard_Boolean IsSubShape (const Standard_Integer theI1, const Standard_Integer theI2);
0442   
0443   //! Fills theLP with sorted paves
0444   //! of the shape with index theIndex
0445   Standard_EXPORT void Paves (const Standard_Integer theIndex, BOPDS_ListOfPave& theLP);
0446 
0447   //! Update the pave blocks for all shapes in data structure
0448   Standard_EXPORT void UpdatePaveBlocksWithSDVertices();
0449 
0450   //! Update the pave block for all shapes in data structure
0451   Standard_EXPORT void UpdatePaveBlockWithSDVertices(const Handle(BOPDS_PaveBlock)& thePB);
0452 
0453   //! Update the pave block of the common block for all shapes in data structure
0454   Standard_EXPORT void UpdateCommonBlockWithSDVertices(const Handle(BOPDS_CommonBlock)& theCB);
0455 
0456   Standard_EXPORT void InitPaveBlocksForVertex(const Standard_Integer theNV);
0457 
0458   //! Clears information about PaveBlocks for the untouched edges
0459   Standard_EXPORT void ReleasePaveBlocks();
0460 
0461   //! Checks if the existing shrunk data of the pave block is still valid.<br>
0462   //! The shrunk data may become invalid if e.g. the vertices of the pave block
0463   //! have been replaced with the new one with bigger tolerances, or the tolerances
0464   //! of the existing vertices have been increased.
0465   Standard_EXPORT Standard_Boolean IsValidShrunkData(const Handle(BOPDS_PaveBlock)& thePB);
0466 
0467   //! Computes bounding box <theBox> for the solid with DS-index <theIndex>.
0468   //! The flag <theCheckInverted> enables/disables the check of the solid
0469   //! for inverted status. By default the solids will be checked.
0470   Standard_EXPORT void BuildBndBoxSolid (const Standard_Integer theIndex,
0471                                          Bnd_Box& theBox,
0472                                          const Standard_Boolean theCheckInverted = Standard_True);
0473 
0474 protected:
0475 
0476   
0477 
0478   //! Initializes the pave blocks for the shape with index theIndex
0479   Standard_EXPORT void InitPaveBlocks (const Standard_Integer theIndex);
0480 
0481   //! Initializes the state of face with index theIndex
0482   Standard_EXPORT void InitFaceInfo (const Standard_Integer theIndex);
0483 
0484   //! Initializes the FaceInfo structure for face with index theIndex with elements
0485   //! having IN state for the face
0486   Standard_EXPORT void InitFaceInfoIn (const Standard_Integer theIndex);
0487   
0488   Standard_EXPORT void InitShape (const Standard_Integer theIndex, const TopoDS_Shape& theS);
0489   
0490   Standard_EXPORT Standard_Boolean CheckCoincidence (const Handle(BOPDS_PaveBlock)& thePB1,
0491                                                      const Handle(BOPDS_PaveBlock)& thePB2,
0492                                                      const Standard_Real theFuzz);
0493 
0494 
0495   Handle(NCollection_BaseAllocator) myAllocator;
0496   TopTools_ListOfShape myArguments;
0497   Standard_Integer myNbShapes;
0498   Standard_Integer myNbSourceShapes;
0499   BOPDS_VectorOfIndexRange myRanges;
0500   BOPDS_VectorOfShapeInfo myLines;
0501   TopTools_DataMapOfShapeInteger myMapShapeIndex;
0502   BOPDS_VectorOfListOfPaveBlock myPaveBlocksPool;
0503   BOPDS_DataMapOfPaveBlockCommonBlock myMapPBCB;
0504   BOPDS_VectorOfFaceInfo myFaceInfoPool;
0505   TColStd_DataMapOfIntegerInteger myShapesSD;
0506   TColStd_DataMapOfIntegerListOfInteger myMapVE;
0507   BOPDS_MapOfPair myInterfTB;
0508   BOPDS_VectorOfInterfVV myInterfVV;
0509   BOPDS_VectorOfInterfVE myInterfVE;
0510   BOPDS_VectorOfInterfVF myInterfVF;
0511   BOPDS_VectorOfInterfEE myInterfEE;
0512   BOPDS_VectorOfInterfEF myInterfEF;
0513   BOPDS_VectorOfInterfFF myInterfFF;
0514   BOPDS_VectorOfInterfVZ myInterfVZ;
0515   BOPDS_VectorOfInterfEZ myInterfEZ;
0516   BOPDS_VectorOfInterfFZ myInterfFZ;
0517   BOPDS_VectorOfInterfZZ myInterfZZ;
0518   TColStd_MapOfInteger myInterfered;
0519 
0520 
0521 private:
0522 
0523 
0524 
0525 
0526 
0527 };
0528 
0529 
0530 #include <BOPDS_DS.lxx>
0531 
0532 
0533 
0534 
0535 
0536 #endif // _BOPDS_DS_HeaderFile