Back to index

salome-smesh  6.5.0
StdMeshers_NumberOfSegments_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_NumberOfSegments_i.cxx
00025 //           Moved here from SMESH_NumberOfSegments_i.cxx
00026 //  Author : Paul RASCLE, EDF
00027 //  Module : SMESH
00028 //
00029 #include "StdMeshers_NumberOfSegments_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 //=============================================================================
00046 //=============================================================================
00047 
00048 StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_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_NumberOfSegments_i::StdMeshers_NumberOfSegments_i" );
00055   myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(),
00056                                              theStudyId,
00057                                              theGenImpl );
00058 }
00059 
00060 //=============================================================================
00066 //=============================================================================
00067 
00068 StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i()
00069 {
00070   MESSAGE( "StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i" );
00071 }
00072 
00073 //=============================================================================
00079 //=============================================================================
00080 SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionExpr( const char* func, 
00081                                                                            CORBA::Long nbSeg, 
00082                                                                            CORBA::Long conv )
00083   throw ( SALOME::SALOME_Exception )
00084 {
00085   ASSERT( myBaseImpl );
00086   try
00087   {
00088     SMESH::double_array_var aRes = new SMESH::double_array();
00089     const std::vector<double>& res = this->GetImpl()->BuildDistributionExpr( func, nbSeg, conv );
00090     aRes->length( res.size() );
00091     for (int i = 0; i < res.size(); i++)
00092       aRes[i] = res[i];
00093     return aRes._retn();
00094   }
00095   catch( SALOME_Exception& S_ex )
00096   {
00097     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
00098   }
00099 }
00100 
00101 SMESH::double_array* StdMeshers_NumberOfSegments_i::BuildDistributionTab( const SMESH::double_array& func,
00102                                                                           CORBA::Long nbSeg, 
00103                                                                           CORBA::Long conv )
00104   throw ( SALOME::SALOME_Exception )
00105 {
00106   ASSERT( myBaseImpl );
00107 
00108   std::vector<double> tbl( func.length() );
00109   for (int i = 0; i < func.length(); i++)
00110     tbl[i] = func[i];
00111 
00112   try
00113   {
00114     SMESH::double_array_var aRes = new SMESH::double_array();
00115     const std::vector<double>& res = this->GetImpl()->BuildDistributionTab( tbl, nbSeg, conv );
00116     aRes->length( res.size() );
00117     for (int i = 0; i < res.size(); i++)
00118       aRes[i] = res[i];
00119     return aRes._retn();
00120   }
00121   catch( SALOME_Exception& S_ex )
00122   {
00123     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
00124   }
00125 }
00126 
00127 //=============================================================================
00133 //=============================================================================
00134 
00135 void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegmentsNumber )
00136      throw ( SALOME::SALOME_Exception )
00137 {
00138   ASSERT( myBaseImpl );
00139   try {
00140     this->GetImpl()->SetNumberOfSegments( theSegmentsNumber );
00141   }
00142   catch (SALOME_Exception& S_ex) {
00143     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00144                                   SALOME::BAD_PARAM );
00145   }
00146 
00147   // Update Python script
00148   SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << SMESH::TVar(theSegmentsNumber) << " )";
00149 }
00150 
00151 //=============================================================================
00157 //=============================================================================
00158 
00159 CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
00160 {
00161   ASSERT( myBaseImpl );
00162   return this->GetImpl()->GetNumberOfSegments();
00163 }
00164 
00165 //=============================================================================
00171 //=============================================================================
00172 
00173 void StdMeshers_NumberOfSegments_i::SetReversedEdges( const SMESH::long_array& theIds )
00174 {
00175   ASSERT( myBaseImpl );
00176   try {
00177     std::vector<int> ids( theIds.length() );
00178     CORBA::Long iEnd = theIds.length();
00179     for ( CORBA::Long i = 0; i < iEnd; i++ )
00180       ids[ i ] = theIds[ i ];
00181 
00182     this->GetImpl()->SetReversedEdges( ids );
00183   }
00184   catch ( SALOME_Exception& S_ex ) {
00185     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00186                                   SALOME::BAD_PARAM );
00187   }
00188 
00189   // Update Python script
00190   SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
00191 }
00192 
00193 //=============================================================================
00199 //=============================================================================
00200 
00201 void StdMeshers_NumberOfSegments_i::SetObjectEntry( const char* theEntry )
00202 {
00203   ASSERT( myBaseImpl );
00204   string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
00205   try {
00206     this->GetImpl()->SetObjectEntry( entry.c_str() );
00207   }
00208   catch ( SALOME_Exception& S_ex ) {
00209     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00210                                   SALOME::BAD_PARAM );
00211   }
00212   // Update Python script
00213   SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
00214 }
00215 
00216 //=============================================================================
00222 //=============================================================================
00223 
00224 char* StdMeshers_NumberOfSegments_i::GetObjectEntry()
00225 {
00226   ASSERT( myBaseImpl );
00227 
00228   const char* entry;
00229   try {
00230     entry = this->GetImpl()->GetObjectEntry();
00231   }
00232   catch ( SALOME_Exception& S_ex ) {
00233     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00234                                   SALOME::BAD_PARAM );
00235   }
00236   return CORBA::string_dup( entry );
00237 }
00238 
00239 //=============================================================================
00245 //=============================================================================
00246 
00247 SMESH::long_array* StdMeshers_NumberOfSegments_i::GetReversedEdges()
00248 {
00249   MESSAGE( "StdMeshers_NumberOfSegments_i::GetReversedEdges" );
00250   ASSERT( myBaseImpl );
00251   SMESH::long_array_var anArray = new SMESH::long_array;
00252   std::vector<int> ids = this->GetImpl()->GetReversedEdges();
00253   anArray->length( ids.size() );
00254   for ( CORBA::Long i = 0; i < ids.size(); i++)
00255     anArray [ i ] = ids [ i ];
00256 
00257   return anArray._retn();
00258 }
00259 
00260 //=============================================================================
00263 //=============================================================================
00264 
00265 void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
00266   throw ( SALOME::SALOME_Exception )
00267 {
00268   ASSERT( myBaseImpl );
00269   try {
00270     this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
00271 
00272     // Update Python script
00273     SMESH::TPythonDump() << _this() << ".SetDistrType( " << typ << " )";
00274   }
00275   catch ( SALOME_Exception& S_ex ) {
00276     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00277                                   SALOME::BAD_PARAM );
00278   }
00279 }
00280 
00281 //=============================================================================
00284 //=============================================================================
00285 
00286 CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
00287 {
00288   ASSERT( myBaseImpl );
00289   return this->GetImpl()->GetDistrType();
00290 }
00291 
00292 //=============================================================================
00298 //=============================================================================
00299 
00300 void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor )
00301      throw ( SALOME::SALOME_Exception )
00302 {
00303   ASSERT( myBaseImpl );
00304   try {
00305     this->GetImpl()->SetScaleFactor( theScaleFactor );
00306     // Update Python script
00307     SMESH::TPythonDump() << _this() << ".SetScaleFactor( " << SMESH::TVar(theScaleFactor) << " )";
00308   }
00309   catch ( SALOME_Exception& S_ex ) {
00310     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00311                                   SALOME::BAD_PARAM );
00312   }
00313 }
00314 
00315 //=============================================================================
00321 //=============================================================================
00322 
00323 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
00324   throw ( SALOME::SALOME_Exception )
00325 {
00326   ASSERT( myBaseImpl );
00327   double scale;
00328   try {
00329     scale = this->GetImpl()->GetScaleFactor();
00330   }
00331   catch ( SALOME_Exception& S_ex ) {
00332     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00333                                   SALOME::BAD_PARAM );
00334   }
00335   return scale;
00336 }
00337 
00338 //=============================================================================
00341 //=============================================================================
00342 
00343 void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
00344   throw ( SALOME::SALOME_Exception )
00345 {
00346   ASSERT( myBaseImpl );
00347   std::vector<double> tbl( table.length() );
00348   for (int i = 0; i < table.length(); i++)
00349     tbl[i] = table[i];
00350   try {
00351     this->GetImpl()->SetTableFunction( tbl );
00352     // Update Python script
00353     SMESH::TPythonDump() << _this() << ".SetTableFunction( " << table << " )";
00354   }
00355   catch ( SALOME_Exception& S_ex ) {
00356     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00357                                   SALOME::BAD_PARAM );
00358   }
00359 }
00360 
00361 //=============================================================================
00364 //=============================================================================
00365 
00366 SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
00367   throw ( SALOME::SALOME_Exception )
00368 {
00369   ASSERT( myBaseImpl );
00370   const std::vector<double>* tbl;
00371   try {
00372     tbl = &this->GetImpl()->GetTableFunction();
00373   }
00374   catch ( SALOME_Exception& S_ex ) {
00375     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00376                                   SALOME::BAD_PARAM );
00377   }
00378   SMESH::double_array_var aRes = new SMESH::double_array();
00379   aRes->length(tbl->size());
00380   for (int i = 0; i < tbl->size(); i++)
00381     aRes[i] = (*tbl)[i];
00382   return aRes._retn();
00383 }
00384 
00385 //=============================================================================
00388 //=============================================================================
00389 
00390 void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
00391   throw ( SALOME::SALOME_Exception )
00392 {
00393   ASSERT( myBaseImpl );
00394   try {
00395     this->GetImpl()->SetExpressionFunction( expr );
00396     // Update Python script
00397     SMESH::TPythonDump() << _this() << ".SetExpressionFunction( '" << expr << "' )";
00398   }
00399   catch ( SALOME_Exception& S_ex ) {
00400     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00401                                   SALOME::BAD_PARAM );
00402   }
00403 }
00404 
00405 //=============================================================================
00408 //=============================================================================
00409 
00410 char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
00411   throw ( SALOME::SALOME_Exception )
00412 {
00413   ASSERT( myBaseImpl );
00414   const char* expr;
00415   try {
00416     expr = this->GetImpl()->GetExpressionFunction();
00417   }
00418   catch ( SALOME_Exception& S_ex ) {
00419     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00420                                   SALOME::BAD_PARAM );
00421   }
00422   return CORBA::string_dup(expr);
00423 }
00424 
00425 //=============================================================================
00428 //=============================================================================
00429 
00430 void StdMeshers_NumberOfSegments_i::SetConversionMode(CORBA::Long conv )
00431   throw ( SALOME::SALOME_Exception )
00432 {
00433   ASSERT( myBaseImpl );
00434   try {
00435     this->GetImpl()->SetConversionMode( conv );
00436     // Update Python script
00437     SMESH::TPythonDump() << _this() << ".SetConversionMode( " << conv << " )";
00438   }
00439   catch ( SALOME_Exception& S_ex ) {
00440     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00441                                   SALOME::BAD_PARAM );
00442   }
00443 }
00444 
00445 //=============================================================================
00448 //=============================================================================
00449 
00450 CORBA::Long StdMeshers_NumberOfSegments_i::ConversionMode()
00451   throw ( SALOME::SALOME_Exception )
00452 {
00453   ASSERT( myBaseImpl );
00454   int conv;
00455   try {
00456     conv = this->GetImpl()->ConversionMode();
00457   }
00458   catch ( SALOME_Exception& S_ex ) {
00459     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00460                                   SALOME::BAD_PARAM );
00461   }
00462   return conv;
00463 }
00464 
00465 //=============================================================================
00471 //=============================================================================
00472 
00473 ::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl()
00474 {
00475   return ( ::StdMeshers_NumberOfSegments* )myBaseImpl;
00476 }
00477 
00478 //================================================================================
00486 //================================================================================  
00487 CORBA::Boolean StdMeshers_NumberOfSegments_i::IsDimSupported( SMESH::Dimension type )
00488 {
00489   return type == SMESH::DIM_1D;
00490 }
00491 
00492 //================================================================================
00496 //================================================================================
00497 
00498 std::string StdMeshers_NumberOfSegments_i::getMethodOfParameter(const int paramIndex, int ) const
00499 {
00500   return paramIndex == 0 ? "SetNumberOfSegments" : "SetScaleFactor";
00501 }