mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0029363: No history for shapes which were produced as a result of intersection
1. Implementation of the *Generated* method for the algorithms in Boolean Component. In terms of these algorithms the shape from the arguments can have Generated shapes only if these new shapes have been obtained as a result of pure intersection (not overlapping) of this shape with any other shapes from arguments. Thus, the Generated shapes are always: * VERTICES created from the intersection points and may be Generated from edges and faces only; * EDGES created from the intersection edges and may be Generated from faces only. So, only EDGES and FACES could have information about Generated shapes. For all other types of shapes the list of Generated shapes will be empty. 2. Optimization and simplification of the Modified and IsDeleted methods based on the correct filling of the BOPAlgo_BuilderShape::myImagesResult map. 3. Provide history of unification of the solids in the CellsBuilder algorithm. 4. Update of the documentation of Boolean Operations User guide with new chapter "History Information" describing rules for filling history for operations in Boolean Component. 5. Test cases for the issue. New grid "history" has been added into "boolean" category.
This commit is contained in:
@@ -172,17 +172,39 @@ public: //! @name Performing the operation
|
||||
|
||||
public: //! @name History methods
|
||||
|
||||
//! Returns the list of shapes generated from the
|
||||
//! shape theS.
|
||||
//! Returns the list of shapes generated from the shape theS.
|
||||
Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& theS) Standard_OVERRIDE;
|
||||
|
||||
//! Returns the list of shapes modified from the shape
|
||||
//! theS.
|
||||
//! Returns the list of shapes modified from the shape theS.
|
||||
Standard_EXPORT virtual const TopTools_ListOfShape& Modified (const TopoDS_Shape& theS) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the shape theS has been deleted.
|
||||
Standard_EXPORT virtual Standard_Boolean IsDeleted (const TopoDS_Shape& theS) Standard_OVERRIDE;
|
||||
|
||||
protected: //! @name History methods
|
||||
|
||||
//! Prepare information for history support.
|
||||
Standard_EXPORT virtual void PrepareHistory() Standard_OVERRIDE;
|
||||
|
||||
//! Prepare history information for the input shapes taking into account possible
|
||||
//! operation-specific modifications.
|
||||
//! For instance, in the CellsBuilder operation, additionally to splitting input shapes
|
||||
//! the splits of the shapes (or the shapes themselves) may be unified during removal of internal
|
||||
//! boundaries. In this case each split should be linked to the unified shape.
|
||||
//!
|
||||
//! To have correct history information, the method should be redefined in each operation
|
||||
//! where such additional modification is possible. The input shape <theS> should be the one from arguments,
|
||||
//! and the returning list should contain all final elements to which the input shape has evolved,
|
||||
//! including those not contained in the result shape.
|
||||
//!
|
||||
//! The method returns pointer to the list of modified elements.
|
||||
//! NULL pointer means that the shape has not been modified at all.
|
||||
//!
|
||||
//! The General Fuse operation does not perform any other modification than splitting the input
|
||||
//! shapes basing on their intersection information. This information is contained in myImages map.
|
||||
//! Thus, here the method returns only splits (if any) contained in this map.
|
||||
Standard_EXPORT virtual const TopTools_ListOfShape* LocModified(const TopoDS_Shape& theS);
|
||||
|
||||
|
||||
public: //! @name Images/Origins
|
||||
|
||||
@@ -217,9 +239,6 @@ protected: //! @name Methods for building the result
|
||||
//! it will be necessary to override this method.
|
||||
Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF);
|
||||
|
||||
//! Prepare information for history support.
|
||||
Standard_EXPORT virtual void PrepareHistory() Standard_OVERRIDE;
|
||||
|
||||
//! Builds the result of operation.
|
||||
//! The method is called for each of the arguments type and
|
||||
//! adds into the result the splits of the arguments of that type.
|
||||
|
@@ -122,6 +122,7 @@
|
||||
{
|
||||
myHistShapes.Clear();
|
||||
myMapShape.Clear();
|
||||
myImagesResult.Clear();
|
||||
myHasDeleted=Standard_False;
|
||||
myHasGenerated=Standard_False;
|
||||
myHasModified=Standard_False;
|
||||
|
@@ -17,9 +17,9 @@
|
||||
|
||||
|
||||
#include <BOPAlgo_Builder.hxx>
|
||||
#include <BOPAlgo_PaveFiller.hxx>
|
||||
#include <BOPDS_DS.hxx>
|
||||
#include <BOPTools_AlgoTools.hxx>
|
||||
#include <BOPTools_AlgoTools3D.hxx>
|
||||
#include <IntTools_Context.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
@@ -32,9 +32,112 @@
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopTools_ListOfShape& BOPAlgo_Builder::Generated
|
||||
(const TopoDS_Shape&)
|
||||
(const TopoDS_Shape& theS)
|
||||
{
|
||||
// The rules for Generated shapes are these:
|
||||
// 1. The EDGE may be generated from the FACES as an intersection edge;
|
||||
// 2. The VERTEX may be generated from the EDGES and FACES as an intersection vertex.
|
||||
//
|
||||
// The list of generated elements will contain only those which are contained
|
||||
// in the result of the operation.
|
||||
|
||||
myHistShapes.Clear();
|
||||
|
||||
if (!myHasGenerated)
|
||||
return myHistShapes;
|
||||
|
||||
if (theS.IsNull())
|
||||
return myHistShapes;
|
||||
|
||||
// Only EDGES and FACES should be considered
|
||||
TopAbs_ShapeEnum aType = theS.ShapeType();
|
||||
if (aType != TopAbs_EDGE && aType != TopAbs_FACE)
|
||||
// Wrong type
|
||||
return myHistShapes;
|
||||
|
||||
// Check that DS contains the shape, i.e. it is from the arguments of the operation
|
||||
Standard_Integer nS = myDS->Index(theS);
|
||||
if (nS < 0)
|
||||
// Unknown shape
|
||||
return myHistShapes;
|
||||
|
||||
// Check that the shape has participated in any intersections
|
||||
const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(nS);
|
||||
if (!aSI.HasReference())
|
||||
// Untouched shape
|
||||
return myHistShapes;
|
||||
|
||||
// Analyze all types of Interferences which can produce
|
||||
// new vertices - Edge/Edge and Edge/Face
|
||||
BOPDS_VectorOfInterfEE& aEEs = myDS->InterfEE();
|
||||
BOPDS_VectorOfInterfEF& aEFs = myDS->InterfEF();
|
||||
|
||||
// Fence map to avoid duplicates in the list of Generated;
|
||||
TColStd_MapOfInteger aMFence;
|
||||
|
||||
// Analyze each interference and find those in which the given shape has participated
|
||||
|
||||
// No need to analyze Edge/Edge interferences for the shapes of type FACE
|
||||
Standard_Boolean isFace = (aType == TopAbs_FACE);
|
||||
|
||||
for (Standard_Integer k = (isFace ? 1 : 0); k < 2; ++k)
|
||||
{
|
||||
Standard_Integer aNbLines = !k ? aEEs.Length() : aEFs.Length();
|
||||
for (Standard_Integer i = 0; i < aNbLines; ++i)
|
||||
{
|
||||
BOPDS_Interf *aInt = !k ? (BOPDS_Interf*)(&aEEs(i)) : (BOPDS_Interf*)(&aEFs(i));
|
||||
if (!aInt->HasIndexNew())
|
||||
// No new vertices created
|
||||
continue;
|
||||
|
||||
if (!aInt->Contains(nS))
|
||||
continue;
|
||||
|
||||
Standard_Integer nVNew = aInt->IndexNew();
|
||||
myDS->HasShapeSD(nVNew, nVNew);
|
||||
if (!aMFence.Add(nVNew))
|
||||
continue;
|
||||
|
||||
// Get the new vertex
|
||||
const TopoDS_Shape& aVNew = myDS->Shape(nVNew);
|
||||
|
||||
// Check that the result shape contains vertex
|
||||
if (myMapShape.Contains(aVNew))
|
||||
// Save the vertex as generated
|
||||
myHistShapes.Append(aVNew);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isFace)
|
||||
return myHistShapes;
|
||||
|
||||
// For the FACE it is also necessary to collect all
|
||||
// section elements created in FACE/FACE interferences.
|
||||
// This information is available in the FaceInfo structure.
|
||||
const BOPDS_FaceInfo& aFI = myDS->FaceInfo(nS);
|
||||
|
||||
// Section edges of the face
|
||||
const BOPDS_IndexedMapOfPaveBlock& aMPBSc = aFI.PaveBlocksSc();
|
||||
// Save section edges contained in the result shape
|
||||
Standard_Integer aNb = aMPBSc.Extent();
|
||||
for (Standard_Integer i = 1; i <= aNb; ++i)
|
||||
{
|
||||
const TopoDS_Shape& aENew = myDS->Shape(aMPBSc(i)->Edge());
|
||||
if (myMapShape.Contains(aENew))
|
||||
myHistShapes.Append(aENew);
|
||||
}
|
||||
|
||||
// Section vertices of the face
|
||||
const TColStd_MapOfInteger& aMVSc = aFI.VerticesSc();
|
||||
// Save section vertices contained in the result shape
|
||||
TColStd_MapOfInteger::Iterator aItM(aMVSc);
|
||||
for (; aItM.More(); aItM.Next())
|
||||
{
|
||||
const TopoDS_Shape& aVNew = myDS->Shape(aItM.Value());
|
||||
if (myMapShape.Contains(aVNew))
|
||||
myHistShapes.Append(aVNew);
|
||||
}
|
||||
|
||||
return myHistShapes;
|
||||
}
|
||||
//=======================================================================
|
||||
@@ -44,99 +147,59 @@ const TopTools_ListOfShape& BOPAlgo_Builder::Generated
|
||||
const TopTools_ListOfShape& BOPAlgo_Builder::Modified
|
||||
(const TopoDS_Shape& theS)
|
||||
{
|
||||
Standard_Boolean bHasImage, bToReverse;
|
||||
TopAbs_ShapeEnum aType;
|
||||
TopTools_ListIteratorOfListOfShape aIt;
|
||||
//
|
||||
myHistShapes.Clear();
|
||||
//
|
||||
if (theS.IsNull()) {
|
||||
|
||||
if (!myHasModified)
|
||||
// No modified elements
|
||||
return myHistShapes;
|
||||
}
|
||||
//
|
||||
bHasImage=myImages.IsBound(theS);
|
||||
if (!bHasImage) {
|
||||
|
||||
const TopTools_ListOfShape* pLSp = myImagesResult.Seek(theS);
|
||||
if (!pLSp)
|
||||
// No track in the result -> no modified
|
||||
return myHistShapes;
|
||||
|
||||
// For modification check if the shape is not linked to itself
|
||||
if (pLSp->Extent() == 1)
|
||||
{
|
||||
if (theS.IsSame(pLSp->First()) && !myImages.IsBound(theS))
|
||||
// Shape is not modified
|
||||
return myHistShapes;
|
||||
}
|
||||
//
|
||||
aType=theS.ShapeType();
|
||||
//
|
||||
if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
|
||||
aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
|
||||
return myHistShapes;
|
||||
}
|
||||
//
|
||||
//PrepareHistory();
|
||||
//
|
||||
const TopTools_ListOfShape& aLSp=myImages.Find(theS);
|
||||
aIt.Initialize(aLSp);
|
||||
for (; aIt.More(); aIt.Next()) {
|
||||
TopoDS_Shape aSp=aIt.Value();
|
||||
if (myShapesSD.IsBound(aSp)) {
|
||||
aSp = myShapesSD.Find(aSp);
|
||||
}
|
||||
//
|
||||
if (myMapShape.Contains(aSp)) {
|
||||
//
|
||||
if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
|
||||
aSp.Orientation(theS.Orientation());
|
||||
}
|
||||
else {
|
||||
bToReverse=
|
||||
BOPTools_AlgoTools::IsSplitToReverse(aSp, theS, myContext);
|
||||
if (bToReverse) {
|
||||
aSp.Reverse();
|
||||
}
|
||||
}
|
||||
//
|
||||
myHistShapes.Append(aSp);
|
||||
}
|
||||
|
||||
// Iterate on all splits and save them with proper orientation into the result list
|
||||
TopTools_ListIteratorOfListOfShape aIt(*pLSp);
|
||||
for (; aIt.More(); aIt.Next())
|
||||
{
|
||||
TopoDS_Shape aSp = aIt.Value();
|
||||
// Use the orientation of the input shape
|
||||
TopAbs_ShapeEnum aType = aSp.ShapeType();
|
||||
if (aType == TopAbs_VERTEX || aType == TopAbs_SOLID)
|
||||
aSp.Orientation(theS.Orientation());
|
||||
else if (BOPTools_AlgoTools::IsSplitToReverse(aSp, theS, myContext))
|
||||
aSp.Reverse();
|
||||
|
||||
myHistShapes.Append(aSp);
|
||||
}
|
||||
//
|
||||
|
||||
return myHistShapes;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : IsDeleted
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BOPAlgo_Builder::IsDeleted
|
||||
(const TopoDS_Shape& theS)
|
||||
Standard_Boolean BOPAlgo_Builder::IsDeleted(const TopoDS_Shape& theS)
|
||||
{
|
||||
Standard_Boolean bRet;
|
||||
TopAbs_ShapeEnum aType;
|
||||
TopTools_ListIteratorOfListOfShape aIt;
|
||||
//
|
||||
bRet = Standard_True;
|
||||
//
|
||||
if (theS.IsNull()) {
|
||||
return bRet;
|
||||
}
|
||||
//
|
||||
aType = theS.ShapeType();
|
||||
if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
|
||||
aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
|
||||
return bRet;
|
||||
}
|
||||
//
|
||||
if (!myImages.IsBound(theS)) {
|
||||
bRet = !myMapShape.Contains(theS);
|
||||
return bRet;
|
||||
}
|
||||
//
|
||||
const TopTools_ListOfShape& aLSp = myImages.Find(theS);
|
||||
aIt.Initialize(aLSp);
|
||||
for (; aIt.More(); aIt.Next()) {
|
||||
const TopoDS_Shape& aSp = aIt.Value();
|
||||
const TopoDS_Shape& aSpR = myShapesSD.IsBound(aSp) ?
|
||||
myShapesSD.Find(aSp) : aSp;
|
||||
//
|
||||
if (myMapShape.Contains(aSpR)) {
|
||||
bRet = Standard_False;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
return bRet;
|
||||
// The shape is considered as Deleted if the result shape
|
||||
// does not contain the shape itself and none of its splits
|
||||
return myHasDeleted && !myImagesResult.Contains(theS);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : LocModified
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopTools_ListOfShape* BOPAlgo_Builder::LocModified(const TopoDS_Shape& theS)
|
||||
{
|
||||
return myImages.Seek(theS);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : PrepareHistory
|
||||
@@ -144,85 +207,100 @@ Standard_Boolean BOPAlgo_Builder::IsDeleted
|
||||
//=======================================================================
|
||||
void BOPAlgo_Builder::PrepareHistory()
|
||||
{
|
||||
if (!myFlagHistory) {
|
||||
if (!myFlagHistory)
|
||||
{
|
||||
// Clearing
|
||||
BOPAlgo_BuilderShape::PrepareHistory();
|
||||
return;
|
||||
}
|
||||
//
|
||||
if(myShape.IsNull()) {
|
||||
return;
|
||||
}
|
||||
//
|
||||
Standard_Boolean bHasImage;
|
||||
TopAbs_ShapeEnum aType;
|
||||
TopTools_MapOfShape aMS;
|
||||
TopTools_ListIteratorOfListOfShape aIt;
|
||||
TopTools_MapIteratorOfMapOfShape aItM;
|
||||
//
|
||||
// 1. Clearing
|
||||
|
||||
// Clearing from previous operations
|
||||
BOPAlgo_BuilderShape::PrepareHistory();
|
||||
//
|
||||
// 2. myMapShape - all shapes of result with theirs sub-shapes
|
||||
TopExp::MapShapes(myShape, myMapShape);
|
||||
//
|
||||
// 3. MS - all argument shapes with theirs sub-shapes
|
||||
const TopTools_ListOfShape& aArguments=myDS->Arguments();
|
||||
aIt.Initialize(aArguments);
|
||||
for (; aIt.More(); aIt.Next()) {
|
||||
const TopoDS_Shape& aSx=aIt.Value();
|
||||
TopExp::MapShapes(aSx, aMS);
|
||||
myFlagHistory = Standard_True;
|
||||
|
||||
if (myShape.IsNull() ||
|
||||
BOPTools_AlgoTools3D::IsEmptyShape(myShape))
|
||||
{
|
||||
// The result shape is a null shape or empty shape,
|
||||
// thus, no modified, no generated, all deleted
|
||||
myHasModified = Standard_False;
|
||||
myHasGenerated = Standard_False;
|
||||
myHasDeleted = Standard_True;
|
||||
return;
|
||||
}
|
||||
//
|
||||
// 4. Treatment
|
||||
aItM.Initialize(aMS);
|
||||
for (; aItM.More(); aItM.Next()) {
|
||||
const TopoDS_Shape& aSx=aItM.Key();
|
||||
aType = aSx.ShapeType();
|
||||
if (!(aType == TopAbs_VERTEX || aType == TopAbs_EDGE ||
|
||||
aType == TopAbs_FACE || aType == TopAbs_SOLID)) {
|
||||
|
||||
// Map the result shape
|
||||
TopExp::MapShapes(myShape, myMapShape);
|
||||
|
||||
// Among all input shapes find those that have any trace in the result
|
||||
// and save them into myImagesResult map with connection to parts
|
||||
// kept in the result shape.
|
||||
// Also, set the proper values to the history flags:
|
||||
// - myHasDeleted for Deleted shapes;
|
||||
// - myHasModified for Modified shapes;
|
||||
// - myHasGenerated for Generated shapes.
|
||||
Standard_Integer aNbS = myDS->NbSourceShapes();
|
||||
for (Standard_Integer i = 0; i < aNbS; ++i)
|
||||
{
|
||||
const TopoDS_Shape& aS = myDS->Shape(i);
|
||||
|
||||
// History information is only available for the shapes of type
|
||||
// VERTEX, EDGE, FACE and SOLID. Skip all shapes of different type.
|
||||
TopAbs_ShapeEnum aType = aS.ShapeType();
|
||||
if (!(aType == TopAbs_VERTEX ||
|
||||
aType == TopAbs_EDGE ||
|
||||
aType == TopAbs_FACE ||
|
||||
aType == TopAbs_SOLID))
|
||||
continue;
|
||||
|
||||
// Check if the shape has any splits
|
||||
const TopTools_ListOfShape* pLSp = LocModified(aS);
|
||||
if (!pLSp)
|
||||
{
|
||||
// No splits, check if the result shape contains the shape itself
|
||||
if (myMapShape.Contains(aS))
|
||||
// Shape has passed into result without modifications -> link the shape to itself
|
||||
myImagesResult(myImagesResult.Add(aS, TopTools_ListOfShape())).Append(aS);
|
||||
else
|
||||
// No trace of the shape in the result -> Deleted element is found
|
||||
myHasDeleted = Standard_True;
|
||||
}
|
||||
//
|
||||
// 4.1 .myImagesResult
|
||||
bHasImage=myImages.IsBound(aSx);
|
||||
//
|
||||
TopTools_ListOfShape aLSx;
|
||||
if (!bHasImage) {
|
||||
if (myMapShape.Contains(aSx)) {
|
||||
aLSx.Append(aSx);
|
||||
myImagesResult.Add(aSx, aLSx);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const TopTools_ListOfShape& aLSp=myImages.Find(aSx);
|
||||
aIt.Initialize(aLSp);
|
||||
for (; aIt.More(); aIt.Next()) {
|
||||
const TopoDS_Shape& aSp=aIt.Value();
|
||||
if (myMapShape.Contains(aSp)) {
|
||||
aLSx.Append(aSp);
|
||||
else
|
||||
{
|
||||
// Find all splits of the shape which are kept in the result
|
||||
TopTools_ListOfShape *pLSpKept = NULL;
|
||||
TopTools_ListIteratorOfListOfShape aIt(*pLSp);
|
||||
for (; aIt.More(); aIt.Next())
|
||||
{
|
||||
const TopoDS_Shape& aSp = aIt.Value();
|
||||
|
||||
// Check if the result shape contains the split
|
||||
if (myMapShape.Contains(aSp))
|
||||
{
|
||||
if (!pLSpKept)
|
||||
pLSpKept = &myImagesResult(myImagesResult.Add(aS, TopTools_ListOfShape()));
|
||||
|
||||
// Link the shape to the split
|
||||
pLSpKept->Append(aSp);
|
||||
}
|
||||
}
|
||||
myImagesResult.Add(aSx, aLSx);
|
||||
}
|
||||
// <- A
|
||||
//
|
||||
// 4.2 As it was
|
||||
if (!myHasDeleted) {
|
||||
myHasDeleted=IsDeleted(aSx);
|
||||
}
|
||||
//
|
||||
if (!myHasModified && bHasImage) {
|
||||
if (aType==TopAbs_EDGE || aType==TopAbs_FACE ||
|
||||
aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
|
||||
|
||||
if (pLSpKept)
|
||||
// Modified element is found
|
||||
myHasModified = Standard_True;
|
||||
}
|
||||
else
|
||||
// Deleted element is found
|
||||
myHasDeleted = Standard_True;
|
||||
}
|
||||
//
|
||||
if (!myHasGenerated) {
|
||||
if (aType==TopAbs_FACE) {
|
||||
const TopTools_ListOfShape& aLG = Generated(aSx);
|
||||
myHasGenerated = aLG.Extent() > 0;
|
||||
}
|
||||
|
||||
// Until first found, check if the shape has Generated elements
|
||||
if (!myHasGenerated)
|
||||
{
|
||||
// Temporarily set the HasGenerated flag to TRUE to look for the shapes generated from aS.
|
||||
// Otherwise, the method Generated will always be returning an empty list, assuming that the
|
||||
// operation has no generated elements at all.
|
||||
myHasGenerated = Standard_True;
|
||||
myHasGenerated = (Generated(aS).Extent() > 0);
|
||||
}
|
||||
}
|
||||
myFlagHistory=Standard_True;
|
||||
}
|
||||
|
@@ -15,22 +15,17 @@
|
||||
|
||||
#include <BOPAlgo_CellsBuilder.hxx>
|
||||
|
||||
#include <TopoDS_Compound.hxx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
|
||||
#include <BOPTools_AlgoTools.hxx>
|
||||
|
||||
#include <BOPAlgo_BuilderSolid.hxx>
|
||||
#include <BOPAlgo_Alerts.hxx>
|
||||
|
||||
#include <BOPAlgo_BuilderSolid.hxx>
|
||||
#include <BOPDS_DS.hxx>
|
||||
#include <BOPTools_AlgoTools.hxx>
|
||||
#include <BOPTools_AlgoTools3D.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <ShapeUpgrade_UnifySameDomain.hxx>
|
||||
#include <TColStd_MapOfInteger.hxx>
|
||||
#include <TopExp.hxx>
|
||||
|
||||
#include <ShapeUpgrade_UnifySameDomain.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
|
||||
|
||||
static
|
||||
@@ -939,118 +934,54 @@ Standard_Boolean BOPAlgo_CellsBuilder::RemoveInternals(const TopTools_ListOfShap
|
||||
//
|
||||
theLSNew.Append(aSNew);
|
||||
bRemoved = Standard_True;
|
||||
|
||||
// Save information about the fuse of the solids into a history map
|
||||
aItS.Initialize(aCB);
|
||||
for (; aItS.More(); aItS.Next())
|
||||
myMapModified.Bind(aItS.Value(), aSNew);
|
||||
}
|
||||
}
|
||||
return bRemoved;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDeleted
|
||||
//function : LocModified
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BOPAlgo_CellsBuilder::IsDeleted(const TopoDS_Shape& theS)
|
||||
const TopTools_ListOfShape* BOPAlgo_CellsBuilder::LocModified(const TopoDS_Shape& theS)
|
||||
{
|
||||
Standard_Boolean bRet = Standard_True;
|
||||
if (theS.IsNull()) {
|
||||
return bRet;
|
||||
}
|
||||
//
|
||||
TopAbs_ShapeEnum aType = theS.ShapeType();
|
||||
if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
|
||||
aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
|
||||
return bRet;
|
||||
}
|
||||
//
|
||||
Standard_Boolean bHasImage, bHasModified;
|
||||
//
|
||||
bHasImage = myImages.IsBound(theS);
|
||||
bHasModified = myMapModified.IsBound(theS);
|
||||
if (!bHasImage && !bHasModified) {
|
||||
bRet = !myMapShape.Contains(theS);
|
||||
return bRet;
|
||||
}
|
||||
//
|
||||
if (bHasModified) {
|
||||
const TopoDS_Shape& aSG = myMapModified.Find(theS);
|
||||
if (myMapShape.Contains(aSG)) {
|
||||
bRet = Standard_False;
|
||||
return bRet;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (bHasImage) {
|
||||
const TopTools_ListOfShape& aLSp = myImages.Find(theS);
|
||||
TopTools_ListIteratorOfListOfShape aIt(aLSp);
|
||||
for (; aIt.More(); aIt.Next()) {
|
||||
const TopoDS_Shape& aSp = aIt.Value();
|
||||
const TopoDS_Shape& aSpR = myShapesSD.IsBound(aSp) ?
|
||||
myShapesSD.Find(aSp) : aSp;
|
||||
//
|
||||
const TopoDS_Shape& aSpRG = myMapModified.IsBound(aSpR) ?
|
||||
myMapModified.Find(aSpR) : aSpR;
|
||||
if (myMapShape.Contains(aSpRG)) {
|
||||
bRet = Standard_False;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
return bRet;
|
||||
}
|
||||
// Get shape's modification coming from GF operation
|
||||
const TopTools_ListOfShape* pLSp = BOPAlgo_Builder::LocModified(theS);
|
||||
if (myMapModified.IsEmpty())
|
||||
// No local modifications
|
||||
return pLSp;
|
||||
|
||||
//=======================================================================
|
||||
//function : Modified
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopTools_ListOfShape& BOPAlgo_CellsBuilder::Modified(const TopoDS_Shape& theS)
|
||||
{
|
||||
myHistShapes.Clear();
|
||||
if (theS.IsNull()) {
|
||||
return myHistShapes;
|
||||
|
||||
// Check if the shape (or its splits) has participated in unification
|
||||
if (!pLSp)
|
||||
{
|
||||
// No splits from GF operation.
|
||||
// Check if the shape has been unified with other shapes
|
||||
const TopoDS_Shape* pSU = myMapModified.Seek(theS);
|
||||
if (!pSU)
|
||||
return NULL;
|
||||
|
||||
myHistShapes.Append(*pSU);
|
||||
}
|
||||
//
|
||||
TopAbs_ShapeEnum aType = theS.ShapeType();
|
||||
if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE || aType==TopAbs_VERTEX)) {
|
||||
return myHistShapes;
|
||||
}
|
||||
//
|
||||
Standard_Boolean bHasModified = myMapModified.IsBound(theS);
|
||||
if (bHasModified) {
|
||||
const TopoDS_Shape& aSG = myMapModified.Find(theS);
|
||||
if (myMapShape.Contains(aSG)) {
|
||||
myHistShapes.Append(aSG);
|
||||
}
|
||||
return myHistShapes;
|
||||
}
|
||||
//
|
||||
Standard_Boolean bHasImage = myImages.IsBound(theS);
|
||||
if (!bHasImage) {
|
||||
return myHistShapes;
|
||||
}
|
||||
//
|
||||
TopTools_MapOfShape aMFence;
|
||||
const TopTools_ListOfShape& aLSp = myImages.Find(theS);
|
||||
TopTools_ListIteratorOfListOfShape aIt(aLSp);
|
||||
for (; aIt.More(); aIt.Next()) {
|
||||
const TopoDS_Shape aSp = aIt.Value();
|
||||
const TopoDS_Shape& aSpR = myShapesSD.IsBound(aSp) ?
|
||||
myShapesSD.Find(aSp) : aSp;
|
||||
//
|
||||
if (myMapModified.IsBound(aSpR)) {
|
||||
const TopoDS_Shape& aSG = myMapModified.Find(aSpR);
|
||||
if (myMapShape.Contains(aSG)) {
|
||||
if (aMFence.Add(aSG)) {
|
||||
myHistShapes.Append(aSG);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (aMFence.Add(aSpR))
|
||||
else
|
||||
{
|
||||
// Process all GF splits and check them for local unification with other shapes
|
||||
TopTools_ListIteratorOfListOfShape aIt(*pLSp);
|
||||
for (; aIt.More(); aIt.Next())
|
||||
{
|
||||
myHistShapes.Append(aSpR);
|
||||
const TopoDS_Shape* pSp = &aIt.Value();
|
||||
const TopoDS_Shape* pSU = myMapModified.Seek(*pSp);
|
||||
if (pSU) pSp = pSU;
|
||||
myHistShapes.Append(*pSp);
|
||||
}
|
||||
}
|
||||
//
|
||||
return myHistShapes;
|
||||
return &myHistShapes;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -90,8 +90,6 @@
|
||||
//! 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.<br>
|
||||
//!
|
||||
//! The algorithm can return the following Error Statuses:
|
||||
//! - Error status acquired in the General Fuse algorithm.
|
||||
@@ -238,15 +236,13 @@ class BOPAlgo_CellsBuilder : public BOPAlgo_Builder
|
||||
//! Makes the Containers of proper type from the parts added to result.
|
||||
Standard_EXPORT void MakeContainers();
|
||||
|
||||
//! Returns the list of shapes generated from the shape theS.
|
||||
Standard_EXPORT virtual const TopTools_ListOfShape& Modified(const TopoDS_Shape& theS) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the shape theS has been deleted.
|
||||
Standard_EXPORT virtual Standard_Boolean IsDeleted (const TopoDS_Shape& theS) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Redefined method Prepare - no need to prepare history
|
||||
//! Prepare information for history support taking into account
|
||||
//! local modification map of unified elements - myMapModified.
|
||||
Standard_EXPORT virtual const TopTools_ListOfShape* LocModified(const TopoDS_Shape& theS) Standard_OVERRIDE;
|
||||
|
||||
//! 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;
|
||||
|
||||
@@ -269,11 +265,11 @@ class BOPAlgo_CellsBuilder : public BOPAlgo_Builder
|
||||
const TopTools_MapOfShape& theMapKeepBnd = TopTools_MapOfShape());
|
||||
|
||||
// fields
|
||||
TopoDS_Shape myAllParts;
|
||||
TopTools_IndexedDataMapOfShapeListOfShape myIndex;
|
||||
TopTools_DataMapOfIntegerListOfShape myMaterials;
|
||||
TopTools_DataMapOfShapeInteger myShapeMaterial;
|
||||
TopTools_DataMapOfShapeShape myMapModified;
|
||||
TopoDS_Shape myAllParts; //!< All split parts of the arguments
|
||||
TopTools_IndexedDataMapOfShapeListOfShape myIndex; //!< Connection map from all splits parts to the argument shapes from which they were created
|
||||
TopTools_DataMapOfIntegerListOfShape myMaterials; //!< Map of assigned materials (material -> list of shape)
|
||||
TopTools_DataMapOfShapeInteger myShapeMaterial; //!< Map of assigned materials (shape -> material)
|
||||
TopTools_DataMapOfShapeShape myMapModified; //!< Local modification map to track unification of the splits
|
||||
};
|
||||
|
||||
#endif //_BOPAlgo_CellsBuilder_HeaderFile
|
||||
|
@@ -15,7 +15,6 @@
|
||||
|
||||
#include <BOPAlgo_Section.hxx>
|
||||
#include <BOPAlgo_Alerts.hxx>
|
||||
#include <BOPAlgo_BuilderSolid.hxx>
|
||||
#include <BOPAlgo_PaveFiller.hxx>
|
||||
#include <BOPDS_CommonBlock.hxx>
|
||||
#include <BOPDS_DS.hxx>
|
||||
@@ -26,7 +25,6 @@
|
||||
#include <BOPDS_VectorOfFaceInfo.hxx>
|
||||
#include <BOPDS_VectorOfListOfPaveBlock.hxx>
|
||||
#include <BOPTools_AlgoTools.hxx>
|
||||
#include <BOPTools_AlgoTools3D.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
@@ -36,7 +34,6 @@
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopTools_DataMapOfShapeShape.hxx>
|
||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
@@ -357,44 +354,3 @@ void BOPAlgo_Section::BuildSection()
|
||||
//
|
||||
myShape=aRC;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Generated
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopTools_ListOfShape& BOPAlgo_Section::Generated
|
||||
(const TopoDS_Shape& theS)
|
||||
{
|
||||
myHistShapes.Clear();
|
||||
if (theS.IsNull()) {
|
||||
return myHistShapes;
|
||||
}
|
||||
//
|
||||
TopAbs_ShapeEnum aType = theS.ShapeType();
|
||||
if (aType != TopAbs_FACE) {
|
||||
return myHistShapes;
|
||||
}
|
||||
//
|
||||
Standard_Integer nS = myDS->Index(theS);
|
||||
if (nS < 0) {
|
||||
return myHistShapes;
|
||||
}
|
||||
//
|
||||
if (!myDS->HasFaceInfo(nS)) {
|
||||
return myHistShapes;
|
||||
}
|
||||
//
|
||||
//collect section edges of the face theS
|
||||
Standard_Integer i, aNb, nSp;
|
||||
//
|
||||
const BOPDS_FaceInfo& aFI = myDS->FaceInfo(nS);
|
||||
const BOPDS_IndexedMapOfPaveBlock& aMPBSc = aFI.PaveBlocksSc();
|
||||
aNb = aMPBSc.Extent();
|
||||
for (i = 1; i <= aNb; ++i) {
|
||||
const Handle(BOPDS_PaveBlock)& aPB = aMPBSc(i);
|
||||
nSp = aPB->Edge();
|
||||
const TopoDS_Shape& aSp = myDS->Shape(nSp);
|
||||
myHistShapes.Append(aSp);
|
||||
}
|
||||
//
|
||||
return myHistShapes;
|
||||
}
|
||||
|
@@ -43,26 +43,20 @@ public:
|
||||
//! Empty constructor
|
||||
Standard_EXPORT BOPAlgo_Section();
|
||||
Standard_EXPORT virtual ~BOPAlgo_Section();
|
||||
|
||||
//! Empty constructor
|
||||
//!
|
||||
//! protected methods
|
||||
Standard_EXPORT BOPAlgo_Section(const Handle(NCollection_BaseAllocator)& theAllocator);
|
||||
|
||||
Standard_EXPORT virtual void BuildSection();
|
||||
|
||||
//! Returns the list of shapes generated from the
|
||||
//! shape theS.
|
||||
Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& theS) Standard_OVERRIDE;
|
||||
|
||||
//! Constructor with allocator
|
||||
Standard_EXPORT BOPAlgo_Section(const Handle(NCollection_BaseAllocator)& theAllocator);
|
||||
|
||||
protected:
|
||||
|
||||
//! Checks the data before performing the operation
|
||||
Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
|
||||
|
||||
//! Performs calculations using prepared Filler
|
||||
//! object <thePF>
|
||||
Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF) Standard_OVERRIDE;
|
||||
|
||||
//! Combine the result of section operation
|
||||
Standard_EXPORT virtual void BuildSection();
|
||||
|
||||
//! Performs calculations using prepared Filler object <thePF>
|
||||
Standard_EXPORT virtual void PerformInternal1(const BOPAlgo_PaveFiller& thePF) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
|
Reference in New Issue
Block a user