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 //=============================================================================
161 //=============================================================================
162 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurface
163 (GEOM::GEOM_Object_ptr theSurface,
164 CORBA::Double theUParameter,
165 CORBA::Double theVParameter)
167 GEOM::GEOM_Object_var aGEOMObject;
169 //Set a not done flag
170 GetOperations()->SetNotDone();
172 //Get the reference surface
173 Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
174 if (aReference.IsNull()) return aGEOMObject._retn();
177 Handle(GEOM_Object) anObject =
178 GetOperations()->MakePointOnSurface(aReference, theUParameter, theVParameter);
179 if (!GetOperations()->IsDone() || anObject.IsNull())
180 return aGEOMObject._retn();
182 return GetObject(anObject);
186 //=============================================================================
190 //=============================================================================
191 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
192 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
194 GEOM::GEOM_Object_var aGEOMObject;
196 //Set a not done flag
197 GetOperations()->SetNotDone();
199 //Get the reference curve
200 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
201 if (aReference.IsNull()) return aGEOMObject._retn();
204 Handle(GEOM_Object) anObject =
205 GetOperations()->MakeTangentOnCurve(aReference, theParameter);
206 if (!GetOperations()->IsDone() || anObject.IsNull())
207 return aGEOMObject._retn();
209 return GetObject(anObject);
212 //=============================================================================
216 //=============================================================================
217 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
218 (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
220 GEOM::GEOM_Object_var aGEOMObject;
222 //Set a not done flag
223 GetOperations()->SetNotDone();
227 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
228 if (!GetOperations()->IsDone() || anObject.IsNull())
229 return aGEOMObject._retn();
231 return GetObject(anObject);
234 //=============================================================================
238 //=============================================================================
239 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
240 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
242 GEOM::GEOM_Object_var aGEOMObject;
244 //Set a not done flag
245 GetOperations()->SetNotDone();
247 //Get the reference points
248 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
249 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
250 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
253 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
254 if (!GetOperations()->IsDone() || anObject.IsNull())
255 return aGEOMObject._retn();
257 return GetObject(anObject);
261 //=============================================================================
265 //=============================================================================
266 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
267 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
269 GEOM::GEOM_Object_var aGEOMObject;
271 //Set a not done flag
272 GetOperations()->SetNotDone();
274 //Get the reference objects
275 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
276 Handle(GEOM_Object) aRef2 = GetObjectImpl(theDir);
277 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
280 Handle(GEOM_Object) anObject = GetOperations()->MakeLine(aRef1, aRef2);
281 if (!GetOperations()->IsDone() || anObject.IsNull())
282 return aGEOMObject._retn();
284 return GetObject(anObject);
287 //=============================================================================
291 //=============================================================================
292 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
293 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
295 GEOM::GEOM_Object_var aGEOMObject;
297 //Set a not done flag
298 GetOperations()->SetNotDone();
300 //Get the reference points
301 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
302 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
303 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
306 Handle(GEOM_Object) anObject = GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
307 if (!GetOperations()->IsDone() || anObject.IsNull())
308 return aGEOMObject._retn();
310 return GetObject(anObject);
313 //=============================================================================
317 //=============================================================================
318 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces
319 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
321 GEOM::GEOM_Object_var aGEOMObject;
323 //Set a not done flag
324 GetOperations()->SetNotDone();
326 //Get the reference points
327 Handle(GEOM_Object) aRef1 = GetObjectImpl(theFace1);
328 Handle(GEOM_Object) aRef2 = GetObjectImpl(theFace2);
329 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
332 Handle(GEOM_Object) anObject =
333 GetOperations()->MakeLineTwoFaces(aRef1, aRef2);
334 if (!GetOperations()->IsDone() || anObject.IsNull())
335 return aGEOMObject._retn();
337 return GetObject(anObject);
341 //=============================================================================
345 //=============================================================================
346 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
347 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
348 CORBA::Double theTrimSize)
350 GEOM::GEOM_Object_var aGEOMObject;
352 //Set a not done flag
353 GetOperations()->SetNotDone();
356 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
357 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec);
358 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
361 Handle(GEOM_Object) anObject =
362 GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
363 if (!GetOperations()->IsDone() || anObject.IsNull())
364 return aGEOMObject._retn();
366 return GetObject(anObject);
369 //=============================================================================
373 //=============================================================================
374 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
375 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
376 GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
378 GEOM::GEOM_Object_var aGEOMObject;
380 //Set a not done flag
381 GetOperations()->SetNotDone();
383 //Get the reference points
384 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
385 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
386 Handle(GEOM_Object) aRef3 = GetObjectImpl(thePnt3);
387 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
388 return aGEOMObject._retn();
391 Handle(GEOM_Object) anObject =
392 GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
393 if (!GetOperations()->IsDone() || anObject.IsNull())
394 return aGEOMObject._retn();
396 return GetObject(anObject);
399 //=============================================================================
403 //=============================================================================
404 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
405 (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
407 GEOM::GEOM_Object_var aGEOMObject;
409 //Set a not done flag
410 GetOperations()->SetNotDone();
412 //Get the reference face
413 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
414 if (aRef.IsNull()) return aGEOMObject._retn();
417 Handle(GEOM_Object) anObject =
418 GetOperations()->MakePlaneFace(aRef, theTrimSize);
419 if (!GetOperations()->IsDone() || anObject.IsNull())
420 return aGEOMObject._retn();
422 return GetObject(anObject);
425 //=============================================================================
429 //=============================================================================
430 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlane2Vec
431 (GEOM::GEOM_Object_ptr theVec1, GEOM::GEOM_Object_ptr theVec2,
432 CORBA::Double theTrimSize)
434 GEOM::GEOM_Object_var aGEOMObject;
436 //Set a not done flag
437 GetOperations()->SetNotDone();
440 Handle(GEOM_Object) aRef1 = GetObjectImpl(theVec1);
441 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec2);
442 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
445 Handle(GEOM_Object) anObject =
446 GetOperations()->MakePlane2Vec(aRef1, aRef2, theTrimSize);
447 if (!GetOperations()->IsDone() || anObject.IsNull())
448 return aGEOMObject._retn();
450 return GetObject(anObject);
453 //=============================================================================
457 //=============================================================================
458 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneLCS
459 (GEOM::GEOM_Object_ptr theLCS, CORBA::Double theTrimSize,
460 CORBA::Double theOrientation)
462 GEOM::GEOM_Object_var aGEOMObject;
464 //Set a not done flag
465 GetOperations()->SetNotDone();
468 Handle(GEOM_Object) aRef1 = GetObjectImpl(theLCS);
471 Handle(GEOM_Object) anObject =
472 GetOperations()->MakePlaneLCS(aRef1, theTrimSize, theOrientation);
473 if (!GetOperations()->IsDone() || anObject.IsNull())
474 return aGEOMObject._retn();
476 return GetObject(anObject);
479 //=============================================================================
483 //=============================================================================
484 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
485 (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
486 CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
487 CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
489 GEOM::GEOM_Object_var aGEOMObject;
491 //Set a not done flag
492 GetOperations()->SetNotDone();
495 Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
496 theXDX, theXDY, theXDZ,
497 theYDX, theYDY, theYDZ);
498 if (!GetOperations()->IsDone() || anObject.IsNull())
499 return aGEOMObject._retn();
501 return GetObject(anObject);
504 //=============================================================================
506 * MakeTangentPlaneOnFace
508 //=============================================================================
510 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
511 (GEOM::GEOM_Object_ptr theFace,
512 CORBA::Double theParameterU,
513 CORBA::Double theParameterV,
514 CORBA::Double theTrimSize)
516 GEOM::GEOM_Object_var aGEOMObject;
518 //Set a not done flag
519 GetOperations()->SetNotDone();
521 //Get the reference face
522 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
523 if (aRef.IsNull()) return aGEOMObject._retn();
526 Handle(GEOM_Object) anObject =
527 GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
528 if (!GetOperations()->IsDone() || anObject.IsNull())
529 return aGEOMObject._retn();
531 return GetObject(anObject);