Salome HOME
ENV: Windows porting.
[modules/geom.git] / src / GEOM_I / GEOM_ILocalOperations_i.cc
1 #include <Standard_Stream.hxx>
2
3 #include "GEOM_ILocalOperations_i.hh"
4
5 #include "utilities.h"
6 #include "OpUtil.hxx"
7 #include "Utils_ExceptHandlers.hxx"
8
9 #include "GEOM_Engine.hxx"
10 #include "GEOM_Object.hxx"
11
12 //=============================================================================
13 /*!
14  *   constructor:
15  */
16 //=============================================================================
17 GEOM_ILocalOperations_i::GEOM_ILocalOperations_i (PortableServer::POA_ptr thePOA,
18                                                   GEOM::GEOM_Gen_ptr theEngine,
19                                                   ::GEOMImpl_ILocalOperations* theImpl)
20      :GEOM_IOperations_i(thePOA, theEngine, theImpl)
21 {
22   MESSAGE("GEOM_ILocalOperations_i::GEOM_ILocalOperations_i");
23 }
24
25 //=============================================================================
26 /*!
27  *  destructor
28  */
29 //=============================================================================
30 GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i()
31 {
32   MESSAGE("GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i");
33 }
34
35
36 //=============================================================================
37 /*!
38  *  MakeFilletAll
39  */
40 //=============================================================================
41 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletAll
42                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR)
43 {
44   GEOM::GEOM_Object_var aGEOMObject;
45
46   if (theShape == NULL) return aGEOMObject._retn();
47
48   //Get the reference shape
49   Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
50     (theShape->GetStudyID(), theShape->GetEntry());
51
52   if (aShapeRef.IsNull()) return aGEOMObject._retn();
53
54   //Create the Fillet
55   Handle(GEOM_Object) anObject =
56     GetOperations()->MakeFilletAll(aShapeRef, theR);
57   if (!GetOperations()->IsDone() || anObject.IsNull())
58     return aGEOMObject._retn();
59
60   return GetObject(anObject);
61 }
62
63 //=============================================================================
64 /*!
65  *  MakeFilletEdges
66  */
67 //=============================================================================
68 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdges
69                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
70                        const GEOM::ListOfLong& theEdges)
71 {
72   GEOM::GEOM_Object_var aGEOMObject;
73
74   if (theShape == NULL) return aGEOMObject._retn();
75
76   //Get the reference shape
77   Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
78     (theShape->GetStudyID(), theShape->GetEntry());
79   if (aShapeRef.IsNull()) return aGEOMObject._retn();
80
81   //Get the reference edges
82   int ind = 0;
83   int aLen = theEdges.length();
84   list<int> anEdges;
85   for (; ind < aLen; ind++) {
86     anEdges.push_back(theEdges[ind]);
87   }
88
89   //Create the Fillet
90   Handle(GEOM_Object) anObject =
91     GetOperations()->MakeFilletEdges(aShapeRef, theR, anEdges);
92   if (!GetOperations()->IsDone() || anObject.IsNull())
93     return aGEOMObject._retn();
94
95   return GetObject(anObject);
96 }
97
98 //=============================================================================
99 /*!
100  *  MakeFilletFaces
101  */
102 //=============================================================================
103 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFaces
104                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
105                        const GEOM::ListOfLong& theFaces)
106 {
107   GEOM::GEOM_Object_var aGEOMObject;
108
109   if (theShape == NULL) return aGEOMObject._retn();
110
111   //Get the reference shape
112   Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
113     (theShape->GetStudyID(), theShape->GetEntry());
114   if (aShapeRef.IsNull()) return aGEOMObject._retn();
115
116   //Get the reference faces
117   int ind = 0;
118   int aLen = theFaces.length();
119   list<int> aFaces;
120   for (; ind < aLen; ind++) {
121     aFaces.push_back(theFaces[ind]);
122   }
123
124   //Create the Fillet
125   Handle(GEOM_Object) anObject =
126     GetOperations()->MakeFilletFaces(aShapeRef, theR, aFaces);
127   if (!GetOperations()->IsDone() || anObject.IsNull())
128     return aGEOMObject._retn();
129
130   return GetObject(anObject);
131 }
132
133 //=============================================================================
134 /*!
135  *  MakeChamferAll
136  */
137 //=============================================================================
138 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferAll
139                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD)
140 {
141   GEOM::GEOM_Object_var aGEOMObject;
142
143   if (theShape == NULL) return aGEOMObject._retn();
144
145   //Get the reference shape
146   Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
147     (theShape->GetStudyID(), theShape->GetEntry());
148
149   if (aShapeRef.IsNull()) return aGEOMObject._retn();
150
151   //Create the Chamfer
152   Handle(GEOM_Object) anObject =
153     GetOperations()->MakeChamferAll(aShapeRef, theD);
154   if (!GetOperations()->IsDone() || anObject.IsNull())
155     return aGEOMObject._retn();
156
157   return GetObject(anObject);
158 }
159
160 //=============================================================================
161 /*!
162  *  MakeChamferEdge
163  */
164 //=============================================================================
165 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdge
166                       (GEOM::GEOM_Object_ptr theShape,
167                        CORBA::Double theD1, CORBA::Double theD2,
168                        CORBA::Long theFace1, CORBA::Long theFace2)
169 {
170   GEOM::GEOM_Object_var aGEOMObject;
171
172   if (theShape == NULL) return aGEOMObject._retn();
173
174   //Get the reference shape
175   Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
176     (theShape->GetStudyID(), theShape->GetEntry());
177   if (aShapeRef.IsNull()) return aGEOMObject._retn();
178
179   //Create the Chamfer
180   Handle(GEOM_Object) anObject =
181     GetOperations()->MakeChamferEdge(aShapeRef, theD1, theD2, theFace1, theFace2);
182   if (!GetOperations()->IsDone() || anObject.IsNull())
183     return aGEOMObject._retn();
184
185   return GetObject(anObject);
186 }
187
188 //=============================================================================
189 /*!
190  *  MakeChamferFaces
191  */
192 //=============================================================================
193 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFaces
194                       (GEOM::GEOM_Object_ptr theShape,
195                        CORBA::Double theD1, CORBA::Double theD2,
196                        const GEOM::ListOfLong& theFaces)
197 {
198   GEOM::GEOM_Object_var aGEOMObject;
199
200   if (theShape == NULL) return aGEOMObject._retn();
201
202   //Get the reference shape
203   Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
204     (theShape->GetStudyID(), theShape->GetEntry());
205   if (aShapeRef.IsNull()) return aGEOMObject._retn();
206
207   //Get the reference faces
208   int ind = 0;
209   int aLen = theFaces.length();
210   list<int> aFaces;
211   for (; ind < aLen; ind++) {
212     aFaces.push_back(theFaces[ind]);
213   }
214
215   //Create the Chamfer
216   Handle(GEOM_Object) anObject =
217     GetOperations()->MakeChamferFaces(aShapeRef, theD1, theD2, aFaces);
218   if (!GetOperations()->IsDone() || anObject.IsNull())
219     return aGEOMObject._retn();
220
221   return GetObject(anObject);
222 }
223
224 //=============================================================================
225 /*!
226  *  MakeArchimede
227  */
228 //=============================================================================
229 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeArchimede (GEOM::GEOM_Object_ptr theShape,
230                                                               CORBA::Double theWeight,
231                                                               CORBA::Double theWaterDensity,
232                                                               CORBA::Double theMeshingDeflection)
233 {
234   GEOM::GEOM_Object_var aGEOMObject;
235
236   if (theShape == NULL) return aGEOMObject._retn();
237
238   //Get the reference shape
239   Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
240     (theShape->GetStudyID(), theShape->GetEntry());
241   if (aShapeRef.IsNull()) return aGEOMObject._retn();
242
243   //Create the Archimede
244   Handle(GEOM_Object) anObject = GetOperations()->MakeArchimede
245     (aShapeRef, theWeight, theWaterDensity, theMeshingDeflection);
246   if (!GetOperations()->IsDone() || anObject.IsNull())
247     return aGEOMObject._retn();
248
249   return GetObject(anObject);
250 }
251
252 //=============================================================================
253 /*!
254  *  GetSubShapeIndex
255  */
256 //=============================================================================
257 CORBA::Long GEOM_ILocalOperations_i::GetSubShapeIndex
258   (GEOM::GEOM_Object_ptr theShape, GEOM::GEOM_Object_ptr theSubShape)
259 {
260   if (theShape == NULL || theSubShape == NULL) return -1;
261
262   //Get the reference shapes
263   Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
264     (theShape->GetStudyID(), theShape->GetEntry());
265   Handle(GEOM_Object) aSubShapeRef = GetOperations()->GetEngine()->GetObject
266     (theSubShape->GetStudyID(), theSubShape->GetEntry());
267   if (aShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
268
269   //Get the unique ID of <theSubShape> inside <theShape>
270   CORBA::Long anID = GetOperations()->GetSubShapeIndex(aShapeRef, aSubShapeRef);
271   if (!GetOperations()->IsDone())
272     return -1;
273
274   return anID;
275 }