Back to index

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