diff --git a/src/BOPTest/BOPTest.cxx b/src/BOPTest/BOPTest.cxx index 23c67bddeb..5de6f3d84d 100644 --- a/src/BOPTest/BOPTest.cxx +++ b/src/BOPTest/BOPTest.cxx @@ -142,3 +142,48 @@ void BOPTest::ReportAlerts(const Handle(Message_Report)& theReport) } } } + +//======================================================================= +//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(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; +} diff --git a/src/BOPTest/BOPTest.hxx b/src/BOPTest/BOPTest.hxx index 8a34659201..5f0a999948 100644 --- a/src/BOPTest/BOPTest.hxx +++ b/src/BOPTest/BOPTest.hxx @@ -19,6 +19,7 @@ #include #include #include +#include #include class BOPTest_Objects; @@ -68,6 +69,10 @@ public: //! 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: diff --git a/src/BOPTest/BOPTest_APICommands.cxx b/src/BOPTest/BOPTest_APICommands.cxx index 613ea086d6..3a9949551e 100644 --- a/src/BOPTest/BOPTest_APICommands.cxx +++ b/src/BOPTest/BOPTest_APICommands.cxx @@ -50,9 +50,28 @@ void BOPTest::APICommands(Draw_Interpretor& theCommands) // 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 @@ -62,30 +81,29 @@ Standard_Integer bapibop(Draw_Interpretor& di, 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; @@ -115,7 +133,7 @@ Standard_Integer bapibop(Draw_Interpretor& di, bNonDestructive = BOPTest_Objects::NonDestructive(); BOPAlgo_GlueEnum aGlue = BOPTest_Objects::Glue(); // - if (aOp!=BOPAlgo_CUT21) { + if (anOp!=BOPAlgo_CUT21) { pBuilder->SetArguments(aLS); pBuilder->SetTools(aLT); } @@ -157,7 +175,7 @@ Standard_Integer bapibop(Draw_Interpretor& di, // const TopoDS_Shape& aR=pBuilder->Shape(); if (aR.IsNull()) { - di << " null shape\n"; + di << "Result is a null shape\n"; return 0; } // @@ -172,9 +190,9 @@ Standard_Integer bapibuild(Draw_Interpretor& di, 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; @@ -226,7 +244,7 @@ Standard_Integer bapibuild(Draw_Interpretor& di, // const TopoDS_Shape& aR=aBuilder.Shape(); if (aR.IsNull()) { - di << " null shape\n"; + di << "Result is a null shape\n"; return 0; } // @@ -242,8 +260,8 @@ Standard_Integer bapisplit(Draw_Interpretor& di, Standard_Integer n, const char** a) { - if (n < 2) { - di << " use bapisplit r\n"; + if (n != 2) { + di.PrintHelp(a[0]); return 1; } // @@ -289,7 +307,7 @@ Standard_Integer bapisplit(Draw_Interpretor& di, // 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; } // diff --git a/src/BOPTest/BOPTest_ObjCommands.cxx b/src/BOPTest/BOPTest_ObjCommands.cxx index 2170f7861e..ef440650dd 100644 --- a/src/BOPTest/BOPTest_ObjCommands.cxx +++ b/src/BOPTest/BOPTest_ObjCommands.cxx @@ -14,26 +14,26 @@ #include + #include + #include + #include + #include #include + #include -#include -// -// -// -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 : @@ -46,25 +46,56 @@ static Standard_Integer bclear (Draw_Interpretor&, Standard_Integer, const cha // 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; @@ -85,13 +116,13 @@ Standard_Integer baddcompound (Draw_Interpretor& , //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; @@ -113,13 +144,13 @@ Standard_Integer baddctools (Draw_Interpretor& , //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; @@ -137,13 +168,13 @@ Standard_Integer baddobjects (Draw_Interpretor& , //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(); @@ -154,13 +185,13 @@ Standard_Integer bclearobjects (Draw_Interpretor& , //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; @@ -178,13 +209,13 @@ Standard_Integer baddtools (Draw_Interpretor& , //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(); @@ -195,13 +226,13 @@ Standard_Integer bcleartools (Draw_Interpretor& , //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(); diff --git a/src/BOPTest/BOPTest_PartitionCommands.cxx b/src/BOPTest/BOPTest_PartitionCommands.cxx index b85f70110e..ffc15f6fc4 100644 --- a/src/BOPTest/BOPTest_PartitionCommands.cxx +++ b/src/BOPTest/BOPTest_PartitionCommands.cxx @@ -55,25 +55,53 @@ void BOPTest::PartitionCommands(Draw_Interpretor& theCommands) // 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("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("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("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 : @@ -83,20 +111,20 @@ Standard_Integer bfillds(Draw_Interpretor& di, 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; } // @@ -107,10 +135,16 @@ Standard_Integer bfillds(Draw_Interpretor& di, aTol = BOPTest_Objects::FuzzyValue(); BOPAlgo_GlueEnum aGlue = BOPTest_Objects::Glue(); // - for (i=1; i 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; // @@ -203,10 +236,16 @@ Standard_Integer bbuild(Draw_Interpretor& di, // bShowTime=Standard_False; bRunParallel=BOPTest_Objects::RunParallel(); - for (i=2; i 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; iClear(); // 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(); @@ -315,7 +354,7 @@ Standard_Integer bbop(Draw_Interpretor& di, pBOP->AddTool(aS); } // - pBOP->SetOperation(aOp); + pBOP->SetOperation(anOp); } else { TopTools_ListOfShape& aLSTools=BOPTest_Objects::Tools(); @@ -349,13 +388,14 @@ Standard_Integer bbop(Draw_Interpretor& di, 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; } // @@ -373,14 +413,14 @@ Standard_Integer bsplit(Draw_Interpretor& di, 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; } // @@ -424,10 +464,18 @@ Standard_Integer bsplit(Draw_Interpretor& di, } // // 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 diff --git a/tests/bugs/modalg_5/bug24639 b/tests/bugs/modalg_5/bug24639 index f5b855ae00..49aa6a5fbb 100644 --- a/tests/bugs/modalg_5/bug24639 +++ b/tests/bugs/modalg_5/bug24639 @@ -69,8 +69,15 @@ baddcompound bx 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" +} diff --git a/tests/bugs/modalg_7/bug30206 b/tests/bugs/modalg_7/bug30206 new file mode 100644 index 0000000000..158725d573 --- /dev/null +++ b/tests/bugs/modalg_7/bug30206 @@ -0,0 +1,84 @@ +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" +} diff --git a/tests/perf/bop/buildfaces b/tests/perf/bop/buildfaces index eb7563a4b9..7a51598254 100644 --- a/tests/perf/bop/buildfaces +++ b/tests/perf/bop/buildfaces @@ -40,22 +40,34 @@ puts "Comparing performance of building many faces" 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