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>
33 #include <BOPAlgo_Section.hxx>
35 #include <BOPTest_DrawableShape.hxx>
36 #include <BOPTest_Objects.hxx>
38 #include <OSD_Timer.hxx>
40 static Standard_Integer bfillds (Draw_Interpretor&, Standard_Integer, const char**);
41 static Standard_Integer bbuild (Draw_Interpretor&, Standard_Integer, const char**);
42 static Standard_Integer bbop (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 = "BOPTest commands";
56 theCommands.Add("bfillds", "use bfillds [-t]" , __FILE__, bfillds, g);
57 theCommands.Add("bbuild" , "use bbuild r [-t]" , __FILE__, bbuild, g);
58 theCommands.Add("bbop" , "use bbop r op [-t]", __FILE__, bbop, g);
60 //=======================================================================
63 //=======================================================================
64 Standard_Integer bfillds(Draw_Interpretor& di,
69 di << " use bfillds [-t]\n";
74 Standard_Boolean bRunParallel, bShowTime;
75 Standard_Integer i, aNbS, iErr;
77 BOPCol_ListIteratorOfListOfShape aIt;
78 BOPCol_ListOfShape aLC;
79 BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes();
82 di << " no objects to process\n";
86 bShowTime = Standard_False;
88 bRunParallel=BOPTest_Objects::RunParallel();
89 aTol=BOPTest_Objects::FuzzyValue();
92 if (!strcmp(a[i], "-t")) {
93 bShowTime=Standard_True;
97 BOPCol_ListOfShape& aLT=BOPTest_Objects::Tools();
100 for (; aIt.More(); aIt.Next()) {
101 const TopoDS_Shape& aS=aIt.Value();
106 for (; aIt.More(); aIt.Next()) {
107 const TopoDS_Shape& aS=aIt.Value();
111 BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
113 aPF.SetArguments(aLC);
114 aPF.SetRunParallel(bRunParallel);
115 aPF.SetFuzzyValue(aTol);
121 iErr=aPF.ErrorStatus();
123 Sprintf(buf, " error: %d\n", iErr);
133 Sprintf(buf, " Tps: %7.2lf\n", aTimer.ElapsedTime());
139 //=======================================================================
142 //=======================================================================
143 Standard_Integer bbuild(Draw_Interpretor& di,
148 di << " use bbuild r [-t]\n";
152 BOPDS_PDS pDS=BOPTest_Objects::PDS();
154 di << " prepare PaveFiller first\n";
159 Standard_Boolean bRunParallel, bShowTime;
160 Standard_Integer i, iErr;
162 BOPCol_ListIteratorOfListOfShape aIt;
164 BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
166 BOPAlgo_Builder& aBuilder=BOPTest_Objects::Builder();
169 BOPCol_ListOfShape& aLSObj=BOPTest_Objects::Shapes();
170 aIt.Initialize(aLSObj);
171 for (; aIt.More(); aIt.Next()) {
172 const TopoDS_Shape& aS=aIt.Value();
173 aBuilder.AddArgument(aS);
176 BOPCol_ListOfShape& aLSTool=BOPTest_Objects::Tools();
177 aIt.Initialize(aLSTool);
178 for (; aIt.More(); aIt.Next()) {
179 const TopoDS_Shape& aS=aIt.Value();
180 aBuilder.AddArgument(aS);
183 bShowTime=Standard_False;
184 bRunParallel=BOPTest_Objects::RunParallel();
185 for (i=2; i<n; ++i) {
186 if (!strcmp(a[i], "-t")) {
187 bShowTime=Standard_True;
190 aBuilder.SetRunParallel(bRunParallel);
196 aBuilder.PerformWithFiller(aPF);
197 iErr=aBuilder.ErrorStatus();
199 Sprintf(buf, " error: %d\n", iErr);
209 Sprintf(buf, " Tps: %7.2lf\n", aTimer.ElapsedTime());
213 const TopoDS_Shape& aR=aBuilder.Shape();
215 di << " null shape\n";
219 DBRep::Set(a[1], aR);
222 //=======================================================================
225 //=======================================================================
226 Standard_Integer bbop(Draw_Interpretor& di,
231 di << " use bbop r op [-t]\n";
235 BOPDS_PDS pDS=BOPTest_Objects::PDS();
237 di << " prepare PaveFiller first\n";
242 Standard_Boolean bRunParallel, bShowTime;
243 Standard_Integer iErr, iOp, i;
244 BOPAlgo_Operation aOp;
245 BOPCol_ListIteratorOfListOfShape aIt;
247 iOp=Draw::Atoi(a[2]);
248 if (iOp<0 || iOp>4) {
249 di << " invalid operation type\n";
252 aOp=(BOPAlgo_Operation)iOp;
254 bShowTime=Standard_False;
255 bRunParallel=BOPTest_Objects::RunParallel();
256 for (i=3; i<n; ++i) {
257 if (!strcmp(a[i], "-t")) {
258 bShowTime=Standard_True;
262 BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
264 BOPAlgo_Builder *pBuilder=NULL;
266 if (aOp!=BOPAlgo_SECTION) {
267 pBuilder=&BOPTest_Objects::BOP();
270 pBuilder=&BOPTest_Objects::Section();
275 BOPCol_ListOfShape& aLSObj=BOPTest_Objects::Shapes();
276 aIt.Initialize(aLSObj);
277 for (; aIt.More(); aIt.Next()) {
278 const TopoDS_Shape& aS=aIt.Value();
279 pBuilder->AddArgument(aS);
282 if (aOp!=BOPAlgo_SECTION) {
283 BOPAlgo_BOP *pBOP=(BOPAlgo_BOP *)pBuilder;
285 BOPCol_ListOfShape& aLSTools=BOPTest_Objects::Tools();
286 aIt.Initialize(aLSTools);
287 for (; aIt.More(); aIt.Next()) {
288 const TopoDS_Shape& aS=aIt.Value();
292 pBOP->SetOperation(aOp);
295 BOPCol_ListOfShape& aLSTools=BOPTest_Objects::Tools();
296 aIt.Initialize(aLSTools);
297 for (; aIt.More(); aIt.Next()) {
298 const TopoDS_Shape& aS=aIt.Value();
299 pBuilder->AddArgument(aS);
303 pBuilder->SetRunParallel(bRunParallel);
308 pBuilder->PerformWithFiller(aPF);
309 iErr=pBuilder->ErrorStatus();
311 Sprintf(buf, " error: %d\n", iErr);
320 Sprintf(buf, " Tps: %7.2lf\n", aTimer.ElapsedTime());
324 const TopoDS_Shape& aR=pBuilder->Shape();
326 di << " null shape\n";
330 DBRep::Set(a[1], aR);