1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <Standard_Stream.hxx>
22 #include "GEOM_ICurvesOperations_i.hh"
24 #include "utilities.h"
27 #include "GEOM_Engine.hxx"
28 #include "GEOM_Object.hxx"
30 //=============================================================================
34 //=============================================================================
35 GEOM_ICurvesOperations_i::GEOM_ICurvesOperations_i (PortableServer::POA_ptr thePOA,
36 GEOM::GEOM_Gen_ptr theEngine,
37 ::GEOMImpl_ICurvesOperations* theImpl)
38 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
40 MESSAGE("GEOM_ICurvesOperations_i::GEOM_ICurvesOperations_i");
43 //=============================================================================
47 //=============================================================================
48 GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i()
50 MESSAGE("GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i");
54 //=============================================================================
58 //=============================================================================
59 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCirclePntVecR
60 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
63 GEOM::GEOM_Object_var aGEOMObject;
66 GetOperations()->SetNotDone();
68 // Not set thePnt means origin of global CS,
69 // Not set theVec means Z axis of global CS
70 //if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
73 Handle(GEOM_Object) aPnt, aVec;
74 if (!CORBA::is_nil(thePnt)) {
75 aPnt = GetOperations()->GetEngine()->GetObject
76 (thePnt->GetStudyID(), thePnt->GetEntry());
77 if (aPnt.IsNull()) return aGEOMObject._retn();
79 if (!CORBA::is_nil(theVec)) {
80 aVec = GetOperations()->GetEngine()->GetObject
81 (theVec->GetStudyID(), theVec->GetEntry());
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 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
110 //Get the reference points
111 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
112 (thePnt1->GetStudyID(), thePnt1->GetEntry());
113 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
114 (thePnt2->GetStudyID(), thePnt2->GetEntry());
115 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
116 (thePnt3->GetStudyID(), thePnt3->GetEntry());
118 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
121 Handle(GEOM_Object) anObject =
122 GetOperations()->MakeCircleThreePnt(aPnt1, aPnt2, aPnt3);
123 if (!GetOperations()->IsDone() || anObject.IsNull())
124 return aGEOMObject._retn();
126 return GetObject(anObject);
129 //=============================================================================
131 * MakeCircleCenter2Pnt
133 //=============================================================================
134 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleCenter2Pnt
135 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
136 GEOM::GEOM_Object_ptr thePnt3)
138 GEOM::GEOM_Object_var aGEOMObject;
140 //Set a not done flag
141 GetOperations()->SetNotDone();
143 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
145 //Get the reference points
146 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
147 (thePnt1->GetStudyID(), thePnt1->GetEntry());
148 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
149 (thePnt2->GetStudyID(), thePnt2->GetEntry());
150 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
151 (thePnt3->GetStudyID(), thePnt3->GetEntry());
153 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
156 Handle(GEOM_Object) anObject = GetOperations()->MakeCircleCenter2Pnt(aPnt1, aPnt2, aPnt3);
157 if (!GetOperations()->IsDone() || anObject.IsNull())
158 return aGEOMObject._retn();
160 return GetObject(anObject);
163 //=============================================================================
167 //=============================================================================
168 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipse
169 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
170 CORBA::Double theRMajor, double theRMinor)
172 GEOM::GEOM_Object_var aGEOMObject;
174 //Set a not done flag
175 GetOperations()->SetNotDone();
177 // Not set thePnt means origin of global CS,
178 // Not set theVec means Z axis of global CS
179 //if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
182 Handle(GEOM_Object) aPnt, aVec;
183 if (!CORBA::is_nil(thePnt)) {
184 aPnt = GetOperations()->GetEngine()->GetObject
185 (thePnt->GetStudyID(), thePnt->GetEntry());
186 if (aPnt.IsNull()) return aGEOMObject._retn();
188 if (!CORBA::is_nil(theVec)) {
189 aVec = GetOperations()->GetEngine()->GetObject
190 (theVec->GetStudyID(), theVec->GetEntry());
191 if (aVec.IsNull()) return aGEOMObject._retn();
195 Handle(GEOM_Object) anObject =
196 GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor);
197 if (!GetOperations()->IsDone() || anObject.IsNull())
198 return aGEOMObject._retn();
200 return GetObject(anObject);
203 //=============================================================================
207 //=============================================================================
208 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArc
209 (GEOM::GEOM_Object_ptr thePnt1,
210 GEOM::GEOM_Object_ptr thePnt2,
211 GEOM::GEOM_Object_ptr thePnt3)
213 GEOM::GEOM_Object_var aGEOMObject;
215 //Set a not done flag
216 GetOperations()->SetNotDone();
218 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
220 //Get the reference points
221 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
222 (thePnt1->GetStudyID(), thePnt1->GetEntry());
223 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
224 (thePnt2->GetStudyID(), thePnt2->GetEntry());
225 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
226 (thePnt3->GetStudyID(), thePnt3->GetEntry());
228 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
231 Handle(GEOM_Object) anObject =
232 GetOperations()->MakeArc(aPnt1, aPnt2, aPnt3);
233 if (!GetOperations()->IsDone() || anObject.IsNull())
234 return aGEOMObject._retn();
236 return GetObject(anObject);
240 //=============================================================================
244 //=============================================================================
245 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcCenter
246 (GEOM::GEOM_Object_ptr thePnt1,
247 GEOM::GEOM_Object_ptr thePnt2,
248 GEOM::GEOM_Object_ptr thePnt3,
249 CORBA::Boolean theSense)
252 GEOM::GEOM_Object_var aGEOMObject;
253 //Set a not done flag
254 GetOperations()->SetNotDone();
256 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
258 //Get the reference points
259 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
260 (thePnt1->GetStudyID(), thePnt1->GetEntry());
261 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
262 (thePnt2->GetStudyID(), thePnt2->GetEntry());
263 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
264 (thePnt3->GetStudyID(), thePnt3->GetEntry());
266 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
269 Handle(GEOM_Object) anObject =
270 GetOperations()->MakeArcCenter(aPnt1, aPnt2, aPnt3,theSense);
271 if (!GetOperations()->IsDone() || anObject.IsNull())
272 return aGEOMObject._retn();
274 return GetObject(anObject);
276 //=============================================================================
280 //=============================================================================
281 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline
282 (const GEOM::ListOfGO& thePoints)
284 GEOM::GEOM_Object_var aGEOMObject;
286 //Set a not done flag
287 GetOperations()->SetNotDone();
289 //Get the reference point
291 int aLen = thePoints.length();
292 list<Handle(GEOM_Object)> aPoints;
293 for (; ind < aLen; ind++) {
294 if (thePoints[ind] == NULL) return aGEOMObject._retn();
296 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
297 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
299 if (aPnt.IsNull()) return aGEOMObject._retn();
300 aPoints.push_back(aPnt);
304 Handle(GEOM_Object) anObject =
305 GetOperations()->MakePolyline(aPoints);
306 if (!GetOperations()->IsDone() || anObject.IsNull())
307 return aGEOMObject._retn();
309 return GetObject(anObject);
312 //=============================================================================
316 //=============================================================================
317 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineBezier
318 (const GEOM::ListOfGO& thePoints)
320 GEOM::GEOM_Object_var aGEOMObject;
322 //Set a not done flag
323 GetOperations()->SetNotDone();
325 //Get the reference point
327 int aLen = thePoints.length();
328 list<Handle(GEOM_Object)> aPoints;
329 for (; ind < aLen; ind++) {
330 if (thePoints[ind] == NULL) return aGEOMObject._retn();
332 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
333 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
335 if (aPnt.IsNull()) return aGEOMObject._retn();
336 aPoints.push_back(aPnt);
340 Handle(GEOM_Object) anObject =
341 GetOperations()->MakeSplineBezier(aPoints);
342 if (!GetOperations()->IsDone() || anObject.IsNull())
343 return aGEOMObject._retn();
345 return GetObject(anObject);
348 //=============================================================================
350 * MakeSplineInterpolation
352 //=============================================================================
353 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
354 (const GEOM::ListOfGO& thePoints)
356 GEOM::GEOM_Object_var aGEOMObject;
358 //Set a not done flag
359 GetOperations()->SetNotDone();
361 //Get the reference point
363 int aLen = thePoints.length();
364 list<Handle(GEOM_Object)> aPoints;
365 for (; ind < aLen; ind++) {
366 if (thePoints[ind] == NULL) return aGEOMObject._retn();
368 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
369 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
371 if (aPnt.IsNull()) return aGEOMObject._retn();
372 aPoints.push_back(aPnt);
376 Handle(GEOM_Object) anObject =
377 GetOperations()->MakeSplineInterpolation(aPoints);
378 if (!GetOperations()->IsDone() || anObject.IsNull())
379 return aGEOMObject._retn();
381 return GetObject(anObject);
384 //=============================================================================
388 //=============================================================================
389 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
390 (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane)
392 //Set a not done flag
393 GetOperations()->SetNotDone();
396 int aLen = theWorkingPlane.length();
397 list<double> aWorkingPlane;
398 for (; ind < aLen; ind++)
399 aWorkingPlane.push_back(theWorkingPlane[ind]);
402 Handle(GEOM_Object) anObject =
403 GetOperations()->MakeSketcher((char*)theCommand, aWorkingPlane);
404 if (!GetOperations()->IsDone() || anObject.IsNull())
405 return GEOM::GEOM_Object::_nil();
407 return GetObject(anObject);
411 //=============================================================================
413 * MakeSketcherOnPlane
415 //=============================================================================
416 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
417 (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
419 //Set a not done flag
420 GetOperations()->SetNotDone();
422 Handle(GEOM_Object) aWorkingPlane = GetOperations()->GetEngine()->GetObject
423 (theWorkingPlane->GetStudyID(), theWorkingPlane->GetEntry());
426 Handle(GEOM_Object) anObject =
427 GetOperations()->MakeSketcherOnPlane((char*)theCommand, aWorkingPlane);
428 if (!GetOperations()->IsDone() || anObject.IsNull())
429 return GEOM::GEOM_Object::_nil();
431 return GetObject(anObject);