1 // Copyright (C) 2007-2016 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, 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_ILocalOperations_i.hh"
27 #include "utilities.h"
29 #include "Utils_ExceptHandlers.hxx"
31 #include "GEOM_Engine.hxx"
32 #include "GEOM_Object.hxx"
34 //=============================================================================
38 //=============================================================================
39 GEOM_ILocalOperations_i::GEOM_ILocalOperations_i (PortableServer::POA_ptr thePOA,
40 GEOM::GEOM_Gen_ptr theEngine,
41 ::GEOMImpl_ILocalOperations* theImpl)
42 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
44 MESSAGE("GEOM_ILocalOperations_i::GEOM_ILocalOperations_i");
47 //=============================================================================
51 //=============================================================================
52 GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i()
54 MESSAGE("GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i");
58 //=============================================================================
62 //=============================================================================
63 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletAll
64 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR)
66 GEOM::GEOM_Object_var aGEOMObject;
68 //Get the reference shape
69 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
70 if (aShapeRef.IsNull()) return aGEOMObject._retn();
73 HANDLE_NAMESPACE(GEOM_Object) anObject =
74 GetOperations()->MakeFilletAll(aShapeRef, theR);
75 if (!GetOperations()->IsDone() || anObject.IsNull())
76 return aGEOMObject._retn();
78 return GetObject(anObject);
81 //=============================================================================
85 //=============================================================================
86 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdges
87 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
88 const GEOM::ListOfLong& theEdges)
90 GEOM::GEOM_Object_var aGEOMObject;
92 //Get the reference shape
93 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
94 if (aShapeRef.IsNull()) return aGEOMObject._retn();
96 //Get the reference edges
98 int aLen = theEdges.length();
99 std::list<int> anEdges;
100 for (; ind < aLen; ind++) {
101 anEdges.push_back(theEdges[ind]);
105 HANDLE_NAMESPACE(GEOM_Object) anObject =
106 GetOperations()->MakeFilletEdges(aShapeRef, theR, anEdges);
107 if (!GetOperations()->IsDone() || anObject.IsNull())
108 return aGEOMObject._retn();
110 return GetObject(anObject);
113 //=============================================================================
115 * MakeFilletEdges R1 R2
117 //=============================================================================
118 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdgesR1R2
119 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1,
120 CORBA::Double theR2, const GEOM::ListOfLong& theEdges)
122 GEOM::GEOM_Object_var aGEOMObject;
124 //Get the reference shape
125 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
126 if (aShapeRef.IsNull()) return aGEOMObject._retn();
128 //Get the reference edges
130 int aLen = theEdges.length();
131 std::list<int> anEdges;
132 for (; ind < aLen; ind++) {
133 anEdges.push_back(theEdges[ind]);
137 HANDLE_NAMESPACE(GEOM_Object) anObject =
138 GetOperations()->MakeFilletEdgesR1R2(aShapeRef, theR1, theR2, anEdges);
139 if (!GetOperations()->IsDone() || anObject.IsNull())
140 return aGEOMObject._retn();
142 return GetObject(anObject);
145 //=============================================================================
149 //=============================================================================
150 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFaces
151 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
152 const GEOM::ListOfLong& theFaces)
154 GEOM::GEOM_Object_var aGEOMObject;
156 //Get the reference shape
157 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
158 if (aShapeRef.IsNull()) return aGEOMObject._retn();
160 //Get the reference faces
162 int aLen = theFaces.length();
163 std::list<int> aFaces;
164 for (; ind < aLen; ind++) {
165 aFaces.push_back(theFaces[ind]);
169 HANDLE_NAMESPACE(GEOM_Object) anObject =
170 GetOperations()->MakeFilletFaces(aShapeRef, theR, aFaces);
171 if (!GetOperations()->IsDone() || anObject.IsNull())
172 return aGEOMObject._retn();
174 return GetObject(anObject);
177 //=============================================================================
179 * MakeFilletFaces R1 R2
181 //=============================================================================
182 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFacesR1R2
183 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1,
184 CORBA::Double theR2, const GEOM::ListOfLong& theFaces)
186 GEOM::GEOM_Object_var aGEOMObject;
188 //Get the reference shape
189 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
190 if (aShapeRef.IsNull()) return aGEOMObject._retn();
192 //Get the reference faces
194 int aLen = theFaces.length();
195 std::list<int> aFaces;
196 for (; ind < aLen; ind++) {
197 aFaces.push_back(theFaces[ind]);
201 HANDLE_NAMESPACE(GEOM_Object) anObject =
202 GetOperations()->MakeFilletFacesR1R2(aShapeRef, theR1, theR2, aFaces);
203 if (!GetOperations()->IsDone() || anObject.IsNull())
204 return aGEOMObject._retn();
206 return GetObject(anObject);
209 //=============================================================================
213 //=============================================================================
214 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFillet2D
215 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
216 const GEOM::ListOfLong& theVertexes)
218 GEOM::GEOM_Object_var aGEOMObject;
220 //Get the reference shape
221 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
222 if (aShapeRef.IsNull()) return aGEOMObject._retn();
224 //Get the reference vertex
226 int aLen = theVertexes.length();
227 std::list<int> aVertexes;
228 for (; ind < aLen; ind++) {
229 aVertexes.push_back(theVertexes[ind]);
233 HANDLE_NAMESPACE(GEOM_Object) anObject =
234 GetOperations()->MakeFillet2D(aShapeRef, theR, aVertexes);
235 if (!GetOperations()->IsDone() || anObject.IsNull())
236 return aGEOMObject._retn();
238 return GetObject(anObject);
241 //=============================================================================
245 //=============================================================================
246 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFillet1D
247 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
248 const GEOM::ListOfLong& theVertexes,
249 CORBA::Boolean doIgnoreSecantVertices)
251 GEOM::GEOM_Object_var aGEOMObject;
253 //Get the reference shape (wire)
254 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
255 if (aShapeRef.IsNull()) return aGEOMObject._retn();
257 //Get the reference vertex
259 int aLen = theVertexes.length();
260 std::list<int> aVertexes;
261 for (; ind < aLen; ind++) {
262 aVertexes.push_back(theVertexes[ind]);
266 HANDLE_NAMESPACE(GEOM_Object) anObject =
267 GetOperations()->MakeFillet1D(aShapeRef, theR, aVertexes, doIgnoreSecantVertices);
268 if (!GetOperations()->IsDone() || anObject.IsNull())
269 return aGEOMObject._retn();
271 return GetObject(anObject);
274 //=============================================================================
278 //=============================================================================
279 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferAll
280 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD)
282 GEOM::GEOM_Object_var aGEOMObject;
284 //Get the reference shape
285 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
286 if (aShapeRef.IsNull()) return aGEOMObject._retn();
289 HANDLE_NAMESPACE(GEOM_Object) anObject =
290 GetOperations()->MakeChamferAll(aShapeRef, theD);
291 if (!GetOperations()->IsDone() || anObject.IsNull())
292 return aGEOMObject._retn();
294 return GetObject(anObject);
297 //=============================================================================
301 //=============================================================================
302 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdge
303 (GEOM::GEOM_Object_ptr theShape,
304 CORBA::Double theD1, CORBA::Double theD2,
305 CORBA::Long theFace1, CORBA::Long theFace2)
307 GEOM::GEOM_Object_var aGEOMObject;
309 //Get the reference shape
310 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
311 if (aShapeRef.IsNull()) return aGEOMObject._retn();
314 HANDLE_NAMESPACE(GEOM_Object) anObject =
315 GetOperations()->MakeChamferEdge(aShapeRef, theD1, theD2, theFace1, theFace2);
316 if (!GetOperations()->IsDone() || anObject.IsNull())
317 return aGEOMObject._retn();
319 return GetObject(anObject);
321 //=============================================================================
325 //=============================================================================
326 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgeAD
327 (GEOM::GEOM_Object_ptr theShape,
328 CORBA::Double theD, CORBA::Double theAngle,
329 CORBA::Long theFace1, CORBA::Long theFace2)
331 GEOM::GEOM_Object_var aGEOMObject;
333 //Get the reference shape
334 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
335 if (aShapeRef.IsNull()) return aGEOMObject._retn();
338 HANDLE_NAMESPACE(GEOM_Object) anObject =
339 GetOperations()->MakeChamferEdgeAD(aShapeRef, theD, theAngle, theFace1, theFace2);
340 if (!GetOperations()->IsDone() || anObject.IsNull())
341 return aGEOMObject._retn();
343 return GetObject(anObject);
346 //=============================================================================
350 //=============================================================================
351 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFaces
352 (GEOM::GEOM_Object_ptr theShape,
353 CORBA::Double theD1, CORBA::Double theD2,
354 const GEOM::ListOfLong& theFaces)
356 GEOM::GEOM_Object_var aGEOMObject;
358 //Get the reference shape
359 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
360 if (aShapeRef.IsNull()) return aGEOMObject._retn();
362 //Get the reference faces
364 int aLen = theFaces.length();
365 std::list<int> aFaces;
366 for (; ind < aLen; ind++) {
367 aFaces.push_back(theFaces[ind]);
371 HANDLE_NAMESPACE(GEOM_Object) anObject =
372 GetOperations()->MakeChamferFaces(aShapeRef, theD1, theD2, aFaces);
373 if (!GetOperations()->IsDone() || anObject.IsNull())
374 return aGEOMObject._retn();
376 return GetObject(anObject);
378 //=============================================================================
382 //=============================================================================
383 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFacesAD
384 (GEOM::GEOM_Object_ptr theShape,
385 CORBA::Double theD, CORBA::Double theAngle,
386 const GEOM::ListOfLong& theFaces)
388 GEOM::GEOM_Object_var aGEOMObject;
390 //Get the reference shape
391 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
392 if (aShapeRef.IsNull()) return aGEOMObject._retn();
394 //Get the reference faces
396 int aLen = theFaces.length();
397 std::list<int> aFaces;
398 for (; ind < aLen; ind++) {
399 aFaces.push_back(theFaces[ind]);
403 HANDLE_NAMESPACE(GEOM_Object) anObject =
404 GetOperations()->MakeChamferFacesAD(aShapeRef, theD, theAngle, aFaces);
405 if (!GetOperations()->IsDone() || anObject.IsNull())
406 return aGEOMObject._retn();
408 return GetObject(anObject);
411 //=============================================================================
415 //=============================================================================
416 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdges
417 (GEOM::GEOM_Object_ptr theShape,
418 CORBA::Double theD1, CORBA::Double theD2,
419 const GEOM::ListOfLong& theEdges)
421 GEOM::GEOM_Object_var aGEOMObject;
423 //Get the reference shape
424 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
425 if (aShapeRef.IsNull()) return aGEOMObject._retn();
427 //Get the reference edges
429 int aLen = theEdges.length();
430 std::list<int> aEdges;
431 for (; ind < aLen; ind++) {
432 aEdges.push_back(theEdges[ind]);
436 HANDLE_NAMESPACE(GEOM_Object) anObject =
437 GetOperations()->MakeChamferEdges(aShapeRef, theD1, theD2, aEdges);
438 if (!GetOperations()->IsDone() || anObject.IsNull())
439 return aGEOMObject._retn();
441 return GetObject(anObject);
444 //=============================================================================
448 //=============================================================================
449 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgesAD
450 (GEOM::GEOM_Object_ptr theShape,
451 CORBA::Double theD, CORBA::Double theAngle,
452 const GEOM::ListOfLong& theEdges)
454 GEOM::GEOM_Object_var aGEOMObject;
456 //Get the reference shape
457 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
458 if (aShapeRef.IsNull()) return aGEOMObject._retn();
460 //Get the reference edges
462 int aLen = theEdges.length();
463 std::list<int> aEdges;
464 for (; ind < aLen; ind++) {
465 aEdges.push_back(theEdges[ind]);
469 HANDLE_NAMESPACE(GEOM_Object) anObject =
470 GetOperations()->MakeChamferEdgesAD(aShapeRef, theD, theAngle, aEdges);
471 if (!GetOperations()->IsDone() || anObject.IsNull())
472 return aGEOMObject._retn();
474 return GetObject(anObject);
477 //=============================================================================
481 //=============================================================================
482 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeArchimede (GEOM::GEOM_Object_ptr theShape,
483 CORBA::Double theWeight,
484 CORBA::Double theWaterDensity,
485 CORBA::Double theMeshingDeflection)
487 GEOM::GEOM_Object_var aGEOMObject;
489 //Get the reference shape
490 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
491 if (aShapeRef.IsNull()) return aGEOMObject._retn();
493 //Create the Archimede
494 HANDLE_NAMESPACE(GEOM_Object) anObject = GetOperations()->MakeArchimede
495 (aShapeRef, theWeight, theWaterDensity, theMeshingDeflection);
496 if (!GetOperations()->IsDone() || anObject.IsNull())
497 return aGEOMObject._retn();
499 return GetObject(anObject);
502 //=============================================================================
506 //=============================================================================
507 CORBA::Long GEOM_ILocalOperations_i::GetSubShapeIndex
508 (GEOM::GEOM_Object_ptr theShape, GEOM::GEOM_Object_ptr theSubShape)
510 //Get the reference shapes
511 HANDLE_NAMESPACE(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
512 HANDLE_NAMESPACE(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
513 if (aShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
515 //Get the unique ID of <theSubShape> inside <theShape>
516 CORBA::Long anID = GetOperations()->GetSubShapeIndex(aShapeRef, aSubShapeRef);
517 if (!GetOperations()->IsDone())