1 // Copyright (C) 2007-2016 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_NAMESPACE(GEOM_Object) aSh1 = GetObjectImpl(theShape1);
77 HANDLE_NAMESPACE(GEOM_Object) aSh2 = GetObjectImpl(theShape2);
79 if (aSh1.IsNull() || aSh2.IsNull()) return aGEOMObject._retn();
82 HANDLE_NAMESPACE(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::MakeFuse
96 (GEOM::GEOM_Object_ptr theShape1,
97 GEOM::GEOM_Object_ptr theShape2,
98 CORBA::Boolean IsCheckSelfInte,
99 CORBA::Boolean IsRmExtraEdges)
101 GEOM::GEOM_Object_var aGEOMObject;
103 //Set a not done flag
104 GetOperations()->SetNotDone();
106 //Get the reference shapes
107 HANDLE_NAMESPACE(GEOM_Object) aSh1 = GetObjectImpl(theShape1);
108 HANDLE_NAMESPACE(GEOM_Object) aSh2 = GetObjectImpl(theShape2);
110 if (aSh1.IsNull() || aSh2.IsNull()) return aGEOMObject._retn();
113 HANDLE_NAMESPACE(GEOM_Object) anObject = GetOperations()->MakeFuse
114 (aSh1, aSh2, IsCheckSelfInte, IsRmExtraEdges);
116 if (!GetOperations()->IsDone() || anObject.IsNull())
117 return aGEOMObject._retn();
119 return GetObject(anObject);
122 //=============================================================================
126 //=============================================================================
127 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuseList
128 (const GEOM::ListOfGO& theShapes,
129 CORBA::Boolean IsCheckSelfInte,
130 CORBA::Boolean IsRmExtraEdges)
132 GEOM::GEOM_Object_var aGEOMObject;
134 //Set a not done flag
135 GetOperations()->SetNotDone();
137 Handle(TColStd_HSequenceOfTransient) aShapes =
138 GetListOfObjectsImpl(theShapes);
140 if (aShapes.IsNull()) {
141 return aGEOMObject._retn();
145 HANDLE_NAMESPACE(GEOM_Object) anObject =
146 GetOperations()->MakeFuseList(aShapes, IsCheckSelfInte, IsRmExtraEdges);
148 if (!GetOperations()->IsDone() || anObject.IsNull())
149 return aGEOMObject._retn();
151 return GetObject(anObject);
154 //=============================================================================
158 //=============================================================================
159 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCommonList
160 (const GEOM::ListOfGO& theShapes,
161 CORBA::Boolean IsCheckSelfInte)
163 GEOM::GEOM_Object_var aGEOMObject;
165 //Set a not done flag
166 GetOperations()->SetNotDone();
168 Handle(TColStd_HSequenceOfTransient) aShapes =
169 GetListOfObjectsImpl(theShapes);
171 if (aShapes.IsNull()) {
172 return aGEOMObject._retn();
176 HANDLE_NAMESPACE(GEOM_Object) anObject =
177 GetOperations()->MakeCommonList(aShapes, IsCheckSelfInte);
179 if (!GetOperations()->IsDone() || anObject.IsNull())
180 return aGEOMObject._retn();
182 return GetObject(anObject);
185 //=============================================================================
189 //=============================================================================
190 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCutList
191 (GEOM::GEOM_Object_ptr theMainShape,
192 const GEOM::ListOfGO& theShapes,
193 CORBA::Boolean IsCheckSelfInte)
195 GEOM::GEOM_Object_var aGEOMObject;
197 //Set a not done flag
198 GetOperations()->SetNotDone();
200 HANDLE_NAMESPACE(GEOM_Object) aMainShape = GetObjectImpl(theMainShape);
202 if (aMainShape.IsNull()) {
203 return aGEOMObject._retn();
206 Handle(TColStd_HSequenceOfTransient) aShapes =
207 GetListOfObjectsImpl(theShapes);
209 if (aShapes.IsNull()) {
210 return aGEOMObject._retn();
214 HANDLE_NAMESPACE(GEOM_Object) anObject =
215 GetOperations()->MakeCutList(aMainShape, aShapes, IsCheckSelfInte);
217 if (!GetOperations()->IsDone() || anObject.IsNull())
218 return aGEOMObject._retn();
220 return GetObject(anObject);
223 //=============================================================================
227 //=============================================================================
228 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition
229 (const GEOM::ListOfGO& theShapes,
230 const GEOM::ListOfGO& theTools,
231 const GEOM::ListOfGO& theKeepIns,
232 const GEOM::ListOfGO& theRemoveIns,
233 CORBA::Short theLimit,
234 CORBA::Boolean theRemoveWebs,
235 const GEOM::ListOfLong& theMaterials,
236 CORBA::Short theKeepNonlimitShapes)
238 GEOM::GEOM_Object_var aGEOMObject;
240 //Set a not done flag
241 GetOperations()->SetNotDone();
243 Handle(TColStd_HSequenceOfTransient) aShapes = GetListOfObjectsImpl(theShapes);
244 Handle(TColStd_HSequenceOfTransient) aTools = GetListOfObjectsImpl(theTools);
245 Handle(TColStd_HSequenceOfTransient) aKeepIns = GetListOfObjectsImpl(theKeepIns);
246 Handle(TColStd_HSequenceOfTransient) aRemIns = GetListOfObjectsImpl(theRemoveIns);
247 Handle(TColStd_HArray1OfInteger) aMaterials;
249 if (aShapes.IsNull() || aTools.IsNull() ||
250 aKeepIns.IsNull() || aRemIns.IsNull()) {
251 return aGEOMObject._retn();
256 int aLen = theMaterials.length();
258 aMaterials = new TColStd_HArray1OfInteger (1, aLen);
259 for (ind = 0; ind < aLen; ind++) {
260 aMaterials->SetValue(ind+1, theMaterials[ind]);
265 HANDLE_NAMESPACE(GEOM_Object) anObject =
266 GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns,
267 theLimit, theRemoveWebs, aMaterials,
268 theKeepNonlimitShapes,
269 /*PerformSelfIntersections*/Standard_True,
270 /*IsCheckSelfInte*/Standard_False);
271 if (!GetOperations()->IsDone() || anObject.IsNull())
272 return aGEOMObject._retn();
274 return GetObject(anObject);
277 //=============================================================================
279 * MakePartitionNonSelfIntersectedShape
281 //=============================================================================
282 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersectedShape
283 (const GEOM::ListOfGO& theShapes,
284 const GEOM::ListOfGO& theTools,
285 const GEOM::ListOfGO& theKeepIns,
286 const GEOM::ListOfGO& theRemoveIns,
287 CORBA::Short theLimit,
288 CORBA::Boolean theRemoveWebs,
289 const GEOM::ListOfLong& theMaterials,
290 CORBA::Short theKeepNonlimitShapes,
291 CORBA::Boolean IsCheckSelfInte)
293 GEOM::GEOM_Object_var aGEOMObject;
295 //Set a not done flag
296 GetOperations()->SetNotDone();
298 Handle(TColStd_HSequenceOfTransient) aShapes = GetListOfObjectsImpl(theShapes);
299 Handle(TColStd_HSequenceOfTransient) aTools = GetListOfObjectsImpl(theTools);
300 Handle(TColStd_HSequenceOfTransient) aKeepIns = GetListOfObjectsImpl(theKeepIns);
301 Handle(TColStd_HSequenceOfTransient) aRemIns = GetListOfObjectsImpl(theRemoveIns);
302 Handle(TColStd_HArray1OfInteger) aMaterials;
304 if (aShapes.IsNull() || aTools.IsNull() ||
305 aKeepIns.IsNull() || aRemIns.IsNull()) {
306 return aGEOMObject._retn();
311 int aLen = theMaterials.length();
313 aMaterials = new TColStd_HArray1OfInteger (1, aLen);
314 for (ind = 0; ind < aLen; ind++) {
315 aMaterials->SetValue(ind+1, theMaterials[ind]);
320 HANDLE_NAMESPACE(GEOM_Object) anObject =
321 GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns,
322 theLimit, theRemoveWebs, aMaterials,
323 theKeepNonlimitShapes,
324 /*PerformSelfIntersections*/Standard_False,
326 if (!GetOperations()->IsDone() || anObject.IsNull())
327 return aGEOMObject._retn();
329 return GetObject(anObject);
332 //=============================================================================
336 //=============================================================================
337 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartition
338 (GEOM::GEOM_Object_ptr theShape,
339 GEOM::GEOM_Object_ptr thePlane)
341 GEOM::GEOM_Object_var aGEOMObject;
343 //Set a not done flag
344 GetOperations()->SetNotDone();
346 //Get the reference shapes
347 HANDLE_NAMESPACE(GEOM_Object) aSh = GetObjectImpl(theShape);
348 HANDLE_NAMESPACE(GEOM_Object) aPl = GetObjectImpl(thePlane);
350 if (aSh.IsNull() || aPl.IsNull()) return aGEOMObject._retn();
352 // Make Half Partition
353 HANDLE_NAMESPACE(GEOM_Object) anObject =
354 GetOperations()->MakeHalfPartition(aSh, aPl);
355 if (!GetOperations()->IsDone() || anObject.IsNull())
356 return aGEOMObject._retn();
358 return GetObject(anObject);