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 = GetOperations()->GetEngine()->GetObject
78 (thePnt->GetStudyID(), thePnt->GetEntry());
79 if (aPnt.IsNull()) return aGEOMObject._retn();
81 if (!CORBA::is_nil(theVec)) {
82 aVec = GetOperations()->GetEngine()->GetObject
83 (theVec->GetStudyID(), theVec->GetEntry());
84 if (aVec.IsNull()) return aGEOMObject._retn();
88 Handle(GEOM_Object) anObject =
89 GetOperations()->MakeCirclePntVecR(aPnt, aVec, theR);
90 if (!GetOperations()->IsDone() || anObject.IsNull())
91 return aGEOMObject._retn();
93 return GetObject(anObject);
96 //=============================================================================
100 //=============================================================================
101 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleThreePnt
102 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
103 GEOM::GEOM_Object_ptr thePnt3)
105 GEOM::GEOM_Object_var aGEOMObject;
107 //Set a not done flag
108 GetOperations()->SetNotDone();
110 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
112 //Get the reference points
113 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
114 (thePnt1->GetStudyID(), thePnt1->GetEntry());
115 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
116 (thePnt2->GetStudyID(), thePnt2->GetEntry());
117 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
118 (thePnt3->GetStudyID(), thePnt3->GetEntry());
120 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
123 Handle(GEOM_Object) anObject =
124 GetOperations()->MakeCircleThreePnt(aPnt1, aPnt2, aPnt3);
125 if (!GetOperations()->IsDone() || anObject.IsNull())
126 return aGEOMObject._retn();
128 return GetObject(anObject);
131 //=============================================================================
133 * MakeCircleCenter2Pnt
135 //=============================================================================
136 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleCenter2Pnt
137 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
138 GEOM::GEOM_Object_ptr thePnt3)
140 GEOM::GEOM_Object_var aGEOMObject;
142 //Set a not done flag
143 GetOperations()->SetNotDone();
145 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
147 //Get the reference points
148 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
149 (thePnt1->GetStudyID(), thePnt1->GetEntry());
150 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
151 (thePnt2->GetStudyID(), thePnt2->GetEntry());
152 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
153 (thePnt3->GetStudyID(), thePnt3->GetEntry());
155 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
158 Handle(GEOM_Object) anObject = GetOperations()->MakeCircleCenter2Pnt(aPnt1, aPnt2, aPnt3);
159 if (!GetOperations()->IsDone() || anObject.IsNull())
160 return aGEOMObject._retn();
162 return GetObject(anObject);
165 //=============================================================================
169 //=============================================================================
170 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipse
171 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
172 CORBA::Double theRMajor, double theRMinor)
174 GEOM::GEOM_Object_var aGEOMObject;
176 //Set a not done flag
177 GetOperations()->SetNotDone();
179 // Not set thePnt means origin of global CS,
180 // Not set theVec means Z axis of global CS
181 //if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
184 Handle(GEOM_Object) aPnt, aVec;
185 if (!CORBA::is_nil(thePnt)) {
186 aPnt = GetOperations()->GetEngine()->GetObject
187 (thePnt->GetStudyID(), thePnt->GetEntry());
188 if (aPnt.IsNull()) return aGEOMObject._retn();
190 if (!CORBA::is_nil(theVec)) {
191 aVec = GetOperations()->GetEngine()->GetObject
192 (theVec->GetStudyID(), theVec->GetEntry());
193 if (aVec.IsNull()) return aGEOMObject._retn();
197 Handle(GEOM_Object) anObject =
198 GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor);
199 if (!GetOperations()->IsDone() || anObject.IsNull())
200 return aGEOMObject._retn();
202 return GetObject(anObject);
205 //=============================================================================
209 //=============================================================================
210 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArc
211 (GEOM::GEOM_Object_ptr thePnt1,
212 GEOM::GEOM_Object_ptr thePnt2,
213 GEOM::GEOM_Object_ptr thePnt3)
215 GEOM::GEOM_Object_var aGEOMObject;
217 //Set a not done flag
218 GetOperations()->SetNotDone();
220 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
222 //Get the reference points
223 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
224 (thePnt1->GetStudyID(), thePnt1->GetEntry());
225 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
226 (thePnt2->GetStudyID(), thePnt2->GetEntry());
227 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
228 (thePnt3->GetStudyID(), thePnt3->GetEntry());
230 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
233 Handle(GEOM_Object) anObject =
234 GetOperations()->MakeArc(aPnt1, aPnt2, aPnt3);
235 if (!GetOperations()->IsDone() || anObject.IsNull())
236 return aGEOMObject._retn();
238 return GetObject(anObject);
242 //=============================================================================
246 //=============================================================================
247 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcCenter
248 (GEOM::GEOM_Object_ptr thePnt1,
249 GEOM::GEOM_Object_ptr thePnt2,
250 GEOM::GEOM_Object_ptr thePnt3,
251 CORBA::Boolean theSense)
254 GEOM::GEOM_Object_var aGEOMObject;
255 //Set a not done flag
256 GetOperations()->SetNotDone();
258 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
260 //Get the reference points
261 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
262 (thePnt1->GetStudyID(), thePnt1->GetEntry());
263 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
264 (thePnt2->GetStudyID(), thePnt2->GetEntry());
265 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
266 (thePnt3->GetStudyID(), thePnt3->GetEntry());
268 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
271 Handle(GEOM_Object) anObject =
272 GetOperations()->MakeArcCenter(aPnt1, aPnt2, aPnt3,theSense);
273 if (!GetOperations()->IsDone() || anObject.IsNull())
274 return aGEOMObject._retn();
276 return GetObject(anObject);
279 //=============================================================================
283 //=============================================================================
284 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcOfEllipse
285 (GEOM::GEOM_Object_ptr thePnt1,
286 GEOM::GEOM_Object_ptr thePnt2,
287 GEOM::GEOM_Object_ptr thePnt3)
289 GEOM::GEOM_Object_var aGEOMObject;
291 //Set a not done flag
292 GetOperations()->SetNotDone();
294 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
296 //Get the reference points
297 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
298 (thePnt1->GetStudyID(), thePnt1->GetEntry());
299 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
300 (thePnt2->GetStudyID(), thePnt2->GetEntry());
301 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
302 (thePnt3->GetStudyID(), thePnt3->GetEntry());
304 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
307 Handle(GEOM_Object) anObject =
308 GetOperations()->MakeArcOfEllipse(aPnt1, aPnt2, aPnt3);
309 if (!GetOperations()->IsDone() || anObject.IsNull())
310 return aGEOMObject._retn();
312 return GetObject(anObject);
315 //=============================================================================
319 //=============================================================================
320 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline
321 (const GEOM::ListOfGO& thePoints)
323 GEOM::GEOM_Object_var aGEOMObject;
325 //Set a not done flag
326 GetOperations()->SetNotDone();
328 //Get the reference point
330 int aLen = thePoints.length();
331 list<Handle(GEOM_Object)> aPoints;
332 for (; ind < aLen; ind++) {
333 if (thePoints[ind] == NULL) return aGEOMObject._retn();
335 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
336 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
338 if (aPnt.IsNull()) return aGEOMObject._retn();
339 aPoints.push_back(aPnt);
343 Handle(GEOM_Object) anObject =
344 GetOperations()->MakePolyline(aPoints);
345 if (!GetOperations()->IsDone() || anObject.IsNull())
346 return aGEOMObject._retn();
348 return GetObject(anObject);
351 //=============================================================================
355 //=============================================================================
356 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineBezier
357 (const GEOM::ListOfGO& thePoints)
359 GEOM::GEOM_Object_var aGEOMObject;
361 //Set a not done flag
362 GetOperations()->SetNotDone();
364 //Get the reference point
366 int aLen = thePoints.length();
367 list<Handle(GEOM_Object)> aPoints;
368 for (; ind < aLen; ind++) {
369 if (thePoints[ind] == NULL) return aGEOMObject._retn();
371 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
372 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
374 if (aPnt.IsNull()) return aGEOMObject._retn();
375 aPoints.push_back(aPnt);
379 Handle(GEOM_Object) anObject =
380 GetOperations()->MakeSplineBezier(aPoints);
381 if (!GetOperations()->IsDone() || anObject.IsNull())
382 return aGEOMObject._retn();
384 return GetObject(anObject);
387 //=============================================================================
389 * MakeSplineInterpolation
391 //=============================================================================
392 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
393 (const GEOM::ListOfGO& thePoints)
395 GEOM::GEOM_Object_var aGEOMObject;
397 //Set a not done flag
398 GetOperations()->SetNotDone();
400 //Get the reference point
402 int aLen = thePoints.length();
403 list<Handle(GEOM_Object)> aPoints;
404 for (; ind < aLen; ind++) {
405 if (thePoints[ind] == NULL) return aGEOMObject._retn();
407 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
408 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
410 if (aPnt.IsNull()) return aGEOMObject._retn();
411 aPoints.push_back(aPnt);
415 Handle(GEOM_Object) anObject =
416 GetOperations()->MakeSplineInterpolation(aPoints);
417 if (!GetOperations()->IsDone() || anObject.IsNull())
418 return aGEOMObject._retn();
420 return GetObject(anObject);
423 //=============================================================================
427 //=============================================================================
428 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
429 (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane)
431 //Set a not done flag
432 GetOperations()->SetNotDone();
435 int aLen = theWorkingPlane.length();
436 list<double> aWorkingPlane;
437 for (; ind < aLen; ind++)
438 aWorkingPlane.push_back(theWorkingPlane[ind]);
441 Handle(GEOM_Object) anObject =
442 GetOperations()->MakeSketcher(theCommand, aWorkingPlane);
443 if (!GetOperations()->IsDone() || anObject.IsNull())
444 return GEOM::GEOM_Object::_nil();
446 return GetObject(anObject);
449 //=============================================================================
453 //=============================================================================
454 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher
455 (const GEOM::ListOfDouble& theCoordinates)
457 //Set a not done flag
458 GetOperations()->SetNotDone();
461 int aLen = theCoordinates.length();
462 list<double> aCoords;
463 for (; ind < aLen; ind++)
464 aCoords.push_back(theCoordinates[ind]);
467 Handle(GEOM_Object) anObject =
468 GetOperations()->Make3DSketcher(aCoords);
469 if (!GetOperations()->IsDone() || anObject.IsNull())
470 return GEOM::GEOM_Object::_nil();
472 return GetObject(anObject);
475 //=============================================================================
477 * MakeSketcherOnPlane
479 //=============================================================================
480 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
481 (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
483 //Set a not done flag
484 GetOperations()->SetNotDone();
486 Handle(GEOM_Object) aWorkingPlane = GetOperations()->GetEngine()->GetObject
487 (theWorkingPlane->GetStudyID(), theWorkingPlane->GetEntry());
490 Handle(GEOM_Object) anObject =
491 GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane);
492 if (!GetOperations()->IsDone() || anObject.IsNull())
493 return GEOM::GEOM_Object::_nil();
495 return GetObject(anObject);