35c36e3f067f17086da91cc4803c44ff46855f61
[occt.git] / src / BOPTest / BOPTest_BOPCommands.cxx
1 // Created on: 2000-03-16
2 // Created by: Peter KURNEV
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16
17 #include <BOPAlgo_BOP.hxx>
18 #include <BOPAlgo_MakerVolume.hxx>
19 #include <BOPAlgo_Operation.hxx>
20 #include <BOPAlgo_PaveFiller.hxx>
21 #include <BOPAlgo_Section.hxx>
22 #include <BOPCol_ListOfShape.hxx>
23 #include <BOPDS_DS.hxx>
24 #include <BOPTest.hxx>
25 #include <BOPTest_DrawableShape.hxx>
26 #include <BOPTest_Objects.hxx>
27 #include <BRep_Builder.hxx>
28 #include <BRepAlgoAPI_BooleanOperation.hxx>
29 #include <BRepAlgoAPI_Common.hxx>
30 #include <BRepAlgoAPI_Cut.hxx>
31 #include <BRepAlgoAPI_Fuse.hxx>
32 #include <BRepAlgoAPI_Section.hxx>
33 #include <DBRep.hxx>
34 #include <Draw.hxx>
35 #include <Draw_Color.hxx>
36 #include <DrawTrSurf.hxx>
37 #include <Geom2d_Curve.hxx>
38 #include <Geom_Curve.hxx>
39 #include <IntTools_Curve.hxx>
40 #include <IntTools_FaceFace.hxx>
41 #include <IntTools_PntOn2Faces.hxx>
42 #include <NCollection_BaseAllocator.hxx>
43 #include <NCollection_IncAllocator.hxx>
44 #include <TCollection_AsciiString.hxx>
45 #include <TopoDS_Compound.hxx>
46 #include <TopoDS_Iterator.hxx>
47 #include <TopoDS_Shape.hxx>
48
49 #include <stdio.h>
50 //
51 //
52 static BOPAlgo_PaveFiller* pPF=NULL;
53 //
54
55 static
56   Standard_Integer bopsmt(Draw_Interpretor& di,
57                           Standard_Integer n,
58                           const char** a,
59                           const BOPAlgo_Operation aOp);
60 //
61 static
62   Standard_Integer bsmt (Draw_Interpretor& di, 
63                        Standard_Integer n, 
64                        const char** a,
65                        const BOPAlgo_Operation aOp);
66 //
67 static Standard_Integer bop       (Draw_Interpretor&, Standard_Integer, const char**);
68 static Standard_Integer bopsection(Draw_Interpretor&, Standard_Integer, const char**);
69 static Standard_Integer boptuc    (Draw_Interpretor&, Standard_Integer, const char**);
70 static Standard_Integer bopcut    (Draw_Interpretor&, Standard_Integer, const char**);
71 static Standard_Integer bopfuse   (Draw_Interpretor&, Standard_Integer, const char**);
72 static Standard_Integer bopcommon (Draw_Interpretor&, Standard_Integer, const char**);
73 //
74 static Standard_Integer bsection  (Draw_Interpretor&, Standard_Integer, const char**);
75 static Standard_Integer btuc      (Draw_Interpretor&, Standard_Integer, const char**);
76 static Standard_Integer bcut      (Draw_Interpretor&, Standard_Integer, const char**);
77 static Standard_Integer bfuse     (Draw_Interpretor&, Standard_Integer, const char**);
78 static Standard_Integer bcommon   (Draw_Interpretor&, Standard_Integer, const char**);
79 //
80 static Standard_Integer bopcurves (Draw_Interpretor&, Standard_Integer, const char**);
81 static Standard_Integer bopnews   (Draw_Interpretor&, Standard_Integer, const char**);
82 static Standard_Integer mkvolume   (Draw_Interpretor&, Standard_Integer, const char**);
83
84 //=======================================================================
85 //function : BOPCommands
86 //purpose  : 
87 //=======================================================================
88   void BOPTest::BOPCommands(Draw_Interpretor& theCommands)
89 {
90   static Standard_Boolean done = Standard_False;
91   if (done) return;
92   done = Standard_True;
93   // Chapter's name
94   const char* g = "BOPTest commands";
95   // Commands
96   
97   theCommands.Add("bop"       , "use bop s1 s2" , __FILE__, bop, g);
98   theCommands.Add("bopcommon" , "use bopcommon r"     , __FILE__, bopcommon, g);
99   theCommands.Add("bopfuse"   , "use bopfuse r"       , __FILE__,bopfuse, g);
100   theCommands.Add("bopcut"    , "use bopcut r"        , __FILE__,bopcut, g);
101   theCommands.Add("boptuc"    , "use boptuc r"        , __FILE__,boptuc, g);
102   theCommands.Add("bopsection", "use bopsection r"    , __FILE__,bopsection, g);
103   //
104   theCommands.Add("bcommon" , "use bcommon r s1 s2" , __FILE__,bcommon, g);
105   theCommands.Add("bfuse"   , "use bfuse r s1 s2"   , __FILE__,bfuse, g);
106   theCommands.Add("bcut"    , "use bcut r s1 s2"    , __FILE__,bcut, g);
107   theCommands.Add("btuc"    , "use btuc r s1 s2"    , __FILE__,btuc, g);
108   theCommands.Add("bsection", "use bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na]", 
109                                                       __FILE__, bsection, g);
110   //
111   theCommands.Add("bopcurves", "use bopcurves F1 F2 [-2d/-2d1/-2d2]",
112                                                       __FILE__, bopcurves, g);
113   theCommands.Add("bopnews"  , "use  bopnews -v[e,f]"      , __FILE__, bopnews, g);
114   theCommands.Add("mkvolume", "make solids from set of shapes.\nmkvolume r b1 b2 ... [-c] [-ni]", 
115                   __FILE__, mkvolume , g);
116 }
117
118 //=======================================================================
119 //function : bop
120 //purpose  : 
121 //=======================================================================
122 Standard_Integer bop(Draw_Interpretor& di, 
123                      Standard_Integer n, 
124                      const char** a)
125 {
126   char buf[32];
127   Standard_Boolean bRunParallel;
128   Standard_Integer iErr;
129   Standard_Real aTol;
130   TopoDS_Shape aS1, aS2;
131   BOPCol_ListOfShape aLC;
132   //
133   if (n != 3) {
134     di << " use bop s1 s2 \n";
135     return 0;
136   }
137   //
138   aS1=DBRep::Get(a[1]);
139   aS2=DBRep::Get(a[2]);
140   //
141   if (aS1.IsNull() || aS2.IsNull()) {
142     di << " null shapes are not allowed \n";
143     return 0;
144   }
145   //
146   aTol=BOPTest_Objects::FuzzyValue();
147   bRunParallel=BOPTest_Objects::RunParallel();
148   //
149   aLC.Append(aS1);
150   aLC.Append(aS2);
151   //
152   if (pPF!=NULL) {
153     delete pPF;
154     pPF=NULL;
155   }
156   Handle(NCollection_BaseAllocator)aAL=new NCollection_IncAllocator;
157   pPF=new BOPAlgo_PaveFiller(aAL);
158   //
159   pPF->SetArguments(aLC);
160   pPF->SetFuzzyValue(aTol);
161   pPF->SetRunParallel(bRunParallel);
162   //
163   pPF->Perform();
164   iErr=pPF->ErrorStatus();
165   if (iErr) {
166     Sprintf(buf, " ErrorStatus : %d\n",  iErr);
167     di << buf;
168     return 0;
169   }
170   //
171   return 0;
172 }
173 //=======================================================================
174 //function : bopcommon
175 //purpose  : 
176 //=======================================================================
177 Standard_Integer bopcommon (Draw_Interpretor& di, 
178                             Standard_Integer n, 
179                             const char** a)
180 {
181   return bopsmt(di, n, a, BOPAlgo_COMMON);
182 }
183 //=======================================================================
184 //function : bopfuse
185 //purpose  : 
186 //=======================================================================
187 Standard_Integer bopfuse(Draw_Interpretor& di, 
188                          Standard_Integer n, 
189                          const char** a)
190 {
191   return bopsmt(di, n, a, BOPAlgo_FUSE);
192 }
193 //=======================================================================
194 //function : bopcut
195 //purpose  : 
196 //=======================================================================
197 Standard_Integer bopcut(Draw_Interpretor& di, 
198                         Standard_Integer n, 
199                         const char** a)
200 {
201   return bopsmt(di, n, a, BOPAlgo_CUT);
202 }
203 //=======================================================================
204 //function : boptuc
205 //purpose  : 
206 //=======================================================================
207 Standard_Integer boptuc(Draw_Interpretor& di, 
208                         Standard_Integer n, 
209                         const char** a)
210 {
211   return bopsmt(di, n, a, BOPAlgo_CUT21);
212 }
213 //=======================================================================
214 //function : bopsmt
215 //purpose  : 
216 //=======================================================================
217 Standard_Integer bopsmt(Draw_Interpretor& di,
218                         Standard_Integer n,
219                         const char** a,
220                         const BOPAlgo_Operation aOp)
221 {
222   if (n<2) {
223     di << " use bopsmt r\n";
224     return 0;
225   }
226   //
227   if (!pPF) {
228     di << " prepare PaveFiller first\n";
229     return 0;
230   }
231   //
232   if (pPF->ErrorStatus()) {
233     di << " PaveFiller has not been done\n";
234     return 0;
235   }
236   //
237   char buf[64];
238   Standard_Boolean bRunParallel;
239   Standard_Integer aNb, iErr;
240   BOPAlgo_BOP aBOP;
241   //
242   const BOPCol_ListOfShape& aLC=pPF->Arguments();
243   aNb=aLC.Extent();
244   if (aNb!=2) {
245     Sprintf (buf, " wrong number of arguments %s\n", aNb);
246     di << buf;
247     return 0;
248   }
249   // 
250   bRunParallel=BOPTest_Objects::RunParallel();
251   //
252   const TopoDS_Shape& aS1=aLC.First();
253   const TopoDS_Shape& aS2=aLC.Last();
254   //
255   aBOP.AddArgument(aS1);
256   aBOP.AddTool(aS2);
257   aBOP.SetOperation(aOp);
258   aBOP.SetRunParallel (bRunParallel);
259   //
260   aBOP.PerformWithFiller(*pPF);
261   iErr=aBOP.ErrorStatus();
262   if (iErr) {
263     Sprintf(buf, " ErrorStatus : %d\n",  iErr);
264     di << buf;
265     return 0;
266   }
267   //
268   const TopoDS_Shape& aR=aBOP.Shape();
269   if (aR.IsNull()) {
270     di << " null shape\n";
271     return 0;
272   }
273   //
274   DBRep::Set(a[1], aR);
275   return 0;
276 }
277 //=======================================================================
278 //function : bopsection
279 //purpose  : 
280 //=======================================================================
281 Standard_Integer bopsection(Draw_Interpretor& di, 
282                             Standard_Integer n, 
283                             const char** a)
284 {
285   if (n<2) {
286     di << " use bopsection r\n";
287     return 0;
288   }
289   //
290   if (!pPF) {
291     di << " prepare PaveFiller first\n";
292     return 0;
293   }
294   //
295   if (pPF->ErrorStatus()) {
296     di << " PaveFiller has not been done\n";
297     return 0;
298   }
299   //
300   char buf[64];
301   Standard_Boolean bRunParallel;
302   Standard_Integer aNb, iErr;
303   BOPAlgo_Section aBOP;
304   //
305   const BOPCol_ListOfShape& aLC=pPF->Arguments();
306   aNb=aLC.Extent();
307   if (aNb!=2) {
308     Sprintf (buf, " wrong number of arguments %s\n", aNb);
309     di << buf;
310     return 0;
311   }
312   //
313   bRunParallel=BOPTest_Objects::RunParallel();
314   //
315   const TopoDS_Shape& aS1=aLC.First();
316   const TopoDS_Shape& aS2=aLC.Last();
317   //
318   aBOP.AddArgument(aS1);
319   aBOP.AddArgument(aS2);
320   aBOP.SetRunParallel (bRunParallel);
321   //
322   aBOP.PerformWithFiller(*pPF);
323   iErr=aBOP.ErrorStatus();
324   if (iErr) {
325     Sprintf(buf, " ErrorStatus : %d\n",  iErr);
326     di << buf;
327     return 0;
328   }
329   //
330   const TopoDS_Shape& aR=aBOP.Shape();
331   if (aR.IsNull()) {
332     di << " null shape\n";
333     return 0;
334   }
335   //
336   DBRep::Set(a[1], aR);
337   return 0;
338 }
339 //=======================================================================
340 //function : bcommon
341 //purpose  : 
342 //=======================================================================
343 Standard_Integer bcommon (Draw_Interpretor& di, 
344                           Standard_Integer n, 
345                           const char** a)
346 {
347   return bsmt(di, n, a, BOPAlgo_COMMON);
348 }
349 //=======================================================================
350 //function : bfuse
351 //purpose  : 
352 //=======================================================================
353 Standard_Integer bfuse (Draw_Interpretor& di, 
354                         Standard_Integer n, 
355                         const char** a)
356 {
357   return bsmt(di, n, a, BOPAlgo_FUSE);
358 }
359 //=======================================================================
360 //function : bcut
361 //purpose  : 
362 //=======================================================================
363 Standard_Integer bcut (Draw_Interpretor& di, 
364                        Standard_Integer n, 
365                        const char** a)
366 {
367   return bsmt(di, n, a, BOPAlgo_CUT);
368 }
369 //=======================================================================
370 //function : btuc
371 //purpose  : 
372 //=======================================================================
373 Standard_Integer btuc (Draw_Interpretor& di, 
374                        Standard_Integer n, 
375                        const char** a)
376 {
377   return bsmt(di, n, a, BOPAlgo_CUT21);
378 }
379 //=======================================================================
380 //function : bsection
381 //purpose  : 
382 //=======================================================================
383 Standard_Integer  bsection(Draw_Interpretor& di, 
384                            Standard_Integer n, 
385                            const char** a)
386 {
387   if (n < 4) {
388     di << "use bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na] [tol]\n";
389     return 0;
390   }
391   //
392   TopoDS_Shape aS1, aS2;
393   //
394   aS1=DBRep::Get(a[2]);
395   aS2=DBRep::Get(a[3]);
396   if (aS1.IsNull() || aS2.IsNull()) {
397     di << " Null shapes are not allowed \n";
398     return 0;
399   }
400   // 
401   char buf[80];
402   Standard_Boolean bRunParallel, bApp, bPC1, bPC2;
403   Standard_Integer i, iErr;
404   Standard_Real aTol;
405   //
406   bApp = Standard_True;
407   bPC1 = Standard_True;
408   bPC2 = Standard_True;
409   aTol = BOPTest_Objects::FuzzyValue(); 
410   bRunParallel = BOPTest_Objects::RunParallel();
411   //
412   for (i = 4; i < n; ++i) {
413     if (!strcmp(a[i], "-n2d")) {
414       bPC1 = Standard_False;
415       bPC2 = Standard_False;
416     }
417     else if (!strcmp(a[i], "-n2d1")) {
418       bPC1 = Standard_False;
419     }
420     else if (!strcmp(a[i], "-n2d2")) {
421       bPC2 = Standard_False;
422     }
423     else if (!strcmp(a[i], "-na")) {
424       bApp = Standard_False;
425     }
426   }
427   //
428   BRepAlgoAPI_Section aSec(aS1, aS2, Standard_False);
429   //
430   aSec.Approximation(bApp);
431   aSec.ComputePCurveOn1(bPC1);
432   aSec.ComputePCurveOn2(bPC2);
433   //
434   aSec.SetFuzzyValue(aTol);
435   aSec.SetRunParallel(bRunParallel);
436   //
437   aSec.Build();
438   iErr=aSec.ErrorStatus();
439   if (!aSec.IsDone()) {
440     Sprintf(buf, " ErrorStatus : %d\n",  iErr);
441     di << buf;
442     return 0;
443   }
444   //
445   const TopoDS_Shape& aR=aSec.Shape();
446   if (aR.IsNull()) {
447     di << " null shape\n";
448     return 0;
449   }
450   DBRep::Set(a[1], aR);
451   return 0;
452 }
453 //=======================================================================
454 //function : bsmt
455 //purpose  : 
456 //=======================================================================
457 Standard_Integer bsmt (Draw_Interpretor& di, 
458                        Standard_Integer n, 
459                        const char** a,
460                        const BOPAlgo_Operation aOp)
461 {
462   char buf[32];
463   Standard_Boolean bRunParallel;
464   Standard_Integer iErr;
465   TopoDS_Shape aS1, aS2;
466   BOPCol_ListOfShape aLC;
467   Standard_Real aTol;
468   //
469   if (n != 4) {
470     di << " use bx r s1 s2\n";
471     return 0;
472   }
473   //
474   aS1=DBRep::Get(a[2]);
475   aS2=DBRep::Get(a[3]);
476   //
477   if (aS1.IsNull() || aS2.IsNull()) {
478     di << " null shapes are not allowed \n";
479     return 0;
480   }
481   aLC.Append(aS1);
482   aLC.Append(aS2);
483   // 
484   aTol=BOPTest_Objects::FuzzyValue();
485   bRunParallel = BOPTest_Objects::RunParallel();
486   //
487   Handle(NCollection_BaseAllocator)aAL=new NCollection_IncAllocator;
488   //
489   //---------------------------------------------------------------
490   BOPAlgo_PaveFiller aPF(aAL);
491   //
492   aPF.SetArguments(aLC);
493   aPF.SetFuzzyValue(aTol); 
494   aPF.SetRunParallel(bRunParallel);
495   //
496   aPF.Perform();
497   iErr=aPF.ErrorStatus();
498   if (iErr) {
499     Sprintf(buf, " ErrorStatus : %d\n",  iErr);
500     di << buf;
501     return 0;
502   }
503   //
504   //---------------------------------------------------------------
505   BOPAlgo_BOP aBOP(aAL);
506   //
507   aBOP.AddArgument(aS1);
508   aBOP.AddTool(aS2);
509   aBOP.SetOperation(aOp);
510   aBOP.SetRunParallel(bRunParallel);
511   // 
512   aBOP.PerformWithFiller(aPF);
513   //
514   iErr=aBOP.ErrorStatus();
515   if (iErr) {
516     Sprintf(buf, " ErrorStatus : %d\n",  iErr);
517     di << buf;
518     return 0;
519   }
520   const TopoDS_Shape& aR=aBOP.Shape();
521   if (aR.IsNull()) {
522     di << " null shape\n";
523     return 0;
524   }
525   //
526   DBRep::Set(a[1], aR);
527   return 0;
528 }
529 //=======================================================================
530 //function : bopnews
531 //purpose  : 
532 //=======================================================================
533 Standard_Integer bopnews (Draw_Interpretor& di, 
534                           Standard_Integer n, 
535                           const char** a)
536 {
537   if (n!=2) {
538     di << " use bopnews -v[e,f]\n";
539     return 0;
540   }
541   //
542   if (pPF==NULL) {
543     di << " Prepare BOPAlgo_PaveFiller first >bop S1 S2\n";
544     return 0;
545   }
546   //
547   char buf[32];
548   Standard_CString aText;
549   Standard_Integer i, i1, i2, iFound;
550   Draw_Color aTextColor(Draw_cyan);
551   TopAbs_ShapeEnum aT;
552   Handle(BOPTest_DrawableShape) aDShape;
553   //
554   const BOPDS_PDS& pDS=pPF->PDS();
555   //
556   aT=TopAbs_SHAPE;
557   if (!strcmp (a[1], "-f")) {
558     aT=TopAbs_FACE;
559   }
560   else if (!strcmp (a[1], "-e")){
561     aT=TopAbs_EDGE;
562   }
563   else if (!strcmp (a[1], "-v")){
564     aT=TopAbs_VERTEX;
565   }
566   else {
567     di << " use bopnews -v[e,f]\n";
568     return 0;
569   }
570   //
571   iFound=0;
572   i1=pDS->NbSourceShapes();
573   i2=pDS->NbShapes();
574   for (i=i1; i<i2; ++i) {
575     const BOPDS_ShapeInfo& aSI=pDS->ShapeInfo(i);
576     if (aSI.ShapeType()==aT) {
577       const TopoDS_Shape& aS=aSI.Shape();
578       //
579       Sprintf (buf, "z%d", i);
580       aText=buf;
581       aDShape=new BOPTest_DrawableShape (aS, aText, aTextColor);
582       Draw::Set (aText, aDShape);
583       //
584       Sprintf (buf, " z%d", i);
585       di << buf;
586       //
587       iFound=1;
588     }
589   }
590   //
591   if (iFound) {
592     di << "\n";
593   }
594   else {
595     di << " not found\n";
596   }
597   //
598   return 0;
599 }
600 //=======================================================================
601 //function : bopcurves
602 //purpose  : 
603 //=======================================================================
604 Standard_Integer bopcurves (Draw_Interpretor& di, 
605                             Standard_Integer n, 
606                             const char** a)
607 {
608   if (n<3) {
609     di << " use bopcurves F1 F2 [-2d/-2d1/-2d2]\n";
610     return 1;
611   }
612   //
613   TopoDS_Shape S1 = DBRep::Get(a[1]);
614   TopoDS_Shape S2 = DBRep::Get(a[2]);
615   TopAbs_ShapeEnum aType;
616   //
617   if (S1.IsNull() || S2.IsNull()) {
618     di << " Null shapes is not allowed \n";
619     return 1;
620   }
621   //
622   aType=S1.ShapeType();
623   if (aType != TopAbs_FACE) {
624     di << " Type mismatch F1\n";
625     return 1;
626   }
627   aType=S2.ShapeType();
628   if (aType != TopAbs_FACE) {
629     di << " Type mismatch F2\n";
630     return 1;
631   }
632   //
633   const TopoDS_Face& aF1=*(TopoDS_Face*)(&S1);
634   const TopoDS_Face& aF2=*(TopoDS_Face*)(&S2);
635   //
636   Standard_Boolean aToApproxC3d, aToApproxC2dOnS1, aToApproxC2dOnS2, anIsDone;
637   Standard_Integer i, aNbCurves, aNbPoints;
638   Standard_Real anAppTol, aTolR;
639   TCollection_AsciiString aNm("c_"), aNp("p_");
640   //
641   anAppTol = 0.0000001;
642   aToApproxC3d = Standard_True;
643   aToApproxC2dOnS1 = Standard_False;
644   aToApproxC2dOnS2 = Standard_False;
645   //
646   if (n > 3) {
647     if (!strcasecmp(a[3],"-2d")) {
648       aToApproxC2dOnS1 = Standard_True;
649       aToApproxC2dOnS2 = Standard_True;
650     } 
651     else if (!strcasecmp(a[3],"-2d1")) {
652       aToApproxC2dOnS1 = Standard_True;
653     }
654     else if (!strcasecmp(a[3],"-2d2")) {
655       aToApproxC2dOnS2 = Standard_True;
656     }
657     else {
658       di << "Wrong key. To build 2d curves use: bopcurves F1 F2 -2d/-2d1/-2d2 \n";
659       return 1;
660     }
661   }
662   //
663   IntTools_FaceFace aFF;
664   //
665   aFF.SetParameters (aToApproxC3d,
666                      aToApproxC2dOnS1,
667                      aToApproxC2dOnS2,
668                      anAppTol);
669   //
670   aFF.Perform (aF1, aF2);
671   //
672   anIsDone=aFF.IsDone();
673   if (!anIsDone) {
674     di << "Error: anIsDone=" << (Standard_Integer) anIsDone << "\n";
675     return 0;
676   }
677   //
678   aFF.PrepareLines3D(Standard_False);
679   const IntTools_SequenceOfCurves& aSCs=aFF.Lines();
680   const IntTools_SequenceOfPntOn2Faces& aSPs = aFF.Points();
681   //
682   aNbCurves = aSCs.Length();
683   aNbPoints = aSPs.Length();
684   if (!aNbCurves && !aNbPoints) {
685     di << " has no 3d curves\n";
686     di << " has no 3d points\n";
687     return 0;
688   }
689   //
690   aTolR=aFF.TolReached3d();
691   di << "Tolerance Reached=" << aTolR << "\n";
692   //
693   // curves
694   if (aNbCurves) {
695     di << aNbCurves << " curve(s) found.\n";
696     //
697     for (i=1; i<=aNbCurves; i++) {
698       const IntTools_Curve& anIC=aSCs(i);
699
700       Handle (Geom_Curve)  aC3D = anIC.Curve();
701
702       if (aC3D.IsNull()) {
703         di << " has Null 3d curve# " << i << "\n";
704         continue;
705       }
706
707       TCollection_AsciiString anIndx(i), aNmx;
708       aNmx = aNm + anIndx;
709
710       Standard_CString nameC = aNmx.ToCString();
711
712       DrawTrSurf::Set(nameC, aC3D);
713       di << nameC << " ";
714       //
715       Handle(Geom2d_Curve) aPC1 = anIC.FirstCurve2d();
716       Handle(Geom2d_Curve) aPC2 = anIC.SecondCurve2d();
717       //
718       if (!aPC1.IsNull() || !aPC2.IsNull()) {
719         di << "(";
720         //
721         if (!aPC1.IsNull()) {
722           TCollection_AsciiString pc1N("c2d1_"), pc1Nx;
723           pc1Nx = pc1N + anIndx;
724           Standard_CString nameC2d1 = pc1Nx.ToCString();
725           //
726           DrawTrSurf::Set(nameC2d1, aPC1);
727           di << nameC2d1;
728         }
729         //
730         if (!aPC2.IsNull()) {
731           TCollection_AsciiString pc2N("c2d2_"), pc2Nx;
732           pc2Nx = pc2N + anIndx;
733           Standard_CString nameC2d2 = pc2Nx.ToCString();
734           //
735           DrawTrSurf::Set(nameC2d2, aPC2);
736           //
737           if (!aPC1.IsNull()) {
738             di << ", ";
739           }
740           di << nameC2d2;
741         }
742         di << ") ";
743       }
744     }
745     di << "\n";
746   }
747   //
748   // points
749   if (aNbPoints) {
750     di << aNbPoints << " point(s) found.\n";
751     //
752     for (i = 1; i <= aNbPoints; i++) {
753       const IntTools_PntOn2Faces& aPi = aSPs(i);
754       const gp_Pnt& aP = aPi.P1().Pnt();
755       //
756       TCollection_AsciiString anIndx(i), aNmx;
757       aNmx = aNp + anIndx;
758       Standard_CString nameP = aNmx.ToCString();
759       //
760       DrawTrSurf::Set(nameP, aP);
761       di << nameP << " ";
762     }
763     di << "\n";
764   }
765   //
766   return 0;
767 }
768 //=======================================================================
769 //function : mkvolume
770 //purpose  : 
771 //=======================================================================
772 Standard_Integer mkvolume(Draw_Interpretor& di, Standard_Integer n, const char** a) 
773 {
774   if (n < 3) {
775     di << "Usage: mkvolume r b1 b2 ... [-c] [-ni]\n";
776     di << "Options:\n";
777     di << " -c  - use this option if the arguments are compounds\n";
778     di << "       containing shapes that should be interfered;\n";
779     di << " -ni - use this option if the arguments should not be interfered;\n";
780     return 1;
781   }
782   //
783   const char* usage = "Type mkvolume without arguments for the usage of the command.\n";
784   //
785   Standard_Boolean bToIntersect, bRunParallel, bCompounds;
786   Standard_Integer i;
787   Standard_Real aTol;
788   TopoDS_Shape aS;
789   BOPCol_ListOfShape aLS;
790   //
791   aTol = BOPTest_Objects::FuzzyValue();
792   bRunParallel = BOPTest_Objects::RunParallel();
793   //
794   bToIntersect = Standard_True;
795   bCompounds = Standard_False;
796   //
797   for (i = 2; i < n; ++i) {
798     aS = DBRep::Get(a[i]);
799     if (!aS.IsNull()) {
800       aLS.Append(aS);
801     }
802     else {
803       if (!strcmp(a[i], "-c")) {
804         bCompounds = Standard_True;
805       }
806       else if (!strcmp(a[i], "-ni")) {
807         bToIntersect = Standard_False;
808       }
809     }
810   }
811   //
812   if (aLS.IsEmpty()) {
813     di << "No shapes to process.\n";
814     di << usage;
815     return 1;
816   }
817   //
818   // treat list of arguments for the case of compounds
819   if (bToIntersect && bCompounds) {
820     BOPCol_ListOfShape aLSx;
821     BOPCol_ListIteratorOfListOfShape aItLS;
822     //
823     aItLS.Initialize(aLS);
824     for (; aItLS.More(); aItLS.Next()) {
825       const TopoDS_Shape& aSx = aItLS.Value();
826       TopoDS_Iterator aItS(aSx);
827       for (; aItS.More(); aItS.Next()) {
828         const TopoDS_Shape& aSxS = aItS.Value();
829         aLSx.Append(aSxS);
830       }
831     }
832     //
833     aLS.Clear();
834     aLS.Assign(aLSx);
835   }
836   //
837   BOPAlgo_MakerVolume aMV;
838   aMV.SetArguments(aLS);
839   aMV.SetIntersect(bToIntersect);
840   aMV.SetRunParallel(bRunParallel);
841   aMV.SetFuzzyValue(aTol);
842   //
843   aMV.Perform();
844   if (aMV.ErrorStatus()) {
845     di << "Error status: " << aMV.ErrorStatus();
846     return 1;
847   }
848   //
849   const TopoDS_Shape& aR = aMV.Shape();
850   //
851   DBRep::Set(a[1], aR);
852   //
853   return 0;
854 }