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

0029604: Uniform mechanism providing History of shape's modifications for OCCT algorithms in DRAW

Implementation of the mechanism for unification of the history commands for all OCCT algorithms.
The following Draw commands should be used to track the history of shapes modifications of any operation:
- modified - to find the shapes modified from the given shape in the given history.
- generated - to find the shapes generated from the given shape in the given history.
- isdeleted - to check if the given shape has been deleted during operation.

The mechanism allows fast & easy enabling of the DRAW history support for the algorithms supporting the history on the API level (i.e. the algorithm should have the methods Modified(), Generated() and IsDeleted()).
To enable the draw history support it is necessary to store the history of the algorithm into the session. For instance:

TopTools_ListOfShape Objects = ...; // Objects
TopTools_ListOfShape Tools = ...; // Tools

BRepAlgoAPI_Cut aCut(Objects, Tools); // Boolean cut operation

BRepTest_Objects::SetHistory(Objects, aCut); // Store the history for the Objects (overwrites the history in the session)
BRepTest_Objects::AddHistory(Tools, aCut);   // Add the history for the Tools

To get the stored history in draw the command "savehistory" should be used. It saves the history kept in session into a Drawable object with the given name:

# perform cut
bcut r s1 s2

# save history of cut
savehistory cut_history

explode s1 f
modified m cut_history s1_1

The Draw History commands of the following algorithms have been removed:
- Boolean Operations;
- Defeaturing;
- Unify same domain;
- Sweep;
- Thrusections;

All these algorithms have been switched to support the new Draw history mechanism.

The Fillet and Blend algorithms have been also enabled to support history commands.
This commit is contained in:
emv
2018-03-21 16:59:29 +03:00
committed by bugmaster
parent a3d3777de9
commit 4f7d41eac3
94 changed files with 1892 additions and 1236 deletions

View File

@@ -154,7 +154,7 @@ const TopTools_ListOfShape& BOPAlgo_Builder::Modified
return myHistShapes;
const TopTools_ListOfShape* pLSp = myImagesResult.Seek(theS);
if (!pLSp)
if (!pLSp || pLSp->IsEmpty())
// No track in the result -> no modified
return myHistShapes;
@@ -189,9 +189,22 @@ const TopTools_ListOfShape& BOPAlgo_Builder::Modified
//=======================================================================
Standard_Boolean BOPAlgo_Builder::IsDeleted(const TopoDS_Shape& theS)
{
// 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);
// 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
@@ -218,23 +231,15 @@ void BOPAlgo_Builder::PrepareHistory()
BOPAlgo_BuilderShape::PrepareHistory();
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;
}
// 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.
// 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;
@@ -253,6 +258,9 @@ void BOPAlgo_Builder::PrepareHistory()
aType == TopAbs_SOLID))
continue;
// Track the modification of the shape
TopTools_ListOfShape* pImages = &myImagesResult(myImagesResult.Add(aS, TopTools_ListOfShape()));
// Check if the shape has any splits
const TopTools_ListOfShape* pLSp = LocModified(aS);
if (!pLSp)
@@ -260,7 +268,7 @@ void BOPAlgo_Builder::PrepareHistory()
// 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);
pImages->Append(aS);
else
// No trace of the shape in the result -> Deleted element is found
myHasDeleted = Standard_True;
@@ -268,7 +276,6 @@ void BOPAlgo_Builder::PrepareHistory()
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())
{
@@ -277,15 +284,12 @@ void BOPAlgo_Builder::PrepareHistory()
// 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);
pImages->Append(aSp);
}
}
if (pLSpKept)
if (!pImages->IsEmpty())
// Modified element is found
myHasModified = Standard_True;
else

View File

@@ -973,6 +973,7 @@ const TopTools_ListOfShape* BOPAlgo_CellsBuilder::LocModified(const TopoDS_Shape
}
else
{
TopTools_MapOfShape aMFence;
// Process all GF splits and check them for local unification with other shapes
TopTools_ListIteratorOfListOfShape aIt(*pLSp);
for (; aIt.More(); aIt.Next())
@@ -980,7 +981,8 @@ const TopTools_ListOfShape* BOPAlgo_CellsBuilder::LocModified(const TopoDS_Shape
const TopoDS_Shape* pSp = &aIt.Value();
const TopoDS_Shape* pSU = myMapModified.Seek(*pSp);
if (pSU) pSp = pSU;
myHistShapes.Append(*pSp);
if (aMFence.Add(*pSp))
myHistShapes.Append(*pSp);
}
}
return &myHistShapes;