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:
@@ -22,6 +22,7 @@
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepBuilderAPI.hxx>
|
||||
#include <BRepBuilderAPI_Transform.hxx>
|
||||
#include <BRepTest_Objects.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRepTools_ReShape.hxx>
|
||||
#include <DBRep.hxx>
|
||||
@@ -1360,65 +1361,12 @@ static Standard_Integer unifysamedom(Draw_Interpretor& di, Standard_Integer n, c
|
||||
Unifier().Build();
|
||||
TopoDS_Shape Result = Unifier().Shape();
|
||||
|
||||
BRepTest_Objects::SetHistory(Unifier().History());
|
||||
|
||||
DBRep::Set(a[1], Result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Standard_Integer unifysamedommod(Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n != 3) {
|
||||
di << "use unifysamedommod newshape oldshape\n";
|
||||
return 0;
|
||||
}
|
||||
TopoDS_Shape aShape;
|
||||
aShape = DBRep::Get(a[2]);
|
||||
if (aShape.IsNull()) {
|
||||
di << "Null shape is not allowed here\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
const TopTools_ListOfShape& aLS = Unifier().History()->Modified(aShape);
|
||||
|
||||
if (aLS.Extent() > 1) {
|
||||
BRep_Builder aBB;
|
||||
TopoDS_Compound aRes;
|
||||
aBB.MakeCompound(aRes);
|
||||
TopTools_ListIteratorOfListOfShape aIt(aLS);
|
||||
for (; aIt.More(); aIt.Next()) {
|
||||
const TopoDS_Shape& aCurrentShape = aIt.Value();
|
||||
aBB.Add(aRes, aCurrentShape);
|
||||
}
|
||||
DBRep::Set(a[1], aRes);
|
||||
}
|
||||
else if (aLS.Extent() == 1) {
|
||||
DBRep::Set(a[1], aLS.First());
|
||||
}
|
||||
else {
|
||||
di << "The shape has not been modified\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Standard_Integer unifysamedomisdel(Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
if (n < 2) {
|
||||
di << "Use: unifysamedomisdel shape\n";
|
||||
return 1;
|
||||
}
|
||||
TopoDS_Shape aShape = DBRep::Get(a[1]);
|
||||
if (aShape.IsNull()) {
|
||||
di << "Null shape is not allowed here\n";
|
||||
return 1;
|
||||
}
|
||||
Standard_Boolean IsDeleted = Unifier().History()->IsRemoved(aShape);
|
||||
di << "The shape has" << (IsDeleted ? " " : " not ") << "been deleted" << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer copytranslate(Draw_Interpretor& di,
|
||||
Standard_Integer argc,
|
||||
const char** argv)
|
||||
@@ -1634,15 +1582,6 @@ static Standard_Integer reshape(Draw_Interpretor& /*theDI*/,
|
||||
"unifysamedom result shape [s1 s2 ...] [-f] [-e] [-nosafe] [+b] [+i] [-t val] [-a val]",
|
||||
__FILE__,unifysamedom,g);
|
||||
|
||||
theCommands.Add("unifysamedommod",
|
||||
"unifysamedommod newshape oldshape : get new shape modified "
|
||||
"by unifysamedom command from the old one",
|
||||
__FILE__, unifysamedommod, g);
|
||||
|
||||
theCommands.Add("unifysamedomisdel",
|
||||
"unifysamedomisdel shape : shape is deleted ",
|
||||
__FILE__, unifysamedomisdel, g);
|
||||
|
||||
theCommands.Add ("copytranslate","result shape dx dy dz",__FILE__,copytranslate,g);
|
||||
|
||||
theCommands.Add ("reshape",
|
||||
|
Reference in New Issue
Block a user