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
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 * MakePointOnCurveByLength
161 //=============================================================================
162 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByLength
163 (GEOM::GEOM_Object_ptr theCurve,
164 CORBA::Double theLength,
165 GEOM::GEOM_Object_ptr theStartPoint)
167 GEOM::GEOM_Object_var aGEOMObject;
169 //Set a not done flag
170 GetOperations()->SetNotDone();
172 //Get the reference curve
173 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
174 if (aReference.IsNull()) return aGEOMObject._retn();
176 //Get the reference point (can be NULL)
177 Handle(GEOM_Object) aRefPoint;
178 if (!CORBA::is_nil(theStartPoint)) {
179 aRefPoint = GetObjectImpl(theStartPoint);
183 Handle(GEOM_Object) anObject =
184 GetOperations()->MakePointOnCurveByLength(aReference, theLength, aRefPoint);
185 if (!GetOperations()->IsDone() || anObject.IsNull())
186 return aGEOMObject._retn();
188 return GetObject(anObject);
191 //=============================================================================
193 * MakePointOnCurveByCoord
195 //=============================================================================
196 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByCoord
197 (GEOM::GEOM_Object_ptr theCurve,
198 CORBA::Double theXParameter,
199 CORBA::Double theYParameter,
200 CORBA::Double theZParameter)
202 GEOM::GEOM_Object_var aGEOMObject;
204 //Set a not done flag
205 GetOperations()->SetNotDone();
207 //Get the reference curve
208 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
209 if (aReference.IsNull()) return aGEOMObject._retn();
212 Handle(GEOM_Object) anObject =
213 GetOperations()->MakePointOnCurveByCoord(aReference, theXParameter,
214 theYParameter, theZParameter);
215 if (!GetOperations()->IsDone() || anObject.IsNull())
216 return aGEOMObject._retn();
218 return GetObject(anObject);
221 //=============================================================================
225 //=============================================================================
226 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurface
227 (GEOM::GEOM_Object_ptr theSurface,
228 CORBA::Double theUParameter,
229 CORBA::Double theVParameter)
231 GEOM::GEOM_Object_var aGEOMObject;
233 //Set a not done flag
234 GetOperations()->SetNotDone();
236 //Get the reference surface
237 Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
238 if (aReference.IsNull()) return aGEOMObject._retn();
241 Handle(GEOM_Object) anObject =
242 GetOperations()->MakePointOnSurface(aReference, theUParameter, theVParameter);
243 if (!GetOperations()->IsDone() || anObject.IsNull())
244 return aGEOMObject._retn();
246 return GetObject(anObject);
249 //=============================================================================
251 * MakePointOnSurfaceByCoord
253 //=============================================================================
254 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurfaceByCoord
255 (GEOM::GEOM_Object_ptr theSurface,
256 CORBA::Double theXParameter,
257 CORBA::Double theYParameter,
258 CORBA::Double theZParameter)
260 GEOM::GEOM_Object_var aGEOMObject;
262 //Set a not done flag
263 GetOperations()->SetNotDone();
265 //Get the reference surface
266 Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
267 if (aReference.IsNull()) return aGEOMObject._retn();
270 Handle(GEOM_Object) anObject =
271 GetOperations()->MakePointOnSurfaceByCoord(aReference, theXParameter,
272 theYParameter, theZParameter);
273 if (!GetOperations()->IsDone() || anObject.IsNull())
274 return aGEOMObject._retn();
276 return GetObject(anObject);
280 //=============================================================================
284 //=============================================================================
285 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
286 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
288 GEOM::GEOM_Object_var aGEOMObject;
290 //Set a not done flag
291 GetOperations()->SetNotDone();
293 //Get the reference curve
294 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
295 if (aReference.IsNull()) return aGEOMObject._retn();
298 Handle(GEOM_Object) anObject =
299 GetOperations()->MakeTangentOnCurve(aReference, theParameter);
300 if (!GetOperations()->IsDone() || anObject.IsNull())
301 return aGEOMObject._retn();
303 return GetObject(anObject);
306 //=============================================================================
310 //=============================================================================
311 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
312 (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
314 GEOM::GEOM_Object_var aGEOMObject;
316 //Set a not done flag
317 GetOperations()->SetNotDone();
321 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
322 if (!GetOperations()->IsDone() || anObject.IsNull())
323 return aGEOMObject._retn();
325 return GetObject(anObject);
328 //=============================================================================
332 //=============================================================================
333 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
334 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
336 GEOM::GEOM_Object_var aGEOMObject;
338 //Set a not done flag
339 GetOperations()->SetNotDone();
341 //Get the reference points
342 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
343 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
344 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
347 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
348 if (!GetOperations()->IsDone() || anObject.IsNull())
349 return aGEOMObject._retn();
351 return GetObject(anObject);
355 //=============================================================================
359 //=============================================================================
360 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
361 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
363 GEOM::GEOM_Object_var aGEOMObject;
365 //Set a not done flag
366 GetOperations()->SetNotDone();
368 //Get the reference objects
369 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
370 Handle(GEOM_Object) aRef2 = GetObjectImpl(theDir);
371 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
374 Handle(GEOM_Object) anObject = GetOperations()->MakeLine(aRef1, aRef2);
375 if (!GetOperations()->IsDone() || anObject.IsNull())
376 return aGEOMObject._retn();
378 return GetObject(anObject);
381 //=============================================================================
385 //=============================================================================
386 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
387 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
389 GEOM::GEOM_Object_var aGEOMObject;
391 //Set a not done flag
392 GetOperations()->SetNotDone();
394 //Get the reference points
395 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
396 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
397 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
400 Handle(GEOM_Object) anObject = GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
401 if (!GetOperations()->IsDone() || anObject.IsNull())
402 return aGEOMObject._retn();
404 return GetObject(anObject);
407 //=============================================================================
411 //=============================================================================
412 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces
413 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
415 GEOM::GEOM_Object_var aGEOMObject;
417 //Set a not done flag
418 GetOperations()->SetNotDone();
420 //Get the reference points
421 Handle(GEOM_Object) aRef1 = GetObjectImpl(theFace1);
422 Handle(GEOM_Object) aRef2 = GetObjectImpl(theFace2);
423 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
426 Handle(GEOM_Object) anObject =
427 GetOperations()->MakeLineTwoFaces(aRef1, aRef2);
428 if (!GetOperations()->IsDone() || anObject.IsNull())
429 return aGEOMObject._retn();
431 return GetObject(anObject);
435 //=============================================================================
439 //=============================================================================
440 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
441 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
442 CORBA::Double theTrimSize)
444 GEOM::GEOM_Object_var aGEOMObject;
446 //Set a not done flag
447 GetOperations()->SetNotDone();
450 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
451 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec);
452 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
455 Handle(GEOM_Object) anObject =
456 GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
457 if (!GetOperations()->IsDone() || anObject.IsNull())
458 return aGEOMObject._retn();
460 return GetObject(anObject);
463 //=============================================================================
467 //=============================================================================
468 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
469 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
470 GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
472 GEOM::GEOM_Object_var aGEOMObject;
474 //Set a not done flag
475 GetOperations()->SetNotDone();
477 //Get the reference points
478 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
479 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
480 Handle(GEOM_Object) aRef3 = GetObjectImpl(thePnt3);
481 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
482 return aGEOMObject._retn();
485 Handle(GEOM_Object) anObject =
486 GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
487 if (!GetOperations()->IsDone() || anObject.IsNull())
488 return aGEOMObject._retn();
490 return GetObject(anObject);
493 //=============================================================================
497 //=============================================================================
498 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
499 (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
501 GEOM::GEOM_Object_var aGEOMObject;
503 //Set a not done flag
504 GetOperations()->SetNotDone();
506 //Get the reference face
507 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
508 if (aRef.IsNull()) return aGEOMObject._retn();
511 Handle(GEOM_Object) anObject =
512 GetOperations()->MakePlaneFace(aRef, theTrimSize);
513 if (!GetOperations()->IsDone() || anObject.IsNull())
514 return aGEOMObject._retn();
516 return GetObject(anObject);
519 //=============================================================================
523 //=============================================================================
524 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlane2Vec
525 (GEOM::GEOM_Object_ptr theVec1, GEOM::GEOM_Object_ptr theVec2,
526 CORBA::Double theTrimSize)
528 GEOM::GEOM_Object_var aGEOMObject;
530 //Set a not done flag
531 GetOperations()->SetNotDone();
534 Handle(GEOM_Object) aRef1 = GetObjectImpl(theVec1);
535 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec2);
536 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
539 Handle(GEOM_Object) anObject =
540 GetOperations()->MakePlane2Vec(aRef1, aRef2, theTrimSize);
541 if (!GetOperations()->IsDone() || anObject.IsNull())
542 return aGEOMObject._retn();
544 return GetObject(anObject);
547 //=============================================================================
551 //=============================================================================
552 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneLCS
553 (GEOM::GEOM_Object_ptr theLCS, CORBA::Double theTrimSize,
554 CORBA::Double theOrientation)
556 GEOM::GEOM_Object_var aGEOMObject;
558 //Set a not done flag
559 GetOperations()->SetNotDone();
562 Handle(GEOM_Object) aRef1 = GetObjectImpl(theLCS);
565 Handle(GEOM_Object) anObject =
566 GetOperations()->MakePlaneLCS(aRef1, theTrimSize, theOrientation);
567 if (!GetOperations()->IsDone() || anObject.IsNull())
568 return aGEOMObject._retn();
570 return GetObject(anObject);
573 //=============================================================================
577 //=============================================================================
578 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
579 (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
580 CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
581 CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
583 GEOM::GEOM_Object_var aGEOMObject;
585 //Set a not done flag
586 GetOperations()->SetNotDone();
589 Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
590 theXDX, theXDY, theXDZ,
591 theYDX, theYDY, theYDZ);
592 if (!GetOperations()->IsDone() || anObject.IsNull())
593 return aGEOMObject._retn();
595 return GetObject(anObject);
598 //=============================================================================
600 * MakeMarkerFromShape
602 //=============================================================================
603 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerFromShape
604 (GEOM::GEOM_Object_ptr theShape)
606 GEOM::GEOM_Object_var aGEOMObject;
608 //Set a not done flag
609 GetOperations()->SetNotDone();
611 //Get the referenced object
612 Handle(GEOM_Object) aRef = GetObjectImpl(theShape);
613 if (aRef.IsNull()) return aGEOMObject._retn();
616 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerFromShape(aRef);
617 if (!GetOperations()->IsDone() || anObject.IsNull())
618 return aGEOMObject._retn();
620 return GetObject(anObject);
623 //=============================================================================
625 * MakeMarkerPntTwoVec
627 //=============================================================================
628 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerPntTwoVec
629 (GEOM::GEOM_Object_ptr theOrigin,
630 GEOM::GEOM_Object_ptr theXVec,
631 GEOM::GEOM_Object_ptr theYVec)
633 GEOM::GEOM_Object_var aGEOMObject;
635 //Set a not done flag
636 GetOperations()->SetNotDone();
638 //Get the referenced objects
639 Handle(GEOM_Object) aRef1 = GetObjectImpl(theOrigin);
640 Handle(GEOM_Object) aRef2 = GetObjectImpl(theXVec);
641 Handle(GEOM_Object) aRef3 = GetObjectImpl(theYVec);
642 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return aGEOMObject._retn();
645 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerPntTwoVec(aRef1,
648 if (!GetOperations()->IsDone() || anObject.IsNull())
649 return aGEOMObject._retn();
651 return GetObject(anObject);
654 //=============================================================================
656 * MakeTangentPlaneOnFace
658 //=============================================================================
660 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
661 (GEOM::GEOM_Object_ptr theFace,
662 CORBA::Double theParameterU,
663 CORBA::Double theParameterV,
664 CORBA::Double theTrimSize)
666 GEOM::GEOM_Object_var aGEOMObject;
668 //Set a not done flag
669 GetOperations()->SetNotDone();
671 //Get the reference face
672 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
673 if (aRef.IsNull()) return aGEOMObject._retn();
676 Handle(GEOM_Object) anObject =
677 GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
678 if (!GetOperations()->IsDone() || anObject.IsNull())
679 return aGEOMObject._retn();
681 return GetObject(anObject);