0030058: Visualization, Select3D_SensitivePrimitiveArray - the selection is not fast...
[occt.git] / src / BOPTest / BOPTest_ObjCommands.cxx
1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15
16 #include <BOPTest.hxx>
17 #include <BOPTest_Objects.hxx>
18 #include <DBRep.hxx>
19 #include <Draw_Interpretor.hxx>
20 #include <TopoDS_Iterator.hxx>
21 #include <TopoDS_Shape.hxx>
22 #include <TopTools_ListOfShape.hxx>
23
24 #include <stdio.h>
25 //
26 //
27 //
28 static Standard_Integer baddobjects (Draw_Interpretor& , Standard_Integer , const char** );
29 static Standard_Integer bclearobjects (Draw_Interpretor& , Standard_Integer , const char** );
30 static Standard_Integer baddtools   (Draw_Interpretor& , Standard_Integer , const char** );
31 static Standard_Integer bcleartools (Draw_Interpretor& , Standard_Integer , const char** );
32 static Standard_Integer baddcompound(Draw_Interpretor& , Standard_Integer , const char** );
33 static Standard_Integer baddctools  (Draw_Interpretor& , Standard_Integer , const char** );
34 static Standard_Integer bclear   (Draw_Interpretor&, Standard_Integer, const char**);
35
36 //
37 //=======================================================================
38 //function :ObjCommands
39 //purpose  : 
40 //=======================================================================
41   void BOPTest::ObjCommands(Draw_Interpretor& theCommands)
42 {
43   static Standard_Boolean done = Standard_False;
44   if (done) return;
45   done = Standard_True;
46   // Chapter's name
47   const char* g = "BOPTest commands";
48   // Commands
49   theCommands.Add("baddobjects"    , "use baddobjects s1 s2 ..." , __FILE__, baddobjects, g);
50   theCommands.Add("bclearobjects"  , "use bclearobjects"         , __FILE__, bclearobjects, g);
51   theCommands.Add("baddtools"      , "use baddtools s1 s2 ..."   , __FILE__, baddtools, g);
52   theCommands.Add("bcleartools"    , "use bcleartools"           , __FILE__, bcleartools, g);
53   theCommands.Add("baddcompound"   , "use baddcompound c"        , __FILE__, baddcompound, g);
54   theCommands.Add("baddctools"     , "use baddctools c"          , __FILE__, baddctools, g);
55   theCommands.Add("bclear" , "use bclear"        , __FILE__, bclear, g);
56 }
57 //=======================================================================
58 //function : baddcompound
59 //purpose  : 
60 //=======================================================================
61 Standard_Integer baddcompound (Draw_Interpretor& , 
62                                Standard_Integer n, 
63                                const char** a)
64 {
65   if (n<2) {
66     printf(" use baddcompound c\n");
67     return 0;
68   }
69   //
70   TopoDS_Iterator aIt;
71   TopoDS_Shape aS;
72   //
73   aS=DBRep::Get(a[1]);
74   //
75   TopTools_ListOfShape& aLS=BOPTest_Objects::Shapes();
76   aIt.Initialize(aS);
77   for (; aIt.More(); aIt.Next()) {
78     const TopoDS_Shape& aSx=aIt.Value();
79     aLS.Append(aSx);
80   }
81   //
82   return 0;
83 }
84 //=======================================================================
85 //function : baddctools
86 //purpose  : 
87 //=======================================================================
88 Standard_Integer baddctools (Draw_Interpretor& , 
89                              Standard_Integer n, 
90                              const char** a)
91 {
92   if (n<2) {
93     printf(" use baddctools c\n");
94     return 0;
95   }
96   //
97   TopoDS_Iterator aIt;
98   TopoDS_Shape aS;
99   //
100   aS=DBRep::Get(a[1]);
101   //
102   TopTools_ListOfShape& aLT=BOPTest_Objects::Tools();
103   aIt.Initialize(aS);
104   for (; aIt.More(); aIt.Next()) {
105     const TopoDS_Shape& aSx=aIt.Value();
106     aLT.Append(aSx);
107   }
108   //
109   return 0;
110 }
111 //
112 //=======================================================================
113 //function :baddobjects
114 //purpose  : 
115 //=======================================================================
116 Standard_Integer baddobjects (Draw_Interpretor& , 
117                               Standard_Integer n, 
118                               const char** a)
119 {
120   if (n<2) {
121     printf(" use baddobjects s1 s2 ...\n");
122     return 0;
123   }
124   //
125   Standard_Integer i;
126   TopoDS_Shape aS;
127   //
128   TopTools_ListOfShape& aLS=BOPTest_Objects::Shapes();
129   for (i = 1; i < n; ++i) {
130     aS=DBRep::Get(a[i]);
131     aLS.Append(aS);
132   }
133   //
134   return 0;
135 }
136 //=======================================================================
137 //function : bclearobjects
138 //purpose  : 
139 //=======================================================================
140 Standard_Integer bclearobjects (Draw_Interpretor& , 
141                                 Standard_Integer n, 
142                                 const char** )
143 {
144   if (n!=1) {
145     printf(" use bclearobjects\n");
146     return 0;
147   }
148   TopTools_ListOfShape& aLS=BOPTest_Objects::Shapes();
149   aLS.Clear();
150   //
151   return 0;
152 }
153 //=======================================================================
154 //function : baddtools
155 //purpose  : 
156 //=======================================================================
157 Standard_Integer baddtools (Draw_Interpretor& , 
158                             Standard_Integer n, 
159                             const char** a)
160 {
161   if (n<2) {
162     printf(" use baddtools s1 s2 ...\n");
163     return 0;
164   }
165   //
166   Standard_Integer i;
167   TopoDS_Shape aS;
168   //
169   TopTools_ListOfShape& aLS=BOPTest_Objects::Tools();
170   for (i = 1; i < n; ++i) {
171     aS=DBRep::Get(a[i]);
172     aLS.Append(aS);
173   }
174   //
175   return 0;
176 }
177 //=======================================================================
178 //function : bcleartools
179 //purpose  : 
180 //=======================================================================
181 Standard_Integer bcleartools (Draw_Interpretor& ,
182                               Standard_Integer n, 
183                               const char** )
184 {
185   if (n!=1) {
186     printf(" use bcleartools\n");
187     return 0;
188   }
189   TopTools_ListOfShape& aLS=BOPTest_Objects::Tools();
190   aLS.Clear();
191   //
192   return 0;
193 }
194 //=======================================================================
195 //function : bclear
196 //purpose  : 
197 //=======================================================================
198 Standard_Integer bclear(Draw_Interpretor& di, 
199                         Standard_Integer n, 
200                         const char** ) 
201 {
202   if (n!=1) {
203     di << " use bclear\n";
204     return 0;
205   }
206   //
207   BOPTest_Objects::Clear(); 
208   return 0;
209 }