Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created by: Eugeny MALTCHIKOV
0002 // Copyright (c) 2015 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 
0016 #ifndef _BOPAlgo_CellsBuilder_HeaderFile
0017 #define _BOPAlgo_CellsBuilder_HeaderFile
0018 
0019 #include <Standard_Handle.hxx>
0020 
0021 #include <TopoDS_Shape.hxx>
0022 
0023 #include <BOPAlgo_Builder.hxx>
0024 
0025 #include <TopTools_ListOfShape.hxx>
0026 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
0027 #include <TopTools_DataMapOfIntegerListOfShape.hxx>
0028 #include <TopTools_DataMapOfShapeInteger.hxx>
0029 #include <TopTools_DataMapOfShapeShape.hxx>
0030 
0031 //! The algorithm is based on the General Fuse algorithm (GFA).
0032 //! The result of GFA is all split parts of the Arguments.
0033 //!
0034 //! The purpose of this algorithm is to provide the result with the content of:
0035 //! 1. Cells (parts) defined by the user;
0036 //! 2. Internal boundaries defined by the user.
0037 //!
0038 //! In other words the algorithm should provide the possibility for the user to add
0039 //! or remove any part to (from) result and remove any internal boundaries between parts.
0040 //!
0041 //! All the requirements of GFA for the DATA are inherited in this algorithm.
0042 //! The arguments could be of any type (dimension) and should be valid
0043 //! in terms of BRepCheck_Analyzer and BOPAlgo_ArgumentAnalyzer.
0044 //!
0045 //! Results:
0046 //!
0047 //! The result of the algorithm is compound containing selected parts of the basic types (VERTEX, EDGE, FACE or SOLID).
0048 //! The default result is empty compound.
0049 //! It is possible to add any split part to the result by using the methods AddToRessult() and AddAllToResult().
0050 //! It is also possible to remove any part from the result by using methods RemoveFromResult() and RemoveAllFromResult().
0051 //! The method RemoveAllFromResult() is also suitable for clearing the result.
0052 //!
0053 //! To remove Internal boundaries it is necessary to set the same material to the
0054 //! parts between which the boundaries should be removed and call the method RemoveInternalBoundaries().
0055 //! The material should not be equal to 0, as this is default material value.
0056 //! The boundaries between parts with this value will not be removed.
0057 //! One part cannot be added with the different materials.
0058 //! It is also possible to remove the boundaries during combining the result.
0059 //! To do this it is necessary to set the material for parts (not equal to 0) and set the flag bUpdate to TRUE.
0060 //! For the arguments of the types FACE or EDGE it is recommended
0061 //! to remove the boundaries in the end when the result is completely built.
0062 //! It will help to avoid self-intersections in the result.
0063 //!
0064 //! Note, that if the result contains the parts with same material but of different
0065 //! dimension the boundaries between such parts will not be removed.
0066 //! Currently, the removal of the internal boundaries between multi-dimensional shapes is not supported.
0067 //!
0068 //! It is possible to create typed Containers from the parts added to result by using method MakeContainers().
0069 //! The type of the containers will depend on the type of the arguments:
0070 //! WIRES for EEDGE, SHELLS for FACES and COMPSOLIDS for SOLIDS.
0071 //! The result will be compound containing containers.
0072 //! Adding of the parts to such result will not update containers.
0073 //! The result compound will contain the containers and new added parts (of basic type).
0074 //! Removing of the parts from such result may affect some containers if
0075 //! the parts that should be removed is in container.
0076 //! In this case this container will be rebuilt without that part.
0077 //!
0078 //! History:
0079 //!
0080 //! The algorithm supports history information for basic types of the shapes - VERTEX, EDGE, FACE.
0081 //! This information available through the methods IsDeleted() and Modified().
0082 //!
0083 //! In DRAW Test Harness it is available through the same commands
0084 //! as for Boolean Operations (bmodified, bgenerated and bisdeleted).
0085 //!
0086 //! The algorithm can return the following Error Statuses:
0087 //! - Error status acquired in the General Fuse algorithm.
0088 //! The Error status can be checked with HasErrors() method.
0089 //! If the Error status is not equal to zero, the result cannot be trustworthy.
0090 //!
0091 //! The algorithm can set the following Warning Statuses:
0092 //! - Warning status acquired in the General Fuse algorithm;
0093 //! - BOPAlgo_AlertRemovalOfIBForMDimShapes
0094 //! - BOPAlgo_AlertRemovalOfIBForFacesFailed
0095 //! - BOPAlgo_AlertRemovalOfIBForEdgesFailed
0096 //! - BOPAlgo_AlertRemovalOfIBForSolidsFailed
0097 //!
0098 //! The Warning status can be checked with HasWarnings() method or printed with the DumpWarnings() method.
0099 //! If warnings are recorded, the result may be not as expected.
0100 //!
0101 //! Examples:
0102 //!
0103 //! 1. API
0104 //! @code
0105 //! BOPAlgo_CellsBuilder aCBuilder;
0106 //! TopTools_ListOfShape aLS = ...; // arguments
0107 //! // parallel or single mode (the default value is FALSE)
0108 //! bool toRunParallel = false;
0109 //! // fuzzy option (default value is 0)
0110 //! Standard_Real aTol = 0.0;
0111 //! //
0112 //! aCBuilder.SetArguments (aLS);
0113 //! aCBuilder.SetRunParallel (toRunParallel);
0114 //! aCBuilder.SetFuzzyValue (aTol);
0115 //! //
0116 //! aCBuilder.Perform();
0117 //! if (aCBuilder.HasErrors()) // check error status
0118 //! {
0119 //!   return;
0120 //! }
0121 //! // empty compound, as nothing has been added yet
0122 //! const TopoDS_Shape& aRes = aCBuilder.Shape();
0123 //! // all split parts
0124 //! const TopoDS_Shape& aRes = aCBuilder.GetAllParts();
0125 //! //
0126 //! TopTools_ListOfShape aLSToTake  = ...; // parts of these arguments will be taken into result
0127 //! TopTools_ListOfShape aLSToAvoid = ...; // parts of these arguments will not be taken into result
0128 //! //
0129 //! // defines the material common for the cells,
0130 //! // i.e. the boundaries between cells with the same material will be removed.
0131 //! // By default it is set to 0.
0132 //! // Thus, to remove some boundary the value of this variable should not be equal to 0.
0133 //! Standard_Integer iMaterial = ...;
0134 //! // defines whether to update the result right now or not
0135 //! bool toUpdate = ...;
0136 //! // adding to result
0137 //! aCBuilder.AddToResult (aLSToTake, aLSToAvoid, iMaterial, toUpdate);
0138 //! aR = aCBuilder.Shape(); // the result
0139 //! // removing of the boundaries (should be called only if toUpdate is false)
0140 //! aCBuilder.RemoveInternalBoundaries();
0141 //! //
0142 //! // removing from result
0143 //! aCBuilder.AddAllToResult();
0144 //! aCBuilder.RemoveFromResult (aLSToTake, aLSToAvoid);
0145 //! aR = aCBuilder.Shape(); // the result
0146 //! @endcode
0147 //!
0148 //! 2. DRAW Test Harness
0149 //! @code
0150 //! psphere s1 15
0151 //! psphere s2 15
0152 //! psphere s3 15
0153 //! ttranslate s1 0 0 10
0154 //! ttranslate s2 20 0 10
0155 //! ttranslate s3 10 0 0
0156 //! # adding arguments
0157 //! bclearobjects; bcleartools
0158 //! baddobjects s1 s2 s3
0159 //! # intersection
0160 //! bfillds
0161 //! # rx will contain all split parts
0162 //! bcbuild rx
0163 //! # add to result the part that is common for all three spheres
0164 //! bcadd res s1 1 s2 1 s3 1 -m 1
0165 //! # add to result the part that is common only for first and third spheres
0166 //! bcadd res s1 1 s2 0 s3 1 -m 1
0167 //! # remove internal boundaries
0168 //! bcremoveint res
0169 //! @endcode
0170 class BOPAlgo_CellsBuilder : public BOPAlgo_Builder
0171 {
0172  public:
0173 
0174   DEFINE_STANDARD_ALLOC
0175 
0176   Standard_EXPORT BOPAlgo_CellsBuilder();
0177 
0178   Standard_EXPORT BOPAlgo_CellsBuilder(const Handle(NCollection_BaseAllocator)& theAllocator);
0179 
0180   Standard_EXPORT virtual ~BOPAlgo_CellsBuilder();
0181 
0182   //! Redefined method Clear - clears the contents.
0183   Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
0184 
0185   //! Adding the parts to result.<br>
0186   //! The parts are defined by two lists of shapes:<br>
0187   //! <theLSToTake> defines the arguments which parts should be taken into result;<br>
0188   //! <theLSToAvoid> defines the arguments which parts should not be taken into result;<br>
0189   //! To be taken into result the part must be IN for all shapes from the list
0190   //! <theLSToTake> and must be OUT of all shapes from the list <theLSToAvoid>.<br>
0191   //! 
0192   //! To remove internal boundaries between any cells in the result
0193   //! <theMaterial> variable should be used. The boundaries between
0194   //! cells with the same material will be removed. Default value is 0.<br>
0195   //! Thus, to remove any boundary the value of this variable should not be equal to 0.<br>
0196   //! <theUpdate> parameter defines whether to remove boundaries now or not.
0197   Standard_EXPORT void AddToResult(const TopTools_ListOfShape& theLSToTake,
0198                                    const TopTools_ListOfShape& theLSToAvoid,
0199                                    const Standard_Integer theMaterial = 0,
0200                                    const Standard_Boolean theUpdate = Standard_False);
0201 
0202   //! Add all split parts to result.<br>
0203   //! <theMaterial> defines the removal of internal boundaries;<br>
0204   //! <theUpdate> parameter defines whether to remove boundaries now or not.
0205   Standard_EXPORT void AddAllToResult(const Standard_Integer theMaterial = 0,
0206                                       const Standard_Boolean theUpdate = Standard_False);
0207 
0208   //! Removing the parts from result.<br>
0209   //! The parts are defined by two lists of shapes:<br>
0210   //! <theLSToTake> defines the arguments which parts should be removed from result;<br>
0211   //! <theLSToAvoid> defines the arguments which parts should not be removed from result.<br>
0212   //! To be removed from the result the part must be IN for all shapes from the list
0213   //! <theLSToTake> and must be OUT of all shapes from the list <theLSToAvoid>.
0214   Standard_EXPORT void RemoveFromResult(const TopTools_ListOfShape& theLSToTake,
0215                                         const TopTools_ListOfShape& theLSToAvoid);
0216 
0217   //! Remove all parts from result.
0218   Standard_EXPORT void RemoveAllFromResult();
0219 
0220   //! Removes internal boundaries between cells with the same material.<br>
0221   //! If the result contains the cells with same material but of different dimension
0222   //! the removal of internal boundaries between these cells will not be performed.<br>
0223   //! In case of some errors during the removal the method will set the appropriate warning 
0224   //! status - use GetReport() to access them.
0225   Standard_EXPORT void RemoveInternalBoundaries();
0226 
0227   //! Get all split parts.
0228   Standard_EXPORT const TopoDS_Shape& GetAllParts() const;
0229 
0230   //! Makes the Containers of proper type from the parts added to result.
0231   Standard_EXPORT void MakeContainers();
0232 
0233  protected:
0234 
0235   //! Prepare information for history support taking into account
0236   //! local modification map of unified elements - myMapModified.
0237   Standard_EXPORT virtual const TopTools_ListOfShape* LocModified(const TopoDS_Shape& theS) Standard_OVERRIDE;
0238 
0239   //! Redefined method PerformInternal1 - makes all split parts,
0240   //! nullifies the result <myShape>, and index all parts.
0241   Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF, const Message_ProgressRange& theRange) Standard_OVERRIDE;
0242 
0243   //! Indexes the parts for quick access to the arguments.
0244   Standard_EXPORT void IndexParts();
0245 
0246   //! Looking for the parts defined by two lists.
0247   Standard_EXPORT void FindParts(const TopTools_ListOfShape& theLSToTake,
0248                                  const TopTools_ListOfShape& theLSToAvoid,
0249                                  TopTools_ListOfShape& theParts);
0250 
0251   //! Removes internal boundaries between cells with the same material.<br>
0252   //! Returns TRUE if any internal boundaries have been removed.
0253   Standard_EXPORT Standard_Boolean RemoveInternals(const TopTools_ListOfShape& theLS,
0254                                                    TopTools_ListOfShape& theLSNew,
0255                                                    const TopTools_MapOfShape& theMapKeepBnd = TopTools_MapOfShape());
0256 
0257   // fields
0258   TopoDS_Shape myAllParts;                           //!< All split parts of the arguments
0259   TopTools_IndexedDataMapOfShapeListOfShape myIndex; //!< Connection map from all splits parts to the argument shapes from which they were created
0260   TopTools_DataMapOfIntegerListOfShape myMaterials;  //!< Map of assigned materials (material -> list of shape)
0261   TopTools_DataMapOfShapeInteger myShapeMaterial;    //!< Map of assigned materials (shape -> material)
0262   TopTools_DataMapOfShapeShape myMapModified;        //!< Local modification map to track unification of the splits
0263 };
0264 
0265 #endif //_BOPAlgo_CellsBuilder_HeaderFile