1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <Standard_Stream.hxx>
22 #include "GEOM_ILocalOperations_i.hh"
24 #include "utilities.h"
26 #include "Utils_ExceptHandlers.hxx"
28 #include "GEOM_Engine.hxx"
29 #include "GEOM_Object.hxx"
31 //=============================================================================
35 //=============================================================================
36 GEOM_ILocalOperations_i::GEOM_ILocalOperations_i (PortableServer::POA_ptr thePOA,
37 GEOM::GEOM_Gen_ptr theEngine,
38 ::GEOMImpl_ILocalOperations* theImpl)
39 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
41 MESSAGE("GEOM_ILocalOperations_i::GEOM_ILocalOperations_i");
44 //=============================================================================
48 //=============================================================================
49 GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i()
51 MESSAGE("GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i");
55 //=============================================================================
59 //=============================================================================
60 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletAll
61 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR)
63 GEOM::GEOM_Object_var aGEOMObject;
65 if (theShape == NULL) return aGEOMObject._retn();
67 //Get the reference shape
68 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
69 (theShape->GetStudyID(), theShape->GetEntry());
71 if (aShapeRef.IsNull()) return aGEOMObject._retn();
74 Handle(GEOM_Object) anObject =
75 GetOperations()->MakeFilletAll(aShapeRef, theR);
76 if (!GetOperations()->IsDone() || anObject.IsNull())
77 return aGEOMObject._retn();
79 return GetObject(anObject);
82 //=============================================================================
86 //=============================================================================
87 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdges
88 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
89 const GEOM::ListOfLong& theEdges)
91 GEOM::GEOM_Object_var aGEOMObject;
93 if (theShape == NULL) return aGEOMObject._retn();
95 //Get the reference shape
96 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
97 (theShape->GetStudyID(), theShape->GetEntry());
98 if (aShapeRef.IsNull()) return aGEOMObject._retn();
100 //Get the reference edges
102 int aLen = theEdges.length();
104 for (; ind < aLen; ind++) {
105 anEdges.push_back(theEdges[ind]);
109 Handle(GEOM_Object) anObject =
110 GetOperations()->MakeFilletEdges(aShapeRef, theR, anEdges);
111 if (!GetOperations()->IsDone() || anObject.IsNull())
112 return aGEOMObject._retn();
114 return GetObject(anObject);
117 //=============================================================================
119 * MakeFilletEdges R1 R2
121 //=============================================================================
122 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdgesR1R2
123 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1,
124 CORBA::Double theR2, const GEOM::ListOfLong& theEdges)
126 GEOM::GEOM_Object_var aGEOMObject;
128 if (theShape == NULL) return aGEOMObject._retn();
130 //Get the reference shape
131 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
132 (theShape->GetStudyID(), theShape->GetEntry());
133 if (aShapeRef.IsNull()) return aGEOMObject._retn();
135 //Get the reference edges
137 int aLen = theEdges.length();
139 for (; ind < aLen; ind++) {
140 anEdges.push_back(theEdges[ind]);
144 Handle(GEOM_Object) anObject =
145 GetOperations()->MakeFilletEdgesR1R2(aShapeRef, theR1, theR2, anEdges);
146 if (!GetOperations()->IsDone() || anObject.IsNull())
147 return aGEOMObject._retn();
149 return GetObject(anObject);
152 //=============================================================================
156 //=============================================================================
157 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFaces
158 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
159 const GEOM::ListOfLong& theFaces)
161 GEOM::GEOM_Object_var aGEOMObject;
163 if (theShape == NULL) return aGEOMObject._retn();
165 //Get the reference shape
166 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
167 (theShape->GetStudyID(), theShape->GetEntry());
168 if (aShapeRef.IsNull()) return aGEOMObject._retn();
170 //Get the reference faces
172 int aLen = theFaces.length();
174 for (; ind < aLen; ind++) {
175 aFaces.push_back(theFaces[ind]);
179 Handle(GEOM_Object) anObject =
180 GetOperations()->MakeFilletFaces(aShapeRef, theR, aFaces);
181 if (!GetOperations()->IsDone() || anObject.IsNull())
182 return aGEOMObject._retn();
184 return GetObject(anObject);
187 //=============================================================================
189 * MakeFilletFaces R1 R2
191 //=============================================================================
192 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFacesR1R2
193 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1,
194 CORBA::Double theR2, const GEOM::ListOfLong& theFaces)
196 GEOM::GEOM_Object_var aGEOMObject;
198 if (theShape == NULL) return aGEOMObject._retn();
200 //Get the reference shape
201 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
202 (theShape->GetStudyID(), theShape->GetEntry());
203 if (aShapeRef.IsNull()) return aGEOMObject._retn();
205 //Get the reference faces
207 int aLen = theFaces.length();
209 for (; ind < aLen; ind++) {
210 aFaces.push_back(theFaces[ind]);
214 Handle(GEOM_Object) anObject =
215 GetOperations()->MakeFilletFacesR1R2(aShapeRef, theR1, theR2, aFaces);
216 if (!GetOperations()->IsDone() || anObject.IsNull())
217 return aGEOMObject._retn();
219 return GetObject(anObject);
222 //=============================================================================
226 //=============================================================================
227 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferAll
228 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD)
230 GEOM::GEOM_Object_var aGEOMObject;
232 if (theShape == NULL) return aGEOMObject._retn();
234 //Get the reference shape
235 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
236 (theShape->GetStudyID(), theShape->GetEntry());
238 if (aShapeRef.IsNull()) return aGEOMObject._retn();
241 Handle(GEOM_Object) anObject =
242 GetOperations()->MakeChamferAll(aShapeRef, theD);
243 if (!GetOperations()->IsDone() || anObject.IsNull())
244 return aGEOMObject._retn();
246 return GetObject(anObject);
249 //=============================================================================
253 //=============================================================================
254 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdge
255 (GEOM::GEOM_Object_ptr theShape,
256 CORBA::Double theD1, CORBA::Double theD2,
257 CORBA::Long theFace1, CORBA::Long theFace2)
259 GEOM::GEOM_Object_var aGEOMObject;
261 if (theShape == NULL) return aGEOMObject._retn();
263 //Get the reference shape
264 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
265 (theShape->GetStudyID(), theShape->GetEntry());
266 if (aShapeRef.IsNull()) return aGEOMObject._retn();
269 Handle(GEOM_Object) anObject =
270 GetOperations()->MakeChamferEdge(aShapeRef, theD1, theD2, theFace1, theFace2);
271 if (!GetOperations()->IsDone() || anObject.IsNull())
272 return aGEOMObject._retn();
274 return GetObject(anObject);
276 //=============================================================================
280 //=============================================================================
281 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgeAD
282 (GEOM::GEOM_Object_ptr theShape,
283 CORBA::Double theD, CORBA::Double theAngle,
284 CORBA::Long theFace1, CORBA::Long theFace2)
286 GEOM::GEOM_Object_var aGEOMObject;
288 if (theShape == NULL) return aGEOMObject._retn();
290 //Get the reference shape
291 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
292 (theShape->GetStudyID(), theShape->GetEntry());
293 if (aShapeRef.IsNull()) return aGEOMObject._retn();
296 Handle(GEOM_Object) anObject =
297 GetOperations()->MakeChamferEdgeAD(aShapeRef, theD, theAngle, theFace1, theFace2);
298 if (!GetOperations()->IsDone() || anObject.IsNull())
299 return aGEOMObject._retn();
301 return GetObject(anObject);
304 //=============================================================================
308 //=============================================================================
309 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFaces
310 (GEOM::GEOM_Object_ptr theShape,
311 CORBA::Double theD1, CORBA::Double theD2,
312 const GEOM::ListOfLong& theFaces)
314 GEOM::GEOM_Object_var aGEOMObject;
316 if (theShape == NULL) return aGEOMObject._retn();
318 //Get the reference shape
319 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
320 (theShape->GetStudyID(), theShape->GetEntry());
321 if (aShapeRef.IsNull()) return aGEOMObject._retn();
323 //Get the reference faces
325 int aLen = theFaces.length();
327 for (; ind < aLen; ind++) {
328 aFaces.push_back(theFaces[ind]);
332 Handle(GEOM_Object) anObject =
333 GetOperations()->MakeChamferFaces(aShapeRef, theD1, theD2, aFaces);
334 if (!GetOperations()->IsDone() || anObject.IsNull())
335 return aGEOMObject._retn();
337 return GetObject(anObject);
339 //=============================================================================
343 //=============================================================================
344 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFacesAD
345 (GEOM::GEOM_Object_ptr theShape,
346 CORBA::Double theD, CORBA::Double theAngle,
347 const GEOM::ListOfLong& theFaces)
349 GEOM::GEOM_Object_var aGEOMObject;
351 if (theShape == NULL) return aGEOMObject._retn();
353 //Get the reference shape
354 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
355 (theShape->GetStudyID(), theShape->GetEntry());
356 if (aShapeRef.IsNull()) return aGEOMObject._retn();
358 //Get the reference faces
360 int aLen = theFaces.length();
362 for (; ind < aLen; ind++) {
363 aFaces.push_back(theFaces[ind]);
367 Handle(GEOM_Object) anObject =
368 GetOperations()->MakeChamferFacesAD(aShapeRef, theD, theAngle, aFaces);
369 if (!GetOperations()->IsDone() || anObject.IsNull())
370 return aGEOMObject._retn();
372 return GetObject(anObject);
375 //=============================================================================
379 //=============================================================================
380 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdges
381 (GEOM::GEOM_Object_ptr theShape,
382 CORBA::Double theD1, CORBA::Double theD2,
383 const GEOM::ListOfLong& theEdges)
385 GEOM::GEOM_Object_var aGEOMObject;
387 if (theShape == NULL) return aGEOMObject._retn();
389 //Get the reference shape
390 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
391 (theShape->GetStudyID(), theShape->GetEntry());
392 if (aShapeRef.IsNull()) return aGEOMObject._retn();
394 //Get the reference edges
396 int aLen = theEdges.length();
398 for (; ind < aLen; ind++) {
399 aEdges.push_back(theEdges[ind]);
403 Handle(GEOM_Object) anObject =
404 GetOperations()->MakeChamferEdges(aShapeRef, theD1, theD2, aEdges);
405 if (!GetOperations()->IsDone() || anObject.IsNull())
406 return aGEOMObject._retn();
408 return GetObject(anObject);
411 //=============================================================================
415 //=============================================================================
416 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgesAD
417 (GEOM::GEOM_Object_ptr theShape,
418 CORBA::Double theD, CORBA::Double theAngle,
419 const GEOM::ListOfLong& theEdges)
421 GEOM::GEOM_Object_var aGEOMObject;
423 if (theShape == NULL) return aGEOMObject._retn();
425 //Get the reference shape
426 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
427 (theShape->GetStudyID(), theShape->GetEntry());
428 if (aShapeRef.IsNull()) return aGEOMObject._retn();
430 //Get the reference edges
432 int aLen = theEdges.length();
434 for (; ind < aLen; ind++) {
435 aEdges.push_back(theEdges[ind]);
439 Handle(GEOM_Object) anObject =
440 GetOperations()->MakeChamferEdgesAD(aShapeRef, theD, theAngle, aEdges);
441 if (!GetOperations()->IsDone() || anObject.IsNull())
442 return aGEOMObject._retn();
444 return GetObject(anObject);
447 //=============================================================================
451 //=============================================================================
452 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeArchimede (GEOM::GEOM_Object_ptr theShape,
453 CORBA::Double theWeight,
454 CORBA::Double theWaterDensity,
455 CORBA::Double theMeshingDeflection)
457 GEOM::GEOM_Object_var aGEOMObject;
459 if (theShape == NULL) return aGEOMObject._retn();
461 //Get the reference shape
462 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
463 (theShape->GetStudyID(), theShape->GetEntry());
464 if (aShapeRef.IsNull()) return aGEOMObject._retn();
466 //Create the Archimede
467 Handle(GEOM_Object) anObject = GetOperations()->MakeArchimede
468 (aShapeRef, theWeight, theWaterDensity, theMeshingDeflection);
469 if (!GetOperations()->IsDone() || anObject.IsNull())
470 return aGEOMObject._retn();
472 return GetObject(anObject);
475 //=============================================================================
479 //=============================================================================
480 CORBA::Long GEOM_ILocalOperations_i::GetSubShapeIndex
481 (GEOM::GEOM_Object_ptr theShape, GEOM::GEOM_Object_ptr theSubShape)
483 if (theShape == NULL || theSubShape == NULL) return -1;
485 //Get the reference shapes
486 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
487 (theShape->GetStudyID(), theShape->GetEntry());
488 Handle(GEOM_Object) aSubShapeRef = GetOperations()->GetEngine()->GetObject
489 (theSubShape->GetStudyID(), theSubShape->GetEntry());
490 if (aShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
492 //Get the unique ID of <theSubShape> inside <theShape>
493 CORBA::Long anID = GetOperations()->GetSubShapeIndex(aShapeRef, aSubShapeRef);
494 if (!GetOperations()->IsDone())