1
0
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:
emv
2018-04-26 14:35:35 +03:00
committed by bugmaster
parent 894dba72a3
commit 948fe6ca88
58 changed files with 2139 additions and 1783 deletions

View File

@@ -128,13 +128,16 @@ Standard_Integer bapibop(Draw_Interpretor& di,
pBuilder->SetGlue(aGlue);
pBuilder->SetCheckInverted(BOPTest_Objects::CheckInverted());
pBuilder->SetUseOBB(BOPTest_Objects::UseOBB());
pBuilder->SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
//
pBuilder->Build();
pBuilder->Build();
pBuilder->SimplifyResult(BOPTest_Objects::UnifyEdges(),
BOPTest_Objects::UnifyFaces(),
BOPTest_Objects::Angular());
// 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);
// Store the history of operation into the session
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(pBuilder->History());
if (pBuilder->HasWarnings()) {
Standard_SStream aSStream;
@@ -192,13 +195,16 @@ Standard_Integer bapibuild(Draw_Interpretor& di,
aBuilder.SetGlue(aGlue);
aBuilder.SetCheckInverted(BOPTest_Objects::CheckInverted());
aBuilder.SetUseOBB(BOPTest_Objects::UseOBB());
aBuilder.SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
//
aBuilder.Build();
aBuilder.Build();
aBuilder.SimplifyResult(BOPTest_Objects::UnifyEdges(),
BOPTest_Objects::UnifyFaces(),
BOPTest_Objects::Angular());
// 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);
// Store the history of operation into the session
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aBuilder.History());
if (aBuilder.HasWarnings()) {
Standard_SStream aSStream;
@@ -248,14 +254,17 @@ Standard_Integer bapisplit(Draw_Interpretor& di,
aSplitter.SetGlue(BOPTest_Objects::Glue());
aSplitter.SetCheckInverted(BOPTest_Objects::CheckInverted());
aSplitter.SetUseOBB(BOPTest_Objects::UseOBB());
aSplitter.SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
//
// performing operation
aSplitter.Build();
aSplitter.SimplifyResult(BOPTest_Objects::UnifyEdges(),
BOPTest_Objects::UnifyFaces(),
BOPTest_Objects::Angular());
// 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);
// Store the history of operation into the session
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aSplitter.History());
// check warning status
if (aSplitter.HasWarnings()) {

View File

@@ -256,12 +256,14 @@ Standard_Integer bopsmt(Draw_Interpretor& di,
aBOP.SetOperation(aOp);
aBOP.SetRunParallel (bRunParallel);
aBOP.SetCheckInverted(BOPTest_Objects::CheckInverted());
aBOP.SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
//
aBOP.PerformWithFiller(*pPF);
BOPTest::ReportAlerts(aBOP.GetReport());
// Store the history of Boolean operation into the session
BRepTest_Objects::SetHistory(pPF->Arguments(), aBOP);
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aBOP.History());
if (aBOP.HasErrors()) {
return 0;
@@ -321,12 +323,14 @@ Standard_Integer bopsection(Draw_Interpretor& di,
aBOP.AddArgument(aS2);
aBOP.SetRunParallel (bRunParallel);
aBOP.SetCheckInverted(BOPTest_Objects::CheckInverted());
aBOP.SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
//
aBOP.PerformWithFiller(*pPF);
BOPTest::ReportAlerts(aBOP.GetReport());
// Store the history of Section operation into the session
BRepTest_Objects::SetHistory(pPF->Arguments(), aBOP);
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aBOP.History());
if (aBOP.HasErrors()) {
return 0;
@@ -445,7 +449,8 @@ Standard_Integer bsection(Draw_Interpretor& di,
aSec.Build();
// Store the history of Section operation into the session
BRepTest_Objects::SetHistory(aSec.DSFiller()->Arguments(), aSec);
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aSec.History());
//
if (aSec.HasWarnings()) {
@@ -530,12 +535,14 @@ Standard_Integer bsmt (Draw_Interpretor& di,
aBOP.SetOperation(aOp);
aBOP.SetRunParallel(bRunParallel);
aBOP.SetCheckInverted(BOPTest_Objects::CheckInverted());
//
aBOP.SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
//
aBOP.PerformWithFiller(aPF);
BOPTest::ReportAlerts(aBOP.GetReport());
// Store the history of Boolean operation into the session
BRepTest_Objects::SetHistory(aPF.Arguments(), aBOP);
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aPF.Arguments(), aBOP);
if (aBOP.HasErrors()) {
return 0;
@@ -842,12 +849,14 @@ Standard_Integer mkvolume(Draw_Interpretor& di, Standard_Integer n, const char**
aMV.SetAvoidInternalShapes(bAvoidInternal);
aMV.SetGlue(aGlue);
aMV.SetUseOBB(BOPTest_Objects::UseOBB());
aMV.SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
//
aMV.Perform();
BOPTest::ReportAlerts(aMV.GetReport());
// Store the history of Volume Maker into the session
BRepTest_Objects::SetHistory(aLS, aMV);
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aLS, aMV);
if (aMV.HasErrors()) {
return 0;

View File

@@ -114,12 +114,14 @@ Standard_Integer bcbuild(Draw_Interpretor& di,
aCBuilder.SetGlue(aGlue);
aCBuilder.SetCheckInverted(BOPTest_Objects::CheckInverted());
aCBuilder.SetUseOBB(BOPTest_Objects::UseOBB());
aCBuilder.SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
//
aCBuilder.PerformWithFiller(aPF);
BOPTest::ReportAlerts(aCBuilder.GetReport());
// Store the history of the Cells Builder into the session
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
if (aCBuilder.HasErrors()) {
return 0;
@@ -172,7 +174,8 @@ Standard_Integer bcaddall(Draw_Interpretor& di,
const TopoDS_Shape& aR = aCBuilder.Shape();
// Update the history of the Cells Builder
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
DBRep::Set(a[1], aR);
return 0;
@@ -196,7 +199,8 @@ Standard_Integer bcremoveall(Draw_Interpretor& di,
aCBuilder.RemoveAllFromResult();
// Update the history of the Cells Builder
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
return 0;
}
@@ -262,7 +266,8 @@ Standard_Integer bcadd(Draw_Interpretor& di,
const TopoDS_Shape& aR = aCBuilder.Shape();
// Update the history of the Cells Builder
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
DBRep::Set(a[1], aR);
return 0;
@@ -311,7 +316,8 @@ Standard_Integer bcremove(Draw_Interpretor& di,
const TopoDS_Shape& aR = aCBuilder.Shape();
// Update the history of the Cells Builder
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
DBRep::Set(a[1], aR);
return 0;
@@ -339,7 +345,8 @@ Standard_Integer bcremoveint(Draw_Interpretor& di,
const TopoDS_Shape& aR = aCBuilder.Shape();
// Update the history of the Cells Builder
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aCBuilder.Arguments(), aCBuilder);
DBRep::Set(a[1], aR);
return 0;

View File

@@ -51,13 +51,7 @@ class BOPTest_Session {
myBuilderDefault=new BOPAlgo_Builder(pA2);
//
myBuilder=myBuilderDefault;
myRunParallel=Standard_False;
myNonDestructive = Standard_False;
myFuzzyValue = Precision::Confusion();
myGlue = BOPAlgo_GlueOff;
myDrawWarnShapes = Standard_False;
myCheckInverted = Standard_True;
myUseOBB = Standard_False;
SetDefaultOptions();
};
//
// Clear
@@ -104,6 +98,20 @@ class BOPTest_Session {
TopTools_ListOfShape& Tools() {
return myTools;
}
// Resets all options to default values
void SetDefaultOptions()
{
myRunParallel = Standard_False;
myNonDestructive = Standard_False;
myFuzzyValue = Precision::Confusion();
myGlue = BOPAlgo_GlueOff;
myDrawWarnShapes = Standard_False;
myCheckInverted = Standard_True;
myUseOBB = Standard_False;
myUnifyEdges = Standard_False;
myUnifyFaces = Standard_False;
myAngTol = Precision::Angular();
}
//
void SetRunParallel(const Standard_Boolean bFlag) {
myRunParallel=bFlag;
@@ -160,6 +168,22 @@ class BOPTest_Session {
Standard_Boolean UseOBB() const {
return myUseOBB;
};
// Controls the Unification of Edges after BOP
void SetUnifyEdges(const Standard_Boolean bUE) { myUnifyEdges = bUE; }
// Returns flag of Edges unification
Standard_Boolean UnifyEdges() const { return myUnifyEdges; }
// Controls the Unification of Faces after BOP
void SetUnifyFaces(const Standard_Boolean bUF) { myUnifyFaces = bUF; }
// Returns flag of Faces unification
Standard_Boolean UnifyFaces() const { return myUnifyFaces; }
// Sets angular tolerance for Edges and Faces unification
void SetAngular(const Standard_Real theAngTol) { myAngTol = theAngTol; }
// Returns angular tolerance
Standard_Real Angular() const { return myAngTol; }
protected:
//
BOPTest_Session(const BOPTest_Session&);
@@ -180,6 +204,9 @@ protected:
Standard_Boolean myDrawWarnShapes;
Standard_Boolean myCheckInverted;
Standard_Boolean myUseOBB;
Standard_Boolean myUnifyEdges;
Standard_Boolean myUnifyFaces;
Standard_Real myAngTol;
};
//
//=======================================================================
@@ -310,6 +337,14 @@ TopTools_ListOfShape& BOPTest_Objects::Tools()
return GetSession().Tools();
}
//=======================================================================
//function : SetDefaultOptions
//purpose :
//=======================================================================
void BOPTest_Objects::SetDefaultOptions()
{
GetSession().SetDefaultOptions();
}
//=======================================================================
//function : SetRunParallel
//purpose :
//=======================================================================
@@ -422,6 +457,54 @@ Standard_Boolean BOPTest_Objects::UseOBB()
return GetSession().UseOBB();
}
//=======================================================================
//function : SetUnifyEdges
//purpose :
//=======================================================================
void BOPTest_Objects::SetUnifyEdges(const Standard_Boolean bUE)
{
GetSession().SetUnifyEdges(bUE);
}
//=======================================================================
//function : UnifyEdges
//purpose :
//=======================================================================
Standard_Boolean BOPTest_Objects::UnifyEdges()
{
return GetSession().UnifyEdges();
}
//=======================================================================
//function : SetUnifyFaces
//purpose :
//=======================================================================
void BOPTest_Objects::SetUnifyFaces(const Standard_Boolean bUF)
{
GetSession().SetUnifyFaces(bUF);
}
//=======================================================================
//function : UnifyFaces
//purpose :
//=======================================================================
Standard_Boolean BOPTest_Objects::UnifyFaces()
{
return GetSession().UnifyFaces();
}
//=======================================================================
//function : SetAngular
//purpose :
//=======================================================================
void BOPTest_Objects::SetAngular(const Standard_Real theAngTol)
{
GetSession().SetAngular(theAngTol);
}
//=======================================================================
//function : Angular
//purpose :
//=======================================================================
Standard_Real BOPTest_Objects::Angular()
{
return GetSession().Angular();
}
//=======================================================================
//function : Allocator1
//purpose :
//=======================================================================

View File

@@ -66,7 +66,9 @@ public:
Standard_EXPORT static void SetBuilder (const BOPAlgo_PBuilder& theBuilder);
Standard_EXPORT static void SetBuilderDefault();
Standard_EXPORT static void SetDefaultOptions();
Standard_EXPORT static void SetRunParallel (const Standard_Boolean theFlag);
Standard_EXPORT static Standard_Boolean RunParallel();
@@ -95,6 +97,15 @@ public:
Standard_EXPORT static Standard_Boolean UseOBB();
Standard_EXPORT static void SetUnifyEdges(const Standard_Boolean bUE);
Standard_EXPORT static Standard_Boolean UnifyEdges();
Standard_EXPORT static void SetUnifyFaces(const Standard_Boolean bUF);
Standard_EXPORT static Standard_Boolean UnifyFaces();
Standard_EXPORT static void SetAngular(const Standard_Real bAngTol);
Standard_EXPORT static Standard_Real Angular();
protected:
private:

View File

@@ -29,6 +29,7 @@ static Standard_Integer bGlue(Draw_Interpretor&, Standard_Integer, const char**)
static Standard_Integer bdrawwarnshapes(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bcheckinverted(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer buseobb(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bsimplify(Draw_Interpretor&, Standard_Integer, const char**);
//=======================================================================
//function : OptionCommands
@@ -42,18 +43,45 @@ void BOPTest::OptionCommands(Draw_Interpretor& theCommands)
// Chapter's name
const char* g = "BOPTest commands";
// Commands
theCommands.Add("boptions", "use boptions, shows current value of BOP options" , __FILE__, boptions, g);
theCommands.Add("brunparallel", "use brunparallel [0/1]" , __FILE__, brunparallel, g);
theCommands.Add("bnondestructive", "use bnondestructive [0/1]", __FILE__, bnondestructive, g);
theCommands.Add("bfuzzyvalue", "use bfuzzyvalue value", __FILE__, bfuzzyvalue, g);
theCommands.Add("bglue", "use bglue [0 (off) / 1 (shift) / 2 (full)]", __FILE__, bGlue, g);
theCommands.Add("bdrawwarnshapes", "Defines whether to draw warning shapes or not\n"
"Usage: bdrawwarnshapes [0 (do not draw) / 1 (draw warning shapes)",
theCommands.Add("boptions", "Usage: boptions [-default]\n"
"\t\tw/o arguments shows current value of BOP options\n"
"\t\t-default - allows setting all options to default values",
__FILE__, boptions, g);
theCommands.Add("brunparallel", "Enables/Disables parallel processing mode.\n"
"\t\tUsage: brunparallel 0/1",
__FILE__, brunparallel, g);
theCommands.Add("bnondestructive", "Enables/Disables the safe processing mode.\n"
"\t\tUsage: bnondestructive 0/1",
__FILE__, bnondestructive, g);
theCommands.Add("bfuzzyvalue", "Sets the additional tolerance for BOP algorithms.\n"
"\t\tUsage: bfuzzyvalue value",
__FILE__, bfuzzyvalue, g);
theCommands.Add("bglue", "Sets the gluing mode for the BOP algorithms.\n"
"\t\tUsage: bglue [0 (off) / 1 (shift) / 2 (full)]",
__FILE__, bGlue, g);
theCommands.Add("bdrawwarnshapes", "Enables/Disables drawing of waring shapes of BOP algorithms.\n"
"\t\tUsage: bdrawwarnshapes 0 (do not draw) / 1 (draw warning shapes)",
__FILE__, bdrawwarnshapes, g);
theCommands.Add("bcheckinverted", "Defines whether to check the input solids on inverted status or not\n"
"Usage: bcheckinverted [0 (off) / 1 (on)]", __FILE__, bcheckinverted, g);
theCommands.Add("buseobb", "Enables/disables the usage of OBB\n"
"Usage: buseobb [0 (off) / 1 (on)]", __FILE__, buseobb, g);
theCommands.Add("bcheckinverted", "Enables/Disables the check of the input solids on inverted status in BOP algorithms\n"
"\t\tUsage: bcheckinverted 0 (off) / 1 (on)",
__FILE__, bcheckinverted, g);
theCommands.Add("buseobb", "Enables/disables the usage of OBB in BOP algorithms\n"
"\t\tUsage: buseobb 0 (off) / 1 (on)",
__FILE__, buseobb, g);
theCommands.Add("bsimplify", "Enables/Disables the result simplification after BOP\n"
"\t\tUsage: bsimplify [-e 0/1] [-f 0/1] [-a tol]\n"
"\t\t-e 0/1 - enables/disables edges unification\n"
"\t\t-f 0/1 - enables/disables faces unification\n"
"\t\t-a tol - changes default angular tolerance of unification algo (accepts value in degrees).",
__FILE__, bsimplify, g);
}
//=======================================================================
//function : boptions
@@ -61,40 +89,60 @@ void BOPTest::OptionCommands(Draw_Interpretor& theCommands)
//=======================================================================
Standard_Integer boptions(Draw_Interpretor& di,
Standard_Integer n,
const char** )
const char** a)
{
if (n!=1) {
di << " use boptions\n";
if (n > 2)
{
di.PrintHelp(a[0]);
return 1;
}
if (n == 2)
{
if (strcmp(a[1], "-default"))
{
di.PrintHelp(a[0]);
return 1;
}
// Set all options to default values
BOPTest_Objects::SetDefaultOptions();
return 0;
}
//
char buf[128];
Standard_Boolean bRunParallel, bNonDestructive;
Standard_Real aFuzzyValue;
BOPAlgo_GlueEnum aGlue;
BOPAlgo_GlueEnum aGlue = BOPTest_Objects::Glue();
//
bRunParallel=BOPTest_Objects::RunParallel();
bNonDestructive = BOPTest_Objects::NonDestructive();
aFuzzyValue = BOPTest_Objects::FuzzyValue();
aGlue = BOPTest_Objects::Glue();
Standard_Boolean bDrawWarnShapes = BOPTest_Objects::DrawWarnShapes();
Standard_Boolean bCheckInverted = BOPTest_Objects::CheckInverted();
Standard_Boolean bUseOBB = BOPTest_Objects::UseOBB();
//
Sprintf(buf, " RunParallel: %d\n", bRunParallel);
Sprintf(buf, " RunParallel: %s \t\t(%s)\n", BOPTest_Objects::RunParallel() ? "Yes" : "No",
"use \"brunparallel\" command to change");
di << buf;
Sprintf(buf, " NonDestructive: %d\n", bNonDestructive);
Sprintf(buf, " NonDestructive: %s \t\t(%s)\n", BOPTest_Objects::NonDestructive() ? "Yes" : "No",
"use \"bnondestructive\" command to change");
di << buf;
Sprintf(buf, " FuzzyValue: %lf\n", aFuzzyValue);
Sprintf(buf, " FuzzyValue: %g \t\t(%s)\n", BOPTest_Objects::FuzzyValue(),
"use \"bfuzzyvalue\" command to change");
di << buf;
Sprintf(buf, " GlueOption: %s\n", ((aGlue == BOPAlgo_GlueOff) ? "Off" :
((aGlue == BOPAlgo_GlueFull) ? "Full" : "Shift")));
Sprintf(buf, " GlueOption: %s \t\t(%s)\n", ((aGlue == BOPAlgo_GlueOff) ? "Off" :
((aGlue == BOPAlgo_GlueFull) ? "Full" : "Shift")),
"use \"bglue\" command to change");
di << buf;
Sprintf(buf, " Draw Warning Shapes: %s\n", bDrawWarnShapes ? "Yes" : "No");
Sprintf(buf, " Draw Warning Shapes: %s \t(%s)\n", BOPTest_Objects::DrawWarnShapes() ? "Yes" : "No",
"use \"bdrawwarnshapes\" command to change");
di << buf;
Sprintf(buf, " Check for inverted solids: %s\n", bCheckInverted ? "Yes" : "No");
Sprintf(buf, " Check for invert solids: %s \t(%s)\n", BOPTest_Objects::CheckInverted() ? "Yes" : "No",
"use \"bcheckinverted\" command to change");
di << buf;
Sprintf(buf, " Use OBB: %s\n", bUseOBB ? "Yes" : "No");
Sprintf(buf, " Use OBB: %s \t\t\t(%s)\n", BOPTest_Objects::UseOBB() ? "Yes" : "No",
"use \"buseobb\" command to change");
di << buf;
Sprintf(buf, " Unify Edges: %s \t\t(%s)\n", BOPTest_Objects::UnifyEdges() ? "Yes" : "No",
"use \"bsimplify -e\" command to change");
di << buf;
Sprintf(buf, " Unify Faces: %s \t\t(%s)\n", BOPTest_Objects::UnifyFaces() ? "Yes" : "No",
"use \"bsimplify -f\" command to change");
di << buf;
Sprintf(buf, " Angular: %g \t\t(%s)\n", BOPTest_Objects::Angular(),
"use \"bsimplify -a\" command to change");
di << buf;
//
return 0;
@@ -106,22 +154,15 @@ Standard_Integer boptions(Draw_Interpretor& di,
Standard_Integer bfuzzyvalue(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n!=2) {
di << " use bfuzzyvalue value\n";
return 0;
{
if (n != 2)
{
di.PrintHelp(a[0]);
return 1;
}
//
Standard_Real aFuzzyValue;
//
aFuzzyValue=Draw::Atof(a[1]);
if (aFuzzyValue<0.) {
di << " Wrong value.\n";
return 0;
}
//
Standard_Real aFuzzyValue = Draw::Atof(a[1]);
BOPTest_Objects::SetFuzzyValue(aFuzzyValue);
//
return 0;
}
//=======================================================================
@@ -129,26 +170,17 @@ Standard_Integer bfuzzyvalue(Draw_Interpretor& di,
//purpose :
//=======================================================================
Standard_Integer brunparallel(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n!=2) {
di << " use brunparallel [0/1]\n";
return 0;
Standard_Integer n,
const char** a)
{
if (n != 2)
{
di.PrintHelp(a[0]);
return 1;
}
//
Standard_Integer iX;
Standard_Boolean bRunParallel;
//
iX=Draw::Atoi(a[1]);
if (iX<0 || iX>1) {
di << " Wrong value.\n";
return 0;
}
//
bRunParallel = (iX != 0);
BOPTest_Objects::SetRunParallel(bRunParallel);
//
Standard_Integer iRunParallel = Draw::Atoi(a[1]);
BOPTest_Objects::SetRunParallel(iRunParallel != 0);
return 0;
}
//=======================================================================
@@ -156,26 +188,17 @@ Standard_Integer brunparallel(Draw_Interpretor& di,
//purpose :
//=======================================================================
Standard_Integer bnondestructive(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
Standard_Integer n,
const char** a)
{
if (n != 2) {
di << " use bnondestructive [0/1]\n";
return 0;
if (n != 2)
{
di.PrintHelp(a[0]);
return 1;
}
//
Standard_Integer iX;
Standard_Boolean bNonDestructive;
//
iX = Draw::Atoi(a[1]);
if (iX<0 || iX>1) {
di << " Wrong value.\n";
return 0;
}
//
bNonDestructive = (iX != 0);
BOPTest_Objects::SetNonDestructive(bNonDestructive);
//
Standard_Integer iNonDestructive = Draw::Atoi(a[1]);
BOPTest_Objects::SetNonDestructive(iNonDestructive != 0);
return 0;
}
@@ -184,23 +207,25 @@ Standard_Integer bnondestructive(Draw_Interpretor& di,
//purpose :
//=======================================================================
Standard_Integer bGlue(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
Standard_Integer n,
const char** a)
{
if (n != 2) {
di << " use bglue [0 (off) / 1 (shift) / 2 (full)]\n";
if (n != 2)
{
di.PrintHelp(a[0]);
return 1;
}
//
Standard_Integer iGlue = Draw::Atoi(a[1]);
if (iGlue < 0 || iGlue > 2) {
di << " Wrong value. Use bglue [0 (off) / 1 (shift) / 2 (full)]\n";
if (iGlue < 0 || iGlue > 2)
{
di << "Wrong value.\n";
di.PrintHelp(a[0]);
return 1;
}
//
BOPAlgo_GlueEnum aGlue = BOPAlgo_GlueEnum(iGlue);
BOPTest_Objects::SetGlue(aGlue);
//
return 0;
}
@@ -209,14 +234,15 @@ Standard_Integer bGlue(Draw_Interpretor& di,
//purpose :
//=======================================================================
Standard_Integer bdrawwarnshapes(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
Standard_Integer n,
const char** a)
{
if (n != 2) {
di << " use bdrawwarnshapes [0 (do not draw) / 1 (draw warning shapes)\n";
if (n != 2)
{
di.PrintHelp(a[0]);
return 1;
}
//
Standard_Integer iDraw = Draw::Atoi(a[1]);
BOPTest_Objects::SetDrawWarnShapes(iDraw != 0);
return 0;
@@ -230,11 +256,12 @@ Standard_Integer bcheckinverted(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n != 2) {
if (n != 2)
{
di.PrintHelp(a[0]);
return 1;
}
//
Standard_Integer iCheck = Draw::Atoi(a[1]);
BOPTest_Objects::SetCheckInverted(iCheck != 0);
return 0;
@@ -253,8 +280,49 @@ Standard_Integer buseobb(Draw_Interpretor& di,
di.PrintHelp(a[0]);
return 1;
}
//
Standard_Integer iUse = Draw::Atoi(a[1]);
BOPTest_Objects::SetUseOBB(iUse != 0);
return 0;
}
//=======================================================================
//function : bsimplify
//purpose :
//=======================================================================
Standard_Integer bsimplify(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n == 1 || n%2 == 0)
{
di.PrintHelp(a[0]);
return 1;
}
for (Standard_Integer i = 1; i < n - 1; ++i)
{
if (!strcmp(a[i], "-e"))
{
Standard_Integer iUnifyEdges = Draw::Atoi(a[++i]);
BOPTest_Objects::SetUnifyEdges(iUnifyEdges != 0);
}
else if (!strcmp(a[i], "-f"))
{
Standard_Integer iUnifyFaces = Draw::Atoi(a[++i]);
BOPTest_Objects::SetUnifyFaces(iUnifyFaces != 0);
}
else if (!strcmp(a[i], "-a"))
{
Standard_Real anAngTol = Draw::Atof(a[++i]) * (M_PI / 180.0);
BOPTest_Objects::SetAngular(anAngTol);
}
else
{
di << "Wrong key option.\n";
di.PrintHelp(a[0]);
return 1;
}
}
return 0;
}

View File

@@ -191,6 +191,7 @@ Standard_Integer bbuild(Draw_Interpretor& di,
}
aBuilder.SetRunParallel(bRunParallel);
aBuilder.SetCheckInverted(BOPTest_Objects::CheckInverted());
aBuilder.SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
//
//
OSD_Timer aTimer;
@@ -200,7 +201,8 @@ Standard_Integer bbuild(Draw_Interpretor& di,
BOPTest::ReportAlerts(aBuilder.GetReport());
// Set history of GF operation into the session
BRepTest_Objects::SetHistory(aPF.Arguments(), aBuilder);
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aPF.Arguments(), aBuilder);
if (aBuilder.HasErrors()) {
return 0;
@@ -306,6 +308,7 @@ Standard_Integer bbop(Draw_Interpretor& di,
//
pBuilder->SetRunParallel(bRunParallel);
pBuilder->SetCheckInverted(BOPTest_Objects::CheckInverted());
pBuilder->SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
//
OSD_Timer aTimer;
aTimer.Start();
@@ -314,7 +317,8 @@ Standard_Integer bbop(Draw_Interpretor& di,
BOPTest::ReportAlerts(pBuilder->GetReport());
// Set history of Boolean operation into the session
BRepTest_Objects::SetHistory(aPF.Arguments(), *pBuilder);
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aPF.Arguments(), *pBuilder);
if (pBuilder->HasErrors()) {
return 0;
@@ -376,6 +380,7 @@ Standard_Integer bsplit(Draw_Interpretor& di,
pSplitter->SetNonDestructive(BOPTest_Objects::NonDestructive());
pSplitter->SetFuzzyValue(BOPTest_Objects::FuzzyValue());
pSplitter->SetCheckInverted(BOPTest_Objects::CheckInverted());
pSplitter->SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
//
// measure the time of the operation
OSD_Timer aTimer;
@@ -388,7 +393,8 @@ Standard_Integer bsplit(Draw_Interpretor& di,
BOPTest::ReportAlerts(pSplitter->GetReport());
// Set history of Split operation into the session
BRepTest_Objects::SetHistory(aPF.Arguments(), *pSplitter);
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aPF.Arguments(), *pSplitter);
if (pSplitter->HasErrors()) {
return 0;

View File

@@ -43,12 +43,11 @@ void BOPTest::RemoveFeaturesCommands(Draw_Interpretor& theCommands)
// Chapter's name
const char* group = "BOPTest commands";
// Commands
theCommands.Add("removefeatures", "removefeatures result shape f1 f2 ... [-nohist] [-parallel]\n"
theCommands.Add("removefeatures", "removefeatures result shape f1 f2 ... [-parallel]\n"
"\t\tRemoves user-defined features (faces) from the shape.\n"
"\t\tresult - result of the operation;\n"
"\t\tshape - the shape to remove the features from;\n"
"\t\tf1, f2 - features to remove from the shape;\n"
"\t\tnohist - disables the history collection;\n"
"\t\tparallel - enables the parallel processing mode.",
__FILE__, RemoveFeatures, group);
}
@@ -84,13 +83,7 @@ Standard_Integer RemoveFeatures(Draw_Interpretor& theDI,
TopoDS_Shape aF = DBRep::Get(theArgv[i]);
if (aF.IsNull())
{
// Check for the options
if (!strcmp(theArgv[i], "-nohist"))
{
// disable the history collection
aRF.TrackHistory(Standard_False);
}
else if (!strcmp(theArgv[i], "-parallel"))
if (!strcmp(theArgv[i], "-parallel"))
{
// enable the parallel processing mode
aRF.SetRunParallel(Standard_True);
@@ -104,14 +97,16 @@ Standard_Integer RemoveFeatures(Draw_Interpretor& theDI,
aRF.AddFaceToRemove(aF);
}
aRF.SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
// Perform the removal
aRF.Build();
// Check for the errors/warnings
BOPTest::ReportAlerts(aRF.GetReport());
if (aRF.HasHistory())
BRepTest_Objects::SetHistory(aRF.GetHistory());
if (BRepTest_Objects::IsHistoryNeeded())
BRepTest_Objects::SetHistory(aRF.History());
if (aRF.HasErrors())
return 0;