diff --git a/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx b/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx index 3326863a2d..113d41cb6b 100644 --- a/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx +++ b/src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx @@ -16,12 +16,13 @@ #include #include -#include -#include -#include -#include -#include + +#include + #include + +#include + #include #include #include @@ -29,34 +30,34 @@ #include #include #include + +#include +#include + +#include +#include + +#include +// #include #include #include -#include - #include #include #include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - #include #include #include -#include -#include + +#include +#include + +#include +#include +#include // ================================================================================ // function: Constructor @@ -302,145 +303,57 @@ void BOPAlgo_ArgumentAnalyzer::TestTypes() //======================================================================= void BOPAlgo_ArgumentAnalyzer::TestSelfInterferences() { - Standard_Integer ii=0, j; - Standard_Boolean bSelfInt; - + Standard_Integer ii; + // for(ii = 0; ii < 2; ii++) { const TopoDS_Shape& aS = (ii == 0) ? myShape1 : myShape2; - if(aS.IsNull()) { continue; } - + // Standard_Boolean bIsEmpty = (ii == 0) ? myEmpty1 : myEmpty2; if (bIsEmpty) { continue; } - - BOPAlgo_CheckerSI aChecker; + // + Standard_Integer iErr, n1, n2; + BOPDS_MapIteratorMapOfPassKey aItMPK; BOPCol_ListOfShape anArgs; + BOPAlgo_CheckerSI aChecker; // anArgs.Append(aS); aChecker.SetArguments(anArgs); // aChecker.Perform(); - Standard_Integer iErr = aChecker.ErrorStatus(); + iErr=aChecker.ErrorStatus(); // - const BOPDS_PDS& theDS = aChecker.PDS(); - BOPDS_VectorOfInterfVV& aVVs=theDS->InterfVV(); - BOPDS_VectorOfInterfVE& aVEs=theDS->InterfVE(); - BOPDS_VectorOfInterfEE& aEEs=theDS->InterfEE(); - BOPDS_VectorOfInterfVF& aVFs=theDS->InterfVF(); - BOPDS_VectorOfInterfEF& aEFs=theDS->InterfEF(); - BOPDS_VectorOfInterfFF& aFFs=theDS->InterfFF(); - BOPDS_VectorOfInterfVZ& aVZs=theDS->InterfVZ(); - BOPDS_VectorOfInterfEZ& aEZs=theDS->InterfEZ(); - BOPDS_VectorOfInterfFZ& aFZs=theDS->InterfFZ(); - BOPDS_VectorOfInterfZZ& aZZs=theDS->InterfZZ(); + const BOPDS_DS& aDS=*(aChecker.PDS()); + const BOPDS_MapOfPassKey& aMPK=aDS.Interferences(); // - Standard_Integer aNbTypeInt, aTypeInt, i, nI1, nI2; - Standard_Integer aNb[] = { - aVVs.Extent(), aVEs.Extent(), aEEs.Extent(), - aVFs.Extent(), aEFs.Extent(), aFFs.Extent(), - aVZs.Extent(), aEZs.Extent(), aFZs.Extent(), - aZZs.Extent() - }; - // - BOPDS_Interf* aInt=NULL; - // - aNbTypeInt=BOPDS_DS::NbInterfTypes(); - for (aTypeInt = 0; aTypeInt < aNbTypeInt; ++aTypeInt) { - for (i = 0; i < aNb[aTypeInt]; ++i) { - switch(aTypeInt) { - case 0: - aInt=(BOPDS_Interf*)(&aVVs(i)); - break; - case 1: - aInt=(BOPDS_Interf*)(&aVEs(i)); - break; - case 2: - aInt=(BOPDS_Interf*)(&aEEs(i)); - break; - case 3: - aInt=(BOPDS_Interf*)(&aVFs(i)); - break; - case 4: - aInt=(BOPDS_Interf*)(&aEFs(i)); - break; - case 5: - aInt=(BOPDS_Interf*)(&aFFs(i)); - break; - case 6: - aInt=(BOPDS_Interf*)(&aVZs(i)); - break; - case 7: - aInt=(BOPDS_Interf*)(&aEZs(i)); - break; - case 8: - aInt=(BOPDS_Interf*)(&aFZs(i)); - break; - case 9: - aInt=(BOPDS_Interf*)(&aZZs(i)); - break; - default: - aInt=NULL; - } - // - aInt->Indices(nI1, nI2); - if (nI1 == nI2) { - continue; - } - if (theDS->IsNewShape(nI1) || theDS->IsNewShape(nI2)) { - continue; - } - // - if (aTypeInt == 4) { - BOPDS_InterfEF& aEF=aEFs(i); - if (aEF.CommonPart().Type()==TopAbs_SHAPE) { - continue; - } - } - // - const TopoDS_Shape& aS1 = theDS->Shape(nI1); - const TopoDS_Shape& aS2 = theDS->Shape(nI2); - // - if (aTypeInt == 5) { - bSelfInt = Standard_False; - BOPDS_InterfFF& aFF = aFFs(i); - BOPDS_VectorOfPoint& aVP=aFF.ChangePoints(); - Standard_Integer aNbP=aVP.Extent(); - BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves(); - Standard_Integer aNbC=aVC.Extent(); - if (!aNbP && !aNbC) { - continue; - } - for (j=0; j -#include -#include +#include +#include +#include + +#include #include #include #include +#include #include - -#include -#include - #include -#include - -#include #include #include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include -static - Standard_Integer bopcheck (Draw_Interpretor&, Standard_Integer, const char** ); - -static - Standard_Integer bopargcheck (Draw_Interpretor&, Standard_Integer, const char** ); +#include // +static + void MakeShapeForFullOutput (const TCollection_AsciiString&, + const Standard_Integer, + const BOPCol_ListOfShape&, + Standard_Integer& , + Draw_Interpretor&); +// +static Standard_Integer bopcheck (Draw_Interpretor&, Standard_Integer, const char** ); +static Standard_Integer bopargcheck(Draw_Interpretor&, Standard_Integer, const char** ); //======================================================================= //function : CheckCommands //purpose : //======================================================================= - void BOPTest::CheckCommands(Draw_Interpretor& theCommands) +void BOPTest::CheckCommands(Draw_Interpretor& theCommands) { static Standard_Boolean done = Standard_False; if (done) @@ -78,16 +70,71 @@ static "Use bopargcheck without parameters to get ", __FILE__, bopargcheck, g); } - +//======================================================================= +//class : BOPTest_Interf +//purpose : Auxiliary class +//======================================================================= +class BOPTest_Interf { + public: + BOPTest_Interf() : myIndex1(-1), myIndex2(-1), myType(-1) { + } + // + ~BOPTest_Interf() { + } + // + void SetIndices(const Standard_Integer theIndex1, + const Standard_Integer theIndex2) { + myIndex1=theIndex1; + myIndex2=theIndex2; + } + // + void Indices(Standard_Integer& theIndex1, + Standard_Integer& theIndex2) const { + theIndex1=myIndex1; + theIndex2=myIndex2; + } + // + void SetType(const Standard_Integer theType) { + myType=theType; + } + // + Standard_Integer Type() const { + return myType; + } + // + bool operator < (const BOPTest_Interf& aOther) const { + bool bFlag; + // + if (myType==aOther.myType) { + if (myIndex1 == aOther.myIndex1) { + bFlag=(myIndex2 < aOther.myIndex2); + } + else { + bFlag=(myIndex1 < aOther.myIndex1); + } + } + else { + bFlag=(myType < aOther.myType); + } + // + return bFlag; + } + // + protected: + Standard_Integer myIndex1; + Standard_Integer myIndex2; + Standard_Integer myType; +}; //======================================================================= //function : bopcheck //purpose : //======================================================================= -Standard_Integer bopcheck - (Draw_Interpretor& di, Standard_Integer n, const char** a ) +Standard_Integer bopcheck (Draw_Interpretor& di, + Standard_Integer n, + const char** a ) { if (n<2) { - di << " Use >bopcheck Shape [level of check: 0 - 9" << "\n"; + di << " Use > bopcheck Shape [level of check: 0 - 9] [-t -s]" << "\n"; di << " The level of check defines "; di << " which interferences will be checked:\n"; di << " 0 - V/V only\n"; @@ -110,28 +157,53 @@ Standard_Integer bopcheck return 1; } // - Standard_Integer theLevelOfCheck, aNbInterfTypes; + Standard_Boolean bRunParallel, bShowTime; + Standard_Integer i, aLevel, aNbInterfTypes; // aNbInterfTypes=BOPDS_DS::NbInterfTypes(); // - theLevelOfCheck = (n==3) ? Draw::Atoi(a[2]) : aNbInterfTypes-1; - if (theLevelOfCheck > aNbInterfTypes-1) { + aLevel=aNbInterfTypes-1; + // + if (n>2) { + aLevel=Draw::Atoi(a[2]); + } + // + if (aLevel < 0 || aLevel > aNbInterfTypes-1) { di << "Invalid level"; return 1; } + // + bShowTime=Standard_False; + bRunParallel=Standard_True; + for (i=3; i= 0 && theLevelOfCheck < (aNbInterfTypes-1)) { + Standard_Integer iErr, iCnt, n1, n2, iT; + TopAbs_ShapeEnum aType1, aType2; + BOPAlgo_CheckerSI aChecker; + BOPCol_ListOfShape aLS; + BOPDS_MapIteratorMapOfPassKey aItMPK; + BOPTime_Chronometer aChrono; + // + if (aLevel < (aNbInterfTypes-1)) { di << "Info:\nThe level of check is set to " - << type[theLevelOfCheck] << ", i.e. intersection(s)\n"; - for (i=theLevelOfCheck+1; iInterfVV(); - BOPDS_VectorOfInterfVE& aVEs=theDS->InterfVE(); - BOPDS_VectorOfInterfEE& aEEs=theDS->InterfEE(); - BOPDS_VectorOfInterfVF& aVFs=theDS->InterfVF(); - BOPDS_VectorOfInterfEF& aEFs=theDS->InterfEF(); - BOPDS_VectorOfInterfFF& aFFs=theDS->InterfFF(); - BOPDS_VectorOfInterfVZ& aVZs=theDS->InterfVZ(); - BOPDS_VectorOfInterfEZ& aEZs=theDS->InterfEZ(); - BOPDS_VectorOfInterfFZ& aFZs=theDS->InterfFZ(); - BOPDS_VectorOfInterfZZ& aZZs=theDS->InterfZZ(); + aChrono.Stop(); // - Standard_Integer aNb[] ={ - aVVs.Extent(), aVEs.Extent(), aEEs.Extent(), - aVFs.Extent(), aEFs.Extent(), aFFs.Extent(), - aVZs.Extent(), aEZs.Extent(), aFZs.Extent(), - aZZs.Extent(), - }; + iErr=aChecker.ErrorStatus(); // - bSelfInt = Standard_False; - ind = 0; - for (aTypeInt = 0; aTypeInt < aNbInterfTypes; ++aTypeInt) { - - for (i = 0; i < aNb[aTypeInt]; ++i) { - BOPDS_Interf* aInt=NULL; - // - switch(aTypeInt) { - case 0: - aInt=(BOPDS_Interf*)(&aVVs(i)); - break; - case 1: - aInt=(BOPDS_Interf*)(&aVEs(i)); - break; - case 2: - aInt=(BOPDS_Interf*)(&aEEs(i)); - break; - case 3: - aInt=(BOPDS_Interf*)(&aVFs(i)); - break; - case 4: - aInt=(BOPDS_Interf*)(&aEFs(i)); - break; - case 5: - aInt=(BOPDS_Interf*)(&aFFs(i)); - break; - case 6: - aInt=(BOPDS_Interf*)(&aVZs(i)); - break; - case 7: - aInt=(BOPDS_Interf*)(&aEZs(i)); - break; - case 8: - aInt=(BOPDS_Interf*)(&aFZs(i)); - break; - case 9: - aInt=(BOPDS_Interf*)(&aZZs(i)); - break; - default: - break; - } - // - nI1 = aInt->Index1(); - nI2 = aInt->Index2(); - if (nI1 == nI2) { - continue; - } - // - if(theDS->IsNewShape(nI1) || theDS->IsNewShape(nI2)) { - continue; - } - // - if (aTypeInt == 4) { - BOPDS_InterfEF& aEF=aEFs(i); - if (aEF.CommonPart().Type()==TopAbs_SHAPE) { - continue; - } - } - // - const TopoDS_Shape& aS1 = theDS->Shape(nI1); - const TopoDS_Shape& aS2 = theDS->Shape(nI2); - // - if (aTypeInt == 5) { - bFFInt = Standard_False; - BOPDS_InterfFF& aFF = aFFs(i); - BOPDS_VectorOfPoint& aVP=aFF.ChangePoints(); - Standard_Integer aNbP=aVP.Extent(); - BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves(); - Standard_Integer aNbC=aVC.Extent(); - if (!aNbP && !aNbC) { - continue; - } - for (j=0; j aVec; + vector ::iterator aIt; + BOPTest_Interf aBInterf; + // + aItMPK.Initialize(aMPK); + for (; aItMPK.More(); aItMPK.Next()) { + const BOPDS_PassKey& aPK=aItMPK.Value(); + aPK.Ids(n1, n2); + if(aDS.IsNewShape(n1) || aDS.IsNewShape(n2)) { + continue; } + // + const BOPDS_ShapeInfo& aSI1=aDS.ShapeInfo(n1); + const BOPDS_ShapeInfo& aSI2=aDS.ShapeInfo(n2); + aType1=aSI1.ShapeType(); + aType2=aSI2.ShapeType(); + // + iT=BOPDS_Tools::TypeToInteger(aType1, aType2); + // + aBInterf.SetIndices(n1, n2); + aBInterf.SetType(iT); + // + aVec.push_back(aBInterf); + } + // + sort( aVec.begin(), aVec.end(), less()); + // + iCnt=0; + for (aIt=aVec.begin(); aIt!=aVec.end(); aIt++) { + const BOPTest_Interf& aBI=*aIt; + // + aBI.Indices(n1, n2); + if(aDS.IsNewShape(n1) || aDS.IsNewShape(n2)) { + continue; + } + // + const TopoDS_Shape& aS1=aDS.Shape(n1); + const TopoDS_Shape& aS2=aDS.Shape(n2); + // + iT=aBI.Type(); + di << aInterfTypes[iT] << ": "; + // + sprintf(aName1, "x%d", n1); + //sprintf(aName1, "x%d", iCnt); + DBRep::Set (aName1, aS1); + // + ++iCnt; + sprintf(aName2, "x%d", n2); + //sprintf(aName2, "x%d", iCnt); + DBRep::Set (aName2, aS2); + ++iCnt; + // + sprintf(buf, "%s %s \n", aName1, aName2); + di << buf; } // if (iErr) { @@ -278,48 +290,25 @@ Standard_Integer bopcheck di << "so the list may be incomplete." << "\n"; } // - if (!bSelfInt) { + if (!iCnt) { di << " This shape seems to be OK." << "\n"; } + if (bShowTime) { + Standard_Real aTime; + // + aTime=aChrono.Time(); + Sprintf(buf, " Tps: %7.2lf\n", aTime); + di << buf; + } return 0; } - -//======================================================================= -//function : MakeShapeForFullOutput -//purpose : -//======================================================================= -static void MakeShapeForFullOutput - (const TCollection_AsciiString & aBaseName, - const Standard_Integer aIndex, - const BOPCol_ListOfShape & aList, - Standard_Integer& aCount, - Draw_Interpretor& di) -{ - TCollection_AsciiString aNum(aIndex); - TCollection_AsciiString aName = aBaseName + aNum; - Standard_CString name = aName.ToCString(); - - TopoDS_Compound cmp; - BRep_Builder BB; - BB.MakeCompound(cmp); - - BOPCol_ListIteratorOfListOfShape anIt(aList); - for(; anIt.More(); anIt.Next()) { - const TopoDS_Shape & aS = anIt.Value(); - BB.Add(cmp, aS); - aCount++; - } - di << "Made faulty shape: " << name << "\n"; - DBRep::Set(name, cmp); -} - - //======================================================================= //function : bopargcheck //purpose : //======================================================================= -Standard_Integer bopargcheck - (Draw_Interpretor& di, Standard_Integer n, const char** a ) +Standard_Integer bopargcheck (Draw_Interpretor& di, + Standard_Integer n, + const char** a ) { if (n<2) { di << "\n"; @@ -333,7 +322,7 @@ Standard_Integer bopargcheck di << " S (section)" << "\n"; di << " U (unknown)" << "\n"; di << " For example: \"bopargcheck s1 s2 -F\" enables" ; - di << "checking for Fuse operation" << "\n"; + di << " checking for Fuse operation" << "\n"; di << " default - section" << "\n" << "\n"; di << " /" << "\n"; di << " R (disable small edges (shrank range) test)" << "\n"; @@ -852,3 +841,30 @@ Standard_Integer bopargcheck return 0; } +//======================================================================= +//function : MakeShapeForFullOutput +//purpose : +//======================================================================= +void MakeShapeForFullOutput (const TCollection_AsciiString & aBaseName, + const Standard_Integer aIndex, + const BOPCol_ListOfShape & aList, + Standard_Integer& aCount, + Draw_Interpretor& di) +{ + TCollection_AsciiString aNum(aIndex); + TCollection_AsciiString aName = aBaseName + aNum; + Standard_CString name = aName.ToCString(); + + TopoDS_Compound cmp; + BRep_Builder BB; + BB.MakeCompound(cmp); + + BOPCol_ListIteratorOfListOfShape anIt(aList); + for(; anIt.More(); anIt.Next()) { + const TopoDS_Shape & aS = anIt.Value(); + BB.Add(cmp, aS); + aCount++; + } + di << "Made faulty shape: " << name << "\n"; + DBRep::Set(name, cmp); +} diff --git a/src/BOPTest/BOPTest_Chronometer.hxx b/src/BOPTest/BOPTest_Chronometer.hxx new file mode 100644 index 0000000000..e51aa2f688 --- /dev/null +++ b/src/BOPTest/BOPTest_Chronometer.hxx @@ -0,0 +1,83 @@ +// Created by: Peter KURNEV +// Copyright (c) 2010-2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#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 +//purpose : +//======================================================================= +class BOPTime_Chronometer { + public: + BOPTime_Chronometer() { + } + // + ~BOPTime_Chronometer() { + } + // + void Start() { + myChronometer.Reset(); + myChronometer.Start(); + } + // + void Stop() { + myChronometer.Stop(); + myChronometer.Show(myTime); + } + // + double Time() const{ + return myTime; + }; + // + protected: + OSD_Chronometer myChronometer; + double myTime; +}; +#endif +// +#endif diff --git a/src/BOPTest/BOPTest_PartitionCommands.cxx b/src/BOPTest/BOPTest_PartitionCommands.cxx index d735a98b33..ea3794e76d 100644 --- a/src/BOPTest/BOPTest_PartitionCommands.cxx +++ b/src/BOPTest/BOPTest_PartitionCommands.cxx @@ -34,71 +34,7 @@ #include #include -// -#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 -//purpose : -//======================================================================= -class BOPTime_Chronometer { - public: - BOPTime_Chronometer() { - } - // - ~BOPTime_Chronometer() { - } - // - void Start() { - myChronometer.Reset(); - myChronometer.Start(); - } - // - void Stop() { - myChronometer.Stop(); - myChronometer.Show(myTime); - } - // - double Time() const{ - return myTime; - }; - // - protected: - OSD_Chronometer myChronometer; - double myTime; -}; -#endif +#include static Standard_Integer bfillds (Draw_Interpretor&, Standard_Integer, const char**); static Standard_Integer bbuild (Draw_Interpretor&, Standard_Integer, const char**); diff --git a/src/BOPTest/FILES b/src/BOPTest/FILES index f94d8f11a2..1a1377d86b 100755 --- a/src/BOPTest/FILES +++ b/src/BOPTest/FILES @@ -4,3 +4,4 @@ BOPTest_LowCommands.cxx BOPTest_CheckCommands.cxx BOPTest_TolerCommands.cxx BOPTest_ObjCommands.cxx +BOPTest_Chronometer.hxx diff --git a/tests/bugs/modalg_5/bug24029 b/tests/bugs/modalg_5/bug24029 index 0841d10551..1a7ac90dbe 100644 --- a/tests/bugs/modalg_5/bug24029 +++ b/tests/bugs/modalg_5/bug24029 @@ -14,13 +14,13 @@ set info1 [bopcheck c] set info2 [bopcheck c 4] set info3 [bopcheck c 3] -if { [regexp "x23" $info1] != 1 } { +if { [regexp "x35" $info1] != 1 } { puts "Error : bopcheck c works wrong" } else { puts "OK: bopcheck c works properly" } -if { [regexp "x11" $info2] != 1 || [regexp "F/F:x12," $info2] != 0 } { +if { [regexp "x13" $info2] != 1 || [regexp "x39" $info2] != 1 } { puts "Error : bopcheck c 4 works wrong" } else { puts "OK: bopcheck c 4 works properly" @@ -31,4 +31,3 @@ if { [regexp "This shape seems to be OK" $info3] != 1 } { } else { puts "OK: bopcheck c 3 works properly" } - diff --git a/tests/bugs/modalg_5/bug24764 b/tests/bugs/modalg_5/bug24764 index 0c622eaa1f..516f354b69 100755 --- a/tests/bugs/modalg_5/bug24764 +++ b/tests/bugs/modalg_5/bug24764 @@ -9,15 +9,7 @@ puts "" restore [locate_data_file bug24764_qa.brep] a bopcheck a 4 - -set N 16 -set qz {} - -lappend qz a -for {set i 0} {$i < $N} {incr i} { - lappend qz x${i} -} -eval compound $qz result +compound a x2 x51 x8 x10 x28 x30 x36 x46 x1 x50 result set nb_v_good 24 set nb_e_good 24