1 // Created by: Peter KURNEV
2 // Copyright (c) 2010-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <BOPTest.ixx>
21 #include <TCollection_AsciiString.hxx>
23 #include <TopExp_Explorer.hxx>
25 #include <TopTools_MapOfShape.hxx>
26 #include <TopTools_ShapeMapHasher.hxx>
28 #include <TopoDS_Shape.hxx>
29 #include <TopoDS_Compound.hxx>
30 #include <BRep_Builder.hxx>
31 #include <BRepBuilderAPI_Copy.hxx>
36 #include <BOPCol_ListOfShape.hxx>
38 #include <BOPDS_DS.hxx>
39 #include <BOPDS_MapOfPassKey.hxx>
41 #include <BOPAlgo_CheckerSI.hxx>
42 #include <BOPAlgo_ArgumentAnalyzer.hxx>
43 #include <BOPAlgo_CheckResult.hxx>
45 #include <BOPTools_AlgoTools.hxx>
47 #include <BOPTest_Chronometer.hxx>
50 void MakeShapeForFullOutput (const TCollection_AsciiString&,
51 const Standard_Integer,
52 const BOPCol_ListOfShape&,
55 Standard_Boolean bCurveOnSurf = Standard_False,
56 Standard_Real aMaxDist = 0.,
57 Standard_Real aMaxParameter = 0.);
59 static Standard_Integer bopcheck (Draw_Interpretor&, Standard_Integer, const char** );
60 static Standard_Integer bopargcheck(Draw_Interpretor&, Standard_Integer, const char** );
61 static Standard_Integer xdistef(Draw_Interpretor&, Standard_Integer, const char** );
62 static Standard_Integer checkcurveonsurf (Draw_Interpretor&, Standard_Integer, const char**);
64 //=======================================================================
65 //function : CheckCommands
67 //=======================================================================
68 void BOPTest::CheckCommands(Draw_Interpretor& theCommands)
70 static Standard_Boolean done = Standard_False;
76 const char* g = "CCR commands";
78 theCommands.Add("bopcheck",
79 "Use >bopcheck Shape [level of check: 0(V/V) - 5(all)]",
80 __FILE__, bopcheck, g);
81 theCommands.Add("bopargcheck" ,
82 "Use bopargcheck without parameters to get ",
83 __FILE__, bopargcheck, g);
84 theCommands.Add ("xdistef" ,
85 "Use xdistef edge face",
86 __FILE__, xdistef, g);
87 theCommands.Add("checkcurveonsurf",
88 "checkcurveonsurf shape",
89 __FILE__, checkcurveonsurf, g);
91 //=======================================================================
92 //class : BOPTest_Interf
93 //purpose : Auxiliary class
94 //=======================================================================
95 class BOPTest_Interf {
97 BOPTest_Interf() : myIndex1(-1), myIndex2(-1), myType(-1) {
103 void SetIndices(const Standard_Integer theIndex1,
104 const Standard_Integer theIndex2) {
109 void Indices(Standard_Integer& theIndex1,
110 Standard_Integer& theIndex2) const {
115 void SetType(const Standard_Integer theType) {
119 Standard_Integer Type() const {
123 bool operator < (const BOPTest_Interf& aOther) const {
126 if (myType==aOther.myType) {
127 if (myIndex1 == aOther.myIndex1) {
128 bFlag=(myIndex2 < aOther.myIndex2);
131 bFlag=(myIndex1 < aOther.myIndex1);
135 bFlag=(myType < aOther.myType);
142 Standard_Integer myIndex1;
143 Standard_Integer myIndex2;
144 Standard_Integer myType;
146 //=======================================================================
147 //function : bopcheck
149 //=======================================================================
150 Standard_Integer bopcheck (Draw_Interpretor& di,
155 di << " Use > bopcheck Shape [level of check: 0 - 9] [-t -s] [-tol tol]" << "\n";
156 di << " The level of check defines ";
157 di << " which interferences will be checked:\n";
158 di << " 0 - V/V only\n";
159 di << " 1 - V/V, V/E\n";
160 di << " 2 - V/V, V/E, E/E\n";
161 di << " 3 - V/V, V/E, E/E , V/F\n";
162 di << " 4 - V/V, V/E, E/E, V/F , E/F\n";
163 di << " 5 - V/V, V/E, E/E, V/F, E/F, F/F;\n";
164 di << " 6 - V/V, V/E, E/E, V/F, E/F, F/F, V/Z\n";
165 di << " 7 - V/V, V/E, E/E, V/F, E/F, F/F, E/Z\n";
166 di << " 8 - V/V, V/E, E/E, V/F, E/F, F/F, E/Z, F/Z\n";
167 di << " 9 - V/V, V/E, E/E, V/F, E/F, F/F, E/Z, F/Z, Z/Z\n";
168 di << " Default level is 9\n";
172 TopoDS_Shape aS = DBRep::Get(a[1]);
174 di << "null shapes are not allowed here!";
178 Standard_Boolean bRunParallel, bShowTime;
179 Standard_Integer i, aLevel, aNbInterfTypes;
180 Standard_Real aTolerance;
182 aNbInterfTypes=BOPDS_DS::NbInterfTypes();
184 aLevel=aNbInterfTypes-1;
187 if (a[2][0] != '-') {
188 aLevel=Draw::Atoi(a[2]);
192 if (aLevel < 0 || aLevel > aNbInterfTypes-1) {
193 di << "Invalid level";
198 bShowTime=Standard_False;
199 bRunParallel=Standard_True;
200 for (i=2; i<n; ++i) {
201 if (!strcmp(a[i], "-s")) {
202 bRunParallel=Standard_False;
204 else if (!strcmp(a[i], "-t")) {
205 bShowTime=Standard_True;
207 else if (!strcmp(a[i], "-tol")) {
210 aTolerance = Draw::Atof(a[i]);
215 //aLevel = (n==3) ? Draw::Atoi(a[2]) : aNbInterfTypes-1;
216 //-------------------------------------------------------------------
217 char buf[256], aName1[32], aName2[32];
218 char aInterfTypes[10][4] = {
219 "V/V", "V/E", "E/E","V/F", "E/F", "F/F", "V/Z", "E/Z", "F/Z", "Z/Z"
222 Standard_Integer iErr, iCnt, n1, n2, iT;
223 TopAbs_ShapeEnum aType1, aType2;
224 BOPAlgo_CheckerSI aChecker;
225 BOPCol_ListOfShape aLS;
226 BOPDS_MapIteratorMapOfPassKey aItMPK;
227 BOPTime_Chronometer aChrono;
229 if (aLevel < (aNbInterfTypes-1)) {
230 di << "Info:\nThe level of check is set to "
231 << aInterfTypes[aLevel] << ", i.e. intersection(s)\n";
233 for (i=aLevel+1; i<aNbInterfTypes; ++i) {
234 di << aInterfTypes[i];
235 if (i<aNbInterfTypes-1) {
239 di << " will not be checked.\n\n";
243 aChecker.SetArguments(aLS);
244 aChecker.SetLevelOfCheck(aLevel);
245 aChecker.SetRunParallel(bRunParallel);
246 aChecker.SetFuzzyValue(aTolerance);
254 iErr=aChecker.ErrorStatus();
256 const BOPDS_DS& aDS=*(aChecker.PDS());
258 const BOPDS_MapOfPassKey& aMPK=aDS.Interferences();
259 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
261 vector <BOPTest_Interf> aVec;
262 vector <BOPTest_Interf>::iterator aIt;
263 BOPTest_Interf aBInterf;
265 aItMPK.Initialize(aMPK);
266 for (; aItMPK.More(); aItMPK.Next()) {
267 const BOPDS_PassKey& aPK=aItMPK.Value();
269 if(aDS.IsNewShape(n1) || aDS.IsNewShape(n2)) {
273 const BOPDS_ShapeInfo& aSI1=aDS.ShapeInfo(n1);
274 const BOPDS_ShapeInfo& aSI2=aDS.ShapeInfo(n2);
275 aType1=aSI1.ShapeType();
276 aType2=aSI2.ShapeType();
278 iT=BOPDS_Tools::TypeToInteger(aType1, aType2);
280 aBInterf.SetIndices(n1, n2);
281 aBInterf.SetType(iT);
283 aVec.push_back(aBInterf);
286 sort( aVec.begin(), aVec.end(), less<BOPTest_Interf>());
289 for (aIt=aVec.begin(); aIt!=aVec.end(); aIt++) {
290 const BOPTest_Interf& aBI=*aIt;
293 if(aDS.IsNewShape(n1) || aDS.IsNewShape(n2)) {
297 const TopoDS_Shape& aS1=aDS.Shape(n1);
298 const TopoDS_Shape& aS2=aDS.Shape(n2);
301 di << aInterfTypes[iT] << ": ";
303 sprintf(aName1, "x%d", n1);
304 //sprintf(aName1, "x%d", iCnt);
305 DBRep::Set (aName1, aS1);
308 sprintf(aName2, "x%d", n2);
309 //sprintf(aName2, "x%d", iCnt);
310 DBRep::Set (aName2, aS2);
313 sprintf(buf, "%s %s \n", aName1, aName2);
318 di << "There were errors during the operation, ";
319 di << "so the list may be incomplete." << "\n";
323 di << " This shape seems to be OK." << "\n";
328 aTime=aChrono.Time();
329 Sprintf(buf, " Tps: %7.2lf\n", aTime);
334 //=======================================================================
335 //function : bopargcheck
337 //=======================================================================
338 Standard_Integer bopargcheck (Draw_Interpretor& di,
344 di << " Use >bopargcheck Shape1 [[Shape2] ";
345 di << "[-F/O/C/T/S/U] [/R|F|T|V|E|I|P|C|S]] [#BF] [-tol tol]" << "\n" << "\n";
346 di << " -<Boolean Operation>" << "\n";
347 di << " F (fuse)" << "\n";
348 di << " O (common)" << "\n";
349 di << " C (cut)" << "\n";
350 di << " T (cut21)" << "\n";
351 di << " S (section)" << "\n";
352 di << " U (unknown)" << "\n";
353 di << " For example: \"bopargcheck s1 s2 -F\" enables" ;
354 di << " checking for Fuse operation" << "\n";
355 di << " default - section" << "\n" << "\n";
356 di << " /<Test Options>" << "\n";
357 di << " R (disable small edges (shrank range) test)" << "\n";
358 di << " F (disable faces verification test)" << "\n";
359 di << " T (disable tangent faces searching test)" << "\n";
360 di << " V (disable test possibility to merge vertices)" << "\n";
361 di << " E (disable test possibility to merge edges)" << "\n";
362 di << " I (disable self-interference test)" << "\n";
363 di << " P (disable shape type test)" << "\n";
364 di << " C (disable test for shape continuity)" << "\n";
365 di << " S (disable curve on surface check)" << "\n";
366 di << " For example: \"bopargcheck s1 s2 /RI\" disables ";
367 di << "small edge detection and self-intersection detection" << "\n";
368 di << " default - all options are enabled" << "\n" << "\n";
369 di << " #<Additional Test Options>" << "\n";
370 di << " B (stop test on first faulty found); default OFF" << "\n";
371 di << " F (full output for faulty shapes); default - output ";
372 di << "in a short format" << "\n" << "\n";
373 di << " NOTE: <Boolean Operation> and <Test Options> are ";
374 di << "used only for couple" << "\n";
375 di << " of argument shapes, except I and P options ";
376 di << "that are always used for" << "\n";
377 di << " couple of shapes as well as for ";
378 di <<"single shape test." << "\n";
382 TopoDS_Shape aS1 = DBRep::Get(a[1]);
385 di << "Error: null shape not allowed!" << "\n";
386 di << "Type bopargcheck without arguments for more ";
387 di <<"information" << "\n";
391 Standard_Boolean isBO = Standard_False;
392 Standard_Integer indxBO = 0;
393 Standard_Boolean isOP = Standard_False;
394 Standard_Integer indxOP = 0;
395 Standard_Boolean isAD = Standard_False;
396 Standard_Integer indxAD = 0;
397 Standard_Boolean isS2 = Standard_False;
398 Standard_Integer indxS2 = 0;
399 Standard_Real aTolerance = 0;
402 Standard_Integer iIndex = 0;
403 for(iIndex = 2; iIndex < n; iIndex++) {
404 if(!strcmp(a[iIndex], "-tol"))
406 if ((iIndex+1) < n) {
408 aTolerance = Draw::Atof(a[iIndex]);
411 else if(a[iIndex][0] == '-')
413 isBO = Standard_True;
416 //else if(a[iIndex][0] == '+')
417 else if(a[iIndex][0] == '/')
419 isOP = Standard_True;
422 else if(a[iIndex][0] == '#')
424 isAD = Standard_True;
428 isS2 = Standard_True;
434 // set & test second shape
435 TopoDS_Shape aS22, aS2;
438 di << "Error: second shape should follow the first one!" << "\n";
439 di << "Type bopargcheck without arguments for more information" << "\n";
443 aS22 = DBRep::Get(a[2]);
445 di << "Error: second shape is null!" << "\n";
446 di << "Type bopargcheck without arguments for more information" << "\n";
453 BOPAlgo_ArgumentAnalyzer aChecker;
454 aChecker.SetFuzzyValue(aTolerance);
455 aChecker.SetShape1(aS1);
457 // set default options (always tested!) for single and couple shapes
458 aChecker.ArgumentTypeMode() = Standard_True;
459 aChecker.SelfInterMode() = Standard_True;
460 aChecker.SmallEdgeMode() = Standard_True;
461 aChecker.RebuildFaceMode() = Standard_True;
462 aChecker.ContinuityMode() = Standard_True;
463 aChecker.CurveOnSurfaceMode() = Standard_True;
465 // test & set options and operation for two shapes
467 aS2 = BRepBuilderAPI_Copy(aS22).Shape();
468 aChecker.SetShape2(aS2);
469 // set operation (default - Section)
471 if(a[indxBO][1] == 'F' || a[indxBO][1] == 'f') {
472 aChecker.OperationType() = BOPAlgo_FUSE;
474 else if(a[indxBO][1] == 'O' || a[indxBO][1] == 'o') {
475 aChecker.OperationType() = BOPAlgo_COMMON;
477 else if(a[indxBO][1] == 'C' || a[indxBO][1] == 'c') {
478 aChecker.OperationType() = BOPAlgo_CUT;
480 else if(a[indxBO][1] == 'T' || a[indxBO][1] == 't') {
481 aChecker.OperationType() = BOPAlgo_CUT21;
483 else if(a[indxBO][1] == 'S' || a[indxBO][1] == 's') {
484 aChecker.OperationType() = BOPAlgo_SECTION;
486 else if(a[indxBO][1] == 'U' || a[indxBO][1] == 'u') {
487 aChecker.OperationType() = BOPAlgo_UNKNOWN;
490 di << "Error: invalid boolean operation type!" << "\n";
491 di << "Type bopargcheck without arguments for more information" << "\n";
496 aChecker.OperationType() = BOPAlgo_SECTION;
498 aChecker.TangentMode() = Standard_True;
499 aChecker.MergeVertexMode() = Standard_True;
500 aChecker.MergeEdgeMode() = Standard_True;
503 // set options (default - all ON)
505 Standard_Integer ind = 1;
506 while(a[indxOP][ind] != 0) {
507 if(a[indxOP][ind] == 'R' || a[indxOP][ind] == 'r') {
508 aChecker.SmallEdgeMode() = Standard_False;
510 else if(a[indxOP][ind] == 'F' || a[indxOP][ind] == 'f') {
511 aChecker.RebuildFaceMode() = Standard_False;
513 else if(a[indxOP][ind] == 'T' || a[indxOP][ind] == 't') {
514 aChecker.TangentMode() = Standard_False;
516 else if(a[indxOP][ind] == 'V' || a[indxOP][ind] == 'v') {
517 aChecker.MergeVertexMode() = Standard_False;
519 else if(a[indxOP][ind] == 'E' || a[indxOP][ind] == 'e') {
520 aChecker.MergeEdgeMode() = Standard_False;
522 else if(a[indxOP][ind] == 'I' || a[indxOP][ind] == 'i') {
523 aChecker.SelfInterMode() = Standard_False;
525 else if(a[indxOP][ind] == 'P' || a[indxOP][ind] == 'p') {
526 aChecker.ArgumentTypeMode() = Standard_False;
528 else if(a[indxOP][ind] == 'C' || a[indxOP][ind] == 'c') {
529 aChecker.ContinuityMode() = Standard_False;
531 else if(a[indxOP][ind] == 'S' || a[indxOP][ind] == 's') {
532 aChecker.CurveOnSurfaceMode() = Standard_False;
535 di << "Error: invalid test option(s)!" << "\n";
536 di << "Type bopargcheck without arguments for more information" << "\n";
543 // set additional options
544 Standard_Boolean fullOutput = Standard_False;
546 Standard_Integer ind = 1;
547 while(a[indxAD][ind] != 0) {
548 if(a[indxAD][ind] == 'B' || a[indxAD][ind] == 'b') {
549 aChecker.StopOnFirstFaulty() = Standard_True;
551 else if(a[indxAD][ind] == 'F' || a[indxAD][ind] == 'f') {
552 fullOutput = Standard_True;
555 di << "Error: invalid additional test option(s)!" << "\n";
556 di << "Type bopargcheck without arguments for more information" << "\n";
566 // process result of checking
567 if(!aChecker.HasFaulty()) {
568 di << "Shape(s) seem(s) to be valid for BOP." << "\n";
572 di << "Faulties, that can not be treated by BOP, are detected." << "\n";
575 const BOPAlgo_ListOfCheckResult& aResultList = aChecker.GetCheckResult();
576 BOPAlgo_ListIteratorOfListOfCheckResult anIt(aResultList);
578 Standard_Integer S1_BadType = 0, S1_SelfInt = 0, S1_SmalE = 0, S1_BadF = 0, S1_BadV = 0, S1_BadE = 0;
579 Standard_Integer S1_SelfIntAll = 0, S1_SmalEAll = 0, S1_BadFAll = 0, S1_BadVAll = 0, S1_BadEAll = 0;
580 Standard_Integer S2_BadType = 0, S2_SelfInt = 0, S2_SmalE = 0, S2_BadF = 0, S2_BadV = 0, S2_BadE = 0;
581 Standard_Integer S2_SelfIntAll = 0, S2_SmalEAll = 0, S2_BadFAll = 0, S2_BadVAll = 0, S2_BadEAll = 0;
582 Standard_Integer S1_OpAb = 0, S2_OpAb = 0;
583 Standard_Integer S1_C0 = 0, S2_C0 = 0, S1_C0All = 0, S2_C0All = 0;
584 Standard_Integer S1_COnS = 0, S2_COnS = 0, S1_COnSAll = 0, S2_COnSAll = 0;
585 Standard_Boolean hasUnknown = Standard_False;
587 TCollection_AsciiString aS1SIBaseName("s1si_");
588 TCollection_AsciiString aS1SEBaseName("s1se_");
589 TCollection_AsciiString aS1BFBaseName("s1bf_");
590 TCollection_AsciiString aS1BVBaseName("s1bv_");
591 TCollection_AsciiString aS1BEBaseName("s1be_");
592 TCollection_AsciiString aS1C0BaseName("s1C0_");
593 TCollection_AsciiString aS1COnSBaseName("s1COnS_");
594 TCollection_AsciiString aS2SIBaseName("s2si_");
595 TCollection_AsciiString aS2SEBaseName("s2se_");
596 TCollection_AsciiString aS2BFBaseName("s2bf_");
597 TCollection_AsciiString aS2BVBaseName("s2bv_");
598 TCollection_AsciiString aS2BEBaseName("s2be_");
599 TCollection_AsciiString aS2C0BaseName("s2C0_");
600 TCollection_AsciiString aS2COnSBaseName("s2COnS_");
602 for(; anIt.More(); anIt.Next()) {
603 const BOPAlgo_CheckResult& aResult = anIt.Value();
604 const TopoDS_Shape & aSS1 = aResult.GetShape1();
605 const TopoDS_Shape & aSS2 = aResult.GetShape2();
606 const BOPCol_ListOfShape & aLS1 = aResult.GetFaultyShapes1();
607 const BOPCol_ListOfShape & aLS2 = aResult.GetFaultyShapes2();
608 Standard_Boolean isL1 = !aLS1.IsEmpty();
609 Standard_Boolean isL2 = !aLS2.IsEmpty();
611 switch(aResult.GetCheckStatus()) {
612 case BOPAlgo_BadType: {
613 if(!aSS1.IsNull()) S1_BadType++;
614 if(!aSS2.IsNull()) S2_BadType++;
617 case BOPAlgo_SelfIntersect: {
621 MakeShapeForFullOutput(aS1SIBaseName, S1_SelfInt, aLS1, S1_SelfIntAll, di);
626 MakeShapeForFullOutput(aS2SIBaseName, S2_SelfInt, aLS2, S2_SelfIntAll, di);
630 case BOPAlgo_TooSmallEdge: {
634 MakeShapeForFullOutput(aS1SEBaseName, S1_SmalE, aLS1, S1_SmalEAll, di);
639 MakeShapeForFullOutput(aS2SEBaseName, S2_SmalE, aLS2, S2_SmalEAll, di);
643 case BOPAlgo_NonRecoverableFace: {
647 MakeShapeForFullOutput(aS1BFBaseName, S1_BadF, aLS1, S1_BadFAll, di);
652 MakeShapeForFullOutput(aS2BFBaseName, S2_BadF, aLS2, S2_BadFAll, di);
656 case BOPAlgo_IncompatibilityOfVertex: {
660 MakeShapeForFullOutput(aS1BVBaseName, S1_BadV, aLS1, S1_BadVAll, di);
666 MakeShapeForFullOutput(aS2BVBaseName, S2_BadV, aLS2, S2_BadVAll, di);
671 case BOPAlgo_IncompatibilityOfEdge: {
675 MakeShapeForFullOutput(aS1BEBaseName, S1_BadE, aLS1, S1_BadEAll, di);
681 MakeShapeForFullOutput(aS2BEBaseName, S2_BadE, aLS2, S2_BadEAll, di);
686 case BOPAlgo_IncompatibilityOfFace: {
687 // not yet implemented
690 case BOPAlgo_GeomAbs_C0: {
694 MakeShapeForFullOutput(aS1C0BaseName, S1_C0, aLS1, S1_C0All, di);
700 MakeShapeForFullOutput(aS2C0BaseName, S2_C0, aLS2, S2_C0All, di);
705 case BOPAlgo_InvalidCurveOnSurface: {
709 Standard_Real aMaxDist = aResult.GetMaxDistance1();
710 Standard_Real aMaxParameter = aResult.GetMaxParameter1();
711 MakeShapeForFullOutput(aS1COnSBaseName, S1_COnS, aLS1, S1_COnSAll, di,
712 Standard_True, aMaxDist, aMaxParameter);
718 Standard_Real aMaxDist = aResult.GetMaxDistance2();
719 Standard_Real aMaxParameter = aResult.GetMaxParameter2();
720 MakeShapeForFullOutput(aS2COnSBaseName, S2_COnS, aLS2, S2_COnSAll, di,
721 Standard_True, aMaxDist, aMaxParameter);
726 case BOPAlgo_OperationAborted: {
727 if(!aSS1.IsNull()) S1_OpAb++;
728 if(!aSS2.IsNull()) S2_OpAb++;
731 case BOPAlgo_CheckUnknown:
733 hasUnknown = Standard_True;
739 Standard_Integer FS1 = S1_SelfInt + S1_SmalE + S1_BadF + S1_BadV + S1_BadE + S1_OpAb + S1_C0 + S1_COnS;
740 FS1 += (S1_BadType != 0) ? 1 : 0;
741 Standard_Integer FS2 = S2_SelfInt + S2_SmalE + S2_BadF + S2_BadV + S2_BadE + S2_OpAb + S2_C0 + S2_COnS;
742 FS2 += (S2_BadType != 0) ? 1 : 0;
744 // output for first shape
745 di << "Faulties for FIRST shape found : " << FS1 << "\n";
747 di << "---------------------------------" << "\n";
748 Standard_CString CString1;
752 CString1=aChecker.ArgumentTypeMode() ? "NO" : "DISABLED";
753 di << "Shapes are not suppotrted by BOP: " << CString1 << "\n";
754 Standard_CString CString2;
758 CString2=aChecker.SelfInterMode() ? "NO" : "DISABLED";
759 di << "Self-Intersections : " << CString2;
761 di << " Cases(" << S1_SelfInt << ") Total shapes(" << S1_SelfIntAll << ")" << "\n";
764 Standard_CString CString13;
768 CString13=aChecker.SelfInterMode() ? "NO" : "DISABLED";
769 di << "Check for SI has been aborted : " << CString13 << "\n";
770 Standard_CString CString3;
774 CString3=aChecker.SmallEdgeMode() ? "NO" : "DISABLED";
775 di << "Too small edges : " << CString3;
777 di << " Cases(" << S1_SmalE << ") Total shapes(" << S1_SmalEAll << ")" << "\n";
780 Standard_CString CString4;
784 CString4=aChecker.RebuildFaceMode() ? "NO" : "DISABLED";
785 di << "Bad faces : " << CString4;
787 di << " Cases(" << S1_BadF << ") Total shapes(" << S1_BadFAll << ")" << "\n";
790 Standard_CString CString5;
794 CString5=aChecker.MergeVertexMode() ? "NO" : "DISABLED";
795 di << "Too close vertices : " << CString5;
797 di << " Cases(" << S1_BadV << ") Total shapes(" << S1_BadVAll << ")" << "\n";
800 Standard_CString CString6;
804 CString6=aChecker.MergeEdgeMode() ? "NO" : "DISABLED";
805 di << "Too close edges : " << CString6;
807 di << " Cases(" << S1_BadE << ") Total shapes(" << S1_BadEAll << ")" << "\n";
810 Standard_CString CString15;
814 CString15=aChecker.ContinuityMode() ? "NO" : "DISABLED";
815 di << "Shapes with Continuity C0 : " << CString15;
817 di << " Cases(" << S1_C0 << ") Total shapes(" << S1_C0All << ")" << "\n";
821 Standard_CString CString17;
825 CString17=aChecker.CurveOnSurfaceMode() ? "NO" : "DISABLED";
826 di << "Invalid Curve on Surface : " << CString17;
828 di << " Cases(" << S1_COnS << ") Total shapes(" << S1_COnSAll << ")" << "\n";
833 // output for second shape
835 di << "Faulties for SECOND shape found : " << FS2 << "\n";
837 di << "---------------------------------" << "\n";
838 Standard_CString CString7;
842 CString7=aChecker.ArgumentTypeMode() ? "NO" : "DISABLED";
843 di << "Shapes are not suppotrted by BOP: " << CString7 << "\n";
844 Standard_CString CString8;
848 CString8=aChecker.SelfInterMode() ? "NO" : "DISABLED";
849 di << "Self-Intersections : " << CString8;
851 di << " Cases(" << S2_SelfInt << ") Total shapes(" << S2_SelfIntAll << ")" << "\n";
855 Standard_CString CString14;
859 CString14=aChecker.SelfInterMode() ? "NO" : "DISABLED";
860 di << "Check for SI has been aborted : " << CString14 << "\n";
861 Standard_CString CString9;
865 CString9=aChecker.SmallEdgeMode() ? "NO" : "DISABLED";
866 di << "Too small edges : " << CString9;
868 di << " Cases(" << S2_SmalE << ") Total shapes(" << S2_SmalEAll << ")" << "\n";
871 Standard_CString CString10;
875 CString10=aChecker.RebuildFaceMode() ? "NO" : "DISABLED";
876 di << "Bad faces : " << CString10;
878 di << " Cases(" << S2_BadF << ") Total shapes(" << S2_BadFAll << ")" << "\n";
881 Standard_CString CString11;
885 CString11=aChecker.MergeVertexMode() ? "NO" : "DISABLED";
886 di << "Too close vertices : " << CString11;
888 di << " Cases(" << S2_BadV << ") Total shapes(" << S2_BadVAll << ")" << "\n";
891 Standard_CString CString12;
895 CString12=aChecker.MergeEdgeMode() ? "NO" : "DISABLED";
896 di << "Too close edges : " << CString12;
898 di << " Cases(" << S2_BadE << ") Total shapes(" << S2_BadEAll << ")" << "\n";
901 Standard_CString CString16;
905 CString16=aChecker.ContinuityMode() ? "NO" : "DISABLED";
906 di << "Shapes with Continuity C0 : " << CString16;
908 di << " Cases(" << S2_C0 << ") Total shapes(" << S2_C0All << ")" << "\n";
912 Standard_CString CString18;
916 CString18=aChecker.CurveOnSurfaceMode() ? "NO" : "DISABLED";
917 di << "Invalid Curve on Surface : " << CString18;
919 di << " Cases(" << S2_COnS << ") Total shapes(" << S2_COnSAll << ")" << "\n";
926 di << "WARNING: The unexpected test break occurs!" << "\n";
934 //=======================================================================
937 //=======================================================================
938 Standard_Integer xdistef(Draw_Interpretor& di,
943 di << "Use efmaxdist edge face\n";
947 const TopoDS_Shape aS1 = DBRep::Get(a[1]);
948 const TopoDS_Shape aS2 = DBRep::Get(a[2]);
950 if (aS1.IsNull() || aS2.IsNull()) {
951 di << "null shapes\n";
955 if (aS1.ShapeType() != TopAbs_EDGE ||
956 aS2.ShapeType() != TopAbs_FACE) {
957 di << "type mismatch\n";
961 Standard_Real aMaxDist = 0.0, aMaxPar = 0.0;
963 const TopoDS_Edge& anEdge = *(TopoDS_Edge*)&aS1;
964 const TopoDS_Face& aFace = *(TopoDS_Face*)&aS2;
966 if(!BOPTools_AlgoTools::ComputeTolerance
967 (aFace, anEdge, aMaxDist, aMaxPar)) {
968 di << "Tolerance cannot be computed\n";
972 di << "Max Distance = " << aMaxDist
973 << "; Parameter on curve = " << aMaxPar << "\n";
978 //=======================================================================
979 //function : checkcurveonsurf
981 //=======================================================================
982 Standard_Integer checkcurveonsurf(Draw_Interpretor& di,
987 di << "use checkcurveonsurf shape\n";
991 TopoDS_Shape aS = DBRep::Get(a[1]);
993 di << "null shape\n";
997 Standard_Integer nE, nF, anECounter, aFCounter;
998 Standard_Real aT, aTolE, aDMax;
999 TopExp_Explorer aExpF, aExpE;
1000 char buf[200], aFName[10], anEName[10];
1001 NCollection_DataMap<TopoDS_Shape, Standard_Real, TopTools_ShapeMapHasher> aDMETol;
1002 BOPCol_DataMapOfShapeInteger aMSI;
1007 aExpF.Init(aS, TopAbs_FACE);
1008 for (; aExpF.More(); aExpF.Next()) {
1009 const TopoDS_Face& aF = *(TopoDS_Face*)&aExpF.Current();
1011 aExpE.Init(aF, TopAbs_EDGE);
1012 for (; aExpE.More(); aExpE.Next()) {
1013 const TopoDS_Edge& aE = *(TopoDS_Edge*)&aExpE.Current();
1015 if (!BOPTools_AlgoTools::ComputeTolerance(aF, aE, aDMax, aT)) {
1019 aTolE = BRep_Tool::Tolerance(aE);
1020 if (aDMax < aTolE) {
1024 if (aDMETol.IsBound(aE)) {
1025 Standard_Real& aD = aDMETol.ChangeFind(aE);
1031 aDMETol.Bind(aE, aDMax);
1034 if (anECounter == 0) {
1035 di << "Invalid curves on surface:\n";
1038 if (aMSI.IsBound(aE)) {
1047 if (aMSI.IsBound(aF)) {
1055 sprintf(anEName, "e_%d", nE);
1056 sprintf(aFName , "f_%d", nF);
1057 sprintf(buf, "edge %s on face %s (max dist: %3.16f, parameter on curve: %3.16f)\n",
1058 anEName, aFName, aDMax, aT);
1061 DBRep::Set(anEName, aE);
1062 DBRep::Set(aFName , aF);
1066 if (anECounter > 0) {
1067 di << "\n\nSugestions to fix the shape:\n";
1068 di << "explode " << a[1] << " e;\n";
1070 TopTools_MapOfShape M;
1071 aExpE.Init(aS, TopAbs_EDGE);
1072 for (anECounter = 0; aExpE.More(); aExpE.Next()) {
1073 const TopoDS_Shape& aE = aExpE.Current();
1079 if (!aDMETol.IsBound(aE)) {
1083 aTolE = aDMETol.Find(aE);
1085 sprintf(buf, "settolerance %s_%d %3.16f;\n", a[1], anECounter, aTolE);
1090 di << "This shape seems to be OK.\n";
1096 //=======================================================================
1097 //function : MakeShapeForFullOutput
1099 //=======================================================================
1100 void MakeShapeForFullOutput (const TCollection_AsciiString & aBaseName,
1101 const Standard_Integer aIndex,
1102 const BOPCol_ListOfShape & aList,
1103 Standard_Integer& aCount,
1104 Draw_Interpretor& di,
1105 Standard_Boolean bCurveOnSurf,
1106 Standard_Real aMaxDist,
1107 Standard_Real aMaxParameter)
1109 TCollection_AsciiString aNum(aIndex);
1110 TCollection_AsciiString aName = aBaseName + aNum;
1111 Standard_CString name = aName.ToCString();
1113 TopoDS_Compound cmp;
1115 BB.MakeCompound(cmp);
1117 BOPCol_ListIteratorOfListOfShape anIt(aList);
1118 for(; anIt.More(); anIt.Next()) {
1119 const TopoDS_Shape & aS = anIt.Value();
1123 di << "Made faulty shape: " << name;
1126 di << " (MaxDist = " << aMaxDist
1127 << ", MaxPar = " << aMaxParameter << ")";
1132 DBRep::Set(name, cmp);