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);
191 //=============================================================================
195 //=============================================================================
196 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline
197 (const GEOM::ListOfGO& thePoints)
199 GEOM::GEOM_Object_var aGEOMObject;
201 //Set a not done flag
202 GetOperations()->SetNotDone();
204 //Get the reference point
206 int aLen = thePoints.length();
207 list<Handle(GEOM_Object)> aPoints;
208 for (; ind < aLen; ind++) {
209 if (thePoints[ind] == NULL) return aGEOMObject._retn();
211 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
212 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
214 if (aPnt.IsNull()) return aGEOMObject._retn();
215 aPoints.push_back(aPnt);
219 Handle(GEOM_Object) anObject =
220 GetOperations()->MakePolyline(aPoints);
221 if (!GetOperations()->IsDone() || anObject.IsNull())
222 return aGEOMObject._retn();
224 return GetObject(anObject);
227 //=============================================================================
231 //=============================================================================
232 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineBezier
233 (const GEOM::ListOfGO& thePoints)
235 GEOM::GEOM_Object_var aGEOMObject;
237 //Set a not done flag
238 GetOperations()->SetNotDone();
240 //Get the reference point
242 int aLen = thePoints.length();
243 list<Handle(GEOM_Object)> aPoints;
244 for (; ind < aLen; ind++) {
245 if (thePoints[ind] == NULL) return aGEOMObject._retn();
247 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
248 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
250 if (aPnt.IsNull()) return aGEOMObject._retn();
251 aPoints.push_back(aPnt);
255 Handle(GEOM_Object) anObject =
256 GetOperations()->MakeSplineBezier(aPoints);
257 if (!GetOperations()->IsDone() || anObject.IsNull())
258 return aGEOMObject._retn();
260 return GetObject(anObject);
263 //=============================================================================
265 * MakeSplineInterpolation
267 //=============================================================================
268 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
269 (const GEOM::ListOfGO& thePoints)
271 GEOM::GEOM_Object_var aGEOMObject;
273 //Set a not done flag
274 GetOperations()->SetNotDone();
276 //Get the reference point
278 int aLen = thePoints.length();
279 list<Handle(GEOM_Object)> aPoints;
280 for (; ind < aLen; ind++) {
281 if (thePoints[ind] == NULL) return aGEOMObject._retn();
283 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
284 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
286 if (aPnt.IsNull()) return aGEOMObject._retn();
287 aPoints.push_back(aPnt);
291 Handle(GEOM_Object) anObject =
292 GetOperations()->MakeSplineInterpolation(aPoints);
293 if (!GetOperations()->IsDone() || anObject.IsNull())
294 return aGEOMObject._retn();
296 return GetObject(anObject);
299 //=============================================================================
303 //=============================================================================
304 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
305 (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane)
307 //Set a not done flag
308 GetOperations()->SetNotDone();
311 int aLen = theWorkingPlane.length();
312 list<double> aWorkingPlane;
313 for (; ind < aLen; ind++)
314 aWorkingPlane.push_back(theWorkingPlane[ind]);
317 Handle(GEOM_Object) anObject =
318 GetOperations()->MakeSketcher((char*)theCommand, aWorkingPlane);
319 if (!GetOperations()->IsDone() || anObject.IsNull())
320 return GEOM::GEOM_Object::_nil();
322 return GetObject(anObject);
326 //=============================================================================
328 * MakeSketcherOnPlane
330 //=============================================================================
331 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
332 (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
334 //Set a not done flag
335 GetOperations()->SetNotDone();
337 Handle(GEOM_Object) aWorkingPlane = GetOperations()->GetEngine()->GetObject
338 (theWorkingPlane->GetStudyID(), theWorkingPlane->GetEntry());
341 Handle(GEOM_Object) anObject =
342 GetOperations()->MakeSketcherOnPlane((char*)theCommand, aWorkingPlane);
343 if (!GetOperations()->IsDone() || anObject.IsNull())
344 return GEOM::GEOM_Object::_nil();
346 return GetObject(anObject);