1 // Copyright (C) 2007-2012 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
22 #include <Standard_Stream.hxx>
24 #include "GEOM_ICurvesOperations_i.hh"
26 #include "utilities.h"
29 #include "GEOM_Engine.hxx"
30 #include "GEOM_Object.hxx"
32 //=============================================================================
36 //=============================================================================
37 GEOM_ICurvesOperations_i::GEOM_ICurvesOperations_i (PortableServer::POA_ptr thePOA,
38 GEOM::GEOM_Gen_ptr theEngine,
39 ::GEOMImpl_ICurvesOperations* theImpl)
40 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
42 MESSAGE("GEOM_ICurvesOperations_i::GEOM_ICurvesOperations_i");
45 //=============================================================================
49 //=============================================================================
50 GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i()
52 MESSAGE("GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i");
56 //=============================================================================
60 //=============================================================================
61 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCirclePntVecR
62 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
65 GEOM::GEOM_Object_var aGEOMObject;
68 GetOperations()->SetNotDone();
70 // Not set thePnt means origin of global CS,
71 // Not set theVec means Z axis of global CS
72 //if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
75 Handle(GEOM_Object) aPnt, aVec;
76 if (!CORBA::is_nil(thePnt)) {
77 aPnt = GetObjectImpl(thePnt);
78 if (aPnt.IsNull()) return aGEOMObject._retn();
80 if (!CORBA::is_nil(theVec)) {
81 aVec = GetObjectImpl(theVec);
82 if (aVec.IsNull()) return aGEOMObject._retn();
86 Handle(GEOM_Object) anObject =
87 GetOperations()->MakeCirclePntVecR(aPnt, aVec, theR);
88 if (!GetOperations()->IsDone() || anObject.IsNull())
89 return aGEOMObject._retn();
91 return GetObject(anObject);
94 //=============================================================================
98 //=============================================================================
99 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleThreePnt
100 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
101 GEOM::GEOM_Object_ptr thePnt3)
103 GEOM::GEOM_Object_var aGEOMObject;
105 //Set a not done flag
106 GetOperations()->SetNotDone();
108 //Get the reference points
109 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
110 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
111 Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
113 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
116 Handle(GEOM_Object) anObject =
117 GetOperations()->MakeCircleThreePnt(aPnt1, aPnt2, aPnt3);
118 if (!GetOperations()->IsDone() || anObject.IsNull())
119 return aGEOMObject._retn();
121 return GetObject(anObject);
124 //=============================================================================
126 * MakeCircleCenter2Pnt
128 //=============================================================================
129 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleCenter2Pnt
130 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
131 GEOM::GEOM_Object_ptr thePnt3)
133 GEOM::GEOM_Object_var aGEOMObject;
135 //Set a not done flag
136 GetOperations()->SetNotDone();
138 //Get the reference points
139 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
140 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
141 Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
143 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
146 Handle(GEOM_Object) anObject = GetOperations()->MakeCircleCenter2Pnt(aPnt1, aPnt2, aPnt3);
147 if (!GetOperations()->IsDone() || anObject.IsNull())
148 return aGEOMObject._retn();
150 return GetObject(anObject);
153 //=============================================================================
157 //=============================================================================
158 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipse
159 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
160 CORBA::Double theRMajor, double theRMinor)
162 GEOM::GEOM_Object_var aGEOMObject;
164 //Set a not done flag
165 GetOperations()->SetNotDone();
167 // Not set thePnt means origin of global CS,
168 // Not set theVec means Z axis of global CS
169 //if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
172 Handle(GEOM_Object) aPnt, aVec, aVecMaj;
173 if (!CORBA::is_nil(thePnt)) {
174 aPnt = GetObjectImpl(thePnt);
175 if (aPnt.IsNull()) return aGEOMObject._retn();
177 if (!CORBA::is_nil(theVec)) {
178 aVec = GetObjectImpl(theVec);
179 if (aVec.IsNull()) return aGEOMObject._retn();
183 Handle(GEOM_Object) anObject =
184 GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor, aVecMaj);
185 if (!GetOperations()->IsDone() || anObject.IsNull())
186 return aGEOMObject._retn();
188 return GetObject(anObject);
191 //=============================================================================
195 //=============================================================================
196 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipseVec
197 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
198 CORBA::Double theRMajor, double theRMinor,
199 GEOM::GEOM_Object_ptr theVecMaj)
201 GEOM::GEOM_Object_var aGEOMObject;
203 //Set a not done flag
204 GetOperations()->SetNotDone();
206 // Not set thePnt means origin of global CS,
207 // Not set theVec means Z axis of global CS
208 // Not set theVecMaj means X axis of global CS
209 //if (thePnt == NULL || theVec == NULL || theVecMaj == NULL) return aGEOMObject._retn();
212 Handle(GEOM_Object) aPnt, aVec, aVecMaj;
213 if (!CORBA::is_nil(thePnt)) {
214 aPnt = GetObjectImpl(thePnt);
215 if (aPnt.IsNull()) return aGEOMObject._retn();
217 if (!CORBA::is_nil(theVec)) {
218 aVec = GetObjectImpl(theVec);
219 if (aVec.IsNull()) return aGEOMObject._retn();
221 if (!CORBA::is_nil(theVecMaj)) {
222 aVecMaj = GetObjectImpl(theVecMaj);
223 if (aVecMaj.IsNull()) return aGEOMObject._retn();
227 Handle(GEOM_Object) anObject =
228 GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor, aVecMaj);
229 if (!GetOperations()->IsDone() || anObject.IsNull())
230 return aGEOMObject._retn();
232 return GetObject(anObject);
235 //=============================================================================
239 //=============================================================================
240 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArc
241 (GEOM::GEOM_Object_ptr thePnt1,
242 GEOM::GEOM_Object_ptr thePnt2,
243 GEOM::GEOM_Object_ptr thePnt3)
245 GEOM::GEOM_Object_var aGEOMObject;
247 //Set a not done flag
248 GetOperations()->SetNotDone();
250 //Get the reference points
251 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
252 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
253 Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
255 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
258 Handle(GEOM_Object) anObject =
259 GetOperations()->MakeArc(aPnt1, aPnt2, aPnt3);
260 if (!GetOperations()->IsDone() || anObject.IsNull())
261 return aGEOMObject._retn();
263 return GetObject(anObject);
267 //=============================================================================
271 //=============================================================================
272 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcCenter
273 (GEOM::GEOM_Object_ptr thePnt1,
274 GEOM::GEOM_Object_ptr thePnt2,
275 GEOM::GEOM_Object_ptr thePnt3,
276 CORBA::Boolean theSense)
279 GEOM::GEOM_Object_var aGEOMObject;
280 //Set a not done flag
281 GetOperations()->SetNotDone();
283 //Get the reference points
284 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
285 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
286 Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
288 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
291 Handle(GEOM_Object) anObject =
292 GetOperations()->MakeArcCenter(aPnt1, aPnt2, aPnt3,theSense);
293 if (!GetOperations()->IsDone() || anObject.IsNull())
294 return aGEOMObject._retn();
296 return GetObject(anObject);
299 //=============================================================================
303 //=============================================================================
304 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcOfEllipse
305 (GEOM::GEOM_Object_ptr thePnt1,
306 GEOM::GEOM_Object_ptr thePnt2,
307 GEOM::GEOM_Object_ptr thePnt3)
309 GEOM::GEOM_Object_var aGEOMObject;
311 //Set a not done flag
312 GetOperations()->SetNotDone();
314 //Get the reference points
315 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
316 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
317 Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
319 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
322 Handle(GEOM_Object) anObject =
323 GetOperations()->MakeArcOfEllipse(aPnt1, aPnt2, aPnt3);
324 if (!GetOperations()->IsDone() || anObject.IsNull())
325 return aGEOMObject._retn();
327 return GetObject(anObject);
330 //=============================================================================
334 //=============================================================================
335 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline
336 (const GEOM::ListOfGO& thePoints,
337 CORBA::Boolean theIsClosed)
339 GEOM::GEOM_Object_var aGEOMObject;
341 //Set a not done flag
342 GetOperations()->SetNotDone();
344 //Get the reference point
346 int aLen = thePoints.length();
347 std::list<Handle(GEOM_Object)> aPoints;
348 for (; ind < aLen; ind++) {
349 Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
350 if (aPnt.IsNull()) return aGEOMObject._retn();
351 aPoints.push_back(aPnt);
355 Handle(GEOM_Object) anObject =
356 GetOperations()->MakePolyline(aPoints, theIsClosed);
357 if (!GetOperations()->IsDone() || anObject.IsNull())
358 return aGEOMObject._retn();
360 return GetObject(anObject);
363 //=============================================================================
367 //=============================================================================
368 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineBezier
369 (const GEOM::ListOfGO& thePoints,
370 CORBA::Boolean theIsClosed)
372 GEOM::GEOM_Object_var aGEOMObject;
374 //Set a not done flag
375 GetOperations()->SetNotDone();
377 //Get the reference point
379 int aLen = thePoints.length();
380 std::list<Handle(GEOM_Object)> aPoints;
381 for (; ind < aLen; ind++) {
382 Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
383 if (aPnt.IsNull()) return aGEOMObject._retn();
384 aPoints.push_back(aPnt);
388 Handle(GEOM_Object) anObject =
389 GetOperations()->MakeSplineBezier(aPoints, theIsClosed);
390 if (!GetOperations()->IsDone() || anObject.IsNull())
391 return aGEOMObject._retn();
393 return GetObject(anObject);
396 //=============================================================================
398 * MakeSplineInterpolation
400 //=============================================================================
401 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
402 (const GEOM::ListOfGO& thePoints,
403 CORBA::Boolean theIsClosed,
404 CORBA::Boolean theDoReordering)
406 GEOM::GEOM_Object_var aGEOMObject;
408 //Set a not done flag
409 GetOperations()->SetNotDone();
411 //Get the reference point
413 int aLen = thePoints.length();
414 std::list<Handle(GEOM_Object)> aPoints;
415 for (; ind < aLen; ind++) {
416 Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
417 if (aPnt.IsNull()) return aGEOMObject._retn();
418 aPoints.push_back(aPnt);
422 Handle(GEOM_Object) anObject =
423 GetOperations()->MakeSplineInterpolation(aPoints, theIsClosed, theDoReordering);
424 if (!GetOperations()->IsDone() || anObject.IsNull())
425 return aGEOMObject._retn();
427 return GetObject(anObject);
430 //=============================================================================
432 * MakeCurveParametric
434 //=============================================================================
435 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric
436 (const char* thexExpr, const char* theyExpr, const char* thezExpr,
437 double theParamMin, double theParamMax, double theParamStep,
438 GEOM::curve_type theCurveType)
440 GEOM::GEOM_Object_var aGEOMObject;
441 //Set a not done flag
442 GetOperations()->SetNotDone();
444 GEOMImpl_ICurvesOperations::CurveType aType;
445 switch(theCurveType) {
447 aType = GEOMImpl_ICurvesOperations::Polyline;
450 aType = GEOMImpl_ICurvesOperations::Bezier;
452 case GEOM::Interpolation:
453 aType = GEOMImpl_ICurvesOperations::Interpolation;
460 Handle(GEOM_Object) anObject =
461 GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
462 theParamMin, theParamMax,
463 theParamStep, aType);
465 if (!GetOperations()->IsDone() || anObject.IsNull())
466 return aGEOMObject._retn();
468 return GetObject(anObject);
471 //=============================================================================
473 * MakeCurveParametricNew
475 //=============================================================================
476 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew
477 (const char* thexExpr, const char* theyExpr, const char* thezExpr,
478 double theParamMin, double theParamMax, CORBA::Long theParamNbStep,
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 0.0, aType, theParamNbStep, true);
506 if (!GetOperations()->IsDone() || anObject.IsNull())
507 return aGEOMObject._retn();
509 return GetObject(anObject);
512 //=============================================================================
516 //=============================================================================
517 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
518 (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane)
520 //Set a not done flag
521 GetOperations()->SetNotDone();
524 int aLen = theWorkingPlane.length();
525 std::list<double> aWorkingPlane;
526 for (; ind < aLen; ind++)
527 aWorkingPlane.push_back(theWorkingPlane[ind]);
530 Handle(GEOM_Object) anObject =
531 GetOperations()->MakeSketcher(theCommand, aWorkingPlane);
532 if (!GetOperations()->IsDone() || anObject.IsNull())
533 return GEOM::GEOM_Object::_nil();
535 return GetObject(anObject);
538 //=============================================================================
540 * MakeSketcherOnPlane
542 //=============================================================================
543 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
544 (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
546 //Set a not done flag
547 GetOperations()->SetNotDone();
549 Handle(GEOM_Object) aWorkingPlane = GetObjectImpl(theWorkingPlane);
552 Handle(GEOM_Object) anObject =
553 GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane);
554 if (!GetOperations()->IsDone() || anObject.IsNull())
555 return GEOM::GEOM_Object::_nil();
557 return GetObject(anObject);
560 //=============================================================================
562 * Make3DSketcherCommand
564 //=============================================================================
565 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcherCommand (const char* theCommand)
567 //Set a not done flag
568 GetOperations()->SetNotDone();
571 Handle(GEOM_Object) anObject = GetOperations()->Make3DSketcherCommand(theCommand);
572 if (!GetOperations()->IsDone() || anObject.IsNull())
573 return GEOM::GEOM_Object::_nil();
575 return GetObject(anObject);
578 //=============================================================================
582 //=============================================================================
583 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher
584 (const GEOM::ListOfDouble& theCoordinates)
586 //Set a not done flag
587 GetOperations()->SetNotDone();
590 int aLen = theCoordinates.length();
591 std::list<double> aCoords;
592 for (; ind < aLen; ind++)
593 aCoords.push_back(theCoordinates[ind]);
596 Handle(GEOM_Object) anObject =
597 GetOperations()->Make3DSketcher(aCoords);
598 if (!GetOperations()->IsDone() || anObject.IsNull())
599 return GEOM::GEOM_Object::_nil();
601 return GetObject(anObject);