1 // Created on: 2000-03-16
2 // Created by: Peter KURNEV
3 // Copyright (c) 2000-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
22 #include <BOPTest.ixx>
27 #include <DBRep_DrawableShape.hxx>
30 #include <Draw_Color.hxx>
32 #include <TCollection_AsciiString.hxx>
34 #include <TopAbs_ShapeEnum.hxx>
36 #include <TopoDS_Shape.hxx>
37 #include <TopoDS_Shell.hxx>
40 #include <TopTools_IndexedMapOfShape.hxx>
42 #include <BRep_Builder.hxx>
44 #include <BooleanOperations_ShapesDataStructure.hxx>
45 #include <BooleanOperations_StateOfShape.hxx>
47 #include <BOPTools_SolidStateFiller.hxx>
48 #include <BOPTools_DSFiller.hxx>
49 #include <BOPTools_SplitShapesPool.hxx>
50 #include <BOPTools_ListOfPaveBlock.hxx>
51 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
52 #include <BOPTools_PaveBlock.hxx>
53 #include <BOPTools_PCurveMaker.hxx>
54 #include <BOPTools_InterferencePool.hxx>
55 #include <BOPTools_CArray1OfVVInterference.hxx>
56 #include <BOPTools_CArray1OfVSInterference.hxx>
57 #include <BOPTools_CArray1OfVEInterference.hxx>
58 #include <BOPTools_CArray1OfESInterference.hxx>
59 #include <BOPTools_CArray1OfEEInterference.hxx>
60 #include <BOPTools_CArray1OfSSInterference.hxx>
61 #include <BOPTools_VVInterference.hxx>
62 #include <BOPTools_VEInterference.hxx>
63 #include <BOPTools_VSInterference.hxx>
64 #include <BOPTools_EEInterference.hxx>
65 #include <BOPTools_ESInterference.hxx>
66 #include <BOPTools_SSInterference.hxx>
68 #include <BOPTest_DrawableShape.hxx>
70 #include <BRepAlgoAPI_BooleanOperation.hxx>
71 #include <BRepAlgoAPI_Section.hxx>
72 #include <BRepAlgoAPI_Common.hxx>
73 #include <BRepAlgoAPI_Fuse.hxx>
74 #include <BRepAlgoAPI_Cut.hxx>
76 #include <OSD_Chronometer.hxx>
77 #include <TColStd_IndexedMapOfInteger.hxx>
79 static OSD_Chronometer DRAW_BOP_CHRONO;
80 static void StartChrono();
81 static void StopChrono(Draw_Interpretor&);
82 Standard_Integer btimesum (Draw_Interpretor& , Standard_Integer n, const char** a);
86 static Standard_Integer bop (Draw_Interpretor&, Standard_Integer, const char**);
88 static Standard_Integer bcommon (Draw_Interpretor& , Standard_Integer , const char**);
89 static Standard_Integer bfuse (Draw_Interpretor& , Standard_Integer , const char**);
90 static Standard_Integer bcut (Draw_Interpretor& , Standard_Integer , const char**);
91 static Standard_Integer bsection (Draw_Interpretor& , Standard_Integer , const char**);
93 static Standard_Integer bFillDS (Draw_Interpretor& , Standard_Integer , const char**);
95 static Standard_Integer bopcommon (Draw_Interpretor& , Standard_Integer , const char**);
96 static Standard_Integer bopfuse (Draw_Interpretor& , Standard_Integer , const char**);
97 static Standard_Integer bopcut (Draw_Interpretor& , Standard_Integer , const char**);
98 static Standard_Integer boptuc (Draw_Interpretor& , Standard_Integer , const char**);
99 static Standard_Integer bopsection (Draw_Interpretor& , Standard_Integer , const char**);
101 static Standard_Integer boperationFiller (Standard_Integer n, const char** a, const BOP_Operation anOp,
104 static Standard_Integer bopstates (Draw_Interpretor& , Standard_Integer , const char**);
106 static Standard_Integer bopwho (Draw_Interpretor& , Standard_Integer , const char**);
107 static Standard_Integer bopsticks (Draw_Interpretor& , Standard_Integer , const char**);
111 void UnUsedMap(BOPTools_SequenceOfCurves& ,
112 const BOPTools_PaveSet& ,
113 TColStd_IndexedMapOfInteger& );
114 //=======================================================================
115 //function : BOPCommands
117 //=======================================================================
118 void BOPTest::BOPCommands(Draw_Interpretor& theCommands)
120 static Standard_Boolean done = Standard_False;
124 done = Standard_True;
126 const char* g = "CCR commands";
128 // Using DSFiller that is ready.
129 theCommands.Add("bop" , "Use >bop Shape1 Shape2", __FILE__, bop, g);
130 theCommands.Add("bopcommon" , "Use >bopcommon R" , __FILE__, bopcommon , g);
131 theCommands.Add("bopfuse" , "Use >bopfuse R" , __FILE__, bopfuse , g);
132 theCommands.Add("bopcut" , "Use >bopcut R" , __FILE__, bopcut , g);
133 theCommands.Add("boptuc" , "Use >boptuc R" , __FILE__, boptuc , g);
134 theCommands.Add("bopsection", "Use >bopsection R", __FILE__, bopsection, g);
137 theCommands.Add("bopstates", "Use bopstates [-f] [-t] [-out]", __FILE__, bopstates, g);
139 theCommands.Add("bcommon" , "Use >bcommon R a b" , __FILE__, bcommon , g);
140 theCommands.Add("bfuse" , "Use >bfuse R a b" , __FILE__, bfuse , g);
141 theCommands.Add("bcut" , "Use >bcut R a b" , __FILE__, bcut , g);
144 theCommands.Add("bsection", "Use >bsection Result s1 s2 [-2d/-2d1/-2d2] [-a]"
145 , __FILE__, bsection, g);
147 theCommands.Add("btimesum" , "Use >btimesum FileName" , __FILE__, btimesum, g);
148 theCommands.Add("bopwho" , "Use >bopwho Index" , __FILE__, bopwho, g);
149 theCommands.Add("bopsticks" , "Use >bopsticks" , __FILE__, bopsticks, g);
153 //////////////////////////////////
155 // The one and only global variable
157 BOPTools_DSFiller *pDF;
159 //////////////////////////////////
161 //=======================================================================
164 //=======================================================================
165 Standard_Integer bop (Draw_Interpretor& di,
172 di << " Use >bop Shape1 Shape2\n";
177 TopoDS_Shape S1 = DBRep::Get(a[1]);
178 TopoDS_Shape S2 = DBRep::Get(a[2]);
180 if (S1.IsNull() || S2.IsNull()) {
181 di << " Null shapes are not allowed \n";
190 pDF=new BOPTools_DSFiller;
192 pDF->SetShapes (S1, S2);
193 if (!pDF->IsDone()) {
194 di << "Check types of the arguments, please\n";
204 //printf(" BOPTools_DSFiller is Ready to use\n");
211 //=======================================================================
214 //=======================================================================
215 Standard_Integer bFillDS (Draw_Interpretor& di,
220 di << " Usage: >command Result Shape1 Shape2\n";
224 return bop(di, n, a+1);
227 //=======================================================================
230 //=======================================================================
231 Standard_Integer bcommon (Draw_Interpretor& di,
235 Standard_Integer iFlag;
237 iFlag =bFillDS (di, n, a);
243 return bopcommon(di, n, a);
245 //=======================================================================
248 //=======================================================================
249 Standard_Integer bfuse(Draw_Interpretor& di,
253 Standard_Integer iFlag;
255 iFlag =bFillDS (di, n, a);
261 return bopfuse(di, n, a);
264 //=======================================================================
267 //=======================================================================
268 Standard_Integer bcut(Draw_Interpretor& di,
272 Standard_Integer iFlag;
274 iFlag =bFillDS (di, n, a);
280 return bopcut(di, n, a);
282 //=======================================================================
283 //function : bsection
285 //=======================================================================
286 Standard_Integer bsection(Draw_Interpretor& di,
290 const char* usage = " Usage: bsection Result s1 s2 [-2d/-2d1/-2d2] [-a]\n";
296 TopoDS_Shape S1 = DBRep::Get(a[2]);
297 TopoDS_Shape S2 = DBRep::Get(a[3]);
299 if (S1.IsNull() || S2.IsNull()) {
300 di << " Null shapes are not allowed \n";
305 BRepAlgoAPI_Section aSec(S1, S2, Standard_False);
306 aSec.Approximation(Standard_False);
307 aSec.ComputePCurveOn1(Standard_False);
308 aSec.ComputePCurveOn2(Standard_False);
309 Standard_Boolean isbadparameter = Standard_False;
312 const char* key1 = a[4];
313 const char* key2 = (n > 5) ? a[5] : NULL;
314 const char* pcurveconf = NULL;
315 Standard_Boolean approx = Standard_False;
318 if (key1 && !strcasecmp(key1,"-2d")) {
320 if (key1 && !strncasecmp(key1,"-2d", 3)) {
325 if (!strcasecmp(key1,"-a")) {
326 approx = Standard_True;
329 isbadparameter = Standard_True;
333 if (key2 && !strcasecmp(key2,"-2d")) {
335 if (key2 && !strncasecmp(key2,"-2d", 3)) {
338 isbadparameter = Standard_True;
346 if (!strcasecmp(key2,"-a")) {
347 approx = Standard_True;
350 isbadparameter = Standard_True;
355 if(!isbadparameter && pcurveconf) {
357 if (strcasecmp(pcurveconf, "-2d") == 0) {
358 aSec.ComputePCurveOn1(Standard_True);
359 aSec.ComputePCurveOn2(Standard_True);
362 if (strcasecmp(pcurveconf, "-2d1") == 0) {
363 aSec.ComputePCurveOn1(Standard_True);
366 if (strcasecmp(pcurveconf, "-2d2") == 0) {
367 aSec.ComputePCurveOn2(Standard_True);
372 aSec.Approximation(approx);
375 if(!isbadparameter) {
377 Standard_Boolean anIsDone = aSec.IsDone();
380 const TopoDS_Shape& aR = aSec.Shape();
381 DBRep::Set (a[1], aR);
384 di << "not done ErrorStatus()="<< aSec.ErrorStatus() <<"\n";
394 //=======================================================================
395 //function : bopcommon
397 //=======================================================================
398 Standard_Integer bopcommon (Draw_Interpretor& di,
402 return boperationFiller (n, a, BOP_COMMON, di);
405 //=======================================================================
408 //=======================================================================
409 Standard_Integer bopfuse(Draw_Interpretor& di,
413 return boperationFiller (n, a, BOP_FUSE, di);
416 //=======================================================================
419 //=======================================================================
420 Standard_Integer bopcut (Draw_Interpretor& di,
424 return boperationFiller (n, a, BOP_CUT, di);
426 //=======================================================================
429 //=======================================================================
430 Standard_Integer boptuc (Draw_Interpretor& di,
434 return boperationFiller (n, a, BOP_CUT21, di);
436 //=======================================================================
437 //function : bopsection
439 //=======================================================================
440 Standard_Integer bopsection (Draw_Interpretor& di,
444 return boperationFiller (n, a, BOP_SECTION, di);
447 //=======================================================================
448 //function : boperationFiller
450 //=======================================================================
451 Standard_Integer boperationFiller (Standard_Integer n,
453 const BOP_Operation anOp,
454 Draw_Interpretor& di)
461 di << " Use oper> Result [-mf]\n";
467 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
472 const TopoDS_Shape& S1 = pDF->Shape1();
473 const TopoDS_Shape& S2 = pDF->Shape2();
475 if (S1.IsNull() || S2.IsNull()) {
476 di << " Null shapes are not allowed \n";
481 Standard_Boolean aMFlag, anIsDone;
483 aMFlag=Standard_False;
485 BRepAlgoAPI_BooleanOperation* pBuilder=NULL;
488 if (anOp==BOP_SECTION) {
489 pBuilder=new BRepAlgoAPI_Section(S1, S2, *pDF);
491 else if (anOp==BOP_COMMON) {
492 pBuilder=new BRepAlgoAPI_Common(S1, S2, *pDF);
494 else if (anOp==BOP_FUSE) {
495 pBuilder=new BRepAlgoAPI_Fuse(S1, S2, *pDF);
497 else if (anOp==BOP_CUT) {
498 pBuilder=new BRepAlgoAPI_Cut (S1, S2, *pDF);
500 else if (anOp==BOP_CUT21) {
501 pBuilder=new BRepAlgoAPI_Cut(S1, S2, *pDF, Standard_False);
504 anIsDone=pBuilder->IsDone();
506 const TopoDS_Shape& aR=pBuilder->Shape();
507 DBRep::Set (a[1], aR);
510 di << "not done ErrorStatus()=" << pBuilder->ErrorStatus() << "\n";
520 //=======================================================================
524 void GetName (const BooleanOperations_StateOfShape aState,
525 TCollection_AsciiString& aNm);
527 TopAbs_ShapeEnum ChooseShapeType(const char* a1);
530 BooleanOperations_StateOfShape ChooseShapeState(const char* a3);
532 //=======================================================================
533 //function : bopstates
535 //=======================================================================
536 Standard_Integer bopstates(Draw_Interpretor& di,
541 di << " Use bopstates [-f] [-t] [-out]\n";
546 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
550 Standard_Integer i, aNbLines, aIsSmtToDraw=0;
551 BooleanOperations_StateOfShape aState, aChooseState;
552 aChooseState=BooleanOperations_UNKNOWN;
553 TopAbs_ShapeEnum aEnumToDisplay = TopAbs_COMPOUND;
554 Draw_Color aTextColor(Draw_cyan);
556 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
558 // Choose Object or Tool or All
560 aNbLines=aDS.NumberOfSourceShapes();
562 if (!strcmp (a[2], "-o")) {
563 aDS.ObjectRange(i, aNbLines);
565 if (!strcmp (a[2], "-t")) {
566 aDS.ToolRange(i, aNbLines);
572 aChooseState=ChooseShapeState(a[3]);
577 aEnumToDisplay=TopAbs_EDGE;
580 aEnumToDisplay=ChooseShapeType(a[1]);
584 for (; i<=aNbLines; ++i) {
585 const TopoDS_Shape& aS=aDS.GetShape(i);
586 TopAbs_ShapeEnum aCurrentType=aS.ShapeType();
587 if (aCurrentType==aEnumToDisplay) {
588 aState=aDS.GetState(i);
589 TCollection_AsciiString aNm, aInd(i);
590 GetName(aState, aNm);
592 if (aState==BooleanOperations_INTERSECTED && aCurrentType==TopAbs_EDGE) {
594 const BOPTools_SplitShapesPool& aSpPool=pDF->SplitShapesPool();
595 const BOPTools_ListOfPaveBlock& aSplitsList=aSpPool(aDS.RefEdge(i));
596 BOPTools_ListIteratorOfListOfPaveBlock anIt(aSplitsList);
597 for (; anIt.More();anIt.Next()) {
598 const BOPTools_PaveBlock& aPB=anIt.Value();
599 Standard_Integer nSplit=aPB.Edge();
600 const TopoDS_Shape& aSplit=aDS.GetShape(nSplit);
601 aState=aDS.GetState(nSplit);
602 GetName(aState, aNm);
604 TCollection_AsciiString aNmx, anUnd("_"), aIndx(nSplit);
608 Standard_CString aTxt=aNmx.ToCString();
610 if (aChooseState!=BooleanOperations_UNKNOWN) {
611 if (aState!=aChooseState) {
616 //printf("%s ", aTxt);
618 Handle(BOPTest_DrawableShape) aDSh=
619 new BOPTest_DrawableShape (aSplit, aTxt, aTextColor);
620 Draw::Set (aTxt, aDSh);
626 Standard_CString aText=aNm.ToCString();
628 if (aChooseState!=BooleanOperations_UNKNOWN) {
629 if (aState!=aChooseState) {
634 //printf("%s ", aText);
636 Handle(BOPTest_DrawableShape) aDShape=
637 new BOPTest_DrawableShape (aS, aText, aTextColor);
638 Draw::Set (aText, aDShape);
643 di << " No specified shapes\n";
653 //=======================================================================
656 //=======================================================================
657 void GetName (const BooleanOperations_StateOfShape aState,
658 TCollection_AsciiString& aNm)
660 TCollection_AsciiString aNmOut("ou_"), aNmIn("in_"),
661 aNmOn("on_"), aNmUn("un_"), aNmInter("intr_");
664 case BooleanOperations_OUT:
667 case BooleanOperations_IN:
670 case BooleanOperations_ON:
673 case BooleanOperations_INTERSECTED:
682 //=======================================================================
683 //function : ChooseShapeType
685 //=======================================================================
686 TopAbs_ShapeEnum ChooseShapeType(const char* a1)
688 TopAbs_ShapeEnum aEnumToDisplay;
690 if (!strcmp (a1, "-c")) {
691 aEnumToDisplay=TopAbs_COMPOUND;
693 else if (!strcmp (a1, "-cs")) {
694 aEnumToDisplay=TopAbs_COMPSOLID;
696 else if (!strcmp (a1, "-s")) {
697 aEnumToDisplay=TopAbs_SOLID;
699 else if (!strcmp (a1, "-sh")) {
700 aEnumToDisplay=TopAbs_SHELL;
702 else if (!strcmp (a1, "-f")) {
703 aEnumToDisplay=TopAbs_FACE;
705 else if (!strcmp (a1, "-w")) {
706 aEnumToDisplay=TopAbs_WIRE;
708 else if (!strcmp (a1, "-e")) {
709 aEnumToDisplay=TopAbs_EDGE;
711 else if (!strcmp (a1, "-v")) {
712 aEnumToDisplay=TopAbs_VERTEX;
715 aEnumToDisplay=TopAbs_EDGE;
717 return aEnumToDisplay;
720 //=======================================================================
721 //function : ChooseShapeState
723 //=======================================================================
724 BooleanOperations_StateOfShape ChooseShapeState(const char* a3)
726 BooleanOperations_StateOfShape aChooseState=BooleanOperations_UNKNOWN;
728 if (!strcmp (a3, "-out")) {
729 aChooseState=BooleanOperations_OUT;
731 if (!strcmp (a3, "-in")) {
732 aChooseState=BooleanOperations_IN;
734 if (!strcmp (a3, "-on")) {
735 aChooseState=BooleanOperations_ON;
742 #include <OSD_Chronometer.hxx>
743 #include <TCollection_AsciiString.hxx>
744 #include <OSD_OpenMode.hxx>
745 #include <OSD_Path.hxx>
746 #include <OSD_Protection.hxx>
747 #include <OSD_File.hxx>
749 static void SaveTimeInFile(const Standard_CString aFileName,
750 const Standard_Real aChrono,
751 Draw_Interpretor& di);
753 //=======================================================================
754 //function : StartChrono
756 //=======================================================================
759 char *xr=getenv ("BOPCHRONO");
761 if (!strcmp (xr, "yes")){
762 DRAW_BOP_CHRONO.Reset();
763 DRAW_BOP_CHRONO.Start();
768 //=======================================================================
769 //function : StopChrono
771 //=======================================================================
772 void StopChrono(Draw_Interpretor& di)
774 char *xr=getenv ("BOPCHRONO");
776 if (!strcmp (xr, "yes")) {
777 Standard_Real Chrono;
778 DRAW_BOP_CHRONO.Stop();
779 DRAW_BOP_CHRONO.Show(Chrono);
781 char *aFileName=getenv("BOPCHRONOFILE");
782 if (aFileName!=NULL){
783 SaveTimeInFile(aFileName, Chrono, di);
786 di << "Tps: " << Chrono << "\n";
792 //=======================================================================
793 //function : SaveTimeInFile
795 //=======================================================================
796 void SaveTimeInFile(const Standard_CString aFileName,
797 const Standard_Real aChrono,
798 Draw_Interpretor& di)
800 OSD_OpenMode aMode = OSD_ReadWrite;
801 OSD_Protection aProtect(OSD_RW,OSD_RW,OSD_RW,OSD_RW);
802 TCollection_AsciiString anASName(aFileName);
803 OSD_Path aPath (anASName);
804 OSD_File aFile (aPath);
805 aFile.Append(aMode, aProtect);
806 if (!( aFile.Exists() && aFile.IsOpen())) {
807 Standard_CString aStr=anASName.ToCString();
808 di << "Can not open the file: " << aStr << "\n";
811 TCollection_AsciiString aASTime(aChrono), aASendl("\n");
812 aASTime=aASTime+aASendl;
813 aFile.Write (aASTime, aASTime.Length());
817 //=======================================================================
818 //function : btimesum
820 //=======================================================================
821 Standard_Integer btimesum (Draw_Interpretor& di,
826 di << " Use >btimesum FileName\n";
830 TCollection_AsciiString anASName(a[1]);
831 OSD_OpenMode aMode = OSD_ReadWrite;
832 OSD_Protection aProtect(OSD_RW,OSD_RW,OSD_RW,OSD_RW);
833 OSD_Path aPath (anASName);
834 OSD_File aFile (aPath);
835 aFile.Open(aMode, aProtect);
837 if (!( aFile.Exists() && aFile.IsOpen())) {
838 Standard_CString aStr=anASName.ToCString();
839 di << "Can not open the file: " << aStr << "\n";
843 Standard_Integer aNbyteRead, aNByte=256, pos;
844 Standard_Real aTC, aTime=0.;
846 if (aFile.IsAtEnd()) {
850 TCollection_AsciiString aStr(aNByte);
851 aFile.ReadLine(aStr, aNByte, aNbyteRead);
852 //Standard_CString pStr=aStr.ToCString();
854 pos=aStr.Search("\n");
859 if (aStr.IsRealValue()) {
860 aTC=aStr.RealValue();
866 aFile.Append(aMode, aProtect);
868 TCollection_AsciiString aASLine("----------\n"), aASTime(aTime), aASendl("\n");
869 aASTime=aASTime+aASendl;
870 aFile.Write (aASLine, aASLine.Length());
871 aFile.Write (aASTime, aASTime.Length());
878 //=======================================================================
880 // ex. BOPTest_TSTCommands
884 #include <BOPTest_DrawableShape.hxx>
887 #include <DBRep_DrawableShape.hxx>
890 #include <Draw_Color.hxx>
892 #include <TCollection_AsciiString.hxx>
894 #include <TColStd_ListOfInteger.hxx>
895 #include <TColStd_ListIteratorOfListOfInteger.hxx>
898 #include <BooleanOperations_ShapesDataStructure.hxx>
899 #include <BOPTools_CArray1OfInterferenceLine.hxx>
900 #include <BOPTools_InterferenceLine.hxx>
901 #include <BOPTools_ListOfInterference.hxx>
902 #include <BOPTools_ListIteratorOfListOfInterference.hxx>
903 #include <BOPTools_Interference.hxx>
904 #include <BOPTools_InterferencePool.hxx>
906 #include <BOPTools_DSFiller.hxx>
907 #include <BOPTools_SplitShapesPool.hxx>
908 #include <BOPTools_ListOfPaveBlock.hxx>
909 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
910 #include <BOPTools_PaveBlock.hxx>
912 #include <BOPTools_PavePool.hxx>
913 #include <BOPTools_PaveSet.hxx>
914 #include <BOPTools_ListOfPave.hxx>
915 #include <BOPTools_ListIteratorOfListOfPave.hxx>
917 #include <BOPTools_CommonBlockPool.hxx>
918 #include <BOPTools_ListOfCommonBlock.hxx>
919 #include <BOPTools_ListIteratorOfListOfCommonBlock.hxx>
920 #include <BOPTools_CommonBlock.hxx>
921 #include <BOPTools_PaveFiller.hxx>
922 #include <BOPTools_CArray1OfSSInterference.hxx>
923 #include <BOPTools_SSInterference.hxx>
924 #include <BOPTools_InterferencePool.hxx>
925 #include <BOPTools_SequenceOfCurves.hxx>
926 #include <BOPTools_Curve.hxx>
928 #include <BOPTools_SequenceOfCurves.hxx>
929 #include <BOPTools_Curve.hxx>
930 #include <BOPTools_ListOfPaveBlock.hxx>
931 #include <BOPTools_PaveBlock.hxx>
932 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
935 static Standard_Integer bopinterf (Draw_Interpretor&, Standard_Integer, const char**);
936 static Standard_Integer bopds (Draw_Interpretor&, Standard_Integer, const char**);
937 static Standard_Integer bopsplits (Draw_Interpretor&, Standard_Integer, const char**);
938 static Standard_Integer bopscts (Draw_Interpretor&, Standard_Integer, const char**);
939 static Standard_Integer bopsamedomain(Draw_Interpretor&, Standard_Integer, const char**);
940 static Standard_Integer bopaves (Draw_Interpretor&, Standard_Integer, const char**);
941 static Standard_Integer bopsinf (Draw_Interpretor&, Standard_Integer, const char**);
942 static Standard_Integer bopsonf (Draw_Interpretor&, Standard_Integer, const char**);
943 static Standard_Integer bopnews (Draw_Interpretor& ,Standard_Integer, const char**);
945 //=======================================================================
946 //function : TSTCommands
948 //=======================================================================
949 void BOPTest::TSTCommands(Draw_Interpretor& theCommands)
951 static Standard_Boolean done = Standard_False;
953 done = Standard_True;
955 const char* g = "CCR commands";
957 theCommands.Add("bopinterf" , "", __FILE__, bopinterf, g);
958 theCommands.Add("bopds" , "Use bopds [-sw]", __FILE__, bopds, g);
960 theCommands.Add("bopsplits" , "", __FILE__, bopsplits, g);
961 theCommands.Add("bopscts" , "", __FILE__, bopscts, g);
963 theCommands.Add("bopsamedomain" , "", __FILE__, bopsamedomain, g);//SameDomain Edges
964 theCommands.Add("bopaves" , "", __FILE__, bopaves, g);
965 theCommands.Add("bopnews" , "bopnews [-f,w,e,v]", __FILE__, bopnews, g);
967 // All Splits of face1 IN face2
968 theCommands.Add("bopsinf" , "Use bopsinf #F1 #F2", __FILE__, bopsinf, g);
970 // All Splits of face1 ON face2
971 theCommands.Add("bopsonf" , "Use bopsinf #F1 #F2", __FILE__, bopsonf, g);
975 //=======================================================================
976 //function : bopinterf
978 //=======================================================================
979 Standard_Integer bopinterf (Draw_Interpretor& di,
980 Standard_Integer /*n*/,
984 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
988 Standard_Integer i, aNbLines;
991 Standard_Integer aWith, anIndex, aFst, aLF;
992 BooleanOperations_KindOfInterference aType;
994 const BOPTools_InterferencePool& anInterferencePool=pDF->InterfPool();
995 const BOPTools_CArray1OfInterferenceLine& aTableIL=anInterferencePool.InterferenceTable();
997 aNbLines=aTableIL.Extent();
998 for (i=1; i<=aNbLines; ++i) {
1001 const BOPTools_InterferenceLine& aIL=aTableIL(i);
1002 const BOPTools_ListOfInterference& aIList=aIL.List();
1003 BOPTools_ListIteratorOfListOfInterference anIt(aIList);
1004 for (; anIt.More(); anIt.Next()) {
1005 const BOPTools_Interference& anInterf=anIt.Value();
1006 aWith=anInterf.With();
1007 aType=anInterf.Type();
1008 anIndex=anInterf.Index();
1011 //printf(" #%d ", i);
1012 di << " #" << i << " ";
1016 //printf("(%d, %d, %d),", aWith, aType, anIndex);
1017 di << "(" << aWith << ", " << aType << ", " << anIndex << "),";
1028 //=======================================================================
1031 //=======================================================================
1032 Standard_Integer bopds (Draw_Interpretor& di,
1037 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1041 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1042 Standard_Integer i, aNbLines;
1045 aNbLines=aDS.NumberOfSourceShapes();
1048 if (!strcmp (a[2], "-o")) {
1049 aDS.ObjectRange(i, aNbLines);
1051 if (!strcmp (a[2], "-t")) {
1052 aDS.ToolRange(i, aNbLines);
1056 Draw_Color aTextColor(Draw_cyan);
1057 TCollection_AsciiString aNm("z");
1059 for (; i<=aNbLines; ++i) {
1061 const TopoDS_Shape& aS=aDS.GetShape(i);
1064 TopAbs_ShapeEnum aType=aS.ShapeType();
1066 if (aType==TopAbs_COMPOUND ||
1067 aType==TopAbs_COMPSOLID ||
1068 aType==TopAbs_SOLID ||
1069 aType==TopAbs_SHELL ||
1070 aType==TopAbs_FACE ||
1071 aType==TopAbs_WIRE) {
1077 if (!strcmp (a[1], "-c")) {
1078 if (aType!=TopAbs_COMPOUND) {
1082 else if (!strcmp (a[1], "-cs")) {
1083 if (aType!=TopAbs_COMPSOLID) {
1087 else if (!strcmp (a[1], "-s")) {
1088 if (aType!=TopAbs_SOLID) {
1092 else if (!strcmp (a[1], "-sh")) {
1093 if (aType!=TopAbs_SHELL) {
1097 else if (!strcmp (a[1], "-f")) {
1098 if (aType!=TopAbs_FACE) {
1102 else if (!strcmp (a[1], "-w")) {
1103 if (aType!=TopAbs_WIRE) {
1107 else if (!strcmp (a[1], "-e")) {
1108 if (aType!=TopAbs_EDGE) {
1112 else if (!strcmp (a[1], "-v")) {
1113 if (aType!=TopAbs_VERTEX) {
1122 TCollection_AsciiString aInd(i), aName;
1124 Standard_CString aText=aName.ToCString();
1126 Handle(BOPTest_DrawableShape) aDShape=
1127 new BOPTest_DrawableShape (aS, aText, aTextColor);
1128 Draw::Set (aText, aDShape);
1133 //=======================================================================
1134 //function : bopaves
1136 //=======================================================================
1137 Standard_Integer bopaves(Draw_Interpretor& di,
1138 Standard_Integer /*n*/,
1142 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1145 Standard_Integer i, aNbLines, anIndex;
1146 Standard_Real aParam;
1148 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1149 const BOPTools_PavePool& aPavePool=pDF->PavePool();
1151 aNbLines=aDS.NumberOfSourceShapes();
1152 for (i=1; i<=aNbLines; ++i) {
1153 const TopoDS_Shape& aS=aDS.GetShape(i);
1154 if (aS.ShapeType()==TopAbs_EDGE) {
1155 //printf(" Edge#%d\n", i);
1156 di << " Edge#" << i << "\n";
1157 const BOPTools_PaveSet& aPaveSet=aPavePool(aDS.RefEdge(i));
1158 const BOPTools_ListOfPave& aLP= aPaveSet.Set();
1159 BOPTools_ListIteratorOfListOfPave anIt(aLP);
1160 for (; anIt.More(); anIt.Next()){
1161 const BOPTools_Pave& aPave=anIt.Value();
1162 anIndex=aPave.Index();
1163 aParam =aPave.Param();
1164 //printf(" VertIndex=%d, aParam=%f\n", anIndex, aParam);
1165 di << " VertIndex=" << anIndex << ", aParam=" << aParam << "\n";
1172 //=======================================================================
1174 //purpose : SameDomain Edges
1175 //=======================================================================
1176 Standard_Integer bopsamedomain (Draw_Interpretor& di,
1177 Standard_Integer /*n*/,
1181 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1184 TCollection_AsciiString aNm("s");
1186 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1187 const BOPTools_CommonBlockPool& aCommonBlockPool=pDF->CommonBlockPool();
1189 Standard_Integer i, aNbLines, nFSD, nESD1, nESD2, nOriginal2;
1191 aNbLines=aDS.NumberOfSourceShapes();
1192 for (i=1; i<=aNbLines; ++i) {
1193 const TopoDS_Shape& aSE=aDS.GetShape(i);
1194 TopAbs_ShapeEnum aType=aSE.ShapeType();
1195 if (aType==TopAbs_EDGE) {
1197 const BOPTools_ListOfCommonBlock& aLCB=aCommonBlockPool(aDS.RefEdge(i));
1199 if (aLCB.Extent()) {
1201 BOPTools_ListIteratorOfListOfCommonBlock anIt(aLCB);
1202 for (; anIt.More(); anIt.Next()) {
1203 const BOPTools_CommonBlock& aCB=anIt.Value();
1206 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1();
1209 TCollection_AsciiString aInd(i), anUnd("_"), aName;
1213 Standard_CString aText=aName.ToCString();
1215 //printf(" (EF %s %df),", aText, nFSD);
1216 di << " (EF " << aText << " " << nFSD << "f),";
1220 const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1();
1223 TCollection_AsciiString aInd(i), anUnd("_"), aName;
1227 Standard_CString aText=aName.ToCString();
1229 const BOPTools_PaveBlock& aPB2=aCB.PaveBlock2();
1231 nOriginal2=aPB2.OriginalEdge();
1233 TCollection_AsciiString aInd2(nOriginal2), aName2;
1235 aName2=aName2+anUnd;
1236 aName2=aName2+nESD2;
1237 Standard_CString aText2=aName2.ToCString();
1239 //printf(" (EE %s %s ),", aText, aText2);
1240 di << " (EE " << aText << " " << aText2 << " ),";
1250 //=======================================================================
1251 //function : bopnews
1253 //=======================================================================
1254 Standard_Integer bopnews (Draw_Interpretor& di,
1260 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1264 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1266 Standard_Integer i, iStart, aNbLinesTotal;
1267 Draw_Color aTextColor(Draw_cyan);
1268 TCollection_AsciiString aNm("z");
1271 TopAbs_ShapeEnum aType=TopAbs_EDGE;
1273 if (!strcmp (a[1], "-f")) {
1276 else if (!strcmp (a[1], "-w")) {
1279 else if (!strcmp (a[1], "-e")) {
1282 else if (!strcmp (a[1], "-v")) {
1283 aType=TopAbs_VERTEX;
1288 iStart=aDS.NumberOfSourceShapes()+1;
1289 aNbLinesTotal =aDS.NumberOfInsertedShapes();
1291 for (i=iStart; i<=aNbLinesTotal; ++i) {
1292 const TopoDS_Shape& aS=aDS.Shape(i);
1293 TopAbs_ShapeEnum aTypeCurrent=aS.ShapeType();
1294 if (aTypeCurrent==aType) {
1295 TCollection_AsciiString aName, aInd(i);
1297 Standard_CString aText=aName.ToCString();
1299 Handle(BOPTest_DrawableShape) aDShape=
1300 new BOPTest_DrawableShape (aS, aText, aTextColor);
1301 Draw::Set (aText, aDShape);
1302 //printf("%s ", aText);
1307 if (iStart>aNbLinesTotal) {
1308 di << " No new shapes occured";
1315 //=======================================================================
1316 //function : bopsplits
1318 //=======================================================================
1319 Standard_Integer bopsplits (Draw_Interpretor& di,
1320 Standard_Integer /*n*/,
1325 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1329 const BOPTools_SplitShapesPool& aSpPool=pDF->SplitShapesPool();
1330 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1332 Standard_Integer i, aNbLines, aNbSplits, aSplitExist=0;
1333 Draw_Color aTextColor(Draw_cyan);
1334 TCollection_AsciiString aNm("s");
1336 aNbLines=aDS.NumberOfSourceShapes();
1337 for (i=1; i<=aNbLines; ++i) {
1338 const TopoDS_Shape& aSE=aDS.GetShape(i);
1339 TopAbs_ShapeEnum aType=aSE.ShapeType();
1340 if (aType==TopAbs_EDGE) {
1342 // Splits' Prestentation
1343 const BOPTools_ListOfPaveBlock& aSplitsList=aSpPool(aDS.RefEdge(i));
1344 aNbSplits=aSplitsList.Extent();
1351 BOPTools_ListIteratorOfListOfPaveBlock anIt(aSplitsList);
1352 for (; anIt.More();anIt.Next()) {
1353 const BOPTools_PaveBlock& aPB=anIt.Value();
1354 Standard_Integer nSplit=aPB.Edge();
1355 const TopoDS_Shape& aS=aDS.GetShape(nSplit);
1357 TCollection_AsciiString aInd(i), anUnd("_"), aName;
1361 Standard_CString aText=aName.ToCString();
1363 Handle(BOPTest_DrawableShape) aDShape=
1364 new BOPTest_DrawableShape (aS, aText, aTextColor);
1365 Draw::Set (aText, aDShape);
1373 di << " No splits occured";
1379 //=======================================================================
1380 //function : bopscts
1382 //=======================================================================
1383 Standard_Integer bopscts (Draw_Interpretor& di,
1384 Standard_Integer /*n*/,
1389 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1392 Standard_Integer i, nF1, nF2, aNbFFs, aNbOldSects, aSectExist=0, nSect;
1393 Standard_Integer j, aNbCurves, aNbPaveBlocks, nNewEdge;
1394 Draw_Color aTextColor(Draw_cyan);
1395 TCollection_AsciiString aNm("t");
1397 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1398 const BOPTools_InterferencePool& anInterfPool=pDF->InterfPool();
1399 BOPTools_InterferencePool* pInterfPool= (BOPTools_InterferencePool*) &anInterfPool;
1400 BOPTools_CArray1OfSSInterference& aFFs=pInterfPool->SSInterferences();
1402 aNbFFs=aFFs.Extent();
1403 for (i=1; i<=aNbFFs; ++i) {
1404 BOPTools_SSInterference& aFFi=aFFs(i);
1408 TCollection_AsciiString aInd(nF1), anUnd("_");
1410 // Old Section Edges
1411 const BOPTools_ListOfPaveBlock& aSectList=aFFi.PaveBlocks();
1412 aNbOldSects=aSectList.Extent();
1419 BOPTools_ListIteratorOfListOfPaveBlock anIt(aSectList);
1420 for (; anIt.More();anIt.Next()) {
1421 const BOPTools_PaveBlock& aPB=anIt.Value();
1423 const TopoDS_Shape& aS=aDS.GetShape(nSect);
1425 TCollection_AsciiString aName;
1429 Standard_CString aText=aName.ToCString();
1431 Handle(BOPTest_DrawableShape) aDShape=
1432 new BOPTest_DrawableShape (aS, aText, aTextColor);
1433 Draw::Set (aText, aDShape);
1438 // New Section Edges
1439 BOPTools_SequenceOfCurves& aBCurves=aFFi.Curves();
1440 aNbCurves=aBCurves.Length();
1441 for (j=1; j<=aNbCurves; j++) {
1442 BOPTools_Curve& aBC=aBCurves(j);
1443 const BOPTools_ListOfPaveBlock& aSectEdges=aBC.NewPaveBlocks();
1444 aNbPaveBlocks=aSectEdges.Extent();
1445 if (aNbPaveBlocks) {
1451 BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSectEdges);
1452 for (; aPBIt.More(); aPBIt.Next()) {
1453 BOPTools_PaveBlock& aPB=aPBIt.Value();
1454 nNewEdge=aPB.Edge();
1455 const TopoDS_Shape& aSectEdge=aDS.GetShape(nNewEdge);
1457 TCollection_AsciiString aName;
1460 aName=aName+nNewEdge;
1461 Standard_CString aText=aName.ToCString();
1463 Handle(BOPTest_DrawableShape) aDShape=
1464 new BOPTest_DrawableShape (aSectEdge, aText, aTextColor);
1465 Draw::Set (aText, aDShape);
1472 di << " No section edges";
1478 //=======================================================================
1479 //function : bopsinf
1481 //=======================================================================
1482 Standard_Integer bopsinf (Draw_Interpretor& di,
1487 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1492 di << " Use: bopsinf> #F1 #F2\n";
1496 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1498 Standard_Integer nSp=0, nF1, nF2, anExistFlag=0;
1502 const TopoDS_Shape& aS1=aDS.GetShape(nF1);
1503 const TopoDS_Shape& aS2=aDS.GetShape(nF2);
1504 if (aS1.IsNull() || aS2.IsNull()) {
1505 //printf(" Null shapes #%d #%d\n", nF1, nF2 );
1506 di << " Null shapes #" << nF1 << " #" << nF2 << "\n";
1510 if (aS1.ShapeType()!=TopAbs_FACE ||
1511 aS2.ShapeType()!=TopAbs_FACE ) {
1512 //printf(" Shapes #%d #%d are not faces\n", nF1, nF2 );
1513 di << " Shapes #" << nF1 << " #" << nF2 << " are not faces\n";
1517 TColStd_ListOfInteger aSplList;
1518 const BOPTools_PaveFiller& aPF=pDF->PaveFiller();
1519 BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)&aPF;
1521 pPF->SplitsInFace (nSp, nF1, nF2, aSplList);
1523 TColStd_ListIteratorOfListOfInteger anIt (aSplList);
1524 for (; anIt.More(); anIt.Next()) {
1527 //printf("%d, ", nSp);
1535 di << "No splits of Face" << nF1 << " IN Face " << nF2 << "\n";
1540 //=======================================================================
1541 //function : bopsonf
1543 //=======================================================================
1544 Standard_Integer bopsonf (Draw_Interpretor& di,
1549 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1554 di << " Use: bopsonf> #F1 #F2\n";
1558 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1560 Standard_Integer nSp=0, nF1, nF2, anExistFlag=0;
1564 const TopoDS_Shape& aS1=aDS.GetShape(nF1);
1565 const TopoDS_Shape& aS2=aDS.GetShape(nF2);
1566 if (aS1.IsNull() || aS2.IsNull()) {
1567 //printf(" Null shapes #%d #%d\n", nF1, nF2 );
1568 di << " Null shapes #" << nF1 << " #" << nF2 << "\n";
1572 if (aS1.ShapeType()!=TopAbs_FACE ||
1573 aS2.ShapeType()!=TopAbs_FACE ) {
1574 //printf(" Shapes #%d #%d are not faces\n", nF1, nF2 );
1575 di << " Shapes #" << nF1 << " #" << nF2 << " are not faces\n";
1579 TColStd_ListOfInteger aSplList;
1580 const BOPTools_PaveFiller& aPF=pDF->PaveFiller();
1581 BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)&aPF;
1583 pPF->SplitsOnFace (nSp, nF1, nF2, aSplList);
1585 TColStd_ListIteratorOfListOfInteger anIt (aSplList);
1586 for (; anIt.More(); anIt.Next()) {
1589 //printf("%d, ", nSp);
1597 di << "No splits of Face" << nF1 << " ON Face " << nF2 << "\n";
1603 //=======================================================================
1606 //=======================================================================
1607 Standard_Integer bopwho (Draw_Interpretor& di,
1612 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1617 di << " Use >bopwho Index\n";
1621 Standard_Boolean bIsNewShape;
1622 Standard_Integer iNum, i, aNbLines, aNbObj, aNewShape, aWhat, aWith;
1626 di << " Shape Index must be >0 .\n";
1630 //printf("Shape #%d is ", iNum);
1631 di << "Shape #" << iNum << " is ";
1633 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1634 aNbLines=aDS.NumberOfSourceShapes();
1637 // Old shapes processing
1639 if (iNum>0 && iNum<=aNbLines) {
1642 aNbObj=aDS.NumberOfShapesOfTheObject();
1653 bIsNewShape=aDS.IsNewShape(iNum);
1659 di << "undefined.\n";
1663 // New shapes processing
1665 const TopoDS_Shape& aShapeToFind=aDS.Shape(iNum);
1666 TopAbs_ShapeEnum aTypeOfShapeToFind=aShapeToFind.ShapeType();
1669 const BOPTools_InterferencePool& anInterferencePool=pDF->InterfPool();
1671 const BOPTools_CArray1OfVVInterference& aVVInterfs=anInterferencePool.VVInterfs();
1672 const BOPTools_CArray1OfVEInterference& aVEInterfs=anInterferencePool.VEInterfs();
1673 const BOPTools_CArray1OfVSInterference& aVSInterfs=anInterferencePool.VSInterfs();
1674 const BOPTools_CArray1OfEEInterference& aEEInterfs=anInterferencePool.EEInterfs();
1675 const BOPTools_CArray1OfESInterference& aESInterfs=anInterferencePool.ESInterfs();
1678 aNbLines=aVVInterfs.Extent();
1679 for (i=1; i<=aNbLines; ++i) {
1680 aNewShape=aVVInterfs(i).NewShape();
1681 if (aNewShape==iNum) {
1682 aVVInterfs(i).Indices(aWhat, aWith);
1683 //printf(" VV: (%d, %d)\n", aWhat, aWith);
1684 di << " VV: (" << aWhat << ", " << aWith << ")\n";
1689 aNbLines=aVEInterfs.Extent();
1690 for (i=1; i<=aNbLines; ++i) {
1691 aNewShape=aVEInterfs(i).NewShape();
1692 if (aNewShape==iNum) {
1693 aVEInterfs(i).Indices(aWhat, aWith);
1694 //printf(" VE: (%d, %d)\n", aWhat, aWith);
1695 di << " VE: (" << aWhat << ", " << aWith << ")\n";
1700 aNbLines=aVSInterfs.Extent();
1701 for (i=1; i<=aNbLines; ++i) {
1702 aNewShape=aVSInterfs(i).NewShape();
1703 if (aNewShape==iNum) {
1704 aVSInterfs(i).Indices(aWhat, aWith);
1705 //printf(" VF: (%d, %d)\n", aWhat, aWith);
1706 di << " VF: (" << aWhat << ", " << aWith << ")\n";
1711 aNbLines=aEEInterfs.Extent();
1712 for (i=1; i<=aNbLines; ++i) {
1713 aNewShape=aEEInterfs(i).NewShape();
1714 if (aNewShape==iNum) {
1715 aEEInterfs(i).Indices(aWhat, aWith);
1716 //printf(" EE: (%d, %d)\n", aWhat, aWith);
1717 di << " EE: (" << aWhat << ", " << aWith << ")\n";
1722 aNbLines=aESInterfs.Extent();
1723 for (i=1; i<=aNbLines; ++i) {
1724 aNewShape=aESInterfs(i).NewShape();
1725 if (aNewShape==iNum) {
1726 aESInterfs(i).Indices(aWhat, aWith);
1727 //printf(" EF: (%d, %d)\n", aWhat, aWith);
1728 di << " EF: (" << aWhat << ", " << aWith << ")\n";
1733 Standard_Integer j, aNbCurves;
1735 BOPTools_InterferencePool* pInterPool=(BOPTools_InterferencePool*)&pDF->InterfPool();
1736 BOPTools_CArray1OfSSInterference& aSSInterfs=pInterPool->SSInterferences();
1738 aNbLines=aSSInterfs.Extent();
1739 for (i=1; i<=aNbLines; ++i) {
1740 BOPTools_SSInterference& aFF=aSSInterfs(i);
1745 BOPTools_SequenceOfCurves& aSC=aFF.Curves();
1747 aNbCurves=aSC.Length();
1748 for (j=1; j<=aNbCurves; ++j) {
1749 const BOPTools_Curve& aBC=aSC(j);
1751 if (aTypeOfShapeToFind==TopAbs_EDGE) {
1752 const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks();
1753 BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
1754 for (; anIt.More(); anIt.Next()) {
1755 const BOPTools_PaveBlock& aPB=anIt.Value();
1756 aNewShape=aPB.Edge();
1757 if (aNewShape==iNum) {
1758 //printf(" FF: (%d, %d) [Section Edge]\n", aWhat, aWith);
1759 di << " FF: (" << aWhat << ", " << aWith << ") [Section Edge]\n";
1764 if (aTypeOfShapeToFind==TopAbs_VERTEX) {
1765 BOPTools_Curve* pBC=(BOPTools_Curve*)&aBC;
1766 TColStd_ListOfInteger& aTVList=pBC->TechnoVertices();
1767 TColStd_ListIteratorOfListOfInteger aTVIt(aTVList);
1768 for (; aTVIt.More(); aTVIt.Next()) {
1769 aNewShape=aTVIt.Value();
1770 if (aNewShape==iNum) {
1771 //printf(" FF: (%d, %d) [Techno Vertex]\n", aWhat, aWith);
1772 di << " FF: (" << aWhat << ", " << aWith << ") [Techno Vertex]\n";
1778 if (aTypeOfShapeToFind==TopAbs_VERTEX) {
1779 TColStd_ListOfInteger& anAVList=aFF.AloneVertices();
1780 TColStd_ListIteratorOfListOfInteger anAVIt(anAVList);
1781 for (; anAVIt.More(); anAVIt.Next()) {
1782 aNewShape=anAVIt.Value();
1783 if (aNewShape==iNum) {
1784 //printf(" FF: (%d, %d) [Alone Vertex]\n", aWhat, aWith);
1785 di << " FF: (" << aWhat << ", " << aWith << ") [Alone Vertex]\n";
1793 if (aTypeOfShapeToFind==TopAbs_EDGE) {
1795 Standard_Integer aNbPaveBlocks, nE, nOriginalEdge, aNbCommonBlocks;
1796 Standard_Integer nFace, nE2, nOriginalEdge2;
1798 const BOPTools_CommonBlockPool& aCommonBlockPool=pDF->CommonBlockPool();
1799 const BOPTools_SplitShapesPool& aSplitShapesPool=pDF->SplitShapesPool();
1800 aNbLines=aSplitShapesPool.Extent();
1801 for (i=1; i<=aNbLines; ++i) {
1802 const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(i);
1803 aNbPaveBlocks=aSplitEdges.Extent();
1805 BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges);
1806 for (; aPBIt.More(); aPBIt.Next()) {
1807 const BOPTools_PaveBlock& aPB=aPBIt.Value();
1809 nOriginalEdge=aPB.OriginalEdge();
1811 //printf(" PaveBlock [Base Edge #%d]\n", nOriginalEdge);
1812 di << " PaveBlock [Base Edge #" << nOriginalEdge << "]\n";
1813 const BOPTools_ListOfCommonBlock& aLCB=
1814 aCommonBlockPool(aDS.RefEdge(nOriginalEdge));
1815 aNbCommonBlocks=aLCB.Extent();
1817 BOPTools_ListIteratorOfListOfCommonBlock aCBIt(aLCB);
1818 for (; aCBIt.More(); aCBIt.Next()) {
1819 BOPTools_CommonBlock& aCB=aCBIt.Value();
1822 //printf(" CommonBlock with Face #%d\n", nFace);
1823 di << " CommonBlock with Face #" << nFace << "\n";
1826 BOPTools_PaveBlock& aPB2=aCB.PaveBlock2(nOriginalEdge);
1828 nOriginalEdge2=aPB2.OriginalEdge();
1829 //printf(" CommonBlock with Edge #%d [Base Edge #%d]\n",
1830 // nE2, nOriginalEdge2);
1831 di << " CommonBlock with Edge #" << nE2 << " [Base Edge #" << nOriginalEdge2 << "]\n";
1843 //=======================================================================
1844 //function : bopsticks
1846 //=======================================================================
1847 Standard_Integer bopsticks (Draw_Interpretor& di,
1852 di << " Prepare BOPTools_DSFiller first >bop S1 S2\n";
1857 di << " Use >bopsticks\n";
1861 Standard_Integer i, j, aNbLines, nF1, nF2, aNbVtx, nV;
1863 const BooleanOperations_ShapesDataStructure& aDS=pDF->DS();
1864 const BOPTools_PaveFiller& aPF=pDF->PaveFiller();
1865 BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)&aPF;
1866 BOPTools_InterferencePool* pInterPool=(BOPTools_InterferencePool*)&pDF->InterfPool();
1867 BOPTools_CArray1OfSSInterference& aSSInterfs=pInterPool->SSInterferences();
1869 aNbLines=aSSInterfs.Extent();
1871 for (i=1; i<=aNbLines; ++i) {
1872 TColStd_IndexedMapOfInteger aMapUnUsed;
1873 BOPTools_PaveSet aPSF;
1875 BOPTools_SSInterference& aFF=aSSInterfs(i);
1876 BOPTools_SequenceOfCurves& aSCvs=aFF.Curves();
1881 pPF->PrepareSetForFace(nF1, nF2, aPSF);
1882 UnUsedMap(aSCvs, aPSF, aMapUnUsed);
1883 aNbVtx=aMapUnUsed.Extent();
1884 for (j=1; j<=aNbVtx; ++j) {
1886 if (aDS.IsNewShape(nV)) {
1887 //printf(" Vertex #%d [FF:(%d, %d)]\n", nV, nF1, nF2);
1888 di << " Vertex #" << nV << " [FF:(" << nF1 << ", " << nF2 << ")]\n";
1895 //=======================================================================
1896 // function: UnUsedMap
1898 //=======================================================================
1899 void UnUsedMap(BOPTools_SequenceOfCurves& aSCvs,
1900 const BOPTools_PaveSet& aPSF,
1901 TColStd_IndexedMapOfInteger& aMapUnUsed)
1904 // What stick/non-stick vertices we used
1905 TColStd_IndexedMapOfInteger aMapUsed, aMapMustBeUsed;
1906 Standard_Integer j, aNbCurves, aNbVtx, nV1;//, nV2;
1907 BOPTools_ListIteratorOfListOfPave anLPIt;
1909 aNbCurves=aSCvs.Length();
1910 for (j=1; j<=aNbCurves; ++j) {
1911 BOPTools_Curve& aBC=aSCvs(j);
1912 //const IntTools_Curve& aC= aBC.Curve();// Wng in Gcc 3.0
1914 const BOPTools_PaveSet& aPaveSet=aBC.Set();
1915 const BOPTools_ListOfPave& aLPAlreadyUsed=aPaveSet.Set();
1916 anLPIt.Initialize(aLPAlreadyUsed);
1917 for (; anLPIt.More(); anLPIt.Next()) {
1918 const BOPTools_Pave& aPave=anLPIt.Value();
1924 // 2. Stick vertices that must be used
1925 const BOPTools_ListOfPave& aLPMustUsed=aPSF.Set();
1926 anLPIt.Initialize(aLPMustUsed);
1927 for (; anLPIt.More(); anLPIt.Next()) {
1928 const BOPTools_Pave& aPave=anLPIt.Value();
1930 aMapMustBeUsed.Add(nV1);
1933 // 3.Unused Stick vertices .
1934 aNbVtx=aMapMustBeUsed.Extent();
1935 for (j=1; j<=aNbVtx; ++j) {
1936 nV1=aMapMustBeUsed(j);
1937 if (!aMapUsed.Contains(nV1)) {
1938 aMapUnUsed.Add(nV1);