1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <BOPTest.ixx>
20 #include <NCollection_IncAllocator.hxx>
24 #include <Draw_Color.hxx>
25 #include <DrawTrSurf.hxx>
27 #include <TopoDS_Shape.hxx>
29 #include <BOPAlgo_Builder.hxx>
30 #include <BOPAlgo_PaveFiller.hxx>
31 #include <BOPAlgo_Operation.hxx>
32 #include <BOPAlgo_BOP.hxx>
34 #include <BOPTest_DrawableShape.hxx>
35 #include <BOPTest_Objects.hxx>
37 #include <BOPTest_Chronometer.hxx>
39 static Standard_Integer bfillds (Draw_Interpretor&, Standard_Integer, const char**);
40 static Standard_Integer bbuild (Draw_Interpretor&, Standard_Integer, const char**);
41 static Standard_Integer bbop (Draw_Interpretor&, Standard_Integer, const char**);
42 static Standard_Integer bclear (Draw_Interpretor&, Standard_Integer, const char**);
44 //=======================================================================
45 //function : PartitionCommands
47 //=======================================================================
48 void BOPTest::PartitionCommands(Draw_Interpretor& theCommands)
50 static Standard_Boolean done = Standard_False;
54 const char* g = "Partition commands";
56 theCommands.Add("bfillds", "use bfillds [-s -t]" , __FILE__, bfillds, g);
57 theCommands.Add("bbuild" , "use bbuild r [-s -t]" , __FILE__, bbuild, g);
58 theCommands.Add("bbop" , "use bbop r op [-s -t]", __FILE__, bbop, g);
59 theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g);
62 //=======================================================================
65 //=======================================================================
66 Standard_Integer bclear(Draw_Interpretor& di,
71 di << " use bclear\n";
75 BOPTest_Objects::Clear();
78 //=======================================================================
81 //=======================================================================
82 Standard_Integer bfillds(Draw_Interpretor& di,
87 di << " use bfillds [-s -t]\n";
92 Standard_Boolean bRunParallel, bShowTime;
93 Standard_Integer i, aNbS, iErr;
94 BOPCol_ListIteratorOfListOfShape aIt;
95 BOPCol_ListOfShape aLC;
96 BOPTime_Chronometer aChrono;
98 BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes();
101 di << " no objects to process\n";
105 bShowTime=Standard_False;
106 bRunParallel=Standard_True;
107 for (i=1; i<n; ++i) {
108 if (!strcmp(a[i], "-s")) {
109 bRunParallel=Standard_False;
111 else if (!strcmp(a[i], "-t")) {
112 bShowTime=Standard_True;
116 BOPCol_ListOfShape& aLT=BOPTest_Objects::Tools();
119 for (; aIt.More(); aIt.Next()) {
120 const TopoDS_Shape& aS=aIt.Value();
125 for (; aIt.More(); aIt.Next()) {
126 const TopoDS_Shape& aS=aIt.Value();
130 BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
132 aPF.SetArguments(aLC);
133 aPF.SetRunParallel(bRunParallel);
138 iErr=aPF.ErrorStatus();
140 Sprintf(buf, " error: %d\n", iErr);
150 aTime=aChrono.Time();
151 Sprintf(buf, " Tps: %7.2lf\n", aTime);
157 //=======================================================================
160 //=======================================================================
161 Standard_Integer bbuild(Draw_Interpretor& di,
166 di << " use bbuild r [-s -t]\n";
170 BOPDS_PDS pDS=BOPTest_Objects::PDS();
172 di << " prepare PaveFiller first\n";
177 Standard_Boolean bRunParallel, bShowTime;
178 Standard_Integer i, iErr;
180 BOPTime_Chronometer aChrono;
181 BOPCol_ListIteratorOfListOfShape aIt;
183 BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
185 BOPAlgo_Builder& aBuilder=BOPTest_Objects::Builder();
188 BOPCol_ListOfShape& aLSObj=BOPTest_Objects::Shapes();
189 aIt.Initialize(aLSObj);
190 for (; aIt.More(); aIt.Next()) {
191 const TopoDS_Shape& aS=aIt.Value();
192 aBuilder.AddArgument(aS);
195 BOPCol_ListOfShape& aLSTool=BOPTest_Objects::Tools();
196 aIt.Initialize(aLSTool);
197 for (; aIt.More(); aIt.Next()) {
198 const TopoDS_Shape& aS=aIt.Value();
199 aBuilder.AddArgument(aS);
202 bShowTime=Standard_False;
203 bRunParallel=Standard_True;
204 for (i=2; i<n; ++i) {
205 if (!strcmp(a[i], "-s")) {
206 bRunParallel=Standard_False;
208 else if (!strcmp(a[i], "-t")) {
209 bShowTime=Standard_True;
212 aBuilder.SetRunParallel(bRunParallel);
217 aBuilder.PerformWithFiller(aPF);
218 iErr=aBuilder.ErrorStatus();
220 Sprintf(buf, " error: %d\n", iErr);
230 aTime=aChrono.Time();
231 Sprintf(buf, " Tps: %7.2lf\n", aTime);
235 const TopoDS_Shape& aR=aBuilder.Shape();
237 di << " null shape\n";
241 DBRep::Set(a[1], aR);
245 //=======================================================================
248 //=======================================================================
249 Standard_Integer bbop(Draw_Interpretor& di,
254 di << " use bbop r op [-s -t]\n";
258 BOPDS_PDS pDS=BOPTest_Objects::PDS();
260 di << " prepare PaveFiller first\n";
265 Standard_Boolean bRunParallel, bShowTime;
266 Standard_Integer iErr, iOp, i;
267 BOPAlgo_Operation aOp;
268 BOPCol_ListIteratorOfListOfShape aIt;
269 BOPTime_Chronometer aChrono;
271 iOp=Draw::Atoi(a[2]);
272 if (iOp<0 || iOp>4) {
273 di << " invalid operation type\n";
276 aOp=(BOPAlgo_Operation)iOp;
278 bShowTime=Standard_False;
279 bRunParallel=Standard_True;
280 for (i=3; i<n; ++i) {
281 if (!strcmp(a[i], "-s")) {
282 bRunParallel=Standard_False;
284 else if (!strcmp(a[i], "-t")) {
285 bShowTime=Standard_True;
289 BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
291 BOPAlgo_BOP& aBOP=BOPTest_Objects::BOP();
294 BOPCol_ListOfShape& aLSObj=BOPTest_Objects::Shapes();
295 aIt.Initialize(aLSObj);
296 for (; aIt.More(); aIt.Next()) {
297 const TopoDS_Shape& aS=aIt.Value();
298 aBOP.AddArgument(aS);
301 BOPCol_ListOfShape& aLSTools=BOPTest_Objects::Tools();
302 aIt.Initialize(aLSTools);
303 for (; aIt.More(); aIt.Next()) {
304 const TopoDS_Shape& aS=aIt.Value();
308 aBOP.SetOperation(aOp);
309 aBOP.SetRunParallel(bRunParallel);
313 aBOP.PerformWithFiller(aPF);
314 iErr=aBOP.ErrorStatus();
316 Sprintf(buf, " error: %d\n", iErr);
326 aTime=aChrono.Time();
327 Sprintf(buf, " Tps: %7.2lf\n", aTime);
331 const TopoDS_Shape& aR=aBOP.Shape();
333 di << " null shape\n";
337 DBRep::Set(a[1], aR);