1 // File: BOPTest_BOPCommands.cxx
2 // Created: 10:45:01 2000
3 // Author: Peter KURNEV
12 #include <DBRep_DrawableShape.hxx>
15 #include <Draw_Color.hxx>
17 #include <TCollection_AsciiString.hxx>
19 #include <TopAbs_ShapeEnum.hxx>
21 #include <TopoDS_Shape.hxx>
22 #include <TopoDS_Shell.hxx>
25 #include <TopTools_IndexedMapOfShape.hxx>
27 #include <BRep_Builder.hxx>
29 #include <BooleanOperations_ShapesDataStructure.hxx>
30 #include <BooleanOperations_StateOfShape.hxx>
32 #include <BOPTools_SolidStateFiller.hxx>
33 #include <BOPTools_DSFiller.hxx>
34 #include <BOPTools_SplitShapesPool.hxx>
35 #include <BOPTools_ListOfPaveBlock.hxx>
36 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
37 #include <BOPTools_PaveBlock.hxx>
38 #include <BOPTools_PCurveMaker.hxx>
39 #include <BOPTools_InterferencePool.hxx>
40 #include <BOPTools_CArray1OfVVInterference.hxx>
41 #include <BOPTools_CArray1OfVSInterference.hxx>
42 #include <BOPTools_CArray1OfVEInterference.hxx>
43 #include <BOPTools_CArray1OfESInterference.hxx>
44 #include <BOPTools_CArray1OfEEInterference.hxx>
45 #include <BOPTools_CArray1OfSSInterference.hxx>
46 #include <BOPTools_VVInterference.hxx>
47 #include <BOPTools_VEInterference.hxx>
48 #include <BOPTools_VSInterference.hxx>
49 #include <BOPTools_EEInterference.hxx>
50 #include <BOPTools_ESInterference.hxx>
51 #include <BOPTools_SSInterference.hxx>
53 #include <BOPTest_DrawableShape.hxx>
55 #include <BRepAlgoAPI_BooleanOperation.hxx>
56 #include <BRepAlgoAPI_Section.hxx>
57 #include <BRepAlgoAPI_Common.hxx>
58 #include <BRepAlgoAPI_Fuse.hxx>
59 #include <BRepAlgoAPI_Cut.hxx>
61 #include <TColStd_IndexedMapOfInteger.hxx>
68 #include <Standard_Static.hxx>
69 #include <OSD_Chronometer.hxx>
72 Standard_STATIC(OSD_Chronometer, S_Chrono);
73 static void StartChrono();
74 static void StopChrono(Draw_Interpretor&);
75 Standard_Integer btimesum (Draw_Interpretor& , Standard_Integer n, const char** a);
79 static Standard_Integer bop (Draw_Interpretor&, Standard_Integer, const char**);
81 static Standard_Integer bcommon (Draw_Interpretor& , Standard_Integer , const char**);
82 static Standard_Integer bfuse (Draw_Interpretor& , Standard_Integer , const char**);
83 static Standard_Integer bcut (Draw_Interpretor& , Standard_Integer , const char**);
84 static Standard_Integer bsection (Draw_Interpretor& , Standard_Integer , const char**);
86 static Standard_Integer bFillDS (Draw_Interpretor& , Standard_Integer , const char**);
88 static Standard_Integer bopcommon (Draw_Interpretor& , Standard_Integer , const char**);
89 static Standard_Integer bopfuse (Draw_Interpretor& , Standard_Integer , const char**);
90 static Standard_Integer bopcut (Draw_Interpretor& , Standard_Integer , const char**);
91 static Standard_Integer boptuc (Draw_Interpretor& , Standard_Integer , const char**);
92 static Standard_Integer bopsection (Draw_Interpretor& , Standard_Integer , const char**);
94 static Standard_Integer boperationFiller (Standard_Integer n, const char** a, const BOP_Operation anOp,
97 static Standard_Integer bopstates (Draw_Interpretor& , Standard_Integer , const char**);
99 static Standard_Integer bopwho (Draw_Interpretor& , Standard_Integer , const char**);
100 static Standard_Integer bopsticks (Draw_Interpretor& , Standard_Integer , const char**);
104 void UnUsedMap(BOPTools_SequenceOfCurves& ,
105 const BOPTools_PaveSet& ,
106 TColStd_IndexedMapOfInteger& );
107 //=======================================================================
108 //function : BOPCommands
110 //=======================================================================
111 void BOPTest::BOPCommands(Draw_Interpretor& theCommands)
113 static Standard_Boolean done = Standard_False;
117 done = Standard_True;
119 const char* g = "CCR commands";
121 // Using DSFiller that is ready.
122 theCommands.Add("bop" , "Use >bop Shape1 Shape2", __FILE__, bop, g);
123 theCommands.Add("bopcommon" , "Use >bopcommon R" , __FILE__, bopcommon , g);
124 theCommands.Add("bopfuse" , "Use >bopfuse R" , __FILE__, bopfuse , g);
125 theCommands.Add("bopcut" , "Use >bopcut R" , __FILE__, bopcut , g);
126 theCommands.Add("boptuc" , "Use >boptuc R" , __FILE__, boptuc , g);
127 theCommands.Add("bopsection", "Use >bopsection R", __FILE__, bopsection, g);
130 theCommands.Add("bopstates", "Use bopstates [-f] [-t] [-out]", __FILE__, bopstates, g);
132 theCommands.Add("bcommon" , "Use >bcommon R a b" , __FILE__, bcommon , g);
133 theCommands.Add("bfuse" , "Use >bfuse R a b" , __FILE__, bfuse , g);
134 theCommands.Add("bcut" , "Use >bcut R a b" , __FILE__, bcut , g);
137 theCommands.Add("bsection", "Use >bsection Result s1 s2 [-2d/-2d1/-2d2] [-a]"
138 , __FILE__, bsection, g);
140 theCommands.Add("btimesum" , "Use >btimesum FileName" , __FILE__, btimesum, g);
141 theCommands.Add("bopwho" , "Use >bopwho Index" , __FILE__, bopwho, g);
142 theCommands.Add("bopsticks" , "Use >bopsticks" , __FILE__, bopsticks, g);
146 //////////////////////////////////
148 // The one and only global variable
150 BOPTools_DSFiller *pDF;
152 //////////////////////////////////
154 //=======================================================================
157 //=======================================================================
158 Standard_Integer bop (Draw_Interpretor& di,
165 di << " Use >bop Shape1 Shape2\n";
170 TopoDS_Shape S1 = DBRep::Get(a[1]);
171 TopoDS_Shape S2 = DBRep::Get(a[2]);
173 if (S1.IsNull() || S2.IsNull()) {
174 di << " Null shapes are not allowed \n";
183 pDF=new BOPTools_DSFiller;
185 pDF->SetShapes (S1, S2);
186 if (!pDF->IsDone()) {
187 di << "Check types of the arguments, please\n";
197 //printf(" BOPTools_DSFiller is Ready to use\n");
204 //=======================================================================
207 //=======================================================================
208 Standard_Integer bFillDS (Draw_Interpretor& di,
213 di << " Usage: >command Result Shape1 Shape2\n";
217 return bop(di, n, a+1);
220 //=======================================================================
223 //=======================================================================
224 Standard_Integer bcommon (Draw_Interpretor& di,
228 Standard_Integer iFlag;
230 iFlag =bFillDS (di, n, a);
236 return bopcommon(di, n, a);
238 //=======================================================================
241 //=======================================================================
242 Standard_Integer bfuse(Draw_Interpretor& di,
246 Standard_Integer iFlag;
248 iFlag =bFillDS (di, n, a);
254 return bopfuse(di, n, a);
257 //=======================================================================
260 //=======================================================================
261 Standard_Integer bcut(Draw_Interpretor& di,
265 Standard_Integer iFlag;
267 iFlag =bFillDS (di, n, a);
273 return bopcut(di, n, a);
275 //=======================================================================
276 //function : bsection
278 //=======================================================================
279 Standard_Integer bsection(Draw_Interpretor& di,
283 const char* usage = " Usage: bsection Result s1 s2 [-2d/-2d1/-2d2] [-a]\n";
289 TopoDS_Shape S1 = DBRep::Get(a[2]);
290 TopoDS_Shape S2 = DBRep::Get(a[3]);
292 if (S1.IsNull() || S2.IsNull()) {
293 di << " Null shapes are not allowed \n";
298 BRepAlgoAPI_Section aSec(S1, S2, Standard_False);
299 aSec.Approximation(Standard_False);
300 aSec.ComputePCurveOn1(Standard_False);
301 aSec.ComputePCurveOn2(Standard_False);
302 Standard_Boolean isbadparameter = Standard_False;
305 const char* key1 = a[4];
306 const char* key2 = (n > 5) ? a[5] : NULL;
307 const char* pcurveconf = NULL;
308 Standard_Boolean approx = Standard_False;
311 if (key1 && !strcasecmp(key1,"-2d")) {
313 if (key1 && !strncasecmp(key1,"-2d", 3)) {
318 if (!strcasecmp(key1,"-a")) {
319 approx = Standard_True;
322 isbadparameter = Standard_True;
326 if (key2 && !strcasecmp(key2,"-2d")) {
328 if (key2 && !strncasecmp(key2,"-2d", 3)) {
331 isbadparameter = Standard_True;
339 if (!strcasecmp(key2,"-a")) {
340 approx = Standard_True;
343 isbadparameter = Standard_True;
348 if(!isbadparameter && pcurveconf) {
350 if (strcasecmp(pcurveconf, "-2d") == 0) {
351 aSec.ComputePCurveOn1(Standard_True);
352 aSec.ComputePCurveOn2(Standard_True);
355 if (strcasecmp(pcurveconf, "-2d1") == 0) {
356 aSec.ComputePCurveOn1(Standard_True);
359 if (strcasecmp(pcurveconf, "-2d2") == 0) {
360 aSec.ComputePCurveOn2(Standard_True);
365 aSec.Approximation(approx);
368 if(!isbadparameter) {
370 Standard_Boolean anIsDone = aSec.IsDone();
373 const TopoDS_Shape& aR = aSec.Shape();
374 DBRep::Set (a[1], aR);
377 di << "not done ErrorStatus()="<< aSec.ErrorStatus() <<"\n";
387 //=======================================================================
388 //function : bopcommon
390 //=======================================================================
391 Standard_Integer bopcommon (Draw_Interpretor& di,
395 return boperationFiller (n, a, BOP_COMMON, di);
398 //=======================================================================
401 //=======================================================================
402 Standard_Integer bopfuse(Draw_Interpretor& di,
406 return boperationFiller (n, a, BOP_FUSE, di);
409 //=======================================================================
412 //=======================================================================
413 Standard_Integer bopcut (Draw_Interpretor& di,
417 return boperationFiller (n, a, BOP_CUT, di);
419 //=======================================================================
422 //=======================================================================
423 Standard_Integer boptuc (Draw_Interpretor& di,
427 return boperationFiller (n, a, BOP_CUT21, di);
429 //=======================================================================
430 //function : bopsection
432 //=======================================================================
433 Standard_Integer bopsection (Draw_Interpretor& di,
437 return boperationFiller (n, a, BOP_SECTION, di);
440 //=======================================================================
441 //function : boperationFiller
443 //=======================================================================
444 Standard_Integer boperationFiller (Standard_Integer n,
446 const BOP_Operation anOp,
447 Draw_Interpretor& di)
454 di << " Use oper> Result [-mf]\n";
460 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
465 const TopoDS_Shape& S1 = pDF->Shape1();
466 const TopoDS_Shape& S2 = pDF->Shape2();
468 if (S1.IsNull() || S2.IsNull()) {
469 di << " Null shapes are not allowed \n";
474 Standard_Boolean aMFlag, anIsDone;
476 aMFlag=Standard_False;
478 BRepAlgoAPI_BooleanOperation* pBuilder=NULL;
481 if (anOp==BOP_SECTION) {
482 pBuilder=new BRepAlgoAPI_Section(S1, S2, *pDF);
484 else if (anOp==BOP_COMMON) {
485 pBuilder=new BRepAlgoAPI_Common(S1, S2, *pDF);
487 else if (anOp==BOP_FUSE) {
488 pBuilder=new BRepAlgoAPI_Fuse(S1, S2, *pDF);
490 else if (anOp==BOP_CUT) {
491 pBuilder=new BRepAlgoAPI_Cut (S1, S2, *pDF);
493 else if (anOp==BOP_CUT21) {
494 pBuilder=new BRepAlgoAPI_Cut(S1, S2, *pDF, Standard_False);
497 anIsDone=pBuilder->IsDone();
499 const TopoDS_Shape& aR=pBuilder->Shape();
500 DBRep::Set (a[1], aR);
503 di << "not done ErrorStatus()=" << pBuilder->ErrorStatus() << "\n";
513 //=======================================================================
517 void GetName (const BooleanOperations_StateOfShape aState,
518 TCollection_AsciiString& aNm);
520 TopAbs_ShapeEnum ChooseShapeType(const char* a1);
523 BooleanOperations_StateOfShape ChooseShapeState(const char* a3);
525 //=======================================================================
526 //function : bopstates
528 //=======================================================================
529 Standard_Integer bopstates(Draw_Interpretor& di,
534 di << " Use bopstates [-f] [-t] [-out]\n";
539 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
543 Standard_Integer i, aNbLines, aIsSmtToDraw=0;
544 BooleanOperations_StateOfShape aState, aChooseState;
545 aChooseState=BooleanOperations_UNKNOWN;
546 TopAbs_ShapeEnum aEnumToDisplay = TopAbs_COMPOUND;
547 Draw_Color aTextColor(Draw_cyan);
549 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
551 // Choose Object or Tool or All
553 aNbLines=aDS.NumberOfSourceShapes();
555 if (!strcmp (a[2], "-o")) {
556 aDS.ObjectRange(i, aNbLines);
558 if (!strcmp (a[2], "-t")) {
559 aDS.ToolRange(i, aNbLines);
565 aChooseState=ChooseShapeState(a[3]);
570 aEnumToDisplay=TopAbs_EDGE;
573 aEnumToDisplay=ChooseShapeType(a[1]);
577 for (; i<=aNbLines; ++i) {
578 const TopoDS_Shape& aS=aDS.GetShape(i);
579 TopAbs_ShapeEnum aCurrentType=aS.ShapeType();
580 if (aCurrentType==aEnumToDisplay) {
581 aState=aDS.GetState(i);
582 TCollection_AsciiString aNm, aInd(i);
583 GetName(aState, aNm);
585 if (aState==BooleanOperations_INTERSECTED && aCurrentType==TopAbs_EDGE) {
587 const BOPTools_SplitShapesPool& aSpPool=pDF->SplitShapesPool();
588 const BOPTools_ListOfPaveBlock& aSplitsList=aSpPool(aDS.RefEdge(i));
589 BOPTools_ListIteratorOfListOfPaveBlock anIt(aSplitsList);
590 for (; anIt.More();anIt.Next()) {
591 const BOPTools_PaveBlock& aPB=anIt.Value();
592 Standard_Integer nSplit=aPB.Edge();
593 const TopoDS_Shape& aSplit=aDS.GetShape(nSplit);
594 aState=aDS.GetState(nSplit);
595 GetName(aState, aNm);
597 TCollection_AsciiString aNmx, anUnd("_"), aIndx(nSplit);
601 Standard_CString aTxt=aNmx.ToCString();
603 if (aChooseState!=BooleanOperations_UNKNOWN) {
604 if (aState!=aChooseState) {
609 //printf("%s ", aTxt);
611 Handle(BOPTest_DrawableShape) aDSh=
612 new BOPTest_DrawableShape (aSplit, aTxt, aTextColor);
613 Draw::Set (aTxt, aDSh);
619 Standard_CString aText=aNm.ToCString();
621 if (aChooseState!=BooleanOperations_UNKNOWN) {
622 if (aState!=aChooseState) {
627 //printf("%s ", aText);
629 Handle(BOPTest_DrawableShape) aDShape=
630 new BOPTest_DrawableShape (aS, aText, aTextColor);
631 Draw::Set (aText, aDShape);
636 di << " No specified shapes\n";
646 //=======================================================================
649 //=======================================================================
650 void GetName (const BooleanOperations_StateOfShape aState,
651 TCollection_AsciiString& aNm)
653 TCollection_AsciiString aNmOut("ou_"), aNmIn("in_"),
654 aNmOn("on_"), aNmUn("un_"), aNmInter("intr_");
657 case BooleanOperations_OUT:
660 case BooleanOperations_IN:
663 case BooleanOperations_ON:
666 case BooleanOperations_INTERSECTED:
675 //=======================================================================
676 //function : ChooseShapeType
678 //=======================================================================
679 TopAbs_ShapeEnum ChooseShapeType(const char* a1)
681 TopAbs_ShapeEnum aEnumToDisplay;
683 if (!strcmp (a1, "-c")) {
684 aEnumToDisplay=TopAbs_COMPOUND;
686 else if (!strcmp (a1, "-cs")) {
687 aEnumToDisplay=TopAbs_COMPSOLID;
689 else if (!strcmp (a1, "-s")) {
690 aEnumToDisplay=TopAbs_SOLID;
692 else if (!strcmp (a1, "-sh")) {
693 aEnumToDisplay=TopAbs_SHELL;
695 else if (!strcmp (a1, "-f")) {
696 aEnumToDisplay=TopAbs_FACE;
698 else if (!strcmp (a1, "-w")) {
699 aEnumToDisplay=TopAbs_WIRE;
701 else if (!strcmp (a1, "-e")) {
702 aEnumToDisplay=TopAbs_EDGE;
704 else if (!strcmp (a1, "-v")) {
705 aEnumToDisplay=TopAbs_VERTEX;
708 aEnumToDisplay=TopAbs_EDGE;
710 return aEnumToDisplay;
713 //=======================================================================
714 //function : ChooseShapeState
716 //=======================================================================
717 BooleanOperations_StateOfShape ChooseShapeState(const char* a3)
719 BooleanOperations_StateOfShape aChooseState=BooleanOperations_UNKNOWN;
721 if (!strcmp (a3, "-out")) {
722 aChooseState=BooleanOperations_OUT;
724 if (!strcmp (a3, "-in")) {
725 aChooseState=BooleanOperations_IN;
727 if (!strcmp (a3, "-on")) {
728 aChooseState=BooleanOperations_ON;
735 #include <OSD_Chronometer.hxx>
736 #include <TCollection_AsciiString.hxx>
737 #include <OSD_OpenMode.hxx>
738 #include <OSD_Path.hxx>
739 #include <OSD_Protection.hxx>
740 #include <OSD_File.hxx>
742 static void SaveTimeInFile(const Standard_CString aFileName,
743 const Standard_Real aChrono,
744 Draw_Interpretor& di);
746 //=======================================================================
747 //function : StartChrono
749 //=======================================================================
752 char *xr=getenv ("BOPCHRONO");
754 if (!strcmp (xr, "yes")){
761 //=======================================================================
762 //function : StopChrono
764 //=======================================================================
765 void StopChrono(Draw_Interpretor& di)
767 char *xr=getenv ("BOPCHRONO");
769 if (!strcmp (xr, "yes")) {
770 Standard_Real Chrono;
772 S_Chrono().Show(Chrono);
774 char *aFileName=getenv("BOPCHRONOFILE");
775 if (aFileName!=NULL){
776 SaveTimeInFile(aFileName, Chrono, di);
779 di << "Tps: " << Chrono << "\n";
785 //=======================================================================
786 //function : SaveTimeInFile
788 //=======================================================================
789 void SaveTimeInFile(const Standard_CString aFileName,
790 const Standard_Real aChrono,
791 Draw_Interpretor& di)
793 OSD_OpenMode aMode = OSD_ReadWrite;
794 OSD_Protection aProtect(OSD_RW,OSD_RW,OSD_RW,OSD_RW);
795 TCollection_AsciiString anASName(aFileName);
796 OSD_Path aPath (anASName);
797 OSD_File aFile (aPath);
798 aFile.Append(aMode, aProtect);
799 if (!( aFile.Exists() && aFile.IsOpen())) {
800 Standard_CString aStr=anASName.ToCString();
801 di << "Can not open the file: " << aStr << "\n";
804 TCollection_AsciiString aASTime(aChrono), aASendl("\n");
805 aASTime=aASTime+aASendl;
806 aFile.Write (aASTime, aASTime.Length());
810 //=======================================================================
811 //function : btimesum
813 //=======================================================================
814 Standard_Integer btimesum (Draw_Interpretor& di,
819 di << " Use >btimesum FileName\n";
823 TCollection_AsciiString anASName(a[1]);
824 OSD_OpenMode aMode = OSD_ReadWrite;
825 OSD_Protection aProtect(OSD_RW,OSD_RW,OSD_RW,OSD_RW);
826 OSD_Path aPath (anASName);
827 OSD_File aFile (aPath);
828 aFile.Open(aMode, aProtect);
830 if (!( aFile.Exists() && aFile.IsOpen())) {
831 Standard_CString aStr=anASName.ToCString();
832 di << "Can not open the file: " << aStr << "\n";
836 Standard_Integer aNbyteRead, aNByte=256, pos;
837 Standard_Real aTC, aTime=0.;
839 if (aFile.IsAtEnd()) {
843 TCollection_AsciiString aStr(aNByte);
844 aFile.ReadLine(aStr, aNByte, aNbyteRead);
845 //Standard_CString pStr=aStr.ToCString();
847 pos=aStr.Search("\n");
852 if (aStr.IsRealValue()) {
853 aTC=aStr.RealValue();
859 aFile.Append(aMode, aProtect);
861 TCollection_AsciiString aASLine("----------\n"), aASTime(aTime), aASendl("\n");
862 aASTime=aASTime+aASendl;
863 aFile.Write (aASLine, aASLine.Length());
864 aFile.Write (aASTime, aASTime.Length());
871 //=======================================================================
873 // ex. BOPTest_TSTCommands
877 #include <BOPTest_DrawableShape.hxx>
880 #include <DBRep_DrawableShape.hxx>
883 #include <Draw_Color.hxx>
885 #include <TCollection_AsciiString.hxx>
887 #include <TColStd_ListOfInteger.hxx>
888 #include <TColStd_ListIteratorOfListOfInteger.hxx>
891 #include <BooleanOperations_ShapesDataStructure.hxx>
892 #include <BOPTools_CArray1OfInterferenceLine.hxx>
893 #include <BOPTools_InterferenceLine.hxx>
894 #include <BOPTools_ListOfInterference.hxx>
895 #include <BOPTools_ListIteratorOfListOfInterference.hxx>
896 #include <BOPTools_Interference.hxx>
897 #include <BOPTools_InterferencePool.hxx>
899 #include <BOPTools_DSFiller.hxx>
900 #include <BOPTools_SplitShapesPool.hxx>
901 #include <BOPTools_ListOfPaveBlock.hxx>
902 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
903 #include <BOPTools_PaveBlock.hxx>
905 #include <BOPTools_PavePool.hxx>
906 #include <BOPTools_PaveSet.hxx>
907 #include <BOPTools_ListOfPave.hxx>
908 #include <BOPTools_ListIteratorOfListOfPave.hxx>
910 #include <BOPTools_CommonBlockPool.hxx>
911 #include <BOPTools_ListOfCommonBlock.hxx>
912 #include <BOPTools_ListIteratorOfListOfCommonBlock.hxx>
913 #include <BOPTools_CommonBlock.hxx>
914 #include <BOPTools_PaveFiller.hxx>
915 #include <BOPTools_CArray1OfSSInterference.hxx>
916 #include <BOPTools_SSInterference.hxx>
917 #include <BOPTools_InterferencePool.hxx>
918 #include <BOPTools_SequenceOfCurves.hxx>
919 #include <BOPTools_Curve.hxx>
921 #include <BOPTools_SequenceOfCurves.hxx>
922 #include <BOPTools_Curve.hxx>
923 #include <BOPTools_ListOfPaveBlock.hxx>
924 #include <BOPTools_PaveBlock.hxx>
925 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
928 static Standard_Integer bopinterf (Draw_Interpretor&, Standard_Integer, const char**);
929 static Standard_Integer bopds (Draw_Interpretor&, Standard_Integer, const char**);
930 static Standard_Integer bopsplits (Draw_Interpretor&, Standard_Integer, const char**);
931 static Standard_Integer bopscts (Draw_Interpretor&, Standard_Integer, const char**);
932 static Standard_Integer bopsamedomain(Draw_Interpretor&, Standard_Integer, const char**);
933 static Standard_Integer bopaves (Draw_Interpretor&, Standard_Integer, const char**);
934 static Standard_Integer bopsinf (Draw_Interpretor&, Standard_Integer, const char**);
935 static Standard_Integer bopsonf (Draw_Interpretor&, Standard_Integer, const char**);
936 static Standard_Integer bopnews (Draw_Interpretor& ,Standard_Integer, const char**);
938 //=======================================================================
939 //function : TSTCommands
941 //=======================================================================
942 void BOPTest::TSTCommands(Draw_Interpretor& theCommands)
944 static Standard_Boolean done = Standard_False;
946 done = Standard_True;
948 const char* g = "CCR commands";
950 theCommands.Add("bopinterf" , "", __FILE__, bopinterf, g);
951 theCommands.Add("bopds" , "Use bopds [-sw]", __FILE__, bopds, g);
953 theCommands.Add("bopsplits" , "", __FILE__, bopsplits, g);
954 theCommands.Add("bopscts" , "", __FILE__, bopscts, g);
956 theCommands.Add("bopsamedomain" , "", __FILE__, bopsamedomain, g);//SameDomain Edges
957 theCommands.Add("bopaves" , "", __FILE__, bopaves, g);
958 theCommands.Add("bopnews" , "bopnews [-f,w,e,v]", __FILE__, bopnews, g);
960 // All Splits of face1 IN face2
961 theCommands.Add("bopsinf" , "Use bopsinf #F1 #F2", __FILE__, bopsinf, g);
963 // All Splits of face1 ON face2
964 theCommands.Add("bopsonf" , "Use bopsinf #F1 #F2", __FILE__, bopsonf, g);
968 //=======================================================================
969 //function : bopinterf
971 //=======================================================================
972 Standard_Integer bopinterf (Draw_Interpretor& di,
973 Standard_Integer /*n*/,
977 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
981 Standard_Integer i, aNbLines;
984 Standard_Integer aWith, anIndex, aFst, aLF;
985 BooleanOperations_KindOfInterference aType;
987 const BOPTools_InterferencePool& anInterferencePool=pDF->InterfPool();
988 const BOPTools_CArray1OfInterferenceLine& aTableIL=anInterferencePool.InterferenceTable();
990 aNbLines=aTableIL.Extent();
991 for (i=1; i<=aNbLines; ++i) {
994 const BOPTools_InterferenceLine& aIL=aTableIL(i);
995 const BOPTools_ListOfInterference& aIList=aIL.List();
996 BOPTools_ListIteratorOfListOfInterference anIt(aIList);
997 for (; anIt.More(); anIt.Next()) {
998 const BOPTools_Interference& anInterf=anIt.Value();
999 aWith=anInterf.With();
1000 aType=anInterf.Type();
1001 anIndex=anInterf.Index();
1004 //printf(" #%d ", i);
1005 di << " #" << i << " ";
1009 //printf("(%d, %d, %d),", aWith, aType, anIndex);
1010 di << "(" << aWith << ", " << aType << ", " << anIndex << "),";
1021 //=======================================================================
1024 //=======================================================================
1025 Standard_Integer bopds (Draw_Interpretor& di,
1030 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1034 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1035 Standard_Integer i, aNbLines;
1038 aNbLines=aDS.NumberOfSourceShapes();
1041 if (!strcmp (a[2], "-o")) {
1042 aDS.ObjectRange(i, aNbLines);
1044 if (!strcmp (a[2], "-t")) {
1045 aDS.ToolRange(i, aNbLines);
1049 Draw_Color aTextColor(Draw_cyan);
1050 TCollection_AsciiString aNm("z");
1052 for (; i<=aNbLines; ++i) {
1054 const TopoDS_Shape& aS=aDS.GetShape(i);
1057 TopAbs_ShapeEnum aType=aS.ShapeType();
1059 if (aType==TopAbs_COMPOUND ||
1060 aType==TopAbs_COMPSOLID ||
1061 aType==TopAbs_SOLID ||
1062 aType==TopAbs_SHELL ||
1063 aType==TopAbs_FACE ||
1064 aType==TopAbs_WIRE) {
1070 if (!strcmp (a[1], "-c")) {
1071 if (aType!=TopAbs_COMPOUND) {
1075 else if (!strcmp (a[1], "-cs")) {
1076 if (aType!=TopAbs_COMPSOLID) {
1080 else if (!strcmp (a[1], "-s")) {
1081 if (aType!=TopAbs_SOLID) {
1085 else if (!strcmp (a[1], "-sh")) {
1086 if (aType!=TopAbs_SHELL) {
1090 else if (!strcmp (a[1], "-f")) {
1091 if (aType!=TopAbs_FACE) {
1095 else if (!strcmp (a[1], "-w")) {
1096 if (aType!=TopAbs_WIRE) {
1100 else if (!strcmp (a[1], "-e")) {
1101 if (aType!=TopAbs_EDGE) {
1105 else if (!strcmp (a[1], "-v")) {
1106 if (aType!=TopAbs_VERTEX) {
1115 TCollection_AsciiString aInd(i), aName;
1117 Standard_CString aText=aName.ToCString();
1119 Handle(BOPTest_DrawableShape) aDShape=
1120 new BOPTest_DrawableShape (aS, aText, aTextColor);
1121 Draw::Set (aText, aDShape);
1126 //=======================================================================
1127 //function : bopaves
1129 //=======================================================================
1130 Standard_Integer bopaves(Draw_Interpretor& di,
1131 Standard_Integer /*n*/,
1135 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1138 Standard_Integer i, aNbLines, anIndex;
1139 Standard_Real aParam;
1141 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1142 const BOPTools_PavePool& aPavePool=pDF->PavePool();
1144 aNbLines=aDS.NumberOfSourceShapes();
1145 for (i=1; i<=aNbLines; ++i) {
1146 const TopoDS_Shape& aS=aDS.GetShape(i);
1147 if (aS.ShapeType()==TopAbs_EDGE) {
1148 //printf(" Edge#%d\n", i);
1149 di << " Edge#" << i << "\n";
1150 const BOPTools_PaveSet& aPaveSet=aPavePool(aDS.RefEdge(i));
1151 const BOPTools_ListOfPave& aLP= aPaveSet.Set();
1152 BOPTools_ListIteratorOfListOfPave anIt(aLP);
1153 for (; anIt.More(); anIt.Next()){
1154 const BOPTools_Pave& aPave=anIt.Value();
1155 anIndex=aPave.Index();
1156 aParam =aPave.Param();
1157 //printf(" VertIndex=%d, aParam=%f\n", anIndex, aParam);
1158 di << " VertIndex=" << anIndex << ", aParam=" << aParam << "\n";
1165 //=======================================================================
1167 //purpose : SameDomain Edges
1168 //=======================================================================
1169 Standard_Integer bopsamedomain (Draw_Interpretor& di,
1170 Standard_Integer /*n*/,
1174 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1177 TCollection_AsciiString aNm("s");
1179 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1180 const BOPTools_CommonBlockPool& aCommonBlockPool=pDF->CommonBlockPool();
1182 Standard_Integer i, aNbLines, nFSD, nESD1, nESD2, nOriginal2;
1184 aNbLines=aDS.NumberOfSourceShapes();
1185 for (i=1; i<=aNbLines; ++i) {
1186 const TopoDS_Shape& aSE=aDS.GetShape(i);
1187 TopAbs_ShapeEnum aType=aSE.ShapeType();
1188 if (aType==TopAbs_EDGE) {
1190 const BOPTools_ListOfCommonBlock& aLCB=aCommonBlockPool(aDS.RefEdge(i));
1192 if (aLCB.Extent()) {
1194 BOPTools_ListIteratorOfListOfCommonBlock anIt(aLCB);
1195 for (; anIt.More(); anIt.Next()) {
1196 const BOPTools_CommonBlock& aCB=anIt.Value();
1199 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1();
1202 TCollection_AsciiString aInd(i), anUnd("_"), aName;
1206 Standard_CString aText=aName.ToCString();
1208 //printf(" (EF %s %df),", aText, nFSD);
1209 di << " (EF " << aText << " " << nFSD << "f),";
1213 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1();
1216 TCollection_AsciiString aInd(i), anUnd("_"), aName;
1220 Standard_CString aText=aName.ToCString();
1222 const BOPTools_PaveBlock& aPB2=aCB.PaveBlock2();
1224 nOriginal2=aPB2.OriginalEdge();
1226 TCollection_AsciiString aInd2(nOriginal2), aName2;
1228 aName2=aName2+anUnd;
1229 aName2=aName2+nESD2;
1230 Standard_CString aText2=aName2.ToCString();
1232 //printf(" (EE %s %s ),", aText, aText2);
1233 di << " (EE " << aText << " " << aText2 << " ),";
1243 //=======================================================================
1244 //function : bopnews
1246 //=======================================================================
1247 Standard_Integer bopnews (Draw_Interpretor& di,
1253 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1257 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1259 Standard_Integer i, iStart, aNbLinesTotal;
1260 Draw_Color aTextColor(Draw_cyan);
1261 TCollection_AsciiString aNm("z");
1264 TopAbs_ShapeEnum aType=TopAbs_EDGE;
1266 if (!strcmp (a[1], "-f")) {
1269 else if (!strcmp (a[1], "-w")) {
1272 else if (!strcmp (a[1], "-e")) {
1275 else if (!strcmp (a[1], "-v")) {
1276 aType=TopAbs_VERTEX;
1281 iStart=aDS.NumberOfSourceShapes()+1;
1282 aNbLinesTotal =aDS.NumberOfInsertedShapes();
1284 for (i=iStart; i<=aNbLinesTotal; ++i) {
1285 const TopoDS_Shape& aS=aDS.Shape(i);
1286 TopAbs_ShapeEnum aTypeCurrent=aS.ShapeType();
1287 if (aTypeCurrent==aType) {
1288 TCollection_AsciiString aName, aInd(i);
1290 Standard_CString aText=aName.ToCString();
1292 Handle(BOPTest_DrawableShape) aDShape=
1293 new BOPTest_DrawableShape (aS, aText, aTextColor);
1294 Draw::Set (aText, aDShape);
1295 //printf("%s ", aText);
1300 if (iStart>aNbLinesTotal) {
1301 di << " No new shapes occured";
1308 //=======================================================================
1309 //function : bopsplits
1311 //=======================================================================
1312 Standard_Integer bopsplits (Draw_Interpretor& di,
1313 Standard_Integer /*n*/,
1318 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1322 const BOPTools_SplitShapesPool& aSpPool=pDF->SplitShapesPool();
1323 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1325 Standard_Integer i, aNbLines, aNbSplits, aSplitExist=0;
1326 Draw_Color aTextColor(Draw_cyan);
1327 TCollection_AsciiString aNm("s");
1329 aNbLines=aDS.NumberOfSourceShapes();
1330 for (i=1; i<=aNbLines; ++i) {
1331 const TopoDS_Shape& aSE=aDS.GetShape(i);
1332 TopAbs_ShapeEnum aType=aSE.ShapeType();
1333 if (aType==TopAbs_EDGE) {
1335 // Splits' Prestentation
1336 const BOPTools_ListOfPaveBlock& aSplitsList=aSpPool(aDS.RefEdge(i));
1337 aNbSplits=aSplitsList.Extent();
1344 BOPTools_ListIteratorOfListOfPaveBlock anIt(aSplitsList);
1345 for (; anIt.More();anIt.Next()) {
1346 const BOPTools_PaveBlock& aPB=anIt.Value();
1347 Standard_Integer nSplit=aPB.Edge();
1348 const TopoDS_Shape& aS=aDS.GetShape(nSplit);
1350 TCollection_AsciiString aInd(i), anUnd("_"), aName;
1354 Standard_CString aText=aName.ToCString();
1356 Handle(BOPTest_DrawableShape) aDShape=
1357 new BOPTest_DrawableShape (aS, aText, aTextColor);
1358 Draw::Set (aText, aDShape);
1366 di << " No splits occured";
1372 //=======================================================================
1373 //function : bopscts
1375 //=======================================================================
1376 Standard_Integer bopscts (Draw_Interpretor& di,
1377 Standard_Integer /*n*/,
1382 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1385 Standard_Integer i, nF1, nF2, aNbFFs, aNbOldSects, aSectExist=0, nSect;
1386 Standard_Integer j, aNbCurves, aNbPaveBlocks, nNewEdge;
1387 Draw_Color aTextColor(Draw_cyan);
1388 TCollection_AsciiString aNm("t");
1390 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1391 const BOPTools_InterferencePool& anInterfPool=pDF->InterfPool();
1392 BOPTools_InterferencePool* pInterfPool= (BOPTools_InterferencePool*) &anInterfPool;
1393 BOPTools_CArray1OfSSInterference& aFFs=pInterfPool->SSInterferences();
1395 aNbFFs=aFFs.Extent();
1396 for (i=1; i<=aNbFFs; ++i) {
1397 BOPTools_SSInterference& aFFi=aFFs(i);
1401 TCollection_AsciiString aInd(nF1), anUnd("_");
1403 // Old Section Edges
1404 const BOPTools_ListOfPaveBlock& aSectList=aFFi.PaveBlocks();
1405 aNbOldSects=aSectList.Extent();
1412 BOPTools_ListIteratorOfListOfPaveBlock anIt(aSectList);
1413 for (; anIt.More();anIt.Next()) {
1414 const BOPTools_PaveBlock& aPB=anIt.Value();
1416 const TopoDS_Shape& aS=aDS.GetShape(nSect);
1418 TCollection_AsciiString aName;
1422 Standard_CString aText=aName.ToCString();
1424 Handle(BOPTest_DrawableShape) aDShape=
1425 new BOPTest_DrawableShape (aS, aText, aTextColor);
1426 Draw::Set (aText, aDShape);
1431 // New Section Edges
1432 BOPTools_SequenceOfCurves& aBCurves=aFFi.Curves();
1433 aNbCurves=aBCurves.Length();
1434 for (j=1; j<=aNbCurves; j++) {
1435 BOPTools_Curve& aBC=aBCurves(j);
1436 const BOPTools_ListOfPaveBlock& aSectEdges=aBC.NewPaveBlocks();
1437 aNbPaveBlocks=aSectEdges.Extent();
1438 if (aNbPaveBlocks) {
1444 BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSectEdges);
1445 for (; aPBIt.More(); aPBIt.Next()) {
1446 BOPTools_PaveBlock& aPB=aPBIt.Value();
1447 nNewEdge=aPB.Edge();
1448 const TopoDS_Shape& aSectEdge=aDS.GetShape(nNewEdge);
1450 TCollection_AsciiString aName;
1453 aName=aName+nNewEdge;
1454 Standard_CString aText=aName.ToCString();
1456 Handle(BOPTest_DrawableShape) aDShape=
1457 new BOPTest_DrawableShape (aSectEdge, aText, aTextColor);
1458 Draw::Set (aText, aDShape);
1465 di << " No section edges";
1471 //=======================================================================
1472 //function : bopsinf
1474 //=======================================================================
1475 Standard_Integer bopsinf (Draw_Interpretor& di,
1480 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1485 di << " Use: bopsinf> #F1 #F2\n";
1489 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1491 Standard_Integer nSp=0, nF1, nF2, anExistFlag=0;
1495 const TopoDS_Shape& aS1=aDS.GetShape(nF1);
1496 const TopoDS_Shape& aS2=aDS.GetShape(nF2);
1497 if (aS1.IsNull() || aS2.IsNull()) {
1498 //printf(" Null shapes #%d #%d\n", nF1, nF2 );
1499 di << " Null shapes #" << nF1 << " #" << nF2 << "\n";
1503 if (aS1.ShapeType()!=TopAbs_FACE ||
1504 aS1.ShapeType()!=TopAbs_FACE ) {
1505 //printf(" Shapes #%d #%d are not faces\n", nF1, nF2 );
1506 di << " Shapes #" << nF1 << " #" << nF2 << " are not faces\n";
1510 TColStd_ListOfInteger aSplList;
1511 const BOPTools_PaveFiller& aPF=pDF->PaveFiller();
1512 BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)&aPF;
1514 pPF->SplitsInFace (nSp, nF1, nF2, aSplList);
1516 TColStd_ListIteratorOfListOfInteger anIt (aSplList);
1517 for (; anIt.More(); anIt.Next()) {
1520 //printf("%d, ", nSp);
1528 di << "No splits of Face" << nF1 << " IN Face " << nF2 << "\n";
1533 //=======================================================================
1534 //function : bopsonf
1536 //=======================================================================
1537 Standard_Integer bopsonf (Draw_Interpretor& di,
1542 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1547 di << " Use: bopsonf> #F1 #F2\n";
1551 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1553 Standard_Integer nSp=0, nF1, nF2, anExistFlag=0;
1557 const TopoDS_Shape& aS1=aDS.GetShape(nF1);
1558 const TopoDS_Shape& aS2=aDS.GetShape(nF2);
1559 if (aS1.IsNull() || aS2.IsNull()) {
1560 //printf(" Null shapes #%d #%d\n", nF1, nF2 );
1561 di << " Null shapes #" << nF1 << " #" << nF2 << "\n";
1565 if (aS1.ShapeType()!=TopAbs_FACE ||
1566 aS1.ShapeType()!=TopAbs_FACE ) {
1567 //printf(" Shapes #%d #%d are not faces\n", nF1, nF2 );
1568 di << " Shapes #" << nF1 << " #" << nF2 << " are not faces\n";
1572 TColStd_ListOfInteger aSplList;
1573 const BOPTools_PaveFiller& aPF=pDF->PaveFiller();
1574 BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)&aPF;
1576 pPF->SplitsOnFace (nSp, nF1, nF2, aSplList);
1578 TColStd_ListIteratorOfListOfInteger anIt (aSplList);
1579 for (; anIt.More(); anIt.Next()) {
1582 //printf("%d, ", nSp);
1590 di << "No splits of Face" << nF1 << " ON Face " << nF2 << "\n";
1596 //=======================================================================
1599 //=======================================================================
1600 Standard_Integer bopwho (Draw_Interpretor& di,
1605 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1610 di << " Use >bopwho Index\n";
1614 Standard_Boolean bIsNewShape;
1615 Standard_Integer iNum, i, aNbLines, aNbObj, aNewShape, aWhat, aWith;
1619 di << " Shape Index must be >0 .\n";
1623 //printf("Shape #%d is ", iNum);
1624 di << "Shape #" << iNum << " is ";
1626 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1627 aNbLines=aDS.NumberOfSourceShapes();
1630 // Old shapes processing
1632 if (iNum>0 && iNum<=aNbLines) {
1635 aNbObj=aDS.NumberOfShapesOfTheObject();
1646 bIsNewShape=aDS.IsNewShape(iNum);
1652 di << "undefined.\n";
1656 // New shapes processing
1658 const TopoDS_Shape& aShapeToFind=aDS.Shape(iNum);
1659 TopAbs_ShapeEnum aTypeOfShapeToFind=aShapeToFind.ShapeType();
1662 const BOPTools_InterferencePool& anInterferencePool=pDF->InterfPool();
1664 const BOPTools_CArray1OfVVInterference& aVVInterfs=anInterferencePool.VVInterfs();
1665 const BOPTools_CArray1OfVEInterference& aVEInterfs=anInterferencePool.VEInterfs();
1666 const BOPTools_CArray1OfVSInterference& aVSInterfs=anInterferencePool.VSInterfs();
1667 const BOPTools_CArray1OfEEInterference& aEEInterfs=anInterferencePool.EEInterfs();
1668 const BOPTools_CArray1OfESInterference& aESInterfs=anInterferencePool.ESInterfs();
1671 aNbLines=aVVInterfs.Extent();
1672 for (i=1; i<=aNbLines; ++i) {
1673 aNewShape=aVVInterfs(i).NewShape();
1674 if (aNewShape==iNum) {
1675 aVVInterfs(i).Indices(aWhat, aWith);
1676 //printf(" VV: (%d, %d)\n", aWhat, aWith);
1677 di << " VV: (" << aWhat << ", " << aWith << ")\n";
1682 aNbLines=aVEInterfs.Extent();
1683 for (i=1; i<=aNbLines; ++i) {
1684 aNewShape=aVEInterfs(i).NewShape();
1685 if (aNewShape==iNum) {
1686 aVEInterfs(i).Indices(aWhat, aWith);
1687 //printf(" VE: (%d, %d)\n", aWhat, aWith);
1688 di << " VE: (" << aWhat << ", " << aWith << ")\n";
1693 aNbLines=aVSInterfs.Extent();
1694 for (i=1; i<=aNbLines; ++i) {
1695 aNewShape=aVSInterfs(i).NewShape();
1696 if (aNewShape==iNum) {
1697 aVSInterfs(i).Indices(aWhat, aWith);
1698 //printf(" VF: (%d, %d)\n", aWhat, aWith);
1699 di << " VF: (" << aWhat << ", " << aWith << ")\n";
1704 aNbLines=aEEInterfs.Extent();
1705 for (i=1; i<=aNbLines; ++i) {
1706 aNewShape=aEEInterfs(i).NewShape();
1707 if (aNewShape==iNum) {
1708 aEEInterfs(i).Indices(aWhat, aWith);
1709 //printf(" EE: (%d, %d)\n", aWhat, aWith);
1710 di << " EE: (" << aWhat << ", " << aWith << ")\n";
1715 aNbLines=aESInterfs.Extent();
1716 for (i=1; i<=aNbLines; ++i) {
1717 aNewShape=aESInterfs(i).NewShape();
1718 if (aNewShape==iNum) {
1719 aESInterfs(i).Indices(aWhat, aWith);
1720 //printf(" EF: (%d, %d)\n", aWhat, aWith);
1721 di << " EF: (" << aWhat << ", " << aWith << ")\n";
1726 Standard_Integer j, aNbCurves;
1728 BOPTools_InterferencePool* pInterPool=(BOPTools_InterferencePool*)&pDF->InterfPool();
1729 BOPTools_CArray1OfSSInterference& aSSInterfs=pInterPool->SSInterferences();
1731 aNbLines=aSSInterfs.Extent();
1732 for (i=1; i<=aNbLines; ++i) {
1733 BOPTools_SSInterference& aFF=aSSInterfs(i);
1738 BOPTools_SequenceOfCurves& aSC=aFF.Curves();
1740 aNbCurves=aSC.Length();
1741 for (j=1; j<=aNbCurves; ++j) {
1742 const BOPTools_Curve& aBC=aSC(j);
1744 if (aTypeOfShapeToFind==TopAbs_EDGE) {
1745 const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks();
1746 BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
1747 for (; anIt.More(); anIt.Next()) {
1748 const BOPTools_PaveBlock& aPB=anIt.Value();
1749 aNewShape=aPB.Edge();
1750 if (aNewShape==iNum) {
1751 //printf(" FF: (%d, %d) [Section Edge]\n", aWhat, aWith);
1752 di << " FF: (" << aWhat << ", " << aWith << ") [Section Edge]\n";
1757 if (aTypeOfShapeToFind==TopAbs_VERTEX) {
1758 BOPTools_Curve* pBC=(BOPTools_Curve*)&aBC;
1759 TColStd_ListOfInteger& aTVList=pBC->TechnoVertices();
1760 TColStd_ListIteratorOfListOfInteger aTVIt(aTVList);
1761 for (; aTVIt.More(); aTVIt.Next()) {
1762 aNewShape=aTVIt.Value();
1763 if (aNewShape==iNum) {
1764 //printf(" FF: (%d, %d) [Techno Vertex]\n", aWhat, aWith);
1765 di << " FF: (" << aWhat << ", " << aWith << ") [Techno Vertex]\n";
1771 if (aTypeOfShapeToFind==TopAbs_VERTEX) {
1772 TColStd_ListOfInteger& anAVList=aFF.AloneVertices();
1773 TColStd_ListIteratorOfListOfInteger anAVIt(anAVList);
1774 for (; anAVIt.More(); anAVIt.Next()) {
1775 aNewShape=anAVIt.Value();
1776 if (aNewShape==iNum) {
1777 //printf(" FF: (%d, %d) [Alone Vertex]\n", aWhat, aWith);
1778 di << " FF: (" << aWhat << ", " << aWith << ") [Alone Vertex]\n";
1786 if (aTypeOfShapeToFind==TopAbs_EDGE) {
1788 Standard_Integer aNbPaveBlocks, nE, nOriginalEdge, aNbCommonBlocks;
1789 Standard_Integer nFace, nE2, nOriginalEdge2;
1791 const BOPTools_CommonBlockPool& aCommonBlockPool=pDF->CommonBlockPool();
1792 const BOPTools_SplitShapesPool& aSplitShapesPool=pDF->SplitShapesPool();
1793 aNbLines=aSplitShapesPool.Extent();
1794 for (i=1; i<=aNbLines; ++i) {
1795 const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(i);
1796 aNbPaveBlocks=aSplitEdges.Extent();
1798 BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges);
1799 for (; aPBIt.More(); aPBIt.Next()) {
1800 const BOPTools_PaveBlock& aPB=aPBIt.Value();
1802 nOriginalEdge=aPB.OriginalEdge();
1804 //printf(" PaveBlock [Base Edge #%d]\n", nOriginalEdge);
1805 di << " PaveBlock [Base Edge #" << nOriginalEdge << "]\n";
1806 const BOPTools_ListOfCommonBlock& aLCB=
1807 aCommonBlockPool(aDS.RefEdge(nOriginalEdge));
1808 aNbCommonBlocks=aLCB.Extent();
1810 BOPTools_ListIteratorOfListOfCommonBlock aCBIt(aLCB);
1811 for (; aCBIt.More(); aCBIt.Next()) {
1812 BOPTools_CommonBlock& aCB=aCBIt.Value();
1815 //printf(" CommonBlock with Face #%d\n", nFace);
1816 di << " CommonBlock with Face #" << nFace << "\n";
1819 BOPTools_PaveBlock& aPB2=aCB.PaveBlock2(nOriginalEdge);
1821 nOriginalEdge2=aPB2.OriginalEdge();
1822 //printf(" CommonBlock with Edge #%d [Base Edge #%d]\n",
1823 // nE2, nOriginalEdge2);
1824 di << " CommonBlock with Edge #" << nE2 << " [Base Edge #" << nOriginalEdge2 << "]\n";
1836 //=======================================================================
1837 //function : bopsticks
1839 //=======================================================================
1840 Standard_Integer bopsticks (Draw_Interpretor& di,
1845 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1850 di << " Use >bopsticks\n";
1854 Standard_Integer i, j, aNbLines, nF1, nF2, aNbVtx, nV;
1856 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1857 const BOPTools_PaveFiller& aPF=pDF->PaveFiller();
1858 BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)&aPF;
1859 BOPTools_InterferencePool* pInterPool=(BOPTools_InterferencePool*)&pDF->InterfPool();
1860 BOPTools_CArray1OfSSInterference& aSSInterfs=pInterPool->SSInterferences();
1862 aNbLines=aSSInterfs.Extent();
1864 for (i=1; i<=aNbLines; ++i) {
1865 TColStd_IndexedMapOfInteger aMapUnUsed;
1866 BOPTools_PaveSet aPSF;
1868 BOPTools_SSInterference& aFF=aSSInterfs(i);
1869 BOPTools_SequenceOfCurves& aSCvs=aFF.Curves();
1874 pPF->PrepareSetForFace(nF1, nF2, aPSF);
1875 UnUsedMap(aSCvs, aPSF, aMapUnUsed);
1876 aNbVtx=aMapUnUsed.Extent();
1877 for (j=1; j<=aNbVtx; ++j) {
1879 if (aDS.IsNewShape(nV)) {
1880 //printf(" Vertex #%d [FF:(%d, %d)]\n", nV, nF1, nF2);
1881 di << " Vertex #" << nV << " [FF:(" << nF1 << ", " << nF2 << ")]\n";
1888 //=======================================================================
1889 // function: UnUsedMap
1891 //=======================================================================
1892 void UnUsedMap(BOPTools_SequenceOfCurves& aSCvs,
1893 const BOPTools_PaveSet& aPSF,
1894 TColStd_IndexedMapOfInteger& aMapUnUsed)
1897 // What stick/non-stick vertices we used
1898 TColStd_IndexedMapOfInteger aMapUsed, aMapMustBeUsed;
1899 Standard_Integer j, aNbCurves, aNbVtx, nV1;//, nV2;
1900 BOPTools_ListIteratorOfListOfPave anLPIt;
1902 aNbCurves=aSCvs.Length();
1903 for (j=1; j<=aNbCurves; ++j) {
1904 BOPTools_Curve& aBC=aSCvs(j);
1905 //const IntTools_Curve& aC= aBC.Curve();// Wng in Gcc 3.0
1907 const BOPTools_PaveSet& aPaveSet=aBC.Set();
1908 const BOPTools_ListOfPave& aLPAlreadyUsed=aPaveSet.Set();
1909 anLPIt.Initialize(aLPAlreadyUsed);
1910 for (; anLPIt.More(); anLPIt.Next()) {
1911 const BOPTools_Pave& aPave=anLPIt.Value();
1917 // 2. Stick vertices that must be used
1918 const BOPTools_ListOfPave& aLPMustUsed=aPSF.Set();
1919 anLPIt.Initialize(aLPMustUsed);
1920 for (; anLPIt.More(); anLPIt.Next()) {
1921 const BOPTools_Pave& aPave=anLPIt.Value();
1923 aMapMustBeUsed.Add(nV1);
1926 // 3.Unused Stick vertices .
1927 aNbVtx=aMapMustBeUsed.Extent();
1928 for (j=1; j<=aNbVtx; ++j) {
1929 nV1=aMapMustBeUsed(j);
1930 if (!aMapUsed.Contains(nV1)) {
1931 aMapUnUsed.Add(nV1);