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();
57 //=============================================================================
61 //=============================================================================
63 SMESH_Hypothesis::~SMESH_Hypothesis()
65 MESSAGE("SMESH_Hypothesis::~SMESH_Hypothesis");
68 //=============================================================================
72 //=============================================================================
74 int SMESH_Hypothesis::GetDim() const
79 case ALGO_1D: dim = 1; break;
80 case ALGO_2D: dim = 2; break;
81 case ALGO_3D: dim = 3; break;
83 dim = ( _param_algo_dim < 0 ) ? -_param_algo_dim : _param_algo_dim; break;
88 //=============================================================================
92 //=============================================================================
94 int SMESH_Hypothesis::GetShapeType() const
99 //=============================================================================
103 //=============================================================================
105 int SMESH_Hypothesis::GetStudyId() const
110 //=============================================================================
114 //=============================================================================
116 void SMESH_Hypothesis::NotifySubMeshesHypothesisModification()
118 MESSAGE("SMESH_Hypothesis::NotifySubMeshesHypothesisModification");
120 // for all meshes in study
122 StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
123 map<int, SMESH_Mesh*>::iterator itm;
124 for (itm = myStudyContext->mapMesh.begin();
125 itm != myStudyContext->mapMesh.end();
128 SMESH_Mesh* mesh = (*itm).second;
129 mesh->NotifySubMeshesHypothesisModification( this );
133 //=============================================================================
137 //=============================================================================
139 const char* SMESH_Hypothesis::GetLibName() const
141 return _libName.c_str();
144 //=============================================================================
148 //=============================================================================
150 void SMESH_Hypothesis::SetLibName(const char* theLibName)
152 _libName = string(theLibName);
155 //=======================================================================
156 //function : GetMeshByPersistentID
157 //purpose : Find a mesh with given persistent ID
158 //=======================================================================
160 SMESH_Mesh* SMESH_Hypothesis::GetMeshByPersistentID(int id)
162 StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
163 map<int, SMESH_Mesh*>::iterator itm = itm = myStudyContext->mapMesh.begin();
164 for ( ; itm != myStudyContext->mapMesh.end(); itm++)
166 SMESH_Mesh* mesh = (*itm).second;
167 if ( mesh->GetMeshDS()->GetPersistentId() == id )
173 //=============================================================================
177 //=============================================================================
178 void SMESH_Hypothesis::SetParameters(const char *theParameters)
180 string aNewParameters(theParameters);
181 if(aNewParameters.size()==0 && _parameters.size()==0)
182 aNewParameters = " ";
183 if(_parameters.size()>0)
185 _parameters +=aNewParameters;
186 SetLastParameters(theParameters);
189 //=============================================================================
193 //=============================================================================
194 void SMESH_Hypothesis::ClearParameters()
196 _parameters = string();
199 //=============================================================================
203 //=============================================================================
204 char* SMESH_Hypothesis::GetParameters() const
206 return (char*)_parameters.c_str();
209 //=============================================================================
213 //=============================================================================
214 char* SMESH_Hypothesis::GetLastParameters() const
216 return (char*)_lastParameters.c_str();
219 //=============================================================================
223 //=============================================================================
224 void SMESH_Hypothesis::SetLastParameters(const char* theParameters)
226 _lastParameters = string(theParameters);