From 43cb001124e4326c3a3a6bf54d803fbc80bf4cf1 Mon Sep 17 00:00:00 2001 From: pkv Date: Wed, 14 Jan 2015 09:43:30 +0300 Subject: [PATCH] 0025700: Ensuring uniform control of the functionalities of the Boolean operations algorithm at the level of DRAW application Changes: 1. Class BOPTest_Chronometer The class definition that depends on TBB has been removed 2. For the following commands: >bop s1 s2 [tol] >bopcommon r s1 s2 [tol] >bfuse r s1 s2 [tol] >bcut s1 s2 [tol] >btuc r s1 s2 [tol] >bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na] [tol] >mkvolume r b1 b2 ... [-c] [-ni] [-s] [tol] >bopcheck Shape [level of check: 0 - 9] [-t -s] [-tol tol] >bopargcheck Shape1 [[Shape2] [-F/O/C/T/S/U] [/R|F|T|V|E|I|P|C|S]] [#BF] [-tol tol] >bfillds [-s -t] [tol] the syntax has been changed. Parameter [tol] has been removed. The value "tol" (i.e. Fuzzy Value) is option for the algorithm. If it is necessary, the value "tol" can be set by the command: >bfuzzyvalue value see http://tracker.dev.opencascade.org/view.php?id=25614 for more details 3. For the following commands: >bopcheck Shape [level of check: 0 - 9] [-t -s] [-tol tol] >bfillds [-s -t] [tol] >bbuild r [-s -t] >bbop r op [-s -t] the syntax has been changed. Parameter [-s] has been removed. Parameter [-s] was to provide the sequential mode of the computations. The mode of the computations is option for the algorithm. The mode of the computations can be set by the command: >brunparallel [0/1] 1 -sets the parallel mode of the computations 0 -sets the sequential mode of the computations see http://tracker.dev.opencascade.org/view.php?id=25614 for more details --- src/BOPTest/BOPTest_APICommands.cxx | 7 +- src/BOPTest/BOPTest_BOPCommands.cxx | 137 ++++++-------- src/BOPTest/BOPTest_CheckCommands.cxx | 61 +++--- src/BOPTest/BOPTest_Chronometer.hxx | 43 +---- src/BOPTest/BOPTest_DrawableShape.cdl | 43 +++-- src/BOPTest/BOPTest_DrawableShape.cxx | 179 +++++++++--------- src/BOPTest/BOPTest_LowCommands.cxx | 67 +++---- src/BOPTest/BOPTest_ObjCommands.cxx | 71 +++++-- src/BOPTest/BOPTest_OptionCommands.cxx | 34 +++- src/BOPTest/BOPTest_PartitionCommands.cxx | 60 ++---- src/BOPTest/BOPTest_TolerCommands.cxx | 215 +++++++++++----------- tests/bugs/modalg_5/bug25477_1 | 3 +- tests/bugs/modalg_5/bug25477_2 | 3 +- 13 files changed, 441 insertions(+), 482 deletions(-) diff --git a/src/BOPTest/BOPTest_APICommands.cxx b/src/BOPTest/BOPTest_APICommands.cxx index 772bed1767..01a0dc42a2 100644 --- a/src/BOPTest/BOPTest_APICommands.cxx +++ b/src/BOPTest/BOPTest_APICommands.cxx @@ -52,7 +52,7 @@ void BOPTest::APICommands(Draw_Interpretor& theCommands) if (done) return; done = Standard_True; // Chapter's name - const char* g = "Partition commands"; + 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); @@ -170,9 +170,11 @@ Standard_Integer bapibuild(Draw_Interpretor& di, BRepAlgoAPI_BuilderAlgo aBuilder; // BOPCol_ListOfShape& aLSB=BOPTest_Objects::Shapes(); + BOPCol_ListOfShape& aLTB=BOPTest_Objects::Tools(); // - TopTools_ListOfShape aLS, aLT; + TopTools_ListOfShape aLS; ConvertList(aLSB, aLS); + ConvertList(aLTB, aLS); // bRunParallel=BOPTest_Objects::RunParallel(); aFuzzyValue=BOPTest_Objects::FuzzyValue(); @@ -207,7 +209,6 @@ void ConvertList(const BOPCol_ListOfShape& aLSB, { BOPCol_ListIteratorOfListOfShape aItB; // - aLS.Clear(); aItB.Initialize(aLSB); for (; aItB.More(); aItB.Next()) { const TopoDS_Shape& aS=aItB.Value(); diff --git a/src/BOPTest/BOPTest_BOPCommands.cxx b/src/BOPTest/BOPTest_BOPCommands.cxx index ca7da1c6dd..1724253c4f 100644 --- a/src/BOPTest/BOPTest_BOPCommands.cxx +++ b/src/BOPTest/BOPTest_BOPCommands.cxx @@ -64,6 +64,7 @@ static Standard_Integer n, const char** a, const BOPAlgo_Operation aOp); +// static Standard_Integer bsmt (Draw_Interpretor& di, Standard_Integer n, @@ -85,9 +86,6 @@ static Standard_Integer bcommon (Draw_Interpretor&, Standard_Integer, const ch // static Standard_Integer bopcurves (Draw_Interpretor&, Standard_Integer, const char**); static Standard_Integer bopnews (Draw_Interpretor&, Standard_Integer, const char**); -// -static Standard_Integer bparallelmode(Draw_Interpretor&, Standard_Integer, const char**); -// static Standard_Integer mkvolume (Draw_Interpretor&, Standard_Integer, const char**); //======================================================================= @@ -100,28 +98,26 @@ static Standard_Integer mkvolume (Draw_Interpretor&, Standard_Integer, const c if (done) return; done = Standard_True; // Chapter's name - const char* g = "BOP commands"; + const char* g = "BOPTest commands"; // Commands - theCommands.Add("bop" , "use bop s1 s2 [tol]" , __FILE__, bop, g); + theCommands.Add("bop" , "use bop s1 s2" , __FILE__, bop, g); theCommands.Add("bopcommon" , "use bopcommon r" , __FILE__, bopcommon, g); theCommands.Add("bopfuse" , "use bopfuse r" , __FILE__,bopfuse, g); theCommands.Add("bopcut" , "use bopcut r" , __FILE__,bopcut, g); theCommands.Add("boptuc" , "use boptuc r" , __FILE__,boptuc, g); theCommands.Add("bopsection", "use bopsection r" , __FILE__,bopsection, g); // - theCommands.Add("bcommon" , "use bcommon r s1 s2 [tol]" , __FILE__,bcommon, g); - theCommands.Add("bfuse" , "use bfuse r s1 s2 [tol]" , __FILE__,bfuse, g); - theCommands.Add("bcut" , "use bcut r s1 s2 [tol]" , __FILE__,bcut, g); - theCommands.Add("btuc" , "use btuc r s1 s2 [tol]" , __FILE__,btuc, g); - theCommands.Add("bsection", "Use >bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na] [tol]", + theCommands.Add("bcommon" , "use bcommon r s1 s2" , __FILE__,bcommon, g); + theCommands.Add("bfuse" , "use bfuse r s1 s2" , __FILE__,bfuse, g); + theCommands.Add("bcut" , "use bcut r s1 s2" , __FILE__,bcut, g); + theCommands.Add("btuc" , "use btuc r s1 s2" , __FILE__,btuc, g); + theCommands.Add("bsection", "use bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na]", __FILE__, bsection, g); // theCommands.Add("bopcurves", "use bopcurves F1 F2 [-2d]", __FILE__, bopcurves, g); - theCommands.Add("bopnews", "use bopnews -v[e,f]" , __FILE__, bopnews, g); - theCommands.Add("bparallelmode", "bparallelmode [1/0] : show / set parallel mode for boolean operations", - __FILE__, bparallelmode, g); - theCommands.Add("mkvolume", "make solids from set of shapes.\nmkvolume r b1 b2 ... [-c] [-ni] [-s] [tol]", + theCommands.Add("bopnews" , "use bopnews -v[e,f]" , __FILE__, bopnews, g); + theCommands.Add("mkvolume", "make solids from set of shapes.\nmkvolume r b1 b2 ... [-c] [-ni]", __FILE__, mkvolume , g); } @@ -129,7 +125,9 @@ static Standard_Integer mkvolume (Draw_Interpretor&, Standard_Integer, const c //function : bop //purpose : //======================================================================= -Standard_Integer bop(Draw_Interpretor& di, Standard_Integer n, const char** a) +Standard_Integer bop(Draw_Interpretor& di, + Standard_Integer n, + const char** a) { char buf[32]; Standard_Boolean bRunParallel; @@ -138,8 +136,8 @@ Standard_Integer bop(Draw_Interpretor& di, Standard_Integer n, const char** a) TopoDS_Shape aS1, aS2; BOPCol_ListOfShape aLC; // - if (n < 3 || n > 4) { - di << " use bop Shape1 Shape2 [tol]\n"; + if (n != 3) { + di << " use bop s1 s2 \n"; return 0; } // @@ -152,10 +150,6 @@ Standard_Integer bop(Draw_Interpretor& di, Standard_Integer n, const char** a) } // aTol=BOPTest_Objects::FuzzyValue(); - if (n == 4) { - aTol = Draw::Atof(a[3]); - } - // bRunParallel=BOPTest_Objects::RunParallel(); // aLC.Append(aS1); @@ -186,7 +180,9 @@ Standard_Integer bop(Draw_Interpretor& di, Standard_Integer n, const char** a) //function : bopcommon //purpose : //======================================================================= -Standard_Integer bopcommon (Draw_Interpretor& di, Standard_Integer n, const char** a) +Standard_Integer bopcommon (Draw_Interpretor& di, + Standard_Integer n, + const char** a) { return bopsmt(di, n, a, BOPAlgo_COMMON); } @@ -194,7 +190,9 @@ Standard_Integer bopcommon (Draw_Interpretor& di, Standard_Integer n, const char //function : bopfuse //purpose : //======================================================================= -Standard_Integer bopfuse(Draw_Interpretor& di, Standard_Integer n, const char** a) +Standard_Integer bopfuse(Draw_Interpretor& di, + Standard_Integer n, + const char** a) { return bopsmt(di, n, a, BOPAlgo_FUSE); } @@ -202,7 +200,9 @@ Standard_Integer bopfuse(Draw_Interpretor& di, Standard_Integer n, const char** //function : bopcut //purpose : //======================================================================= -Standard_Integer bopcut(Draw_Interpretor& di, Standard_Integer n, const char** a) +Standard_Integer bopcut(Draw_Interpretor& di, + Standard_Integer n, + const char** a) { return bopsmt(di, n, a, BOPAlgo_CUT); } @@ -210,7 +210,9 @@ Standard_Integer bopcut(Draw_Interpretor& di, Standard_Integer n, const char** a //function : boptuc //purpose : //======================================================================= -Standard_Integer boptuc(Draw_Interpretor& di, Standard_Integer n, const char** a) +Standard_Integer boptuc(Draw_Interpretor& di, + Standard_Integer n, + const char** a) { return bopsmt(di, n, a, BOPAlgo_CUT21); } @@ -224,7 +226,7 @@ Standard_Integer bopsmt(Draw_Interpretor& di, const BOPAlgo_Operation aOp) { if (n<2) { - di << " use bopsmt r\n [tol]"; + di << " use bopsmt r\n"; return 0; } // @@ -282,10 +284,12 @@ Standard_Integer bopsmt(Draw_Interpretor& di, //function : bopsection //purpose : //======================================================================= -Standard_Integer bopsection(Draw_Interpretor& di, Standard_Integer n, const char** a) +Standard_Integer bopsection(Draw_Interpretor& di, + Standard_Integer n, + const char** a) { if (n<2) { - di << " use bopsmt r\n"; + di << " use bopsection r\n"; return 0; } // @@ -342,7 +346,9 @@ Standard_Integer bopsection(Draw_Interpretor& di, Standard_Integer n, const char //function : bcommon //purpose : //======================================================================= -Standard_Integer bcommon (Draw_Interpretor& di, Standard_Integer n, const char** a) +Standard_Integer bcommon (Draw_Interpretor& di, + Standard_Integer n, + const char** a) { return bsmt(di, n, a, BOPAlgo_COMMON); } @@ -350,7 +356,9 @@ Standard_Integer bcommon (Draw_Interpretor& di, Standard_Integer n, const char** //function : bfuse //purpose : //======================================================================= -Standard_Integer bfuse (Draw_Interpretor& di, Standard_Integer n, const char** a) +Standard_Integer bfuse (Draw_Interpretor& di, + Standard_Integer n, + const char** a) { return bsmt(di, n, a, BOPAlgo_FUSE); } @@ -358,7 +366,9 @@ Standard_Integer bfuse (Draw_Interpretor& di, Standard_Integer n, const char** a //function : bcut //purpose : //======================================================================= -Standard_Integer bcut (Draw_Interpretor& di, Standard_Integer n, const char** a) +Standard_Integer bcut (Draw_Interpretor& di, + Standard_Integer n, + const char** a) { return bsmt(di, n, a, BOPAlgo_CUT); } @@ -366,7 +376,9 @@ Standard_Integer bcut (Draw_Interpretor& di, Standard_Integer n, const char** a) //function : btuc //purpose : //======================================================================= -Standard_Integer btuc (Draw_Interpretor& di, Standard_Integer n, const char** a) +Standard_Integer btuc (Draw_Interpretor& di, + Standard_Integer n, + const char** a) { return bsmt(di, n, a, BOPAlgo_CUT21); } @@ -378,15 +390,15 @@ Standard_Integer bsection(Draw_Interpretor& di, Standard_Integer n, const char** a) { - const char* usage = " Usage: bsection Result s1 s2 [-n2d/-n2d1/-n2d2] [-na] [tol]\n"; if (n < 4) { - di << usage; + di << "use bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na] [tol]\n"; return 0; } // - TopoDS_Shape aS1 = DBRep::Get(a[2]); - TopoDS_Shape aS2 = DBRep::Get(a[3]); + TopoDS_Shape aS1, aS2; // + aS1=DBRep::Get(a[2]); + aS2=DBRep::Get(a[3]); if (aS1.IsNull() || aS2.IsNull()) { di << " Null shapes are not allowed \n"; return 0; @@ -417,9 +429,6 @@ Standard_Integer bsection(Draw_Interpretor& di, else if (!strcmp(a[i], "-na")) { bApp = Standard_False; } - else { - aTol = Draw::Atof(a[i]); - } } // BRepAlgoAPI_Section aSec(aS1, aS2, Standard_False); @@ -427,6 +436,7 @@ Standard_Integer bsection(Draw_Interpretor& di, aSec.Approximation(bApp); aSec.ComputePCurveOn1(bPC1); aSec.ComputePCurveOn2(bPC2); + // aSec.SetFuzzyValue(aTol); aSec.SetRunParallel(bRunParallel); // @@ -462,8 +472,8 @@ Standard_Integer bsmt (Draw_Interpretor& di, BOPCol_ListOfShape aLC; Standard_Real aTol; // - if (n < 4 || n > 5) { - di << " use bx r s1 s2 [tol]\n"; + if (n != 4) { + di << " use bx r s1 s2\n"; return 0; } // @@ -478,10 +488,6 @@ Standard_Integer bsmt (Draw_Interpretor& di, aLC.Append(aS2); // aTol=BOPTest_Objects::FuzzyValue(); - if (n == 5) { - aTol = Draw::Atof(a[4]); - } - // bRunParallel = BOPTest_Objects::RunParallel(); // Handle(NCollection_BaseAllocator)aAL=new NCollection_IncAllocator; @@ -760,13 +766,11 @@ Standard_Integer bopcurves (Draw_Interpretor& di, Standard_Integer mkvolume(Draw_Interpretor& di, Standard_Integer n, const char** a) { if (n < 3) { - di << "Usage: mkvolume r b1 b2 ... [-c] [-ni] [-s] [tol]\n"; + di << "Usage: mkvolume r b1 b2 ... [-c] [-ni]\n"; di << "Options:\n"; di << " -c - use this option if the arguments are compounds\n"; di << " containing shapes that should be interfered;\n"; di << " -ni - use this option if the arguments should not be interfered;\n"; - di << " -s - use this option to run the operation in non parallel mode;\n"; - di << " tol - additional tolerance value (real).\n"; return 1; } // @@ -779,8 +783,9 @@ Standard_Integer mkvolume(Draw_Interpretor& di, Standard_Integer n, const char** BOPCol_ListOfShape aLS; // aTol = BOPTest_Objects::FuzzyValue(); - bToIntersect = Standard_True; bRunParallel = BOPTest_Objects::RunParallel(); + // + bToIntersect = Standard_True; bCompounds = Standard_False; // for (i = 2; i < n; ++i) { @@ -795,12 +800,6 @@ Standard_Integer mkvolume(Draw_Interpretor& di, Standard_Integer n, const char** else if (!strcmp(a[i], "-ni")) { bToIntersect = Standard_False; } - else if (!strcmp(a[i], "-s")) { - bRunParallel = Standard_False; - } - else { - aTol = Draw::Atof(a[i]); - } } } // @@ -847,31 +846,3 @@ Standard_Integer mkvolume(Draw_Interpretor& di, Standard_Integer n, const char** // return 0; } -//======================================================================= -//function : bparallelmode -//purpose : -//======================================================================= -Standard_Integer bparallelmode(Draw_Interpretor& di, Standard_Integer n, const char** a) -{ - if (n == 2) - { - Standard_Boolean isParallelOn = Draw::Atoi (a[1]) == 1; - if (isParallelOn == 1) - { - BOPAlgo_Algo::SetParallelMode(Standard_True); - di << "Parallel mode for boolean operations has been enabled"; - } - else - { - BOPAlgo_Algo::SetParallelMode(Standard_False); - di << "Parallel mode for boolean operations has been disabled"; - } - } - else - { - di << "Parallel mode state for boolean operations: " - << (BOPAlgo_Algo::GetParallelMode()? "enabled" : "disabled"); - } - - return 0; -} diff --git a/src/BOPTest/BOPTest_CheckCommands.cxx b/src/BOPTest/BOPTest_CheckCommands.cxx index a63ed3eb2c..cfd5996c8b 100644 --- a/src/BOPTest/BOPTest_CheckCommands.cxx +++ b/src/BOPTest/BOPTest_CheckCommands.cxx @@ -45,6 +45,8 @@ #include #include +#include + // static void MakeShapeForFullOutput (const TCollection_AsciiString&, @@ -73,19 +75,19 @@ void BOPTest::CheckCommands(Draw_Interpretor& theCommands) done = Standard_True; // Chapter's name - const char* g = "CCR commands"; + const char* g = "BOPTest commands"; // theCommands.Add("bopcheck", - "Use >bopcheck Shape [level of check: 0(V/V) - 5(all)]", + "use bopcheck Shape [level of check: 0 - 9] [-t]", __FILE__, bopcheck, g); theCommands.Add("bopargcheck" , - "Use bopargcheck without parameters to get ", + "use bopargcheck without parameters to get ", __FILE__, bopargcheck, g); theCommands.Add ("xdistef" , - "Use xdistef edge face", + "use xdistef edge face", __FILE__, xdistef, g); theCommands.Add("checkcurveonsurf", - "checkcurveonsurf shape", + "use checkcurveonsurf shape", __FILE__, checkcurveonsurf, g); } //======================================================================= @@ -152,7 +154,7 @@ Standard_Integer bopcheck (Draw_Interpretor& di, const char** a ) { if (n<2) { - di << " Use > bopcheck Shape [level of check: 0 - 9] [-t -s] [-tol tol]" << "\n"; + di << " use bopcheck Shape [level of check: 0 - 9] [-t]\n"; di << " The level of check defines "; di << " which interferences will be checked:\n"; di << " 0 - V/V only\n"; @@ -177,7 +179,7 @@ Standard_Integer bopcheck (Draw_Interpretor& di, // Standard_Boolean bRunParallel, bShowTime; Standard_Integer i, aLevel, aNbInterfTypes; - Standard_Real aTolerance; + Standard_Real aTol; // aNbInterfTypes=BOPDS_DS::NbInterfTypes(); // @@ -194,22 +196,14 @@ Standard_Integer bopcheck (Draw_Interpretor& di, return 1; } // - aTolerance = 0; bShowTime=Standard_False; - bRunParallel=Standard_True; + aTol=BOPTest_Objects::FuzzyValue(); + bRunParallel=BOPTest_Objects::RunParallel(); + // for (i=2; ibopargcheck Shape1 [[Shape2] "; - di << "[-F/O/C/T/S/U] [/R|F|T|V|E|I|P|C|S]] [#BF] [-tol tol]" << "\n" << "\n"; + di << "[-F/O/C/T/S/U] [/R|F|T|V|E|I|P|C|S]] [#BF]\n\n"; di << " -" << "\n"; di << " F (fuse)" << "\n"; di << " O (common)" << "\n"; @@ -398,29 +392,20 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer indxS2 = 0; Standard_Real aTolerance = 0; + aTolerance=BOPTest_Objects::FuzzyValue(); + if(n >= 3) { Standard_Integer iIndex = 0; for(iIndex = 2; iIndex < n; iIndex++) { - if(!strcmp(a[iIndex], "-tol")) - { - if ((iIndex+1) < n) { - ++iIndex; - aTolerance = Draw::Atof(a[iIndex]); - } - } - else if(a[iIndex][0] == '-') - { + if(a[iIndex][0] == '-') { isBO = Standard_True; indxBO = iIndex; } - //else if(a[iIndex][0] == '+') - else if(a[iIndex][0] == '/') - { + else if(a[iIndex][0] == '/') { isOP = Standard_True; indxOP = iIndex; } - else if(a[iIndex][0] == '#') - { + else if(a[iIndex][0] == '#') { isAD = Standard_True; indxAD = iIndex; } @@ -939,8 +924,8 @@ Standard_Integer xdistef(Draw_Interpretor& di, Standard_Integer n, const char** a) { - if(n < 3) { - di << "Use efmaxdist edge face\n"; + if(n < 3) { + di << "use xdistef edge face\n"; return 1; } // diff --git a/src/BOPTest/BOPTest_Chronometer.hxx b/src/BOPTest/BOPTest_Chronometer.hxx index e51aa2f688..16821d061e 100644 --- a/src/BOPTest/BOPTest_Chronometer.hxx +++ b/src/BOPTest/BOPTest_Chronometer.hxx @@ -15,49 +15,17 @@ #ifndef BOPTest_Chronometer_HeaderFile #define BOPTest_Chronometer_HeaderFile // -#ifdef HAVE_TBB -#include -//======================================================================= -//class : BOPTime_Chronometer -//purpose : -//======================================================================= -class BOPTime_Chronometer { - public: - BOPTime_Chronometer() { - } - // - ~BOPTime_Chronometer() { - } - // - void Start() { - myT0 = tick_count::now(); - } - // - void Stop() { - myTime=(tick_count::now() - myT0).seconds(); - } - // - double Time() const{ - return myTime; - }; - // - protected: - tick_count myT0; - double myTime; -}; -//////////////////////////////////////////////////////////////////////// -#else #include //======================================================================= -//class : BOPTime_Chronometer +//class : BOPTest_Chronometer //purpose : //======================================================================= -class BOPTime_Chronometer { +class BOPTest_Chronometer { public: - BOPTime_Chronometer() { + BOPTest_Chronometer() { } // - ~BOPTime_Chronometer() { + ~BOPTest_Chronometer() { } // void Start() { @@ -78,6 +46,5 @@ class BOPTime_Chronometer { OSD_Chronometer myChronometer; double myTime; }; -#endif -// + #endif diff --git a/src/BOPTest/BOPTest_DrawableShape.cdl b/src/BOPTest/BOPTest_DrawableShape.cdl index 0d78dd903f..7d897df4ed 100644 --- a/src/BOPTest/BOPTest_DrawableShape.cdl +++ b/src/BOPTest/BOPTest_DrawableShape.cdl @@ -13,7 +13,8 @@ -- Alternatively, this file may be used under the terms of Open CASCADE -- commercial license or contractual agreement. -class DrawableShape from BOPTest inherits DrawableShape from DBRep +class DrawableShape from BOPTest + inherits DrawableShape from DBRep ---Purpose: @@ -28,33 +29,31 @@ uses Pnt from gp is + Create (S : Shape from TopoDS; + FreeCol : Color from Draw; -- color for free edges + ConnCol : Color from Draw; -- color for shared edges + EdgeCol : Color from Draw; -- color for other edges + IsosCol : Color from Draw; -- color for Isos + size : Real; -- size for infinite isos + nbisos : Integer; -- # of isos on each face + discret : Integer; -- # of points on curves + Text : CString from Standard; + TextColor : Color from Draw) + returns DrawableShape from BOPTest; Create (S : Shape from TopoDS; - FreeCol : Color from Draw; -- color for free edges - ConnCol : Color from Draw; -- color for shared edges - EdgeCol : Color from Draw; -- color for other edges - IsosCol : Color from Draw; -- color for Isos - size : Real; -- size for infinite isos - nbisos : Integer; -- # of isos on each face - discret : Integer; -- # of points on curves - Text : CString from Standard; - TextColor : Color from Draw - ) - returns DrawableShape from BOPTest; - - Create (S : Shape from TopoDS; - Text : CString from Standard; - TextColor : Color from Draw - ) - returns DrawableShape from BOPTest; - - Pnt(me) returns Pnt from gp is private; + Text : CString from Standard; + TextColor : Color from Draw) + returns DrawableShape from BOPTest; + + Pnt(me) + returns Pnt from gp + is private; DrawOn(me; dis : in out Display from Draw) - is redefined; + is redefined; fields - myText : Text3D from Draw; myTextColor : Color from Draw; diff --git a/src/BOPTest/BOPTest_DrawableShape.cxx b/src/BOPTest/BOPTest_DrawableShape.cxx index 9bb08b6285..9d7ab543c1 100644 --- a/src/BOPTest/BOPTest_DrawableShape.cxx +++ b/src/BOPTest/BOPTest_DrawableShape.cxx @@ -56,40 +56,40 @@ //function : //purpose : //======================================================================= -BOPTest_DrawableShape::BOPTest_DrawableShape (const TopoDS_Shape& aShape, - const Draw_Color& FreeCol, - const Draw_Color& ConnCol, - const Draw_Color& EdgeCol, - const Draw_Color& IsosCol, - const Standard_Real size, - const Standard_Integer nbisos, - const Standard_Integer discret, - const Standard_CString Text, - const Draw_Color& TextColor) +BOPTest_DrawableShape::BOPTest_DrawableShape + (const TopoDS_Shape& aShape, + const Draw_Color& FreeCol, + const Draw_Color& ConnCol, + const Draw_Color& EdgeCol, + const Draw_Color& IsosCol, + const Standard_Real size, + const Standard_Integer nbisos, + const Standard_Integer discret, + const Standard_CString Text, + const Draw_Color& TextColor) : - DBRep_DrawableShape(aShape,FreeCol,ConnCol,EdgeCol,IsosCol,size,nbisos,discret) + DBRep_DrawableShape(aShape,FreeCol,ConnCol, + EdgeCol,IsosCol,size,nbisos,discret) { myText = new Draw_Text3D(Pnt(),Text,TextColor); myTextColor = TextColor; } - //======================================================================= //function : //purpose : //======================================================================= - BOPTest_DrawableShape::BOPTest_DrawableShape (const TopoDS_Shape& aShape, - const Standard_CString Text, - const Draw_Color& TextColor) -: DBRep_DrawableShape( - aShape, - Draw_vert, - Draw_jaune, - Draw_rouge, - Draw_bleu, - 100., //size - 2, //nbIsos - 30 //discret - ) +BOPTest_DrawableShape::BOPTest_DrawableShape + (const TopoDS_Shape& aShape, + const Standard_CString Text, + const Draw_Color& TextColor) +: DBRep_DrawableShape(aShape, + Draw_vert, + Draw_jaune, + Draw_rouge, + Draw_bleu, + 100., //size + 2, //nbIsos + 30) //discret { myText = new Draw_Text3D(Pnt(),Text,TextColor); myTextColor = TextColor; @@ -99,16 +99,16 @@ BOPTest_DrawableShape::BOPTest_DrawableShape (const TopoDS_Shape& aShape, //function : Pnt //purpose : //======================================================================= - gp_Pnt BOPTest_DrawableShape::Pnt() const +gp_Pnt BOPTest_DrawableShape::Pnt() const { gp_Pnt P(0,0,0); Standard_Real u, v, u1, u2, v1, v2, p; TopExp_Explorer ex; - + TopoDS_Shape S = Shape(); TopAbs_ShapeEnum T = S.ShapeType(); Standard_Real facpar = 0.; - + while ( T == TopAbs_COMPOUND ) { TopoDS_Iterator ti(S); if ( ti.More() ) { @@ -121,77 +121,70 @@ BOPTest_DrawableShape::BOPTest_DrawableShape (const TopoDS_Shape& aShape, } // si S final = compound --> P = 0 0 0 - switch (T) - { - case TopAbs_VERTEX : - P = BRep_Tool::Pnt(TopoDS::Vertex(S)); - break; - - case TopAbs_EDGE : - { - BRepAdaptor_Curve CU(TopoDS::Edge(S)); - u1 = CU.FirstParameter(); - u2 = CU.LastParameter(); - if (facpar == 0.) facpar = 0.20; - p = u1 + (u2-u1)*facpar; - P = CU.Value(p); - } - break; - - case TopAbs_WIRE : - { - TopTools_IndexedMapOfShape aME; - TopExp::MapShapes(S, TopAbs_EDGE, aME); - const TopoDS_Edge& anEdge=TopoDS::Edge(aME(1)); - BRepAdaptor_Curve CU(anEdge); - u1 = CU.FirstParameter(); - u2 = CU.LastParameter(); - if (facpar == 0.) facpar = 0.40; - p = u1 + (u2-u1)*facpar; - P = CU.Value(p); - } - break; - - case TopAbs_FACE : - { - BRepAdaptor_Surface SU(TopoDS::Face(S)); - BRepTools::UVBounds(TopoDS::Face(S),u1,u2,v1,v2); - // - facpar = .2; - u = u1 + (u2-u1)*facpar; - v = v1 + (v2-v1)*facpar; - P = SU.Value(u,v); - } - break; - - case TopAbs_SHELL : - case TopAbs_SOLID : - { - TopTools_IndexedMapOfShape aMF; - TopExp::MapShapes(S, TopAbs_FACE, aMF); - const TopoDS_Face& aF=TopoDS::Face(aMF(1)); - - BRepAdaptor_Surface SU(TopoDS::Face(aF)); - BRepTools::UVBounds(aF,u1,u2,v1,v2); - facpar = .4; - u = u1 + (u2-u1)*facpar; - v = v1 + (v2-v1)*facpar; - P = SU.Value(u,v); - } - break; - - default: - break; - } + switch (T) { + case TopAbs_VERTEX : + P = BRep_Tool::Pnt(TopoDS::Vertex(S)); + break; + + case TopAbs_EDGE : { + BRepAdaptor_Curve CU(TopoDS::Edge(S)); + u1 = CU.FirstParameter(); + u2 = CU.LastParameter(); + if (facpar == 0.) facpar = 0.20; + p = u1 + (u2-u1)*facpar; + P = CU.Value(p); + } + break; + + case TopAbs_WIRE : { + TopTools_IndexedMapOfShape aME; + TopExp::MapShapes(S, TopAbs_EDGE, aME); + const TopoDS_Edge& anEdge=TopoDS::Edge(aME(1)); + BRepAdaptor_Curve CU(anEdge); + u1 = CU.FirstParameter(); + u2 = CU.LastParameter(); + if (facpar == 0.) facpar = 0.40; + p = u1 + (u2-u1)*facpar; + P = CU.Value(p); + } + break; + + case TopAbs_FACE : { + BRepAdaptor_Surface SU(TopoDS::Face(S)); + BRepTools::UVBounds(TopoDS::Face(S),u1,u2,v1,v2); + // + facpar = .2; + u = u1 + (u2-u1)*facpar; + v = v1 + (v2-v1)*facpar; + P = SU.Value(u,v); + } + break; + + case TopAbs_SHELL : + case TopAbs_SOLID : { + TopTools_IndexedMapOfShape aMF; + TopExp::MapShapes(S, TopAbs_FACE, aMF); + const TopoDS_Face& aF=TopoDS::Face(aMF(1)); + + BRepAdaptor_Surface SU(TopoDS::Face(aF)); + BRepTools::UVBounds(aF,u1,u2,v1,v2); + facpar = .4; + u = u1 + (u2-u1)*facpar; + v = v1 + (v2-v1)*facpar; + P = SU.Value(u,v); + } + break; + + default: + break; + } return P; } - - //======================================================================= //function : DrawOn //purpose : //======================================================================= - void BOPTest_DrawableShape::DrawOn(Draw_Display& dis) const +void BOPTest_DrawableShape::DrawOn(Draw_Display& dis) const { DBRep_DrawableShape::DrawOn(dis); myText->SetPnt(Pnt()); diff --git a/src/BOPTest/BOPTest_LowCommands.cxx b/src/BOPTest/BOPTest_LowCommands.cxx index ec3cec70c4..dd6eb642c7 100644 --- a/src/BOPTest/BOPTest_LowCommands.cxx +++ b/src/BOPTest/BOPTest_LowCommands.cxx @@ -70,12 +70,12 @@ static Standard_Integer bhaspc (Draw_Interpretor& , Standard_Integer , con if (done) return; done = Standard_True; // Chapter's name - const char* g = "CCR commands"; - theCommands.Add("bclassify" , "Use >bclassify Solid Point [Tolerance=1.e-7]", + const char* g = "BOPTest commands"; + theCommands.Add("bclassify" , "use bclassify Solid Point [Tolerance=1.e-7]", __FILE__, bclassify , g); - theCommands.Add("b2dclassify" , "Use >bclassify Face Point2d [Tol2D=Tol(Face)] ", + theCommands.Add("b2dclassify" , "use bclassify Face Point2d [Tol2D=Tol(Face)] ", __FILE__, b2dclassify , g); - theCommands.Add("bhaspc" , "Use >bhaspc Edge Face [do]", + theCommands.Add("bhaspc" , "use bhaspc Edge Face [do]", __FILE__, bhaspc , g); } @@ -87,27 +87,25 @@ Standard_Integer bclassify (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) { - if (theArgNb < 3) - { - theDI << " Use >bclassify Solid Point [Tolerance=1.e-7]\n"; + if (theArgNb < 3) { + theDI << " use bclassify Solid Point [Tolerance=1.e-7]\n"; return 1; } TopoDS_Shape aS = DBRep::Get (theArgVec[1]); - if (aS.IsNull()) - { - theDI << " Null Shape is not allowed here\n"; + if (aS.IsNull()) { + theDI << " Null Shape is not allowed\n"; return 1; } - else if (aS.ShapeType() != TopAbs_SOLID) - { + else if (aS.ShapeType() != TopAbs_SOLID) { theDI << " Shape type must be SOLID\n"; return 1; } gp_Pnt aP (8., 9., 10.); DrawTrSurf::GetPoint (theArgVec[2], aP); - const Standard_Real aTol = (theArgNb == 4) ? Draw::Atof (theArgVec[3]) : 1.e-7; //Precision::Confusion(); + const Standard_Real aTol = (theArgNb == 4) ? + Draw::Atof (theArgVec[3]) : 1.e-7; BRepClass3d_SolidClassifier aSC (aS); aSC.Perform (aP,aTol); @@ -124,20 +122,17 @@ Standard_Integer b2dclassify (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) { - if (theArgNb < 3) - { - theDI << " Use >bclassify Face Point2d [Tol2D=Tol(Face)]\n"; + if (theArgNb < 3) { + theDI << " use bclassify Face Point2d [Tol2D=Tol(Face)]\n"; return 1; } TopoDS_Shape aS = DBRep::Get (theArgVec[1]); - if (aS.IsNull()) - { + if (aS.IsNull()) { theDI << " Null Shape is not allowed here\n"; return 1; } - else if (aS.ShapeType() != TopAbs_FACE) - { + else if (aS.ShapeType() != TopAbs_FACE) { theDI << " Shape type must be FACE\n"; return 1; } @@ -145,7 +140,8 @@ Standard_Integer b2dclassify (Draw_Interpretor& theDI, gp_Pnt2d aP (8., 9.); DrawTrSurf::GetPoint2d (theArgVec[2], aP); const TopoDS_Face& aF = TopoDS::Face(aS); - const Standard_Real aTol = (theArgNb == 4) ? Draw::Atof (theArgVec[3]) : BRep_Tool::Tolerance (aF); + const Standard_Real aTol = (theArgNb == 4) ? + Draw::Atof (theArgVec[3]) : BRep_Tool::Tolerance (aF); BRepClass_FaceClassifier aClassifier; aClassifier.Perform(aF, aP, aTol); @@ -158,10 +154,12 @@ Standard_Integer b2dclassify (Draw_Interpretor& theDI, //function : bhaspc //purpose : //======================================================================= -Standard_Integer bhaspc (Draw_Interpretor& di, Standard_Integer n, const char** a) +Standard_Integer bhaspc (Draw_Interpretor& di, + Standard_Integer n, + const char** a) { if (n<3) { - di << " Use bhaspc> Edge Face [do]\n"; + di << " use bhaspc Edge Face [do]\n"; return 1; } @@ -198,7 +196,6 @@ Standard_Integer bhaspc (Draw_Interpretor& di, Standard_Integer n, const char** return 0; } - //======================================================================= //function : PrintState //purpose : @@ -206,16 +203,22 @@ Standard_Integer bhaspc (Draw_Interpretor& di, Standard_Integer n, const char** void PrintState (Draw_Interpretor& theDI, const TopAbs_State& theState) { - switch (theState) - { - case TopAbs_IN: theDI << "The point is IN shape\n"; return; - case TopAbs_OUT: theDI << "The point is OUT of shape\n"; return; - case TopAbs_ON: theDI << "The point is ON shape\n"; return; - case TopAbs_UNKNOWN: - default: theDI << "The point is UNKNOWN shape\n"; return; + switch (theState) { + case TopAbs_IN: + theDI << "The point is IN shape\n"; + break; + case TopAbs_OUT: + theDI << "The point is OUT of shape\n"; + break; + case TopAbs_ON: + theDI << "The point is ON shape\n"; + break; + case TopAbs_UNKNOWN: + default: + theDI << "The point is UNKNOWN shape\n"; + break; } } - //======================================================================= //function : CurveOnSurface //purpose : diff --git a/src/BOPTest/BOPTest_ObjCommands.cxx b/src/BOPTest/BOPTest_ObjCommands.cxx index d7bc828173..f1c07403f6 100644 --- a/src/BOPTest/BOPTest_ObjCommands.cxx +++ b/src/BOPTest/BOPTest_ObjCommands.cxx @@ -25,12 +25,14 @@ // #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**); + // //======================================================================= //function :ObjCommands @@ -42,23 +44,26 @@ static Standard_Integer baddctools (Draw_Interpretor& , Standard_Integer , cons if (done) return; done = Standard_True; // Chapter's name - const char* g = "BOP commands"; + const char* g = "BOPTest commands"; // Commands - theCommands.Add("baddobjects" , "baddobjects s1 s2 ..." , __FILE__, baddobjects, g); - theCommands.Add("bclearobjects" , "bclearobjects" , __FILE__, bclearobjects, g); - theCommands.Add("baddtools" , "baddtools s1 s2 ..." , __FILE__, baddtools, g); - theCommands.Add("bcleartools" , "bcleartools" , __FILE__, bcleartools, g); - theCommands.Add("baddcompound" , "baddcompound c" , __FILE__, baddcompound, g); - theCommands.Add("baddctools" , "baddctools c" , __FILE__, baddctools, g); + 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); } //======================================================================= //function : baddcompound //purpose : //======================================================================= -Standard_Integer baddcompound (Draw_Interpretor& , Standard_Integer n, const char** a) +Standard_Integer baddcompound (Draw_Interpretor& , + Standard_Integer n, + const char** a) { if (n<2) { - printf(" Use baddcompound c\n"); + printf(" use baddcompound c\n"); return 0; } // @@ -80,10 +85,12 @@ Standard_Integer baddcompound (Draw_Interpretor& , Standard_Integer n, const cha //function : baddctools //purpose : //======================================================================= -Standard_Integer baddctools (Draw_Interpretor& , Standard_Integer n, const char** a) +Standard_Integer baddctools (Draw_Interpretor& , + Standard_Integer n, + const char** a) { if (n<2) { - printf(" Use baddctools c\n"); + printf(" use baddctools c\n"); return 0; } // @@ -106,10 +113,12 @@ Standard_Integer baddctools (Draw_Interpretor& , Standard_Integer n, const char* //function :baddobjects //purpose : //======================================================================= -Standard_Integer baddobjects (Draw_Interpretor& , Standard_Integer n, const char** a) +Standard_Integer baddobjects (Draw_Interpretor& , + Standard_Integer n, + const char** a) { if (n<2) { - printf(" Use baddobjects s1 s2 ...\n"); + printf(" use baddobjects s1 s2 ...\n"); return 0; } // @@ -128,10 +137,12 @@ Standard_Integer baddobjects (Draw_Interpretor& , Standard_Integer n, const char //function : bclearobjects //purpose : //======================================================================= -Standard_Integer bclearobjects (Draw_Interpretor& , Standard_Integer n, const char** ) +Standard_Integer bclearobjects (Draw_Interpretor& , + Standard_Integer n, + const char** ) { if (n!=1) { - printf(" Use bclearobjects\n"); + printf(" use bclearobjects\n"); return 0; } BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes(); @@ -143,10 +154,12 @@ Standard_Integer bclearobjects (Draw_Interpretor& , Standard_Integer n, const ch //function : baddtools //purpose : //======================================================================= -Standard_Integer baddtools (Draw_Interpretor& , Standard_Integer n, const char** a) +Standard_Integer baddtools (Draw_Interpretor& , + Standard_Integer n, + const char** a) { if (n<2) { - printf(" Use baddtools s1 s2 ...\n"); + printf(" use baddtools s1 s2 ...\n"); return 0; } // @@ -165,10 +178,12 @@ Standard_Integer baddtools (Draw_Interpretor& , Standard_Integer n, const char** //function : bcleartools //purpose : //======================================================================= -Standard_Integer bcleartools (Draw_Interpretor& , Standard_Integer n, const char** ) +Standard_Integer bcleartools (Draw_Interpretor& , + Standard_Integer n, + const char** ) { if (n!=1) { - printf(" Use bcleartools\n"); + printf(" use bcleartools\n"); return 0; } BOPCol_ListOfShape& aLS=BOPTest_Objects::Tools(); @@ -176,3 +191,19 @@ Standard_Integer bcleartools (Draw_Interpretor& , Standard_Integer n, const char // return 0; } +//======================================================================= +//function : bclear +//purpose : +//======================================================================= +Standard_Integer bclear(Draw_Interpretor& di, + Standard_Integer n, + const char** ) +{ + if (n!=1) { + di << " use bclear\n"; + return 0; + } + // + BOPTest_Objects::Clear(); + return 0; +} diff --git a/src/BOPTest/BOPTest_OptionCommands.cxx b/src/BOPTest/BOPTest_OptionCommands.cxx index 3176dd1e15..82505ab3a7 100644 --- a/src/BOPTest/BOPTest_OptionCommands.cxx +++ b/src/BOPTest/BOPTest_OptionCommands.cxx @@ -25,6 +25,7 @@ static Standard_Integer boptions (Draw_Interpretor&, Standard_Integer, const char**); static Standard_Integer brunparallel (Draw_Interpretor&, Standard_Integer, const char**); static Standard_Integer bfuzzyvalue (Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer bparallelmode(Draw_Interpretor&, Standard_Integer, const char**); //======================================================================= //function : OptionCommands @@ -36,11 +37,15 @@ void BOPTest::OptionCommands(Draw_Interpretor& theCommands) if (done) return; done = Standard_True; // Chapter's name - const char* g = "Partition commands"; + const char* g = "BOPTest commands"; // Commands theCommands.Add("boptions", "use boptions" , __FILE__, boptions, g); theCommands.Add("brunparallel", "use brunparallel [0/1]" , __FILE__, brunparallel, g); theCommands.Add("bfuzzyvalue", "use bfuzzyvalue value" , __FILE__, bfuzzyvalue, g); + theCommands.Add("bparallelmode", + "bparallelmode [1/0] : show / set parallel mode for boolean operations", + __FILE__, bparallelmode, g); + } //======================================================================= //function : boptions @@ -121,3 +126,30 @@ Standard_Integer brunparallel(Draw_Interpretor& di, // return 0; } +//======================================================================= +//function : bparallelmode +//purpose : +//======================================================================= +Standard_Integer bparallelmode(Draw_Interpretor& di, + Standard_Integer n, + const char** a) +{ + Standard_Boolean bRunParallel; + // + if (n == 2) { + bRunParallel=(Standard_Boolean)Draw::Atoi(a[1]); + BOPTest_Objects::SetRunParallel(bRunParallel); + if (bRunParallel) { + di << "Parallel mode for boolean operations has been enabled"; + } + else { + di << "Parallel mode for boolean operations has been disabled"; + } + } + else { + bRunParallel=BOPTest_Objects::RunParallel(); + di << "Parallel mode state for boolean operations: " + << (bRunParallel? "enabled" : "disabled"); + } + return 0; +} diff --git a/src/BOPTest/BOPTest_PartitionCommands.cxx b/src/BOPTest/BOPTest_PartitionCommands.cxx index d13302afe4..d8d69ce0c4 100644 --- a/src/BOPTest/BOPTest_PartitionCommands.cxx +++ b/src/BOPTest/BOPTest_PartitionCommands.cxx @@ -40,7 +40,6 @@ static Standard_Integer bfillds (Draw_Interpretor&, Standard_Integer, const char**); static Standard_Integer bbuild (Draw_Interpretor&, Standard_Integer, const char**); static Standard_Integer bbop (Draw_Interpretor&, Standard_Integer, const char**); -static Standard_Integer bclear (Draw_Interpretor&, Standard_Integer, const char**); //======================================================================= //function : PartitionCommands @@ -52,28 +51,11 @@ void BOPTest::PartitionCommands(Draw_Interpretor& theCommands) if (done) return; done = Standard_True; // Chapter's name - const char* g = "Partition commands"; + const char* g = "BOPTest commands"; // Commands - theCommands.Add("bfillds", "use bfillds [-s -t] [tol]" , __FILE__, bfillds, g); - theCommands.Add("bbuild" , "use bbuild r [-s -t]" , __FILE__, bbuild, g); - theCommands.Add("bbop" , "use bbop r op [-s -t]" , __FILE__, bbop, g); - theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g); -} -//======================================================================= -//function : bclear -//purpose : -//======================================================================= -Standard_Integer bclear(Draw_Interpretor& di, - Standard_Integer n, - const char** ) -{ - if (n!=1) { - di << " use bclear\n"; - return 0; - } - // - BOPTest_Objects::Clear(); - return 0; + 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); } //======================================================================= //function : bfillds @@ -83,8 +65,8 @@ Standard_Integer bfillds(Draw_Interpretor& di, Standard_Integer n, const char** a) { - if (n > 4) { - di << " use bfillds [-s -t] [tol]\n"; + if (n > 2) { + di << " use bfillds [-t]\n"; return 0; } // @@ -94,7 +76,7 @@ Standard_Integer bfillds(Draw_Interpretor& di, Standard_Real aTol; BOPCol_ListIteratorOfListOfShape aIt; BOPCol_ListOfShape aLC; - BOPTime_Chronometer aChrono; + BOPTest_Chronometer aChrono; BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes(); aNbS=aLS.Extent(); @@ -109,15 +91,9 @@ Standard_Integer bfillds(Draw_Interpretor& di, aTol=BOPTest_Objects::FuzzyValue(); // for (i=1; i4) { @@ -285,10 +258,7 @@ Standard_Integer bbop(Draw_Interpretor& di, bShowTime=Standard_False; bRunParallel=BOPTest_Objects::RunParallel(); for (i=3; i #include -static - Standard_Integer breducetolerance (Draw_Interpretor&, Standard_Integer, const char** ); -static - Standard_Integer btolx (Draw_Interpretor&, Standard_Integer, const char** ); -static - Standard_Integer bopaddpcs (Draw_Interpretor&, Standard_Integer, const char** ); + // static void ProcessVertex(const TopoDS_Vertex&, @@ -76,9 +71,16 @@ static void ReduceFaceTolerance (const TopoDS_Shape&); static - void ReduceEdgeTolerance (const TopoDS_Shape&, const Standard_Real); - + void ReduceEdgeTolerance (const TopoDS_Shape&, + const Standard_Real); +static + void PreparePCurves(const TopoDS_Shape& , + Draw_Interpretor& di); +// +static Standard_Integer breducetolerance (Draw_Interpretor&, Standard_Integer, const char** ); +static Standard_Integer btolx (Draw_Interpretor&, Standard_Integer, const char** ); +static Standard_Integer bopaddpcs (Draw_Interpretor&, Standard_Integer, const char** ); //======================================================================= //function : TolerCommands //purpose : @@ -91,28 +93,32 @@ static done = Standard_True; // Chapter's name - const char* g = "CCR commands"; + const char* g = "BOPTest commands"; // - theCommands.Add("breducetolerance" , "Use >breducetolerance Shape [maxTol=0.01]", __FILE__, breducetolerance, g); - theCommands.Add("btolx" , "Use >btolx Shape [minTol=1.e-7]", __FILE__, btolx, g); - theCommands.Add("bopaddpcs" , "Use >bopaddpcs Shape" , __FILE__, bopaddpcs, g); + theCommands.Add("breducetolerance" , "use breducetolerance Shape", + __FILE__, breducetolerance, g); + theCommands.Add("btolx" , "use btolx Shape [minTol=1.e-7]", + __FILE__, btolx, g); + theCommands.Add("bopaddpcs" , "Use >bopaddpcs Shape", + __FILE__, bopaddpcs, g); } - //======================================================================= //function : btolx //purpose : //======================================================================= -Standard_Integer btolx(Draw_Interpretor& di, Standard_Integer n, const char** a) +Standard_Integer btolx(Draw_Interpretor& di, + Standard_Integer n, + const char** a) { if (n<2) { - di << " Use >btolx Shape [minTol=1.e-7]\n"; + di << " use btolx Shape [minTol=1.e-7]\n"; return 1; } TopoDS_Shape aS = DBRep::Get(a[1]); if (aS.IsNull()) { - di << " Null shape is not allowed \n"; + di << " Null shape is not allowed\n"; return 1; } // @@ -139,7 +145,8 @@ Standard_Integer btolx(Draw_Interpretor& di, Standard_Integer n, const char** //function : ReduceEdgeTolerance //purpose : //======================================================================= -void ReduceEdgeTolerance (const TopoDS_Shape& aS, const Standard_Real aTolTreshold) +void ReduceEdgeTolerance (const TopoDS_Shape& aS, + const Standard_Real aTolTreshold) { Standard_Integer i, aNbE; TopTools_IndexedMapOfShape aEMap; @@ -178,7 +185,7 @@ void ReduceFaceTolerance (const TopoDS_Shape& aS) const TopoDS_Edge& aE= TopoDS::Edge(aEMap(j)); aTolE =BRep_Tool::Tolerance(aE); if (aTolEaTolEMin) ? aTolx : aTolEMin; @@ -193,7 +200,7 @@ void ReduceVertexTolerance (const TopoDS_Shape& aS) { Standard_Integer i, aNbV; TopTools_IndexedDataMapOfShapeListOfShape aVEMap, aVFMap; - + TopExp::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_EDGE, aVEMap); TopExp::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_FACE, aVFMap); @@ -248,25 +255,25 @@ void ProcessEdge(const TopoDS_Edge& aE, const Standard_Real aTolTreshold) else if (cr->IsCurveOnSurface()) { const Handle(Geom2d_Curve)& aC2D = cr->PCurve(); if (aC2D.IsNull()) { - continue; + continue; } // Surface const Handle(Geom_Surface)& aS=cr->Surface(); // // 2D-point treatment for (i=0; i<=aNb; ++i) { - aT=aT1+i*dT; - if (i==aNb) { - aT=aT2; - } - aPC3D=aC3D->Value(aT); - aPC2D=aC2D->Value(aT); - aS->D0(aPC2D.X(), aPC2D.Y(), aP3D); - aP3D.Transform(L.Transformation()); - aD2=aPC3D.SquareDistance(aP3D); - if (aD2 > aTolMax2) { - aTolMax2=aD2; - } + aT=aT1+i*dT; + if (i==aNb) { + aT=aT2; + } + aPC3D=aC3D->Value(aT); + aPC2D=aC2D->Value(aT); + aS->D0(aPC2D.X(), aPC2D.Y(), aP3D); + aP3D.Transform(L.Transformation()); + aD2=aPC3D.SquareDistance(aP3D); + if (aD2 > aTolMax2) { + aTolMax2=aD2; + } } } //if (cr->IsCurveOnSurface()) }//for (; itcr.More(); itcr.Next()) @@ -292,8 +299,8 @@ void ProcessEdge(const TopoDS_Edge& aE, const Standard_Real aTolTreshold) //purpose : //======================================================================= void ProcessVertex(const TopoDS_Vertex& aV, - const TopTools_ListOfShape& aLE, - const TopTools_ListOfShape& aLF) + const TopTools_ListOfShape& aLE, + const TopTools_ListOfShape& aLF) { Standard_Real aTol, aD2, aTolMax2, aTolE, aParam; gp_Pnt aPC3D; @@ -319,7 +326,7 @@ void ProcessVertex(const TopoDS_Vertex& aV, if (aProcessedEdges.Contains(aE)) { continue; } - aProcessedEdges.Add(aE); + aProcessedEdges.Add(aE); // Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&aE.TShape()); const TopLoc_Location& Eloc = aE.Location(); @@ -329,59 +336,59 @@ void ProcessVertex(const TopoDS_Vertex& aV, const TopoDS_Vertex& aVx=TopoDS::Vertex(aVExp.Current()); // if (!aVx.IsSame(aV)) { - continue; + continue; } // anOrV=aVx.Orientation(); if (!(anOrV==TopAbs_FORWARD || anOrV==TopAbs_REVERSED)) { - continue; + continue; } // const BRep_ListOfCurveRepresentation& aLCR=TE->Curves(); itcr.Initialize(aLCR); for (; itcr.More(); itcr.Next()) { - const Handle(BRep_CurveRepresentation)& cr = itcr.Value(); - const TopLoc_Location& loc = cr->Location(); - TopLoc_Location L = (Eloc * loc).Predivided(aV.Location()); - // - // 3D-Curve - if (cr->IsCurve3D()) { - const Handle(Geom_Curve)& aC3D = cr->Curve3D(); - // - if (aC3D.IsNull()) { - continue; - } - // 3D-point treatment - aParam=BRep_Tool::Parameter(aVx, aE); - aPC3D= aC3D->Value(aParam); - aPC3D.Transform(L.Transformation()); - aD2=aPV3D.SquareDistance(aPC3D); - if (aD2 > aTolMax2) { - aTolMax2=aD2; - } - // - }//if (cr->IsCurve3D()) - // - // 2D-Curve - else if (cr->IsCurveOnSurface()) { - const Handle(Geom2d_Curve)& aC2D = cr->PCurve(); - if (aC2D.IsNull()) { - continue; - } - // Surface - const Handle(Geom_Surface)& aS=cr->Surface(); - // - // 2D-point treatment - aParam=BRep_Tool::Parameter(aVx, aE, aS, L); - aPC2D=aC2D->Value(aParam); - aS->D0(aPC2D.X(), aPC2D.Y(), aPC3D); - aPC3D.Transform(L.Transformation()); - aD2=aPV3D.SquareDistance(aPC3D); - if (aD2 > aTolMax2) { - aTolMax2=aD2; - } - } //if (cr->IsCurveOnSurface()) - + const Handle(BRep_CurveRepresentation)& cr = itcr.Value(); + const TopLoc_Location& loc = cr->Location(); + TopLoc_Location L = (Eloc * loc).Predivided(aV.Location()); + // + // 3D-Curve + if (cr->IsCurve3D()) { + const Handle(Geom_Curve)& aC3D = cr->Curve3D(); + // + if (aC3D.IsNull()) { + continue; + } + // 3D-point treatment + aParam=BRep_Tool::Parameter(aVx, aE); + aPC3D= aC3D->Value(aParam); + aPC3D.Transform(L.Transformation()); + aD2=aPV3D.SquareDistance(aPC3D); + if (aD2 > aTolMax2) { + aTolMax2=aD2; + } + // + }//if (cr->IsCurve3D()) + // + // 2D-Curve + else if (cr->IsCurveOnSurface()) { + const Handle(Geom2d_Curve)& aC2D = cr->PCurve(); + if (aC2D.IsNull()) { + continue; + } + // Surface + const Handle(Geom_Surface)& aS=cr->Surface(); + // + // 2D-point treatment + aParam=BRep_Tool::Parameter(aVx, aE, aS, L); + aPC2D=aC2D->Value(aParam); + aS->D0(aPC2D.X(), aPC2D.Y(), aPC3D); + aPC3D.Transform(L.Transformation()); + aD2=aPV3D.SquareDistance(aPC3D); + if (aD2 > aTolMax2) { + aTolMax2=aD2; + } + } //if (cr->IsCurveOnSurface()) + }//for (; itcr.More(); itcr.Next()) }//for (; aVExp.More(); aVExp.Next()) }//for (; anIt.More(); anIt.Next()) @@ -441,11 +448,11 @@ void ProcessVertex(const TopoDS_Vertex& aV, //purpose : //======================================================================= Standard_Integer breducetolerance(Draw_Interpretor& di, - Standard_Integer n, - const char** a) + Standard_Integer n, + const char** a) { if (n<2) { - di << " Use >bupdatetolerance Shape\n"; + di << " use bupdatetolerance Shape\n"; return 1; } @@ -461,18 +468,17 @@ Standard_Integer breducetolerance(Draw_Interpretor& di, return 0; } // -// -static - void PreparePCurves(const TopoDS_Shape& aShape, Draw_Interpretor& di); - //======================================================================= //function : bopaddpcs -//purpose : Some Edgesdo not contain P-Curveson Faces to which they belong to. +//purpose : Some Edges do not contain P-Curves on Faces to which +// they belong to. // These faces usually based on Geom_Plane surface. // To prevent sophisticated treatment the Command "bopaddpcs: // adds P-Curves for the edges . //======================================================================= -Standard_Integer bopaddpcs(Draw_Interpretor& di, Standard_Integer n, const char** a) +Standard_Integer bopaddpcs(Draw_Interpretor& di, + Standard_Integer n, + const char** a) { if (n<2) { di << " Use >bopaddpcs Shape\n"; @@ -491,7 +497,6 @@ Standard_Integer bopaddpcs(Draw_Interpretor& di, Standard_Integer n, const cha DBRep::Set (a[1], aS); return 0; } - //======================================================================= //function : PreparePCurves //purpose : @@ -534,26 +539,26 @@ void PreparePCurves(const TopoDS_Shape& aShape, Draw_Interpretor& di) BRep_ListIteratorOfListOfCurveRepresentation itcr; itcr.Initialize(aLCR); for (; itcr.More(); itcr.Next()) { - const Handle(BRep_CurveRepresentation)& cr = itcr.Value(); - // - if (cr->IsCurveOnSurface()) { - const Handle(Geom_Surface)& aSCR=cr->Surface(); - aSCRMap.Add(aSCR); - } - // + const Handle(BRep_CurveRepresentation)& cr = itcr.Value(); + // + if (cr->IsCurveOnSurface()) { + const Handle(Geom_Surface)& aSCR=cr->Surface(); + aSCRMap.Add(aSCR); + } + // } // const Handle(Geom_Surface)& aS=BRep_Tool::Surface(aF, aLoc); if (!aSCRMap.Contains(aS)) { - // try to obtain 2D curve - aC2D=BRep_Tool::CurveOnSurface(aE, aS, aLoc, aT1, aT2); - if (aC2D.IsNull()) { - di << " Warning: Can not obtain P-Curve\n"; - continue; - } - else { - aBB.UpdateEdge(aE, aC2D, aF, aTolE); - } + // try to obtain 2D curve + aC2D=BRep_Tool::CurveOnSurface(aE, aS, aLoc, aT1, aT2); + if (aC2D.IsNull()) { + di << " Warning: Can not obtain P-Curve\n"; + continue; + } + else { + aBB.UpdateEdge(aE, aC2D, aF, aTolE); + } } } } diff --git a/tests/bugs/modalg_5/bug25477_1 b/tests/bugs/modalg_5/bug25477_1 index f62520aa30..bf5c3ff55b 100644 --- a/tests/bugs/modalg_5/bug25477_1 +++ b/tests/bugs/modalg_5/bug25477_1 @@ -9,7 +9,8 @@ puts "" box b1 10 10 10 box b2 10.00001 0 0 10 10 10 -bop b1 b2 0.00002 +bfuzzyvalue 0.00002 +bop b1 b2 bopfuse result set nb_v_good 12 diff --git a/tests/bugs/modalg_5/bug25477_2 b/tests/bugs/modalg_5/bug25477_2 index 8158f3fc5b..6bc87682a1 100644 --- a/tests/bugs/modalg_5/bug25477_2 +++ b/tests/bugs/modalg_5/bug25477_2 @@ -15,6 +15,7 @@ bclearobjects bcleartools baddobjects b1 baddtools b2 -bfillds 5.e-5 +bfuzzyvalue 5.e-5 +bfillds bbop res 2 checkshape res