1 // Copyright (C) 2007-2024 CEA, EDF, 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 return MakeBooleanWithFuzzy(theShape1, theShape2, theOp, IsCheckSelfInte, -1.0);
73 //=============================================================================
77 //=============================================================================
78 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuse
79 (GEOM::GEOM_Object_ptr theShape1,
80 GEOM::GEOM_Object_ptr theShape2,
81 CORBA::Boolean IsCheckSelfInte,
82 CORBA::Boolean IsRmExtraEdges)
84 return MakeFuseWithFuzzy(theShape1, theShape2, IsCheckSelfInte, IsRmExtraEdges, -1.0);
87 //=============================================================================
91 //=============================================================================
92 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuseList
93 (const GEOM::ListOfGO& theShapes,
94 CORBA::Boolean IsCheckSelfInte,
95 CORBA::Boolean IsRmExtraEdges)
97 return MakeFuseListWithFuzzy(theShapes, IsCheckSelfInte, IsRmExtraEdges, -1.0);
100 //=============================================================================
104 //=============================================================================
105 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCommonList
106 (const GEOM::ListOfGO& theShapes,
107 CORBA::Boolean IsCheckSelfInte)
109 return MakeCommonListWithFuzzy(theShapes, IsCheckSelfInte, -1.0);
112 //=============================================================================
116 //=============================================================================
117 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCutList
118 (GEOM::GEOM_Object_ptr theMainShape,
119 const GEOM::ListOfGO& theShapes,
120 CORBA::Boolean IsCheckSelfInte)
122 return MakeCutListWithFuzzy(theMainShape, theShapes, IsCheckSelfInte, -1.0);
125 //=============================================================================
129 //=============================================================================
130 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition
131 (const GEOM::ListOfGO& theShapes,
132 const GEOM::ListOfGO& theTools,
133 const GEOM::ListOfGO& theKeepIns,
134 const GEOM::ListOfGO& theRemoveIns,
135 CORBA::Short theLimit,
136 CORBA::Boolean theRemoveWebs,
137 const GEOM::ListOfLong& theMaterials,
138 CORBA::Short theKeepNonlimitShapes)
140 return MakePartitionWithFuzzy(theShapes, theTools, theKeepIns, theRemoveIns, theLimit,
141 theRemoveWebs, theMaterials, theKeepNonlimitShapes, -1.0);
144 //=============================================================================
146 * MakePartitionNonSelfIntersectedShape
148 //=============================================================================
149 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersectedShape
150 (const GEOM::ListOfGO& theShapes,
151 const GEOM::ListOfGO& theTools,
152 const GEOM::ListOfGO& theKeepIns,
153 const GEOM::ListOfGO& theRemoveIns,
154 CORBA::Short theLimit,
155 CORBA::Boolean theRemoveWebs,
156 const GEOM::ListOfLong& theMaterials,
157 CORBA::Short theKeepNonlimitShapes,
158 CORBA::Boolean IsCheckSelfInte)
160 return MakePartitionNonSelfIntersectedShapeWithFuzzy(theShapes, theTools, theKeepIns, theRemoveIns,
161 theLimit, theRemoveWebs, theMaterials,
162 theKeepNonlimitShapes, IsCheckSelfInte, -1.0);
165 //=============================================================================
169 //=============================================================================
170 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartition
171 (GEOM::GEOM_Object_ptr theShape,
172 GEOM::GEOM_Object_ptr thePlane)
174 return MakeHalfPartitionWithFuzzy(theShape, thePlane, -1.0);
179 //=============================================================================
181 * MakeBooleanWithFuzzy
183 //=============================================================================
184 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeBooleanWithFuzzy
185 (GEOM::GEOM_Object_ptr theShape1,
186 GEOM::GEOM_Object_ptr theShape2,
188 CORBA::Boolean IsCheckSelfInte,
189 CORBA::Double theFuzzyParam)
191 GEOM::GEOM_Object_var aGEOMObject;
193 //Set a not done flag
194 GetOperations()->SetNotDone();
196 //Get the reference shapes
197 Handle(::GEOM_Object) aSh1 = GetObjectImpl(theShape1);
198 Handle(::GEOM_Object) aSh2 = GetObjectImpl(theShape2);
200 if (aSh1.IsNull() || aSh2.IsNull()) return aGEOMObject._retn();
203 Handle(::GEOM_Object) anObject =
204 GetOperations()->MakeBoolean(aSh1, aSh2, theOp, IsCheckSelfInte, theFuzzyParam);
205 if (!GetOperations()->IsDone() || anObject.IsNull())
206 return aGEOMObject._retn();
208 return GetObject(anObject);
211 //=============================================================================
215 //=============================================================================
216 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuseWithFuzzy
217 (GEOM::GEOM_Object_ptr theShape1,
218 GEOM::GEOM_Object_ptr theShape2,
219 CORBA::Boolean IsCheckSelfInte,
220 CORBA::Boolean IsRmExtraEdges,
221 CORBA::Double theFuzzyParam)
223 GEOM::GEOM_Object_var aGEOMObject;
225 //Set a not done flag
226 GetOperations()->SetNotDone();
228 //Get the reference shapes
229 Handle(::GEOM_Object) aSh1 = GetObjectImpl(theShape1);
230 Handle(::GEOM_Object) aSh2 = GetObjectImpl(theShape2);
232 if (aSh1.IsNull() || aSh2.IsNull()) return aGEOMObject._retn();
235 Handle(::GEOM_Object) anObject = GetOperations()->MakeFuse
236 (aSh1, aSh2, IsCheckSelfInte, IsRmExtraEdges, theFuzzyParam);
238 if (!GetOperations()->IsDone() || anObject.IsNull())
239 return aGEOMObject._retn();
241 return GetObject(anObject);
244 //=============================================================================
246 * MakeFuseListWithFuzzy
248 //=============================================================================
249 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuseListWithFuzzy
250 (const GEOM::ListOfGO& theShapes,
251 CORBA::Boolean IsCheckSelfInte,
252 CORBA::Boolean IsRmExtraEdges,
253 CORBA::Double theFuzzyParam)
255 GEOM::GEOM_Object_var aGEOMObject;
257 //Set a not done flag
258 GetOperations()->SetNotDone();
260 Handle(TColStd_HSequenceOfTransient) aShapes =
261 GetListOfObjectsImpl(theShapes);
263 if (aShapes.IsNull()) {
264 return aGEOMObject._retn();
268 Handle(::GEOM_Object) anObject =
269 GetOperations()->MakeFuseList(aShapes, IsCheckSelfInte, IsRmExtraEdges, theFuzzyParam);
271 if (!GetOperations()->IsDone() || anObject.IsNull())
272 return aGEOMObject._retn();
274 return GetObject(anObject);
277 //=============================================================================
279 * MakeCommonListWithFuzzy
281 //=============================================================================
282 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCommonListWithFuzzy
283 (const GEOM::ListOfGO& theShapes,
284 CORBA::Boolean IsCheckSelfInte,
285 CORBA::Double theFuzzyParam)
287 GEOM::GEOM_Object_var aGEOMObject;
289 //Set a not done flag
290 GetOperations()->SetNotDone();
292 Handle(TColStd_HSequenceOfTransient) aShapes =
293 GetListOfObjectsImpl(theShapes);
295 if (aShapes.IsNull()) {
296 return aGEOMObject._retn();
300 Handle(::GEOM_Object) anObject =
301 GetOperations()->MakeCommonList(aShapes, IsCheckSelfInte, theFuzzyParam);
303 if (!GetOperations()->IsDone() || anObject.IsNull())
304 return aGEOMObject._retn();
306 return GetObject(anObject);
309 //=============================================================================
311 * MakeCutListWithFuzzy
313 //=============================================================================
314 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCutListWithFuzzy
315 (GEOM::GEOM_Object_ptr theMainShape,
316 const GEOM::ListOfGO& theShapes,
317 CORBA::Boolean IsCheckSelfInte,
318 CORBA::Double theFuzzyParam)
320 GEOM::GEOM_Object_var aGEOMObject;
322 //Set a not done flag
323 GetOperations()->SetNotDone();
325 Handle(::GEOM_Object) aMainShape = GetObjectImpl(theMainShape);
327 if (aMainShape.IsNull()) {
328 return aGEOMObject._retn();
331 Handle(TColStd_HSequenceOfTransient) aShapes =
332 GetListOfObjectsImpl(theShapes);
334 if (aShapes.IsNull()) {
335 return aGEOMObject._retn();
339 Handle(::GEOM_Object) anObject =
340 GetOperations()->MakeCutList(aMainShape, aShapes, IsCheckSelfInte, theFuzzyParam);
342 if (!GetOperations()->IsDone() || anObject.IsNull())
343 return aGEOMObject._retn();
345 return GetObject(anObject);
348 //=============================================================================
350 * MakePartitionWithFuzzy
352 //=============================================================================
353 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionWithFuzzy
354 (const GEOM::ListOfGO& theShapes,
355 const GEOM::ListOfGO& theTools,
356 const GEOM::ListOfGO& theKeepIns,
357 const GEOM::ListOfGO& theRemoveIns,
358 CORBA::Short theLimit,
359 CORBA::Boolean theRemoveWebs,
360 const GEOM::ListOfLong& theMaterials,
361 CORBA::Short theKeepNonlimitShapes,
362 CORBA::Double theFuzzyParam)
364 GEOM::GEOM_Object_var aGEOMObject;
366 //Set a not done flag
367 GetOperations()->SetNotDone();
369 Handle(TColStd_HSequenceOfTransient) aShapes = GetListOfObjectsImpl(theShapes);
370 Handle(TColStd_HSequenceOfTransient) aTools = GetListOfObjectsImpl(theTools);
371 Handle(TColStd_HSequenceOfTransient) aKeepIns = GetListOfObjectsImpl(theKeepIns);
372 Handle(TColStd_HSequenceOfTransient) aRemIns = GetListOfObjectsImpl(theRemoveIns);
373 Handle(TColStd_HArray1OfInteger) aMaterials;
375 if (aShapes.IsNull() || aTools.IsNull() ||
376 aKeepIns.IsNull() || aRemIns.IsNull()) {
377 return aGEOMObject._retn();
382 int aLen = theMaterials.length();
384 aMaterials = new TColStd_HArray1OfInteger (1, aLen);
385 for (ind = 0; ind < aLen; ind++) {
386 aMaterials->SetValue(ind+1, theMaterials[ind]);
391 Handle(::GEOM_Object) anObject =
392 GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns,
393 theLimit, theRemoveWebs, aMaterials,
394 theKeepNonlimitShapes,
395 /*PerformSelfIntersections*/Standard_True,
396 /*IsCheckSelfInte*/Standard_False,
398 if (!GetOperations()->IsDone() || anObject.IsNull())
399 return aGEOMObject._retn();
401 return GetObject(anObject);
404 //=============================================================================
406 * MakePartitionNonSelfIntersectedShapeWithFuzzy
408 //=============================================================================
409 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersectedShapeWithFuzzy
410 (const GEOM::ListOfGO& theShapes,
411 const GEOM::ListOfGO& theTools,
412 const GEOM::ListOfGO& theKeepIns,
413 const GEOM::ListOfGO& theRemoveIns,
414 CORBA::Short theLimit,
415 CORBA::Boolean theRemoveWebs,
416 const GEOM::ListOfLong& theMaterials,
417 CORBA::Short theKeepNonlimitShapes,
418 CORBA::Boolean IsCheckSelfInte,
419 CORBA::Double theFuzzyParam)
421 GEOM::GEOM_Object_var aGEOMObject;
423 //Set a not done flag
424 GetOperations()->SetNotDone();
426 Handle(TColStd_HSequenceOfTransient) aShapes = GetListOfObjectsImpl(theShapes);
427 Handle(TColStd_HSequenceOfTransient) aTools = GetListOfObjectsImpl(theTools);
428 Handle(TColStd_HSequenceOfTransient) aKeepIns = GetListOfObjectsImpl(theKeepIns);
429 Handle(TColStd_HSequenceOfTransient) aRemIns = GetListOfObjectsImpl(theRemoveIns);
430 Handle(TColStd_HArray1OfInteger) aMaterials;
432 if (aShapes.IsNull() || aTools.IsNull() ||
433 aKeepIns.IsNull() || aRemIns.IsNull()) {
434 return aGEOMObject._retn();
439 int aLen = theMaterials.length();
441 aMaterials = new TColStd_HArray1OfInteger (1, aLen);
442 for (ind = 0; ind < aLen; ind++) {
443 aMaterials->SetValue(ind+1, theMaterials[ind]);
448 Handle(::GEOM_Object) anObject =
449 GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns,
450 theLimit, theRemoveWebs, aMaterials,
451 theKeepNonlimitShapes,
452 /*PerformSelfIntersections*/Standard_False,
455 if (!GetOperations()->IsDone() || anObject.IsNull())
456 return aGEOMObject._retn();
458 return GetObject(anObject);
461 //=============================================================================
463 * MakeHalfPartitionWithFuzzy
465 //=============================================================================
466 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartitionWithFuzzy
467 (GEOM::GEOM_Object_ptr theShape,
468 GEOM::GEOM_Object_ptr thePlane,
469 CORBA::Double theFuzzyParam)
471 GEOM::GEOM_Object_var aGEOMObject;
473 //Set a not done flag
474 GetOperations()->SetNotDone();
476 //Get the reference shapes
477 Handle(::GEOM_Object) aSh = GetObjectImpl(theShape);
478 Handle(::GEOM_Object) aPl = GetObjectImpl(thePlane);
480 if (aSh.IsNull() || aPl.IsNull()) return aGEOMObject._retn();
482 // Make Half Partition
483 Handle(::GEOM_Object) anObject =
484 GetOperations()->MakeHalfPartition(aSh, aPl, theFuzzyParam);
485 if (!GetOperations()->IsDone() || anObject.IsNull())
486 return aGEOMObject._retn();
488 return GetObject(anObject);