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 //=============================================================================
126 //=============================================================================
127 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipse
128 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
129 CORBA::Double theRMajor, double theRMinor)
131 GEOM::GEOM_Object_var aGEOMObject;
133 //Set a not done flag
134 GetOperations()->SetNotDone();
136 if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
138 //Get the reference points
139 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
140 (thePnt->GetStudyID(), thePnt->GetEntry());
141 Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject
142 (theVec->GetStudyID(), theVec->GetEntry());
144 if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
147 Handle(GEOM_Object) anObject =
148 GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor);
149 if (!GetOperations()->IsDone() || anObject.IsNull())
150 return aGEOMObject._retn();
152 return GetObject(anObject);
155 //=============================================================================
159 //=============================================================================
160 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArc
161 (GEOM::GEOM_Object_ptr thePnt1,
162 GEOM::GEOM_Object_ptr thePnt2,
163 GEOM::GEOM_Object_ptr thePnt3)
165 GEOM::GEOM_Object_var aGEOMObject;
167 //Set a not done flag
168 GetOperations()->SetNotDone();
170 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
172 //Get the reference points
173 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
174 (thePnt1->GetStudyID(), thePnt1->GetEntry());
175 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
176 (thePnt2->GetStudyID(), thePnt2->GetEntry());
177 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
178 (thePnt3->GetStudyID(), thePnt3->GetEntry());
180 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
183 Handle(GEOM_Object) anObject =
184 GetOperations()->MakeArc(aPnt1, aPnt2, aPnt3);
185 if (!GetOperations()->IsDone() || anObject.IsNull())
186 return aGEOMObject._retn();
188 return GetObject(anObject);
192 //=============================================================================
196 //=============================================================================
197 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcCenter
198 (GEOM::GEOM_Object_ptr thePnt1,
199 GEOM::GEOM_Object_ptr thePnt2,
200 GEOM::GEOM_Object_ptr thePnt3,
201 CORBA::Boolean theSense)
204 GEOM::GEOM_Object_var aGEOMObject;
205 //Set a not done flag
206 GetOperations()->SetNotDone();
208 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
210 //Get the reference points
211 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
212 (thePnt1->GetStudyID(), thePnt1->GetEntry());
213 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
214 (thePnt2->GetStudyID(), thePnt2->GetEntry());
215 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
216 (thePnt3->GetStudyID(), thePnt3->GetEntry());
218 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
221 Handle(GEOM_Object) anObject =
222 GetOperations()->MakeArcCenter(aPnt1, aPnt2, aPnt3,theSense);
223 if (!GetOperations()->IsDone() || anObject.IsNull())
224 return aGEOMObject._retn();
226 return GetObject(anObject);
228 //=============================================================================
232 //=============================================================================
233 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline
234 (const GEOM::ListOfGO& thePoints)
236 GEOM::GEOM_Object_var aGEOMObject;
238 //Set a not done flag
239 GetOperations()->SetNotDone();
241 //Get the reference point
243 int aLen = thePoints.length();
244 list<Handle(GEOM_Object)> aPoints;
245 for (; ind < aLen; ind++) {
246 if (thePoints[ind] == NULL) return aGEOMObject._retn();
248 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
249 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
251 if (aPnt.IsNull()) return aGEOMObject._retn();
252 aPoints.push_back(aPnt);
256 Handle(GEOM_Object) anObject =
257 GetOperations()->MakePolyline(aPoints);
258 if (!GetOperations()->IsDone() || anObject.IsNull())
259 return aGEOMObject._retn();
261 return GetObject(anObject);
264 //=============================================================================
268 //=============================================================================
269 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineBezier
270 (const GEOM::ListOfGO& thePoints)
272 GEOM::GEOM_Object_var aGEOMObject;
274 //Set a not done flag
275 GetOperations()->SetNotDone();
277 //Get the reference point
279 int aLen = thePoints.length();
280 list<Handle(GEOM_Object)> aPoints;
281 for (; ind < aLen; ind++) {
282 if (thePoints[ind] == NULL) return aGEOMObject._retn();
284 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
285 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
287 if (aPnt.IsNull()) return aGEOMObject._retn();
288 aPoints.push_back(aPnt);
292 Handle(GEOM_Object) anObject =
293 GetOperations()->MakeSplineBezier(aPoints);
294 if (!GetOperations()->IsDone() || anObject.IsNull())
295 return aGEOMObject._retn();
297 return GetObject(anObject);
300 //=============================================================================
302 * MakeSplineInterpolation
304 //=============================================================================
305 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
306 (const GEOM::ListOfGO& thePoints)
308 GEOM::GEOM_Object_var aGEOMObject;
310 //Set a not done flag
311 GetOperations()->SetNotDone();
313 //Get the reference point
315 int aLen = thePoints.length();
316 list<Handle(GEOM_Object)> aPoints;
317 for (; ind < aLen; ind++) {
318 if (thePoints[ind] == NULL) return aGEOMObject._retn();
320 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
321 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
323 if (aPnt.IsNull()) return aGEOMObject._retn();
324 aPoints.push_back(aPnt);
328 Handle(GEOM_Object) anObject =
329 GetOperations()->MakeSplineInterpolation(aPoints);
330 if (!GetOperations()->IsDone() || anObject.IsNull())
331 return aGEOMObject._retn();
333 return GetObject(anObject);
336 //=============================================================================
340 //=============================================================================
341 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
342 (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane)
344 //Set a not done flag
345 GetOperations()->SetNotDone();
348 int aLen = theWorkingPlane.length();
349 list<double> aWorkingPlane;
350 for (; ind < aLen; ind++)
351 aWorkingPlane.push_back(theWorkingPlane[ind]);
354 Handle(GEOM_Object) anObject =
355 GetOperations()->MakeSketcher((char*)theCommand, aWorkingPlane);
356 if (!GetOperations()->IsDone() || anObject.IsNull())
357 return GEOM::GEOM_Object::_nil();
359 return GetObject(anObject);
363 //=============================================================================
365 * MakeSketcherOnPlane
367 //=============================================================================
368 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
369 (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
371 //Set a not done flag
372 GetOperations()->SetNotDone();
374 Handle(GEOM_Object) aWorkingPlane = GetOperations()->GetEngine()->GetObject
375 (theWorkingPlane->GetStudyID(), theWorkingPlane->GetEntry());
378 Handle(GEOM_Object) anObject =
379 GetOperations()->MakeSketcherOnPlane((char*)theCommand, aWorkingPlane);
380 if (!GetOperations()->IsDone() || anObject.IsNull())
381 return GEOM::GEOM_Object::_nil();
383 return GetObject(anObject);