Back to index

salome-smesh  6.5.0
SMESH_Hypothesis.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 : implementaion of SMESH idl descriptions
00024 //  File   : SMESH_Hypothesis.cxx
00025 //  Author : Paul RASCLE, EDF
00026 //  Module : SMESH
00027 //  $Header: /home/server/cvs/SMESH/SMESH_SRC/src/SMESH/SMESH_Hypothesis.cxx,v 1.10.2.2.10.5.2.1 2012-04-13 09:31:08 vsr Exp $
00028 //
00029 #include "SMESH_Hypothesis.hxx"
00030 #include "SMESH_Gen.hxx"
00031 #include "SMESH_subMesh.hxx"
00032 #include "utilities.h"
00033 
00034 using namespace std;
00035 
00036 //=============================================================================
00040 //=============================================================================
00041 
00042 SMESH_Hypothesis::SMESH_Hypothesis(int hypId,
00043                                    int studyId,
00044                                    SMESH_Gen* gen) : SMESHDS_Hypothesis(hypId)
00045 {
00046   //MESSAGE("SMESH_Hypothesis::SMESH_Hypothesis");
00047   _gen = gen;
00048   _studyId = studyId;
00049   StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
00050   myStudyContext->mapHypothesis[_hypId] = this;
00051   _type = PARAM_ALGO;
00052   _shapeType = 0; // to be set by algo with TopAbs_Enum
00053   _param_algo_dim = -1; // to be set by algo parameter
00054   _parameters = string();
00055   _lastParameters = string();
00056   _libName = string();
00057 }
00058 
00059 //=============================================================================
00063 //=============================================================================
00064 
00065 SMESH_Hypothesis::~SMESH_Hypothesis()
00066 {
00067   MESSAGE("SMESH_Hypothesis::~SMESH_Hypothesis");
00068 }
00069 
00070 //=============================================================================
00074 //=============================================================================
00075 
00076 int SMESH_Hypothesis::GetDim() const
00077 {
00078   int dim = 0;
00079   switch (_type)
00080     {
00081     case ALGO_1D: dim = 1; break;
00082     case ALGO_2D: dim = 2; break;
00083     case ALGO_3D: dim = 3; break;
00084     case PARAM_ALGO:
00085       dim = ( _param_algo_dim < 0 ) ? -_param_algo_dim : _param_algo_dim; break;
00086     }
00087   return dim;
00088 }
00089 
00090 //=============================================================================
00094 //=============================================================================
00095 
00096 int SMESH_Hypothesis::GetShapeType() const
00097 {
00098   return _shapeType;
00099 }
00100 
00101 //=============================================================================
00105 //=============================================================================
00106 
00107 int SMESH_Hypothesis::GetStudyId() const
00108 {
00109   return _studyId;
00110 }
00111 
00112 //=============================================================================
00116 //=============================================================================
00117 
00118 void SMESH_Hypothesis::NotifySubMeshesHypothesisModification()
00119 {
00120   MESSAGE("SMESH_Hypothesis::NotifySubMeshesHypothesisModification");
00121 
00122   // for all meshes in study
00123 
00124   StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
00125   map<int, SMESH_Mesh*>::iterator itm;
00126   for (itm = myStudyContext->mapMesh.begin();
00127        itm != myStudyContext->mapMesh.end();
00128        itm++)
00129     {
00130       SMESH_Mesh* mesh = (*itm).second;
00131       mesh->NotifySubMeshesHypothesisModification( this );
00132     }
00133 }
00134 
00135 //=============================================================================
00139 //=============================================================================
00140 
00141 const char* SMESH_Hypothesis::GetLibName() const
00142 {
00143   return _libName.c_str();
00144 }
00145 
00146 //=============================================================================
00150 //=============================================================================
00151 
00152 void SMESH_Hypothesis::SetLibName(const char* theLibName)
00153 {
00154   _libName = string(theLibName);
00155 }
00156 
00157 //=======================================================================
00158 //function : GetMeshByPersistentID
00159 //purpose  : Find a mesh with given persistent ID
00160 //=======================================================================
00161 
00162 SMESH_Mesh* SMESH_Hypothesis::GetMeshByPersistentID(int id)
00163 {
00164   StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
00165   map<int, SMESH_Mesh*>::iterator itm = itm = myStudyContext->mapMesh.begin();
00166   for ( ; itm != myStudyContext->mapMesh.end(); itm++)
00167   {
00168     SMESH_Mesh* mesh = (*itm).second;
00169     if ( mesh->GetMeshDS()->GetPersistentId() == id )
00170       return mesh;
00171   }
00172   return 0;
00173 }
00174 
00175 //=============================================================================
00179 //=============================================================================
00180 void SMESH_Hypothesis::SetParameters(const char *theParameters)
00181 {
00182   string aNewParameters(theParameters);
00183   if(aNewParameters.size()==0 && _parameters.size()==0)
00184     aNewParameters = " ";
00185   if(_parameters.size()>0)
00186     _parameters +="|";
00187   _parameters +=aNewParameters;
00188   SetLastParameters(theParameters);
00189 }
00190 
00191 //=============================================================================
00195 //=============================================================================
00196 void SMESH_Hypothesis::ClearParameters()
00197 {
00198   _parameters = string();
00199 }
00200 
00201 //=============================================================================
00205 //=============================================================================
00206 char* SMESH_Hypothesis::GetParameters() const
00207 {
00208   return (char*)_parameters.c_str();
00209 }
00210 
00211 //=============================================================================
00215 //=============================================================================
00216 char* SMESH_Hypothesis::GetLastParameters() const
00217 {
00218   return (char*)_lastParameters.c_str();
00219 }
00220 
00221 //=============================================================================
00225 //=============================================================================
00226 void SMESH_Hypothesis::SetLastParameters(const char* theParameters)
00227 {
00228   _lastParameters = string(theParameters);
00229 }