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

@@ -53,7 +53,6 @@ void BOPTest::AllCommands(Draw_Interpretor& theCommands)
BOPTest::PartitionCommands (theCommands);
BOPTest::APICommands (theCommands);
BOPTest::OptionCommands (theCommands);
BOPTest::HistoryCommands (theCommands);
BOPTest::DebugCommands (theCommands);
BOPTest::CellsCommands (theCommands);
BOPTest::UtilityCommands (theCommands);

View File

@@ -52,8 +52,6 @@ public:
Standard_EXPORT static void Factory (Draw_Interpretor& aDI);
Standard_EXPORT static void HistoryCommands (Draw_Interpretor& aDI);
Standard_EXPORT static void DebugCommands (Draw_Interpretor& aDI);
Standard_EXPORT static void CellsCommands (Draw_Interpretor& aDI);

View File

@@ -23,6 +23,7 @@
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepAlgoAPI_Section.hxx>
#include <BRepAlgoAPI_Splitter.hxx>
#include <BRepTest_Objects.hxx>
#include <DBRep.hxx>
#include <Draw.hxx>
#include <TopoDS_Shape.hxx>
@@ -129,7 +130,12 @@ Standard_Integer bapibop(Draw_Interpretor& di,
pBuilder->SetUseOBB(BOPTest_Objects::UseOBB());
//
pBuilder->Build();
//
// Store the history for the Objects (overwrites the history in the session)
BRepTest_Objects::SetHistory(BOPTest_Objects::Shapes(), *pBuilder);
// Add the history for the Tools
BRepTest_Objects::AddHistory(BOPTest_Objects::Tools(), *pBuilder);
if (pBuilder->HasWarnings()) {
Standard_SStream aSStream;
pBuilder->DumpWarnings(aSStream);
@@ -188,7 +194,12 @@ Standard_Integer bapibuild(Draw_Interpretor& di,
aBuilder.SetUseOBB(BOPTest_Objects::UseOBB());
//
aBuilder.Build();
//
// Store the history for the Objects (overwrites the history in the session)
BRepTest_Objects::SetHistory(BOPTest_Objects::Shapes(), aBuilder);
// Add the history for the Tools
BRepTest_Objects::AddHistory(BOPTest_Objects::Tools(), aBuilder);
if (aBuilder.HasWarnings()) {
Standard_SStream aSStream;
aBuilder.DumpWarnings(aSStream);
@@ -240,6 +251,12 @@ Standard_Integer bapisplit(Draw_Interpretor& di,
//
// performing operation
aSplitter.Build();
// Store the history for the Objects (overwrites the history in the session)
BRepTest_Objects::SetHistory(BOPTest_Objects::Shapes(), aSplitter);
// Add the history for the Tools
BRepTest_Objects::AddHistory(BOPTest_Objects::Tools(), aSplitter);
// check warning status
if (aSplitter.HasWarnings()) {
Standard_SStream aSStream;

View File

@@ -28,6 +28,7 @@
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepAlgoAPI_Section.hxx>
#include <BRepTest_Objects.hxx>
#include <DBRep.hxx>
#include <Draw.hxx>
#include <DrawTrSurf.hxx>
@@ -258,6 +259,10 @@ Standard_Integer bopsmt(Draw_Interpretor& di,
//
aBOP.PerformWithFiller(*pPF);
BOPTest::ReportAlerts(aBOP.GetReport());
// Store the history of Boolean operation into the session
BRepTest_Objects::SetHistory(pPF->Arguments(), aBOP);
if (aBOP.HasErrors()) {
return 0;
}
@@ -319,6 +324,10 @@ Standard_Integer bopsection(Draw_Interpretor& di,
//
aBOP.PerformWithFiller(*pPF);
BOPTest::ReportAlerts(aBOP.GetReport());
// Store the history of Section operation into the session
BRepTest_Objects::SetHistory(pPF->Arguments(), aBOP);
if (aBOP.HasErrors()) {
return 0;
}
@@ -434,6 +443,10 @@ Standard_Integer bsection(Draw_Interpretor& di,
aSec.SetUseOBB(BOPTest_Objects::UseOBB());
//
aSec.Build();
// Store the history of Section operation into the session
BRepTest_Objects::SetHistory(aSec.DSFiller()->Arguments(), aSec);
//
if (aSec.HasWarnings()) {
Standard_SStream aSStream;
@@ -520,6 +533,10 @@ Standard_Integer bsmt (Draw_Interpretor& di,
//
aBOP.PerformWithFiller(aPF);
BOPTest::ReportAlerts(aBOP.GetReport());
// Store the history of Boolean operation into the session
BRepTest_Objects::SetHistory(aPF.Arguments(), aBOP);
if (aBOP.HasErrors()) {
return 0;
}
@@ -828,6 +845,10 @@ Standard_Integer mkvolume(Draw_Interpretor& di, Standard_Integer n, const char**
//
aMV.Perform();
BOPTest::ReportAlerts(aMV.GetReport());
// Store the history of Volume Maker into the session
BRepTest_Objects::SetHistory(aLS, aMV);
if (aMV.HasErrors()) {
return 0;
}

View File

@@ -23,6 +23,7 @@
#include <BOPAlgo_PaveFiller.hxx>
#include <BOPAlgo_CellsBuilder.hxx>
#include <BRepTest_Objects.hxx>
static Standard_Integer bcbuild (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bcaddall (Draw_Interpretor&, Standard_Integer, const char**);
@@ -116,6 +117,10 @@ Standard_Integer bcbuild(Draw_Interpretor& di,
//
aCBuilder.PerformWithFiller(aPF);
BOPTest::ReportAlerts(aCBuilder.GetReport());
// Store the history of the Cells Builder into the session
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
if (aCBuilder.HasErrors()) {
return 0;
}
@@ -165,7 +170,10 @@ Standard_Integer bcaddall(Draw_Interpretor& di,
BOPTest::ReportAlerts(aCBuilder.GetReport());
//
const TopoDS_Shape& aR = aCBuilder.Shape();
//
// Update the history of the Cells Builder
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
DBRep::Set(a[1], aR);
return 0;
}
@@ -186,7 +194,10 @@ Standard_Integer bcremoveall(Draw_Interpretor& di,
BOPAlgo_CellsBuilder& aCBuilder = BOPTest_Objects::CellsBuilder();
//
aCBuilder.RemoveAllFromResult();
//
// Update the history of the Cells Builder
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
return 0;
}
@@ -249,7 +260,10 @@ Standard_Integer bcadd(Draw_Interpretor& di,
BOPTest::ReportAlerts(aCBuilder.GetReport());
//
const TopoDS_Shape& aR = aCBuilder.Shape();
//
// Update the history of the Cells Builder
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
DBRep::Set(a[1], aR);
return 0;
}
@@ -295,7 +309,10 @@ Standard_Integer bcremove(Draw_Interpretor& di,
aCBuilder.RemoveFromResult(aLSToTake, aLSToAvoid);
//
const TopoDS_Shape& aR = aCBuilder.Shape();
//
// Update the history of the Cells Builder
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
DBRep::Set(a[1], aR);
return 0;
}
@@ -320,7 +337,10 @@ Standard_Integer bcremoveint(Draw_Interpretor& di,
BOPTest::ReportAlerts(aCBuilder.GetReport());
//
const TopoDS_Shape& aR = aCBuilder.Shape();
//
// Update the history of the Cells Builder
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
DBRep::Set(a[1], aR);
return 0;
}

View File

@@ -1,184 +0,0 @@
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2015 OPEN CASCADE SAS
//
// 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 <BOPTest.hxx>
//
#include <Draw.hxx>
#include <DBRep.hxx>
//
#include <BRep_Builder.hxx>
//
#include <TopoDS_Compound.hxx>
//
#include <BOPAlgo_Builder.hxx>
//
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
//
#include <BOPTest_DrawableShape.hxx>
#include <BOPTest_Objects.hxx>
//
static Standard_Integer bmodified (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bgenerated (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bisdeleted (Draw_Interpretor&, Standard_Integer, const char**);
//=======================================================================
//function : HistoryCommands
//purpose :
//=======================================================================
void BOPTest::HistoryCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
// Chapter's name
const char* g = "BOPTest commands";
// Commands
theCommands.Add("bmodified" , "Use: bmodified rc shape", __FILE__, bmodified , g);
theCommands.Add("bgenerated", "Use: bgenerated rc shape", __FILE__, bgenerated, g);
theCommands.Add("bisdeleted", "Use: bisdeleted shape" , __FILE__, bisdeleted, g);
}
//=======================================================================
//function : bmodified
//purpose :
//=======================================================================
Standard_Integer bmodified(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n < 3) {
di << "Use: bmodified rc shape\n";
return 1;
}
//
TopoDS_Shape aS = DBRep::Get(a[2]);
if (aS.IsNull()) {
di << "Null shape\n";
return 1;
}
//
TopAbs_ShapeEnum aType = aS.ShapeType();
if (!(aType==TopAbs_VERTEX || aType==TopAbs_EDGE ||
aType==TopAbs_FACE || aType==TopAbs_SOLID)) {
di << "The shape must be one of the following types: VERTEX, EDGE, FACE or SOLID\n";
return 1;
}
//
BOPAlgo_Builder& aBuilder = BOPTest_Objects::Builder();
const TopTools_ListOfShape& aLS = aBuilder.Modified(aS);
//
if (aLS.IsEmpty()) {
di << "The shape has not been modified\n";
return 0;
}
//
BRep_Builder aBB;
TopoDS_Compound aRes;
//
aBB.MakeCompound(aRes);
TopTools_ListIteratorOfListOfShape aIt(aLS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aShape = aIt.Value();
aBB.Add(aRes, aShape);
}
//
DBRep::Set(a[1], aRes);
//
return 0;
}
//=======================================================================
//function : bgenerated
//purpose :
//=======================================================================
Standard_Integer bgenerated(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n < 3) {
di << "Use: bgenerated rc shape\n";
return 1;
}
//
TopoDS_Shape aS = DBRep::Get(a[2]);
if (aS.IsNull()) {
di << "Null shape\n";
return 1;
}
//
TopAbs_ShapeEnum aType = aS.ShapeType();
if (!(aType==TopAbs_VERTEX || aType==TopAbs_EDGE ||
aType==TopAbs_FACE || aType==TopAbs_SOLID)) {
di << "The shape must be one of the following types: VERTEX, EDGE, FACE or SOLID\n";
return 1;
}
//
BOPAlgo_Builder& aBuilder = BOPTest_Objects::Builder();
const TopTools_ListOfShape& aLS = aBuilder.Generated(aS);
//
if (aLS.IsEmpty()) {
di << "No shapes were generated from the shape\n";
return 0;
}
//
BRep_Builder aBB;
TopoDS_Compound aRes;
//
aBB.MakeCompound(aRes);
TopTools_ListIteratorOfListOfShape aIt(aLS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aShape = aIt.Value();
aBB.Add(aRes, aShape);
}
//
DBRep::Set(a[1], aRes);
//
return 0;
}
//=======================================================================
//function : bisdeleted
//purpose :
//=======================================================================
Standard_Integer bisdeleted(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n < 2) {
di << "Use: bisdeleted shape\n";
return 1;
}
//
TopoDS_Shape aS = DBRep::Get(a[1]);
if (aS.IsNull()) {
di << "Null shape\n";
return 1;
}
//
TopAbs_ShapeEnum aType = aS.ShapeType();
if (!(aType==TopAbs_VERTEX || aType==TopAbs_EDGE ||
aType==TopAbs_FACE || aType==TopAbs_SOLID)) {
di << "The shape must be one of the following types: VERTEX, EDGE, FACE or SOLID\n";
return 1;
}
//
BOPAlgo_Builder& aBuilder = BOPTest_Objects::Builder();
Standard_Boolean isDeleted = aBuilder.IsDeleted(aS);
//
di << (isDeleted ? "Deleted" : "Not deleted") << "\n";
//
return 0;
}

View File

@@ -22,6 +22,7 @@
#include <BOPTest.hxx>
#include <BOPTest_DrawableShape.hxx>
#include <BOPTest_Objects.hxx>
#include <BRepTest_Objects.hxx>
#include <DBRep.hxx>
#include <Draw.hxx>
#include <Draw_Color.hxx>
@@ -197,6 +198,10 @@ Standard_Integer bbuild(Draw_Interpretor& di,
//
aBuilder.PerformWithFiller(aPF);
BOPTest::ReportAlerts(aBuilder.GetReport());
// Set history of GF operation into the session
BRepTest_Objects::SetHistory(aPF.Arguments(), aBuilder);
if (aBuilder.HasErrors()) {
return 0;
}
@@ -307,6 +312,10 @@ Standard_Integer bbop(Draw_Interpretor& di,
//
pBuilder->PerformWithFiller(aPF);
BOPTest::ReportAlerts(pBuilder->GetReport());
// Set history of Boolean operation into the session
BRepTest_Objects::SetHistory(aPF.Arguments(), *pBuilder);
if (pBuilder->HasErrors()) {
return 0;
}
@@ -377,6 +386,10 @@ Standard_Integer bsplit(Draw_Interpretor& di,
//
aTimer.Stop();
BOPTest::ReportAlerts(pSplitter->GetReport());
// Set history of Split operation into the session
BRepTest_Objects::SetHistory(aPF.Arguments(), *pSplitter);
if (pSplitter->HasErrors()) {
return 0;
}
@@ -388,7 +401,7 @@ Standard_Integer bsplit(Draw_Interpretor& di,
di << buf;
}
//
// DRAW history support
// Debug commands support
BOPTest_Objects::SetBuilder(pSplitter);
//
const TopoDS_Shape& aR = pSplitter->Shape();

View File

@@ -21,6 +21,8 @@
#include <BRepAlgoAPI_Defeaturing.hxx>
#include <BRepTest_Objects.hxx>
#include <DBRep.hxx>
#include <Draw.hxx>
@@ -28,15 +30,6 @@
#include <TopoDS_Compound.hxx>
static Standard_Integer RemoveFeatures (Draw_Interpretor&, Standard_Integer, const char**);
// History commands
static Standard_Integer rfModified (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer rfGenerated (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer rfIsDeleted (Draw_Interpretor&, Standard_Integer, const char**);
namespace
{
static BRepAlgoAPI_Defeaturing TheDefeaturingTool;
}
//=======================================================================
//function : RemoveFeaturesCommands
@@ -58,16 +51,6 @@ void BOPTest::RemoveFeaturesCommands(Draw_Interpretor& theCommands)
"\t\tnohist - disables the history collection;\n"
"\t\tparallel - enables the parallel processing mode.",
__FILE__, RemoveFeatures, group);
theCommands.Add("rfmodified", "rfmodified c_modified shape\n"
"\t\tShows the shapes <c_modified> modified from the shape <shape> during Defeaturing.",
__FILE__, rfModified, group);
theCommands.Add("rfgenerated", "rfgenerated c_generated shape\n"
"\t\tShows the shapes <c_generated> generated from the shape <shape> during Defeaturing.",
__FILE__, rfGenerated, group);
theCommands.Add("rfisdeleted", "rfisdeleted shape\n"
"\t\tChecks if the shape has been deleted during Defeaturing.",
__FILE__, rfIsDeleted, group);
}
//=======================================================================
@@ -127,143 +110,14 @@ Standard_Integer RemoveFeatures(Draw_Interpretor& theDI,
// Check for the errors/warnings
BOPTest::ReportAlerts(aRF.GetReport());
if (aRF.HasHistory())
BRepTest_Objects::SetHistory(aRF.GetHistory());
if (aRF.HasErrors())
return 0;
const TopoDS_Shape& aResult = aRF.Shape();
DBRep::Set(theArgv[1], aResult);
TheDefeaturingTool = aRF;
return 0;
}
//=======================================================================
//function : CheckHistory
//purpose : Checks if the history available for the shape
//=======================================================================
Standard_Boolean IsHistoryAvailable(const TopoDS_Shape& theS,
Draw_Interpretor& theDI)
{
if (theS.IsNull())
{
theDI << "Null shape.\n";
return Standard_False;
}
if (!BRepTools_History::IsSupportedType(theS))
{
theDI << "The history is not supported for this kind of shape.\n";
return Standard_False;
}
if (!TheDefeaturingTool.HasHistory())
{
theDI << "The history has not been prepared.\n";
return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : rfModified
//purpose :
//=======================================================================
Standard_Integer rfModified(Draw_Interpretor& theDI,
Standard_Integer theArgc,
const char ** theArgv)
{
if (theArgc != 3)
{
theDI.PrintHelp(theArgv[0]);
return 1;
}
const TopoDS_Shape& aS = DBRep::Get(theArgv[2]);
if (!IsHistoryAvailable(aS, theDI))
return 0;
const TopTools_ListOfShape& aLSIm = TheDefeaturingTool.Modified(aS);
if (aLSIm.IsEmpty())
{
theDI << "The shape has not been modified.\n";
return 0;
}
TopoDS_Shape aCModified;
if (aLSIm.Extent() == 1)
aCModified = aLSIm.First();
else
{
BRep_Builder().MakeCompound(TopoDS::Compound(aCModified));
TopTools_ListIteratorOfListOfShape itLS(aLSIm);
for (; itLS.More(); itLS.Next())
BRep_Builder().Add(aCModified, itLS.Value());
}
DBRep::Set(theArgv[1], aCModified);
return 0;
}
//=======================================================================
//function : rfGenerated
//purpose :
//=======================================================================
Standard_Integer rfGenerated(Draw_Interpretor& theDI,
Standard_Integer theArgc,
const char ** theArgv)
{
if (theArgc != 3)
{
theDI.PrintHelp(theArgv[0]);
return 1;
}
const TopoDS_Shape& aS = DBRep::Get(theArgv[2]);
if (!IsHistoryAvailable(aS, theDI))
return 0;
const TopTools_ListOfShape& aLSGen = TheDefeaturingTool.Generated(aS);
if (aLSGen.IsEmpty())
{
theDI << "No shapes were generated from the shape.\n";
return 0;
}
TopoDS_Shape aCGenerated;
if (aLSGen.Extent() == 1)
aCGenerated = aLSGen.First();
else
{
BRep_Builder().MakeCompound(TopoDS::Compound(aCGenerated));
TopTools_ListIteratorOfListOfShape itLS(aLSGen);
for (; itLS.More(); itLS.Next())
BRep_Builder().Add(aCGenerated, itLS.Value());
}
DBRep::Set(theArgv[1], aCGenerated);
return 0;
}
//=======================================================================
//function : rfIsDeleted
//purpose :
//=======================================================================
Standard_Integer rfIsDeleted(Draw_Interpretor& theDI,
Standard_Integer theArgc,
const char ** theArgv)
{
if (theArgc != 2)
{
theDI.PrintHelp(theArgv[0]);
return 1;
}
const TopoDS_Shape& aS = DBRep::Get(theArgv[1]);
if (!IsHistoryAvailable(aS, theDI))
return 0;
theDI << (TheDefeaturingTool.IsDeleted(aS) ? "Deleted" : "Not deleted") << "\n";
return 0;
}

View File

@@ -12,7 +12,6 @@ BOPTest_Objects.hxx
BOPTest_OptionCommands.cxx
BOPTest_PartitionCommands.cxx
BOPTest_TolerCommands.cxx
BOPTest_HistoryCommands.cxx
BOPTest_DebugCommands.cxx
BOPTest_CellsCommands.cxx
BOPTest_RemoveFeaturesCommands.cxx