1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include <Standard_Stream.hxx>
25 #include "GEOM_IBooleanOperations_i.hh"
27 #include "utilities.h"
30 #include "GEOM_Engine.hxx"
31 #include "GEOM_Object.hxx"
33 #include <TColStd_HArray1OfInteger.hxx>
35 //=============================================================================
39 //=============================================================================
40 GEOM_IBooleanOperations_i::GEOM_IBooleanOperations_i (PortableServer::POA_ptr thePOA,
41 GEOM::GEOM_Gen_ptr theEngine,
42 ::GEOMImpl_IBooleanOperations* theImpl)
43 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
45 MESSAGE("GEOM_IBooleanOperations_i::GEOM_IBooleanOperations_i");
48 //=============================================================================
52 //=============================================================================
53 GEOM_IBooleanOperations_i::~GEOM_IBooleanOperations_i()
55 MESSAGE("GEOM_IBooleanOperations_i::~GEOM_IBooleanOperations_i");
59 //=============================================================================
63 //=============================================================================
64 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeBoolean
65 (GEOM::GEOM_Object_ptr theShape1,
66 GEOM::GEOM_Object_ptr theShape2,
68 CORBA::Boolean IsCheckSelfInte)
70 GEOM::GEOM_Object_var aGEOMObject;
73 GetOperations()->SetNotDone();
75 //Get the reference shapes
76 Handle(GEOM_Object) aSh1 = GetObjectImpl(theShape1);
77 Handle(GEOM_Object) aSh2 = GetObjectImpl(theShape2);
79 if (aSh1.IsNull() || aSh2.IsNull()) return aGEOMObject._retn();
82 Handle(GEOM_Object) anObject =
83 GetOperations()->MakeBoolean(aSh1, aSh2, theOp, IsCheckSelfInte);
84 if (!GetOperations()->IsDone() || anObject.IsNull())
85 return aGEOMObject._retn();
87 return GetObject(anObject);
90 //=============================================================================
94 //=============================================================================
95 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuseList
96 (const GEOM::ListOfGO& theShapes,
97 CORBA::Boolean IsCheckSelfInte)
99 GEOM::GEOM_Object_var aGEOMObject;
101 //Set a not done flag
102 GetOperations()->SetNotDone();
104 Handle(TColStd_HSequenceOfTransient) aShapes =
105 GetListOfObjectsImpl(theShapes);
107 if (aShapes.IsNull()) {
108 return aGEOMObject._retn();
112 Handle(GEOM_Object) anObject =
113 GetOperations()->MakeFuseList(aShapes, IsCheckSelfInte);
115 if (!GetOperations()->IsDone() || anObject.IsNull())
116 return aGEOMObject._retn();
118 return GetObject(anObject);
121 //=============================================================================
125 //=============================================================================
126 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCommonList
127 (const GEOM::ListOfGO& theShapes,
128 CORBA::Boolean IsCheckSelfInte)
130 GEOM::GEOM_Object_var aGEOMObject;
132 //Set a not done flag
133 GetOperations()->SetNotDone();
135 Handle(TColStd_HSequenceOfTransient) aShapes =
136 GetListOfObjectsImpl(theShapes);
138 if (aShapes.IsNull()) {
139 return aGEOMObject._retn();
143 Handle(GEOM_Object) anObject =
144 GetOperations()->MakeCommonList(aShapes, IsCheckSelfInte);
146 if (!GetOperations()->IsDone() || anObject.IsNull())
147 return aGEOMObject._retn();
149 return GetObject(anObject);
152 //=============================================================================
156 //=============================================================================
157 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCutList
158 (GEOM::GEOM_Object_ptr theMainShape,
159 const GEOM::ListOfGO& theShapes,
160 CORBA::Boolean IsCheckSelfInte)
162 GEOM::GEOM_Object_var aGEOMObject;
164 //Set a not done flag
165 GetOperations()->SetNotDone();
167 Handle(GEOM_Object) aMainShape = GetObjectImpl(theMainShape);
169 if (aMainShape.IsNull()) {
170 return aGEOMObject._retn();
173 Handle(TColStd_HSequenceOfTransient) aShapes =
174 GetListOfObjectsImpl(theShapes);
176 if (aShapes.IsNull()) {
177 return aGEOMObject._retn();
181 Handle(GEOM_Object) anObject =
182 GetOperations()->MakeCutList(aMainShape, aShapes, IsCheckSelfInte);
184 if (!GetOperations()->IsDone() || anObject.IsNull())
185 return aGEOMObject._retn();
187 return GetObject(anObject);
190 //=============================================================================
194 //=============================================================================
195 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition
196 (const GEOM::ListOfGO& theShapes,
197 const GEOM::ListOfGO& theTools,
198 const GEOM::ListOfGO& theKeepIns,
199 const GEOM::ListOfGO& theRemoveIns,
200 CORBA::Short theLimit,
201 CORBA::Boolean theRemoveWebs,
202 const GEOM::ListOfLong& theMaterials,
203 CORBA::Short theKeepNonlimitShapes)
205 GEOM::GEOM_Object_var aGEOMObject;
207 //Set a not done flag
208 GetOperations()->SetNotDone();
210 Handle(TColStd_HSequenceOfTransient) aShapes = GetListOfObjectsImpl(theShapes);
211 Handle(TColStd_HSequenceOfTransient) aTools = GetListOfObjectsImpl(theTools);
212 Handle(TColStd_HSequenceOfTransient) aKeepIns = GetListOfObjectsImpl(theKeepIns);
213 Handle(TColStd_HSequenceOfTransient) aRemIns = GetListOfObjectsImpl(theRemoveIns);
214 Handle(TColStd_HArray1OfInteger) aMaterials;
216 if (aShapes.IsNull() || aTools.IsNull() ||
217 aKeepIns.IsNull() || aRemIns.IsNull()) {
218 return aGEOMObject._retn();
223 int aLen = theMaterials.length();
225 aMaterials = new TColStd_HArray1OfInteger (1, aLen);
226 for (ind = 0; ind < aLen; ind++) {
227 aMaterials->SetValue(ind+1, theMaterials[ind]);
232 Handle(GEOM_Object) anObject =
233 GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns,
234 theLimit, theRemoveWebs, aMaterials,
235 theKeepNonlimitShapes,
236 /*PerformSelfIntersections*/Standard_True,
237 /*IsCheckSelfInte*/Standard_False);
238 if (!GetOperations()->IsDone() || anObject.IsNull())
239 return aGEOMObject._retn();
241 return GetObject(anObject);
244 //=============================================================================
246 * MakePartitionNonSelfIntersectedShape
248 //=============================================================================
249 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersectedShape
250 (const GEOM::ListOfGO& theShapes,
251 const GEOM::ListOfGO& theTools,
252 const GEOM::ListOfGO& theKeepIns,
253 const GEOM::ListOfGO& theRemoveIns,
254 CORBA::Short theLimit,
255 CORBA::Boolean theRemoveWebs,
256 const GEOM::ListOfLong& theMaterials,
257 CORBA::Short theKeepNonlimitShapes,
258 CORBA::Boolean IsCheckSelfInte)
260 GEOM::GEOM_Object_var aGEOMObject;
262 //Set a not done flag
263 GetOperations()->SetNotDone();
265 Handle(TColStd_HSequenceOfTransient) aShapes = GetListOfObjectsImpl(theShapes);
266 Handle(TColStd_HSequenceOfTransient) aTools = GetListOfObjectsImpl(theTools);
267 Handle(TColStd_HSequenceOfTransient) aKeepIns = GetListOfObjectsImpl(theKeepIns);
268 Handle(TColStd_HSequenceOfTransient) aRemIns = GetListOfObjectsImpl(theRemoveIns);
269 Handle(TColStd_HArray1OfInteger) aMaterials;
271 if (aShapes.IsNull() || aTools.IsNull() ||
272 aKeepIns.IsNull() || aRemIns.IsNull()) {
273 return aGEOMObject._retn();
278 int aLen = theMaterials.length();
280 aMaterials = new TColStd_HArray1OfInteger (1, aLen);
281 for (ind = 0; ind < aLen; ind++) {
282 aMaterials->SetValue(ind+1, theMaterials[ind]);
287 Handle(GEOM_Object) anObject =
288 GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns,
289 theLimit, theRemoveWebs, aMaterials,
290 theKeepNonlimitShapes,
291 /*PerformSelfIntersections*/Standard_False,
293 if (!GetOperations()->IsDone() || anObject.IsNull())
294 return aGEOMObject._retn();
296 return GetObject(anObject);
299 //=============================================================================
303 //=============================================================================
304 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartition
305 (GEOM::GEOM_Object_ptr theShape,
306 GEOM::GEOM_Object_ptr thePlane)
308 GEOM::GEOM_Object_var aGEOMObject;
310 //Set a not done flag
311 GetOperations()->SetNotDone();
313 //Get the reference shapes
314 Handle(GEOM_Object) aSh = GetObjectImpl(theShape);
315 Handle(GEOM_Object) aPl = GetObjectImpl(thePlane);
317 if (aSh.IsNull() || aPl.IsNull()) return aGEOMObject._retn();
319 // Make Half Partition
320 Handle(GEOM_Object) anObject =
321 GetOperations()->MakeHalfPartition(aSh, aPl);
322 if (!GetOperations()->IsDone() || anObject.IsNull())
323 return aGEOMObject._retn();
325 return GetObject(anObject);