0024428: Implementation of LGPL license
[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
7 // under the terms of the GNU Lesser General Public 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 #include <BOPTest.ixx>
16 #include <stdio.h>
17
18 #include <Draw_Interpretor.hxx>
19 #include <DBRep.hxx>
20 //
21 #include <TopoDS_Iterator.hxx>
22 #include <TopoDS_Shape.hxx>
23 //
24 #include <TopTools_ListOfShape.hxx>
25 //
26 #include <BOPTest_Objects.hxx>
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 //
34 //=======================================================================
35 //function :ObjCommands
36 //purpose  : 
37 //=======================================================================
38   void BOPTest::ObjCommands(Draw_Interpretor& theCommands)
39 {
40   static Standard_Boolean done = Standard_False;
41   if (done) return;
42   done = Standard_True;
43   // Chapter's name
44   const char* g = "BOP commands";
45   // Commands
46   theCommands.Add("baddobjects"    , "baddobjects s1 s2 ..."    , __FILE__, baddobjects, g);
47   theCommands.Add("bclearobjects"  , "bclearobjects"            , __FILE__, bclearobjects, g);
48   theCommands.Add("baddtools"      , "baddtools s1 s2 ..."      , __FILE__, baddtools, g);
49   theCommands.Add("bcleartools"    , "bcleartools"              , __FILE__, bcleartools, g);
50   theCommands.Add("baddcompound"   , "baddcompound c"           , __FILE__, baddcompound, g);
51 }
52 //=======================================================================
53 //function : baddcompound
54 //purpose  : 
55 //=======================================================================
56 Standard_Integer baddcompound (Draw_Interpretor& , Standard_Integer n, const char** a)
57 {
58   if (n<2) {
59     printf(" Use baddcompound c\n");
60     return 0;
61   }
62   //
63   TopoDS_Iterator aIt;
64   TopoDS_Shape aS;
65   //
66   aS=DBRep::Get(a[1]);
67   //
68   BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes();
69   aIt.Initialize(aS);
70   for (; aIt.More(); aIt.Next()) {
71     const TopoDS_Shape& aSx=aIt.Value();
72     aLS.Append(aSx);
73   }
74   //
75   return 0;
76 }
77 //
78 //=======================================================================
79 //function :baddobjects
80 //purpose  : 
81 //=======================================================================
82 Standard_Integer baddobjects (Draw_Interpretor& , Standard_Integer n, const char** a)
83 {
84   if (n<2) {
85     printf(" Use baddobjects s1 s2 ...\n");
86     return 0;
87   }
88   //
89   Standard_Integer i;
90   TopoDS_Shape aS;
91   //
92   BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes();
93   for (i = 1; i < n; ++i) {
94     aS=DBRep::Get(a[i]);
95     aLS.Append(aS);
96   }
97   //
98   return 0;
99 }
100 //=======================================================================
101 //function : bclearobjects
102 //purpose  : 
103 //=======================================================================
104 Standard_Integer bclearobjects (Draw_Interpretor& , Standard_Integer n, const char** )
105 {
106   if (n!=1) {
107     printf(" Use bclearobjects\n");
108     return 0;
109   }
110   BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes();
111   aLS.Clear();
112   //
113   return 0;
114 }
115 //=======================================================================
116 //function : baddtools
117 //purpose  : 
118 //=======================================================================
119 Standard_Integer baddtools (Draw_Interpretor& , Standard_Integer n, const char** a)
120 {
121   if (n<2) {
122     printf(" Use baddtools s1 s2 ...\n");
123     return 0;
124   }
125   //
126   Standard_Integer i;
127   TopoDS_Shape aS;
128   //
129   BOPCol_ListOfShape& aLS=BOPTest_Objects::Tools();
130   for (i = 1; i < n; ++i) {
131     aS=DBRep::Get(a[i]);
132     aLS.Append(aS);
133   }
134   //
135   return 0;
136 }
137 //=======================================================================
138 //function : bcleartools
139 //purpose  : 
140 //=======================================================================
141 Standard_Integer bcleartools (Draw_Interpretor& , Standard_Integer n, const char** )
142 {
143   if (n!=1) {
144     printf(" Use bcleartools\n");
145     return 0;
146   }
147   BOPCol_ListOfShape& aLS=BOPTest_Objects::Tools();
148   aLS.Clear();
149   //
150   return 0;
151 }