mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0028747: Incorrect result of the section operation after edge refinement
Implementation of the method for simplification of the result of Boolean Operation on the API level. The method BRepAlgoAPI_BuilderAlgo::SimplifyResult has been added, so the derived classes such as BooleanOpeation and Splitter can also use this method. The result shape simplification should be called after the operation is done. The simplification is performed by the means of ShapeUpgrade_UnifySameDomain algorithm. Draw command "bsimplify" has been added to control the simplification options. Documentation for new functionality and draw commands controlling the options of Boolean operations. Test cases for the new functionality. Side-effect change: The algorithms in Boolean component have been changed to use the BRepTools_History as a History tool. Now it became possible to disable the collection of shapes modifications during Boolean Operations, which may be useful for performance sake (in draw the option is controlled by *setfillhistory* command). Draw command "unifysamedom" has been changed to accept the angular tolerance in degrees instead of radians.
This commit is contained in:
@@ -95,7 +95,7 @@ BOPAlgo_Builder::~BOPAlgo_Builder()
|
||||
//=======================================================================
|
||||
void BOPAlgo_Builder::Clear()
|
||||
{
|
||||
BOPAlgo_Algo::Clear();
|
||||
BOPAlgo_BuilderShape::Clear();
|
||||
myArguments.Clear();
|
||||
myMapFence.Clear();
|
||||
myImages.Clear();
|
||||
@@ -167,7 +167,6 @@ void BOPAlgo_Builder::Prepare()
|
||||
// 1. myShape is empty compound
|
||||
aBB.MakeCompound(aC);
|
||||
myShape=aC;
|
||||
myFlagHistory=Standard_True;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
|
@@ -174,21 +174,10 @@ public: //! @name Performing the operation
|
||||
Standard_EXPORT virtual void PerformWithFiller (const BOPAlgo_PaveFiller& theFiller);
|
||||
|
||||
|
||||
public: //! @name History methods
|
||||
|
||||
//! 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.
|
||||
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;
|
||||
Standard_EXPORT void PrepareHistory();
|
||||
|
||||
//! Prepare history information for the input shapes taking into account possible
|
||||
//! operation-specific modifications.
|
||||
@@ -209,6 +198,10 @@ protected: //! @name History methods
|
||||
//! Thus, here the method returns only splits (if any) contained in this map.
|
||||
Standard_EXPORT virtual const TopTools_ListOfShape* LocModified(const TopoDS_Shape& theS);
|
||||
|
||||
//! Returns the list of shapes generated from the shape theS.
|
||||
//! Similarly to *LocModified* must be redefined for specific operations,
|
||||
//! obtaining Generated elements differently.
|
||||
Standard_EXPORT virtual const TopTools_ListOfShape& LocGenerated(const TopoDS_Shape& theS);
|
||||
|
||||
public: //! @name Images/Origins
|
||||
|
||||
|
@@ -1,141 +0,0 @@
|
||||
// Created by: Peter KURNEV
|
||||
// Copyright (c) 2010-2014 OPEN CASCADE SAS
|
||||
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
|
||||
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <BOPAlgo_BuilderShape.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BOPAlgo_BuilderShape::BOPAlgo_BuilderShape()
|
||||
:
|
||||
BOPAlgo_Algo()
|
||||
{
|
||||
myHasDeleted=Standard_False;
|
||||
myHasGenerated=Standard_False;
|
||||
myHasModified=Standard_False;
|
||||
myFlagHistory=Standard_False;
|
||||
}
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BOPAlgo_BuilderShape::BOPAlgo_BuilderShape(const Handle(NCollection_BaseAllocator)& theAllocator)
|
||||
:
|
||||
BOPAlgo_Algo(theAllocator)
|
||||
{
|
||||
myHasDeleted=Standard_False;
|
||||
myHasGenerated=Standard_False;
|
||||
myHasModified=Standard_False;
|
||||
myFlagHistory=Standard_False;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : ~
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BOPAlgo_BuilderShape::~BOPAlgo_BuilderShape()
|
||||
{
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Shape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopoDS_Shape& BOPAlgo_BuilderShape::Shape() const
|
||||
{
|
||||
return myShape;
|
||||
}
|
||||
//
|
||||
//=======================================================================
|
||||
//function : Generated
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopTools_ListOfShape& BOPAlgo_BuilderShape::Generated(const TopoDS_Shape& )
|
||||
{
|
||||
myHistShapes.Clear();
|
||||
return myHistShapes;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Modified
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopTools_ListOfShape& BOPAlgo_BuilderShape::Modified(const TopoDS_Shape& )
|
||||
{
|
||||
myHistShapes.Clear();
|
||||
return myHistShapes;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : IsDeleted
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BOPAlgo_BuilderShape::IsDeleted(const TopoDS_Shape& theS)
|
||||
{
|
||||
Standard_Boolean bRet;
|
||||
//
|
||||
bRet=!myMapShape.Contains(theS);
|
||||
return bRet;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : HasDeleted
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BOPAlgo_BuilderShape::HasDeleted()const
|
||||
{
|
||||
return myHasDeleted;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : HasGenerated
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BOPAlgo_BuilderShape::HasGenerated()const
|
||||
{
|
||||
return myHasGenerated;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : HasModified
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BOPAlgo_BuilderShape::HasModified()const
|
||||
{
|
||||
return myHasModified;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : PrepareHistory
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BOPAlgo_BuilderShape::PrepareHistory()
|
||||
{
|
||||
myHistShapes.Clear();
|
||||
myMapShape.Clear();
|
||||
myImagesResult.Clear();
|
||||
myHasDeleted=Standard_False;
|
||||
myHasGenerated=Standard_False;
|
||||
myHasModified=Standard_False;
|
||||
myFlagHistory=Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ImagesResult
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopTools_IndexedDataMapOfShapeListOfShape&
|
||||
BOPAlgo_BuilderShape::ImagesResult()const
|
||||
{
|
||||
return myImagesResult;
|
||||
}
|
||||
|
@@ -21,9 +21,12 @@
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
|
||||
#include <BOPAlgo_Algo.hxx>
|
||||
#include <BRepTools_History.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
|
||||
#include <NCollection_BaseAllocator.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
@@ -31,71 +34,120 @@
|
||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
class TopoDS_Shape;
|
||||
|
||||
|
||||
//! Root class for algorithms that has shape as result.<br>
|
||||
//! Root class for algorithms that has shape as result.
|
||||
//!
|
||||
//! The class provides the History mechanism, which allows
|
||||
//! tracking the modification of the input shapes during
|
||||
//! the operation.
|
||||
class BOPAlgo_BuilderShape : public BOPAlgo_Algo
|
||||
//! the operation. It uses the *BRepTools_History* tool
|
||||
//! as a storer for history objects.
|
||||
class BOPAlgo_BuilderShape : public BOPAlgo_Algo
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
public: //! @name Getting the result
|
||||
|
||||
//! Returns the result of algorithm
|
||||
Standard_EXPORT const TopoDS_Shape& Shape() const;
|
||||
|
||||
//! Returns the list of shapes generated from the
|
||||
//! shape theS.
|
||||
Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& theS);
|
||||
|
||||
//! Returns the list of shapes modified from the
|
||||
//! shape theS.
|
||||
Standard_EXPORT virtual const TopTools_ListOfShape& Modified (const TopoDS_Shape& theS);
|
||||
|
||||
const TopoDS_Shape& Shape() const { return myShape; }
|
||||
|
||||
|
||||
public: //! @name History methods
|
||||
|
||||
//! Returns the list of shapes Modified from the shape theS.
|
||||
const TopTools_ListOfShape& Modified(const TopoDS_Shape& theS)
|
||||
{
|
||||
if (myFillHistory && myHistory)
|
||||
return myHistory->Modified(theS);
|
||||
myHistShapes.Clear();
|
||||
return myHistShapes;
|
||||
}
|
||||
|
||||
//! Returns the list of shapes Generated from the shape theS.
|
||||
const TopTools_ListOfShape& Generated(const TopoDS_Shape& theS)
|
||||
{
|
||||
if (myFillHistory && myHistory)
|
||||
return myHistory->Generated(theS);
|
||||
myHistShapes.Clear();
|
||||
return myHistShapes;
|
||||
}
|
||||
|
||||
//! Returns true if the shape theS has been deleted.
|
||||
Standard_EXPORT virtual Standard_Boolean IsDeleted (const TopoDS_Shape& theS);
|
||||
|
||||
//! Returns true if the at least one shape(or subshape)
|
||||
//! of arguments has been deleted.
|
||||
Standard_EXPORT Standard_Boolean HasDeleted() const;
|
||||
|
||||
//! Returns true if the at least one shape(or subshape)
|
||||
//! of arguments has generated shapes.
|
||||
Standard_EXPORT Standard_Boolean HasGenerated() const;
|
||||
|
||||
//! Returns true if the at least one shape(or subshape)
|
||||
//! of arguments has modified shapes.
|
||||
Standard_EXPORT Standard_Boolean HasModified() const;
|
||||
|
||||
Standard_EXPORT const TopTools_IndexedDataMapOfShapeListOfShape& ImagesResult() const;
|
||||
//! In this case the shape will have no Modified elements,
|
||||
//! but can have Generated elements.
|
||||
Standard_Boolean IsDeleted(const TopoDS_Shape& theS)
|
||||
{
|
||||
return (myFillHistory && myHistory ? myHistory->IsRemoved(theS) : Standard_False);
|
||||
}
|
||||
|
||||
//! Returns true if any of the input shapes has been modified during operation.
|
||||
Standard_Boolean HasModified() const
|
||||
{
|
||||
return (myFillHistory && myHistory ? myHistory->HasModified() : Standard_False);
|
||||
}
|
||||
|
||||
//! Returns true if any of the input shapes has generated shapes during operation.
|
||||
Standard_Boolean HasGenerated() const
|
||||
{
|
||||
return (myFillHistory && myHistory ? myHistory->HasGenerated() : Standard_False);
|
||||
}
|
||||
|
||||
//! Returns true if any of the input shapes has been deleted during operation.
|
||||
Standard_Boolean HasDeleted() const
|
||||
{
|
||||
return (myFillHistory && myHistory ? myHistory->HasRemoved() : Standard_False);
|
||||
}
|
||||
|
||||
//! History Tool
|
||||
Handle(BRepTools_History) History() const
|
||||
{
|
||||
return myFillHistory ? myHistory : NULL;
|
||||
}
|
||||
|
||||
public: //! @name Enabling/Disabling the history collection.
|
||||
|
||||
//! Allows disabling the history collection
|
||||
void SetToFillHistory(const Standard_Boolean theHistFlag) { myFillHistory = theHistFlag; }
|
||||
|
||||
//! Returns flag of history availability
|
||||
Standard_Boolean HasHistory() const { return myFillHistory; }
|
||||
|
||||
protected: //! @name Constructors
|
||||
|
||||
//! Empty constructor
|
||||
BOPAlgo_BuilderShape()
|
||||
:
|
||||
BOPAlgo_Algo(),
|
||||
myFillHistory(Standard_True)
|
||||
{}
|
||||
|
||||
//! Constructor with allocator
|
||||
BOPAlgo_BuilderShape(const Handle(NCollection_BaseAllocator)& theAllocator)
|
||||
:
|
||||
BOPAlgo_Algo(theAllocator),
|
||||
myFillHistory(Standard_True)
|
||||
{}
|
||||
|
||||
|
||||
protected: //! @name Clearing
|
||||
|
||||
//! Clears the content of the algorithm.
|
||||
virtual void Clear() Standard_OVERRIDE
|
||||
{
|
||||
BOPAlgo_Algo::Clear();
|
||||
myHistory.Nullify();
|
||||
myMapShape.Clear();
|
||||
}
|
||||
|
||||
protected:
|
||||
protected: //! @name Fields
|
||||
|
||||
|
||||
Standard_EXPORT BOPAlgo_BuilderShape();
|
||||
Standard_EXPORT virtual ~BOPAlgo_BuilderShape();
|
||||
|
||||
Standard_EXPORT BOPAlgo_BuilderShape(const Handle(NCollection_BaseAllocator)& theAllocator);
|
||||
|
||||
//! Prepare information for history support
|
||||
Standard_EXPORT virtual void PrepareHistory();
|
||||
TopoDS_Shape myShape; //!< Result of the operation
|
||||
|
||||
TopTools_ListOfShape myHistShapes; //!< Storer for the history shapes
|
||||
TopTools_MapOfShape myMapShape; //!< Cashed map of all arguments shapes
|
||||
|
||||
TopoDS_Shape myShape;
|
||||
TopTools_ListOfShape myHistShapes;
|
||||
TopTools_MapOfShape myMapShape;
|
||||
Standard_Boolean myHasDeleted;
|
||||
Standard_Boolean myHasGenerated;
|
||||
Standard_Boolean myHasModified;
|
||||
TopTools_IndexedDataMapOfShapeListOfShape myImagesResult;
|
||||
Standard_Boolean myFlagHistory;
|
||||
|
||||
private:
|
||||
Standard_Boolean myFillHistory; //!< Controls the history filling
|
||||
Handle(BRepTools_History) myHistory; //!< History tool
|
||||
|
||||
};
|
||||
|
||||
|
@@ -19,19 +19,16 @@
|
||||
#include <BOPAlgo_Builder.hxx>
|
||||
#include <BOPDS_DS.hxx>
|
||||
#include <BOPTools_AlgoTools.hxx>
|
||||
#include <BOPTools_AlgoTools3D.hxx>
|
||||
#include <IntTools_Context.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Generated
|
||||
//function : LocGenerated
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopTools_ListOfShape& BOPAlgo_Builder::Generated
|
||||
const TopTools_ListOfShape& BOPAlgo_Builder::LocGenerated
|
||||
(const TopoDS_Shape& theS)
|
||||
{
|
||||
// The rules for Generated shapes are these:
|
||||
@@ -43,9 +40,6 @@ const TopTools_ListOfShape& BOPAlgo_Builder::Generated
|
||||
|
||||
myHistShapes.Clear();
|
||||
|
||||
if (!myHasGenerated)
|
||||
return myHistShapes;
|
||||
|
||||
if (theS.IsNull())
|
||||
return myHistShapes;
|
||||
|
||||
@@ -141,72 +135,6 @@ const TopTools_ListOfShape& BOPAlgo_Builder::Generated
|
||||
return myHistShapes;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Modified
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopTools_ListOfShape& BOPAlgo_Builder::Modified
|
||||
(const TopoDS_Shape& theS)
|
||||
{
|
||||
myHistShapes.Clear();
|
||||
|
||||
if (!myHasModified)
|
||||
// No modified elements
|
||||
return myHistShapes;
|
||||
|
||||
const TopTools_ListOfShape* pLSp = myImagesResult.Seek(theS);
|
||||
if (!pLSp || pLSp->IsEmpty())
|
||||
// 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;
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
// The shape is considered as Deleted if it has participated in the
|
||||
// operation and the result shape does not contain the shape itself
|
||||
// and none of its splits.
|
||||
|
||||
if (!myHasDeleted)
|
||||
// Non of the shapes have been deleted during the operation
|
||||
return Standard_False;
|
||||
|
||||
const TopTools_ListOfShape *pImages = myImagesResult.Seek(theS);
|
||||
if (!pImages)
|
||||
// No track about the shape, i.e. the shape has not participated
|
||||
// in operation -> Not deleted
|
||||
return Standard_False;
|
||||
|
||||
// Check if any parts of the shape has been kept in the result
|
||||
return pImages->IsEmpty();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : LocModified
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
@@ -220,91 +148,72 @@ const TopTools_ListOfShape* BOPAlgo_Builder::LocModified(const TopoDS_Shape& the
|
||||
//=======================================================================
|
||||
void BOPAlgo_Builder::PrepareHistory()
|
||||
{
|
||||
if (!myFlagHistory)
|
||||
{
|
||||
// Clearing
|
||||
BOPAlgo_BuilderShape::PrepareHistory();
|
||||
if (!HasHistory())
|
||||
return;
|
||||
}
|
||||
|
||||
// Clearing from previous operations
|
||||
BOPAlgo_BuilderShape::PrepareHistory();
|
||||
myFlagHistory = Standard_True;
|
||||
// Initializing history tool
|
||||
myHistory = new BRepTools_History;
|
||||
|
||||
// Map the result shape
|
||||
myMapShape.Clear();
|
||||
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. If the input shape has no trace in the
|
||||
// result shape, link it to the empty list in myImagesResult meaning
|
||||
// that the shape has been removed.
|
||||
//
|
||||
// Also, set the proper values to the history flags:
|
||||
// - myHasDeleted for Deleted shapes;
|
||||
// - myHasModified for Modified shapes;
|
||||
// - myHasGenerated for Generated shapes.
|
||||
// Among all input shapes find:
|
||||
// - Shapes that have been modified (split). Add the splits kept in the result
|
||||
// shape as Modified from the shape;
|
||||
// - Shapes that have created new geometries (i.e. generated new shapes). Add
|
||||
// the generated elements kept in the result shape as Generated from the shape;
|
||||
// - Shapes that have no trace in the result shape. Add them as Deleted
|
||||
// during the operation.
|
||||
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))
|
||||
// Check if History information is available for this kind of shape.
|
||||
if (!BRepTools_History::IsSupportedType(aS))
|
||||
continue;
|
||||
|
||||
// Track the modification of the shape
|
||||
TopTools_ListOfShape* pImages = &myImagesResult(myImagesResult.Add(aS, TopTools_ListOfShape()));
|
||||
Standard_Boolean isModified = Standard_False;
|
||||
|
||||
// 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
|
||||
pImages->Append(aS);
|
||||
else
|
||||
// No trace of the shape in the result -> Deleted element is found
|
||||
myHasDeleted = Standard_True;
|
||||
}
|
||||
else
|
||||
if (pLSp)
|
||||
{
|
||||
// Find all splits of the shape which are kept in the result
|
||||
TopTools_ListIteratorOfListOfShape aIt(*pLSp);
|
||||
for (; aIt.More(); aIt.Next())
|
||||
{
|
||||
const TopoDS_Shape& aSp = aIt.Value();
|
||||
|
||||
TopoDS_Shape aSp = aIt.Value();
|
||||
// Check if the result shape contains the split
|
||||
if (myMapShape.Contains(aSp))
|
||||
{
|
||||
// Link the shape to the split
|
||||
pImages->Append(aSp);
|
||||
// Add modified shape with proper orientation
|
||||
TopAbs_ShapeEnum aType = aSp.ShapeType();
|
||||
if (aType == TopAbs_VERTEX || aType == TopAbs_SOLID)
|
||||
aSp.Orientation(aS.Orientation());
|
||||
else if (BOPTools_AlgoTools::IsSplitToReverse(aSp, aS, myContext))
|
||||
aSp.Reverse();
|
||||
|
||||
myHistory->AddModified(aS, aSp);
|
||||
isModified = Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pImages->IsEmpty())
|
||||
// Modified element is found
|
||||
myHasModified = Standard_True;
|
||||
else
|
||||
// Deleted element is found
|
||||
myHasDeleted = Standard_True;
|
||||
}
|
||||
|
||||
// Until first found, check if the shape has Generated elements
|
||||
if (!myHasGenerated)
|
||||
// Check if the shape has Generated elements
|
||||
const TopTools_ListOfShape& aGenShapes = LocGenerated(aS);
|
||||
TopTools_ListIteratorOfListOfShape aIt(aGenShapes);
|
||||
for (; aIt.More(); aIt.Next())
|
||||
{
|
||||
// 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);
|
||||
const TopoDS_Shape& aG = aIt.Value();
|
||||
if (myMapShape.Contains(aG))
|
||||
myHistory->AddGenerated(aS, aG);
|
||||
}
|
||||
|
||||
// Check if the shape has been deleted, i.e. it is not contained in the result
|
||||
// and has no Modified shapes.
|
||||
if (!isModified && !myMapShape.Contains(aS))
|
||||
myHistory->Remove(aS);
|
||||
}
|
||||
}
|
||||
|
@@ -98,36 +98,30 @@ const TopoDS_Shape& BOPAlgo_CellsBuilder::GetAllParts() const
|
||||
return myAllParts;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Prepare
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BOPAlgo_CellsBuilder::Prepare()
|
||||
{
|
||||
BOPAlgo_Builder::Prepare();
|
||||
//
|
||||
myFlagHistory=Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PerformInternal1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BOPAlgo_CellsBuilder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller)
|
||||
{
|
||||
// Avoid filling history after GF operation as later
|
||||
// in this method the result shape will be nullified
|
||||
Standard_Boolean isHistory = HasHistory();
|
||||
SetToFillHistory(Standard_False);
|
||||
// Perform splitting of the arguments
|
||||
BOPAlgo_Builder::PerformInternal1(theFiller);
|
||||
//
|
||||
if (HasErrors()) {
|
||||
return;
|
||||
}
|
||||
//
|
||||
|
||||
// index all the parts to its origins
|
||||
IndexParts();
|
||||
//
|
||||
|
||||
// and nullify <myShape> for building the result;
|
||||
RemoveAllFromResult();
|
||||
//
|
||||
myFlagHistory = Standard_True;
|
||||
|
||||
// Restore user's history settings
|
||||
SetToFillHistory(isHistory);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -242,10 +242,6 @@ class BOPAlgo_CellsBuilder : public BOPAlgo_Builder
|
||||
//! 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;
|
||||
|
||||
//! 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;
|
||||
|
@@ -130,7 +130,7 @@ void BOPAlgo_RemoveFeatures::Perform()
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
|
||||
if (myTrackHistory)
|
||||
if (HasHistory())
|
||||
myHistory = new BRepTools_History();
|
||||
|
||||
// Check the input data
|
||||
@@ -225,7 +225,7 @@ void BOPAlgo_RemoveFeatures::CheckData()
|
||||
|
||||
myShape = aCS;
|
||||
|
||||
if (myTrackHistory)
|
||||
if (HasHistory())
|
||||
{
|
||||
// Make non solid shapes removed in the history
|
||||
MakeRemoved(anOtherShapes, *myHistory.get());
|
||||
@@ -494,7 +494,7 @@ private: //! @name Private methods performing the operation
|
||||
|
||||
anIntResult = aGFInter.Shape();
|
||||
|
||||
myHistory->Merge<BOPAlgo_Builder>(aGFInter.Arguments(), aGFInter);
|
||||
myHistory->Merge(aGFInter.History());
|
||||
}
|
||||
else
|
||||
anIntResult = aGFInter.Arguments().First();
|
||||
@@ -679,7 +679,7 @@ private: //! @name Private methods performing the operation
|
||||
}
|
||||
|
||||
// Update history after intersection of the extended face with bounds
|
||||
myHistory->Merge<BOPAlgo_Builder>(aGFTrim.Arguments(), aGFTrim);
|
||||
myHistory->Merge(aGFTrim.History());
|
||||
|
||||
// Update history with all removed shapes
|
||||
BRepTools_History aHistRem;
|
||||
@@ -782,7 +782,7 @@ void BOPAlgo_RemoveFeatures::RemoveFeatures()
|
||||
|
||||
// No need to fill the history for solids if the history is not
|
||||
// requested and the current feature is the last one.
|
||||
Standard_Boolean isSolidsHistoryNeeded = myTrackHistory || (i < (aNbF - 1));
|
||||
Standard_Boolean isSolidsHistoryNeeded = HasHistory() || (i < (aNbF - 1));
|
||||
|
||||
// Perform removal of the single feature
|
||||
RemoveFeature(aFG.Feature(), aFG.Solids(), aFG.FeatureFacesMap(),
|
||||
@@ -895,7 +895,7 @@ void BOPAlgo_RemoveFeatures::RemoveFeature
|
||||
aFacesToBeKept.Add(anAdjF);
|
||||
}
|
||||
|
||||
if (myTrackHistory)
|
||||
if (HasHistory())
|
||||
{
|
||||
// Look for internal edges in the original adjacent faces
|
||||
const TopoDS_Shape& aFOr = theAdjFaces.FindKey(i);
|
||||
@@ -990,9 +990,9 @@ void BOPAlgo_RemoveFeatures::RemoveFeature
|
||||
// History of adjacent faces reconstruction
|
||||
myHistory->Merge(theAdjFacesHistory);
|
||||
// History of intersection
|
||||
myHistory->Merge<BOPAlgo_MakerVolume>(aMV.Arguments(), aMV);
|
||||
myHistory->Merge(aMV.History());
|
||||
|
||||
if (myTrackHistory)
|
||||
if (HasHistory())
|
||||
{
|
||||
// Map the result to check if the shape is removed
|
||||
TopTools_IndexedMapOfShape aMSRes;
|
||||
@@ -1037,11 +1037,12 @@ void BOPAlgo_RemoveFeatures::RemoveFeature
|
||||
//=======================================================================
|
||||
void BOPAlgo_RemoveFeatures::UpdateHistory()
|
||||
{
|
||||
if (!myTrackHistory)
|
||||
if (!HasHistory())
|
||||
return;
|
||||
|
||||
// Map the result
|
||||
TopExp::MapShapes(myShape, myResultMap);
|
||||
myMapShape.Clear();
|
||||
TopExp::MapShapes(myShape, myMapShape);
|
||||
|
||||
// Update the history
|
||||
BRepTools_History aHistory;
|
||||
@@ -1060,14 +1061,14 @@ void BOPAlgo_RemoveFeatures::UpdateHistory()
|
||||
const TopTools_ListOfShape& aLSIm = myHistory->Modified(aS);
|
||||
if (aLSIm.IsEmpty())
|
||||
{
|
||||
if (!myResultMap.Contains(aS))
|
||||
if (!myMapShape.Contains(aS))
|
||||
aHistory.Remove(aS);
|
||||
}
|
||||
|
||||
TopTools_ListIteratorOfListOfShape itLSIm(aLSIm);
|
||||
for (; itLSIm.More(); itLSIm.Next())
|
||||
{
|
||||
if (!myResultMap.Contains(itLSIm.Value()))
|
||||
if (!myMapShape.Contains(itLSIm.Value()))
|
||||
aHistory.Remove(itLSIm.Value());
|
||||
}
|
||||
}
|
||||
@@ -1089,20 +1090,20 @@ void BOPAlgo_RemoveFeatures::SimplifyResult()
|
||||
// Do not allow producing internal edges
|
||||
aSDTool.AllowInternalEdges(Standard_False);
|
||||
// Avoid removal of the input edges and vertices
|
||||
if (myResultMap.IsEmpty())
|
||||
TopExp::MapShapes(myShape, myResultMap);
|
||||
if (myMapShape.IsEmpty())
|
||||
TopExp::MapShapes(myShape, myMapShape);
|
||||
|
||||
const Standard_Integer aNbS = myInputsMap.Extent();
|
||||
for (Standard_Integer i = 1; i <= aNbS; ++i)
|
||||
{
|
||||
if (myResultMap.Contains(myInputsMap(i)))
|
||||
if (myMapShape.Contains(myInputsMap(i)))
|
||||
aSDTool.KeepShape(myInputsMap(i));
|
||||
}
|
||||
|
||||
// Perform unification
|
||||
aSDTool.Build();
|
||||
myShape = aSDTool.Shape();
|
||||
if (myTrackHistory)
|
||||
if (HasHistory())
|
||||
myHistory->Merge(aSDTool.History());
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <BOPAlgo_Options.hxx>
|
||||
#include <BOPAlgo_BuilderShape.hxx>
|
||||
#include <BRepTools_History.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
@@ -79,7 +79,7 @@
|
||||
//! available through the methods of the history tool *BRepTools_History*,
|
||||
//! which can be accessed here through the method *History()*.
|
||||
//! By default, the history is collected, but it is possible to disable it
|
||||
//! using the method *TrackHistory(false)*;
|
||||
//! using the method *SetToFillHistory(false)*;
|
||||
//!
|
||||
//! <b>Error/Warning reporting system</b> - allows obtaining the extended overview
|
||||
//! of the Errors/Warnings occurred during the operation. As soon as any error
|
||||
@@ -124,7 +124,7 @@
|
||||
//! aRF.SetShape(aSolid); // Set the shape
|
||||
//! aRF.AddFacesToRemove(aFaces); // Add faces to remove
|
||||
//! aRF.SetRunParallel(bRunParallel); // Define the processing mode (parallel or single)
|
||||
//! aRF.TrackHistory(isHistoryNeeded); // Define whether to track the shapes modifications
|
||||
//! aRF.SetToFillHistory(isHistoryNeeded); // Define whether to track the shapes modifications
|
||||
//! aRF.Perform(); // Perform the operation
|
||||
//! if (aRF.HasErrors()) // Check for the errors
|
||||
//! {
|
||||
@@ -144,7 +144,7 @@
|
||||
//! When all possible features are removed, the shape is simplified by
|
||||
//! removing extra edges and vertices, created during operation, from the result shape.
|
||||
//!
|
||||
class BOPAlgo_RemoveFeatures: public BOPAlgo_Options
|
||||
class BOPAlgo_RemoveFeatures: public BOPAlgo_BuilderShape
|
||||
{
|
||||
public:
|
||||
DEFINE_STANDARD_ALLOC
|
||||
@@ -154,10 +154,8 @@ public: //! @name Constructors
|
||||
//! Empty constructor
|
||||
BOPAlgo_RemoveFeatures()
|
||||
:
|
||||
BOPAlgo_Options(),
|
||||
myTrackHistory(Standard_True)
|
||||
{
|
||||
}
|
||||
BOPAlgo_BuilderShape()
|
||||
{}
|
||||
|
||||
|
||||
public: //! @name Setting input data for the algorithm
|
||||
@@ -203,47 +201,21 @@ public: //! @name Setting input data for the algorithm
|
||||
public: //! @name Performing the operation
|
||||
|
||||
//! Performs the operation
|
||||
Standard_EXPORT void Perform();
|
||||
Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
|
||||
|
||||
|
||||
public: //! @name Clearing the contents of the algorithm
|
||||
|
||||
//! Clears the contents of the algorithm from previous run,
|
||||
//! allowing reusing it for following removals.
|
||||
void Clear()
|
||||
virtual void Clear() Standard_OVERRIDE
|
||||
{
|
||||
BOPAlgo_Options::Clear();
|
||||
myHistory.Nullify();
|
||||
BOPAlgo_BuilderShape::Clear();
|
||||
myInputShape.Nullify();
|
||||
myShape.Nullify();
|
||||
myFacesToRemove.Clear();
|
||||
myFeatures.Clear();
|
||||
myInputsMap.Clear();
|
||||
myResultMap.Clear();
|
||||
}
|
||||
|
||||
|
||||
public: //! @name History support
|
||||
|
||||
//! Defines whether to track the modification of the shapes or not
|
||||
void TrackHistory(const Standard_Boolean theFlag)
|
||||
{
|
||||
myTrackHistory = theFlag;
|
||||
}
|
||||
|
||||
//! Gets the History object
|
||||
Handle(BRepTools_History) History()
|
||||
{
|
||||
return (myTrackHistory ? myHistory : NULL);
|
||||
}
|
||||
|
||||
|
||||
public: //! @name Obtaining the results
|
||||
|
||||
//! Returns the resulting shape
|
||||
const TopoDS_Shape& Shape() const
|
||||
{
|
||||
return myShape;
|
||||
}
|
||||
|
||||
|
||||
@@ -254,7 +226,7 @@ protected: //! @name Protected methods performing the removal
|
||||
//! If the input shape is not a solid, the method looks for the solids
|
||||
//! in <myInputShape> and uses only them. All other shapes are simply removed.
|
||||
//! If no solids were found, the Error of unsupported type is returned.
|
||||
Standard_EXPORT void CheckData();
|
||||
Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
|
||||
|
||||
//! Prepares the faces to remove:
|
||||
//! - Gets only faces contained in the input solids;
|
||||
@@ -298,18 +270,11 @@ protected: //! @name Fields
|
||||
// Inputs
|
||||
TopoDS_Shape myInputShape; //!< Input shape
|
||||
TopTools_ListOfShape myFacesToRemove; //!< Faces to remove
|
||||
Standard_Boolean myTrackHistory; //!< Defines whether to track the history of shapes
|
||||
//! modifications or not (true by default)
|
||||
|
||||
// Intermediate
|
||||
TopTools_ListOfShape myFeatures; //!< List of not connected features to remove
|
||||
//! (each feature is a compound of faces)
|
||||
TopTools_IndexedMapOfShape myInputsMap; //!< Map of all sub-shapes of the input shape
|
||||
TopTools_MapOfShape myResultMap; //!< Map of all sub-shapes of the result shape
|
||||
|
||||
// Results
|
||||
TopoDS_Shape myShape; //!< Result shape
|
||||
Handle(BRepTools_History) myHistory; //!< History tool
|
||||
};
|
||||
|
||||
#endif // _BOPAlgo_RemoveFeatures_HeaderFile
|
||||
|
@@ -17,7 +17,6 @@ BOPAlgo_BuilderArea.cxx
|
||||
BOPAlgo_BuilderArea.hxx
|
||||
BOPAlgo_BuilderFace.cxx
|
||||
BOPAlgo_BuilderFace.hxx
|
||||
BOPAlgo_BuilderShape.cxx
|
||||
BOPAlgo_BuilderShape.hxx
|
||||
BOPAlgo_BuilderSolid.cxx
|
||||
BOPAlgo_BuilderSolid.hxx
|
||||
|
Reference in New Issue
Block a user