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