1 // Copyright (C) 2007-2013 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.
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 if (!GetOperations()->IsDone() || anObject.IsNull())
238 return aGEOMObject._retn();
240 return GetObject(anObject);
243 //=============================================================================
245 * MakePartitionNonSelfIntersectedShape
247 //=============================================================================
248 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersectedShape
249 (const GEOM::ListOfGO& theShapes,
250 const GEOM::ListOfGO& theTools,
251 const GEOM::ListOfGO& theKeepIns,
252 const GEOM::ListOfGO& theRemoveIns,
253 CORBA::Short theLimit,
254 CORBA::Boolean theRemoveWebs,
255 const GEOM::ListOfLong& theMaterials,
256 CORBA::Short theKeepNonlimitShapes)
258 GEOM::GEOM_Object_var aGEOMObject;
260 //Set a not done flag
261 GetOperations()->SetNotDone();
263 Handle(TColStd_HSequenceOfTransient) aShapes = GetListOfObjectsImpl(theShapes);
264 Handle(TColStd_HSequenceOfTransient) aTools = GetListOfObjectsImpl(theTools);
265 Handle(TColStd_HSequenceOfTransient) aKeepIns = GetListOfObjectsImpl(theKeepIns);
266 Handle(TColStd_HSequenceOfTransient) aRemIns = GetListOfObjectsImpl(theRemoveIns);
267 Handle(TColStd_HArray1OfInteger) aMaterials;
269 if (aShapes.IsNull() || aTools.IsNull() ||
270 aKeepIns.IsNull() || aRemIns.IsNull()) {
271 return aGEOMObject._retn();
276 int aLen = theMaterials.length();
278 aMaterials = new TColStd_HArray1OfInteger (1, aLen);
279 for (ind = 0; ind < aLen; ind++) {
280 aMaterials->SetValue(ind+1, theMaterials[ind]);
285 Handle(GEOM_Object) anObject =
286 GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns,
287 theLimit, theRemoveWebs, aMaterials,
288 theKeepNonlimitShapes,
289 /*PerformSelfIntersections*/Standard_False);
290 if (!GetOperations()->IsDone() || anObject.IsNull())
291 return aGEOMObject._retn();
293 return GetObject(anObject);
296 //=============================================================================
300 //=============================================================================
301 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartition
302 (GEOM::GEOM_Object_ptr theShape,
303 GEOM::GEOM_Object_ptr thePlane)
305 GEOM::GEOM_Object_var aGEOMObject;
307 //Set a not done flag
308 GetOperations()->SetNotDone();
310 //Get the reference shapes
311 Handle(GEOM_Object) aSh = GetObjectImpl(theShape);
312 Handle(GEOM_Object) aPl = GetObjectImpl(thePlane);
314 if (aSh.IsNull() || aPl.IsNull()) return aGEOMObject._retn();
316 // Make Half Partition
317 Handle(GEOM_Object) anObject = GetOperations()->MakeHalfPartition(aSh, aPl);
318 if (!GetOperations()->IsDone() || anObject.IsNull())
319 return aGEOMObject._retn();
321 return GetObject(anObject);