Back to index

salome-smesh  6.5.0
StdMeshers_FixedPoints1D_i.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
00021 //  File   : StdMeshers_FixedPoints1D_i.cxx
00022 //  Author : Damien COQUERET, OCC
00023 //  Module : SMESH
00024 //  $Header: /home/server/cvs/SMESH/SMESH_SRC/src/StdMeshers_I/Attic/StdMeshers_FixedPoints1D_i.cxx,v 1.1.2.1.14.2.8.1 2012-04-13 09:31:23 vsr Exp $
00025 //
00026 #include "StdMeshers_FixedPoints1D_i.hxx"
00027 #include "SMESH_Gen_i.hxx"
00028 #include "SMESH_Gen.hxx"
00029 #include "SMESH_PythonDump.hxx"
00030 
00031 #include "Utils_CorbaException.hxx"
00032 #include "utilities.h"
00033 
00034 #include <TCollection_AsciiString.hxx>
00035 
00036 using namespace std;
00037 
00038 //=============================================================================
00044 //=============================================================================
00045 
00046 StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i( PortableServer::POA_ptr thePOA,
00047                                                         int                     theStudyId,
00048                                                         ::SMESH_Gen*            theGenImpl )
00049      : SALOME::GenericObj_i( thePOA ), 
00050        SMESH_Hypothesis_i( thePOA )
00051 {
00052   MESSAGE( "StdMeshers_FixedPoints1D_i::StdMeshers_FixedPoints1D_i" );
00053   myBaseImpl = new ::StdMeshers_FixedPoints1D(theGenImpl->GetANewId(),
00054                                               theStudyId,
00055                                               theGenImpl);
00056 }
00057 
00058 //=============================================================================
00064 //=============================================================================
00065 
00066 StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i()
00067 {
00068   MESSAGE( "StdMeshers_FixedPoints1D_i::~StdMeshers_FixedPoints1D_i" );
00069 }
00070 
00071 //=============================================================================
00075 //=============================================================================
00076 
00077 void StdMeshers_FixedPoints1D_i::SetNbSegments(const SMESH::long_array& listNbSeg) 
00078      throw ( SALOME::SALOME_Exception )
00079 {
00080   MESSAGE( "StdMeshers_FixedPoints1D_i::SetNbSegments" );
00081   ASSERT( myBaseImpl );
00082   try {
00083     std::vector<int> nbsegs( listNbSeg.length() );
00084     CORBA::Long iEnd = listNbSeg.length();
00085     for ( CORBA::Long i = 0; i < iEnd; i++ )
00086       nbsegs[ i ] = listNbSeg[ i ];
00087     this->GetImpl()->SetNbSegments( nbsegs );
00088   }
00089   catch ( SALOME_Exception& S_ex ) {
00090     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00091                                   SALOME::BAD_PARAM );
00092   }
00093 
00094   // Update Python script
00095   SMESH::TPythonDump() << _this() << ".SetNbSegments( " << listNbSeg << " )";
00096 }
00097 
00098 //=============================================================================
00102 //=============================================================================
00103 
00104 void StdMeshers_FixedPoints1D_i::SetPoints(const SMESH::double_array& listParams) 
00105      throw ( SALOME::SALOME_Exception )
00106 {
00107   MESSAGE( "StdMeshers_FixedPoints1D_i::SetPoints" );
00108   ASSERT( myBaseImpl );
00109   try {
00110     std::vector<double> params( listParams.length() );
00111     CORBA::Long iEnd = listParams.length();
00112     for ( CORBA::Long i = 0; i < iEnd; i++ )
00113       params[ i ] = listParams[ i ];
00114     this->GetImpl()->SetPoints( params );
00115   }
00116   catch ( SALOME_Exception& S_ex ) {
00117     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00118                                   SALOME::BAD_PARAM );
00119   }
00120 
00121   // Update Python script
00122   SMESH::TPythonDump() << _this() << ".SetPoints( " << listParams << " )";
00123 }
00124 
00125 //=============================================================================
00131 //=============================================================================
00132 
00133 SMESH::double_array* StdMeshers_FixedPoints1D_i::GetPoints()
00134 {
00135   MESSAGE( "StdMeshers_FixedPoints1D_i::GetPoints" );
00136   ASSERT( myBaseImpl );
00137   SMESH::double_array_var anArray = new SMESH::double_array;
00138   std::vector<double> params = this->GetImpl()->GetPoints();
00139   anArray->length( params.size() );
00140   for ( CORBA::Long i = 0; i < params.size(); i++)
00141     anArray [ i ] = params [ i ];
00142 
00143   return anArray._retn();
00144 }
00145 
00146 //=============================================================================
00152 //=============================================================================
00153 
00154 SMESH::long_array* StdMeshers_FixedPoints1D_i::GetNbSegments()
00155 {
00156   MESSAGE( "StdMeshers_FixedPoints1D_i::GetNbSegments" );
00157   ASSERT( myBaseImpl );
00158   SMESH::long_array_var anArray = new SMESH::long_array;
00159   std::vector<int> nbsegs = this->GetImpl()->GetNbSegments();
00160   anArray->length( nbsegs.size() );
00161   for ( CORBA::Long i = 0; i < nbsegs.size(); i++)
00162     anArray [ i ] = nbsegs [ i ];
00163 
00164   return anArray._retn();
00165 }
00166 
00167 //=============================================================================
00173 //=============================================================================
00174 
00175 void StdMeshers_FixedPoints1D_i::SetReversedEdges( const SMESH::long_array& theIds )
00176 {
00177   ASSERT( myBaseImpl );
00178   try {
00179     std::vector<int> ids( theIds.length() );
00180     CORBA::Long iEnd = theIds.length();
00181     for ( CORBA::Long i = 0; i < iEnd; i++ )
00182       ids[ i ] = theIds[ i ];
00183 
00184     this->GetImpl()->SetReversedEdges( ids );
00185   }
00186   catch ( SALOME_Exception& S_ex ) {
00187     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00188                                   SALOME::BAD_PARAM );
00189   }
00190 
00191   // Update Python script
00192   SMESH::TPythonDump() << _this() << ".SetReversedEdges( " << theIds << " )";
00193 }
00194 
00195 //=============================================================================
00201 //=============================================================================
00202 
00203 void StdMeshers_FixedPoints1D_i::SetObjectEntry( const char* theEntry )
00204 {
00205   ASSERT( myBaseImpl );
00206   string entry(theEntry); // actually needed as theEntry is spoiled by moment of dumping
00207   try {
00208     this->GetImpl()->SetObjectEntry( entry.c_str() );
00209     // Update Python script
00210     SMESH::TPythonDump() << _this() << ".SetObjectEntry( \"" << entry.c_str() << "\" )";
00211   }
00212   catch ( SALOME_Exception& S_ex ) {
00213     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),SALOME::BAD_PARAM );
00214   }
00215 }
00216 
00217 //=============================================================================
00223 //=============================================================================
00224 
00225 char* StdMeshers_FixedPoints1D_i::GetObjectEntry()
00226 {
00227   MESSAGE( "StdMeshers_FixedPoints1D_i::SetObjectEntry" );
00228   ASSERT( myBaseImpl );
00229   const char* entry;
00230   try {
00231     entry = this->GetImpl()->GetObjectEntry();
00232   }
00233   catch ( SALOME_Exception& S_ex ) {
00234     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
00235                                   SALOME::BAD_PARAM );
00236   }
00237   return CORBA::string_dup( entry );
00238 }
00239 
00240 //=============================================================================
00246 //=============================================================================
00247 
00248 SMESH::long_array* StdMeshers_FixedPoints1D_i::GetReversedEdges()
00249 {
00250   MESSAGE( "StdMeshers_FixedPoints1D_i::GetReversedEdges" );
00251   ASSERT( myBaseImpl );
00252   SMESH::long_array_var anArray = new SMESH::long_array;
00253   std::vector<int> ids = this->GetImpl()->GetReversedEdges();
00254   anArray->length( ids.size() );
00255   for ( CORBA::Long i = 0; i < ids.size(); i++)
00256     anArray [ i ] = ids [ i ];
00257 
00258   return anArray._retn();
00259 }
00260 
00261 //=============================================================================
00267 //=============================================================================
00268 
00269 ::StdMeshers_FixedPoints1D* StdMeshers_FixedPoints1D_i::GetImpl()
00270 {
00271   MESSAGE( "StdMeshers_FixedPoints1D_i::GetImpl" );
00272   return ( ::StdMeshers_FixedPoints1D* )myBaseImpl;
00273 }
00274 
00275 //================================================================================
00283 //================================================================================  
00284 CORBA::Boolean StdMeshers_FixedPoints1D_i::IsDimSupported( SMESH::Dimension type )
00285 {
00286   return type == SMESH::DIM_1D;
00287 }
00288