1 // Copyright (C) 2007-2010 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
23 #include <Standard_Stream.hxx>
25 #include "GEOM_IBasicOperations_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_IBasicOperations_i::GEOM_IBasicOperations_i (PortableServer::POA_ptr thePOA,
40 GEOM::GEOM_Gen_ptr theEngine,
41 ::GEOMImpl_IBasicOperations* theImpl)
42 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
44 MESSAGE("GEOM_IBasicOperations_i::GEOM_IBasicOperations_i");
47 //=============================================================================
51 //=============================================================================
52 GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i()
54 MESSAGE("GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i");
58 //=============================================================================
62 //=============================================================================
63 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointXYZ
64 (CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ)
66 GEOM::GEOM_Object_var aGEOMObject;
69 GetOperations()->SetNotDone();
72 Handle(GEOM_Object) anObject = GetOperations()->MakePointXYZ(theX, theY, theZ);
73 if (!GetOperations()->IsDone() || anObject.IsNull())
74 return aGEOMObject._retn();
76 return GetObject(anObject);
79 //=============================================================================
81 * MakePointWithReference
83 //=============================================================================
84 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointWithReference
85 (GEOM::GEOM_Object_ptr theReference, CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ)
87 GEOM::GEOM_Object_var aGEOMObject;
90 GetOperations()->SetNotDone();
92 //Get the reference point
93 Handle(GEOM_Object) aReference = GetObjectImpl(theReference);
94 if (aReference.IsNull()) return aGEOMObject._retn();
97 Handle(GEOM_Object) anObject =
98 GetOperations()->MakePointWithReference(aReference, theX, theY, theZ);
99 if (!GetOperations()->IsDone() || anObject.IsNull())
100 return aGEOMObject._retn();
102 return GetObject(anObject);
105 //=============================================================================
107 * MakePointOnLinesIntersection
109 //=============================================================================
110 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnLinesIntersection
111 (GEOM::GEOM_Object_ptr theLine1, GEOM::GEOM_Object_ptr theLine2)
113 GEOM::GEOM_Object_var aGEOMObject;
115 //Set a not done flag
116 GetOperations()->SetNotDone();
118 //Get the reference Lines
119 Handle(GEOM_Object) aRef1 = GetObjectImpl(theLine1);
120 Handle(GEOM_Object) aRef2 = GetObjectImpl(theLine2);
121 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
124 Handle(GEOM_Object) anObject =
125 GetOperations()->MakePointOnLinesIntersection(aRef1, aRef2);
126 if (!GetOperations()->IsDone() || anObject.IsNull())
127 return aGEOMObject._retn();
129 return GetObject(anObject);
132 //=============================================================================
136 //=============================================================================
137 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
138 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
140 GEOM::GEOM_Object_var aGEOMObject;
142 //Set a not done flag
143 GetOperations()->SetNotDone();
145 //Get the reference curve
146 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
147 if (aReference.IsNull()) return aGEOMObject._retn();
150 Handle(GEOM_Object) anObject =
151 GetOperations()->MakePointOnCurve(aReference, theParameter);
152 if (!GetOperations()->IsDone() || anObject.IsNull())
153 return aGEOMObject._retn();
155 return GetObject(anObject);
158 //=============================================================================
160 * MakePointOnCurveByCoord
162 //=============================================================================
163 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByCoord
164 (GEOM::GEOM_Object_ptr theCurve,
165 CORBA::Double theXParameter,
166 CORBA::Double theYParameter,
167 CORBA::Double theZParameter)
169 GEOM::GEOM_Object_var aGEOMObject;
171 //Set a not done flag
172 GetOperations()->SetNotDone();
174 //Get the reference curve
175 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
176 if (aReference.IsNull()) return aGEOMObject._retn();
179 Handle(GEOM_Object) anObject =
180 GetOperations()->MakePointOnCurveByCoord(aReference, theXParameter,
181 theYParameter, theZParameter);
182 if (!GetOperations()->IsDone() || anObject.IsNull())
183 return aGEOMObject._retn();
185 return GetObject(anObject);
188 //=============================================================================
192 //=============================================================================
193 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurface
194 (GEOM::GEOM_Object_ptr theSurface,
195 CORBA::Double theUParameter,
196 CORBA::Double theVParameter)
198 GEOM::GEOM_Object_var aGEOMObject;
200 //Set a not done flag
201 GetOperations()->SetNotDone();
203 //Get the reference surface
204 Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
205 if (aReference.IsNull()) return aGEOMObject._retn();
208 Handle(GEOM_Object) anObject =
209 GetOperations()->MakePointOnSurface(aReference, theUParameter, theVParameter);
210 if (!GetOperations()->IsDone() || anObject.IsNull())
211 return aGEOMObject._retn();
213 return GetObject(anObject);
216 //=============================================================================
218 * MakePointOnSurfaceByCoord
220 //=============================================================================
221 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurfaceByCoord
222 (GEOM::GEOM_Object_ptr theSurface,
223 CORBA::Double theXParameter,
224 CORBA::Double theYParameter,
225 CORBA::Double theZParameter)
227 GEOM::GEOM_Object_var aGEOMObject;
229 //Set a not done flag
230 GetOperations()->SetNotDone();
232 //Get the reference surface
233 Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
234 if (aReference.IsNull()) return aGEOMObject._retn();
237 Handle(GEOM_Object) anObject =
238 GetOperations()->MakePointOnSurfaceByCoord(aReference, theXParameter,
239 theYParameter, theZParameter);
240 if (!GetOperations()->IsDone() || anObject.IsNull())
241 return aGEOMObject._retn();
243 return GetObject(anObject);
247 //=============================================================================
251 //=============================================================================
252 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
253 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
255 GEOM::GEOM_Object_var aGEOMObject;
257 //Set a not done flag
258 GetOperations()->SetNotDone();
260 //Get the reference curve
261 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
262 if (aReference.IsNull()) return aGEOMObject._retn();
265 Handle(GEOM_Object) anObject =
266 GetOperations()->MakeTangentOnCurve(aReference, theParameter);
267 if (!GetOperations()->IsDone() || anObject.IsNull())
268 return aGEOMObject._retn();
270 return GetObject(anObject);
273 //=============================================================================
277 //=============================================================================
278 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
279 (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
281 GEOM::GEOM_Object_var aGEOMObject;
283 //Set a not done flag
284 GetOperations()->SetNotDone();
288 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
289 if (!GetOperations()->IsDone() || anObject.IsNull())
290 return aGEOMObject._retn();
292 return GetObject(anObject);
295 //=============================================================================
299 //=============================================================================
300 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
301 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
303 GEOM::GEOM_Object_var aGEOMObject;
305 //Set a not done flag
306 GetOperations()->SetNotDone();
308 //Get the reference points
309 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
310 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
311 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
314 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
315 if (!GetOperations()->IsDone() || anObject.IsNull())
316 return aGEOMObject._retn();
318 return GetObject(anObject);
322 //=============================================================================
326 //=============================================================================
327 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
328 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
330 GEOM::GEOM_Object_var aGEOMObject;
332 //Set a not done flag
333 GetOperations()->SetNotDone();
335 //Get the reference objects
336 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
337 Handle(GEOM_Object) aRef2 = GetObjectImpl(theDir);
338 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
341 Handle(GEOM_Object) anObject = GetOperations()->MakeLine(aRef1, aRef2);
342 if (!GetOperations()->IsDone() || anObject.IsNull())
343 return aGEOMObject._retn();
345 return GetObject(anObject);
348 //=============================================================================
352 //=============================================================================
353 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
354 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
356 GEOM::GEOM_Object_var aGEOMObject;
358 //Set a not done flag
359 GetOperations()->SetNotDone();
361 //Get the reference points
362 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
363 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
364 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
367 Handle(GEOM_Object) anObject = GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
368 if (!GetOperations()->IsDone() || anObject.IsNull())
369 return aGEOMObject._retn();
371 return GetObject(anObject);
374 //=============================================================================
378 //=============================================================================
379 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces
380 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
382 GEOM::GEOM_Object_var aGEOMObject;
384 //Set a not done flag
385 GetOperations()->SetNotDone();
387 //Get the reference points
388 Handle(GEOM_Object) aRef1 = GetObjectImpl(theFace1);
389 Handle(GEOM_Object) aRef2 = GetObjectImpl(theFace2);
390 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
393 Handle(GEOM_Object) anObject =
394 GetOperations()->MakeLineTwoFaces(aRef1, aRef2);
395 if (!GetOperations()->IsDone() || anObject.IsNull())
396 return aGEOMObject._retn();
398 return GetObject(anObject);
402 //=============================================================================
406 //=============================================================================
407 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
408 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
409 CORBA::Double theTrimSize)
411 GEOM::GEOM_Object_var aGEOMObject;
413 //Set a not done flag
414 GetOperations()->SetNotDone();
417 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
418 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec);
419 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
422 Handle(GEOM_Object) anObject =
423 GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
424 if (!GetOperations()->IsDone() || anObject.IsNull())
425 return aGEOMObject._retn();
427 return GetObject(anObject);
430 //=============================================================================
434 //=============================================================================
435 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
436 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
437 GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
439 GEOM::GEOM_Object_var aGEOMObject;
441 //Set a not done flag
442 GetOperations()->SetNotDone();
444 //Get the reference points
445 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
446 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
447 Handle(GEOM_Object) aRef3 = GetObjectImpl(thePnt3);
448 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
449 return aGEOMObject._retn();
452 Handle(GEOM_Object) anObject =
453 GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
454 if (!GetOperations()->IsDone() || anObject.IsNull())
455 return aGEOMObject._retn();
457 return GetObject(anObject);
460 //=============================================================================
464 //=============================================================================
465 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
466 (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
468 GEOM::GEOM_Object_var aGEOMObject;
470 //Set a not done flag
471 GetOperations()->SetNotDone();
473 //Get the reference face
474 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
475 if (aRef.IsNull()) return aGEOMObject._retn();
478 Handle(GEOM_Object) anObject =
479 GetOperations()->MakePlaneFace(aRef, theTrimSize);
480 if (!GetOperations()->IsDone() || anObject.IsNull())
481 return aGEOMObject._retn();
483 return GetObject(anObject);
486 //=============================================================================
490 //=============================================================================
491 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlane2Vec
492 (GEOM::GEOM_Object_ptr theVec1, GEOM::GEOM_Object_ptr theVec2,
493 CORBA::Double theTrimSize)
495 GEOM::GEOM_Object_var aGEOMObject;
497 //Set a not done flag
498 GetOperations()->SetNotDone();
501 Handle(GEOM_Object) aRef1 = GetObjectImpl(theVec1);
502 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec2);
503 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
506 Handle(GEOM_Object) anObject =
507 GetOperations()->MakePlane2Vec(aRef1, aRef2, theTrimSize);
508 if (!GetOperations()->IsDone() || anObject.IsNull())
509 return aGEOMObject._retn();
511 return GetObject(anObject);
514 //=============================================================================
518 //=============================================================================
519 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneLCS
520 (GEOM::GEOM_Object_ptr theLCS, CORBA::Double theTrimSize,
521 CORBA::Double theOrientation)
523 GEOM::GEOM_Object_var aGEOMObject;
525 //Set a not done flag
526 GetOperations()->SetNotDone();
529 Handle(GEOM_Object) aRef1 = GetObjectImpl(theLCS);
532 Handle(GEOM_Object) anObject =
533 GetOperations()->MakePlaneLCS(aRef1, theTrimSize, theOrientation);
534 if (!GetOperations()->IsDone() || anObject.IsNull())
535 return aGEOMObject._retn();
537 return GetObject(anObject);
540 //=============================================================================
544 //=============================================================================
545 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
546 (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
547 CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
548 CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
550 GEOM::GEOM_Object_var aGEOMObject;
552 //Set a not done flag
553 GetOperations()->SetNotDone();
556 Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
557 theXDX, theXDY, theXDZ,
558 theYDX, theYDY, theYDZ);
559 if (!GetOperations()->IsDone() || anObject.IsNull())
560 return aGEOMObject._retn();
562 return GetObject(anObject);
565 //=============================================================================
567 * MakeMarkerFromShape
569 //=============================================================================
570 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerFromShape
571 (GEOM::GEOM_Object_ptr theShape)
573 GEOM::GEOM_Object_var aGEOMObject;
575 //Set a not done flag
576 GetOperations()->SetNotDone();
578 //Get the referenced object
579 Handle(GEOM_Object) aRef = GetObjectImpl(theShape);
580 if (aRef.IsNull()) return aGEOMObject._retn();
583 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerFromShape(aRef);
584 if (!GetOperations()->IsDone() || anObject.IsNull())
585 return aGEOMObject._retn();
587 return GetObject(anObject);
590 //=============================================================================
592 * MakeMarkerPntTwoVec
594 //=============================================================================
595 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerPntTwoVec
596 (GEOM::GEOM_Object_ptr theOrigin,
597 GEOM::GEOM_Object_ptr theXVec,
598 GEOM::GEOM_Object_ptr theYVec)
600 GEOM::GEOM_Object_var aGEOMObject;
602 //Set a not done flag
603 GetOperations()->SetNotDone();
605 //Get the referenced objects
606 Handle(GEOM_Object) aRef1 = GetObjectImpl(theOrigin);
607 Handle(GEOM_Object) aRef2 = GetObjectImpl(theXVec);
608 Handle(GEOM_Object) aRef3 = GetObjectImpl(theYVec);
609 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return aGEOMObject._retn();
612 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerPntTwoVec(aRef1,
615 if (!GetOperations()->IsDone() || anObject.IsNull())
616 return aGEOMObject._retn();
618 return GetObject(anObject);
621 //=============================================================================
623 * MakeTangentPlaneOnFace
625 //=============================================================================
627 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
628 (GEOM::GEOM_Object_ptr theFace,
629 CORBA::Double theParameterU,
630 CORBA::Double theParameterV,
631 CORBA::Double theTrimSize)
633 GEOM::GEOM_Object_var aGEOMObject;
635 //Set a not done flag
636 GetOperations()->SetNotDone();
638 //Get the reference face
639 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
640 if (aRef.IsNull()) return aGEOMObject._retn();
643 Handle(GEOM_Object) anObject =
644 GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
645 if (!GetOperations()->IsDone() || anObject.IsNull())
646 return aGEOMObject._retn();
648 return GetObject(anObject);