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 if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
70 //Get the reference points
71 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
72 (thePnt->GetStudyID(), thePnt->GetEntry());
73 Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject
74 (theVec->GetStudyID(), theVec->GetEntry());
76 if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
79 Handle(GEOM_Object) anObject =
80 GetOperations()->MakeCirclePntVecR(aPnt, aVec, theR);
81 if (!GetOperations()->IsDone() || anObject.IsNull())
82 return aGEOMObject._retn();
84 return GetObject(anObject);
87 //=============================================================================
91 //=============================================================================
92 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleThreePnt
93 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
94 GEOM::GEOM_Object_ptr thePnt3)
96 GEOM::GEOM_Object_var aGEOMObject;
99 GetOperations()->SetNotDone();
101 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
103 //Get the reference points
104 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
105 (thePnt1->GetStudyID(), thePnt1->GetEntry());
106 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
107 (thePnt2->GetStudyID(), thePnt2->GetEntry());
108 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
109 (thePnt3->GetStudyID(), thePnt3->GetEntry());
111 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
114 Handle(GEOM_Object) anObject =
115 GetOperations()->MakeCircleThreePnt(aPnt1, aPnt2, aPnt3);
116 if (!GetOperations()->IsDone() || anObject.IsNull())
117 return aGEOMObject._retn();
119 return GetObject(anObject);
122 //=============================================================================
124 * MakeCircleCenter2Pnt
126 //=============================================================================
127 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleCenter2Pnt
128 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
129 GEOM::GEOM_Object_ptr thePnt3)
131 GEOM::GEOM_Object_var aGEOMObject;
133 //Set a not done flag
134 GetOperations()->SetNotDone();
136 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
138 //Get the reference points
139 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
140 (thePnt1->GetStudyID(), thePnt1->GetEntry());
141 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
142 (thePnt2->GetStudyID(), thePnt2->GetEntry());
143 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
144 (thePnt3->GetStudyID(), thePnt3->GetEntry());
146 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
149 Handle(GEOM_Object) anObject = GetOperations()->MakeCircleCenter2Pnt(aPnt1, aPnt2, aPnt3);
150 if (!GetOperations()->IsDone() || anObject.IsNull())
151 return aGEOMObject._retn();
153 return GetObject(anObject);
156 //=============================================================================
160 //=============================================================================
161 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipse
162 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
163 CORBA::Double theRMajor, double theRMinor)
165 GEOM::GEOM_Object_var aGEOMObject;
167 //Set a not done flag
168 GetOperations()->SetNotDone();
170 if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
172 //Get the reference points
173 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
174 (thePnt->GetStudyID(), thePnt->GetEntry());
175 Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject
176 (theVec->GetStudyID(), theVec->GetEntry());
178 if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
181 Handle(GEOM_Object) anObject =
182 GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor);
183 if (!GetOperations()->IsDone() || anObject.IsNull())
184 return aGEOMObject._retn();
186 return GetObject(anObject);
189 //=============================================================================
193 //=============================================================================
194 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArc
195 (GEOM::GEOM_Object_ptr thePnt1,
196 GEOM::GEOM_Object_ptr thePnt2,
197 GEOM::GEOM_Object_ptr thePnt3)
199 GEOM::GEOM_Object_var aGEOMObject;
201 //Set a not done flag
202 GetOperations()->SetNotDone();
204 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
206 //Get the reference points
207 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
208 (thePnt1->GetStudyID(), thePnt1->GetEntry());
209 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
210 (thePnt2->GetStudyID(), thePnt2->GetEntry());
211 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
212 (thePnt3->GetStudyID(), thePnt3->GetEntry());
214 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
217 Handle(GEOM_Object) anObject =
218 GetOperations()->MakeArc(aPnt1, aPnt2, aPnt3);
219 if (!GetOperations()->IsDone() || anObject.IsNull())
220 return aGEOMObject._retn();
222 return GetObject(anObject);
226 //=============================================================================
230 //=============================================================================
231 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcCenter
232 (GEOM::GEOM_Object_ptr thePnt1,
233 GEOM::GEOM_Object_ptr thePnt2,
234 GEOM::GEOM_Object_ptr thePnt3,
235 CORBA::Boolean theSense)
238 GEOM::GEOM_Object_var aGEOMObject;
239 //Set a not done flag
240 GetOperations()->SetNotDone();
242 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
244 //Get the reference points
245 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
246 (thePnt1->GetStudyID(), thePnt1->GetEntry());
247 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
248 (thePnt2->GetStudyID(), thePnt2->GetEntry());
249 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
250 (thePnt3->GetStudyID(), thePnt3->GetEntry());
252 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
255 Handle(GEOM_Object) anObject =
256 GetOperations()->MakeArcCenter(aPnt1, aPnt2, aPnt3,theSense);
257 if (!GetOperations()->IsDone() || anObject.IsNull())
258 return aGEOMObject._retn();
260 return GetObject(anObject);
262 //=============================================================================
266 //=============================================================================
267 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline
268 (const GEOM::ListOfGO& thePoints)
270 GEOM::GEOM_Object_var aGEOMObject;
272 //Set a not done flag
273 GetOperations()->SetNotDone();
275 //Get the reference point
277 int aLen = thePoints.length();
278 list<Handle(GEOM_Object)> aPoints;
279 for (; ind < aLen; ind++) {
280 if (thePoints[ind] == NULL) return aGEOMObject._retn();
282 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
283 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
285 if (aPnt.IsNull()) return aGEOMObject._retn();
286 aPoints.push_back(aPnt);
290 Handle(GEOM_Object) anObject =
291 GetOperations()->MakePolyline(aPoints);
292 if (!GetOperations()->IsDone() || anObject.IsNull())
293 return aGEOMObject._retn();
295 return GetObject(anObject);
298 //=============================================================================
302 //=============================================================================
303 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineBezier
304 (const GEOM::ListOfGO& thePoints)
306 GEOM::GEOM_Object_var aGEOMObject;
308 //Set a not done flag
309 GetOperations()->SetNotDone();
311 //Get the reference point
313 int aLen = thePoints.length();
314 list<Handle(GEOM_Object)> aPoints;
315 for (; ind < aLen; ind++) {
316 if (thePoints[ind] == NULL) return aGEOMObject._retn();
318 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
319 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
321 if (aPnt.IsNull()) return aGEOMObject._retn();
322 aPoints.push_back(aPnt);
326 Handle(GEOM_Object) anObject =
327 GetOperations()->MakeSplineBezier(aPoints);
328 if (!GetOperations()->IsDone() || anObject.IsNull())
329 return aGEOMObject._retn();
331 return GetObject(anObject);
334 //=============================================================================
336 * MakeSplineInterpolation
338 //=============================================================================
339 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
340 (const GEOM::ListOfGO& thePoints)
342 GEOM::GEOM_Object_var aGEOMObject;
344 //Set a not done flag
345 GetOperations()->SetNotDone();
347 //Get the reference point
349 int aLen = thePoints.length();
350 list<Handle(GEOM_Object)> aPoints;
351 for (; ind < aLen; ind++) {
352 if (thePoints[ind] == NULL) return aGEOMObject._retn();
354 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
355 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
357 if (aPnt.IsNull()) return aGEOMObject._retn();
358 aPoints.push_back(aPnt);
362 Handle(GEOM_Object) anObject =
363 GetOperations()->MakeSplineInterpolation(aPoints);
364 if (!GetOperations()->IsDone() || anObject.IsNull())
365 return aGEOMObject._retn();
367 return GetObject(anObject);
370 //=============================================================================
374 //=============================================================================
375 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
376 (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane)
378 //Set a not done flag
379 GetOperations()->SetNotDone();
382 int aLen = theWorkingPlane.length();
383 list<double> aWorkingPlane;
384 for (; ind < aLen; ind++)
385 aWorkingPlane.push_back(theWorkingPlane[ind]);
388 Handle(GEOM_Object) anObject =
389 GetOperations()->MakeSketcher((char*)theCommand, aWorkingPlane);
390 if (!GetOperations()->IsDone() || anObject.IsNull())
391 return GEOM::GEOM_Object::_nil();
393 return GetObject(anObject);
397 //=============================================================================
399 * MakeSketcherOnPlane
401 //=============================================================================
402 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
403 (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
405 //Set a not done flag
406 GetOperations()->SetNotDone();
408 Handle(GEOM_Object) aWorkingPlane = GetOperations()->GetEngine()->GetObject
409 (theWorkingPlane->GetStudyID(), theWorkingPlane->GetEntry());
412 Handle(GEOM_Object) anObject =
413 GetOperations()->MakeSketcherOnPlane((char*)theCommand, aWorkingPlane);
414 if (!GetOperations()->IsDone() || anObject.IsNull())
415 return GEOM::GEOM_Object::_nil();
417 return GetObject(anObject);