Back to index

salome-smesh  6.5.0
StdMeshers_Arithmetic1D_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_Arithmetic1D_i.cxx
00025 //  Author : Damien COQUERET, OCC
00026 //  Module : SMESH
00027 //
00028 #include "StdMeshers_Arithmetic1D_i.hxx"
00029 #include "SMESH_Gen_i.hxx"
00030 #include "SMESH_Gen.hxx"
00031 #include "SMESH_PythonDump.hxx"
00032 
00033 #include "Utils_CorbaException.hxx"
00034 #include "utilities.h"
00035 
00036 #include <TCollection_AsciiString.hxx>
00037 
00038 using namespace std;
00039 
00040 //=============================================================================
00046 //=============================================================================
00047 
00048 StdMeshers_Arithmetic1D_i::StdMeshers_Arithmetic1D_i( PortableServer::POA_ptr thePOA,
00049                                                     int                     theStudyId,
00050                                                     ::SMESH_Gen*            theGenImpl )
00051      : SALOME::GenericObj_i( thePOA ), 
00052        SMESH_Hypothesis_i( thePOA )
00053 {
00054   MESSAGE( "StdMeshers_Arithmetic1D_i::StdMeshers_Arithmetic1D_i" );
00055   myBaseImpl = new ::StdMeshers_Arithmetic1D( theGenImpl->GetANewId(),
00056                                              theStudyId,
00057                                              theGenImpl );
00058 }
00059 
00060 //=============================================================================
00066 //=============================================================================
00067 
00068 StdMeshers_Arithmetic1D_i::~StdMeshers_Arithmetic1D_i()
00069 {
00070   MESSAGE( "StdMeshers_Arithmetic1D_i::~StdMeshers_Arithmetic1D_i" );
00071 }
00072 
00073 //=============================================================================
00079 //=============================================================================
00080 
00081 void StdMeshers_Arithmetic1D_i::SetLength(CORBA::Double theLength,
00082                                           CORBA::Boolean theIsStart )
00083      throw ( SALOME::SALOME_Exception )
00084 {
00085   MESSAGE( "StdMeshers_StartEndLength_i::SetLength" );
00086   ASSERT( myBaseImpl );
00087   try {
00088     this->GetImpl()->SetLength( theLength, theIsStart );
00089   }
00090   catch ( SALOME_Exception& S_ex ) {
00091     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00092                                   SALOME::BAD_PARAM );
00093   }
00094 
00095   // Update Python script
00096   SMESH::TPythonDump()
00097     << _this() << ( theIsStart ? ".SetStartLength( " : ".SetEndLength( " )
00098     << SMESH::TVar(theLength) << " )";
00099 }
00100 
00101 //=============================================================================
00105 //=============================================================================
00106 
00107 void StdMeshers_Arithmetic1D_i::SetStartLength( CORBA::Double length)
00108   throw (SALOME::SALOME_Exception)
00109 {
00110   SetLength( length, true );
00111 }
00112 
00113 //=============================================================================
00117 //=============================================================================
00118 
00119 void StdMeshers_Arithmetic1D_i::SetEndLength( CORBA::Double length)
00120   throw (SALOME::SALOME_Exception)
00121 {
00122   SetLength( length, false );
00123 }
00124 
00125 //=============================================================================
00131 //=============================================================================
00132 
00133 CORBA::Double StdMeshers_Arithmetic1D_i::GetLength( CORBA::Boolean theIsStart)
00134 {
00135   MESSAGE( "StdMeshers_Arithmetic1D_i::GetLength" );
00136   ASSERT( myBaseImpl );
00137   return this->GetImpl()->GetLength( theIsStart );
00138 }
00139 
00140 //=============================================================================
00146 //=============================================================================
00147 
00148 void StdMeshers_Arithmetic1D_i::SetReversedEdges( const SMESH::long_array& theIds )
00149 {
00150   ASSERT( myBaseImpl );
00151   try {
00152     std::vector<int> ids( theIds.length() );
00153     CORBA::Long iEnd = theIds.length();
00154     for ( CORBA::Long i = 0; i < iEnd; i++ )
00155       ids[ i ] = theIds[ i ];
00156 
00157     this->GetImpl()->SetReversedEdges( ids );
00158   }
00159   catch ( SALOME_Exception& S_ex ) {
00160     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00161                                   SALOME::BAD_PARAM );
00162   }
00163 
00164   // Update Python script
00165   SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
00166 }
00167 
00168 //=============================================================================
00174 //=============================================================================
00175 
00176 void StdMeshers_Arithmetic1D_i::SetObjectEntry( const char* theEntry )
00177 {
00178   ASSERT( myBaseImpl );
00179   string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
00180   try {
00181     this->GetImpl()->SetObjectEntry( entry.c_str() );
00182     // Update Python script
00183     SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
00184   }
00185   catch ( SALOME_Exception& S_ex ) {
00186     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM );
00187   }
00188 }
00189 
00190 //=============================================================================
00196 //=============================================================================
00197 
00198 char* StdMeshers_Arithmetic1D_i::GetObjectEntry()
00199 {
00200   MESSAGE( "StdMeshers_Arithmetic1D_i::SetObjectEntry" );
00201   ASSERT( myBaseImpl );
00202   const char* entry;
00203   try {
00204     entry = this->GetImpl()->GetObjectEntry();
00205   }
00206   catch ( SALOME_Exception& S_ex ) {
00207     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00208                                   SALOME::BAD_PARAM );
00209   }
00210   return CORBA::string_dup( entry );
00211 }
00212 
00213 //=============================================================================
00219 //=============================================================================
00220 
00221 SMESH::long_array* StdMeshers_Arithmetic1D_i::GetReversedEdges()
00222 {
00223   MESSAGE( "StdMeshers_StartEndLength_i::GetReversedEdges" );
00224   ASSERT( myBaseImpl );
00225   SMESH::long_array_var anArray = new SMESH::long_array;
00226   std::vector<int> ids = this->GetImpl()->GetReversedEdges();
00227   anArray->length( ids.size() );
00228   for ( CORBA::Long i = 0; i < ids.size(); i++)
00229     anArray [ i ] = ids [ i ];
00230 
00231   return anArray._retn();
00232 }
00233 
00234 //=============================================================================
00240 //=============================================================================
00241 
00242 ::StdMeshers_Arithmetic1D* StdMeshers_Arithmetic1D_i::GetImpl()
00243 {
00244   MESSAGE( "StdMeshers_Arithmetic1D_i::GetImpl" );
00245   return ( ::StdMeshers_Arithmetic1D* )myBaseImpl;
00246 }
00247 
00248 //================================================================================
00256 //================================================================================  
00257 CORBA::Boolean StdMeshers_Arithmetic1D_i::IsDimSupported( SMESH::Dimension type )
00258 {
00259   return type == SMESH::DIM_1D;
00260 }
00261 
00262 //================================================================================
00266 //================================================================================
00267 
00268 std::string StdMeshers_Arithmetic1D_i::getMethodOfParameter(const int paramIndex,
00269                                                             int       nbVars) const
00270 {
00271   return paramIndex == 0 ? "SetStartLength" : "SetEndLength";
00272 }