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