Salome HOME
0020098: EDF 899 GEOM : Point on curve/surface with X,Y,Z coordinates.
[modules/geom.git] / src / GEOM_I / GEOM_IBasicOperations_i.cc
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21
22 #include <Standard_Stream.hxx>
23
24 #include "GEOM_IBasicOperations_i.hh"
25
26 #include "utilities.h"
27 #include "OpUtil.hxx"
28 #include "Utils_ExceptHandlers.hxx"
29
30 #include "GEOM_Engine.hxx"
31 #include "GEOM_Object.hxx"
32
33 //=============================================================================
34 /*!
35  *   constructor:
36  */
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)
42 {
43   MESSAGE("GEOM_IBasicOperations_i::GEOM_IBasicOperations_i");
44 }
45
46 //=============================================================================
47 /*!
48  *  destructor
49  */
50 //=============================================================================
51 GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i()
52 {
53   MESSAGE("GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i");
54 }
55
56
57 //=============================================================================
58 /*!
59  *  MakePointXYZ
60  */
61 //=============================================================================
62 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointXYZ
63   (CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ)
64 {
65   GEOM::GEOM_Object_var aGEOMObject;
66
67   //Set a not done flag
68   GetOperations()->SetNotDone();
69
70   //Create the point
71   Handle(GEOM_Object) anObject = GetOperations()->MakePointXYZ(theX, theY, theZ);
72   if (!GetOperations()->IsDone() || anObject.IsNull())
73     return aGEOMObject._retn();
74
75   return GetObject(anObject);
76 }
77
78 //=============================================================================
79 /*!
80  *  MakePointWithReference
81  */
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)
85 {
86   GEOM::GEOM_Object_var aGEOMObject;
87
88   //Set a not done flag
89   GetOperations()->SetNotDone();
90
91   //Get the reference point
92   Handle(GEOM_Object) aReference = GetObjectImpl(theReference);
93   if (aReference.IsNull()) return aGEOMObject._retn();
94
95   //Create the point
96   Handle(GEOM_Object) anObject =
97     GetOperations()->MakePointWithReference(aReference, theX, theY, theZ);
98   if (!GetOperations()->IsDone() || anObject.IsNull())
99     return aGEOMObject._retn();
100
101   return GetObject(anObject);
102 }
103
104 //=============================================================================
105 /*!
106  *  MakePointOnLinesIntersection
107  */
108 //=============================================================================
109 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnLinesIntersection
110                   (GEOM::GEOM_Object_ptr theLine1,  GEOM::GEOM_Object_ptr theLine2)
111 {
112   GEOM::GEOM_Object_var aGEOMObject;
113
114   //Set a not done flag
115   GetOperations()->SetNotDone();
116
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();
121
122   //Create the point
123   Handle(GEOM_Object) anObject =
124     GetOperations()->MakePointOnLinesIntersection(aRef1, aRef2);
125   if (!GetOperations()->IsDone() || anObject.IsNull())
126     return aGEOMObject._retn();
127
128   return GetObject(anObject);
129 }
130
131 //=============================================================================
132 /*!
133  *  MakePointOnCurve
134  */
135 //=============================================================================
136 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
137                   (GEOM::GEOM_Object_ptr theCurve,  CORBA::Double theParameter)
138 {
139   GEOM::GEOM_Object_var aGEOMObject;
140
141   //Set a not done flag
142   GetOperations()->SetNotDone();
143
144   //Get the reference curve
145   Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
146   if (aReference.IsNull()) return aGEOMObject._retn();
147
148   //Create the point
149   Handle(GEOM_Object) anObject =
150     GetOperations()->MakePointOnCurve(aReference, theParameter);
151   if (!GetOperations()->IsDone() || anObject.IsNull())
152     return aGEOMObject._retn();
153
154   return GetObject(anObject);
155 }
156
157 //=============================================================================
158 /*!
159  *  MakePointOnCurveByCoord
160  */
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)
167 {
168   GEOM::GEOM_Object_var aGEOMObject;
169
170   //Set a not done flag
171   GetOperations()->SetNotDone();
172
173   //Get the reference curve
174   Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
175   if (aReference.IsNull()) return aGEOMObject._retn();
176
177   //Create the point
178   Handle(GEOM_Object) anObject =
179     GetOperations()->MakePointOnCurveByCoord(aReference, theXParameter,
180                                              theYParameter, theZParameter);
181   if (!GetOperations()->IsDone() || anObject.IsNull())
182     return aGEOMObject._retn();
183
184   return GetObject(anObject);
185 }
186
187 //=============================================================================
188 /*!
189  *  MakePointOnSurface
190  */
191 //=============================================================================
192 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurface
193                                              (GEOM::GEOM_Object_ptr theSurface,
194                                               CORBA::Double theUParameter,
195                                               CORBA::Double theVParameter)
196 {
197   GEOM::GEOM_Object_var aGEOMObject;
198
199   //Set a not done flag
200   GetOperations()->SetNotDone();
201
202   //Get the reference surface
203   Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
204   if (aReference.IsNull()) return aGEOMObject._retn();
205
206   //Create the point
207   Handle(GEOM_Object) anObject =
208     GetOperations()->MakePointOnSurface(aReference, theUParameter, theVParameter);
209   if (!GetOperations()->IsDone() || anObject.IsNull())
210     return aGEOMObject._retn();
211
212   return GetObject(anObject);
213 }
214
215 //=============================================================================
216 /*!
217  *  MakePointOnSurfaceByCoord
218  */
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)
225 {
226   GEOM::GEOM_Object_var aGEOMObject;
227
228   //Set a not done flag
229   GetOperations()->SetNotDone();
230
231   //Get the reference surface
232   Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
233   if (aReference.IsNull()) return aGEOMObject._retn();
234
235   //Create the point
236   Handle(GEOM_Object) anObject =
237     GetOperations()->MakePointOnSurfaceByCoord(aReference, theXParameter,
238                                                theYParameter, theZParameter);
239   if (!GetOperations()->IsDone() || anObject.IsNull())
240     return aGEOMObject._retn();
241
242   return GetObject(anObject);
243 }
244
245
246 //=============================================================================
247 /*!
248  *  MakeTangentOnCurve
249  */
250 //=============================================================================
251 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
252                   (GEOM::GEOM_Object_ptr theCurve,  CORBA::Double theParameter)
253 {
254   GEOM::GEOM_Object_var aGEOMObject;
255
256   //Set a not done flag
257   GetOperations()->SetNotDone();
258
259   //Get the reference curve
260   Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
261   if (aReference.IsNull()) return aGEOMObject._retn();
262
263   //Create the vector
264   Handle(GEOM_Object) anObject =
265     GetOperations()->MakeTangentOnCurve(aReference, theParameter);
266   if (!GetOperations()->IsDone() || anObject.IsNull())
267     return aGEOMObject._retn();
268
269   return GetObject(anObject);
270 }
271
272 //=============================================================================
273 /*!
274  *  MakeVectorDXDYDZ
275  */
276 //=============================================================================
277 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
278   (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
279 {
280   GEOM::GEOM_Object_var aGEOMObject;
281
282   //Set a not done flag
283   GetOperations()->SetNotDone();
284
285   //Create the Vector
286
287   Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
288   if (!GetOperations()->IsDone() || anObject.IsNull())
289     return aGEOMObject._retn();
290
291   return GetObject(anObject);
292 }
293
294 //=============================================================================
295 /*!
296  *  MakeVectorTwoPnt
297  */
298 //=============================================================================
299 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
300                  (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
301 {
302   GEOM::GEOM_Object_var aGEOMObject;
303
304   //Set a not done flag
305   GetOperations()->SetNotDone();
306
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();
311
312   //Create the vector
313   Handle(GEOM_Object) anObject = GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
314   if (!GetOperations()->IsDone() || anObject.IsNull())
315     return aGEOMObject._retn();
316
317   return GetObject(anObject);
318 }
319
320
321 //=============================================================================
322 /*!
323  *  MakeLine
324  */
325 //=============================================================================
326 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
327                    (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
328 {
329   GEOM::GEOM_Object_var aGEOMObject;
330
331   //Set a not done flag
332   GetOperations()->SetNotDone();
333
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();
338
339   //Create the Line
340   Handle(GEOM_Object) anObject = GetOperations()->MakeLine(aRef1, aRef2);
341   if (!GetOperations()->IsDone() || anObject.IsNull())
342     return aGEOMObject._retn();
343
344   return GetObject(anObject);
345 }
346
347 //=============================================================================
348 /*!
349  *  MakeLineTwoPnt
350  */
351 //=============================================================================
352 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
353                  (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
354 {
355   GEOM::GEOM_Object_var aGEOMObject;
356
357   //Set a not done flag
358   GetOperations()->SetNotDone();
359
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();
364
365   //Create the Line
366   Handle(GEOM_Object) anObject = GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
367   if (!GetOperations()->IsDone() || anObject.IsNull())
368     return aGEOMObject._retn();
369
370   return GetObject(anObject);
371 }
372
373 //=============================================================================
374 /*!
375  *  MakeLineTwoFaces
376  */
377 //=============================================================================
378 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces
379                  (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
380 {
381   GEOM::GEOM_Object_var aGEOMObject;
382
383   //Set a not done flag
384   GetOperations()->SetNotDone();
385
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();
390
391   //Create the Line
392   Handle(GEOM_Object) anObject =
393     GetOperations()->MakeLineTwoFaces(aRef1, aRef2);
394   if (!GetOperations()->IsDone() || anObject.IsNull())
395     return aGEOMObject._retn();
396
397   return GetObject(anObject);
398 }
399
400
401 //=============================================================================
402 /*!
403  *  MakePlanePntVec
404  */
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)
409 {
410   GEOM::GEOM_Object_var aGEOMObject;
411
412   //Set a not done flag
413   GetOperations()->SetNotDone();
414
415   //Get the references
416   Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
417   Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec);
418   if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
419
420   //Create the plane
421   Handle(GEOM_Object) anObject =
422     GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
423   if (!GetOperations()->IsDone() || anObject.IsNull())
424     return aGEOMObject._retn();
425
426   return GetObject(anObject);
427 }
428
429 //=============================================================================
430 /*!
431  *  MakePlaneThreePnt
432  */
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)
437 {
438   GEOM::GEOM_Object_var aGEOMObject;
439
440   //Set a not done flag
441   GetOperations()->SetNotDone();
442
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();
449
450   //Create the plane
451   Handle(GEOM_Object) anObject =
452     GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
453   if (!GetOperations()->IsDone() || anObject.IsNull())
454     return aGEOMObject._retn();
455
456   return GetObject(anObject);
457 }
458
459 //=============================================================================
460 /*!
461  *  MakePlaneFace
462  */
463 //=============================================================================
464 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
465                      (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
466 {
467   GEOM::GEOM_Object_var aGEOMObject;
468
469   //Set a not done flag
470   GetOperations()->SetNotDone();
471
472   //Get the reference face
473   Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
474   if (aRef.IsNull()) return aGEOMObject._retn();
475
476   //Create the plane
477   Handle(GEOM_Object) anObject =
478     GetOperations()->MakePlaneFace(aRef, theTrimSize);
479   if (!GetOperations()->IsDone() || anObject.IsNull())
480     return aGEOMObject._retn();
481
482   return GetObject(anObject);
483 }
484
485 //=============================================================================
486 /*!
487  *  MakePlane2Vec
488  */
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)
493 {
494   GEOM::GEOM_Object_var aGEOMObject;
495
496   //Set a not done flag
497   GetOperations()->SetNotDone();
498
499   //Get the references
500   Handle(GEOM_Object) aRef1 = GetObjectImpl(theVec1);
501   Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec2);
502   if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
503
504   //Create the plane
505   Handle(GEOM_Object) anObject =
506     GetOperations()->MakePlane2Vec(aRef1, aRef2, theTrimSize);
507   if (!GetOperations()->IsDone() || anObject.IsNull())
508     return aGEOMObject._retn();
509
510   return GetObject(anObject);
511 }
512
513 //=============================================================================
514 /*!
515  *  MakePlaneLCS
516  */
517 //=============================================================================
518 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneLCS
519                  (GEOM::GEOM_Object_ptr theLCS, CORBA::Double theTrimSize,
520                   CORBA::Double theOrientation)
521 {
522   GEOM::GEOM_Object_var aGEOMObject;
523
524   //Set a not done flag
525   GetOperations()->SetNotDone();
526
527   //Get the references
528   Handle(GEOM_Object) aRef1 = GetObjectImpl(theLCS);
529
530   //Create the plane
531   Handle(GEOM_Object) anObject =
532     GetOperations()->MakePlaneLCS(aRef1, theTrimSize, theOrientation);
533   if (!GetOperations()->IsDone() || anObject.IsNull())
534     return aGEOMObject._retn();
535
536   return GetObject(anObject);
537 }
538
539 //=============================================================================
540 /*!
541  *  MakeMarker
542  */
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)
548 {
549   GEOM::GEOM_Object_var aGEOMObject;
550
551   //Set a not done flag
552   GetOperations()->SetNotDone();
553
554   //Create the point
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();
560
561   return GetObject(anObject);
562 }
563
564 //=============================================================================
565 /*!
566  *  MakeTangentPlaneOnFace
567  */
568 //=============================================================================
569
570 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
571                      (GEOM::GEOM_Object_ptr theFace,
572                       CORBA::Double theParameterU,
573                       CORBA::Double theParameterV,
574                       CORBA::Double theTrimSize)
575 {
576   GEOM::GEOM_Object_var aGEOMObject;
577
578   //Set a not done flag
579   GetOperations()->SetNotDone();
580
581   //Get the reference face
582   Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
583   if (aRef.IsNull()) return aGEOMObject._retn();
584
585   //Create the plane
586   Handle(GEOM_Object) anObject =
587     GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
588   if (!GetOperations()->IsDone() || anObject.IsNull())
589     return aGEOMObject._retn();
590
591   return GetObject(anObject);
592 }