1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0028508: Make the CellsBuilder algorithm to work with multi-dimensional arguments

1. The CellsBuilder algorithm has been extended to work with multi-dimensional arguments.
It has become possible not only simulate Boolean expressions, but also perform non-supported
Boolean operations, like cutting face from solid, or fusing face with edge.

2. Test cases with multi-dimensional input shapes have been created.

3. Documentation has been updated.
This commit is contained in:
emv
2017-03-10 15:13:48 +03:00
committed by bugmaster
parent 2967828dbf
commit e8b9db57cd
19 changed files with 1201 additions and 426 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -18,6 +18,7 @@
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_OStream.hxx>
#include <TopoDS_Shape.hxx>
@@ -32,128 +33,146 @@
#include <BOPCol_DataMapOfShapeShape.hxx>
//!
//! The algorithm is based on the General Fuse algorithm (GFA). The result of
//! GFA is all split parts of the Arguments.
//!
//! The purpose of this algorithm is to provide the result with the content of:
//! 1. Cells (parts) defined by the user;
//! 2. Internal boundaries defined by the user.
//!
//! The algorithm is based on the General Fuse algorithm (GFA). The result of
//! GFA is all split parts of the Arguments.<br>
//!
//! The purpose of this algorithm is to provide the result with the content of:<br>
//! 1. Cells (parts) defined by the user;<br>
//! 2. Internal boundaries defined by the user.<br>
//!
//! In other words the algorithm should provide the possibility for the user
//! to add or remove any part to (from) result and remove any internal boundaries
//! between parts.
//!
//! Requirements for the Data:
//! All the requirements of GFA for the DATA are inherited in this algorithm.
//! Plus all the arguments should have the same dimension.
//! between parts.<br>
//!
//! Results:
//! The result of the algorithm is compound containing selected parts of
//! the basic type (VERTEX, EDGE, FACE or SOLID). The default result
//! Requirements for the Data:<br>
//! All the requirements of GFA for the DATA are inherited in this algorithm -
//! The arguments could be of any type (dimension) and should be valid in terms of
//! BRepCheck_Analyzer and BOPAlgo_ArgumentAnalyzer.<br>
//!
//! Results:<br>
//! The result of the algorithm is compound containing selected parts of
//! the basic types (VERTEX, EDGE, FACE or SOLID). The default result
//! is empty compound. It is possible to add any split part to the result
//! by using the methods AddToRessult() and AddAllToResult().
//! It is also possible to remove any part from the result by using methods
//! It is also possible to remove any part from the result by using methods
//! RemoveFromResult() and RemoveAllFromResult().
//! The method RemoveAllFromResult() is also suitable for clearing the result.
//! The method RemoveAllFromResult() is also suitable for clearing the result.<br>
//!
//! To remove Internal boundaries it is necessary to set the same material to the
//! parts between which the boundaries should be removed and call the method
//! RemoveInternalBoundaries(). The material should not be equal to 0, as this is
//! default material value. The boundaries between parts with this value
//! To remove Internal boundaries it is necessary to set the same material to the
//! parts between which the boundaries should be removed and call the method
//! RemoveInternalBoundaries(). The material should not be equal to 0, as this is
//! default material value. The boundaries between parts with this value
//! will not be removed.
//! One part cannot be added with the different materials.
//! It is also possible to remove the boundaries during combining the result.
//! To do this it is necessary to set the material for parts (not equal to 0)
//! and set the flag bUpdate to TRUE.
//! BUT for the arguments of the types FACE or EDGE it is recommended
//! and set the flag bUpdate to TRUE.
//! For the arguments of the types FACE or EDGE it is recommended
//! to remove the boundaries in the end when the result is completely built.
//! It will help to avoid self-intersections in the result.
//! It will help to avoid self-intersections in the result.<br>
//! Note, that if the result contains the parts with same material but of different
//! dimension the boundaries between such parts will not be removed. Currently,
//! the removal of the internal boundaries between multi-dimensional shapes is not supported.<br>
//!
//! It is possible to create typed Containers from the parts added to result by using
//! method MakeContainers(). The type of the containers will depend on the type of
//! method MakeContainers(). The type of the containers will depend on the type of
//! the arguments: WIRES for EEDGE, SHELLS for FACES and COMPSOLIDS for SOLIDS.
//! The result will be compound containing containers.
//! Adding of the parts to such result will not update containers. The result
//! Adding of the parts to such result will not update containers. The result
//! compound will contain the containers and new added parts (of basic type).
//! Removing of the parts from such result may affect some containers if the
//! Removing of the parts from such result may affect some containers if
//! the parts that should be removed is in container. In this case this container
//! will be rebuilt without that part.
//! will be rebuilt without that part.<br>
//!
//! History:
//! History:<br>
//! The algorithm supports history information for basic types of the shapes -
//! VERTEX, EDGE, FACE. This information available through the methods
//! IsDeleted() and Modified(). In DRAW Test Harness it is available through the same
//! commands as for Boolean Operations (bmodified, bgenerated and bisdeleted).
//! VERTEX, EDGE, FACE. This information available through the methods
//! IsDeleted() and Modified().<br>
//! In DRAW Test Harness it is available through the same
//! commands as for Boolean Operations (bmodified, bgenerated and bisdeleted).<br>
//! There could be Generated shapes only after removing of the internal boundaries
//! between faces and edges, i.e. after using ShapeUpgrade_UnifySameDomain tool.
//!
//! Examples:
//! 1. API
//! BOPAlgo_CellsBuilder aCBuilder;
//! BOPCol_ListOfShape aLS = ...; // arguments
//! /* parallel or single mode (the default value is FALSE)*/
//! Standard_Boolean bRunParallel = Standard_False;
//! /* fuzzy option (default value is 0)*/
//! Standard_Real aTol = 0.0;
//! //
//! aCBuilder.SetArguments(aLS);
//! aCBuilder.SetRunParallel(bRunParallel);
//! aCBuilder.SetFuzzyValue(aTol);
//! //
//! aCBuilder.Perform();
//! if (aCBuilder.ErrorStatus()) { // check error status
//! return;
//! }
//! /* empty compound, as nothing has been added yet */
//! const TopoDS_Shape& aRes = aCBuilder.Shape();
//! /* all split parts */
//! const TopoDS_Shape& aRes = aCBuilder.GetAllParts();
//! //
//! BOPCol_ListOfShape aLSToTake = ...; // parts of these arguments will be taken into result
//! BOPCol_ListOfShape aLSToAvoid = ...; // parts of these arguments will not be taken into result
//! //
//! between faces and edges, i.e. after using ShapeUpgrade_UnifySameDomain tool.<br>
//!
//! The algorithm can return the following Error Statuses:<br>
//! - 0 - in case of success;<br>
//! - Error status acquired in the General Fuse algorithm.<br>
//! The Error status can be checked with ErrorStatus() method.
//! If the Error status is not equal to zero, the result cannot be trustworthy.<br>
//!
//! The algorithm can return the following Warning Statuses:<br>
//! - 0 - no warnings occurred;<br>
//! - Warning status acquired in the General Fuse algorithm;<br>
//! - One of the warnings from BOPAlgo_CellsBuilder_WarningStatusEnum.<br>
//! The Warning status can be checked with WarningStatus() method or
//! printed with the DumpWarnings() method. If the Warning status is not equal
//! to zero, the result may be not as expected.<br>
//!
//! Examples:<br>
//! 1. API<br>
//! BOPAlgo_CellsBuilder aCBuilder;<br>
//! BOPCol_ListOfShape aLS = ...; // arguments<br>
//! /* parallel or single mode (the default value is FALSE)*/<br>
//! Standard_Boolean bRunParallel = Standard_False;<br>
//! /* fuzzy option (default value is 0)*/<br>
//! Standard_Real aTol = 0.0;<br>
//! //<br>
//! aCBuilder.SetArguments(aLS);<br>
//! aCBuilder.SetRunParallel(bRunParallel);<br>
//! aCBuilder.SetFuzzyValue(aTol);<br>
//! //<br>
//! aCBuilder.Perform();<br>
//! if (aCBuilder.ErrorStatus()) { // check error status<br>
//! return;<br>
//! }<br>
//! /* empty compound, as nothing has been added yet */<br>
//! const TopoDS_Shape& aRes = aCBuilder.Shape();<br>
//! /* all split parts */<br>
//! const TopoDS_Shape& aRes = aCBuilder.GetAllParts();<br>
//! //<br>
//! BOPCol_ListOfShape aLSToTake = ...; // parts of these arguments will be taken into result<br>
//! BOPCol_ListOfShape aLSToAvoid = ...; // parts of these arguments will not be taken into result<br>
//! //<br>
//! /* defines the material common for the cells, i.e.
//! the boundaries between cells with the same material
//! will be removed.
//! By default it is set to 0. Thus, to remove some boundary
//! the value of this variable should not be equal to 0 */
//! Standard_Integer iMaterial = ...;
//! /* defines whether to update the result right now or not */
//! Standard_Boolean bUpdate = ...;
//! // adding to result
//! aCBuilder.AddToResult(aLSToTake, aLSToAvoid, iMaterial, bUpdate);
//! aR = aCBuilder.Shape(); // the result
//! // removing of the boundaries
//! aCBuilder.RemoveInternalBoundaries();
//!
//! // removing from result
//! aCBuilder.AddAllToResult();
//! aCBuilder.RemoveFromResult(aLSToTake, aLSToAvoid);
//! aR = aCBuilder.Shape(); // the result
//!
//!
//! 2. DRAW Test Harness
//! psphere s1 15
//! psphere s2 15
//! psphere s3 15
//! ttranslate s1 0 0 10
//! ttranslate s2 20 0 10
//! ttranslate s3 10 0 0
//!
//! bclearobjects; bcleartools
//! baddobjects s1 s2 s3
//! bfillds
//! # rx will contain all split parts
//! bcbuild rx
//! # add to result the part that is common for all three spheres
//! bcadd res s1 1 s2 1 s3 1 -m 1
//! # add to result the part that is common only for first and third shperes
//! bcadd res s1 1 s2 0 s3 1 -m 1
//! # remove internal boundaries
//! bcremoveint res
//! will be removed.<br>
//! By default it is set to 0. Thus, to remove some boundary
//! the value of this variable should not be equal to 0 */<br>
//! Standard_Integer iMaterial = ...;<br>
//! /* defines whether to update the result right now or not */<br>
//! Standard_Boolean bUpdate = ...;<br>
//! // adding to result<br>
//! aCBuilder.AddToResult(aLSToTake, aLSToAvoid, iMaterial, bUpdate);<br>
//! aR = aCBuilder.Shape(); // the result<br>
//! // removing of the boundaries (should be called only if bUpdate is false)<br>
//! aCBuilder.RemoveInternalBoundaries();<br>
//! //<br>
//! // removing from result<br>
//! aCBuilder.AddAllToResult();<br>
//! aCBuilder.RemoveFromResult(aLSToTake, aLSToAvoid);<br>
//! aR = aCBuilder.Shape(); // the result<br>
//! <br>
//!
//! 2. DRAW Test Harness<br>
//! psphere s1 15<br>
//! psphere s2 15<br>
//! psphere s3 15<br>
//! ttranslate s1 0 0 10<br>
//! ttranslate s2 20 0 10<br>
//! ttranslate s3 10 0 0<br>
//! \# adding arguments<br>
//! bclearobjects; bcleartools<br>
//! baddobjects s1 s2 s3<br>
//! \# intersection<br>
//! bfillds<br>
//! \# rx will contain all split parts<br>
//! bcbuild rx<br>
//! \# add to result the part that is common for all three spheres<br>
//! bcadd res s1 1 s2 1 s3 1 -m 1<br>
//! \# add to result the part that is common only for first and third spheres<br>
//! bcadd res s1 1 s2 0 s3 1 -m 1<br>
//! \# remove internal boundaries<br>
//! bcremoveint res<br>
//!
class BOPAlgo_CellsBuilder : public BOPAlgo_Builder
{
public:
@@ -169,33 +188,33 @@ class BOPAlgo_CellsBuilder : public BOPAlgo_Builder
//! Redefined method Clear - clears the contents.
Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
//! Adding the parts to result.
//! The parts are defined by two lists of shapes.
//! <theLSToTake> defines the arguments which parts should be taken into result;
//! <theLSToAvoid> defines the arguments which parts should not be taken into result;
//! Adding the parts to result.<br>
//! The parts are defined by two lists of shapes:<br>
//! <theLSToTake> defines the arguments which parts should be taken into result;<br>
//! <theLSToAvoid> defines the arguments which parts should not be taken into result;<br>
//! To be taken into result the part must be IN for all shapes from the list
//! <theLSToTake> and must be OUT of all shapes from the list <theLSToAvoid>.
//! <theLSToTake> and must be OUT of all shapes from the list <theLSToAvoid>.<br>
//!
//! To remove internal boundaries between any cells in the result
//! <theMaterial> variable should be used. The boundaries between
//! cells with the same material will be removed. Default value is 0.
//! Thus, to remove any boundary the value of this variable should not be equal to 0.
//! <theUpdate> parameter defines whether to remove boundaries now or not
//! To remove internal boundaries between any cells in the result
//! <theMaterial> variable should be used. The boundaries between
//! cells with the same material will be removed. Default value is 0.<br>
//! Thus, to remove any boundary the value of this variable should not be equal to 0.<br>
//! <theUpdate> parameter defines whether to remove boundaries now or not.
Standard_EXPORT void AddToResult(const BOPCol_ListOfShape& theLSToTake,
const BOPCol_ListOfShape& theLSToAvoid,
const Standard_Integer theMaterial = 0,
const Standard_Boolean theUpdate = Standard_False);
//! Add all split parts to result
//! <theMaterial> defines the removal of internal boundaries;
//! Add all split parts to result.<br>
//! <theMaterial> defines the removal of internal boundaries;<br>
//! <theUpdate> parameter defines whether to remove boundaries now or not.
Standard_EXPORT void AddAllToResult(const Standard_Integer theMaterial = 0,
const Standard_Boolean theUpdate = Standard_False);
//! Removing the parts from result.
//! The parts are defined by two lists of shapes.
//! <theLSToTake> defines the arguments which parts should be removed from result;
//! <theLSToAvoid> defines the arguments which parts should not be removed from result.
//! Removing the parts from result.<br>
//! The parts are defined by two lists of shapes:<br>
//! <theLSToTake> defines the arguments which parts should be removed from result;<br>
//! <theLSToAvoid> defines the arguments which parts should not be removed from result.<br>
//! To be removed from the result the part must be IN for all shapes from the list
//! <theLSToTake> and must be OUT of all shapes from the list <theLSToAvoid>.
Standard_EXPORT void RemoveFromResult(const BOPCol_ListOfShape& theLSToTake,
@@ -204,7 +223,11 @@ class BOPAlgo_CellsBuilder : public BOPAlgo_Builder
//! Remove all parts from result.
Standard_EXPORT void RemoveAllFromResult();
//! Removes internal boundaries between cells with the same material.
//! Removes internal boundaries between cells with the same material.<br>
//! If the result contains the cells with same material but of different dimension
//! the removal of internal boundaries between these cells will not be performed.<br>
//! In case of some errors during the removal the method will set the appropriate warning status -
//! see the WarningStatusEnum enumeration.
Standard_EXPORT void RemoveInternalBoundaries();
//! Get all split parts.
@@ -218,24 +241,34 @@ class BOPAlgo_CellsBuilder : public BOPAlgo_Builder
//! Returns true if the shape theS has been deleted.
Standard_EXPORT virtual Standard_Boolean IsDeleted (const TopoDS_Shape& theS) Standard_OVERRIDE;
//! Define possible warning statuses of the CellsBuilder algorithm:<br>
//! - RemovalOfIBForMDimShapes - The result contains multi-dimensional shapes with the same
//! material. Removal of internal boundaries has not been performed.<br>
//! - RemovalOfIBForSolidsFailed - Removal of internal boundaries among Solids has failed.<br>
//! - RemovalOfIBForFacesFailed - Removal of internal boundaries among Faces has failed.<br>
//! - RemovalOfIBForEdgesFailed - Removal of internal boundaries among Edges has failed.<br>
enum WarningStatusEnum
{
RemovalOfIBForMDimShapes = 2,
RemovalOfIBForSolidsFailed = 4,
RemovalOfIBForFacesFailed = 8,
RemovalOfIBForEdgesFailed = 16
};
//! Dumps the warning status
Standard_EXPORT virtual void DumpWarnings(Standard_OStream& theOS) const;
protected:
//! Redefined method Prepare - no need to prepare history
//! Redefined method Prepare - no need to prepare history
//! information on the default result as it is empty compound.
Standard_EXPORT virtual void Prepare() Standard_OVERRIDE;
//! Redefined method CheckData() - additional check for the arguments
//! to be of the same dimension.
Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
//! Redefined method PerformInternal1 - makes all split parts,
//! Redefined method PerformInternal1 - makes all split parts,
//! nullifies the result <myShape>, and index all parts.
Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF) Standard_OVERRIDE;
//! Saves all split parts in myAllParts.
Standard_EXPORT void TakeAllParts();
//! Indexes the parts for quick access to the arguments.
Standard_EXPORT void IndexParts();
@@ -244,12 +277,12 @@ class BOPAlgo_CellsBuilder : public BOPAlgo_Builder
const BOPCol_ListOfShape& theLSToAvoid,
BOPCol_ListOfShape& theParts);
//! Removes internal boundaries between cells with the same material.
Standard_EXPORT Standard_Integer RemoveInternals(const BOPCol_ListOfShape& theLS,
//! Removes internal boundaries between cells with the same material.<br>
//! Returns TRUE if any internal boundaries have been removed.
Standard_EXPORT Standard_Boolean RemoveInternals(const BOPCol_ListOfShape& theLS,
BOPCol_ListOfShape& theLSNew);
// fields
TopAbs_ShapeEnum myType;
TopoDS_Shape myAllParts;
BOPCol_IndexedDataMapOfShapeListOfShape myIndex;
BOPCol_DataMapOfIntegerListOfShape myMaterials;