1 // Copyright (C) 2007-2013 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.
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 //=============================================================================
37 //=============================================================================
38 GEOM_ICurvesOperations_i::GEOM_ICurvesOperations_i (PortableServer::POA_ptr thePOA,
39 GEOM::GEOM_Gen_ptr theEngine,
40 ::GEOMImpl_ICurvesOperations* theImpl)
41 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
43 MESSAGE("GEOM_ICurvesOperations_i::GEOM_ICurvesOperations_i");
46 //=============================================================================
50 //=============================================================================
51 GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i()
53 MESSAGE("GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i");
57 //=============================================================================
61 //=============================================================================
62 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCirclePntVecR
63 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
66 GEOM::GEOM_Object_var aGEOMObject;
69 GetOperations()->SetNotDone();
71 // Not set thePnt means origin of global CS,
72 // Not set theVec means Z axis of global CS
73 //if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
76 Handle(GEOM_Object) aPnt, aVec;
77 if (!CORBA::is_nil(thePnt)) {
78 aPnt = GetObjectImpl(thePnt);
79 if (aPnt.IsNull()) return aGEOMObject._retn();
81 if (!CORBA::is_nil(theVec)) {
82 aVec = GetObjectImpl(theVec);
83 if (aVec.IsNull()) return aGEOMObject._retn();
87 Handle(GEOM_Object) anObject =
88 GetOperations()->MakeCirclePntVecR(aPnt, aVec, theR);
89 if (!GetOperations()->IsDone() || anObject.IsNull())
90 return aGEOMObject._retn();
92 return GetObject(anObject);
95 //=============================================================================
99 //=============================================================================
100 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleThreePnt
101 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
102 GEOM::GEOM_Object_ptr thePnt3)
104 GEOM::GEOM_Object_var aGEOMObject;
106 //Set a not done flag
107 GetOperations()->SetNotDone();
109 //Get the reference points
110 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
111 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
112 Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
114 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
117 Handle(GEOM_Object) anObject =
118 GetOperations()->MakeCircleThreePnt(aPnt1, aPnt2, aPnt3);
119 if (!GetOperations()->IsDone() || anObject.IsNull())
120 return aGEOMObject._retn();
122 return GetObject(anObject);
125 //=============================================================================
127 * MakeCircleCenter2Pnt
129 //=============================================================================
130 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleCenter2Pnt
131 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
132 GEOM::GEOM_Object_ptr thePnt3)
134 GEOM::GEOM_Object_var aGEOMObject;
136 //Set a not done flag
137 GetOperations()->SetNotDone();
139 //Get the reference points
140 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
141 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
142 Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
144 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
147 Handle(GEOM_Object) anObject = GetOperations()->MakeCircleCenter2Pnt(aPnt1, aPnt2, aPnt3);
148 if (!GetOperations()->IsDone() || anObject.IsNull())
149 return aGEOMObject._retn();
151 return GetObject(anObject);
154 //=============================================================================
158 //=============================================================================
159 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipse
160 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
161 CORBA::Double theRMajor, double theRMinor)
163 GEOM::GEOM_Object_var aGEOMObject;
165 //Set a not done flag
166 GetOperations()->SetNotDone();
168 // Not set thePnt means origin of global CS,
169 // Not set theVec means Z axis of global CS
170 //if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
173 Handle(GEOM_Object) aPnt, aVec, aVecMaj;
174 if (!CORBA::is_nil(thePnt)) {
175 aPnt = GetObjectImpl(thePnt);
176 if (aPnt.IsNull()) return aGEOMObject._retn();
178 if (!CORBA::is_nil(theVec)) {
179 aVec = GetObjectImpl(theVec);
180 if (aVec.IsNull()) return aGEOMObject._retn();
184 Handle(GEOM_Object) anObject =
185 GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor, aVecMaj);
186 if (!GetOperations()->IsDone() || anObject.IsNull())
187 return aGEOMObject._retn();
189 return GetObject(anObject);
192 //=============================================================================
196 //=============================================================================
197 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipseVec
198 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
199 CORBA::Double theRMajor, double theRMinor,
200 GEOM::GEOM_Object_ptr theVecMaj)
202 GEOM::GEOM_Object_var aGEOMObject;
204 //Set a not done flag
205 GetOperations()->SetNotDone();
207 // Not set thePnt means origin of global CS,
208 // Not set theVec means Z axis of global CS
209 // Not set theVecMaj means X axis of global CS
210 //if (thePnt == NULL || theVec == NULL || theVecMaj == NULL) return aGEOMObject._retn();
213 Handle(GEOM_Object) aPnt, aVec, aVecMaj;
214 if (!CORBA::is_nil(thePnt)) {
215 aPnt = GetObjectImpl(thePnt);
216 if (aPnt.IsNull()) return aGEOMObject._retn();
218 if (!CORBA::is_nil(theVec)) {
219 aVec = GetObjectImpl(theVec);
220 if (aVec.IsNull()) return aGEOMObject._retn();
222 if (!CORBA::is_nil(theVecMaj)) {
223 aVecMaj = GetObjectImpl(theVecMaj);
224 if (aVecMaj.IsNull()) return aGEOMObject._retn();
228 Handle(GEOM_Object) anObject =
229 GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor, aVecMaj);
230 if (!GetOperations()->IsDone() || anObject.IsNull())
231 return aGEOMObject._retn();
233 return GetObject(anObject);
236 //=============================================================================
240 //=============================================================================
241 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArc
242 (GEOM::GEOM_Object_ptr thePnt1,
243 GEOM::GEOM_Object_ptr thePnt2,
244 GEOM::GEOM_Object_ptr thePnt3)
246 GEOM::GEOM_Object_var aGEOMObject;
248 //Set a not done flag
249 GetOperations()->SetNotDone();
251 //Get the reference points
252 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
253 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
254 Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
256 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
259 Handle(GEOM_Object) anObject =
260 GetOperations()->MakeArc(aPnt1, aPnt2, aPnt3);
261 if (!GetOperations()->IsDone() || anObject.IsNull())
262 return aGEOMObject._retn();
264 return GetObject(anObject);
268 //=============================================================================
272 //=============================================================================
273 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcCenter
274 (GEOM::GEOM_Object_ptr thePnt1,
275 GEOM::GEOM_Object_ptr thePnt2,
276 GEOM::GEOM_Object_ptr thePnt3,
277 CORBA::Boolean theSense)
280 GEOM::GEOM_Object_var aGEOMObject;
281 //Set a not done flag
282 GetOperations()->SetNotDone();
284 //Get the reference points
285 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
286 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
287 Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
289 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
292 Handle(GEOM_Object) anObject =
293 GetOperations()->MakeArcCenter(aPnt1, aPnt2, aPnt3,theSense);
294 if (!GetOperations()->IsDone() || anObject.IsNull())
295 return aGEOMObject._retn();
297 return GetObject(anObject);
300 //=============================================================================
304 //=============================================================================
305 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcOfEllipse
306 (GEOM::GEOM_Object_ptr thePnt1,
307 GEOM::GEOM_Object_ptr thePnt2,
308 GEOM::GEOM_Object_ptr thePnt3)
310 GEOM::GEOM_Object_var aGEOMObject;
312 //Set a not done flag
313 GetOperations()->SetNotDone();
315 //Get the reference points
316 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
317 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
318 Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
320 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
323 Handle(GEOM_Object) anObject =
324 GetOperations()->MakeArcOfEllipse(aPnt1, aPnt2, aPnt3);
325 if (!GetOperations()->IsDone() || anObject.IsNull())
326 return aGEOMObject._retn();
328 return GetObject(anObject);
331 //=============================================================================
335 //=============================================================================
336 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline
337 (const GEOM::ListOfGO& thePoints,
338 CORBA::Boolean theIsClosed)
340 GEOM::GEOM_Object_var aGEOMObject;
342 //Set a not done flag
343 GetOperations()->SetNotDone();
345 //Get the reference point
347 int aLen = thePoints.length();
348 std::list<Handle(GEOM_Object)> aPoints;
349 for (; ind < aLen; ind++) {
350 Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
351 if (aPnt.IsNull()) return aGEOMObject._retn();
352 aPoints.push_back(aPnt);
356 Handle(GEOM_Object) anObject =
357 GetOperations()->MakePolyline(aPoints, theIsClosed);
358 if (!GetOperations()->IsDone() || anObject.IsNull())
359 return aGEOMObject._retn();
361 return GetObject(anObject);
364 //=============================================================================
368 //=============================================================================
369 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineBezier
370 (const GEOM::ListOfGO& thePoints,
371 CORBA::Boolean theIsClosed)
373 GEOM::GEOM_Object_var aGEOMObject;
375 //Set a not done flag
376 GetOperations()->SetNotDone();
378 //Get the reference point
380 int aLen = thePoints.length();
381 std::list<Handle(GEOM_Object)> aPoints;
382 for (; ind < aLen; ind++) {
383 Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
384 if (aPnt.IsNull()) return aGEOMObject._retn();
385 aPoints.push_back(aPnt);
389 Handle(GEOM_Object) anObject =
390 GetOperations()->MakeSplineBezier(aPoints, theIsClosed);
391 if (!GetOperations()->IsDone() || anObject.IsNull())
392 return aGEOMObject._retn();
394 return GetObject(anObject);
397 //=============================================================================
399 * MakeSplineInterpolation
401 //=============================================================================
402 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
403 (const GEOM::ListOfGO& thePoints,
404 CORBA::Boolean theIsClosed,
405 CORBA::Boolean theDoReordering)
407 GEOM::GEOM_Object_var aGEOMObject;
409 //Set a not done flag
410 GetOperations()->SetNotDone();
412 //Get the reference point
414 int aLen = thePoints.length();
415 std::list<Handle(GEOM_Object)> aPoints;
416 for (; ind < aLen; ind++) {
417 Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
418 if (aPnt.IsNull()) return aGEOMObject._retn();
419 aPoints.push_back(aPnt);
423 Handle(GEOM_Object) anObject =
424 GetOperations()->MakeSplineInterpolation(aPoints, theIsClosed, theDoReordering);
425 if (!GetOperations()->IsDone() || anObject.IsNull())
426 return aGEOMObject._retn();
428 return GetObject(anObject);
431 //=============================================================================
433 * MakeSplineInterpolWithTangents
435 //=============================================================================
436 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolWithTangents
437 (const GEOM::ListOfGO& thePoints,
438 GEOM::GEOM_Object_ptr theFirstVec,
439 GEOM::GEOM_Object_ptr theLastVec)
441 GEOM::GEOM_Object_var aGEOMObject;
443 //Set a not done flag
444 GetOperations()->SetNotDone();
446 //Get the reference points
448 int aLen = thePoints.length();
449 std::list<Handle(GEOM_Object)> aPoints;
450 for (; ind < aLen; ind++) {
451 Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
452 if (aPnt.IsNull()) return aGEOMObject._retn();
453 aPoints.push_back(aPnt);
456 //Get the reference vectors
457 Handle(GEOM_Object) aVec1 = GetObjectImpl(theFirstVec);
458 Handle(GEOM_Object) aVec2 = GetObjectImpl(theLastVec);
460 if (aVec1.IsNull() || aVec2.IsNull()) return aGEOMObject._retn();
463 Handle(GEOM_Object) anObject =
464 GetOperations()->MakeSplineInterpolWithTangents(aPoints, aVec1, aVec2);
465 if (!GetOperations()->IsDone() || anObject.IsNull())
466 return aGEOMObject._retn();
468 return GetObject(anObject);
471 //=============================================================================
473 * MakeCurveParametric
475 //=============================================================================
476 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric
477 (const char* thexExpr, const char* theyExpr, const char* thezExpr,
478 double theParamMin, double theParamMax, double theParamStep,
479 GEOM::curve_type theCurveType)
481 GEOM::GEOM_Object_var aGEOMObject;
482 //Set a not done flag
483 GetOperations()->SetNotDone();
485 GEOMImpl_ICurvesOperations::CurveType aType;
486 switch(theCurveType) {
488 aType = GEOMImpl_ICurvesOperations::Polyline;
491 aType = GEOMImpl_ICurvesOperations::Bezier;
493 case GEOM::Interpolation:
494 aType = GEOMImpl_ICurvesOperations::Interpolation;
501 Handle(GEOM_Object) anObject =
502 GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
503 theParamMin, theParamMax,
504 theParamStep, aType);
506 if (!GetOperations()->IsDone() || anObject.IsNull())
507 return aGEOMObject._retn();
509 return GetObject(anObject);
512 //=============================================================================
514 * MakeCurveParametricNew
516 //=============================================================================
517 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew
518 (const char* thexExpr, const char* theyExpr, const char* thezExpr,
519 double theParamMin, double theParamMax, CORBA::Long theParamNbStep,
520 GEOM::curve_type theCurveType)
522 GEOM::GEOM_Object_var aGEOMObject;
523 //Set a not done flag
524 GetOperations()->SetNotDone();
526 GEOMImpl_ICurvesOperations::CurveType aType;
527 switch(theCurveType) {
529 aType = GEOMImpl_ICurvesOperations::Polyline;
532 aType = GEOMImpl_ICurvesOperations::Bezier;
534 case GEOM::Interpolation:
535 aType = GEOMImpl_ICurvesOperations::Interpolation;
542 Handle(GEOM_Object) anObject =
543 GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
544 theParamMin, theParamMax,
545 0.0, aType, theParamNbStep, true);
547 if (!GetOperations()->IsDone() || anObject.IsNull())
548 return aGEOMObject._retn();
550 return GetObject(anObject);
553 //=============================================================================
557 //=============================================================================
558 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeIsoline
559 (GEOM::GEOM_Object_ptr theFace,
560 CORBA::Boolean IsUIsoline,
563 GEOM::GEOM_Object_var aGEOMObject;
565 //Set a not done flag
566 GetOperations()->SetNotDone();
568 Handle(GEOM_Object) aFace = GetObjectImpl(theFace);
571 Handle(GEOM_Object) anObject =
572 GetOperations()->MakeIsoline(aFace, IsUIsoline, theParameter);
573 if (!GetOperations()->IsDone() || anObject.IsNull())
574 return aGEOMObject._retn();
576 return GetObject(anObject);
579 //=============================================================================
583 //=============================================================================
584 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
585 (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane)
587 //Set a not done flag
588 GetOperations()->SetNotDone();
591 int aLen = theWorkingPlane.length();
592 std::list<double> aWorkingPlane;
593 for (; ind < aLen; ind++)
594 aWorkingPlane.push_back(theWorkingPlane[ind]);
597 Handle(GEOM_Object) anObject =
598 GetOperations()->MakeSketcher(theCommand, aWorkingPlane);
599 if (!GetOperations()->IsDone() || anObject.IsNull())
600 return GEOM::GEOM_Object::_nil();
602 return GetObject(anObject);
605 //=============================================================================
607 * MakeSketcherOnPlane
609 //=============================================================================
610 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
611 (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
613 //Set a not done flag
614 GetOperations()->SetNotDone();
616 Handle(GEOM_Object) aWorkingPlane = GetObjectImpl(theWorkingPlane);
619 Handle(GEOM_Object) anObject =
620 GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane);
621 if (!GetOperations()->IsDone() || anObject.IsNull())
622 return GEOM::GEOM_Object::_nil();
624 return GetObject(anObject);
627 //=============================================================================
629 * Make3DSketcherCommand
631 //=============================================================================
632 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcherCommand (const char* theCommand)
634 //Set a not done flag
635 GetOperations()->SetNotDone();
638 Handle(GEOM_Object) anObject = GetOperations()->Make3DSketcherCommand(theCommand);
639 if (!GetOperations()->IsDone() || anObject.IsNull())
640 return GEOM::GEOM_Object::_nil();
642 return GetObject(anObject);
645 //=============================================================================
649 //=============================================================================
650 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher
651 (const GEOM::ListOfDouble& theCoordinates)
653 //Set a not done flag
654 GetOperations()->SetNotDone();
657 int aLen = theCoordinates.length();
658 std::list<double> aCoords;
659 for (; ind < aLen; ind++)
660 aCoords.push_back(theCoordinates[ind]);
663 Handle(GEOM_Object) anObject =
664 GetOperations()->Make3DSketcher(aCoords);
665 if (!GetOperations()->IsDone() || anObject.IsNull())
666 return GEOM::GEOM_Object::_nil();
668 return GetObject(anObject);