]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOM_I/GEOM_IBasicOperations_i.cc
Salome HOME
IMPs 19766 (Wire from unconnected edges) and 20004 (NumberOfSolids)
[modules/geom.git] / src / GEOM_I / GEOM_IBasicOperations_i.cc
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21
22 #include <Standard_Stream.hxx>
23
24 #include "GEOM_IBasicOperations_i.hh"
25
26 #include "utilities.h"
27 #include "OpUtil.hxx"
28 #include "Utils_ExceptHandlers.hxx"
29
30 #include "GEOM_Engine.hxx"
31 #include "GEOM_Object.hxx"
32
33 //=============================================================================
34 /*!
35  *   constructor:
36  */
37 //=============================================================================
38 GEOM_IBasicOperations_i::GEOM_IBasicOperations_i (PortableServer::POA_ptr thePOA,
39                                                   GEOM::GEOM_Gen_ptr theEngine,
40                                                   ::GEOMImpl_IBasicOperations* theImpl)
41      :GEOM_IOperations_i(thePOA, theEngine, theImpl)
42 {
43   MESSAGE("GEOM_IBasicOperations_i::GEOM_IBasicOperations_i");
44 }
45
46 //=============================================================================
47 /*!
48  *  destructor
49  */
50 //=============================================================================
51 GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i()
52 {
53   MESSAGE("GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i");
54 }
55
56
57 //=============================================================================
58 /*!
59  *  MakePointXYZ
60  */
61 //=============================================================================
62 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointXYZ
63   (CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ)
64 {
65   GEOM::GEOM_Object_var aGEOMObject;
66
67   //Set a not done flag
68   GetOperations()->SetNotDone();
69
70   //Create the point
71   Handle(GEOM_Object) anObject = GetOperations()->MakePointXYZ(theX, theY, theZ);
72   if (!GetOperations()->IsDone() || anObject.IsNull())
73     return aGEOMObject._retn();
74
75   return GetObject(anObject);
76 }
77
78 //=============================================================================
79 /*!
80  *  MakePointWithReference
81  */
82 //=============================================================================
83 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointWithReference
84   (GEOM::GEOM_Object_ptr theReference, CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ)
85 {
86   GEOM::GEOM_Object_var aGEOMObject;
87
88   //Set a not done flag
89   GetOperations()->SetNotDone();
90
91   //Get the reference point
92   Handle(GEOM_Object) aReference = GetObjectImpl(theReference);
93   if (aReference.IsNull()) return aGEOMObject._retn();
94
95   //Create the point
96   Handle(GEOM_Object) anObject =
97     GetOperations()->MakePointWithReference(aReference, theX, theY, theZ);
98   if (!GetOperations()->IsDone() || anObject.IsNull())
99     return aGEOMObject._retn();
100
101   return GetObject(anObject);
102 }
103
104 //=============================================================================
105 /*!
106  *  MakePointOnLinesIntersection
107  */
108 //=============================================================================
109 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnLinesIntersection
110                   (GEOM::GEOM_Object_ptr theLine1,  GEOM::GEOM_Object_ptr theLine2)
111 {
112   GEOM::GEOM_Object_var aGEOMObject;
113
114   //Set a not done flag
115   GetOperations()->SetNotDone();
116
117   //Get the reference Lines
118   Handle(GEOM_Object) aRef1 = GetObjectImpl(theLine1);
119   Handle(GEOM_Object) aRef2 = GetObjectImpl(theLine2);
120   if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
121
122   //Create the point
123   Handle(GEOM_Object) anObject =
124     GetOperations()->MakePointOnLinesIntersection(aRef1, aRef2);
125   if (!GetOperations()->IsDone() || anObject.IsNull())
126     return aGEOMObject._retn();
127
128   return GetObject(anObject);
129 }
130
131 //=============================================================================
132 /*!
133  *  MakePointOnCurve
134  */
135 //=============================================================================
136 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
137                   (GEOM::GEOM_Object_ptr theCurve,  CORBA::Double theParameter)
138 {
139   GEOM::GEOM_Object_var aGEOMObject;
140
141   //Set a not done flag
142   GetOperations()->SetNotDone();
143
144   //Get the reference curve
145   Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
146   if (aReference.IsNull()) return aGEOMObject._retn();
147
148   //Create the point
149   Handle(GEOM_Object) anObject =
150     GetOperations()->MakePointOnCurve(aReference, theParameter);
151   if (!GetOperations()->IsDone() || anObject.IsNull())
152     return aGEOMObject._retn();
153
154   return GetObject(anObject);
155 }
156
157 //=============================================================================
158 /*!
159  *  MakePointOnSurface
160  */
161 //=============================================================================
162 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurface
163                                              (GEOM::GEOM_Object_ptr theSurface,
164                                               CORBA::Double theUParameter,
165                                               CORBA::Double theVParameter)
166 {
167   GEOM::GEOM_Object_var aGEOMObject;
168
169   //Set a not done flag
170   GetOperations()->SetNotDone();
171
172   //Get the reference surface
173   Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
174   if (aReference.IsNull()) return aGEOMObject._retn();
175
176   //Create the point
177   Handle(GEOM_Object) anObject =
178     GetOperations()->MakePointOnSurface(aReference, theUParameter, theVParameter);
179   if (!GetOperations()->IsDone() || anObject.IsNull())
180     return aGEOMObject._retn();
181
182   return GetObject(anObject);
183 }
184
185
186 //=============================================================================
187 /*!
188  *  MakeTangentOnCurve
189  */
190 //=============================================================================
191 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
192                   (GEOM::GEOM_Object_ptr theCurve,  CORBA::Double theParameter)
193 {
194   GEOM::GEOM_Object_var aGEOMObject;
195
196   //Set a not done flag
197   GetOperations()->SetNotDone();
198
199   //Get the reference curve
200   Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
201   if (aReference.IsNull()) return aGEOMObject._retn();
202
203   //Create the vector
204   Handle(GEOM_Object) anObject =
205     GetOperations()->MakeTangentOnCurve(aReference, theParameter);
206   if (!GetOperations()->IsDone() || anObject.IsNull())
207     return aGEOMObject._retn();
208
209   return GetObject(anObject);
210 }
211
212 //=============================================================================
213 /*!
214  *  MakeVectorDXDYDZ
215  */
216 //=============================================================================
217 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
218   (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
219 {
220   GEOM::GEOM_Object_var aGEOMObject;
221
222   //Set a not done flag
223   GetOperations()->SetNotDone();
224
225   //Create the Vector
226
227   Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
228   if (!GetOperations()->IsDone() || anObject.IsNull())
229     return aGEOMObject._retn();
230
231   return GetObject(anObject);
232 }
233
234 //=============================================================================
235 /*!
236  *  MakeVectorTwoPnt
237  */
238 //=============================================================================
239 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
240                  (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
241 {
242   GEOM::GEOM_Object_var aGEOMObject;
243
244   //Set a not done flag
245   GetOperations()->SetNotDone();
246
247   //Get the reference points
248   Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
249   Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
250   if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
251
252   //Create the vector
253   Handle(GEOM_Object) anObject = GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
254   if (!GetOperations()->IsDone() || anObject.IsNull())
255     return aGEOMObject._retn();
256
257   return GetObject(anObject);
258 }
259
260
261 //=============================================================================
262 /*!
263  *  MakeLine
264  */
265 //=============================================================================
266 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
267                    (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
268 {
269   GEOM::GEOM_Object_var aGEOMObject;
270
271   //Set a not done flag
272   GetOperations()->SetNotDone();
273
274   //Get the reference objects
275   Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
276   Handle(GEOM_Object) aRef2 = GetObjectImpl(theDir);
277   if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
278
279   //Create the Line
280   Handle(GEOM_Object) anObject = GetOperations()->MakeLine(aRef1, aRef2);
281   if (!GetOperations()->IsDone() || anObject.IsNull())
282     return aGEOMObject._retn();
283
284   return GetObject(anObject);
285 }
286
287 //=============================================================================
288 /*!
289  *  MakeLineTwoPnt
290  */
291 //=============================================================================
292 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
293                  (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
294 {
295   GEOM::GEOM_Object_var aGEOMObject;
296
297   //Set a not done flag
298   GetOperations()->SetNotDone();
299
300   //Get the reference points
301   Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
302   Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
303   if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
304
305   //Create the Line
306   Handle(GEOM_Object) anObject = GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
307   if (!GetOperations()->IsDone() || anObject.IsNull())
308     return aGEOMObject._retn();
309
310   return GetObject(anObject);
311 }
312
313 //=============================================================================
314 /*!
315  *  MakeLineTwoFaces
316  */
317 //=============================================================================
318 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces
319                  (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
320 {
321   GEOM::GEOM_Object_var aGEOMObject;
322
323   //Set a not done flag
324   GetOperations()->SetNotDone();
325
326   //Get the reference points
327   Handle(GEOM_Object) aRef1 = GetObjectImpl(theFace1);
328   Handle(GEOM_Object) aRef2 = GetObjectImpl(theFace2);
329   if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
330
331   //Create the Line
332   Handle(GEOM_Object) anObject =
333     GetOperations()->MakeLineTwoFaces(aRef1, aRef2);
334   if (!GetOperations()->IsDone() || anObject.IsNull())
335     return aGEOMObject._retn();
336
337   return GetObject(anObject);
338 }
339
340
341 //=============================================================================
342 /*!
343  *  MakePlanePntVec
344  */
345 //=============================================================================
346 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
347                  (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
348                   CORBA::Double theTrimSize)
349 {
350   GEOM::GEOM_Object_var aGEOMObject;
351
352   //Set a not done flag
353   GetOperations()->SetNotDone();
354
355   //Get the references
356   Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
357   Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec);
358   if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
359
360   //Create the plane
361   Handle(GEOM_Object) anObject =
362     GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
363   if (!GetOperations()->IsDone() || anObject.IsNull())
364     return aGEOMObject._retn();
365
366   return GetObject(anObject);
367 }
368
369 //=============================================================================
370 /*!
371  *  MakePlaneThreePnt
372  */
373 //=============================================================================
374 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
375                  (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
376                   GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
377 {
378   GEOM::GEOM_Object_var aGEOMObject;
379
380   //Set a not done flag
381   GetOperations()->SetNotDone();
382
383   //Get the reference points
384   Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
385   Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
386   Handle(GEOM_Object) aRef3 = GetObjectImpl(thePnt3);
387   if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
388     return aGEOMObject._retn();
389
390   //Create the plane
391   Handle(GEOM_Object) anObject =
392     GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
393   if (!GetOperations()->IsDone() || anObject.IsNull())
394     return aGEOMObject._retn();
395
396   return GetObject(anObject);
397 }
398
399 //=============================================================================
400 /*!
401  *  MakePlaneFace
402  */
403 //=============================================================================
404 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
405                      (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
406 {
407   GEOM::GEOM_Object_var aGEOMObject;
408
409   //Set a not done flag
410   GetOperations()->SetNotDone();
411
412   //Get the reference face
413   Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
414   if (aRef.IsNull()) return aGEOMObject._retn();
415
416   //Create the plane
417   Handle(GEOM_Object) anObject =
418     GetOperations()->MakePlaneFace(aRef, theTrimSize);
419   if (!GetOperations()->IsDone() || anObject.IsNull())
420     return aGEOMObject._retn();
421
422   return GetObject(anObject);
423 }
424
425 //=============================================================================
426 /*!
427  *  MakePlane2Vec
428  */
429 //=============================================================================
430 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlane2Vec
431                  (GEOM::GEOM_Object_ptr theVec1, GEOM::GEOM_Object_ptr theVec2,
432                   CORBA::Double theTrimSize)
433 {
434   GEOM::GEOM_Object_var aGEOMObject;
435
436   //Set a not done flag
437   GetOperations()->SetNotDone();
438
439   //Get the references
440   Handle(GEOM_Object) aRef1 = GetObjectImpl(theVec1);
441   Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec2);
442   if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
443
444   //Create the plane
445   Handle(GEOM_Object) anObject =
446     GetOperations()->MakePlane2Vec(aRef1, aRef2, theTrimSize);
447   if (!GetOperations()->IsDone() || anObject.IsNull())
448     return aGEOMObject._retn();
449
450   return GetObject(anObject);
451 }
452
453 //=============================================================================
454 /*!
455  *  MakePlaneLCS
456  */
457 //=============================================================================
458 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneLCS
459                  (GEOM::GEOM_Object_ptr theLCS, CORBA::Double theTrimSize,
460                   CORBA::Double theOrientation)
461 {
462   GEOM::GEOM_Object_var aGEOMObject;
463
464   //Set a not done flag
465   GetOperations()->SetNotDone();
466
467   //Get the references
468   Handle(GEOM_Object) aRef1 = GetObjectImpl(theLCS);
469
470   //Create the plane
471   Handle(GEOM_Object) anObject =
472     GetOperations()->MakePlaneLCS(aRef1, theTrimSize, theOrientation);
473   if (!GetOperations()->IsDone() || anObject.IsNull())
474     return aGEOMObject._retn();
475
476   return GetObject(anObject);
477 }
478
479 //=============================================================================
480 /*!
481  *  MakeMarker
482  */
483 //=============================================================================
484 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
485   (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
486    CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
487    CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
488 {
489   GEOM::GEOM_Object_var aGEOMObject;
490
491   //Set a not done flag
492   GetOperations()->SetNotDone();
493
494   //Create the point
495   Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
496                                                              theXDX, theXDY, theXDZ,
497                                                              theYDX, theYDY, theYDZ);
498   if (!GetOperations()->IsDone() || anObject.IsNull())
499     return aGEOMObject._retn();
500
501   return GetObject(anObject);
502 }
503
504 //=============================================================================
505 /*!
506  *  MakeTangentPlaneOnFace
507  */
508 //=============================================================================
509
510 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
511                      (GEOM::GEOM_Object_ptr theFace,
512                       CORBA::Double theParameterU,
513                       CORBA::Double theParameterV,
514                       CORBA::Double theTrimSize)
515 {
516   GEOM::GEOM_Object_var aGEOMObject;
517
518   //Set a not done flag
519   GetOperations()->SetNotDone();
520
521   //Get the reference face
522   Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
523   if (aRef.IsNull()) return aGEOMObject._retn();
524
525   //Create the plane
526   Handle(GEOM_Object) anObject =
527     GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
528   if (!GetOperations()->IsDone() || anObject.IsNull())
529     return aGEOMObject._retn();
530
531   return GetObject(anObject);
532 }