Salome HOME
untabify
[modules/smesh.git] / src / SMESH / SMESH_Hypothesis.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SMESH SMESH : implementaion of SMESH idl descriptions
23 //  File   : SMESH_Hypothesis.cxx
24 //  Author : Paul RASCLE, EDF
25 //  Module : SMESH
26 //
27 #include "SMESH_Hypothesis.hxx"
28 #include "SMESH_Gen.hxx"
29 #include "SMESH_subMesh.hxx"
30 #include "utilities.h"
31
32 using namespace std;
33
34 //=============================================================================
35 /*!
36  * 
37  */
38 //=============================================================================
39
40 SMESH_Hypothesis::SMESH_Hypothesis(int hypId,
41                                    int studyId,
42                                    SMESH_Gen* gen) : SMESHDS_Hypothesis(hypId)
43 {
44   //MESSAGE("SMESH_Hypothesis::SMESH_Hypothesis");
45   _gen = gen;
46   _studyId = studyId;
47   StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
48   myStudyContext->mapHypothesis[_hypId] = this;
49   _type = PARAM_ALGO;
50   _shapeType = 0; // to be set by algo with TopAbs_Enum
51   _param_algo_dim = -1; // to be set by algo parameter
52   _parameters = string();
53 }
54
55 //=============================================================================
56 /*!
57  * 
58  */
59 //=============================================================================
60
61 SMESH_Hypothesis::~SMESH_Hypothesis()
62 {
63   MESSAGE("SMESH_Hypothesis::~SMESH_Hypothesis");
64 }
65
66 //=============================================================================
67 /*!
68  * 
69  */
70 //=============================================================================
71
72 int SMESH_Hypothesis::GetDim() const
73 {
74   int dim = 0;
75   switch (_type)
76     {
77     case ALGO_1D: dim = 1; break;
78     case ALGO_2D: dim = 2; break;
79     case ALGO_3D: dim = 3; break;
80     case PARAM_ALGO:
81       dim = ( _param_algo_dim < 0 ) ? -_param_algo_dim : _param_algo_dim; break;
82     }
83   return dim;
84 }
85
86 //=============================================================================
87 /*!
88  *  
89  */
90 //=============================================================================
91
92 int SMESH_Hypothesis::GetShapeType() const
93 {
94   return _shapeType;
95 }
96
97 //=============================================================================
98 /*!
99  * 
100  */
101 //=============================================================================
102
103 int SMESH_Hypothesis::GetStudyId() const
104 {
105   return _studyId;
106 }
107
108 //=============================================================================
109 /*!
110  * 
111  */
112 //=============================================================================
113
114 void SMESH_Hypothesis::NotifySubMeshesHypothesisModification()
115 {
116   MESSAGE("SMESH_Hypothesis::NotifySubMeshesHypothesisModification");
117
118   // for all meshes in study
119
120   StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
121   map<int, SMESH_Mesh*>::iterator itm;
122   for (itm = myStudyContext->mapMesh.begin();
123        itm != myStudyContext->mapMesh.end();
124        itm++)
125     {
126       SMESH_Mesh* mesh = (*itm).second;
127       mesh->NotifySubMeshesHypothesisModification( this );
128     }
129 }
130
131 //=============================================================================
132 /*!
133  * 
134  */
135 //=============================================================================
136
137 const char* SMESH_Hypothesis::GetLibName() const
138 {
139   return _libName.c_str();
140 }
141
142 //=============================================================================
143 /*!
144  * 
145  */
146 //=============================================================================
147
148 void SMESH_Hypothesis::SetLibName(const char* theLibName)
149 {
150   _libName = string(theLibName);
151 }
152
153 //=============================================================================
154 /*!
155  * 
156  */
157 //=============================================================================
158 void SMESH_Hypothesis::SetParameters(const char *theParameters)
159 {
160   string aNewParameters(theParameters);
161   if(aNewParameters.size()==0 && _parameters.size()==0)
162     aNewParameters = " ";
163   if(_parameters.size()>0)
164     _parameters +="|";
165   _parameters +=aNewParameters;
166   SetLastParameters(theParameters);
167 }
168
169 //=============================================================================
170 /*!
171  * 
172  */
173 //=============================================================================
174 void SMESH_Hypothesis::ClearParameters()
175 {
176   _parameters = string();
177 }
178
179 //=============================================================================
180 /*!
181  * 
182  */
183 //=============================================================================
184 char* SMESH_Hypothesis::GetParameters() const
185 {
186   return (char*)_parameters.c_str();
187 }
188
189 //=============================================================================
190 /*!
191  * 
192  */
193 //=============================================================================
194 char* SMESH_Hypothesis::GetLastParameters() const
195 {
196   return (char*)_lastParameters.c_str();
197 }
198
199 //=============================================================================
200 /*!
201  * 
202  */
203 //=============================================================================
204 void SMESH_Hypothesis::SetLastParameters(const char* theParameters)
205 {
206   _lastParameters = string(theParameters);
207 }