1 // Copyright (C) 2007-2008 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
22 #include <Standard_Stream.hxx>
24 #include "GEOM_ILocalOperations_i.hh"
26 #include "utilities.h"
28 #include "Utils_ExceptHandlers.hxx"
30 #include "GEOM_Engine.hxx"
31 #include "GEOM_Object.hxx"
33 //=============================================================================
37 //=============================================================================
38 GEOM_ILocalOperations_i::GEOM_ILocalOperations_i (PortableServer::POA_ptr thePOA,
39 GEOM::GEOM_Gen_ptr theEngine,
40 ::GEOMImpl_ILocalOperations* theImpl)
41 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
43 MESSAGE("GEOM_ILocalOperations_i::GEOM_ILocalOperations_i");
46 //=============================================================================
50 //=============================================================================
51 GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i()
53 MESSAGE("GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i");
57 //=============================================================================
61 //=============================================================================
62 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletAll
63 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR)
65 GEOM::GEOM_Object_var aGEOMObject;
67 //Get the reference shape
68 Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
69 if (aShapeRef.IsNull()) return aGEOMObject._retn();
72 Handle(GEOM_Object) anObject =
73 GetOperations()->MakeFilletAll(aShapeRef, theR);
74 if (!GetOperations()->IsDone() || anObject.IsNull())
75 return aGEOMObject._retn();
77 return GetObject(anObject);
80 //=============================================================================
84 //=============================================================================
85 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdges
86 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
87 const GEOM::ListOfLong& theEdges)
89 GEOM::GEOM_Object_var aGEOMObject;
91 //Get the reference shape
92 Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
93 if (aShapeRef.IsNull()) return aGEOMObject._retn();
95 //Get the reference edges
97 int aLen = theEdges.length();
99 for (; ind < aLen; ind++) {
100 anEdges.push_back(theEdges[ind]);
104 Handle(GEOM_Object) anObject =
105 GetOperations()->MakeFilletEdges(aShapeRef, theR, anEdges);
106 if (!GetOperations()->IsDone() || anObject.IsNull())
107 return aGEOMObject._retn();
109 return GetObject(anObject);
112 //=============================================================================
114 * MakeFilletEdges R1 R2
116 //=============================================================================
117 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdgesR1R2
118 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1,
119 CORBA::Double theR2, const GEOM::ListOfLong& theEdges)
121 GEOM::GEOM_Object_var aGEOMObject;
123 //Get the reference shape
124 Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
125 if (aShapeRef.IsNull()) return aGEOMObject._retn();
127 //Get the reference edges
129 int aLen = theEdges.length();
131 for (; ind < aLen; ind++) {
132 anEdges.push_back(theEdges[ind]);
136 Handle(GEOM_Object) anObject =
137 GetOperations()->MakeFilletEdgesR1R2(aShapeRef, theR1, theR2, anEdges);
138 if (!GetOperations()->IsDone() || anObject.IsNull())
139 return aGEOMObject._retn();
141 return GetObject(anObject);
144 //=============================================================================
148 //=============================================================================
149 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFaces
150 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
151 const GEOM::ListOfLong& theFaces)
153 GEOM::GEOM_Object_var aGEOMObject;
155 //Get the reference shape
156 Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
157 if (aShapeRef.IsNull()) return aGEOMObject._retn();
159 //Get the reference faces
161 int aLen = theFaces.length();
163 for (; ind < aLen; ind++) {
164 aFaces.push_back(theFaces[ind]);
168 Handle(GEOM_Object) anObject =
169 GetOperations()->MakeFilletFaces(aShapeRef, theR, aFaces);
170 if (!GetOperations()->IsDone() || anObject.IsNull())
171 return aGEOMObject._retn();
173 return GetObject(anObject);
176 //=============================================================================
178 * MakeFilletFaces R1 R2
180 //=============================================================================
181 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFacesR1R2
182 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1,
183 CORBA::Double theR2, const GEOM::ListOfLong& theFaces)
185 GEOM::GEOM_Object_var aGEOMObject;
187 //Get the reference shape
188 Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
189 if (aShapeRef.IsNull()) return aGEOMObject._retn();
191 //Get the reference faces
193 int aLen = theFaces.length();
195 for (; ind < aLen; ind++) {
196 aFaces.push_back(theFaces[ind]);
200 Handle(GEOM_Object) anObject =
201 GetOperations()->MakeFilletFacesR1R2(aShapeRef, theR1, theR2, aFaces);
202 if (!GetOperations()->IsDone() || anObject.IsNull())
203 return aGEOMObject._retn();
205 return GetObject(anObject);
208 //=============================================================================
212 //=============================================================================
213 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFillet2D
214 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
215 const GEOM::ListOfLong& theVertexes)
217 GEOM::GEOM_Object_var aGEOMObject;
219 //Get the reference shape
220 Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
221 if (aShapeRef.IsNull()) return aGEOMObject._retn();
223 //Get the reference vertex
225 int aLen = theVertexes.length();
227 for (; ind < aLen; ind++) {
228 aVertexes.push_back(theVertexes[ind]);
232 Handle(GEOM_Object) anObject =
233 GetOperations()->MakeFillet2D(aShapeRef, theR, aVertexes);
234 if (!GetOperations()->IsDone() || anObject.IsNull())
235 return aGEOMObject._retn();
237 return GetObject(anObject);
240 //=============================================================================
244 //=============================================================================
245 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferAll
246 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD)
248 GEOM::GEOM_Object_var aGEOMObject;
250 //Get the reference shape
251 Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
252 if (aShapeRef.IsNull()) return aGEOMObject._retn();
255 Handle(GEOM_Object) anObject =
256 GetOperations()->MakeChamferAll(aShapeRef, theD);
257 if (!GetOperations()->IsDone() || anObject.IsNull())
258 return aGEOMObject._retn();
260 return GetObject(anObject);
263 //=============================================================================
267 //=============================================================================
268 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdge
269 (GEOM::GEOM_Object_ptr theShape,
270 CORBA::Double theD1, CORBA::Double theD2,
271 CORBA::Long theFace1, CORBA::Long theFace2)
273 GEOM::GEOM_Object_var aGEOMObject;
275 //Get the reference shape
276 Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
277 if (aShapeRef.IsNull()) return aGEOMObject._retn();
280 Handle(GEOM_Object) anObject =
281 GetOperations()->MakeChamferEdge(aShapeRef, theD1, theD2, theFace1, theFace2);
282 if (!GetOperations()->IsDone() || anObject.IsNull())
283 return aGEOMObject._retn();
285 return GetObject(anObject);
287 //=============================================================================
291 //=============================================================================
292 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgeAD
293 (GEOM::GEOM_Object_ptr theShape,
294 CORBA::Double theD, CORBA::Double theAngle,
295 CORBA::Long theFace1, CORBA::Long theFace2)
297 GEOM::GEOM_Object_var aGEOMObject;
299 //Get the reference shape
300 Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
301 if (aShapeRef.IsNull()) return aGEOMObject._retn();
304 Handle(GEOM_Object) anObject =
305 GetOperations()->MakeChamferEdgeAD(aShapeRef, theD, theAngle, theFace1, theFace2);
306 if (!GetOperations()->IsDone() || anObject.IsNull())
307 return aGEOMObject._retn();
309 return GetObject(anObject);
312 //=============================================================================
316 //=============================================================================
317 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFaces
318 (GEOM::GEOM_Object_ptr theShape,
319 CORBA::Double theD1, CORBA::Double theD2,
320 const GEOM::ListOfLong& theFaces)
322 GEOM::GEOM_Object_var aGEOMObject;
324 //Get the reference shape
325 Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
326 if (aShapeRef.IsNull()) return aGEOMObject._retn();
328 //Get the reference faces
330 int aLen = theFaces.length();
332 for (; ind < aLen; ind++) {
333 aFaces.push_back(theFaces[ind]);
337 Handle(GEOM_Object) anObject =
338 GetOperations()->MakeChamferFaces(aShapeRef, theD1, theD2, aFaces);
339 if (!GetOperations()->IsDone() || anObject.IsNull())
340 return aGEOMObject._retn();
342 return GetObject(anObject);
344 //=============================================================================
348 //=============================================================================
349 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFacesAD
350 (GEOM::GEOM_Object_ptr theShape,
351 CORBA::Double theD, CORBA::Double theAngle,
352 const GEOM::ListOfLong& theFaces)
354 GEOM::GEOM_Object_var aGEOMObject;
356 //Get the reference shape
357 Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
358 if (aShapeRef.IsNull()) return aGEOMObject._retn();
360 //Get the reference faces
362 int aLen = theFaces.length();
364 for (; ind < aLen; ind++) {
365 aFaces.push_back(theFaces[ind]);
369 Handle(GEOM_Object) anObject =
370 GetOperations()->MakeChamferFacesAD(aShapeRef, theD, theAngle, aFaces);
371 if (!GetOperations()->IsDone() || anObject.IsNull())
372 return aGEOMObject._retn();
374 return GetObject(anObject);
377 //=============================================================================
381 //=============================================================================
382 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdges
383 (GEOM::GEOM_Object_ptr theShape,
384 CORBA::Double theD1, CORBA::Double theD2,
385 const GEOM::ListOfLong& theEdges)
387 GEOM::GEOM_Object_var aGEOMObject;
389 //Get the reference shape
390 Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
391 if (aShapeRef.IsNull()) return aGEOMObject._retn();
393 //Get the reference edges
395 int aLen = theEdges.length();
397 for (; ind < aLen; ind++) {
398 aEdges.push_back(theEdges[ind]);
402 Handle(GEOM_Object) anObject =
403 GetOperations()->MakeChamferEdges(aShapeRef, theD1, theD2, aEdges);
404 if (!GetOperations()->IsDone() || anObject.IsNull())
405 return aGEOMObject._retn();
407 return GetObject(anObject);
410 //=============================================================================
414 //=============================================================================
415 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgesAD
416 (GEOM::GEOM_Object_ptr theShape,
417 CORBA::Double theD, CORBA::Double theAngle,
418 const GEOM::ListOfLong& theEdges)
420 GEOM::GEOM_Object_var aGEOMObject;
422 //Get the reference shape
423 Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
424 if (aShapeRef.IsNull()) return aGEOMObject._retn();
426 //Get the reference edges
428 int aLen = theEdges.length();
430 for (; ind < aLen; ind++) {
431 aEdges.push_back(theEdges[ind]);
435 Handle(GEOM_Object) anObject =
436 GetOperations()->MakeChamferEdgesAD(aShapeRef, theD, theAngle, aEdges);
437 if (!GetOperations()->IsDone() || anObject.IsNull())
438 return aGEOMObject._retn();
440 return GetObject(anObject);
443 //=============================================================================
447 //=============================================================================
448 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeArchimede (GEOM::GEOM_Object_ptr theShape,
449 CORBA::Double theWeight,
450 CORBA::Double theWaterDensity,
451 CORBA::Double theMeshingDeflection)
453 GEOM::GEOM_Object_var aGEOMObject;
455 //Get the reference shape
456 Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
457 if (aShapeRef.IsNull()) return aGEOMObject._retn();
459 //Create the Archimede
460 Handle(GEOM_Object) anObject = GetOperations()->MakeArchimede
461 (aShapeRef, theWeight, theWaterDensity, theMeshingDeflection);
462 if (!GetOperations()->IsDone() || anObject.IsNull())
463 return aGEOMObject._retn();
465 return GetObject(anObject);
468 //=============================================================================
472 //=============================================================================
473 CORBA::Long GEOM_ILocalOperations_i::GetSubShapeIndex
474 (GEOM::GEOM_Object_ptr theShape, GEOM::GEOM_Object_ptr theSubShape)
476 //Get the reference shapes
477 Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
478 Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
479 if (aShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
481 //Get the unique ID of <theSubShape> inside <theShape>
482 CORBA::Long anID = GetOperations()->GetSubShapeIndex(aShapeRef, aSubShapeRef);
483 if (!GetOperations()->IsDone())