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