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_IBasicOperations_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_IBasicOperations_i::GEOM_IBasicOperations_i (PortableServer::POA_ptr thePOA,
39 GEOM::GEOM_Gen_ptr theEngine,
40 ::GEOMImpl_IBasicOperations* theImpl)
41 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
43 MESSAGE("GEOM_IBasicOperations_i::GEOM_IBasicOperations_i");
46 //=============================================================================
50 //=============================================================================
51 GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i()
53 MESSAGE("GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i");
57 //=============================================================================
61 //=============================================================================
62 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointXYZ
63 (CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ)
65 GEOM::GEOM_Object_var aGEOMObject;
68 GetOperations()->SetNotDone();
71 Handle(GEOM_Object) anObject = GetOperations()->MakePointXYZ(theX, theY, theZ);
72 if (!GetOperations()->IsDone() || anObject.IsNull())
73 return aGEOMObject._retn();
75 return GetObject(anObject);
78 //=============================================================================
80 * MakePointWithReference
82 //=============================================================================
83 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointWithReference
84 (GEOM::GEOM_Object_ptr theReference, CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ)
86 GEOM::GEOM_Object_var aGEOMObject;
89 GetOperations()->SetNotDone();
91 //Get the reference point
92 Handle(GEOM_Object) aReference = GetObjectImpl(theReference);
93 if (aReference.IsNull()) return aGEOMObject._retn();
96 Handle(GEOM_Object) anObject =
97 GetOperations()->MakePointWithReference(aReference, theX, theY, theZ);
98 if (!GetOperations()->IsDone() || anObject.IsNull())
99 return aGEOMObject._retn();
101 return GetObject(anObject);
104 //=============================================================================
106 * MakePointOnLinesIntersection
108 //=============================================================================
109 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnLinesIntersection
110 (GEOM::GEOM_Object_ptr theLine1, GEOM::GEOM_Object_ptr theLine2)
112 GEOM::GEOM_Object_var aGEOMObject;
114 //Set a not done flag
115 GetOperations()->SetNotDone();
117 //Get the reference Lines
118 Handle(GEOM_Object) aRef1 = GetObjectImpl(theLine1);
119 Handle(GEOM_Object) aRef2 = GetObjectImpl(theLine2);
120 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
123 Handle(GEOM_Object) anObject =
124 GetOperations()->MakePointOnLinesIntersection(aRef1, aRef2);
125 if (!GetOperations()->IsDone() || anObject.IsNull())
126 return aGEOMObject._retn();
128 return GetObject(anObject);
131 //=============================================================================
135 //=============================================================================
136 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
137 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
139 GEOM::GEOM_Object_var aGEOMObject;
141 //Set a not done flag
142 GetOperations()->SetNotDone();
144 //Get the reference curve
145 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
146 if (aReference.IsNull()) return aGEOMObject._retn();
149 Handle(GEOM_Object) anObject =
150 GetOperations()->MakePointOnCurve(aReference, theParameter);
151 if (!GetOperations()->IsDone() || anObject.IsNull())
152 return aGEOMObject._retn();
154 return GetObject(anObject);
157 //=============================================================================
159 * MakePointOnCurveByCoord
161 //=============================================================================
162 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByCoord
163 (GEOM::GEOM_Object_ptr theCurve,
164 CORBA::Double theXParameter,
165 CORBA::Double theYParameter,
166 CORBA::Double theZParameter)
168 GEOM::GEOM_Object_var aGEOMObject;
170 //Set a not done flag
171 GetOperations()->SetNotDone();
173 //Get the reference curve
174 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
175 if (aReference.IsNull()) return aGEOMObject._retn();
178 Handle(GEOM_Object) anObject =
179 GetOperations()->MakePointOnCurveByCoord(aReference, theXParameter,
180 theYParameter, theZParameter);
181 if (!GetOperations()->IsDone() || anObject.IsNull())
182 return aGEOMObject._retn();
184 return GetObject(anObject);
187 //=============================================================================
191 //=============================================================================
192 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurface
193 (GEOM::GEOM_Object_ptr theSurface,
194 CORBA::Double theUParameter,
195 CORBA::Double theVParameter)
197 GEOM::GEOM_Object_var aGEOMObject;
199 //Set a not done flag
200 GetOperations()->SetNotDone();
202 //Get the reference surface
203 Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
204 if (aReference.IsNull()) return aGEOMObject._retn();
207 Handle(GEOM_Object) anObject =
208 GetOperations()->MakePointOnSurface(aReference, theUParameter, theVParameter);
209 if (!GetOperations()->IsDone() || anObject.IsNull())
210 return aGEOMObject._retn();
212 return GetObject(anObject);
215 //=============================================================================
217 * MakePointOnSurfaceByCoord
219 //=============================================================================
220 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurfaceByCoord
221 (GEOM::GEOM_Object_ptr theSurface,
222 CORBA::Double theXParameter,
223 CORBA::Double theYParameter,
224 CORBA::Double theZParameter)
226 GEOM::GEOM_Object_var aGEOMObject;
228 //Set a not done flag
229 GetOperations()->SetNotDone();
231 //Get the reference surface
232 Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
233 if (aReference.IsNull()) return aGEOMObject._retn();
236 Handle(GEOM_Object) anObject =
237 GetOperations()->MakePointOnSurfaceByCoord(aReference, theXParameter,
238 theYParameter, theZParameter);
239 if (!GetOperations()->IsDone() || anObject.IsNull())
240 return aGEOMObject._retn();
242 return GetObject(anObject);
246 //=============================================================================
250 //=============================================================================
251 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
252 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
254 GEOM::GEOM_Object_var aGEOMObject;
256 //Set a not done flag
257 GetOperations()->SetNotDone();
259 //Get the reference curve
260 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
261 if (aReference.IsNull()) return aGEOMObject._retn();
264 Handle(GEOM_Object) anObject =
265 GetOperations()->MakeTangentOnCurve(aReference, theParameter);
266 if (!GetOperations()->IsDone() || anObject.IsNull())
267 return aGEOMObject._retn();
269 return GetObject(anObject);
272 //=============================================================================
276 //=============================================================================
277 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
278 (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
280 GEOM::GEOM_Object_var aGEOMObject;
282 //Set a not done flag
283 GetOperations()->SetNotDone();
287 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
288 if (!GetOperations()->IsDone() || anObject.IsNull())
289 return aGEOMObject._retn();
291 return GetObject(anObject);
294 //=============================================================================
298 //=============================================================================
299 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
300 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
302 GEOM::GEOM_Object_var aGEOMObject;
304 //Set a not done flag
305 GetOperations()->SetNotDone();
307 //Get the reference points
308 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
309 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
310 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
313 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
314 if (!GetOperations()->IsDone() || anObject.IsNull())
315 return aGEOMObject._retn();
317 return GetObject(anObject);
321 //=============================================================================
325 //=============================================================================
326 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
327 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
329 GEOM::GEOM_Object_var aGEOMObject;
331 //Set a not done flag
332 GetOperations()->SetNotDone();
334 //Get the reference objects
335 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
336 Handle(GEOM_Object) aRef2 = GetObjectImpl(theDir);
337 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
340 Handle(GEOM_Object) anObject = GetOperations()->MakeLine(aRef1, aRef2);
341 if (!GetOperations()->IsDone() || anObject.IsNull())
342 return aGEOMObject._retn();
344 return GetObject(anObject);
347 //=============================================================================
351 //=============================================================================
352 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
353 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
355 GEOM::GEOM_Object_var aGEOMObject;
357 //Set a not done flag
358 GetOperations()->SetNotDone();
360 //Get the reference points
361 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
362 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
363 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
366 Handle(GEOM_Object) anObject = GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
367 if (!GetOperations()->IsDone() || anObject.IsNull())
368 return aGEOMObject._retn();
370 return GetObject(anObject);
373 //=============================================================================
377 //=============================================================================
378 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces
379 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
381 GEOM::GEOM_Object_var aGEOMObject;
383 //Set a not done flag
384 GetOperations()->SetNotDone();
386 //Get the reference points
387 Handle(GEOM_Object) aRef1 = GetObjectImpl(theFace1);
388 Handle(GEOM_Object) aRef2 = GetObjectImpl(theFace2);
389 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
392 Handle(GEOM_Object) anObject =
393 GetOperations()->MakeLineTwoFaces(aRef1, aRef2);
394 if (!GetOperations()->IsDone() || anObject.IsNull())
395 return aGEOMObject._retn();
397 return GetObject(anObject);
401 //=============================================================================
405 //=============================================================================
406 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
407 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
408 CORBA::Double theTrimSize)
410 GEOM::GEOM_Object_var aGEOMObject;
412 //Set a not done flag
413 GetOperations()->SetNotDone();
416 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
417 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec);
418 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
421 Handle(GEOM_Object) anObject =
422 GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
423 if (!GetOperations()->IsDone() || anObject.IsNull())
424 return aGEOMObject._retn();
426 return GetObject(anObject);
429 //=============================================================================
433 //=============================================================================
434 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
435 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
436 GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
438 GEOM::GEOM_Object_var aGEOMObject;
440 //Set a not done flag
441 GetOperations()->SetNotDone();
443 //Get the reference points
444 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
445 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
446 Handle(GEOM_Object) aRef3 = GetObjectImpl(thePnt3);
447 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
448 return aGEOMObject._retn();
451 Handle(GEOM_Object) anObject =
452 GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
453 if (!GetOperations()->IsDone() || anObject.IsNull())
454 return aGEOMObject._retn();
456 return GetObject(anObject);
459 //=============================================================================
463 //=============================================================================
464 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
465 (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
467 GEOM::GEOM_Object_var aGEOMObject;
469 //Set a not done flag
470 GetOperations()->SetNotDone();
472 //Get the reference face
473 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
474 if (aRef.IsNull()) return aGEOMObject._retn();
477 Handle(GEOM_Object) anObject =
478 GetOperations()->MakePlaneFace(aRef, theTrimSize);
479 if (!GetOperations()->IsDone() || anObject.IsNull())
480 return aGEOMObject._retn();
482 return GetObject(anObject);
485 //=============================================================================
489 //=============================================================================
490 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlane2Vec
491 (GEOM::GEOM_Object_ptr theVec1, GEOM::GEOM_Object_ptr theVec2,
492 CORBA::Double theTrimSize)
494 GEOM::GEOM_Object_var aGEOMObject;
496 //Set a not done flag
497 GetOperations()->SetNotDone();
500 Handle(GEOM_Object) aRef1 = GetObjectImpl(theVec1);
501 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec2);
502 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
505 Handle(GEOM_Object) anObject =
506 GetOperations()->MakePlane2Vec(aRef1, aRef2, theTrimSize);
507 if (!GetOperations()->IsDone() || anObject.IsNull())
508 return aGEOMObject._retn();
510 return GetObject(anObject);
513 //=============================================================================
517 //=============================================================================
518 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneLCS
519 (GEOM::GEOM_Object_ptr theLCS, CORBA::Double theTrimSize,
520 CORBA::Double theOrientation)
522 GEOM::GEOM_Object_var aGEOMObject;
524 //Set a not done flag
525 GetOperations()->SetNotDone();
528 Handle(GEOM_Object) aRef1 = GetObjectImpl(theLCS);
531 Handle(GEOM_Object) anObject =
532 GetOperations()->MakePlaneLCS(aRef1, theTrimSize, theOrientation);
533 if (!GetOperations()->IsDone() || anObject.IsNull())
534 return aGEOMObject._retn();
536 return GetObject(anObject);
539 //=============================================================================
543 //=============================================================================
544 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
545 (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
546 CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
547 CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
549 GEOM::GEOM_Object_var aGEOMObject;
551 //Set a not done flag
552 GetOperations()->SetNotDone();
555 Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
556 theXDX, theXDY, theXDZ,
557 theYDX, theYDY, theYDZ);
558 if (!GetOperations()->IsDone() || anObject.IsNull())
559 return aGEOMObject._retn();
561 return GetObject(anObject);
564 //=============================================================================
566 * MakeMarkerFromShape
568 //=============================================================================
569 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerFromShape
570 (GEOM::GEOM_Object_ptr theShape)
572 GEOM::GEOM_Object_var aGEOMObject;
574 //Set a not done flag
575 GetOperations()->SetNotDone();
577 //Get the referenced object
578 Handle(GEOM_Object) aRef = GetObjectImpl(theShape);
579 if (aRef.IsNull()) return aGEOMObject._retn();
582 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerFromShape(aRef);
583 if (!GetOperations()->IsDone() || anObject.IsNull())
584 return aGEOMObject._retn();
586 return GetObject(anObject);
589 //=============================================================================
591 * MakeMarkerPntTwoVec
593 //=============================================================================
594 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerPntTwoVec
595 (GEOM::GEOM_Object_ptr theOrigin,
596 GEOM::GEOM_Object_ptr theXVec,
597 GEOM::GEOM_Object_ptr theYVec)
599 GEOM::GEOM_Object_var aGEOMObject;
601 //Set a not done flag
602 GetOperations()->SetNotDone();
604 //Get the referenced objects
605 Handle(GEOM_Object) aRef1 = GetObjectImpl(theOrigin);
606 Handle(GEOM_Object) aRef2 = GetObjectImpl(theXVec);
607 Handle(GEOM_Object) aRef3 = GetObjectImpl(theYVec);
608 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return aGEOMObject._retn();
611 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerPntTwoVec(aRef1,
614 if (!GetOperations()->IsDone() || anObject.IsNull())
615 return aGEOMObject._retn();
617 return GetObject(anObject);
620 //=============================================================================
622 * MakeTangentPlaneOnFace
624 //=============================================================================
626 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
627 (GEOM::GEOM_Object_ptr theFace,
628 CORBA::Double theParameterU,
629 CORBA::Double theParameterV,
630 CORBA::Double theTrimSize)
632 GEOM::GEOM_Object_var aGEOMObject;
634 //Set a not done flag
635 GetOperations()->SetNotDone();
637 //Get the reference face
638 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
639 if (aRef.IsNull()) return aGEOMObject._retn();
642 Handle(GEOM_Object) anObject =
643 GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
644 if (!GetOperations()->IsDone() || anObject.IsNull())
645 return aGEOMObject._retn();
647 return GetObject(anObject);