Version: 6.3.1

src/SMESH/SMESH_Hypothesis.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 : 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.3.6.1 2011-06-02 05:57:25 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 }
00056 
00057 //=============================================================================
00061 //=============================================================================
00062 
00063 SMESH_Hypothesis::~SMESH_Hypothesis()
00064 {
00065   MESSAGE("SMESH_Hypothesis::~SMESH_Hypothesis");
00066 }
00067 
00068 //=============================================================================
00072 //=============================================================================
00073 
00074 int SMESH_Hypothesis::GetDim() const
00075 {
00076   int dim = 0;
00077   switch (_type)
00078     {
00079     case ALGO_1D: dim = 1; break;
00080     case ALGO_2D: dim = 2; break;
00081     case ALGO_3D: dim = 3; break;
00082     case PARAM_ALGO:
00083       dim = ( _param_algo_dim < 0 ) ? -_param_algo_dim : _param_algo_dim; break;
00084     }
00085   return dim;
00086 }
00087 
00088 //=============================================================================
00092 //=============================================================================
00093 
00094 int SMESH_Hypothesis::GetShapeType() const
00095 {
00096   return _shapeType;
00097 }
00098 
00099 //=============================================================================
00103 //=============================================================================
00104 
00105 int SMESH_Hypothesis::GetStudyId() const
00106 {
00107   return _studyId;
00108 }
00109 
00110 //=============================================================================
00114 //=============================================================================
00115 
00116 void SMESH_Hypothesis::NotifySubMeshesHypothesisModification()
00117 {
00118   MESSAGE("SMESH_Hypothesis::NotifySubMeshesHypothesisModification");
00119 
00120   // for all meshes in study
00121 
00122   StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
00123   map<int, SMESH_Mesh*>::iterator itm;
00124   for (itm = myStudyContext->mapMesh.begin();
00125        itm != myStudyContext->mapMesh.end();
00126        itm++)
00127     {
00128       SMESH_Mesh* mesh = (*itm).second;
00129       mesh->NotifySubMeshesHypothesisModification( this );
00130     }
00131 }
00132 
00133 //=============================================================================
00137 //=============================================================================
00138 
00139 const char* SMESH_Hypothesis::GetLibName() const
00140 {
00141   return _libName.c_str();
00142 }
00143 
00144 //=============================================================================
00148 //=============================================================================
00149 
00150 void SMESH_Hypothesis::SetLibName(const char* theLibName)
00151 {
00152   _libName = string(theLibName);
00153 }
00154 
00155 //=======================================================================
00156 //function : GetMeshByPersistentID
00157 //purpose  : Find a mesh with given persistent ID
00158 //=======================================================================
00159 
00160 SMESH_Mesh* SMESH_Hypothesis::GetMeshByPersistentID(int id)
00161 {
00162   StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
00163   map<int, SMESH_Mesh*>::iterator itm = itm = myStudyContext->mapMesh.begin();
00164   for ( ; itm != myStudyContext->mapMesh.end(); itm++)
00165   {
00166     SMESH_Mesh* mesh = (*itm).second;
00167     if ( mesh->GetMeshDS()->GetPersistentId() == id )
00168       return mesh;
00169   }
00170   return 0;
00171 }
00172 
00173 //=============================================================================
00177 //=============================================================================
00178 void SMESH_Hypothesis::SetParameters(const char *theParameters)
00179 {
00180   string aNewParameters(theParameters);
00181   if(aNewParameters.size()==0 && _parameters.size()==0)
00182     aNewParameters = " ";
00183   if(_parameters.size()>0)
00184     _parameters +="|";
00185   _parameters +=aNewParameters;
00186   SetLastParameters(theParameters);
00187 }
00188 
00189 //=============================================================================
00193 //=============================================================================
00194 void SMESH_Hypothesis::ClearParameters()
00195 {
00196   _parameters = string();
00197 }
00198 
00199 //=============================================================================
00203 //=============================================================================
00204 char* SMESH_Hypothesis::GetParameters() const
00205 {
00206   return (char*)_parameters.c_str();
00207 }
00208 
00209 //=============================================================================
00213 //=============================================================================
00214 char* SMESH_Hypothesis::GetLastParameters() const
00215 {
00216   return (char*)_lastParameters.c_str();
00217 }
00218 
00219 //=============================================================================
00223 //=============================================================================
00224 void SMESH_Hypothesis::SetLastParameters(const char* theParameters)
00225 {
00226   _lastParameters = string(theParameters);
00227 }
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