}
}
}
+
+//=======================================================================
+//function : GetOperationType
+//purpose :
+//=======================================================================
+BOPAlgo_Operation BOPTest::GetOperationType(const Standard_CString theOp)
+{
+ TCollection_AsciiString anOp(theOp);
+ anOp.LowerCase();
+
+ if (anOp.IsIntegerValue())
+ {
+ // Check if the given value satisfies the enumeration.
+ Standard_Integer iOp = anOp.IntegerValue();
+ if (iOp >= 0 && iOp <= 4)
+ {
+ return static_cast<BOPAlgo_Operation>(iOp);
+ }
+ return BOPAlgo_UNKNOWN;
+ }
+
+ // Check for the meaningful symbolic operation parameter
+ if (anOp == "common")
+ {
+ return BOPAlgo_COMMON;
+ }
+ else if (anOp == "fuse")
+ {
+ return BOPAlgo_FUSE;
+ }
+ else if (anOp == "cut")
+ {
+ return BOPAlgo_CUT;
+ }
+ else if (anOp == "tuc" || anOp == "cut21")
+ {
+ return BOPAlgo_CUT21;
+ }
+ else if (anOp == "section")
+ {
+ return BOPAlgo_SECTION;
+ }
+
+ return BOPAlgo_UNKNOWN;
+}
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
+#include <BOPAlgo_Operation.hxx>
#include <Draw_Interpretor.hxx>
class BOPTest_Objects;
//! if flag BOPTest_Objects::DrawWarnShapes() is set
Standard_EXPORT static void ReportAlerts (const Handle(Message_Report)& theReport);
+ //! Returns operation type according to the given string.
+ //! For numeric values, the number correspond to the order in enum.
+ Standard_EXPORT static BOPAlgo_Operation GetOperationType(const Standard_CString theOp);
+
protected:
private:
// Chapter's name
const char* g = "BOPTest commands";
// Commands
- theCommands.Add("bapibuild", "use bapibuild r" , __FILE__, bapibuild, g);
- theCommands.Add("bapibop", "use bapibop r type" , __FILE__, bapibop, g);
- theCommands.Add("bapisplit", "use bapisplit r" , __FILE__, bapisplit, g);
+ theCommands.Add("bapibuild", "Builds the result of General Fuse operation using top level API.\n"
+ "\t\tObjects for the operation are added using commands baddobjects and baddtools.\n"
+ "\t\tUsage: bapibuild result",
+ __FILE__, bapibuild, g);
+
+ theCommands.Add("bapibop", "Builds the result of Boolean operation using top level API.\n"
+ "\t\tObjects for the operation are added using commands baddobjects and baddtools.\n"
+ "\t\tUsage: bapibop r operation\n"
+ "\t\tWhere:\n"
+ "\t\tresult - name of the result shape\n"
+ "\t\top - type of Boolean operation. Possible values:\n"
+ "\t\t - 0/common - for Common operation\n"
+ "\t\t - 1/fuse - for Fuse operation\n"
+ "\t\t - 2/cut - for Cut operation\n"
+ "\t\t - 3/tuc/cut21 - for Cut21 operation\n"
+ "\t\t - 4/section - for Section operation",
+ __FILE__, bapibop, g);
+
+ theCommands.Add("bapisplit", "Builds the result of Split operation using top level API.\n"
+ "\t\tObjects for the operation are added using commands baddobjects and baddtools.\n"
+ "\t\tUsage: bapisplit result",
+ __FILE__, bapisplit, g);
}
//=======================================================================
//function : bapibop
Standard_Integer n,
const char** a)
{
- if (n<3) {
- di << " use bapibop r type\n";
+ if (n != 3) {
+ di.PrintHelp(a[0]);
+ return 1;
+ }
+
+ BOPAlgo_Operation anOp = BOPTest::GetOperationType(a[2]);
+ if (anOp == BOPAlgo_UNKNOWN)
+ {
+ di << "Invalid operation type\n";
return 0;
}
//
Standard_Boolean bRunParallel, bNonDestructive;
- Standard_Integer iOp;
Standard_Real aFuzzyValue;
BRepAlgoAPI_Common aCommon;
BRepAlgoAPI_Fuse aFuse;
BRepAlgoAPI_Cut aCut;
BRepAlgoAPI_Section aSection;
BRepAlgoAPI_BooleanOperation *pBuilder;
- BOPAlgo_Operation aOp;
//
pBuilder=NULL;
- iOp=atoi(a[2]);
- if (iOp<0 || iOp>4) {
- di << "invalid operation type\n";
- return 0;
- }
- aOp=(BOPAlgo_Operation)iOp;
//
- switch (aOp) {
+ switch (anOp) {
case BOPAlgo_COMMON:
pBuilder=&aCommon;
break;
bNonDestructive = BOPTest_Objects::NonDestructive();
BOPAlgo_GlueEnum aGlue = BOPTest_Objects::Glue();
//
- if (aOp!=BOPAlgo_CUT21) {
+ if (anOp!=BOPAlgo_CUT21) {
pBuilder->SetArguments(aLS);
pBuilder->SetTools(aLT);
}
//
const TopoDS_Shape& aR=pBuilder->Shape();
if (aR.IsNull()) {
- di << " null shape\n";
+ di << "Result is a null shape\n";
return 0;
}
//
Standard_Integer n,
const char** a)
{
- if (n<2) {
- di << " use bapibuild r\n";
- return 0;
+ if (n != 2) {
+ di.PrintHelp(a[0]);
+ return 1;
}
//
Standard_Boolean bRunParallel, bNonDestructive;
//
const TopoDS_Shape& aR=aBuilder.Shape();
if (aR.IsNull()) {
- di << " null shape\n";
+ di << "Result is a null shape\n";
return 0;
}
//
Standard_Integer n,
const char** a)
{
- if (n < 2) {
- di << " use bapisplit r\n";
+ if (n != 2) {
+ di.PrintHelp(a[0]);
return 1;
}
//
// getting the result of the operation
const TopoDS_Shape& aR = aSplitter.Shape();
if (aR.IsNull()) {
- di << " null shape\n";
+ di << "Result is a null shape\n";
return 0;
}
//
#include <BOPTest.hxx>
+
#include <BOPTest_Objects.hxx>
+
#include <DBRep.hxx>
+
#include <Draw_Interpretor.hxx>
+
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
+
#include <TopTools_ListOfShape.hxx>
-#include <stdio.h>
-//
-//
-//
-static Standard_Integer baddobjects (Draw_Interpretor& , Standard_Integer , const char** );
+static Standard_Integer baddobjects (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer bclearobjects (Draw_Interpretor& , Standard_Integer , const char** );
-static Standard_Integer baddtools (Draw_Interpretor& , Standard_Integer , const char** );
-static Standard_Integer bcleartools (Draw_Interpretor& , Standard_Integer , const char** );
-static Standard_Integer baddcompound(Draw_Interpretor& , Standard_Integer , const char** );
-static Standard_Integer baddctools (Draw_Interpretor& , Standard_Integer , const char** );
-static Standard_Integer bclear (Draw_Interpretor&, Standard_Integer, const char**);
+static Standard_Integer baddtools (Draw_Interpretor& , Standard_Integer , const char** );
+static Standard_Integer bcleartools (Draw_Interpretor& , Standard_Integer , const char** );
+static Standard_Integer baddcompound (Draw_Interpretor& , Standard_Integer , const char** );
+static Standard_Integer baddctools (Draw_Interpretor& , Standard_Integer , const char** );
+static Standard_Integer bclear (Draw_Interpretor&, Standard_Integer, const char**);
-//
//=======================================================================
//function :ObjCommands
//purpose :
// Chapter's name
const char* g = "BOPTest commands";
// Commands
- theCommands.Add("baddobjects" , "use baddobjects s1 s2 ..." , __FILE__, baddobjects, g);
- theCommands.Add("bclearobjects" , "use bclearobjects" , __FILE__, bclearobjects, g);
- theCommands.Add("baddtools" , "use baddtools s1 s2 ..." , __FILE__, baddtools, g);
- theCommands.Add("bcleartools" , "use bcleartools" , __FILE__, bcleartools, g);
- theCommands.Add("baddcompound" , "use baddcompound c" , __FILE__, baddcompound, g);
- theCommands.Add("baddctools" , "use baddctools c" , __FILE__, baddctools, g);
- theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g);
+ theCommands.Add("baddobjects", "Adds objects for Boolean/GF/Split/Cells operations.\n"
+ "\t\tThe command has cumulative effect, thus can be used several times for single operation.\n"
+ "\t\tFor new operation the objects have to be cleared by bclearobjects or bclear commands.\n"
+ "\t\tUsage: baddobjects s1 s2 ...",
+ __FILE__, baddobjects, g);
+
+ theCommands.Add("bclearobjects", "Clears the objects previously added for Boolean/GF/Split/Cells operations.\n"
+ "\t\tUsage: bclearobjects",
+ __FILE__, bclearobjects, g);
+
+ theCommands.Add("baddtools", "Adds tools for Boolean/GF/Split/Cells operations.\n"
+ "\t\tThe command has cumulative effect, thus can be used several times for single operation.\n"
+ "\t\tFor new operation the tools have to be cleared by bcleartools or bclear commands.\n"
+ "\t\tUsage: baddtools s1 s2 ...",
+ __FILE__, baddtools, g);
+
+ theCommands.Add("bcleartools", "Clears the tools previously added for Boolean/GF/Split/Cells operations.\n"
+ "\t\tUsage: bcleartools",
+ __FILE__, bcleartools, g);
+
+ theCommands.Add("baddcompound", "Command for adding multiple objects for Boolean/GF/Split/Cells operations grouped in one object.\n"
+ "\t\tGiven object will be exploded on first level sub-shapes and each of these sub-shapes will act as a separate object.\n"
+ "\t\tThe command has cumulative effect, thus can be used several times for single operation.\n"
+ "\t\tFor new operation the objects have to be cleared by bclearobjects or bclear commands.\n"
+ "\t\tUsage: baddcompound c",
+ __FILE__, baddcompound, g);
+
+ theCommands.Add("baddctools", "Command for adding multiple tools for Boolean/GF/Split/Cells operations grouped in one object.\n"
+ "\t\tGiven object will be exploded on first level sub-shapes and each of these sub-shapes will act as a separate tool.\n"
+ "\t\tThe command has cumulative effect, thus can be used several times for single operation.\n"
+ "\t\tFor new operation the tools have to be cleared by bcleartools or bclear commands.\n"
+ "\t\tUsage: baddctools c",
+ __FILE__, baddctools, g);
+
+ theCommands.Add("bclear" , "Clears both objects and tools previously added for Boolean/GF/Split/Cells operations.\n"
+ "\t\tUsage: bclear",
+ __FILE__, bclear, g);
}
+
//=======================================================================
//function : baddcompound
//purpose :
//=======================================================================
-Standard_Integer baddcompound (Draw_Interpretor& ,
- Standard_Integer n,
+Standard_Integer baddcompound (Draw_Interpretor& di,
+ Standard_Integer n,
const char** a)
{
- if (n<2) {
- printf(" use baddcompound c\n");
- return 0;
+ if (n < 2) {
+ di.PrintHelp(a[0]);
+ return 1;
}
//
TopoDS_Iterator aIt;
//function : baddctools
//purpose :
//=======================================================================
-Standard_Integer baddctools (Draw_Interpretor& ,
- Standard_Integer n,
+Standard_Integer baddctools (Draw_Interpretor& di,
+ Standard_Integer n,
const char** a)
{
- if (n<2) {
- printf(" use baddctools c\n");
- return 0;
+ if (n < 2) {
+ di.PrintHelp(a[0]);
+ return 1;
}
//
TopoDS_Iterator aIt;
//function :baddobjects
//purpose :
//=======================================================================
-Standard_Integer baddobjects (Draw_Interpretor& ,
- Standard_Integer n,
+Standard_Integer baddobjects (Draw_Interpretor& di,
+ Standard_Integer n,
const char** a)
{
- if (n<2) {
- printf(" use baddobjects s1 s2 ...\n");
- return 0;
+ if (n < 2) {
+ di.PrintHelp(a[0]);
+ return 1;
}
//
Standard_Integer i;
//function : bclearobjects
//purpose :
//=======================================================================
-Standard_Integer bclearobjects (Draw_Interpretor& ,
- Standard_Integer n,
- const char** )
+Standard_Integer bclearobjects (Draw_Interpretor& di,
+ Standard_Integer n,
+ const char** a)
{
- if (n!=1) {
- printf(" use bclearobjects\n");
- return 0;
+ if (n != 1) {
+ di.PrintHelp(a[0]);
+ return 1;
}
TopTools_ListOfShape& aLS=BOPTest_Objects::Shapes();
aLS.Clear();
//function : baddtools
//purpose :
//=======================================================================
-Standard_Integer baddtools (Draw_Interpretor& ,
- Standard_Integer n,
+Standard_Integer baddtools (Draw_Interpretor& di,
+ Standard_Integer n,
const char** a)
{
- if (n<2) {
- printf(" use baddtools s1 s2 ...\n");
- return 0;
+ if (n < 2) {
+ di.PrintHelp(a[0]);
+ return 1;
}
//
Standard_Integer i;
//function : bcleartools
//purpose :
//=======================================================================
-Standard_Integer bcleartools (Draw_Interpretor& ,
- Standard_Integer n,
- const char** )
+Standard_Integer bcleartools (Draw_Interpretor& di,
+ Standard_Integer n,
+ const char** a)
{
- if (n!=1) {
- printf(" use bcleartools\n");
- return 0;
+ if (n != 1) {
+ di.PrintHelp(a[0]);
+ return 1;
}
TopTools_ListOfShape& aLS=BOPTest_Objects::Tools();
aLS.Clear();
//function : bclear
//purpose :
//=======================================================================
-Standard_Integer bclear(Draw_Interpretor& di,
- Standard_Integer n,
- const char** )
+Standard_Integer bclear(Draw_Interpretor& di,
+ Standard_Integer n,
+ const char** a)
{
- if (n!=1) {
- di << " use bclear\n";
- return 0;
+ if (n != 1) {
+ di.PrintHelp(a[0]);
+ return 1;
}
//
BOPTest_Objects::Clear();
// Chapter's name
const char* g = "BOPTest commands";
// Commands
- theCommands.Add("bfillds", "use bfillds [-t]" , __FILE__, bfillds, g);
- theCommands.Add("bbuild" , "use bbuild r [-t]" , __FILE__, bbuild, g);
- theCommands.Add("bbop" , "use bbop r op [-t]", __FILE__, bbop, g);
- theCommands.Add("bsplit" , "use bsplit r [-t]" , __FILE__, bsplit, g);
-
- theCommands.Add("buildbop", "Builds the result of BOP basing on the GF.\n"
- " The command uses classification approach for building the result of BOP\n"
- " (thus it operates on solids only and can be used on open solids):\n"
- " - FUSE is built from the faces OUT of all arguments\n"
- " - COMMON is built from the faces IN any of the object/tools\n"
- " - CUT is built from the objects faces OUT of the tools and tools faces IN the objects.\n"
- " Please note that history for solids will not be available.\n\n"
- " Usage: buildbop result -o s1 [s2 ...] -t s3 [s4 ...] -op operation (common/fuse/cut/tuc)\n"
- " Where:\n"
- " result - result shape of the operation\n"
- " s1 s2 s3 s4 - arguments (solids) of the GF operation\n"
- " operation - type of boolean operation",
+ theCommands.Add("bfillds", "Performs intersection of the arguments added for the operation by baddobjects and baddtools commands.\n"
+ "\t\tUsage: bfillds [-t]\n"
+ "\t\tWhere: -t is the optional parameter for enabling timer and showing elapsed time of the operation",
+ __FILE__, bfillds, g);
+
+ theCommands.Add("bbuild" , "Builds the result of General Fuse operation. Intersection (bfillds) has to be already performed by this moment.\n"
+ "\t\tUsage: bbuild result [-t]\n"
+ "\t\tWhere:\n"
+ "\t\tresult - name of the result shape\n"
+ "\t\t-t is the optional parameter for enabling timer and showing elapsed time of the operation",
+ __FILE__, bbuild, g);
+
+ theCommands.Add("bbop" , "Builds the result of Boolean operation. Intersection (bfillds) has to be already performed by this moment.\n"
+ "\t\tUsage: bbop result op [-t]\n"
+ "\t\tWhere:\n"
+ "\t\tresult - name of the result shape\n"
+ "\t\top - type of Boolean operation. Possible values:\n"
+ "\t\t - 0/common - for Common operation\n"
+ "\t\t - 1/fuse - for Fuse operation\n"
+ "\t\t - 2/cut - for Cut operation\n"
+ "\t\t - 3/tuc/cut21 - for Cut21 operation\n"
+ "\t\t - 4/section - for Section operation\n"
+ "\t\t-t - optional parameter for enabling timer and showing elapsed time of the operation",
+ __FILE__, bbop, g);
+
+ theCommands.Add("bsplit" , "Builds the result of Split operation. Intersection (bfillds) has to be already performed by this moment.\n"
+ "\t\tUsage: bsplit result [-t]\n"
+ "\t\tWhere:\n"
+ "\t\tresult - name of the result shape\n"
+ "\t\t-t is the optional parameter for enabling timer and showing elapsed time of the operation",
+ __FILE__, bsplit, g);
+
+ theCommands.Add("buildbop", "Builds the result of BOP basing on the GF, thus bbuild command has to be already performed\n"
+ "\t\tThe command uses classification approach for building the result of BOP\n"
+ "\t\t(thus it operates on solids only and can be used on open solids):\n"
+ "\t\t - FUSE is built from the faces OUT of all arguments\n"
+ "\t\t - COMMON is built from the faces IN any of the object/tools\n"
+ "\t\t - CUT is built from the objects faces OUT of the tools and tools faces IN the objects.\n"
+ "\t\tPlease note that history for solids will not be available.\n\n"
+ "\t\tUsage: buildbop result -o s1 [s2 ...] -t s3 [s4 ...] -op operation (common/fuse/cut/tuc)\n"
+ "\t\tWhere:\n"
+ "\t\tresult - result shape of the operation\n"
+ "\t\ts1 s2 s3 s4 - arguments (solids) of the GF operation\n"
+ "\t\toperation - type of boolean operation",
__FILE__, buildbop, g);
}
+
//=======================================================================
//function : bfillds
//purpose :
const char** a)
{
if (n > 2) {
- di << " use bfillds [-t]\n";
- return 0;
+ di.PrintHelp(a[0]);
+ return 1;
}
//
char buf[32];
Standard_Boolean bRunParallel, bNonDestructive, bShowTime;
- Standard_Integer i, aNbS;
+ Standard_Integer aNbS;
Standard_Real aTol;
TopTools_ListIteratorOfListOfShape aIt;
TopTools_ListOfShape aLC;
TopTools_ListOfShape& aLS=BOPTest_Objects::Shapes();
aNbS=aLS.Extent();
if (!aNbS) {
- di << " no objects to process\n";
+ di << "No objects to process\n";
return 0;
}
//
aTol = BOPTest_Objects::FuzzyValue();
BOPAlgo_GlueEnum aGlue = BOPTest_Objects::Glue();
//
- for (i=1; i<n; ++i) {
- if (!strcmp(a[i], "-t")) {
+ if (n == 2)
+ {
+ if (!strcmp(a[1], "-t"))
+ {
bShowTime=Standard_True;
}
+ else
+ {
+ di << "Warning: invalid key\n";
+ }
}
//
TopTools_ListOfShape& aLT=BOPTest_Objects::Tools();
Standard_Integer n,
const char** a)
{
- if (n<2) {
- di << " use bbuild r [-t]\n";
- return 0;
+ if (n < 2 || n > 3) {
+ di.PrintHelp(a[0]);
+ return 1;
}
//
BOPDS_PDS pDS=BOPTest_Objects::PDS();
if (!pDS) {
- di << " prepare PaveFiller first\n";
+ di << "Prepare PaveFiller first\n";
return 0;
}
//
char buf[128];
Standard_Boolean bRunParallel, bShowTime;
- Standard_Integer i;
TopTools_ListIteratorOfListOfShape aIt;
//
//
bShowTime=Standard_False;
bRunParallel=BOPTest_Objects::RunParallel();
- for (i=2; i<n; ++i) {
- if (!strcmp(a[i], "-t")) {
+ if (n == 3)
+ {
+ if (!strcmp(a[2], "-t"))
+ {
bShowTime=Standard_True;
}
+ else
+ {
+ di << "Warning: invalid key\n";
+ }
}
aBuilder.SetRunParallel(bRunParallel);
aBuilder.SetCheckInverted(BOPTest_Objects::CheckInverted());
//
const TopoDS_Shape& aR=aBuilder.Shape();
if (aR.IsNull()) {
- di << " null shape\n";
+ di << "Result is a null shape\n";
return 0;
}
//
Standard_Integer n,
const char** a)
{
- if (n<3) {
- di << " use bbop r op [-t]\n";
- return 0;
+ if (n < 3 || n > 4) {
+ di.PrintHelp(a[0]);
+ return 1;
}
//
BOPDS_PDS pDS=BOPTest_Objects::PDS();
if (!pDS) {
- di << " prepare PaveFiller first\n";
+ di << "Prepare PaveFiller first\n";
return 0;
}
//
- char buf[32];
- Standard_Boolean bRunParallel, bShowTime;
- Standard_Integer iOp, i;
- BOPAlgo_Operation aOp;
- TopTools_ListIteratorOfListOfShape aIt;
- //
- iOp=Draw::Atoi(a[2]);
- if (iOp<0 || iOp>4) {
- di << " invalid operation type\n";
+ BOPAlgo_Operation anOp = BOPTest::GetOperationType(a[2]);
+ if (anOp == BOPAlgo_UNKNOWN)
+ {
+ di << "Invalid operation type\n";
return 0;
}
- aOp=(BOPAlgo_Operation)iOp;
- //
- bShowTime=Standard_False;
- bRunParallel=BOPTest_Objects::RunParallel();
- for (i=3; i<n; ++i) {
- if (!strcmp(a[i], "-t")) {
+
+ Standard_Boolean bShowTime=Standard_False;
+ Standard_Boolean bRunParallel=BOPTest_Objects::RunParallel();
+ if (n == 4)
+ {
+ if (!strcmp(a[3], "-t"))
+ {
bShowTime=Standard_True;
}
+ else
+ {
+ di << "Warning: invalid key\n";
+ }
}
//
BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
//
BOPAlgo_Builder *pBuilder=NULL;
- if (aOp!=BOPAlgo_SECTION) {
+ if (anOp!=BOPAlgo_SECTION) {
pBuilder=&BOPTest_Objects::BOP();
}
else {
pBuilder->Clear();
//
TopTools_ListOfShape& aLSObj=BOPTest_Objects::Shapes();
- aIt.Initialize(aLSObj);
+ TopTools_ListIteratorOfListOfShape aIt(aLSObj);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
pBuilder->AddArgument(aS);
}
//
- if (aOp!=BOPAlgo_SECTION) {
+ if (anOp!=BOPAlgo_SECTION) {
BOPAlgo_BOP *pBOP=(BOPAlgo_BOP *)pBuilder;
//
TopTools_ListOfShape& aLSTools=BOPTest_Objects::Tools();
pBOP->AddTool(aS);
}
//
- pBOP->SetOperation(aOp);
+ pBOP->SetOperation(anOp);
}
else {
TopTools_ListOfShape& aLSTools=BOPTest_Objects::Tools();
aTimer.Stop();
//
if (bShowTime) {
+ char buf[32];
Sprintf(buf, " Tps: %7.2lf\n", aTimer.ElapsedTime());
di << buf;
}
//
const TopoDS_Shape& aR=pBuilder->Shape();
if (aR.IsNull()) {
- di << " null shape\n";
+ di << "Result is a null shape\n";
return 0;
}
//
Standard_Integer n,
const char** a)
{
- if (n < 2) {
- di << " use bsplit r [-t (show time)]\n";
+ if (n < 2 || n > 3) {
+ di.PrintHelp(a[0]);
return 1;
}
//
BOPDS_PDS pDS = BOPTest_Objects::PDS();
if (!pDS) {
- di << " prepare PaveFiller first\n";
+ di << "Prepare PaveFiller first\n";
return 0;
}
//
}
//
// show time if necessary
- if (n == 3 && !strcmp(a[2], "-t")) {
- char buf[20];
- Sprintf(buf, " Tps: %7.2lf\n", aTimer.ElapsedTime());
- di << buf;
+ if (n == 3)
+ {
+ if (!strcmp(a[2], "-t"))
+ {
+ char buf[20];
+ Sprintf(buf, " Tps: %7.2lf\n", aTimer.ElapsedTime());
+ di << buf;
+ }
+ else
+ {
+ di << "Warning: invalid key\n";
+ }
}
//
// Debug commands support
baddcompound by
baddcompound bz
-# intersection step
-bfillds -t
+# intersection step in serial mode
+brunparallel 0
+regexp {Tps: +([-0-9.+eE]+)} [bfillds -t] full Tps1
-# intersection step
-bfillds -t -s
+# intersection step in parallel mode
+brunparallel 1
+regexp {Tps: +([-0-9.+eE]+)} [bfillds -t] full Tps2
+
+# parallel execution is expected to be at least 20% faster than serial execution
+if {${Tps2} > [dval 0.8*${Tps1}]} {
+ puts "Error: Parallel execution does not give expected performance speed up"
+}
--- /dev/null
+puts "============================================"
+puts "0030206: Improve API of commands bbop and bapibop"
+puts "============================================"
+puts ""
+
+box b1 10 10 10
+box b2 5 5 5 10 10 10
+
+bclearobjects
+bcleartools
+baddobjects b1
+baddtools b2
+bfillds
+
+bcommon r0 b1 b2
+bbop r0_1 0
+bbop r0_2 common
+bapibop r0_3 0
+bapibop r0_4 common
+
+checknbshapes r0_1 -ref [nbshapes r0]
+checknbshapes r0_2 -ref [nbshapes r0]
+checknbshapes r0_3 -ref [nbshapes r0]
+checknbshapes r0_4 -ref [nbshapes r0]
+
+
+bfuse r1 b1 b2
+bbop r1_1 1
+bbop r1_2 fuse
+bapibop r1_3 1
+bapibop r1_4 fuse
+
+checknbshapes r1_1 -ref [nbshapes r1]
+checknbshapes r1_2 -ref [nbshapes r1]
+checknbshapes r1_3 -ref [nbshapes r1]
+checknbshapes r1_4 -ref [nbshapes r1]
+
+
+bcut r2 b1 b2
+bbop r2_1 2
+bbop r2_2 cut
+bapibop r2_3 2
+bapibop r2_4 cut
+
+checknbshapes r2_1 -ref [nbshapes r2]
+checknbshapes r2_2 -ref [nbshapes r2]
+checknbshapes r2_3 -ref [nbshapes r2]
+checknbshapes r2_4 -ref [nbshapes r2]
+
+
+btuc r3 b1 b2
+bbop r3_1 3
+bbop r3_2 tuc
+bbop r3_3 cut21
+bapibop r3_4 3
+bapibop r3_5 tuc
+bapibop r3_6 cut21
+
+checknbshapes r3_1 -ref [nbshapes r3]
+checknbshapes r3_2 -ref [nbshapes r3]
+checknbshapes r3_3 -ref [nbshapes r3]
+checknbshapes r3_4 -ref [nbshapes r3]
+checknbshapes r3_5 -ref [nbshapes r3]
+checknbshapes r3_6 -ref [nbshapes r3]
+
+
+bsection r4 b1 b2
+bbop r4_1 4
+bbop r4_2 section
+bapibop r4_3 4
+bapibop r4_4 section
+
+checknbshapes r4_1 -ref [nbshapes r4]
+checknbshapes r4_2 -ref [nbshapes r4]
+checknbshapes r4_3 -ref [nbshapes r4]
+checknbshapes r4_4 -ref [nbshapes r4]
+
+if {![regexp "Invalid operation type" [bbop r 5]]} {
+ puts "Error: incorrect parameter is not treated"
+}
+
+if {![regexp "Invalid operation type" [bbop r f]]} {
+ puts "Error: incorrect parameter is not treated"
+}
puts "in parallel and serial modes"
#
-# parallel
+# parallel
+brunparallel 1
puts "Build faces in parallel mode:"
+dchrono h start
set info1 [bbuild rp -t]
+dchrono h stop counter Parallel_Builder
regexp {Tps: +([-0-9.+eE]+)} ${info1} full Tps1
puts "Tps1=${Tps1}"
#
# serial
-puts "Build faces in serial mode:"
-set info2 [bbuild rs -s -t]
+brunparallel 0
+puts "Build faces in serial mode:"
+dchrono h restart
+set info2 [bbuild rs -t]
+dchrono h stop counter Serial_Builder
+
regexp {Tps: +([-0-9.+eE]+)} ${info2} full Tps2
puts "Tps2=${Tps2}"
checknbshapes rp -vertex 23060 -edge 35880 -wire 11704 -face 11704 -shell 0 -solid 0 -compsolid 0 -compound 1 -shape 82349
checknbshapes rs -vertex 23060 -edge 35880 -wire 11704 -face 11704 -shell 0 -solid 0 -compsolid 0 -compound 1 -shape 82349
+# parallel execution is expected to be at least 20% faster than serial execution
+if {${Tps1} > [dval 0.8*${Tps2}]} {
+ puts "Error: Parallel execution does not give expected performance speed up"
+}
+
vinit
vdisplay rs
vfit