Salome HOME
fb28bff70b10b657f23e39f407b245334ef7bad5
[modules/geom.git] / src / GEOM_I / GEOM_ICurvesOperations_i.cc
1 // Copyright (C) 2007-2020  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, or (at your option) any later version.
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
23 #include <Standard_Stream.hxx>
24
25 #include "GEOM_ICurvesOperations_i.hh"
26
27 #include "utilities.h"
28 #include "OpUtil.hxx"
29
30 #include "GEOM_Engine.hxx"
31 #include "GEOM_Object.hxx"
32
33 #include <TColStd_HArray1OfByte.hxx>
34 #include <TColStd_HArray1OfReal.hxx>
35
36 //=============================================================================
37 /*!
38  *   constructor:
39  */
40 //=============================================================================
41 GEOM_ICurvesOperations_i::GEOM_ICurvesOperations_i (PortableServer::POA_ptr thePOA,
42                                                     GEOM::GEOM_Gen_ptr theEngine,
43                                                     ::GEOMImpl_ICurvesOperations* theImpl)
44 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
45 {
46   MESSAGE("GEOM_ICurvesOperations_i::GEOM_ICurvesOperations_i");
47 }
48
49 //=============================================================================
50 /*!
51  *  destructor
52  */
53 //=============================================================================
54 GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i()
55 {
56   MESSAGE("GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i");
57 }
58
59
60 //=============================================================================
61 /*!
62  *  MakeCirclePntVecR
63  */
64 //=============================================================================
65 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCirclePntVecR
66                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
67                        CORBA::Double theR)
68 {
69   GEOM::GEOM_Object_var aGEOMObject;
70
71   //Set a not done flag
72   GetOperations()->SetNotDone();
73
74   // Not set thePnt means origin of global CS,
75   // Not set theVec means Z axis of global CS
76   //if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
77
78   //Get the arguments
79   Handle(::GEOM_Object) aPnt, aVec;
80   if (!CORBA::is_nil(thePnt)) {
81     aPnt = GetObjectImpl(thePnt);
82     if (aPnt.IsNull()) return aGEOMObject._retn();
83   }
84   if (!CORBA::is_nil(theVec)) {
85     aVec = GetObjectImpl(theVec);
86     if (aVec.IsNull()) return aGEOMObject._retn();
87   }
88
89   // Make Circle
90   Handle(::GEOM_Object) anObject =
91     GetOperations()->MakeCirclePntVecR(aPnt, aVec, theR);
92   if (!GetOperations()->IsDone() || anObject.IsNull())
93     return aGEOMObject._retn();
94
95   return GetObject(anObject);
96 }
97
98 //=============================================================================
99 /*!
100  *  MakeCircleThreePnt
101  */
102 //=============================================================================
103 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleThreePnt
104                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
105                        GEOM::GEOM_Object_ptr thePnt3)
106 {
107   GEOM::GEOM_Object_var aGEOMObject;
108
109   //Set a not done flag
110   GetOperations()->SetNotDone();
111
112   //Get the reference points
113   Handle(::GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
114   Handle(::GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
115   Handle(::GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
116
117   if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
118
119   // Make Circle
120   Handle(::GEOM_Object) anObject =
121       GetOperations()->MakeCircleThreePnt(aPnt1, aPnt2, aPnt3);
122   if (!GetOperations()->IsDone() || anObject.IsNull())
123     return aGEOMObject._retn();
124
125   return GetObject(anObject);
126 }
127
128 //=============================================================================
129 /*!
130  *  MakeCircleCenter2Pnt
131  */
132 //=============================================================================
133 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleCenter2Pnt
134                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
135                        GEOM::GEOM_Object_ptr thePnt3)
136 {
137   GEOM::GEOM_Object_var aGEOMObject;
138
139   //Set a not done flag
140   GetOperations()->SetNotDone();
141
142   //Get the reference points
143   Handle(::GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
144   Handle(::GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
145   Handle(::GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
146
147   if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
148
149   // Make Circle
150   Handle(::GEOM_Object) anObject = GetOperations()->MakeCircleCenter2Pnt(aPnt1, aPnt2, aPnt3);
151   if (!GetOperations()->IsDone() || anObject.IsNull())
152     return aGEOMObject._retn();
153
154   return GetObject(anObject);
155 }
156
157 //=============================================================================
158 /*!
159  *  MakeEllipse
160  */
161 //=============================================================================
162 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipse
163                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
164                        CORBA::Double theRMajor, double theRMinor)
165 {
166   GEOM::GEOM_Object_var aGEOMObject;
167
168   //Set a not done flag
169   GetOperations()->SetNotDone();
170
171   // Not set thePnt means origin of global CS,
172   // Not set theVec means Z axis of global CS
173   //if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
174
175   //Get the arguments
176   Handle(::GEOM_Object) aPnt, aVec, aVecMaj;
177   if (!CORBA::is_nil(thePnt)) {
178     aPnt = GetObjectImpl(thePnt);
179     if (aPnt.IsNull()) return aGEOMObject._retn();
180   }
181   if (!CORBA::is_nil(theVec)) {
182     aVec = GetObjectImpl(theVec);
183     if (aVec.IsNull()) return aGEOMObject._retn();
184   }
185
186   // Make Ellipse
187   Handle(::GEOM_Object) anObject =
188     GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor, aVecMaj);
189   if (!GetOperations()->IsDone() || anObject.IsNull())
190     return aGEOMObject._retn();
191
192   return GetObject(anObject);
193 }
194
195 //=============================================================================
196 /*!
197  *  MakeEllipseVec
198  */
199 //=============================================================================
200 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipseVec
201                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
202                        CORBA::Double theRMajor, double theRMinor,
203                        GEOM::GEOM_Object_ptr theVecMaj)
204 {
205   GEOM::GEOM_Object_var aGEOMObject;
206
207   //Set a not done flag
208   GetOperations()->SetNotDone();
209
210   // Not set thePnt means origin of global CS,
211   // Not set theVec means Z axis of global CS
212   // Not set theVecMaj means X axis of global CS
213   //if (thePnt == NULL || theVec == NULL || theVecMaj == NULL) return aGEOMObject._retn();
214
215   //Get the arguments
216   Handle(::GEOM_Object) aPnt, aVec, aVecMaj;
217   if (!CORBA::is_nil(thePnt)) {
218     aPnt = GetObjectImpl(thePnt);
219     if (aPnt.IsNull()) return aGEOMObject._retn();
220   }
221   if (!CORBA::is_nil(theVec)) {
222     aVec = GetObjectImpl(theVec);
223     if (aVec.IsNull()) return aGEOMObject._retn();
224   }
225   if (!CORBA::is_nil(theVecMaj)) {
226     aVecMaj = GetObjectImpl(theVecMaj);
227     if (aVecMaj.IsNull()) return aGEOMObject._retn();
228   }
229
230   // Make Ellipse
231   Handle(::GEOM_Object) anObject =
232     GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor, aVecMaj);
233   if (!GetOperations()->IsDone() || anObject.IsNull())
234     return aGEOMObject._retn();
235
236   return GetObject(anObject);
237 }
238
239 //=============================================================================
240 /*!
241  *  MakeArc
242  */
243 //=============================================================================
244 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArc
245                                                 (GEOM::GEOM_Object_ptr thePnt1,
246                                                  GEOM::GEOM_Object_ptr thePnt2,
247                                                  GEOM::GEOM_Object_ptr thePnt3)
248 {
249   GEOM::GEOM_Object_var aGEOMObject;
250
251   //Set a not done flag
252   GetOperations()->SetNotDone();
253
254   //Get the reference points
255   Handle(::GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
256   Handle(::GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
257   Handle(::GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
258
259   if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
260
261   // Make Arc
262   Handle(::GEOM_Object) anObject =
263     GetOperations()->MakeArc(aPnt1, aPnt2, aPnt3);
264   if (!GetOperations()->IsDone() || anObject.IsNull())
265     return aGEOMObject._retn();
266
267   return GetObject(anObject);
268 }
269
270
271 //=============================================================================
272 /*!
273  *  MakeArcCenter
274  */
275 //=============================================================================
276 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcCenter
277     (GEOM::GEOM_Object_ptr thePnt1,
278      GEOM::GEOM_Object_ptr thePnt2,
279      GEOM::GEOM_Object_ptr thePnt3,
280      CORBA::Boolean theSense)
281
282 {
283   GEOM::GEOM_Object_var aGEOMObject;
284   //Set a not done flag
285   GetOperations()->SetNotDone();
286
287   //Get the reference points
288   Handle(::GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
289   Handle(::GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
290   Handle(::GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
291
292   if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
293
294   // Make ArcCenter
295   Handle(::GEOM_Object) anObject =
296       GetOperations()->MakeArcCenter(aPnt1, aPnt2, aPnt3,theSense);
297   if (!GetOperations()->IsDone() || anObject.IsNull())
298     return aGEOMObject._retn();
299
300   return GetObject(anObject);
301 }
302
303 //=============================================================================
304 /*!
305  *  MakeArc
306  */
307 //=============================================================================
308 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcOfEllipse
309                                                 (GEOM::GEOM_Object_ptr thePnt1,
310                                                  GEOM::GEOM_Object_ptr thePnt2,
311                                                  GEOM::GEOM_Object_ptr thePnt3)
312 {
313   GEOM::GEOM_Object_var aGEOMObject;
314
315   //Set a not done flag
316   GetOperations()->SetNotDone();
317
318   //Get the reference points
319   Handle(::GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
320   Handle(::GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
321   Handle(::GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
322
323   if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
324
325   // Make Arc
326   Handle(::GEOM_Object) anObject =
327     GetOperations()->MakeArcOfEllipse(aPnt1, aPnt2, aPnt3);
328   if (!GetOperations()->IsDone() || anObject.IsNull())
329     return aGEOMObject._retn();
330
331   return GetObject(anObject);
332 }
333
334 //=============================================================================
335 /*!
336  *  MakePolyline
337  */
338 //=============================================================================
339 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline
340                                     (const GEOM::ListOfGO& thePoints,
341                                      CORBA::Boolean        theIsClosed)
342 {
343   GEOM::GEOM_Object_var aGEOMObject;
344
345   //Set a not done flag
346   GetOperations()->SetNotDone();
347
348   //Get the reference point
349   int ind = 0;
350   int aLen = thePoints.length();
351   std::list<Handle(::GEOM_Object)> aPoints;
352   for (; ind < aLen; ind++) {
353     Handle(::GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
354     if (aPnt.IsNull()) return aGEOMObject._retn();
355     aPoints.push_back(aPnt);
356   }
357
358   // Make Polyline
359   Handle(::GEOM_Object) anObject =
360     GetOperations()->MakePolyline(aPoints, theIsClosed);
361   if (!GetOperations()->IsDone() || anObject.IsNull())
362     return aGEOMObject._retn();
363
364   return GetObject(anObject);
365 }
366
367 //=============================================================================
368 /*!
369  *  MakeSplineBezier
370  */
371 //=============================================================================
372 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineBezier
373                                               (const GEOM::ListOfGO& thePoints,
374                                                CORBA::Boolean        theIsClosed)
375 {
376   GEOM::GEOM_Object_var aGEOMObject;
377
378   //Set a not done flag
379   GetOperations()->SetNotDone();
380
381   //Get the reference point
382   int ind = 0;
383   int aLen = thePoints.length();
384   std::list<Handle(::GEOM_Object)> aPoints;
385   for (; ind < aLen; ind++) {
386     Handle(::GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
387     if (aPnt.IsNull()) return aGEOMObject._retn();
388     aPoints.push_back(aPnt);
389   }
390
391   // Make Bezier curve
392   Handle(::GEOM_Object) anObject =
393       GetOperations()->MakeSplineBezier(aPoints, theIsClosed);
394   if (!GetOperations()->IsDone() || anObject.IsNull())
395     return aGEOMObject._retn();
396
397   return GetObject(anObject);
398 }
399
400 //=============================================================================
401 /*!
402  *  MakeSplineInterpolation
403  */
404 //=============================================================================
405 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
406                                               (const GEOM::ListOfGO& thePoints,
407                                                CORBA::Boolean        theIsClosed,
408                                                CORBA::Boolean        theDoReordering)
409 {
410   GEOM::GEOM_Object_var aGEOMObject;
411
412   //Set a not done flag
413   GetOperations()->SetNotDone();
414
415   //Get the reference point
416   int ind = 0;
417   int aLen = thePoints.length();
418   std::list<Handle(::GEOM_Object)> aPoints;
419   for (; ind < aLen; ind++) {
420     Handle(::GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
421     if (aPnt.IsNull()) return aGEOMObject._retn();
422     aPoints.push_back(aPnt);
423   }
424
425   // Make Polyline
426   Handle(::GEOM_Object) anObject =
427     GetOperations()->MakeSplineInterpolation(aPoints, theIsClosed, theDoReordering);
428   if (!GetOperations()->IsDone() || anObject.IsNull())
429     return aGEOMObject._retn();
430
431   return GetObject(anObject);
432 }
433
434 //=============================================================================
435 /*!
436  *  MakeSplineInterpolWithTangents
437  */
438 //=============================================================================
439 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolWithTangents
440                                               (const GEOM::ListOfGO& thePoints,
441                                                GEOM::GEOM_Object_ptr theFirstVec,
442                                                GEOM::GEOM_Object_ptr theLastVec)
443 {
444   GEOM::GEOM_Object_var aGEOMObject;
445
446   //Set a not done flag
447   GetOperations()->SetNotDone();
448
449   //Get the reference points
450   int ind = 0;
451   int aLen = thePoints.length();
452   std::list<Handle(::GEOM_Object)> aPoints;
453   for (; ind < aLen; ind++) {
454     Handle(::GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
455     if (aPnt.IsNull()) return aGEOMObject._retn();
456     aPoints.push_back(aPnt);
457   }
458
459   //Get the reference vectors
460   Handle(::GEOM_Object) aVec1 = GetObjectImpl(theFirstVec);
461   Handle(::GEOM_Object) aVec2 = GetObjectImpl(theLastVec);
462
463   if (aVec1.IsNull() || aVec2.IsNull()) return aGEOMObject._retn();
464
465   // Make Polyline
466   Handle(::GEOM_Object) anObject =
467     GetOperations()->MakeSplineInterpolWithTangents(aPoints, aVec1, aVec2);
468   if (!GetOperations()->IsDone() || anObject.IsNull())
469     return aGEOMObject._retn();
470
471   return GetObject(anObject);
472 }
473
474 //=============================================================================
475 /*!
476  *  MakeCurveParametric
477  */
478 //=============================================================================
479 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric
480              (const char* thexExpr, const char* theyExpr, const char* thezExpr,
481               double theParamMin, double theParamMax, double theParamStep,
482               GEOM::curve_type theCurveType)
483 {
484   GEOM::GEOM_Object_var aGEOMObject;
485   //Set a not done flag
486   GetOperations()->SetNotDone();
487
488   GEOMImpl_ICurvesOperations::CurveType aType = GEOMImpl_ICurvesOperations::Polyline; // todo: aType must be explicitly initialized to avoid warning
489   switch(theCurveType) {
490   case GEOM::Polyline:
491     aType = GEOMImpl_ICurvesOperations::Polyline;
492     break;
493   case GEOM::Bezier:
494     aType = GEOMImpl_ICurvesOperations::Bezier;
495     break;
496   case GEOM::Interpolation:
497     aType = GEOMImpl_ICurvesOperations::Interpolation;
498     break;
499   default:
500     break;
501   }
502
503   // Make Polyline
504   Handle(::GEOM_Object) anObject =
505     GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
506                                          theParamMin, theParamMax,
507                                          theParamStep, aType);
508
509   if (!GetOperations()->IsDone() || anObject.IsNull())
510     return aGEOMObject._retn();
511
512   return GetObject(anObject);
513 }
514
515 //=============================================================================
516 /*!
517  *  MakeCurveParametricNew
518  */
519 //=============================================================================
520 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew
521              (const char* thexExpr, const char* theyExpr, const char* thezExpr,
522               double theParamMin, double theParamMax, CORBA::Long theParamNbStep,
523               GEOM::curve_type theCurveType)
524 {
525   GEOM::GEOM_Object_var aGEOMObject;
526   //Set a not done flag
527   GetOperations()->SetNotDone();
528
529   GEOMImpl_ICurvesOperations::CurveType aType = GEOMImpl_ICurvesOperations::Polyline; // todo: aType must be explicitly initialized to avoid warning
530   switch(theCurveType) {
531   case GEOM::Polyline:
532     aType = GEOMImpl_ICurvesOperations::Polyline;
533     break;
534   case GEOM::Bezier:
535     aType = GEOMImpl_ICurvesOperations::Bezier;
536     break;
537   case GEOM::Interpolation:
538     aType = GEOMImpl_ICurvesOperations::Interpolation;
539     break;
540   default:
541     break;
542   }
543
544   // Make Polyline
545   Handle(::GEOM_Object) anObject =
546     GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
547                        theParamMin, theParamMax,
548                        0.0, aType, theParamNbStep, true);
549
550   if (!GetOperations()->IsDone() || anObject.IsNull())
551     return aGEOMObject._retn();
552
553   return GetObject(anObject);
554 }
555
556 //=============================================================================
557 /*!
558  *  MakeIsoline
559  */
560 //=============================================================================
561 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeIsoline
562                                          (GEOM::GEOM_Object_ptr theFace,
563                                           CORBA::Boolean        IsUIsoline,
564                                           double                theParameter)
565 {
566   GEOM::GEOM_Object_var aGEOMObject;
567
568   //Set a not done flag
569   GetOperations()->SetNotDone();
570
571   Handle(::GEOM_Object) aFace = GetObjectImpl(theFace);
572
573   // Make isoline
574   Handle(::GEOM_Object) anObject =
575     GetOperations()->MakeIsoline(aFace, IsUIsoline, theParameter);
576   if (!GetOperations()->IsDone() || anObject.IsNull())
577     return aGEOMObject._retn();
578
579   return GetObject(anObject);
580 }
581
582 //=============================================================================
583 /*!
584  *  MakeSketcher
585  */
586 //=============================================================================
587 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
588             (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane)
589 {
590   //Set a not done flag
591   GetOperations()->SetNotDone();
592
593   int ind = 0;
594   int aLen = theWorkingPlane.length();
595   std::list<double> aWorkingPlane;
596   for (; ind < aLen; ind++)
597     aWorkingPlane.push_back(theWorkingPlane[ind]);
598
599   // Make Sketcher
600   Handle(::GEOM_Object) anObject =
601     GetOperations()->MakeSketcher(theCommand, aWorkingPlane);
602   if (!GetOperations()->IsDone() || anObject.IsNull())
603     return GEOM::GEOM_Object::_nil();
604
605   return GetObject(anObject);
606 }
607
608 //=============================================================================
609 /*!
610  *  MakeSketcherOnPlane
611  */
612 //=============================================================================
613 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
614                 (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
615 {
616   //Set a not done flag
617   GetOperations()->SetNotDone();
618
619   Handle(::GEOM_Object) aWorkingPlane = GetObjectImpl(theWorkingPlane);
620
621   // Make Sketcher
622   Handle(::GEOM_Object) anObject =
623       GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane);
624   if (!GetOperations()->IsDone() || anObject.IsNull())
625     return GEOM::GEOM_Object::_nil();
626
627   return GetObject(anObject);
628 }
629
630 //=============================================================================
631 /*!
632  *  Make3DSketcherCommand
633  */
634 //=============================================================================
635 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcherCommand (const char* theCommand)
636 {
637   //Set a not done flag
638   GetOperations()->SetNotDone();
639
640   // Make 3D Sketcher
641   Handle(::GEOM_Object) anObject = GetOperations()->Make3DSketcherCommand(theCommand);
642   if (!GetOperations()->IsDone() || anObject.IsNull())
643     return GEOM::GEOM_Object::_nil();
644
645   return GetObject(anObject);
646 }
647
648 //=============================================================================
649 /*!
650  *  Make3DSketcher
651  */
652 //=============================================================================
653 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher
654             (const GEOM::ListOfDouble& theCoordinates)
655 {
656   //Set a not done flag
657   GetOperations()->SetNotDone();
658
659   int ind = 0;
660   int aLen = theCoordinates.length();
661   std::list<double> aCoords;
662   for (; ind < aLen; ind++)
663     aCoords.push_back(theCoordinates[ind]);
664
665   // Make Sketcher
666   Handle(::GEOM_Object) anObject =
667     GetOperations()->Make3DSketcher(aCoords);
668   if (!GetOperations()->IsDone() || anObject.IsNull())
669     return GEOM::GEOM_Object::_nil();
670
671   return GetObject(anObject);
672 }
673
674 //=============================================================================
675 /*!
676  *  MakePolyline2D
677  */
678 //=============================================================================
679 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline2D
680                 (const GEOM::ListOfListOfDouble &theCoordsList,
681                  const GEOM::string_array       &theNamesList,
682                  const GEOM::short_array        &theTypesList,
683                  const GEOM::ListOfBool         &theClosedList,
684                  const GEOM::ListOfDouble       &theWorkingPlane)
685 {
686   //Set a not done flag
687   GetOperations()->SetNotDone();
688
689   // Convert input data
690   Handle(TColStd_HArray1OfExtendedString) aNames   =
691     ConvertStringArray(theNamesList);
692   Handle(TColStd_HArray1OfByte)           aTypes   =
693     ConvertEnumArray(theTypesList);
694   Handle(TColStd_HArray1OfByte)           aCloseds =
695     ConvertBoolArray(theClosedList);
696   std::list <std::list <double> >         aCoords;
697
698   ConvertListListDouble(theCoordsList, aCoords);
699
700   Handle(TColStd_HArray1OfReal) aWorkingPlane;
701   const int                     n = theWorkingPlane.length();
702   int                           i;
703
704   if (n > 0) {
705     aWorkingPlane = new TColStd_HArray1OfReal(1, n);
706
707     for (i = 0; i < n; i++) {
708       aWorkingPlane->SetValue(i + 1, theWorkingPlane[i]);
709     }
710   }
711
712   // Make Polyline
713   Handle(::GEOM_Object) anObject = GetOperations()->MakePolyline2D
714             (aCoords, aNames, aTypes, aCloseds, aWorkingPlane);
715
716   if (!GetOperations()->IsDone() || anObject.IsNull()) {
717     return GEOM::GEOM_Object::_nil();
718   }
719
720   return GetObject(anObject);
721 }
722
723 //=============================================================================
724 /*!
725  *  MakePolylineOnPlane
726  */
727 //=============================================================================
728 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline2DOnPlane
729                 (const GEOM::ListOfListOfDouble &theCoordsList,
730                  const GEOM::string_array       &theNamesList,
731                  const GEOM::short_array        &theTypesList,
732                  const GEOM::ListOfBool         &theClosedList,
733                  GEOM::GEOM_Object_ptr           theWorkingPlane)
734 {
735   //Set a not done flag
736   GetOperations()->SetNotDone();
737
738   // Convert input data
739   Handle(TColStd_HArray1OfExtendedString) aNames        =
740     ConvertStringArray(theNamesList);
741   Handle(TColStd_HArray1OfByte)           aTypes        =
742     ConvertEnumArray(theTypesList);
743   Handle(TColStd_HArray1OfByte)           aCloseds      =
744     ConvertBoolArray(theClosedList);
745   std::list <std::list <double> >         aCoords;
746   Handle(::GEOM_Object)                     aWorkingPlane =
747     GetObjectImpl(theWorkingPlane);
748
749   ConvertListListDouble(theCoordsList, aCoords);
750
751   // Make Polyline
752   Handle(::GEOM_Object) anObject = GetOperations()->MakePolyline2DOnPlane
753             (aCoords, aNames, aTypes, aCloseds, aWorkingPlane);
754
755   if (!GetOperations()->IsDone() || anObject.IsNull()) {
756     return GEOM::GEOM_Object::_nil();
757   }
758
759   return GetObject(anObject);
760 }
761
762 //=============================================================================
763 /*!
764  *  ConvertEnumArray
765  */
766 //=============================================================================
767 Handle(TColStd_HArray1OfByte) GEOM_ICurvesOperations_i::ConvertEnumArray
768                 (const GEOM::short_array &theInArray)
769 {
770   Handle(TColStd_HArray1OfByte) anOutArray;
771   const int                     n = theInArray.length();
772   int                           i;
773
774   if (n <= 0) {
775     return anOutArray;
776   }
777
778   anOutArray = new TColStd_HArray1OfByte(1, n);
779
780   for (i = 0; i < n; i++) {
781     bool                                  isOK = true;
782     GEOMImpl_ICurvesOperations::CurveType aType;
783
784     switch(theInArray[i]) {
785       case GEOM::Polyline:
786         aType = GEOMImpl_ICurvesOperations::Polyline;
787         break;
788       case GEOM::Bezier:
789         aType = GEOMImpl_ICurvesOperations::Bezier;
790         break;
791       case GEOM::Interpolation:
792         aType = GEOMImpl_ICurvesOperations::Interpolation;
793         break;
794       default:
795         isOK = false;
796         break;
797     }
798
799     if (isOK) {
800       anOutArray->SetValue(i + 1, aType);
801     } else {
802       anOutArray.Nullify();
803       break;
804     }
805   }
806
807   return anOutArray;
808 }
809
810 //=============================================================================
811 /*!
812  *  ConvertBoolArray
813  */
814 //=============================================================================
815 Handle(TColStd_HArray1OfByte) GEOM_ICurvesOperations_i::ConvertBoolArray
816                 (const GEOM::ListOfBool &theInArray)
817 {
818   Handle(TColStd_HArray1OfByte) anOutArray;
819   const int                     n = theInArray.length();
820   int                           i;
821
822   if (n <= 0) {
823     return anOutArray;
824   }
825
826   anOutArray = new TColStd_HArray1OfByte(1, n);
827
828   for (i = 0; i < n; i++) {
829     anOutArray->SetValue(i + 1, theInArray[i]);
830   }
831
832   return anOutArray;
833 }
834
835 //=============================================================================
836 /*!
837  *  ConvertListListDouble
838  */
839 //=============================================================================
840 void GEOM_ICurvesOperations_i::ConvertListListDouble
841             (const GEOM::ListOfListOfDouble        &theInList,
842                    std::list <std::list <double> > &theOutList)
843 {
844   const int          n = theInList.length();
845   int                i;
846   std::list <double> anEmptyList;
847
848   for (i = 0; i < n; i++) {
849     theOutList.push_back(anEmptyList);
850
851     const int m = theInList[i].length();
852     int       j;
853
854     for (j = 0; j < m; j++) {
855       theOutList.back().push_back(theInList[i][j]);
856     }
857   }
858 }