0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / BOPTest / BOPTest_PartitionCommands.cxx
CommitLineData
4e57c75e 1// Created by: Peter KURNEV
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
4e57c75e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
4e57c75e 5//
0a36ca0a 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
4e57c75e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
4e57c75e 14
4e57c75e 15
42cf5bc1 16#include <BOPAlgo_BOP.hxx>
4e57c75e 17#include <BOPAlgo_Builder.hxx>
4e57c75e 18#include <BOPAlgo_Operation.hxx>
42cf5bc1 19#include <BOPAlgo_PaveFiller.hxx>
85915310 20#include <BOPAlgo_Section.hxx>
c58055ad 21#include <BOPAlgo_Splitter.hxx>
13c0e402 22#include <BOPDS_DS.hxx>
42cf5bc1 23#include <BOPTest.hxx>
4e57c75e 24#include <BOPTest_DrawableShape.hxx>
25#include <BOPTest_Objects.hxx>
4f7d41ea 26#include <BRepTest_Objects.hxx>
42cf5bc1 27#include <DBRep.hxx>
c7b59798 28#include <OSD_Timer.hxx>
42cf5bc1 29#include <TopoDS_Shape.hxx>
d03c0898 30#include <Draw_ProgressIndicator.hxx>
796a784d 31
42cf5bc1 32#include <stdio.h>
33#include <string.h>
34//
35//
c58055ad 36static Standard_Integer bfillds (Draw_Interpretor&, Standard_Integer, const char**);
4e57c75e 37static Standard_Integer bbuild (Draw_Interpretor&, Standard_Integer, const char**);
38static Standard_Integer bbop (Draw_Interpretor&, Standard_Integer, const char**);
c58055ad 39static Standard_Integer bsplit (Draw_Interpretor&, Standard_Integer, const char**);
13c0e402 40static Standard_Integer buildbop (Draw_Interpretor&, Standard_Integer, const char**);
a942f2da 41
4e57c75e 42//=======================================================================
43//function : PartitionCommands
44//purpose :
45//=======================================================================
a942f2da 46void BOPTest::PartitionCommands(Draw_Interpretor& theCommands)
4e57c75e 47{
48 static Standard_Boolean done = Standard_False;
49 if (done) return;
50 done = Standard_True;
51 // Chapter's name
43cb0011 52 const char* g = "BOPTest commands";
4e57c75e 53 // Commands
74a53b82 54 theCommands.Add("bfillds", "Performs intersection of the arguments added for the operation by baddobjects and baddtools commands.\n"
55 "\t\tUsage: bfillds [-t]\n"
56 "\t\tWhere: -t is the optional parameter for enabling timer and showing elapsed time of the operation",
57 __FILE__, bfillds, g);
13c0e402 58
74a53b82 59 theCommands.Add("bbuild" , "Builds the result of General Fuse operation. Intersection (bfillds) has to be already performed by this moment.\n"
60 "\t\tUsage: bbuild result [-t]\n"
61 "\t\tWhere:\n"
62 "\t\tresult - name of the result shape\n"
63 "\t\t-t is the optional parameter for enabling timer and showing elapsed time of the operation",
64 __FILE__, bbuild, g);
65
66 theCommands.Add("bbop" , "Builds the result of Boolean operation. Intersection (bfillds) has to be already performed by this moment.\n"
67 "\t\tUsage: bbop result op [-t]\n"
68 "\t\tWhere:\n"
69 "\t\tresult - name of the result shape\n"
70 "\t\top - type of Boolean operation. Possible values:\n"
71 "\t\t - 0/common - for Common operation\n"
72 "\t\t - 1/fuse - for Fuse operation\n"
73 "\t\t - 2/cut - for Cut operation\n"
74 "\t\t - 3/tuc/cut21 - for Cut21 operation\n"
75 "\t\t - 4/section - for Section operation\n"
76 "\t\t-t - optional parameter for enabling timer and showing elapsed time of the operation",
77 __FILE__, bbop, g);
78
79 theCommands.Add("bsplit" , "Builds the result of Split operation. Intersection (bfillds) has to be already performed by this moment.\n"
80 "\t\tUsage: bsplit result [-t]\n"
81 "\t\tWhere:\n"
82 "\t\tresult - name of the result shape\n"
83 "\t\t-t is the optional parameter for enabling timer and showing elapsed time of the operation",
84 __FILE__, bsplit, g);
85
86 theCommands.Add("buildbop", "Builds the result of BOP basing on the GF, thus bbuild command has to be already performed\n"
87 "\t\tThe command uses classification approach for building the result of BOP\n"
88 "\t\t(thus it operates on solids only and can be used on open solids):\n"
89 "\t\t - FUSE is built from the faces OUT of all arguments\n"
90 "\t\t - COMMON is built from the faces IN any of the object/tools\n"
91 "\t\t - CUT is built from the objects faces OUT of the tools and tools faces IN the objects.\n"
92 "\t\tPlease note that history for solids will not be available.\n\n"
93 "\t\tUsage: buildbop result -o s1 [s2 ...] -t s3 [s4 ...] -op operation (common/fuse/cut/tuc)\n"
94 "\t\tWhere:\n"
95 "\t\tresult - result shape of the operation\n"
96 "\t\ts1 s2 s3 s4 - arguments (solids) of the GF operation\n"
97 "\t\toperation - type of boolean operation",
13c0e402 98 __FILE__, buildbop, g);
4e57c75e 99}
74a53b82 100
4e57c75e 101//=======================================================================
102//function : bfillds
103//purpose :
104//=======================================================================
a942f2da 105Standard_Integer bfillds(Draw_Interpretor& di,
106 Standard_Integer n,
107 const char** a)
4e57c75e 108{
43cb0011 109 if (n > 2) {
74a53b82 110 di.PrintHelp(a[0]);
111 return 1;
4e57c75e 112 }
113 //
114 char buf[32];
3510db62 115 Standard_Boolean bRunParallel, bNonDestructive, bShowTime;
74a53b82 116 Standard_Integer aNbS;
b1d15f53 117 Standard_Real aTol;
1155d05a 118 TopTools_ListIteratorOfListOfShape aIt;
119 TopTools_ListOfShape aLC;
120 TopTools_ListOfShape& aLS=BOPTest_Objects::Shapes();
4e57c75e 121 aNbS=aLS.Extent();
122 if (!aNbS) {
74a53b82 123 di << "No objects to process\n";
4e57c75e 124 return 0;
125 }
126 //
b1d15f53 127 bShowTime = Standard_False;
49b0c452 128 //
129 bRunParallel=BOPTest_Objects::RunParallel();
3510db62 130 bNonDestructive = BOPTest_Objects::NonDestructive();
131 aTol = BOPTest_Objects::FuzzyValue();
483ce1bd 132 BOPAlgo_GlueEnum aGlue = BOPTest_Objects::Glue();
49b0c452 133 //
74a53b82 134 if (n == 2)
135 {
136 if (!strcmp(a[1], "-t"))
137 {
a942f2da 138 bShowTime=Standard_True;
139 }
74a53b82 140 else
141 {
142 di << "Warning: invalid key\n";
143 }
483ce1bd 144 }
a942f2da 145 //
1155d05a 146 TopTools_ListOfShape& aLT=BOPTest_Objects::Tools();
4e57c75e 147 //
148 aIt.Initialize(aLS);
149 for (; aIt.More(); aIt.Next()) {
150 const TopoDS_Shape& aS=aIt.Value();
151 aLC.Append(aS);
152 }
153 //
154 aIt.Initialize(aLT);
155 for (; aIt.More(); aIt.Next()) {
156 const TopoDS_Shape& aS=aIt.Value();
c7b59798 157 aLC.Append(aS);
4e57c75e 158 }
159 //
160 BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
161 //
162 aPF.SetArguments(aLC);
a942f2da 163 aPF.SetRunParallel(bRunParallel);
3510db62 164 aPF.SetNonDestructive(bNonDestructive);
b1d15f53 165 aPF.SetFuzzyValue(aTol);
483ce1bd 166 aPF.SetGlue(aGlue);
944768d2 167 aPF.SetUseOBB(BOPTest_Objects::UseOBB());
a942f2da 168 //
c7b59798 169 OSD_Timer aTimer;
170 aTimer.Start();
4e57c75e 171 //
d03c0898 172 Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
173 aPF.Perform(aProgress->Start());
d9ca2e0c 174 BOPTest::ReportAlerts(aPF.GetReport());
33ba8565 175 if (aPF.HasErrors()) {
4e57c75e 176 return 0;
177 }
178 //
c7b59798 179 aTimer.Stop();
a942f2da 180 //
c7b59798 181 if (bShowTime)
182 {
183 Sprintf(buf, " Tps: %7.2lf\n", aTimer.ElapsedTime());
a942f2da 184 di << buf;
185 }
186 //
4e57c75e 187 return 0;
188}
4e57c75e 189//=======================================================================
190//function : bbuild
191//purpose :
192//=======================================================================
a942f2da 193Standard_Integer bbuild(Draw_Interpretor& di,
194 Standard_Integer n,
195 const char** a)
4e57c75e 196{
74a53b82 197 if (n < 2 || n > 3) {
198 di.PrintHelp(a[0]);
199 return 1;
4e57c75e 200 }
201 //
202 BOPDS_PDS pDS=BOPTest_Objects::PDS();
203 if (!pDS) {
74a53b82 204 di << "Prepare PaveFiller first\n";
4e57c75e 205 return 0;
206 }
207 //
796a784d 208 char buf[128];
209 Standard_Boolean bRunParallel, bShowTime;
c7b59798 210
1155d05a 211 TopTools_ListIteratorOfListOfShape aIt;
4e57c75e 212 //
213 BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
214 //
a493b4a1 215 BOPTest_Objects::SetBuilderDefault();
4e57c75e 216 BOPAlgo_Builder& aBuilder=BOPTest_Objects::Builder();
217 aBuilder.Clear();
218 //
1155d05a 219 TopTools_ListOfShape& aLSObj=BOPTest_Objects::Shapes();
4e57c75e 220 aIt.Initialize(aLSObj);
221 for (; aIt.More(); aIt.Next()) {
222 const TopoDS_Shape& aS=aIt.Value();
223 aBuilder.AddArgument(aS);
224 }
225 //
1155d05a 226 TopTools_ListOfShape& aLSTool=BOPTest_Objects::Tools();
4e57c75e 227 aIt.Initialize(aLSTool);
228 for (; aIt.More(); aIt.Next()) {
229 const TopoDS_Shape& aS=aIt.Value();
230 aBuilder.AddArgument(aS);
231 }
232 //
796a784d 233 bShowTime=Standard_False;
49b0c452 234 bRunParallel=BOPTest_Objects::RunParallel();
74a53b82 235 if (n == 3)
236 {
237 if (!strcmp(a[2], "-t"))
238 {
796a784d 239 bShowTime=Standard_True;
240 }
74a53b82 241 else
242 {
243 di << "Warning: invalid key\n";
244 }
796a784d 245 }
246 aBuilder.SetRunParallel(bRunParallel);
98b37659 247 aBuilder.SetCheckInverted(BOPTest_Objects::CheckInverted());
948fe6ca 248 aBuilder.SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
796a784d 249 //
d03c0898 250 Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
796a784d 251 //
c7b59798 252 OSD_Timer aTimer;
253 aTimer.Start();
796a784d 254 //
d03c0898 255 aBuilder.PerformWithFiller(aPF, aProgress->Start());
d9ca2e0c 256 BOPTest::ReportAlerts(aBuilder.GetReport());
4f7d41ea 257
258 // Set history of GF operation into the session
948fe6ca 259 if (BRepTest_Objects::IsHistoryNeeded())
260 BRepTest_Objects::SetHistory(aPF.Arguments(), aBuilder);
4f7d41ea 261
33ba8565 262 if (aBuilder.HasErrors()) {
4e57c75e 263 return 0;
264 }
265 //
c7b59798 266 aTimer.Stop();
796a784d 267 //
c7b59798 268 if (bShowTime)
269 {
270 Sprintf(buf, " Tps: %7.2lf\n", aTimer.ElapsedTime());
796a784d 271 di << buf;
272 }
273 //
4e57c75e 274 const TopoDS_Shape& aR=aBuilder.Shape();
275 if (aR.IsNull()) {
74a53b82 276 di << "Result is a null shape\n";
4e57c75e 277 return 0;
278 }
279 //
280 DBRep::Set(a[1], aR);
281 return 0;
282}
4e57c75e 283//=======================================================================
284//function : bbop
285//purpose :
286//=======================================================================
a942f2da 287Standard_Integer bbop(Draw_Interpretor& di,
288 Standard_Integer n,
289 const char** a)
4e57c75e 290{
74a53b82 291 if (n < 3 || n > 4) {
292 di.PrintHelp(a[0]);
293 return 1;
4e57c75e 294 }
295 //
296 BOPDS_PDS pDS=BOPTest_Objects::PDS();
297 if (!pDS) {
74a53b82 298 di << "Prepare PaveFiller first\n";
4e57c75e 299 return 0;
300 }
301 //
74a53b82 302 BOPAlgo_Operation anOp = BOPTest::GetOperationType(a[2]);
303 if (anOp == BOPAlgo_UNKNOWN)
304 {
305 di << "Invalid operation type\n";
8620e18d 306 return 0;
4e57c75e 307 }
74a53b82 308
309 Standard_Boolean bShowTime=Standard_False;
310 Standard_Boolean bRunParallel=BOPTest_Objects::RunParallel();
311 if (n == 4)
312 {
313 if (!strcmp(a[3], "-t"))
314 {
8620e18d 315 bShowTime=Standard_True;
316 }
74a53b82 317 else
318 {
319 di << "Warning: invalid key\n";
320 }
8620e18d 321 }
322 //
4e57c75e 323 BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
324 //
85915310 325 BOPAlgo_Builder *pBuilder=NULL;
326
74a53b82 327 if (anOp!=BOPAlgo_SECTION) {
85915310 328 pBuilder=&BOPTest_Objects::BOP();
329 }
330 else {
331 pBuilder=&BOPTest_Objects::Section();
332 }
333 //
334 pBuilder->Clear();
4e57c75e 335 //
1155d05a 336 TopTools_ListOfShape& aLSObj=BOPTest_Objects::Shapes();
74a53b82 337 TopTools_ListIteratorOfListOfShape aIt(aLSObj);
4e57c75e 338 for (; aIt.More(); aIt.Next()) {
339 const TopoDS_Shape& aS=aIt.Value();
85915310 340 pBuilder->AddArgument(aS);
4e57c75e 341 }
342 //
74a53b82 343 if (anOp!=BOPAlgo_SECTION) {
85915310 344 BOPAlgo_BOP *pBOP=(BOPAlgo_BOP *)pBuilder;
345 //
1155d05a 346 TopTools_ListOfShape& aLSTools=BOPTest_Objects::Tools();
85915310 347 aIt.Initialize(aLSTools);
348 for (; aIt.More(); aIt.Next()) {
349 const TopoDS_Shape& aS=aIt.Value();
350 pBOP->AddTool(aS);
351 }
352 //
74a53b82 353 pBOP->SetOperation(anOp);
4e57c75e 354 }
b1d15f53 355 else {
1155d05a 356 TopTools_ListOfShape& aLSTools=BOPTest_Objects::Tools();
b1d15f53 357 aIt.Initialize(aLSTools);
358 for (; aIt.More(); aIt.Next()) {
359 const TopoDS_Shape& aS=aIt.Value();
360 pBuilder->AddArgument(aS);
361 }
362 }
4e57c75e 363 //
85915310 364 pBuilder->SetRunParallel(bRunParallel);
98b37659 365 pBuilder->SetCheckInverted(BOPTest_Objects::CheckInverted());
948fe6ca 366 pBuilder->SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
8620e18d 367 //
d03c0898 368 Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
369 //
c7b59798 370 OSD_Timer aTimer;
371 aTimer.Start();
4e57c75e 372 //
d03c0898 373 pBuilder->PerformWithFiller(aPF, aProgress->Start());
d9ca2e0c 374 BOPTest::ReportAlerts(pBuilder->GetReport());
4f7d41ea 375
376 // Set history of Boolean operation into the session
948fe6ca 377 if (BRepTest_Objects::IsHistoryNeeded())
378 BRepTest_Objects::SetHistory(aPF.Arguments(), *pBuilder);
4f7d41ea 379
33ba8565 380 if (pBuilder->HasErrors()) {
4e57c75e 381 return 0;
382 }
383 //
c7b59798 384 aTimer.Stop();
8620e18d 385 //
386 if (bShowTime) {
74a53b82 387 char buf[32];
c7b59798 388 Sprintf(buf, " Tps: %7.2lf\n", aTimer.ElapsedTime());
8620e18d 389 di << buf;
390 }
391 //
85915310 392 const TopoDS_Shape& aR=pBuilder->Shape();
4e57c75e 393 if (aR.IsNull()) {
74a53b82 394 di << "Result is a null shape\n";
4e57c75e 395 return 0;
396 }
397 //
a493b4a1 398 BOPTest_Objects::SetBuilder(pBuilder);
399 //
4e57c75e 400 DBRep::Set(a[1], aR);
401 return 0;
402}
403
c58055ad 404//=======================================================================
405//function : bsplit
406//purpose :
407//=======================================================================
408Standard_Integer bsplit(Draw_Interpretor& di,
409 Standard_Integer n,
410 const char** a)
411{
74a53b82 412 if (n < 2 || n > 3) {
413 di.PrintHelp(a[0]);
c58055ad 414 return 1;
415 }
416 //
417 BOPDS_PDS pDS = BOPTest_Objects::PDS();
418 if (!pDS) {
74a53b82 419 di << "Prepare PaveFiller first\n";
c58055ad 420 return 0;
421 }
422 //
423 BOPAlgo_PaveFiller& aPF = BOPTest_Objects::PaveFiller();
424 //
425 BOPAlgo_Splitter* pSplitter = &BOPTest_Objects::Splitter();
426 pSplitter->Clear();
427 //
428 // set objects
1155d05a 429 const TopTools_ListOfShape& aLSObjects = BOPTest_Objects::Shapes();
c58055ad 430 pSplitter->SetArguments(aLSObjects);
431 //
432 // set tools
1155d05a 433 TopTools_ListOfShape& aLSTools = BOPTest_Objects::Tools();
c58055ad 434 pSplitter->SetTools(aLSTools);
435 //
436 // set options
437 pSplitter->SetRunParallel(BOPTest_Objects::RunParallel());
438 pSplitter->SetNonDestructive(BOPTest_Objects::NonDestructive());
439 pSplitter->SetFuzzyValue(BOPTest_Objects::FuzzyValue());
98b37659 440 pSplitter->SetCheckInverted(BOPTest_Objects::CheckInverted());
948fe6ca 441 pSplitter->SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
c58055ad 442 //
443 // measure the time of the operation
444 OSD_Timer aTimer;
445 aTimer.Start();
446 //
447 // perform the operation
d03c0898 448 Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
449 pSplitter->PerformWithFiller(aPF, aProgress->Start());
c58055ad 450 //
451 aTimer.Stop();
d9ca2e0c 452 BOPTest::ReportAlerts(pSplitter->GetReport());
4f7d41ea 453
454 // Set history of Split operation into the session
948fe6ca 455 if (BRepTest_Objects::IsHistoryNeeded())
456 BRepTest_Objects::SetHistory(aPF.Arguments(), *pSplitter);
4f7d41ea 457
33ba8565 458 if (pSplitter->HasErrors()) {
c58055ad 459 return 0;
460 }
461 //
462 // show time if necessary
74a53b82 463 if (n == 3)
464 {
465 if (!strcmp(a[2], "-t"))
466 {
467 char buf[20];
468 Sprintf(buf, " Tps: %7.2lf\n", aTimer.ElapsedTime());
469 di << buf;
470 }
471 else
472 {
473 di << "Warning: invalid key\n";
474 }
c58055ad 475 }
476 //
4f7d41ea 477 // Debug commands support
c58055ad 478 BOPTest_Objects::SetBuilder(pSplitter);
479 //
480 const TopoDS_Shape& aR = pSplitter->Shape();
481 if (aR.IsNull()) {
482 di << " null shape\n";
483 return 0;
484 }
485 //
486 DBRep::Set(a[1], aR);
487 return 0;
488}
13c0e402 489
490//=======================================================================
491//function : buildbop
492//purpose :
493//=======================================================================
494Standard_Integer buildbop(Draw_Interpretor& di,
495 Standard_Integer n,
496 const char** a)
497{
498 if (n < 3)
499 {
500 di.PrintHelp(a[0]);
501 return 1;
502 }
503
504 BOPDS_PDS pDS = BOPTest_Objects::PDS();
505 if (!pDS)
506 {
507 di << "Error: perform intersection of arguments first";
508 return 1;
509 }
510
511 BOPAlgo_Builder *pBuilder = &BOPTest_Objects::Builder();
512 if (pBuilder->HasErrors())
513 {
514 di << "Error: there were problems during GF";
515 return 0;
516 }
517
518 if (pBuilder->Arguments().IsEmpty() ||
519 pBuilder->Shape().IsNull())
520 {
521 di << "Error: it seems the GF has not been yet performed";
522 return 1;
523 }
524
525 // Get arguments and operation
526 TopTools_ListOfShape aLObjects, aLTools;
527 BOPAlgo_Operation anOp = BOPAlgo_UNKNOWN;
528
529 for (Standard_Integer i = 2; i < n; ++i)
530 {
531 if (!strcmp(a[i], "-o") || !strcmp(a[i], "-t"))
532 {
533 if (i == (n - 1))
534 {
535 di << "Error: shapes are expected after the key " << a[i];
536 return 1;
537 }
538
539 TopTools_ListOfShape& aList = !strcmp(a[i], "-o") ? aLObjects : aLTools;
540 Standard_Integer j = i + 1;
541 for (; j < n; ++j)
542 {
543 if (a[j][0] == '-')
544 {
545 // reached the following key
546 i = j - 1;
547 break;
548 }
549 else
550 {
551 // Get the shape
552 TopoDS_Shape aS = DBRep::Get(a[j]);
553 if (aS.IsNull())
554 {
555 di << "Error: " << a[j] << " is a null shape";
556 return 1;
557 }
558 if (aS.ShapeType() != TopAbs_SOLID)
559 {
560 di << "Error: " << a[j] << " is not a solid";
561 return 1;
562 }
563 if (pDS->Index(aS) < 0)
564 {
565 di << "Error: " << a[j] << " is not an argument of GF";
566 return 1;
567 }
568 aList.Append(aS);
569 }
570 }
571 // End of arguments is reached
572 if (j == n) break;
573 }
574 else if (!strcmp(a[i], "-op"))
575 {
576 if (i == (n - 1))
577 {
578 di << "Error: operation type is expected after the key " << a[i];
579 return 1;
580 }
581
582 ++i;
583 if (!strcasecmp(a[i], "common"))
584 anOp = BOPAlgo_COMMON;
585 else if (!strcasecmp(a[i], "fuse"))
586 anOp = BOPAlgo_FUSE;
587 else if (!strcasecmp(a[i], "cut"))
588 anOp = BOPAlgo_CUT;
589 else if (!strcasecmp(a[i], "tuc"))
590 anOp = BOPAlgo_CUT21;
591 else
592 {
593 di << "Error: unknown operation type";
594 return 1;
595 }
596 }
597 else
598 {
599 di << "Error: " << a[i] << " invalid key";
600 return 1;
601 }
602 }
603
604 if (anOp == BOPAlgo_UNKNOWN)
605 {
606 di << "Error: operation has not been specified";
607 return 1;
608 }
609
610 Standard_Boolean hasObjects = !aLObjects.IsEmpty();
611 Standard_Boolean hasTools = !aLTools.IsEmpty();
612 if (!hasObjects && !hasTools)
613 {
614 di << "Error: no shapes are given";
615 return 1;
616 }
617
618 // Create new report for the operation
619 Handle(Message_Report) aReport = new Message_Report;
d03c0898 620 Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
13c0e402 621 // Build specific operation
d03c0898 622 pBuilder->BuildBOP(aLObjects, aLTools, anOp, aProgress->Start(), aReport);
13c0e402 623
624 // Report alerts of the operation
625 BOPTest::ReportAlerts(aReport);
626
627 if (!aReport->GetAlerts(Message_Fail).IsEmpty())
628 {
629 return 0;
630 }
631
632 // Set history of Split operation into the session
633 if (BRepTest_Objects::IsHistoryNeeded())
634 BRepTest_Objects::SetHistory(pDS->Arguments(), *pBuilder);
635
636 // Result shape
637 const TopoDS_Shape& aR = pBuilder->Shape();
638 // Draw result shape
639 DBRep::Set(a[1], aR);
640
641 return 0;
642}