1 // Copyright (C) 2007-2008 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)
338 GEOM::GEOM_Object_var aGEOMObject;
340 //Set a not done flag
341 GetOperations()->SetNotDone();
343 //Get the reference point
345 int aLen = thePoints.length();
346 list<Handle(GEOM_Object)> aPoints;
347 for (; ind < aLen; ind++) {
348 Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
349 if (aPnt.IsNull()) return aGEOMObject._retn();
350 aPoints.push_back(aPnt);
354 Handle(GEOM_Object) anObject =
355 GetOperations()->MakePolyline(aPoints);
356 if (!GetOperations()->IsDone() || anObject.IsNull())
357 return aGEOMObject._retn();
359 return GetObject(anObject);
362 //=============================================================================
366 //=============================================================================
367 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineBezier
368 (const GEOM::ListOfGO& thePoints)
370 GEOM::GEOM_Object_var aGEOMObject;
372 //Set a not done flag
373 GetOperations()->SetNotDone();
375 //Get the reference point
377 int aLen = thePoints.length();
378 list<Handle(GEOM_Object)> aPoints;
379 for (; ind < aLen; ind++) {
380 Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
381 if (aPnt.IsNull()) return aGEOMObject._retn();
382 aPoints.push_back(aPnt);
386 Handle(GEOM_Object) anObject =
387 GetOperations()->MakeSplineBezier(aPoints);
388 if (!GetOperations()->IsDone() || anObject.IsNull())
389 return aGEOMObject._retn();
391 return GetObject(anObject);
394 //=============================================================================
396 * MakeSplineInterpolation
398 //=============================================================================
399 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
400 (const GEOM::ListOfGO& thePoints,
401 CORBA::Boolean theIsClosed)
403 GEOM::GEOM_Object_var aGEOMObject;
405 //Set a not done flag
406 GetOperations()->SetNotDone();
408 //Get the reference point
410 int aLen = thePoints.length();
411 list<Handle(GEOM_Object)> aPoints;
412 for (; ind < aLen; ind++) {
413 Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
414 if (aPnt.IsNull()) return aGEOMObject._retn();
415 aPoints.push_back(aPnt);
419 Handle(GEOM_Object) anObject =
420 GetOperations()->MakeSplineInterpolation(aPoints, theIsClosed);
421 if (!GetOperations()->IsDone() || anObject.IsNull())
422 return aGEOMObject._retn();
424 return GetObject(anObject);
427 //=============================================================================
431 //=============================================================================
432 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
433 (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane)
435 //Set a not done flag
436 GetOperations()->SetNotDone();
439 int aLen = theWorkingPlane.length();
440 list<double> aWorkingPlane;
441 for (; ind < aLen; ind++)
442 aWorkingPlane.push_back(theWorkingPlane[ind]);
445 Handle(GEOM_Object) anObject =
446 GetOperations()->MakeSketcher(theCommand, aWorkingPlane);
447 if (!GetOperations()->IsDone() || anObject.IsNull())
448 return GEOM::GEOM_Object::_nil();
450 return GetObject(anObject);
453 //=============================================================================
457 //=============================================================================
458 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher
459 (const GEOM::ListOfDouble& theCoordinates)
461 //Set a not done flag
462 GetOperations()->SetNotDone();
465 int aLen = theCoordinates.length();
466 list<double> aCoords;
467 for (; ind < aLen; ind++)
468 aCoords.push_back(theCoordinates[ind]);
471 Handle(GEOM_Object) anObject =
472 GetOperations()->Make3DSketcher(aCoords);
473 if (!GetOperations()->IsDone() || anObject.IsNull())
474 return GEOM::GEOM_Object::_nil();
476 return GetObject(anObject);
479 //=============================================================================
481 * MakeSketcherOnPlane
483 //=============================================================================
484 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
485 (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
487 //Set a not done flag
488 GetOperations()->SetNotDone();
490 Handle(GEOM_Object) aWorkingPlane = GetObjectImpl(theWorkingPlane);
493 Handle(GEOM_Object) anObject =
494 GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane);
495 if (!GetOperations()->IsDone() || anObject.IsNull())
496 return GEOM::GEOM_Object::_nil();
498 return GetObject(anObject);