1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESH : implementaion of SMESH idl descriptions
24 // File : SMESH_Hypothesis.cxx
25 // Author : Paul RASCLE, EDF
29 #include "SMESH_Hypothesis.hxx"
30 #include "SMESH_Gen.hxx"
31 #include "SMESH_subMesh.hxx"
32 #include "utilities.h"
36 //=============================================================================
40 //=============================================================================
42 SMESH_Hypothesis::SMESH_Hypothesis(int hypId,
44 SMESH_Gen* gen) : SMESHDS_Hypothesis(hypId)
46 //MESSAGE("SMESH_Hypothesis::SMESH_Hypothesis");
49 StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
50 myStudyContext->mapHypothesis[_hypId] = this;
52 _shapeType = 0; // to be set by algo with TopAbs_Enum
53 _param_algo_dim = -1; // to be set by algo parameter
54 _parameters = string();
55 _lastParameters = string();
59 //=============================================================================
63 //=============================================================================
65 SMESH_Hypothesis::~SMESH_Hypothesis()
67 MESSAGE("SMESH_Hypothesis::~SMESH_Hypothesis");
70 //=============================================================================
74 //=============================================================================
76 int SMESH_Hypothesis::GetDim() const
81 case ALGO_1D: dim = 1; break;
82 case ALGO_2D: dim = 2; break;
83 case ALGO_3D: dim = 3; break;
85 dim = ( _param_algo_dim < 0 ) ? -_param_algo_dim : _param_algo_dim; break;
90 //=============================================================================
94 //=============================================================================
96 int SMESH_Hypothesis::GetShapeType() const
101 //=============================================================================
105 //=============================================================================
107 int SMESH_Hypothesis::GetStudyId() const
112 //=============================================================================
116 //=============================================================================
118 void SMESH_Hypothesis::NotifySubMeshesHypothesisModification()
120 MESSAGE("SMESH_Hypothesis::NotifySubMeshesHypothesisModification");
122 // for all meshes in study
124 StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
125 map<int, SMESH_Mesh*>::iterator itm;
126 for (itm = myStudyContext->mapMesh.begin();
127 itm != myStudyContext->mapMesh.end();
130 SMESH_Mesh* mesh = (*itm).second;
131 mesh->NotifySubMeshesHypothesisModification( this );
135 //=============================================================================
139 //=============================================================================
141 const char* SMESH_Hypothesis::GetLibName() const
143 return _libName.c_str();
146 //=============================================================================
150 //=============================================================================
152 void SMESH_Hypothesis::SetLibName(const char* theLibName)
154 _libName = string(theLibName);
157 //=======================================================================
158 //function : GetMeshByPersistentID
159 //purpose : Find a mesh with given persistent ID
160 //=======================================================================
162 SMESH_Mesh* SMESH_Hypothesis::GetMeshByPersistentID(int id)
164 StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
165 map<int, SMESH_Mesh*>::iterator itm = itm = myStudyContext->mapMesh.begin();
166 for ( ; itm != myStudyContext->mapMesh.end(); itm++)
168 SMESH_Mesh* mesh = (*itm).second;
169 if ( mesh->GetMeshDS()->GetPersistentId() == id )
175 //=============================================================================
179 //=============================================================================
180 void SMESH_Hypothesis::SetParameters(const char *theParameters)
182 string aNewParameters(theParameters);
183 if(aNewParameters.size()==0 && _parameters.size()==0)
184 aNewParameters = " ";
185 if(_parameters.size()>0)
187 _parameters +=aNewParameters;
188 SetLastParameters(theParameters);
191 //=============================================================================
195 //=============================================================================
196 void SMESH_Hypothesis::ClearParameters()
198 _parameters = string();
201 //=============================================================================
205 //=============================================================================
206 char* SMESH_Hypothesis::GetParameters() const
208 return (char*)_parameters.c_str();
211 //=============================================================================
215 //=============================================================================
216 char* SMESH_Hypothesis::GetLastParameters() const
218 return (char*)_lastParameters.c_str();
221 //=============================================================================
225 //=============================================================================
226 void SMESH_Hypothesis::SetLastParameters(const char* theParameters)
228 _lastParameters = string(theParameters);