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

0029481: Implementation of the Feature Removal algorithm

Implementation of the 3D model De-featuring algorithm intended for the removal of the unwanted parts (or features) from the model consisting of solids. The features can be the holes, protrusions, gaps, chamfers, fillets etc.
The algorithm removes all possible requested features from the shape and builds the new shape as a result. The input model is not modified.

On the API level the algorithm is implemented in the class *BRepAlgoAPI_Defeaturing*. The actual features removal is performed by the low-level algorithm *BOPAlgo_RemoveFeatures*.

Documentation of the new classes.
Implementation of the DRAW commands for working with new algorithm.
Test cases for the new functionality.

Changes in other algorithms used by De-featuring algorithm:
- Provide history support for the solids in *ShapeUpgrade_UnifySameDomain* algorithm;
- Implementation of the mechanism to merge History of any Algorithm with standard history methods such as IsDeleted(), Modified() and Generated() into *BRepTools_History*.
This commit is contained in:
emv
2018-02-06 08:48:27 +03:00
committed by bugmaster
parent 9e04ccdcf8
commit d9ca2e0cb1
112 changed files with 4212 additions and 39 deletions

View File

@@ -214,6 +214,14 @@ Standard_Boolean BRepTools_History::IsRemoved(
//purpose :
//==============================================================================
void BRepTools_History::Merge(const Handle(BRepTools_History)& theHistory23)
{
Merge(*theHistory23.get());
}
//==============================================================================
//function : Merge
//purpose :
//==============================================================================
void BRepTools_History::Merge(const BRepTools_History& theHistory23)
{
// Propagate R23 directly and M23 and G23 fully to M12 and G12.
// Remember the propagated shapes.
@@ -234,22 +242,22 @@ void BRepTools_History::Merge(const Handle(BRepTools_History)& theHistory23)
for (TopTools_ListOfShape::Iterator aSIt2(aL12); aSIt2.More();)
{
const TopoDS_Shape& aS2 = aSIt2.Value();
if (theHistory23->IsRemoved(aS2))
if (theHistory23.IsRemoved(aS2))
{
aL12.Remove(aSIt2);
aRPropagated.Add(aS2);
aL12.Remove(aSIt2);
}
else
{
if (theHistory23->myShapeToGenerated.IsBound(aS2))
if (theHistory23.myShapeToGenerated.IsBound(aS2))
{
add(aAdditions[0], theHistory23->myShapeToGenerated(aS2));
add(aAdditions[0], theHistory23.myShapeToGenerated(aS2));
aMAndGPropagated.Add(aS2);
}
if (theHistory23->myShapeToModified.IsBound(aS2))
if (theHistory23.myShapeToModified.IsBound(aS2))
{
add(aAdditions[aI], theHistory23->myShapeToModified(aS2));
add(aAdditions[aI], theHistory23.myShapeToModified(aS2));
aMAndGPropagated.Add(aS2);
aL12.Remove(aSIt2);
@@ -278,7 +286,7 @@ void BRepTools_History::Merge(const Handle(BRepTools_History)& theHistory23)
// Propagate M23 and G23 to M12 and G12 sequentially.
const TopTools_DataMapOfShapeListOfShape* aS2ToGAndM[] =
{&theHistory23->myShapeToGenerated, &theHistory23->myShapeToModified};
{&theHistory23.myShapeToGenerated, &theHistory23.myShapeToModified};
for (Standard_Integer aI = 0; aI < 2; ++aI)
{
for (TopTools_DataMapOfShapeListOfShape::Iterator aMIt2(*aS2ToGAndM[aI]);
@@ -310,13 +318,14 @@ void BRepTools_History::Merge(const Handle(BRepTools_History)& theHistory23)
aMIt1.Next();
if (aL12.IsEmpty())
{
myRemoved.Add(aS1);
aS1ToGAndM[aI]->UnBind(aS1);
}
}
}
// Propagate R23 to R12 sequentially.
for (TopTools_MapOfShape::Iterator aRIt23(theHistory23->myRemoved);
for (TopTools_MapOfShape::Iterator aRIt23(theHistory23.myRemoved);
aRIt23.More(); aRIt23.Next())
{
const TopoDS_Shape& aS2 = aRIt23.Value();

View File

@@ -17,6 +17,7 @@
#define _BRepTools_History_HeaderFile
#include <NCollection_Handle.hxx>
#include <TopExp.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
@@ -82,6 +83,51 @@ DEFINE_STANDARD_HANDLE(BRepTools_History, Standard_Transient)
//! Tj <= M12(Si), Qk <= M23(Tj) ==> Qk <= M13(Si);
class BRepTools_History: public Standard_Transient
{
public: //! @name Constructors for History creation
//! Empty constructor
BRepTools_History() {}
//! Template constructor for History creation from the algorithm having
//! standard history methods such as IsDeleted(), Modified() and Generated().
//! @param theArguments [in] Arguments of the algorithm;
//! @param theAlgo [in] The algorithm.
template <class TheAlgo>
BRepTools_History(const TopTools_ListOfShape& theArguments,
TheAlgo& theAlgo)
{
// Map all argument shapes to save them in history
TopTools_IndexedMapOfShape anArgsMap;
TopTools_ListIteratorOfListOfShape aIt(theArguments);
for (; aIt.More(); aIt.Next())
TopExp::MapShapes(aIt.Value(), anArgsMap);
// Copy the history for all supported shapes from the algorithm
Standard_Integer i, aNb = anArgsMap.Extent();
for (i = 1; i <= aNb; ++i)
{
const TopoDS_Shape& aS = anArgsMap(i);
if (!IsSupportedType(aS))
continue;
if (theAlgo.IsDeleted(aS))
{
Remove(aS);
continue;
}
// Check Modified
const TopTools_ListOfShape& aModified = theAlgo.Modified(aS);
for (aIt.Initialize(aModified); aIt.More(); aIt.Next())
AddModified(aS, aIt.Value());
// Check Generated
const TopTools_ListOfShape& aGenerated = theAlgo.Generated(aS);
for (aIt.Initialize(aGenerated); aIt.More(); aIt.Next())
AddGenerated(aS, aIt.Value());
}
}
public:
//! The types of the historical relations.
@@ -150,6 +196,22 @@ public: //! A method to merge a next history to this history.
//! Merges the next history to this history.
Standard_EXPORT void Merge(const Handle(BRepTools_History)& theHistory23);
//! Merges the next history to this history.
Standard_EXPORT void Merge(const BRepTools_History& theHistory23);
//! Template method for merging history of the algorithm having standard
//! history methods such as IsDeleted(), Modified() and Generated()
//! into current history object.
//! @param theArguments [in] Arguments of the algorithm;
//! @param theAlgo [in] The algorithm.
template<class TheAlgo>
void Merge(const TopTools_ListOfShape& theArguments,
TheAlgo& theAlgo)
{
// Create new history object from the given algorithm and merge it into this.
Merge(BRepTools_History(theArguments, theAlgo));
}
public:
//! Define the OCCT RTTI for the type.