0024428: Implementation of LGPL license
[occt.git] / src / BOPTest / BOPTest_ObjCommands.cxx
CommitLineData
4e57c75e 1// Created by: Peter KURNEV
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
4e57c75e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
4e57c75e 5//
973c2be1 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.
4e57c75e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
4e57c75e 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
28static Standard_Integer baddobjects (Draw_Interpretor& , Standard_Integer , const char** );
29static Standard_Integer bclearobjects (Draw_Interpretor& , Standard_Integer , const char** );
30static Standard_Integer baddtools (Draw_Interpretor& , Standard_Integer , const char** );
31static Standard_Integer bcleartools (Draw_Interpretor& , Standard_Integer , const char** );
32static 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//=======================================================================
56Standard_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//=======================================================================
82Standard_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//=======================================================================
104Standard_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//=======================================================================
119Standard_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//=======================================================================
141Standard_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}