1 // Copyright (C) 2007-2010 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)
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);
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)
371 GEOM::GEOM_Object_var aGEOMObject;
373 //Set a not done flag
374 GetOperations()->SetNotDone();
376 //Get the reference point
378 int aLen = thePoints.length();
379 std::list<Handle(GEOM_Object)> aPoints;
380 for (; ind < aLen; ind++) {
381 Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
382 if (aPnt.IsNull()) return aGEOMObject._retn();
383 aPoints.push_back(aPnt);
387 Handle(GEOM_Object) anObject =
388 GetOperations()->MakeSplineBezier(aPoints);
389 if (!GetOperations()->IsDone() || anObject.IsNull())
390 return aGEOMObject._retn();
392 return GetObject(anObject);
395 //=============================================================================
397 * MakeSplineInterpolation
399 //=============================================================================
400 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
401 (const GEOM::ListOfGO& thePoints,
402 CORBA::Boolean theIsClosed)
404 GEOM::GEOM_Object_var aGEOMObject;
406 //Set a not done flag
407 GetOperations()->SetNotDone();
409 //Get the reference point
411 int aLen = thePoints.length();
412 std::list<Handle(GEOM_Object)> aPoints;
413 for (; ind < aLen; ind++) {
414 Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
415 if (aPnt.IsNull()) return aGEOMObject._retn();
416 aPoints.push_back(aPnt);
420 Handle(GEOM_Object) anObject =
421 GetOperations()->MakeSplineInterpolation(aPoints, theIsClosed);
422 if (!GetOperations()->IsDone() || anObject.IsNull())
423 return aGEOMObject._retn();
425 return GetObject(anObject);
428 //=============================================================================
432 //=============================================================================
433 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
434 (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane)
436 //Set a not done flag
437 GetOperations()->SetNotDone();
440 int aLen = theWorkingPlane.length();
441 std::list<double> aWorkingPlane;
442 for (; ind < aLen; ind++)
443 aWorkingPlane.push_back(theWorkingPlane[ind]);
446 Handle(GEOM_Object) anObject =
447 GetOperations()->MakeSketcher(theCommand, aWorkingPlane);
448 if (!GetOperations()->IsDone() || anObject.IsNull())
449 return GEOM::GEOM_Object::_nil();
451 return GetObject(anObject);
454 //=============================================================================
458 //=============================================================================
459 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher
460 (const GEOM::ListOfDouble& theCoordinates)
462 //Set a not done flag
463 GetOperations()->SetNotDone();
466 int aLen = theCoordinates.length();
467 std::list<double> aCoords;
468 for (; ind < aLen; ind++)
469 aCoords.push_back(theCoordinates[ind]);
472 Handle(GEOM_Object) anObject =
473 GetOperations()->Make3DSketcher(aCoords);
474 if (!GetOperations()->IsDone() || anObject.IsNull())
475 return GEOM::GEOM_Object::_nil();
477 return GetObject(anObject);
480 //=============================================================================
482 * MakeSketcherOnPlane
484 //=============================================================================
485 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
486 (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
488 //Set a not done flag
489 GetOperations()->SetNotDone();
491 Handle(GEOM_Object) aWorkingPlane = GetObjectImpl(theWorkingPlane);
494 Handle(GEOM_Object) anObject =
495 GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane);
496 if (!GetOperations()->IsDone() || anObject.IsNull())
497 return GEOM::GEOM_Object::_nil();
499 return GetObject(anObject);