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>
24 #include <NCollection_IncAllocator.hxx>
28 #include <Draw_Color.hxx>
29 #include <DrawTrSurf.hxx>
31 #include <TopoDS_Shape.hxx>
33 #include <BOPAlgo_Builder.hxx>
34 #include <BOPAlgo_PaveFiller.hxx>
35 #include <BOPAlgo_Operation.hxx>
36 #include <BOPAlgo_BOP.hxx>
38 #include <BOPTest_DrawableShape.hxx>
39 #include <BOPTest_Objects.hxx>
42 static Standard_Integer bfillds (Draw_Interpretor&, Standard_Integer, const char**);
43 static Standard_Integer bbuild (Draw_Interpretor&, Standard_Integer, const char**);
44 static Standard_Integer bbop (Draw_Interpretor&, Standard_Integer, const char**);
45 static Standard_Integer bclear (Draw_Interpretor&, Standard_Integer, const char**);
46 //=======================================================================
47 //function : PartitionCommands
49 //=======================================================================
50 void BOPTest::PartitionCommands(Draw_Interpretor& theCommands)
52 static Standard_Boolean done = Standard_False;
56 const char* g = "Partition commands";
58 theCommands.Add("bfillds" , "use bfillds" , __FILE__, bfillds , g);
59 theCommands.Add("bbuild" , "use bbuild r" , __FILE__, bbuild, g);
60 theCommands.Add("bbop" , "use bbop r op" , __FILE__, bbop, g);
61 theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g);
64 //=======================================================================
67 //=======================================================================
68 Standard_Integer bclear(Draw_Interpretor& di, Standard_Integer n, const char** )
71 di << " use bclear\n";
75 BOPTest_Objects::Clear();
78 //=======================================================================
81 //=======================================================================
82 Standard_Integer bfillds(Draw_Interpretor& di, Standard_Integer n, const char** )
85 di << " Use bfillds\n";
90 Standard_Integer aNbS, aNbT, iErr;
91 BOPCol_ListIteratorOfListOfShape aIt;
92 BOPCol_ListOfShape aLC;
94 BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes();
97 di << " no objects to process\n";
101 BOPCol_ListOfShape& aLT=BOPTest_Objects::Tools();
105 for (; aIt.More(); aIt.Next()) {
106 const TopoDS_Shape& aS=aIt.Value();
111 for (; aIt.More(); aIt.Next()) {
112 const TopoDS_Shape& aS=aIt.Value();
116 BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
118 aPF.SetArguments(aLC);
121 iErr=aPF.ErrorStatus();
123 Sprintf(buf, " error: %d\n", iErr);
131 //=======================================================================
134 //=======================================================================
135 Standard_Integer bbuild(Draw_Interpretor& di, Standard_Integer n, const char** a)
138 di << " Use bbuild r\n";
142 BOPDS_PDS pDS=BOPTest_Objects::PDS();
144 di << " prepare PaveFiller first\n";
149 Standard_Integer iErr;
150 BOPCol_ListIteratorOfListOfShape aIt;
152 BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
154 BOPAlgo_Builder& aBuilder=BOPTest_Objects::Builder();
157 BOPCol_ListOfShape& aLSObj=BOPTest_Objects::Shapes();
158 aIt.Initialize(aLSObj);
159 for (; aIt.More(); aIt.Next()) {
160 const TopoDS_Shape& aS=aIt.Value();
161 aBuilder.AddArgument(aS);
164 BOPCol_ListOfShape& aLSTool=BOPTest_Objects::Tools();
165 aIt.Initialize(aLSTool);
166 for (; aIt.More(); aIt.Next()) {
167 const TopoDS_Shape& aS=aIt.Value();
168 aBuilder.AddArgument(aS);
171 aBuilder.PerformWithFiller(aPF);
172 iErr=aBuilder.ErrorStatus();
174 Sprintf(buf, " error: %d\n", iErr);
179 const TopoDS_Shape& aR=aBuilder.Shape();
181 di << " null shape\n";
185 DBRep::Set(a[1], aR);
189 //=======================================================================
192 //=======================================================================
193 Standard_Integer bbop(Draw_Interpretor& di, Standard_Integer n, const char** a)
196 di << " use bbop r op\n";
200 BOPDS_PDS pDS=BOPTest_Objects::PDS();
202 di << " prepare PaveFiller first\n";
207 Standard_Integer iErr, iOp;
208 BOPAlgo_Operation aOp;
209 BOPCol_ListIteratorOfListOfShape aIt;
211 iOp=Draw::Atoi(a[2]);
212 if (iOp<0 || iOp>4) {
213 di << " invalid operation type\n";
215 aOp=(BOPAlgo_Operation)iOp;
217 BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
219 BOPAlgo_BOP& aBOP=BOPTest_Objects::BOP();
222 BOPCol_ListOfShape& aLSObj=BOPTest_Objects::Shapes();
223 aIt.Initialize(aLSObj);
224 for (; aIt.More(); aIt.Next()) {
225 const TopoDS_Shape& aS=aIt.Value();
226 aBOP.AddArgument(aS);
229 BOPCol_ListOfShape& aLSTools=BOPTest_Objects::Tools();
230 aIt.Initialize(aLSTools);
231 for (; aIt.More(); aIt.Next()) {
232 const TopoDS_Shape& aS=aIt.Value();
236 aBOP.SetOperation(aOp);
238 aBOP.PerformWithFiller(aPF);
239 iErr=aBOP.ErrorStatus();
241 Sprintf(buf, " error: %d\n", iErr);
246 const TopoDS_Shape& aR=aBOP.Shape();
248 di << " null shape\n";
252 DBRep::Set(a[1], aR);