Back to index

salome-smesh  6.5.0
StdMeshers_ViscousLayers_i.cxx
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 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
00024 //  File   : StdMeshers_ViscousLayers_i.cxx
00025 //  Module : SMESH
00026 //
00027 #include "StdMeshers_ViscousLayers_i.hxx"
00028 
00029 #include "SMESH_Gen.hxx"
00030 #include "SMESH_Gen_i.hxx"
00031 #include "SMESH_PythonDump.hxx"
00032 
00033 #include "Utils_CorbaException.hxx"
00034 #include "utilities.h"
00035 
00036 #include <TCollection_AsciiString.hxx>
00037 
00038 #include CORBA_SERVER_HEADER(SMESH_Group)
00039 
00040 using namespace std;
00041 
00042 //=============================================================================
00048 //=============================================================================
00049 
00050 StdMeshers_ViscousLayers_i::StdMeshers_ViscousLayers_i( PortableServer::POA_ptr thePOA,
00051                                                         int                     theStudyId,
00052                                                         ::SMESH_Gen*            theGenImpl )
00053   : SALOME::GenericObj_i( thePOA ), 
00054     SMESH_Hypothesis_i( thePOA )
00055 {
00056   MESSAGE( "StdMeshers_ViscousLayers_i::StdMeshers_ViscousLayers_i" );
00057   myBaseImpl = new ::StdMeshers_ViscousLayers( theGenImpl->GetANewId(),
00058                                                theStudyId,
00059                                                theGenImpl );
00060 }
00061 
00062 //=============================================================================
00068 //=============================================================================
00069 
00070 StdMeshers_ViscousLayers_i::~StdMeshers_ViscousLayers_i()
00071 {
00072   MESSAGE( "StdMeshers_ViscousLayers_i::~StdMeshers_ViscousLayers_i" );
00073 }
00074 
00075 //================================================================================
00079 //================================================================================
00080 
00081 void StdMeshers_ViscousLayers_i::SetIgnoreFaces(const ::SMESH::long_array& faceIDs)
00082 throw ( SALOME::SALOME_Exception )
00083 {
00084   vector<int> ids( faceIDs.length() );
00085   for ( unsigned i = 0; i < ids.size(); ++i )
00086     if (( ids[i] = faceIDs[i] ) < 1 )
00087       THROW_SALOME_CORBA_EXCEPTION( "Invalid face id", SALOME::BAD_PARAM );
00088   GetImpl()->SetIgnoreFaces( ids );
00089   SMESH::TPythonDump() << _this() << ".SetIgnoreFaces( " << faceIDs << " )";
00090 }
00091 
00092 //================================================================================
00096 //================================================================================
00097 
00098 SMESH::long_array* StdMeshers_ViscousLayers_i::GetIgnoreFaces()
00099 {
00100   vector<int> idsVec = GetImpl()->GetIgnoreFaces();
00101   SMESH::long_array_var ids = new SMESH::long_array;
00102   ids->length( idsVec.size() );
00103   for ( unsigned i = 0; i < idsVec.size(); ++i )
00104     ids[i] = idsVec[i];
00105   return ids._retn();
00106 }
00107 
00108 //================================================================================
00112 //================================================================================
00113 
00114 void StdMeshers_ViscousLayers_i::SetTotalThickness(::CORBA::Double thickness)
00115 throw ( SALOME::SALOME_Exception )
00116 {
00117   if ( thickness < 1e-100 )
00118     THROW_SALOME_CORBA_EXCEPTION( "Invalid thickness", SALOME::BAD_PARAM );
00119   GetImpl()->SetTotalThickness(thickness);
00120   SMESH::TPythonDump() << _this() << ".SetTotalThickness( " << SMESH::TVar(thickness) << " )";
00121 }
00122 
00123 //================================================================================
00127 //================================================================================
00128 
00129 ::CORBA::Double StdMeshers_ViscousLayers_i::GetTotalThickness()
00130 {
00131   return GetImpl()->GetTotalThickness();
00132 }
00133 
00134 //================================================================================
00139 //================================================================================
00140 
00141 void StdMeshers_ViscousLayers_i::SetNumberLayers(::CORBA::Short nb)
00142 throw ( SALOME::SALOME_Exception )
00143 {
00144   if ( nb < 1 )
00145     THROW_SALOME_CORBA_EXCEPTION( "Invalid number of layers", SALOME::BAD_PARAM );
00146   GetImpl()->SetNumberLayers( nb );
00147   SMESH::TPythonDump() << _this() << ".SetNumberLayers( " << SMESH::TVar(nb) << " )";
00148 }
00149 
00150 //================================================================================
00154 //================================================================================
00155 
00156 ::CORBA::Short StdMeshers_ViscousLayers_i::GetNumberLayers()
00157 {
00158   return CORBA::Short( GetImpl()->GetNumberLayers() );
00159 }
00160 
00161 //================================================================================
00166 //================================================================================
00167 
00168 void StdMeshers_ViscousLayers_i::SetStretchFactor(::CORBA::Double factor)
00169 throw ( SALOME::SALOME_Exception )
00170 {
00171   if ( factor < 1 )
00172     THROW_SALOME_CORBA_EXCEPTION( "Invalid stretch factor, it must be >= 1.0", SALOME::BAD_PARAM );
00173   GetImpl()->SetStretchFactor(factor);
00174   SMESH::TPythonDump() << _this() << ".SetStretchFactor( " << SMESH::TVar(factor) << " )";
00175 }
00176 
00177 //================================================================================
00182 //================================================================================
00183 
00184 ::CORBA::Double StdMeshers_ViscousLayers_i::GetStretchFactor()
00185 {
00186   return GetImpl()->GetStretchFactor();
00187 }
00188 
00189 //=============================================================================
00193 //=============================================================================
00194 
00195 ::StdMeshers_ViscousLayers* StdMeshers_ViscousLayers_i::GetImpl()
00196 {
00197   MESSAGE( "StdMeshers_ViscousLayers_i::GetImpl" );
00198   return ( ::StdMeshers_ViscousLayers* )myBaseImpl;
00199 }
00200 
00201 //================================================================================
00209 //================================================================================  
00210 CORBA::Boolean StdMeshers_ViscousLayers_i::IsDimSupported( SMESH::Dimension type )
00211 {
00212   return type == SMESH::DIM_3D;
00213 }
00214 
00215 //================================================================================
00219 //================================================================================
00220 
00221 std::string StdMeshers_ViscousLayers_i::getMethodOfParameter(const int paramIndex, int ) const
00222 {
00223   // order of methods was defined by StdMeshersGUI_StdHypothesisCreator::storeParams()
00224   switch ( paramIndex )
00225   {
00226   case 0: return "SetTotalThickness";
00227   case 1: return "SetNumberLayers";
00228   case 2: return "SetStretchFactor";
00229   }
00230   return "";
00231 }