Version: 6.3.1

src/SMESH_I/SMESH_Hypothesis_i.cxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  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   : SMESH_Hypothesis_i.cxx
00025 //  Author : Paul RASCLE, EDF
00026 //  Module : SMESH
00027 //  $Header: /home/server/cvs/SMESH/SMESH_SRC/src/SMESH_I/SMESH_Hypothesis_i.cxx,v 1.12.20.2.6.1 2011-06-02 05:57:30 vsr Exp $
00028 //
00029 #include <iostream>
00030 #include <sstream>
00031 #include "SMESH_Hypothesis_i.hxx"
00032 #include "SMESH_Gen_i.hxx"
00033 #include "utilities.h"
00034 
00035 using namespace std;
00036 
00037 //=============================================================================
00043 //=============================================================================
00044 
00045 SMESH_Hypothesis_i::SMESH_Hypothesis_i( PortableServer::POA_ptr thePOA )
00046      : SALOME::GenericObj_i( thePOA )
00047 {
00048   MESSAGE( "SMESH_Hypothesis_i::SMESH_Hypothesis_i / Début" );
00049   myBaseImpl = 0;
00050   
00051   MESSAGE( "SMESH_Hypothesis_i::SMESH_Hypothesis_i / Fin" );
00052 };
00053 
00054 //=============================================================================
00060 //=============================================================================
00061 
00062 SMESH_Hypothesis_i::~SMESH_Hypothesis_i()
00063 {
00064   MESSAGE( "SMESH_Hypothesis_i::~SMESH_Hypothesis_i" );
00065   if ( myBaseImpl )
00066     delete myBaseImpl;
00067 };
00068 
00069 //=============================================================================
00075 //=============================================================================
00076 
00077 char* SMESH_Hypothesis_i::GetName()
00078 {
00079   //MESSAGE( "SMESH_Hypothesis_i::GetName" );
00080   return CORBA::string_dup( myBaseImpl->GetName() );
00081 };
00082 
00083 //=============================================================================
00089 //=============================================================================
00090 
00091 char* SMESH_Hypothesis_i::GetLibName()
00092 {
00093   MESSAGE( "SMESH_Hypothesis_i::GetLibName" );
00094   return CORBA::string_dup( myBaseImpl->GetLibName() );
00095 };
00096 
00097 //=============================================================================
00103 //=============================================================================
00104 
00105 void SMESH_Hypothesis_i::SetLibName(const char* theLibName)
00106 {
00107   MESSAGE( "SMESH_Hypothesis_i::SetLibName" );
00108   myBaseImpl->SetLibName( theLibName );
00109 };
00110 
00111 //=============================================================================
00117 //=============================================================================
00118 
00119 CORBA::Long SMESH_Hypothesis_i::GetId()
00120 {
00121   MESSAGE( "SMESH_Hypothesis_i::GetId" );
00122   return myBaseImpl->GetID();
00123 }
00124 
00125 //=============================================================================
00130 //=============================================================================
00131 bool SMESH_Hypothesis_i::IsPublished(){
00132   bool res = false;
00133   SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
00134   if(gen){
00135     SALOMEDS::SObject_var SO = 
00136       SMESH_Gen_i::ObjectToSObject(gen->GetCurrentStudy() , SMESH::SMESH_Hypothesis::_narrow(_this()));
00137     res = !SO->_is_nil();
00138   }
00139   return res;
00140 }
00141 
00142 //=============================================================================
00147 //=============================================================================
00148 void SMESH_Hypothesis_i::SetParameters(const char* theParameters)
00149 {
00150   SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
00151   char * aParameters = CORBA::string_dup(theParameters);
00152   if(gen){
00153     if(IsPublished()) {
00154       SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Hypothesis::_narrow(_this()),aParameters);
00155     }
00156     else {
00157       myBaseImpl->SetParameters(gen->ParseParameters(aParameters));
00158     }
00159   }
00160 }
00161 
00162 //=============================================================================
00167 //=============================================================================
00168 char* SMESH_Hypothesis_i::GetParameters()
00169 {
00170   SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
00171   char* aResult;
00172   if(IsPublished()) {
00173     MESSAGE("SMESH_Hypothesis_i::GetParameters() : Get Parameters from SObject");
00174     aResult = gen->GetParameters(SMESH::SMESH_Hypothesis::_narrow(_this()));
00175   }
00176   else {
00177     MESSAGE("SMESH_Hypothesis_i::GetParameters() : Get local parameters");
00178     aResult = myBaseImpl->GetParameters(); 
00179   }
00180   return CORBA::string_dup(aResult);
00181 }
00182 
00183 //=============================================================================
00188 //=============================================================================
00189 SMESH::ListOfParameters* SMESH_Hypothesis_i::GetLastParameters()
00190 {
00191   SMESH::ListOfParameters_var aResult = new SMESH::ListOfParameters();
00192   SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
00193   if(gen) {
00194     char *aParameters;
00195     if(IsPublished())
00196      aParameters = GetParameters();
00197     else
00198       aParameters = myBaseImpl->GetLastParameters();
00199 
00200     SALOMEDS::Study_ptr aStudy = gen->GetCurrentStudy();
00201     if(!aStudy->_is_nil()) {
00202       SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters); 
00203       if(aSections->length() > 0) {
00204         SALOMEDS::ListOfStrings aVars = aSections[aSections->length()-1];
00205         aResult->length(aVars.length());
00206         for(int i = 0;i < aVars.length();i++)
00207           aResult[i] = CORBA::string_dup( aVars[i]);
00208       }
00209     }
00210   }
00211   return aResult._retn();
00212 }
00213 
00214 //=============================================================================
00219 //=============================================================================
00220 void SMESH_Hypothesis_i::SetLastParameters(const char* theParameters)
00221 {
00222   if(!IsPublished()) {
00223     myBaseImpl->SetLastParameters(theParameters);
00224   }
00225 }
00226 //=============================================================================
00231 //=============================================================================
00232 void SMESH_Hypothesis_i::ClearParameters()
00233 {
00234   if(!IsPublished()) {
00235     myBaseImpl->ClearParameters();
00236   }
00237 }
00238 
00239 //=============================================================================
00245 //=============================================================================
00246 
00247 ::SMESH_Hypothesis* SMESH_Hypothesis_i::GetImpl()
00248 {
00249   //MESSAGE( "SMESH_Hypothesis_i::GetImpl" );
00250   return myBaseImpl;
00251 }
00252 
00253 //=============================================================================
00259 //=============================================================================
00260 
00261 char* SMESH_Hypothesis_i::SaveTo()
00262 {
00263   MESSAGE( "SMESH_Hypothesis_i::SaveTo" );
00264   std::ostringstream os;
00265   myBaseImpl->SaveTo( os );
00266   return CORBA::string_dup( os.str().c_str() );
00267 }
00268 
00269 //=============================================================================
00275 //=============================================================================
00276 
00277 void SMESH_Hypothesis_i::LoadFrom( const char* theStream )
00278 {
00279   MESSAGE( "SMESH_Hypothesis_i::LoadFrom" );
00280   std::istringstream is( theStream );
00281   myBaseImpl->LoadFrom( is );
00282   // let listeners know about loading (issue 0020918)
00283   myBaseImpl->NotifySubMeshesHypothesisModification();
00284 }
00285 
00286 //================================================================================
00290 //================================================================================
00291 
00292 void SMESH_Hypothesis_i::UpdateAsMeshesRestored()
00293 {
00294   // for hyps needing full data restored
00295 }
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS