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