Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IBasicOperations.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 #include <Standard_Stream.hxx>
21
22 #include <GEOMImpl_IBasicOperations.hxx>
23
24 #include "utilities.h"
25 #include <OpUtil.hxx>
26 #include <Utils_ExceptHandlers.hxx>
27
28 #include <TFunction_DriverTable.hxx>
29 #include <TFunction_Driver.hxx>
30 #include <TFunction_Logbook.hxx>
31 #include <TDF_Tool.hxx>
32
33 #include <GEOM_Function.hxx>
34 #include <GEOM_PythonDump.hxx>
35
36 #include <GEOMImpl_PointDriver.hxx>
37 #include <GEOMImpl_VectorDriver.hxx>
38 #include <GEOMImpl_LineDriver.hxx>
39 #include <GEOMImpl_PlaneDriver.hxx>
40 #include <GEOMImpl_MarkerDriver.hxx>
41
42 #include <GEOMImpl_IPoint.hxx>
43 #include <GEOMImpl_IVector.hxx>
44 #include <GEOMImpl_ILine.hxx>
45 #include <GEOMImpl_IPlane.hxx>
46 #include <GEOMImpl_IMarker.hxx>
47
48 #include <GEOMImpl_Types.hxx>
49
50 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
51
52 //=============================================================================
53 /*!
54  *   constructor:
55  */
56 //=============================================================================
57 GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations(GEOM_Engine* theEngine, int theDocID)
58 : GEOM_IOperations(theEngine, theDocID)
59 {
60   MESSAGE("GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations");
61 }
62
63 //=============================================================================
64 /*!
65  *  destructor
66  */
67 //=============================================================================
68 GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations()
69 {
70   MESSAGE("GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations");
71 }
72
73
74 //=============================================================================
75 /*!
76  *  MakePointXYZ
77  */
78 //=============================================================================
79 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointXYZ
80                                         (double theX, double theY, double theZ)
81 {
82   SetErrorCode(KO);
83
84   //Add a new Point object
85   Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
86
87   //Add a new Point function with XYZ parameters
88   Handle(GEOM_Function) aFunction =
89     aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ);
90   if (aFunction.IsNull()) return NULL;
91
92   //Check if the function is set correctly
93   if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
94
95   GEOMImpl_IPoint aPI(aFunction);
96
97   aPI.SetX(theX);
98   aPI.SetY(theY);
99   aPI.SetZ(theZ);
100
101   //Compute the point value
102   try {
103     if (!GetSolver()->ComputeFunction(aFunction)) {
104       SetErrorCode("Point driver failed");
105       return NULL;
106     }
107   }
108   catch (Standard_Failure) {
109     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
110     SetErrorCode(aFail->GetMessageString());
111     return NULL;
112   }
113
114   //Make a Python command
115   GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertex("
116     << theX << ", " << theY << ", " << theZ << ")";
117
118   SetErrorCode(OK);
119   return aPoint;
120 }
121
122 //=============================================================================
123 /*!
124  *  MakePointWithReference
125  */
126 //=============================================================================
127 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference
128       (Handle(GEOM_Object) theReference, double theX, double theY, double theZ)
129 {
130   SetErrorCode(KO);
131
132   if (theReference.IsNull()) return NULL;
133
134   //Add a new Point object
135   Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
136
137   //Add a new Point function for creation a point relativley another point
138   Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ_REF);
139
140   //Check if the function is set correctly
141   if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
142
143   GEOMImpl_IPoint aPI(aFunction);
144
145   Handle(GEOM_Function) aRefFunction = theReference->GetLastFunction();
146   if (aRefFunction.IsNull()) return NULL;
147
148   aPI.SetRef(aRefFunction);
149   aPI.SetX(theX);
150   aPI.SetY(theY);
151   aPI.SetZ(theZ);
152
153   //Compute the point value
154   try {
155     if (!GetSolver()->ComputeFunction(aFunction)) {
156       SetErrorCode("Point driver failed");
157       return NULL;
158     }
159   }
160   catch (Standard_Failure) {
161     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
162     SetErrorCode(aFail->GetMessageString());
163     return NULL;
164   }
165
166   //Make a Python command
167   GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexWithRef("
168     << theReference << ", " << theX << ", " << theY << ", " << theZ << ")";
169
170   SetErrorCode(OK);
171   return aPoint;
172 }
173
174 //=============================================================================
175 /*!
176  *  MakePointOnCurve
177  */
178 //=============================================================================
179 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
180                             (Handle(GEOM_Object) theCurve, double theParameter)
181 {
182   SetErrorCode(KO);
183
184   if (theCurve.IsNull()) return NULL;
185
186   //Add a new Point object
187   Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT);
188
189   //Add a new Point function for creation a point relativley another point
190   Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_CURVE_PAR);
191
192   //Check if the function is set correctly
193   if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL;
194
195   GEOMImpl_IPoint aPI (aFunction);
196
197   Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
198   if (aRefFunction.IsNull()) return NULL;
199
200   aPI.SetCurve(aRefFunction);
201   aPI.SetParameter(theParameter);
202
203   //Compute the point value
204   try {
205     if (!GetSolver()->ComputeFunction(aFunction)) {
206       SetErrorCode("Point driver failed");
207       return NULL;
208     }
209   }
210   catch (Standard_Failure) {
211     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
212     SetErrorCode(aFail->GetMessageString());
213     return NULL;
214   }
215
216   //Make a Python command
217   GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
218                                << theCurve << ", " << theParameter << ")";
219
220   SetErrorCode(OK);
221   return aPoint;
222 }
223
224 //=============================================================================
225 /*!
226  *  MakeTangentOnCurve
227  */
228 //=============================================================================
229 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve
230                             (const Handle(GEOM_Object)& theCurve, double theParameter)
231 {
232   SetErrorCode(KO);
233
234   if (theCurve.IsNull()) return NULL;
235
236   //Add a new Vector object
237   Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
238
239   //Add a new Point function for creation a point relativley another point
240   Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR);
241
242   //Check if the function is set correctly
243   if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
244
245   GEOMImpl_IVector aVI (aFunction);
246
247   Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction();
248   if (aRefFunction.IsNull()) return NULL;
249
250   aVI.SetCurve(aRefFunction);
251   aVI.SetParameter(theParameter);
252
253   //Compute the vector value
254   try {
255     if (!GetSolver()->ComputeFunction(aFunction)) {
256       SetErrorCode("Vector driver failed");
257       return NULL;
258     }
259   }
260   catch (Standard_Failure) {
261     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
262     SetErrorCode(aFail->GetMessageString());
263     return NULL;
264   }
265
266   //Make a Python command
267   GEOM::TPythonDump(aFunction) << aVec << " = geompy.MakeTangentOnCurve("
268                                << theCurve << ", " << theParameter << ")";
269
270   SetErrorCode(OK);
271   return aVec;
272 }
273
274 //=============================================================================
275 /*!
276  *  MakeVectorDXDYDZ
277  */
278 //=============================================================================
279 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
280                                      (double theDX, double theDY, double theDZ)
281 {
282   SetErrorCode(KO);
283
284   //Add a new Vector object
285   Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
286
287   //Add a new Vector function with DXDYDZ parameters
288   Handle(GEOM_Function) aFunction =
289     aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ);
290   if (aFunction.IsNull()) return NULL;
291
292   //Check if the function is set correctly
293   if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
294
295   GEOMImpl_IVector aPI (aFunction);
296
297   aPI.SetDX(theDX);
298   aPI.SetDY(theDY);
299   aPI.SetDZ(theDZ);
300
301   //Compute the Vector value
302   try {
303     if (!GetSolver()->ComputeFunction(aFunction)) {
304       SetErrorCode("Vector driver failed");
305       return NULL;
306     }
307   }
308   catch (Standard_Failure) {
309     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
310     SetErrorCode(aFail->GetMessageString());
311     return NULL;
312   }
313
314   //Make a Python command
315   GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
316     << theDX << ", " << theDY << ", " << theDZ << ")";
317
318   SetErrorCode(OK);
319   return aVector;
320 }
321
322 //=============================================================================
323 /*!
324  *  MakeVectorTwoPnt
325  */
326 //=============================================================================
327 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
328                      (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
329 {
330   SetErrorCode(KO);
331
332   if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
333
334   //Add a new Vector object
335   Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR);
336
337   //Add a new Vector function
338   Handle(GEOM_Function) aFunction =
339     aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);
340
341   //Check if the function is set correctly
342   if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
343
344   GEOMImpl_IVector aPI (aFunction);
345
346   Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
347   Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
348   if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
349
350   aPI.SetPoint1(aRef1);
351   aPI.SetPoint2(aRef2);
352
353   //Compute the Vector value
354   try {
355     if (!GetSolver()->ComputeFunction(aFunction)) {
356       SetErrorCode("Vector driver failed");
357       return NULL;
358     }
359   }
360   catch (Standard_Failure) {
361     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
362     SetErrorCode(aFail->GetMessageString());
363     return NULL;
364   }
365
366   //Make a Python command
367   GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
368                                << thePnt1 << ", " << thePnt2 << ")";
369
370   SetErrorCode(OK);
371   return aVector;
372 }
373
374
375 //=============================================================================
376 /*!
377  *  MakeLine
378  */
379 //=============================================================================
380 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
381                      (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir)
382 {
383   SetErrorCode(KO);
384
385   if (thePnt.IsNull() || theDir.IsNull()) return NULL;
386
387   //Add a new Line object
388   Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
389
390   //Add a new Line function
391   Handle(GEOM_Function) aFunction =
392     aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR);
393
394   //Check if the function is set correctly
395   if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
396
397   GEOMImpl_ILine aPI (aFunction);
398
399   Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction();
400   Handle(GEOM_Function) aRef2 = theDir->GetLastFunction();
401   if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
402
403   aPI.SetPoint1(aRef1);
404   aPI.SetPoint2(aRef2);
405
406   //Compute the Line value
407   try {
408     if (!GetSolver()->ComputeFunction(aFunction)) {
409       SetErrorCode("Line driver failed");
410       return NULL;
411     }
412   }
413   catch (Standard_Failure) {
414     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
415     SetErrorCode(aFail->GetMessageString());
416     return NULL;
417   }
418
419   //Make a Python command
420   GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
421                                << thePnt << ", " << theDir << ")";
422
423   SetErrorCode(OK);
424   return aLine;
425 }
426
427 //=============================================================================
428 /*!
429  *  MakeLineTwoPnt
430  */
431 //=============================================================================
432 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
433                      (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2)
434 {
435   SetErrorCode(KO);
436
437   if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
438
439   //Add a new Line object
440   Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE);
441
442   //Add a new Line function
443   Handle(GEOM_Function) aFunction =
444     aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT);
445
446   //Check if the function is set correctly
447   if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL;
448
449   GEOMImpl_ILine aPI (aFunction);
450
451   Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
452   Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
453   if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
454
455   aPI.SetPoint1(aRef1);
456   aPI.SetPoint2(aRef2);
457
458   //Compute the Line value
459   try {
460     if (!GetSolver()->ComputeFunction(aFunction)) {
461       SetErrorCode("Line driver failed");
462       return NULL;
463     }
464   }
465   catch (Standard_Failure) {
466     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
467     SetErrorCode(aFail->GetMessageString());
468     return NULL;
469   }
470
471   //Make a Python command
472   GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
473                                << thePnt1 << ", " << thePnt2 << ")";
474
475   SetErrorCode(OK);
476   return aLine;
477 }
478
479
480 //=============================================================================
481 /*!
482  *  MakePlaneThreePnt
483  */
484 //=============================================================================
485 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
486                      (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2,
487                       Handle(GEOM_Object) thePnt3, double theSize)
488 {
489   SetErrorCode(KO);
490
491   if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
492
493   //Add a new Plane object
494   Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
495
496   //Add a new Plane function
497   Handle(GEOM_Function) aFunction =
498     aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT);
499
500   //Check if the function is set correctly
501   if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
502
503   GEOMImpl_IPlane aPI (aFunction);
504
505   Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
506   Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
507   Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction();
508   if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL;
509
510   aPI.SetPoint1(aRef1);
511   aPI.SetPoint2(aRef2);
512   aPI.SetPoint3(aRef3);
513   aPI.SetSize(theSize);
514
515   //Compute the Plane value
516   try {
517     if (!GetSolver()->ComputeFunction(aFunction)) {
518       SetErrorCode("Plane driver failed");
519       return NULL;
520     }
521   }
522   catch (Standard_Failure) {
523     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
524     SetErrorCode(aFail->GetMessageString());
525     return NULL;
526   }
527
528   //Make a Python command
529   GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
530     << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
531
532   SetErrorCode(OK);
533   return aPlane;
534 }
535
536 //=============================================================================
537 /*!
538  *  MakePlanePntVec
539  */
540 //=============================================================================
541 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
542                        (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
543                         double theSize)
544 {
545   SetErrorCode(KO);
546
547   if (thePnt.IsNull() || theVec.IsNull()) return NULL;
548
549   //Add a new Plane object
550   Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
551
552   //Add a new Plane function
553   Handle(GEOM_Function) aFunction =
554     aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC);
555
556   //Check if the function is set correctly
557   if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
558
559   GEOMImpl_IPlane aPI (aFunction);
560
561   Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
562   Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
563   if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
564
565   aPI.SetPoint(aRefPnt);
566   aPI.SetVector(aRefVec);
567   aPI.SetSize(theSize);
568
569   //Compute the Plane value
570   try {
571     if (!GetSolver()->ComputeFunction(aFunction)) {
572       SetErrorCode("Plane driver failed");
573       return NULL;
574     }
575   }
576   catch (Standard_Failure) {
577     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
578     SetErrorCode(aFail->GetMessageString());
579     return NULL;
580   }
581
582   //Make a Python command
583   GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
584     << thePnt << ", " << theVec << ", " << theSize << ")";
585
586   SetErrorCode(OK);
587   return aPlane;
588 }
589
590 //=============================================================================
591 /*!
592  *  MakePlaneFace
593  */
594 //=============================================================================
595 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
596                        (Handle(GEOM_Object) theFace, double theSize)
597 {
598   SetErrorCode(KO);
599
600   if (theFace.IsNull()) return NULL;
601
602   //Add a new Plane object
603   Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
604
605   //Add a new Plane function
606   Handle(GEOM_Function) aFunction =
607     aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE);
608
609   //Check if the function is set correctly
610   if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
611
612   GEOMImpl_IPlane aPI (aFunction);
613
614   Handle(GEOM_Function) aRef = theFace->GetLastFunction();
615   if (aRef.IsNull()) return NULL;
616
617   aPI.SetFace(aRef);
618   aPI.SetSize(theSize);
619
620   //Compute the Plane value
621   try {
622     if (!GetSolver()->ComputeFunction(aFunction)) {
623       SetErrorCode("Plane driver failed");
624       return NULL;
625     }
626   }
627   catch (Standard_Failure) {
628     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
629     SetErrorCode(aFail->GetMessageString());
630     return NULL;
631   }
632
633   //Make a Python command
634   GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
635                                << theFace << ", " << theSize << ")";
636
637   SetErrorCode(OK);
638   return aPlane;
639 }
640
641
642 //=============================================================================
643 /*!
644  *  MakeMarker
645  */
646 //=============================================================================
647 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
648                                   (double theOX,  double theOY,  double theOZ,
649                                    double theXDX, double theXDY, double theXDZ,
650                                    double theYDX, double theYDY, double theYDZ)
651 {
652   SetErrorCode(KO);
653
654   //Add a new Marker object
655   Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
656
657   //Add a new Marker function
658   Handle(GEOM_Function) aFunction =
659     aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS);
660   if (aFunction.IsNull()) return NULL;
661
662   //Check if the function is set correctly
663   if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
664
665   GEOMImpl_IMarker aPI(aFunction);
666
667   aPI.SetOrigin(theOX, theOY, theOZ);
668   aPI.SetXDir(theXDX, theXDY, theXDZ);
669   aPI.SetYDir(theYDX, theYDY, theYDZ);
670
671   //Compute the marker value
672   try {
673     if (!GetSolver()->ComputeFunction(aFunction)) {
674       SetErrorCode("Marker driver failed");
675       return NULL;
676     }
677   }
678   catch (Standard_Failure) {
679     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
680     SetErrorCode(aFail->GetMessageString());
681     return NULL;
682   }
683
684   //Make a Python command
685   GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
686     << theOX << ", " << theOY << ", " << theOZ << ", "
687       << theXDX << ", " << theXDY << ", " << theXDZ << ", "
688         << theYDX << ", " << theYDY << ", " << theYDZ << ")";
689
690   SetErrorCode(OK);
691   return aMarker;
692 }
693
694 //=============================================================================
695 /*!
696  *  MakeTangentPlaneOnFace
697  */
698 //=============================================================================
699
700 Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
701                                                                       double theParamU,
702                                                                       double theParamV,
703                                                                       double theSize)
704 {
705    SetErrorCode(KO);
706
707   if (theFace.IsNull()) return NULL;
708
709   //Add a new Plane object
710   Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE);
711
712   //Add a new Plane function
713   Handle(GEOM_Function) aFunction =
714     aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE);
715
716   //Check if the function is set correctly
717   if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL;
718
719   GEOMImpl_IPlane aPI (aFunction);
720
721   Handle(GEOM_Function) aRef = theFace->GetLastFunction();
722   if (aRef.IsNull()) return NULL;
723
724   aPI.SetFace(aRef);
725   aPI.SetSize(theSize);
726   aPI.SetParameterU(theParamU);
727   aPI.SetParameterV(theParamV);
728
729   //Compute the Plane value
730   try {
731     if (!GetSolver()->ComputeFunction(aFunction)) {
732       SetErrorCode("Plane driver failed");
733       return NULL;
734     }
735   }
736   catch (Standard_Failure) {
737     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
738     SetErrorCode(aFail->GetMessageString());
739     return NULL;
740   }
741
742   //Make a Python command
743   GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakeTangentPlaneOnFace("
744                                << theFace << ", " <<theParamU <<", "<<theParamV <<", "<< theSize << ")";
745
746   SetErrorCode(OK);
747   return aPlane;
748 }
749
750