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_ILocalOperations_i.hh"
24 #include "utilities.h"
26 #include "Utils_ExceptHandlers.hxx"
28 #include "GEOM_Engine.hxx"
29 #include "GEOM_Object.hxx"
31 //=============================================================================
35 //=============================================================================
36 GEOM_ILocalOperations_i::GEOM_ILocalOperations_i (PortableServer::POA_ptr thePOA,
37 GEOM::GEOM_Gen_ptr theEngine,
38 ::GEOMImpl_ILocalOperations* theImpl)
39 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
41 MESSAGE("GEOM_ILocalOperations_i::GEOM_ILocalOperations_i");
44 //=============================================================================
48 //=============================================================================
49 GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i()
51 MESSAGE("GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i");
55 //=============================================================================
59 //=============================================================================
60 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletAll
61 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR)
63 GEOM::GEOM_Object_var aGEOMObject;
65 if (theShape == NULL) return aGEOMObject._retn();
67 //Get the reference shape
68 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
69 (theShape->GetStudyID(), theShape->GetEntry());
71 if (aShapeRef.IsNull()) return aGEOMObject._retn();
74 Handle(GEOM_Object) anObject =
75 GetOperations()->MakeFilletAll(aShapeRef, theR);
76 if (!GetOperations()->IsDone() || anObject.IsNull())
77 return aGEOMObject._retn();
79 return GetObject(anObject);
82 //=============================================================================
86 //=============================================================================
87 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdges
88 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
89 const GEOM::ListOfLong& theEdges)
91 GEOM::GEOM_Object_var aGEOMObject;
93 if (theShape == NULL) return aGEOMObject._retn();
95 //Get the reference shape
96 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
97 (theShape->GetStudyID(), theShape->GetEntry());
98 if (aShapeRef.IsNull()) return aGEOMObject._retn();
100 //Get the reference edges
102 int aLen = theEdges.length();
104 for (; ind < aLen; ind++) {
105 anEdges.push_back(theEdges[ind]);
109 Handle(GEOM_Object) anObject =
110 GetOperations()->MakeFilletEdges(aShapeRef, theR, anEdges);
111 if (!GetOperations()->IsDone() || anObject.IsNull())
112 return aGEOMObject._retn();
114 return GetObject(anObject);
117 //=============================================================================
121 //=============================================================================
122 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFaces
123 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
124 const GEOM::ListOfLong& theFaces)
126 GEOM::GEOM_Object_var aGEOMObject;
128 if (theShape == NULL) return aGEOMObject._retn();
130 //Get the reference shape
131 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
132 (theShape->GetStudyID(), theShape->GetEntry());
133 if (aShapeRef.IsNull()) return aGEOMObject._retn();
135 //Get the reference faces
137 int aLen = theFaces.length();
139 for (; ind < aLen; ind++) {
140 aFaces.push_back(theFaces[ind]);
144 Handle(GEOM_Object) anObject =
145 GetOperations()->MakeFilletFaces(aShapeRef, theR, aFaces);
146 if (!GetOperations()->IsDone() || anObject.IsNull())
147 return aGEOMObject._retn();
149 return GetObject(anObject);
152 //=============================================================================
156 //=============================================================================
157 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferAll
158 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD)
160 GEOM::GEOM_Object_var aGEOMObject;
162 if (theShape == NULL) return aGEOMObject._retn();
164 //Get the reference shape
165 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
166 (theShape->GetStudyID(), theShape->GetEntry());
168 if (aShapeRef.IsNull()) return aGEOMObject._retn();
171 Handle(GEOM_Object) anObject =
172 GetOperations()->MakeChamferAll(aShapeRef, theD);
173 if (!GetOperations()->IsDone() || anObject.IsNull())
174 return aGEOMObject._retn();
176 return GetObject(anObject);
179 //=============================================================================
183 //=============================================================================
184 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdge
185 (GEOM::GEOM_Object_ptr theShape,
186 CORBA::Double theD1, CORBA::Double theD2,
187 CORBA::Long theFace1, CORBA::Long theFace2)
189 GEOM::GEOM_Object_var aGEOMObject;
191 if (theShape == NULL) return aGEOMObject._retn();
193 //Get the reference shape
194 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
195 (theShape->GetStudyID(), theShape->GetEntry());
196 if (aShapeRef.IsNull()) return aGEOMObject._retn();
199 Handle(GEOM_Object) anObject =
200 GetOperations()->MakeChamferEdge(aShapeRef, theD1, theD2, theFace1, theFace2);
201 if (!GetOperations()->IsDone() || anObject.IsNull())
202 return aGEOMObject._retn();
204 return GetObject(anObject);
207 //=============================================================================
211 //=============================================================================
212 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFaces
213 (GEOM::GEOM_Object_ptr theShape,
214 CORBA::Double theD1, CORBA::Double theD2,
215 const GEOM::ListOfLong& theFaces)
217 GEOM::GEOM_Object_var aGEOMObject;
219 if (theShape == NULL) return aGEOMObject._retn();
221 //Get the reference shape
222 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
223 (theShape->GetStudyID(), theShape->GetEntry());
224 if (aShapeRef.IsNull()) return aGEOMObject._retn();
226 //Get the reference faces
228 int aLen = theFaces.length();
230 for (; ind < aLen; ind++) {
231 aFaces.push_back(theFaces[ind]);
235 Handle(GEOM_Object) anObject =
236 GetOperations()->MakeChamferFaces(aShapeRef, theD1, theD2, aFaces);
237 if (!GetOperations()->IsDone() || anObject.IsNull())
238 return aGEOMObject._retn();
240 return GetObject(anObject);
243 //=============================================================================
247 //=============================================================================
248 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeArchimede (GEOM::GEOM_Object_ptr theShape,
249 CORBA::Double theWeight,
250 CORBA::Double theWaterDensity,
251 CORBA::Double theMeshingDeflection)
253 GEOM::GEOM_Object_var aGEOMObject;
255 if (theShape == NULL) return aGEOMObject._retn();
257 //Get the reference shape
258 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
259 (theShape->GetStudyID(), theShape->GetEntry());
260 if (aShapeRef.IsNull()) return aGEOMObject._retn();
262 //Create the Archimede
263 Handle(GEOM_Object) anObject = GetOperations()->MakeArchimede
264 (aShapeRef, theWeight, theWaterDensity, theMeshingDeflection);
265 if (!GetOperations()->IsDone() || anObject.IsNull())
266 return aGEOMObject._retn();
268 return GetObject(anObject);
271 //=============================================================================
275 //=============================================================================
276 CORBA::Long GEOM_ILocalOperations_i::GetSubShapeIndex
277 (GEOM::GEOM_Object_ptr theShape, GEOM::GEOM_Object_ptr theSubShape)
279 if (theShape == NULL || theSubShape == NULL) return -1;
281 //Get the reference shapes
282 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject
283 (theShape->GetStudyID(), theShape->GetEntry());
284 Handle(GEOM_Object) aSubShapeRef = GetOperations()->GetEngine()->GetObject
285 (theSubShape->GetStudyID(), theSubShape->GetEntry());
286 if (aShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
288 //Get the unique ID of <theSubShape> inside <theShape>
289 CORBA::Long anID = GetOperations()->GetSubShapeIndex(aShapeRef, aSubShapeRef);
290 if (!GetOperations()->IsDone())