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 if (theShape == NULL) return aGEOMObject._retn();
69 //Get the reference shape
70 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
71 (theShape->GetStudyID(), theShape->GetEntry());
73 if (aShapeRef.IsNull()) return aGEOMObject._retn();
76 Handle(GEOM_Object) anObject =
77 GetOperations()->MakeFilletAll(aShapeRef, theR);
78 if (!GetOperations()->IsDone() || anObject.IsNull())
79 return aGEOMObject._retn();
81 return GetObject(anObject);
84 //=============================================================================
88 //=============================================================================
89 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdges
90 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
91 const GEOM::ListOfLong& theEdges)
93 GEOM::GEOM_Object_var aGEOMObject;
95 if (theShape == NULL) return aGEOMObject._retn();
97 //Get the reference shape
98 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
99 (theShape->GetStudyID(), theShape->GetEntry());
100 if (aShapeRef.IsNull()) return aGEOMObject._retn();
102 //Get the reference edges
104 int aLen = theEdges.length();
106 for (; ind < aLen; ind++) {
107 anEdges.push_back(theEdges[ind]);
111 Handle(GEOM_Object) anObject =
112 GetOperations()->MakeFilletEdges(aShapeRef, theR, anEdges);
113 if (!GetOperations()->IsDone() || anObject.IsNull())
114 return aGEOMObject._retn();
116 return GetObject(anObject);
119 //=============================================================================
121 * MakeFilletEdges R1 R2
123 //=============================================================================
124 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdgesR1R2
125 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1,
126 CORBA::Double theR2, const GEOM::ListOfLong& theEdges)
128 GEOM::GEOM_Object_var aGEOMObject;
130 if (theShape == NULL) return aGEOMObject._retn();
132 //Get the reference shape
133 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
134 (theShape->GetStudyID(), theShape->GetEntry());
135 if (aShapeRef.IsNull()) return aGEOMObject._retn();
137 //Get the reference edges
139 int aLen = theEdges.length();
141 for (; ind < aLen; ind++) {
142 anEdges.push_back(theEdges[ind]);
146 Handle(GEOM_Object) anObject =
147 GetOperations()->MakeFilletEdgesR1R2(aShapeRef, theR1, theR2, anEdges);
148 if (!GetOperations()->IsDone() || anObject.IsNull())
149 return aGEOMObject._retn();
151 return GetObject(anObject);
154 //=============================================================================
158 //=============================================================================
159 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFaces
160 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
161 const GEOM::ListOfLong& theFaces)
163 GEOM::GEOM_Object_var aGEOMObject;
165 if (theShape == NULL) return aGEOMObject._retn();
167 //Get the reference shape
168 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
169 (theShape->GetStudyID(), theShape->GetEntry());
170 if (aShapeRef.IsNull()) return aGEOMObject._retn();
172 //Get the reference faces
174 int aLen = theFaces.length();
176 for (; ind < aLen; ind++) {
177 aFaces.push_back(theFaces[ind]);
181 Handle(GEOM_Object) anObject =
182 GetOperations()->MakeFilletFaces(aShapeRef, theR, aFaces);
183 if (!GetOperations()->IsDone() || anObject.IsNull())
184 return aGEOMObject._retn();
186 return GetObject(anObject);
189 //=============================================================================
191 * MakeFilletFaces R1 R2
193 //=============================================================================
194 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFacesR1R2
195 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1,
196 CORBA::Double theR2, const GEOM::ListOfLong& theFaces)
198 GEOM::GEOM_Object_var aGEOMObject;
200 if (theShape == NULL) return aGEOMObject._retn();
202 //Get the reference shape
203 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
204 (theShape->GetStudyID(), theShape->GetEntry());
205 if (aShapeRef.IsNull()) return aGEOMObject._retn();
207 //Get the reference faces
209 int aLen = theFaces.length();
211 for (; ind < aLen; ind++) {
212 aFaces.push_back(theFaces[ind]);
216 Handle(GEOM_Object) anObject =
217 GetOperations()->MakeFilletFacesR1R2(aShapeRef, theR1, theR2, aFaces);
218 if (!GetOperations()->IsDone() || anObject.IsNull())
219 return aGEOMObject._retn();
221 return GetObject(anObject);
224 //=============================================================================
228 //=============================================================================
229 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFillet2D
230 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
231 const GEOM::ListOfLong& theVertexes)
233 GEOM::GEOM_Object_var aGEOMObject;
235 if (theShape == NULL) return aGEOMObject._retn();
237 //Get the reference shape
238 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
239 (theShape->GetStudyID(), theShape->GetEntry());
240 if (aShapeRef.IsNull()) return aGEOMObject._retn();
242 //Get the reference vertex
244 int aLen = theVertexes.length();
246 for (; ind < aLen; ind++) {
247 aVertexes.push_back(theVertexes[ind]);
251 Handle(GEOM_Object) anObject =
252 GetOperations()->MakeFillet2D(aShapeRef, theR, aVertexes);
253 if (!GetOperations()->IsDone() || anObject.IsNull())
254 return aGEOMObject._retn();
256 return GetObject(anObject);
259 //=============================================================================
263 //=============================================================================
264 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferAll
265 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD)
267 GEOM::GEOM_Object_var aGEOMObject;
269 if (theShape == NULL) return aGEOMObject._retn();
271 //Get the reference shape
272 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
273 (theShape->GetStudyID(), theShape->GetEntry());
275 if (aShapeRef.IsNull()) return aGEOMObject._retn();
278 Handle(GEOM_Object) anObject =
279 GetOperations()->MakeChamferAll(aShapeRef, theD);
280 if (!GetOperations()->IsDone() || anObject.IsNull())
281 return aGEOMObject._retn();
283 return GetObject(anObject);
286 //=============================================================================
290 //=============================================================================
291 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdge
292 (GEOM::GEOM_Object_ptr theShape,
293 CORBA::Double theD1, CORBA::Double theD2,
294 CORBA::Long theFace1, CORBA::Long theFace2)
296 GEOM::GEOM_Object_var aGEOMObject;
298 if (theShape == NULL) return aGEOMObject._retn();
300 //Get the reference shape
301 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
302 (theShape->GetStudyID(), theShape->GetEntry());
303 if (aShapeRef.IsNull()) return aGEOMObject._retn();
306 Handle(GEOM_Object) anObject =
307 GetOperations()->MakeChamferEdge(aShapeRef, theD1, theD2, theFace1, theFace2);
308 if (!GetOperations()->IsDone() || anObject.IsNull())
309 return aGEOMObject._retn();
311 return GetObject(anObject);
313 //=============================================================================
317 //=============================================================================
318 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgeAD
319 (GEOM::GEOM_Object_ptr theShape,
320 CORBA::Double theD, CORBA::Double theAngle,
321 CORBA::Long theFace1, CORBA::Long theFace2)
323 GEOM::GEOM_Object_var aGEOMObject;
325 if (theShape == NULL) return aGEOMObject._retn();
327 //Get the reference shape
328 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
329 (theShape->GetStudyID(), theShape->GetEntry());
330 if (aShapeRef.IsNull()) return aGEOMObject._retn();
333 Handle(GEOM_Object) anObject =
334 GetOperations()->MakeChamferEdgeAD(aShapeRef, theD, theAngle, theFace1, theFace2);
335 if (!GetOperations()->IsDone() || anObject.IsNull())
336 return aGEOMObject._retn();
338 return GetObject(anObject);
341 //=============================================================================
345 //=============================================================================
346 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFaces
347 (GEOM::GEOM_Object_ptr theShape,
348 CORBA::Double theD1, CORBA::Double theD2,
349 const GEOM::ListOfLong& theFaces)
351 GEOM::GEOM_Object_var aGEOMObject;
353 if (theShape == NULL) return aGEOMObject._retn();
355 //Get the reference shape
356 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
357 (theShape->GetStudyID(), theShape->GetEntry());
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()->MakeChamferFaces(aShapeRef, theD1, theD2, aFaces);
371 if (!GetOperations()->IsDone() || anObject.IsNull())
372 return aGEOMObject._retn();
374 return GetObject(anObject);
376 //=============================================================================
380 //=============================================================================
381 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFacesAD
382 (GEOM::GEOM_Object_ptr theShape,
383 CORBA::Double theD, CORBA::Double theAngle,
384 const GEOM::ListOfLong& theFaces)
386 GEOM::GEOM_Object_var aGEOMObject;
388 if (theShape == NULL) return aGEOMObject._retn();
390 //Get the reference shape
391 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
392 (theShape->GetStudyID(), theShape->GetEntry());
393 if (aShapeRef.IsNull()) return aGEOMObject._retn();
395 //Get the reference faces
397 int aLen = theFaces.length();
399 for (; ind < aLen; ind++) {
400 aFaces.push_back(theFaces[ind]);
404 Handle(GEOM_Object) anObject =
405 GetOperations()->MakeChamferFacesAD(aShapeRef, theD, theAngle, aFaces);
406 if (!GetOperations()->IsDone() || anObject.IsNull())
407 return aGEOMObject._retn();
409 return GetObject(anObject);
412 //=============================================================================
416 //=============================================================================
417 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdges
418 (GEOM::GEOM_Object_ptr theShape,
419 CORBA::Double theD1, CORBA::Double theD2,
420 const GEOM::ListOfLong& theEdges)
422 GEOM::GEOM_Object_var aGEOMObject;
424 if (theShape == NULL) return aGEOMObject._retn();
426 //Get the reference shape
427 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
428 (theShape->GetStudyID(), theShape->GetEntry());
429 if (aShapeRef.IsNull()) return aGEOMObject._retn();
431 //Get the reference edges
433 int aLen = theEdges.length();
435 for (; ind < aLen; ind++) {
436 aEdges.push_back(theEdges[ind]);
440 Handle(GEOM_Object) anObject =
441 GetOperations()->MakeChamferEdges(aShapeRef, theD1, theD2, aEdges);
442 if (!GetOperations()->IsDone() || anObject.IsNull())
443 return aGEOMObject._retn();
445 return GetObject(anObject);
448 //=============================================================================
452 //=============================================================================
453 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgesAD
454 (GEOM::GEOM_Object_ptr theShape,
455 CORBA::Double theD, CORBA::Double theAngle,
456 const GEOM::ListOfLong& theEdges)
458 GEOM::GEOM_Object_var aGEOMObject;
460 if (theShape == NULL) return aGEOMObject._retn();
462 //Get the reference shape
463 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
464 (theShape->GetStudyID(), theShape->GetEntry());
465 if (aShapeRef.IsNull()) return aGEOMObject._retn();
467 //Get the reference edges
469 int aLen = theEdges.length();
471 for (; ind < aLen; ind++) {
472 aEdges.push_back(theEdges[ind]);
476 Handle(GEOM_Object) anObject =
477 GetOperations()->MakeChamferEdgesAD(aShapeRef, theD, theAngle, aEdges);
478 if (!GetOperations()->IsDone() || anObject.IsNull())
479 return aGEOMObject._retn();
481 return GetObject(anObject);
484 //=============================================================================
488 //=============================================================================
489 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeArchimede (GEOM::GEOM_Object_ptr theShape,
490 CORBA::Double theWeight,
491 CORBA::Double theWaterDensity,
492 CORBA::Double theMeshingDeflection)
494 GEOM::GEOM_Object_var aGEOMObject;
496 if (theShape == NULL) return aGEOMObject._retn();
498 //Get the reference shape
499 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
500 (theShape->GetStudyID(), theShape->GetEntry());
501 if (aShapeRef.IsNull()) return aGEOMObject._retn();
503 //Create the Archimede
504 Handle(GEOM_Object) anObject = GetOperations()->MakeArchimede
505 (aShapeRef, theWeight, theWaterDensity, theMeshingDeflection);
506 if (!GetOperations()->IsDone() || anObject.IsNull())
507 return aGEOMObject._retn();
509 return GetObject(anObject);
512 //=============================================================================
516 //=============================================================================
517 CORBA::Long GEOM_ILocalOperations_i::GetSubShapeIndex
518 (GEOM::GEOM_Object_ptr theShape, GEOM::GEOM_Object_ptr theSubShape)
520 if (theShape == NULL || theSubShape == NULL) return -1;
522 //Get the reference shapes
523 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
524 (theShape->GetStudyID(), theShape->GetEntry());
525 Handle(GEOM_Object) aSubShapeRef = GetOperations()->GetEngine()->GetObject
526 (theSubShape->GetStudyID(), theSubShape->GetEntry());
527 if (aShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
529 //Get the unique ID of <theSubShape> inside <theShape>
530 CORBA::Long anID = GetOperations()->GetSubShapeIndex(aShapeRef, aSubShapeRef);
531 if (!GetOperations()->IsDone())