1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
20 #include <BOPTest.ixx>
25 #include <NCollection_IncAllocator.hxx>
29 #include <Draw_Color.hxx>
30 #include <DrawTrSurf.hxx>
32 #include <TopoDS_Shape.hxx>
34 #include <BOPAlgo_Builder.hxx>
35 #include <BOPAlgo_PaveFiller.hxx>
36 #include <BOPAlgo_Operation.hxx>
37 #include <BOPAlgo_BOP.hxx>
39 #include <BOPTest_DrawableShape.hxx>
40 #include <BOPTest_Objects.hxx>
44 #include <BOPCol_TBB.hxx>
45 //=======================================================================
46 //class : BOPTime_Chronometer
48 //=======================================================================
49 class BOPTime_Chronometer {
51 BOPTime_Chronometer() {
54 ~BOPTime_Chronometer() {
58 myT0 = tick_count::now();
62 myTime=(tick_count::now() - myT0).seconds();
73 ////////////////////////////////////////////////////////////////////////
75 #include <OSD_Chronometer.hxx>
76 //=======================================================================
77 //class : BOPTime_Chronometer
79 //=======================================================================
80 class BOPTime_Chronometer {
82 BOPTime_Chronometer() {
85 ~BOPTime_Chronometer() {
89 myChronometer.Reset();
90 myChronometer.Start();
95 myChronometer.Show(myTime);
103 OSD_Chronometer myChronometer;
110 static Standard_Integer bfillds (Draw_Interpretor&, Standard_Integer, const char**);
111 static Standard_Integer bbuild (Draw_Interpretor&, Standard_Integer, const char**);
112 static Standard_Integer bbop (Draw_Interpretor&, Standard_Integer, const char**);
113 static Standard_Integer bclear (Draw_Interpretor&, Standard_Integer, const char**);
114 //=======================================================================
115 //function : PartitionCommands
117 //=======================================================================
118 void BOPTest::PartitionCommands(Draw_Interpretor& theCommands)
120 static Standard_Boolean done = Standard_False;
122 done = Standard_True;
124 const char* g = "Partition commands";
126 theCommands.Add("bfillds" , "use bfillds" , __FILE__, bfillds , g);
127 theCommands.Add("bbuild" , " use bbuild r [-s -t]" , __FILE__, bbuild, g);
128 theCommands.Add("bbop" , "use bbop r op" , __FILE__, bbop, g);
129 theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g);
132 //=======================================================================
135 //=======================================================================
136 Standard_Integer bclear(Draw_Interpretor& di, Standard_Integer n, const char** )
139 di << " use bclear\n";
143 BOPTest_Objects::Clear();
146 //=======================================================================
149 //=======================================================================
150 Standard_Integer bfillds(Draw_Interpretor& di, Standard_Integer n, const char** )
153 di << " Use bfillds\n";
158 Standard_Integer aNbS, aNbT, iErr;
159 BOPCol_ListIteratorOfListOfShape aIt;
160 BOPCol_ListOfShape aLC;
162 BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes();
165 di << " no objects to process\n";
169 BOPCol_ListOfShape& aLT=BOPTest_Objects::Tools();
173 for (; aIt.More(); aIt.Next()) {
174 const TopoDS_Shape& aS=aIt.Value();
179 for (; aIt.More(); aIt.Next()) {
180 const TopoDS_Shape& aS=aIt.Value();
184 BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
186 aPF.SetArguments(aLC);
189 iErr=aPF.ErrorStatus();
191 Sprintf(buf, " error: %d\n", iErr);
198 //=======================================================================
201 //=======================================================================
202 Standard_Integer bbuild(Draw_Interpretor& di, Standard_Integer n, const char** a)
205 di << " use bbuild r [-s -t]\n";
209 BOPDS_PDS pDS=BOPTest_Objects::PDS();
211 di << " prepare PaveFiller first\n";
216 Standard_Boolean bRunParallel, bShowTime;
217 Standard_Integer i, iErr;
219 BOPTime_Chronometer aChrono;
220 BOPCol_ListIteratorOfListOfShape aIt;
224 BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
226 BOPAlgo_Builder& aBuilder=BOPTest_Objects::Builder();
229 BOPCol_ListOfShape& aLSObj=BOPTest_Objects::Shapes();
230 aIt.Initialize(aLSObj);
231 for (; aIt.More(); aIt.Next()) {
232 const TopoDS_Shape& aS=aIt.Value();
233 aBuilder.AddArgument(aS);
236 BOPCol_ListOfShape& aLSTool=BOPTest_Objects::Tools();
237 aIt.Initialize(aLSTool);
238 for (; aIt.More(); aIt.Next()) {
239 const TopoDS_Shape& aS=aIt.Value();
240 aBuilder.AddArgument(aS);
243 bShowTime=Standard_False;
244 bRunParallel=Standard_True;
245 for (i=2; i<n; ++i) {
246 if (!strcmp(a[i], "-s")) {
247 bRunParallel=Standard_False;
249 else if (!strcmp(a[i], "-t")) {
250 bShowTime=Standard_True;
253 aBuilder.SetRunParallel(bRunParallel);
258 aBuilder.PerformWithFiller(aPF);
259 iErr=aBuilder.ErrorStatus();
261 Sprintf(buf, " error: %d\n", iErr);
271 aTime=aChrono.Time();
272 Sprintf(buf, " Tps: %7.2lf\n", aTime);
276 const TopoDS_Shape& aR=aBuilder.Shape();
278 di << " null shape\n";
282 DBRep::Set(a[1], aR);
286 //=======================================================================
289 //=======================================================================
290 Standard_Integer bbop(Draw_Interpretor& di, Standard_Integer n, const char** a)
293 di << " use bbop r op\n";
297 BOPDS_PDS pDS=BOPTest_Objects::PDS();
299 di << " prepare PaveFiller first\n";
304 Standard_Integer iErr, iOp;
305 BOPAlgo_Operation aOp;
306 BOPCol_ListIteratorOfListOfShape aIt;
308 iOp=Draw::Atoi(a[2]);
309 if (iOp<0 || iOp>4) {
310 di << " invalid operation type\n";
312 aOp=(BOPAlgo_Operation)iOp;
314 BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
316 BOPAlgo_BOP& aBOP=BOPTest_Objects::BOP();
319 BOPCol_ListOfShape& aLSObj=BOPTest_Objects::Shapes();
320 aIt.Initialize(aLSObj);
321 for (; aIt.More(); aIt.Next()) {
322 const TopoDS_Shape& aS=aIt.Value();
323 aBOP.AddArgument(aS);
326 BOPCol_ListOfShape& aLSTools=BOPTest_Objects::Tools();
327 aIt.Initialize(aLSTools);
328 for (; aIt.More(); aIt.Next()) {
329 const TopoDS_Shape& aS=aIt.Value();
333 aBOP.SetOperation(aOp);
335 aBOP.PerformWithFiller(aPF);
336 iErr=aBOP.ErrorStatus();
338 Sprintf(buf, " error: %d\n", iErr);
343 const TopoDS_Shape& aR=aBOP.Shape();
345 di << " null shape\n";
349 DBRep::Set(a[1], aR);