1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include <Standard_Stream.hxx>
25 #include "GEOM_ICurvesOperations_i.hh"
27 #include "utilities.h"
30 #include "GEOM_Engine.hxx"
31 #include "GEOM_Object.hxx"
33 #include <TColStd_HArray1OfByte.hxx>
34 #include <TColStd_HArray1OfReal.hxx>
36 //=============================================================================
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)
46 MESSAGE("GEOM_ICurvesOperations_i::GEOM_ICurvesOperations_i");
49 //=============================================================================
53 //=============================================================================
54 GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i()
56 MESSAGE("GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i");
60 //=============================================================================
64 //=============================================================================
65 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCirclePntVecR
66 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
69 GEOM::GEOM_Object_var aGEOMObject;
72 GetOperations()->SetNotDone();
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();
79 HANDLE_NAMESPACE(GEOM_Object) aPnt, aVec;
80 if (!CORBA::is_nil(thePnt)) {
81 aPnt = GetObjectImpl(thePnt);
82 if (aPnt.IsNull()) return aGEOMObject._retn();
84 if (!CORBA::is_nil(theVec)) {
85 aVec = GetObjectImpl(theVec);
86 if (aVec.IsNull()) return aGEOMObject._retn();
90 HANDLE_NAMESPACE(GEOM_Object) anObject =
91 GetOperations()->MakeCirclePntVecR(aPnt, aVec, theR);
92 if (!GetOperations()->IsDone() || anObject.IsNull())
93 return aGEOMObject._retn();
95 return GetObject(anObject);
98 //=============================================================================
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)
107 GEOM::GEOM_Object_var aGEOMObject;
109 //Set a not done flag
110 GetOperations()->SetNotDone();
112 //Get the reference points
113 HANDLE_NAMESPACE(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
114 HANDLE_NAMESPACE(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
115 HANDLE_NAMESPACE(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
117 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
120 HANDLE_NAMESPACE(GEOM_Object) anObject =
121 GetOperations()->MakeCircleThreePnt(aPnt1, aPnt2, aPnt3);
122 if (!GetOperations()->IsDone() || anObject.IsNull())
123 return aGEOMObject._retn();
125 return GetObject(anObject);
128 //=============================================================================
130 * MakeCircleCenter2Pnt
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)
137 GEOM::GEOM_Object_var aGEOMObject;
139 //Set a not done flag
140 GetOperations()->SetNotDone();
142 //Get the reference points
143 HANDLE_NAMESPACE(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
144 HANDLE_NAMESPACE(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
145 HANDLE_NAMESPACE(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
147 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
150 HANDLE_NAMESPACE(GEOM_Object) anObject = GetOperations()->MakeCircleCenter2Pnt(aPnt1, aPnt2, aPnt3);
151 if (!GetOperations()->IsDone() || anObject.IsNull())
152 return aGEOMObject._retn();
154 return GetObject(anObject);
157 //=============================================================================
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)
166 GEOM::GEOM_Object_var aGEOMObject;
168 //Set a not done flag
169 GetOperations()->SetNotDone();
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();
176 HANDLE_NAMESPACE(GEOM_Object) aPnt, aVec, aVecMaj;
177 if (!CORBA::is_nil(thePnt)) {
178 aPnt = GetObjectImpl(thePnt);
179 if (aPnt.IsNull()) return aGEOMObject._retn();
181 if (!CORBA::is_nil(theVec)) {
182 aVec = GetObjectImpl(theVec);
183 if (aVec.IsNull()) return aGEOMObject._retn();
187 HANDLE_NAMESPACE(GEOM_Object) anObject =
188 GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor, aVecMaj);
189 if (!GetOperations()->IsDone() || anObject.IsNull())
190 return aGEOMObject._retn();
192 return GetObject(anObject);
195 //=============================================================================
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)
205 GEOM::GEOM_Object_var aGEOMObject;
207 //Set a not done flag
208 GetOperations()->SetNotDone();
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();
216 HANDLE_NAMESPACE(GEOM_Object) aPnt, aVec, aVecMaj;
217 if (!CORBA::is_nil(thePnt)) {
218 aPnt = GetObjectImpl(thePnt);
219 if (aPnt.IsNull()) return aGEOMObject._retn();
221 if (!CORBA::is_nil(theVec)) {
222 aVec = GetObjectImpl(theVec);
223 if (aVec.IsNull()) return aGEOMObject._retn();
225 if (!CORBA::is_nil(theVecMaj)) {
226 aVecMaj = GetObjectImpl(theVecMaj);
227 if (aVecMaj.IsNull()) return aGEOMObject._retn();
231 HANDLE_NAMESPACE(GEOM_Object) anObject =
232 GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor, aVecMaj);
233 if (!GetOperations()->IsDone() || anObject.IsNull())
234 return aGEOMObject._retn();
236 return GetObject(anObject);
239 //=============================================================================
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)
249 GEOM::GEOM_Object_var aGEOMObject;
251 //Set a not done flag
252 GetOperations()->SetNotDone();
254 //Get the reference points
255 HANDLE_NAMESPACE(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
256 HANDLE_NAMESPACE(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
257 HANDLE_NAMESPACE(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
259 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
262 HANDLE_NAMESPACE(GEOM_Object) anObject =
263 GetOperations()->MakeArc(aPnt1, aPnt2, aPnt3);
264 if (!GetOperations()->IsDone() || anObject.IsNull())
265 return aGEOMObject._retn();
267 return GetObject(anObject);
271 //=============================================================================
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)
283 GEOM::GEOM_Object_var aGEOMObject;
284 //Set a not done flag
285 GetOperations()->SetNotDone();
287 //Get the reference points
288 HANDLE_NAMESPACE(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
289 HANDLE_NAMESPACE(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
290 HANDLE_NAMESPACE(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
292 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
295 HANDLE_NAMESPACE(GEOM_Object) anObject =
296 GetOperations()->MakeArcCenter(aPnt1, aPnt2, aPnt3,theSense);
297 if (!GetOperations()->IsDone() || anObject.IsNull())
298 return aGEOMObject._retn();
300 return GetObject(anObject);
303 //=============================================================================
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)
313 GEOM::GEOM_Object_var aGEOMObject;
315 //Set a not done flag
316 GetOperations()->SetNotDone();
318 //Get the reference points
319 HANDLE_NAMESPACE(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
320 HANDLE_NAMESPACE(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
321 HANDLE_NAMESPACE(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
323 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
326 HANDLE_NAMESPACE(GEOM_Object) anObject =
327 GetOperations()->MakeArcOfEllipse(aPnt1, aPnt2, aPnt3);
328 if (!GetOperations()->IsDone() || anObject.IsNull())
329 return aGEOMObject._retn();
331 return GetObject(anObject);
334 //=============================================================================
338 //=============================================================================
339 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline
340 (const GEOM::ListOfGO& thePoints,
341 CORBA::Boolean theIsClosed)
343 GEOM::GEOM_Object_var aGEOMObject;
345 //Set a not done flag
346 GetOperations()->SetNotDone();
348 //Get the reference point
350 int aLen = thePoints.length();
351 std::list<HANDLE_NAMESPACE(GEOM_Object)> aPoints;
352 for (; ind < aLen; ind++) {
353 HANDLE_NAMESPACE(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
354 if (aPnt.IsNull()) return aGEOMObject._retn();
355 aPoints.push_back(aPnt);
359 HANDLE_NAMESPACE(GEOM_Object) anObject =
360 GetOperations()->MakePolyline(aPoints, theIsClosed);
361 if (!GetOperations()->IsDone() || anObject.IsNull())
362 return aGEOMObject._retn();
364 return GetObject(anObject);
367 //=============================================================================
371 //=============================================================================
372 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineBezier
373 (const GEOM::ListOfGO& thePoints,
374 CORBA::Boolean theIsClosed)
376 GEOM::GEOM_Object_var aGEOMObject;
378 //Set a not done flag
379 GetOperations()->SetNotDone();
381 //Get the reference point
383 int aLen = thePoints.length();
384 std::list<HANDLE_NAMESPACE(GEOM_Object)> aPoints;
385 for (; ind < aLen; ind++) {
386 HANDLE_NAMESPACE(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
387 if (aPnt.IsNull()) return aGEOMObject._retn();
388 aPoints.push_back(aPnt);
392 HANDLE_NAMESPACE(GEOM_Object) anObject =
393 GetOperations()->MakeSplineBezier(aPoints, theIsClosed);
394 if (!GetOperations()->IsDone() || anObject.IsNull())
395 return aGEOMObject._retn();
397 return GetObject(anObject);
400 //=============================================================================
402 * MakeSplineInterpolation
404 //=============================================================================
405 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
406 (const GEOM::ListOfGO& thePoints,
407 CORBA::Boolean theIsClosed,
408 CORBA::Boolean theDoReordering)
410 GEOM::GEOM_Object_var aGEOMObject;
412 //Set a not done flag
413 GetOperations()->SetNotDone();
415 //Get the reference point
417 int aLen = thePoints.length();
418 std::list<HANDLE_NAMESPACE(GEOM_Object)> aPoints;
419 for (; ind < aLen; ind++) {
420 HANDLE_NAMESPACE(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
421 if (aPnt.IsNull()) return aGEOMObject._retn();
422 aPoints.push_back(aPnt);
426 HANDLE_NAMESPACE(GEOM_Object) anObject =
427 GetOperations()->MakeSplineInterpolation(aPoints, theIsClosed, theDoReordering);
428 if (!GetOperations()->IsDone() || anObject.IsNull())
429 return aGEOMObject._retn();
431 return GetObject(anObject);
434 //=============================================================================
436 * MakeSplineInterpolWithTangents
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)
444 GEOM::GEOM_Object_var aGEOMObject;
446 //Set a not done flag
447 GetOperations()->SetNotDone();
449 //Get the reference points
451 int aLen = thePoints.length();
452 std::list<HANDLE_NAMESPACE(GEOM_Object)> aPoints;
453 for (; ind < aLen; ind++) {
454 HANDLE_NAMESPACE(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
455 if (aPnt.IsNull()) return aGEOMObject._retn();
456 aPoints.push_back(aPnt);
459 //Get the reference vectors
460 HANDLE_NAMESPACE(GEOM_Object) aVec1 = GetObjectImpl(theFirstVec);
461 HANDLE_NAMESPACE(GEOM_Object) aVec2 = GetObjectImpl(theLastVec);
463 if (aVec1.IsNull() || aVec2.IsNull()) return aGEOMObject._retn();
466 HANDLE_NAMESPACE(GEOM_Object) anObject =
467 GetOperations()->MakeSplineInterpolWithTangents(aPoints, aVec1, aVec2);
468 if (!GetOperations()->IsDone() || anObject.IsNull())
469 return aGEOMObject._retn();
471 return GetObject(anObject);
474 //=============================================================================
476 * MakeCurveParametric
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)
484 GEOM::GEOM_Object_var aGEOMObject;
485 //Set a not done flag
486 GetOperations()->SetNotDone();
488 GEOMImpl_ICurvesOperations::CurveType aType;
489 switch(theCurveType) {
491 aType = GEOMImpl_ICurvesOperations::Polyline;
494 aType = GEOMImpl_ICurvesOperations::Bezier;
496 case GEOM::Interpolation:
497 aType = GEOMImpl_ICurvesOperations::Interpolation;
504 HANDLE_NAMESPACE(GEOM_Object) anObject =
505 GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
506 theParamMin, theParamMax,
507 theParamStep, aType);
509 if (!GetOperations()->IsDone() || anObject.IsNull())
510 return aGEOMObject._retn();
512 return GetObject(anObject);
515 //=============================================================================
517 * MakeCurveParametricNew
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)
525 GEOM::GEOM_Object_var aGEOMObject;
526 //Set a not done flag
527 GetOperations()->SetNotDone();
529 GEOMImpl_ICurvesOperations::CurveType aType;
530 switch(theCurveType) {
532 aType = GEOMImpl_ICurvesOperations::Polyline;
535 aType = GEOMImpl_ICurvesOperations::Bezier;
537 case GEOM::Interpolation:
538 aType = GEOMImpl_ICurvesOperations::Interpolation;
545 HANDLE_NAMESPACE(GEOM_Object) anObject =
546 GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
547 theParamMin, theParamMax,
548 0.0, aType, theParamNbStep, true);
550 if (!GetOperations()->IsDone() || anObject.IsNull())
551 return aGEOMObject._retn();
553 return GetObject(anObject);
556 //=============================================================================
560 //=============================================================================
561 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeIsoline
562 (GEOM::GEOM_Object_ptr theFace,
563 CORBA::Boolean IsUIsoline,
566 GEOM::GEOM_Object_var aGEOMObject;
568 //Set a not done flag
569 GetOperations()->SetNotDone();
571 HANDLE_NAMESPACE(GEOM_Object) aFace = GetObjectImpl(theFace);
574 HANDLE_NAMESPACE(GEOM_Object) anObject =
575 GetOperations()->MakeIsoline(aFace, IsUIsoline, theParameter);
576 if (!GetOperations()->IsDone() || anObject.IsNull())
577 return aGEOMObject._retn();
579 return GetObject(anObject);
582 //=============================================================================
586 //=============================================================================
587 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
588 (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane)
590 //Set a not done flag
591 GetOperations()->SetNotDone();
594 int aLen = theWorkingPlane.length();
595 std::list<double> aWorkingPlane;
596 for (; ind < aLen; ind++)
597 aWorkingPlane.push_back(theWorkingPlane[ind]);
600 HANDLE_NAMESPACE(GEOM_Object) anObject =
601 GetOperations()->MakeSketcher(theCommand, aWorkingPlane);
602 if (!GetOperations()->IsDone() || anObject.IsNull())
603 return GEOM::GEOM_Object::_nil();
605 return GetObject(anObject);
608 //=============================================================================
610 * MakeSketcherOnPlane
612 //=============================================================================
613 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
614 (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
616 //Set a not done flag
617 GetOperations()->SetNotDone();
619 HANDLE_NAMESPACE(GEOM_Object) aWorkingPlane = GetObjectImpl(theWorkingPlane);
622 HANDLE_NAMESPACE(GEOM_Object) anObject =
623 GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane);
624 if (!GetOperations()->IsDone() || anObject.IsNull())
625 return GEOM::GEOM_Object::_nil();
627 return GetObject(anObject);
630 //=============================================================================
632 * Make3DSketcherCommand
634 //=============================================================================
635 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcherCommand (const char* theCommand)
637 //Set a not done flag
638 GetOperations()->SetNotDone();
641 HANDLE_NAMESPACE(GEOM_Object) anObject = GetOperations()->Make3DSketcherCommand(theCommand);
642 if (!GetOperations()->IsDone() || anObject.IsNull())
643 return GEOM::GEOM_Object::_nil();
645 return GetObject(anObject);
648 //=============================================================================
652 //=============================================================================
653 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher
654 (const GEOM::ListOfDouble& theCoordinates)
656 //Set a not done flag
657 GetOperations()->SetNotDone();
660 int aLen = theCoordinates.length();
661 std::list<double> aCoords;
662 for (; ind < aLen; ind++)
663 aCoords.push_back(theCoordinates[ind]);
666 HANDLE_NAMESPACE(GEOM_Object) anObject =
667 GetOperations()->Make3DSketcher(aCoords);
668 if (!GetOperations()->IsDone() || anObject.IsNull())
669 return GEOM::GEOM_Object::_nil();
671 return GetObject(anObject);
674 //=============================================================================
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)
686 //Set a not done flag
687 GetOperations()->SetNotDone();
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;
698 ConvertListListDouble(theCoordsList, aCoords);
700 Handle(TColStd_HArray1OfReal) aWorkingPlane;
701 const int n = theWorkingPlane.length();
705 aWorkingPlane = new TColStd_HArray1OfReal(1, n);
707 for (i = 0; i < n; i++) {
708 aWorkingPlane->SetValue(i + 1, theWorkingPlane[i]);
713 HANDLE_NAMESPACE(GEOM_Object) anObject = GetOperations()->MakePolyline2D
714 (aCoords, aNames, aTypes, aCloseds, aWorkingPlane);
716 if (!GetOperations()->IsDone() || anObject.IsNull()) {
717 return GEOM::GEOM_Object::_nil();
720 return GetObject(anObject);
723 //=============================================================================
725 * MakePolylineOnPlane
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)
735 //Set a not done flag
736 GetOperations()->SetNotDone();
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_NAMESPACE(GEOM_Object) aWorkingPlane =
747 GetObjectImpl(theWorkingPlane);
749 ConvertListListDouble(theCoordsList, aCoords);
752 HANDLE_NAMESPACE(GEOM_Object) anObject = GetOperations()->MakePolyline2DOnPlane
753 (aCoords, aNames, aTypes, aCloseds, aWorkingPlane);
755 if (!GetOperations()->IsDone() || anObject.IsNull()) {
756 return GEOM::GEOM_Object::_nil();
759 return GetObject(anObject);
762 //=============================================================================
766 //=============================================================================
767 Handle(TColStd_HArray1OfByte) GEOM_ICurvesOperations_i::ConvertEnumArray
768 (const GEOM::short_array &theInArray)
770 Handle(TColStd_HArray1OfByte) anOutArray;
771 const int n = theInArray.length();
778 anOutArray = new TColStd_HArray1OfByte(1, n);
780 for (i = 0; i < n; i++) {
782 GEOMImpl_ICurvesOperations::CurveType aType;
784 switch(theInArray[i]) {
786 aType = GEOMImpl_ICurvesOperations::Polyline;
789 aType = GEOMImpl_ICurvesOperations::Bezier;
791 case GEOM::Interpolation:
792 aType = GEOMImpl_ICurvesOperations::Interpolation;
800 anOutArray->SetValue(i + 1, aType);
802 anOutArray.Nullify();
810 //=============================================================================
814 //=============================================================================
815 Handle(TColStd_HArray1OfByte) GEOM_ICurvesOperations_i::ConvertBoolArray
816 (const GEOM::ListOfBool &theInArray)
818 Handle(TColStd_HArray1OfByte) anOutArray;
819 const int n = theInArray.length();
826 anOutArray = new TColStd_HArray1OfByte(1, n);
828 for (i = 0; i < n; i++) {
829 anOutArray->SetValue(i + 1, theInArray[i]);
835 //=============================================================================
837 * ConvertListListDouble
839 //=============================================================================
840 void GEOM_ICurvesOperations_i::ConvertListListDouble
841 (const GEOM::ListOfListOfDouble &theInList,
842 std::list <std::list <double> > &theOutList)
844 const int n = theInList.length();
846 std::list <double> anEmptyList;
848 for (i = 0; i < n; i++) {
849 theOutList.push_back(anEmptyList);
851 const int m = theInList[i].length();
854 for (j = 0; j < m; j++) {
855 theOutList.back().push_back(theInList[i][j]);