1 #include <Standard_Stream.hxx>
3 #include "GEOM_ICurvesOperations_i.hh"
8 #include "GEOM_Engine.hxx"
9 #include "GEOM_Object.hxx"
11 //=============================================================================
15 //=============================================================================
16 GEOM_ICurvesOperations_i::GEOM_ICurvesOperations_i (PortableServer::POA_ptr thePOA,
17 GEOM::GEOM_Gen_ptr theEngine,
18 ::GEOMImpl_ICurvesOperations* theImpl)
19 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
21 MESSAGE("GEOM_ICurvesOperations_i::GEOM_ICurvesOperations_i");
24 //=============================================================================
28 //=============================================================================
29 GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i()
31 MESSAGE("GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i");
35 //=============================================================================
39 //=============================================================================
40 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCirclePntVecR
41 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
44 GEOM::GEOM_Object_var aGEOMObject;
47 GetOperations()->SetNotDone();
49 if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
51 //Get the reference points
52 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
53 (thePnt->GetStudyID(), thePnt->GetEntry());
54 Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject
55 (theVec->GetStudyID(), theVec->GetEntry());
57 if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
60 Handle(GEOM_Object) anObject =
61 GetOperations()->MakeCirclePntVecR(aPnt, aVec, theR);
62 if (!GetOperations()->IsDone() || anObject.IsNull())
63 return aGEOMObject._retn();
65 return GetObject(anObject);
68 //=============================================================================
72 //=============================================================================
73 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleThreePnt
74 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
75 GEOM::GEOM_Object_ptr thePnt3)
77 GEOM::GEOM_Object_var aGEOMObject;
80 GetOperations()->SetNotDone();
82 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
84 //Get the reference points
85 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
86 (thePnt1->GetStudyID(), thePnt1->GetEntry());
87 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
88 (thePnt2->GetStudyID(), thePnt2->GetEntry());
89 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
90 (thePnt3->GetStudyID(), thePnt3->GetEntry());
92 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
95 Handle(GEOM_Object) anObject =
96 GetOperations()->MakeCircleThreePnt(aPnt1, aPnt2, aPnt3);
97 if (!GetOperations()->IsDone() || anObject.IsNull())
98 return aGEOMObject._retn();
100 return GetObject(anObject);
103 //=============================================================================
107 //=============================================================================
108 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipse
109 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
110 CORBA::Double theRMajor, double theRMinor)
112 GEOM::GEOM_Object_var aGEOMObject;
114 //Set a not done flag
115 GetOperations()->SetNotDone();
117 if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
119 //Get the reference points
120 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
121 (thePnt->GetStudyID(), thePnt->GetEntry());
122 Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject
123 (theVec->GetStudyID(), theVec->GetEntry());
125 if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
128 Handle(GEOM_Object) anObject =
129 GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor);
130 if (!GetOperations()->IsDone() || anObject.IsNull())
131 return aGEOMObject._retn();
133 return GetObject(anObject);
136 //=============================================================================
140 //=============================================================================
141 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArc
142 (GEOM::GEOM_Object_ptr thePnt1,
143 GEOM::GEOM_Object_ptr thePnt2,
144 GEOM::GEOM_Object_ptr thePnt3)
146 GEOM::GEOM_Object_var aGEOMObject;
148 //Set a not done flag
149 GetOperations()->SetNotDone();
151 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
153 //Get the reference points
154 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
155 (thePnt1->GetStudyID(), thePnt1->GetEntry());
156 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
157 (thePnt2->GetStudyID(), thePnt2->GetEntry());
158 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
159 (thePnt3->GetStudyID(), thePnt3->GetEntry());
161 if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
164 Handle(GEOM_Object) anObject =
165 GetOperations()->MakeArc(aPnt1, aPnt2, aPnt3);
166 if (!GetOperations()->IsDone() || anObject.IsNull())
167 return aGEOMObject._retn();
169 return GetObject(anObject);
172 //=============================================================================
176 //=============================================================================
177 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline
178 (const GEOM::ListOfGO& thePoints)
180 GEOM::GEOM_Object_var aGEOMObject;
182 //Set a not done flag
183 GetOperations()->SetNotDone();
185 //Get the reference point
187 int aLen = thePoints.length();
188 list<Handle(GEOM_Object)> aPoints;
189 for (; ind < aLen; ind++) {
190 if (thePoints[ind] == NULL) return aGEOMObject._retn();
192 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
193 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
195 if (aPnt.IsNull()) return aGEOMObject._retn();
196 aPoints.push_back(aPnt);
200 Handle(GEOM_Object) anObject =
201 GetOperations()->MakePolyline(aPoints);
202 if (!GetOperations()->IsDone() || anObject.IsNull())
203 return aGEOMObject._retn();
205 return GetObject(anObject);
208 //=============================================================================
212 //=============================================================================
213 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineBezier
214 (const GEOM::ListOfGO& thePoints)
216 GEOM::GEOM_Object_var aGEOMObject;
218 //Set a not done flag
219 GetOperations()->SetNotDone();
221 //Get the reference point
223 int aLen = thePoints.length();
224 list<Handle(GEOM_Object)> aPoints;
225 for (; ind < aLen; ind++) {
226 if (thePoints[ind] == NULL) return aGEOMObject._retn();
228 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
229 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
231 if (aPnt.IsNull()) return aGEOMObject._retn();
232 aPoints.push_back(aPnt);
236 Handle(GEOM_Object) anObject =
237 GetOperations()->MakeSplineBezier(aPoints);
238 if (!GetOperations()->IsDone() || anObject.IsNull())
239 return aGEOMObject._retn();
241 return GetObject(anObject);
244 //=============================================================================
246 * MakeSplineInterpolation
248 //=============================================================================
249 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
250 (const GEOM::ListOfGO& thePoints)
252 GEOM::GEOM_Object_var aGEOMObject;
254 //Set a not done flag
255 GetOperations()->SetNotDone();
257 //Get the reference point
259 int aLen = thePoints.length();
260 list<Handle(GEOM_Object)> aPoints;
261 for (; ind < aLen; ind++) {
262 if (thePoints[ind] == NULL) return aGEOMObject._retn();
264 Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
265 (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry());
267 if (aPnt.IsNull()) return aGEOMObject._retn();
268 aPoints.push_back(aPnt);
272 Handle(GEOM_Object) anObject =
273 GetOperations()->MakeSplineInterpolation(aPoints);
274 if (!GetOperations()->IsDone() || anObject.IsNull())
275 return aGEOMObject._retn();
277 return GetObject(anObject);
280 //=============================================================================
284 //=============================================================================
285 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
286 (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane)
288 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_nil();
290 //Set a not done flag
291 GetOperations()->SetNotDone();
294 int aLen = theWorkingPlane.length();
295 list<double> aWorkingPlane;
296 for (; ind < aLen; ind++)
297 aWorkingPlane.push_back(theWorkingPlane[ind]);
300 Handle(GEOM_Object) anObject =
301 GetOperations()->MakeSketcher(strdup(theCommand), aWorkingPlane);
302 if (!GetOperations()->IsDone() || anObject.IsNull())
303 //return aGEOMObject._retn();
304 return GEOM::GEOM_Object::_nil();
306 return GetObject(anObject);
310 //=============================================================================
312 * MakeSketcherOnPlane
314 //=============================================================================
315 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
316 (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
318 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_nil();
320 //Set a not done flag
321 GetOperations()->SetNotDone();
323 Handle(GEOM_Object) aWorkingPlane = GetOperations()->GetEngine()->GetObject
324 (theWorkingPlane->GetStudyID(), theWorkingPlane->GetEntry());
327 Handle(GEOM_Object) anObject =
328 GetOperations()->MakeSketcherOnPlane(strdup(theCommand), aWorkingPlane);
329 if (!GetOperations()->IsDone() || anObject.IsNull())
330 return aGEOMObject._retn();
332 return GetObject(anObject);