Back to index

salome-geom  6.5.0
GEOM_ILocalOperations_i.cc
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include <Standard_Stream.hxx>
00024 
00025 #include "GEOM_ILocalOperations_i.hh"
00026 
00027 #include "utilities.h"
00028 #include "OpUtil.hxx"
00029 #include "Utils_ExceptHandlers.hxx"
00030 
00031 #include "GEOM_Engine.hxx"
00032 #include "GEOM_Object.hxx"
00033 
00034 //=============================================================================
00038 //=============================================================================
00039 GEOM_ILocalOperations_i::GEOM_ILocalOperations_i (PortableServer::POA_ptr thePOA,
00040                                                   GEOM::GEOM_Gen_ptr theEngine,
00041                                                   ::GEOMImpl_ILocalOperations* theImpl)
00042      :GEOM_IOperations_i(thePOA, theEngine, theImpl)
00043 {
00044   MESSAGE("GEOM_ILocalOperations_i::GEOM_ILocalOperations_i");
00045 }
00046 
00047 //=============================================================================
00051 //=============================================================================
00052 GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i()
00053 {
00054   MESSAGE("GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i");
00055 }
00056 
00057 
00058 //=============================================================================
00062 //=============================================================================
00063 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletAll
00064                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR)
00065 {
00066   GEOM::GEOM_Object_var aGEOMObject;
00067 
00068   //Get the reference shape
00069   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00070   if (aShapeRef.IsNull()) return aGEOMObject._retn();
00071 
00072   //Create the Fillet
00073   Handle(GEOM_Object) anObject =
00074     GetOperations()->MakeFilletAll(aShapeRef, theR);
00075   if (!GetOperations()->IsDone() || anObject.IsNull())
00076     return aGEOMObject._retn();
00077 
00078   return GetObject(anObject);
00079 }
00080 
00081 //=============================================================================
00085 //=============================================================================
00086 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdges
00087                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
00088                        const GEOM::ListOfLong& theEdges)
00089 {
00090   GEOM::GEOM_Object_var aGEOMObject;
00091 
00092   //Get the reference shape
00093   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00094   if (aShapeRef.IsNull()) return aGEOMObject._retn();
00095 
00096   //Get the reference edges
00097   int ind = 0;
00098   int aLen = theEdges.length();
00099   std::list<int> anEdges;
00100   for (; ind < aLen; ind++) {
00101     anEdges.push_back(theEdges[ind]);
00102   }
00103 
00104   //Create the Fillet
00105   Handle(GEOM_Object) anObject =
00106     GetOperations()->MakeFilletEdges(aShapeRef, theR, anEdges);
00107   if (!GetOperations()->IsDone() || anObject.IsNull())
00108     return aGEOMObject._retn();
00109 
00110   return GetObject(anObject);
00111 }
00112 
00113 //=============================================================================
00117 //=============================================================================
00118 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdgesR1R2
00119                      (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1,
00120                       CORBA::Double theR2, const GEOM::ListOfLong& theEdges)
00121 {
00122   GEOM::GEOM_Object_var aGEOMObject;
00123 
00124   //Get the reference shape
00125   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00126   if (aShapeRef.IsNull()) return aGEOMObject._retn();
00127 
00128   //Get the reference edges
00129   int ind = 0;
00130   int aLen = theEdges.length();
00131   std::list<int> anEdges;
00132   for (; ind < aLen; ind++) {
00133     anEdges.push_back(theEdges[ind]);
00134   }
00135 
00136   //Create the Fillet
00137   Handle(GEOM_Object) anObject =
00138     GetOperations()->MakeFilletEdgesR1R2(aShapeRef, theR1, theR2, anEdges);
00139   if (!GetOperations()->IsDone() || anObject.IsNull())
00140     return aGEOMObject._retn();
00141 
00142   return GetObject(anObject);
00143 }
00144 
00145 //=============================================================================
00149 //=============================================================================
00150 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFaces
00151                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
00152                        const GEOM::ListOfLong& theFaces)
00153 {
00154   GEOM::GEOM_Object_var aGEOMObject;
00155 
00156   //Get the reference shape
00157   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00158   if (aShapeRef.IsNull()) return aGEOMObject._retn();
00159 
00160   //Get the reference faces
00161   int ind = 0;
00162   int aLen = theFaces.length();
00163   std::list<int> aFaces;
00164   for (; ind < aLen; ind++) {
00165     aFaces.push_back(theFaces[ind]);
00166   }
00167 
00168   //Create the Fillet
00169   Handle(GEOM_Object) anObject =
00170     GetOperations()->MakeFilletFaces(aShapeRef, theR, aFaces);
00171   if (!GetOperations()->IsDone() || anObject.IsNull())
00172     return aGEOMObject._retn();
00173 
00174   return GetObject(anObject);
00175 }
00176 
00177 //=============================================================================
00181 //=============================================================================
00182 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFacesR1R2
00183                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1,
00184                        CORBA::Double theR2, const GEOM::ListOfLong& theFaces)
00185 {
00186   GEOM::GEOM_Object_var aGEOMObject;
00187 
00188   //Get the reference shape
00189   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00190   if (aShapeRef.IsNull()) return aGEOMObject._retn();
00191 
00192   //Get the reference faces
00193   int ind = 0;
00194   int aLen = theFaces.length();
00195   std::list<int> aFaces;
00196   for (; ind < aLen; ind++) {
00197     aFaces.push_back(theFaces[ind]);
00198   }
00199 
00200   //Create the Fillet
00201   Handle(GEOM_Object) anObject =
00202     GetOperations()->MakeFilletFacesR1R2(aShapeRef, theR1, theR2, aFaces);
00203   if (!GetOperations()->IsDone() || anObject.IsNull())
00204     return aGEOMObject._retn();
00205 
00206   return GetObject(anObject);
00207 }
00208 
00209 //=============================================================================
00213 //=============================================================================
00214 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFillet2D
00215                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
00216                        const GEOM::ListOfLong& theVertexes)
00217 {
00218   GEOM::GEOM_Object_var aGEOMObject;
00219 
00220   //Get the reference shape
00221   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00222   if (aShapeRef.IsNull()) return aGEOMObject._retn();
00223 
00224   //Get the reference vertex
00225   int ind = 0;
00226   int aLen = theVertexes.length();
00227   std::list<int> aVertexes;
00228   for (; ind < aLen; ind++) {
00229     aVertexes.push_back(theVertexes[ind]);
00230   }
00231 
00232   //Create the Fillet
00233   Handle(GEOM_Object) anObject =
00234     GetOperations()->MakeFillet2D(aShapeRef, theR, aVertexes);
00235   if (!GetOperations()->IsDone() || anObject.IsNull())
00236     return aGEOMObject._retn();
00237 
00238   return GetObject(anObject);
00239 }
00240 
00241 //=============================================================================
00245 //=============================================================================
00246 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFillet1D
00247                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
00248                        const GEOM::ListOfLong& theVertexes)
00249 {
00250   GEOM::GEOM_Object_var aGEOMObject;
00251 
00252   //Get the reference shape (wire)
00253   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00254   if (aShapeRef.IsNull()) return aGEOMObject._retn();
00255 
00256   //Get the reference vertex
00257   int ind = 0;
00258   int aLen = theVertexes.length();
00259   std::list<int> aVertexes;
00260   for (; ind < aLen; ind++) {
00261     aVertexes.push_back(theVertexes[ind]);
00262   }
00263 
00264   //Create the Fillet
00265   Handle(GEOM_Object) anObject =
00266     GetOperations()->MakeFillet1D(aShapeRef, theR, aVertexes);
00267   if (!GetOperations()->IsDone() || anObject.IsNull())
00268     return aGEOMObject._retn();
00269 
00270   return GetObject(anObject);
00271 }
00272 
00273 //=============================================================================
00277 //=============================================================================
00278 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferAll
00279                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD)
00280 {
00281   GEOM::GEOM_Object_var aGEOMObject;
00282 
00283   //Get the reference shape
00284   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00285   if (aShapeRef.IsNull()) return aGEOMObject._retn();
00286 
00287   //Create the Chamfer
00288   Handle(GEOM_Object) anObject =
00289     GetOperations()->MakeChamferAll(aShapeRef, theD);
00290   if (!GetOperations()->IsDone() || anObject.IsNull())
00291     return aGEOMObject._retn();
00292 
00293   return GetObject(anObject);
00294 }
00295 
00296 //=============================================================================
00300 //=============================================================================
00301 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdge
00302                       (GEOM::GEOM_Object_ptr theShape,
00303                        CORBA::Double theD1, CORBA::Double theD2,
00304                        CORBA::Long theFace1, CORBA::Long theFace2)
00305 {
00306   GEOM::GEOM_Object_var aGEOMObject;
00307 
00308   //Get the reference shape
00309   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00310   if (aShapeRef.IsNull()) return aGEOMObject._retn();
00311 
00312   //Create the Chamfer
00313   Handle(GEOM_Object) anObject =
00314     GetOperations()->MakeChamferEdge(aShapeRef, theD1, theD2, theFace1, theFace2);
00315   if (!GetOperations()->IsDone() || anObject.IsNull())
00316     return aGEOMObject._retn();
00317 
00318   return GetObject(anObject);
00319 }
00320 //=============================================================================
00324 //=============================================================================
00325 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgeAD
00326                       (GEOM::GEOM_Object_ptr theShape,
00327                        CORBA::Double theD, CORBA::Double theAngle,
00328                        CORBA::Long theFace1, CORBA::Long theFace2)
00329 {
00330   GEOM::GEOM_Object_var aGEOMObject;
00331 
00332   //Get the reference shape
00333   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00334   if (aShapeRef.IsNull()) return aGEOMObject._retn();
00335 
00336   //Create the Chamfer
00337   Handle(GEOM_Object) anObject =
00338     GetOperations()->MakeChamferEdgeAD(aShapeRef, theD, theAngle, theFace1, theFace2);
00339   if (!GetOperations()->IsDone() || anObject.IsNull())
00340     return aGEOMObject._retn();
00341 
00342   return GetObject(anObject);
00343 }
00344 
00345 //=============================================================================
00349 //=============================================================================
00350 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFaces
00351                       (GEOM::GEOM_Object_ptr theShape,
00352                        CORBA::Double theD1, CORBA::Double theD2,
00353                        const GEOM::ListOfLong& theFaces)
00354 {
00355   GEOM::GEOM_Object_var aGEOMObject;
00356 
00357   //Get the reference shape
00358   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00359   if (aShapeRef.IsNull()) return aGEOMObject._retn();
00360 
00361   //Get the reference faces
00362   int ind = 0;
00363   int aLen = theFaces.length();
00364   std::list<int> aFaces;
00365   for (; ind < aLen; ind++) {
00366     aFaces.push_back(theFaces[ind]);
00367   }
00368 
00369   //Create the Chamfer
00370   Handle(GEOM_Object) anObject =
00371     GetOperations()->MakeChamferFaces(aShapeRef, theD1, theD2, aFaces);
00372   if (!GetOperations()->IsDone() || anObject.IsNull())
00373     return aGEOMObject._retn();
00374 
00375   return GetObject(anObject);
00376 }
00377 //=============================================================================
00381 //=============================================================================
00382 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFacesAD
00383                       (GEOM::GEOM_Object_ptr theShape,
00384                        CORBA::Double theD, CORBA::Double theAngle,
00385                        const GEOM::ListOfLong& theFaces)
00386 {
00387   GEOM::GEOM_Object_var aGEOMObject;
00388 
00389   //Get the reference shape
00390   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00391   if (aShapeRef.IsNull()) return aGEOMObject._retn();
00392 
00393   //Get the reference faces
00394   int ind = 0;
00395   int aLen = theFaces.length();
00396   std::list<int> aFaces;
00397   for (; ind < aLen; ind++) {
00398     aFaces.push_back(theFaces[ind]);
00399   }
00400 
00401   //Create the Chamfer
00402   Handle(GEOM_Object) anObject =
00403     GetOperations()->MakeChamferFacesAD(aShapeRef, theD, theAngle, aFaces);
00404   if (!GetOperations()->IsDone() || anObject.IsNull())
00405     return aGEOMObject._retn();
00406 
00407   return GetObject(anObject);
00408 }
00409 
00410 //=============================================================================
00414 //=============================================================================
00415 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdges
00416                       (GEOM::GEOM_Object_ptr theShape,
00417                        CORBA::Double theD1, CORBA::Double theD2,
00418                        const GEOM::ListOfLong& theEdges)
00419 {
00420   GEOM::GEOM_Object_var aGEOMObject;
00421 
00422   //Get the reference shape
00423   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00424   if (aShapeRef.IsNull()) return aGEOMObject._retn();
00425 
00426   //Get the reference edges
00427   int ind = 0;
00428   int aLen = theEdges.length();
00429   std::list<int> aEdges;
00430   for (; ind < aLen; ind++) {
00431     aEdges.push_back(theEdges[ind]);
00432   }
00433 
00434   //Create the Chamfer
00435   Handle(GEOM_Object) anObject =
00436     GetOperations()->MakeChamferEdges(aShapeRef, theD1, theD2, aEdges);
00437   if (!GetOperations()->IsDone() || anObject.IsNull())
00438     return aGEOMObject._retn();
00439 
00440   return GetObject(anObject);
00441 }
00442 
00443 //=============================================================================
00447 //=============================================================================
00448 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgesAD
00449                       (GEOM::GEOM_Object_ptr theShape,
00450                        CORBA::Double theD, CORBA::Double theAngle,
00451                        const GEOM::ListOfLong& theEdges)
00452 {
00453   GEOM::GEOM_Object_var aGEOMObject;
00454 
00455   //Get the reference shape
00456   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00457   if (aShapeRef.IsNull()) return aGEOMObject._retn();
00458 
00459   //Get the reference edges
00460   int ind = 0;
00461   int aLen = theEdges.length();
00462   std::list<int> aEdges;
00463   for (; ind < aLen; ind++) {
00464     aEdges.push_back(theEdges[ind]);
00465   }
00466 
00467   //Create the Chamfer
00468   Handle(GEOM_Object) anObject =
00469     GetOperations()->MakeChamferEdgesAD(aShapeRef, theD, theAngle, aEdges);
00470   if (!GetOperations()->IsDone() || anObject.IsNull())
00471     return aGEOMObject._retn();
00472 
00473   return GetObject(anObject);
00474 }
00475 
00476 //=============================================================================
00480 //=============================================================================
00481 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeArchimede (GEOM::GEOM_Object_ptr theShape,
00482                                                               CORBA::Double theWeight,
00483                                                               CORBA::Double theWaterDensity,
00484                                                               CORBA::Double theMeshingDeflection)
00485 {
00486   GEOM::GEOM_Object_var aGEOMObject;
00487 
00488   //Get the reference shape
00489   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00490   if (aShapeRef.IsNull()) return aGEOMObject._retn();
00491 
00492   //Create the Archimede
00493   Handle(GEOM_Object) anObject = GetOperations()->MakeArchimede
00494     (aShapeRef, theWeight, theWaterDensity, theMeshingDeflection);
00495   if (!GetOperations()->IsDone() || anObject.IsNull())
00496     return aGEOMObject._retn();
00497 
00498   return GetObject(anObject);
00499 }
00500 
00501 //=============================================================================
00505 //=============================================================================
00506 CORBA::Long GEOM_ILocalOperations_i::GetSubShapeIndex
00507   (GEOM::GEOM_Object_ptr theShape, GEOM::GEOM_Object_ptr theSubShape)
00508 {
00509   //Get the reference shapes
00510   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
00511   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
00512   if (aShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
00513 
00514   //Get the unique ID of <theSubShape> inside <theShape>
00515   CORBA::Long anID = GetOperations()->GetSubShapeIndex(aShapeRef, aSubShapeRef);
00516   if (!GetOperations()->IsDone())
00517     return -1;
00518 
00519   return anID;
00520 }