Salome HOME
df282103c9e2f2749c6fbb7456796a2672a2da3d
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Hypothesis.cxx
1 //  BLSURFPlugin : C++ implementation
2 //
3 //  Copyright (C) 2006  OPEN CASCADE, CEA/DEN, EDF R&D
4 // 
5 //  This library is free software; you can redistribute it and/or 
6 //  modify it under the terms of the GNU Lesser General Public 
7 //  License as published by the Free Software Foundation; either 
8 //  version 2.1 of the License. 
9 // 
10 //  This library is distributed in the hope that it will be useful, 
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
13 //  Lesser General Public License for more details. 
14 // 
15 //  You should have received a copy of the GNU Lesser General Public 
16 //  License along with this library; if not, write to the Free Software 
17 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
18 // 
19 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
20 //
21 //
22 // File      : BLSURFPlugin_Hypothesis.cxx
23 // Authors   : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
24 // Date      : 28/03/2006
25 // Project   : SALOME
26 //=============================================================================
27
28 using namespace std;
29 #include <BLSURFPlugin_Hypothesis.hxx>
30 #include <utilities.h>
31
32 //=============================================================================
33 /*!
34  *  
35  */
36 //=============================================================================
37 BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis (int hypId, int studyId,
38                                                   SMESH_Gen * gen)
39   : SMESH_Hypothesis(hypId, studyId, gen),
40     _physicalMesh(GetDefaultPhysicalMesh()),
41     _phySize(GetDefaultPhySize()),
42     _geometricMesh(GetDefaultGeometricMesh()),
43     _angleMeshS(GetDefaultAngleMeshS()),
44     _gradation(GetDefaultGradation()),
45     _quadAllowed(GetDefaultQuadAllowed()),
46     _decimesh(GetDefaultDecimesh())
47 {
48   _name = "BLSURF_Parameters";
49   _param_algo_dim = 2;
50 }
51
52 //=============================================================================
53 /*!
54  *  
55  */
56 //=============================================================================
57 void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh)
58 {
59   if (thePhysicalMesh != _physicalMesh) {
60     _physicalMesh = thePhysicalMesh;
61     switch( _physicalMesh ) {
62       case DefaultSize:
63       default:
64         _phySize = GetDefaultPhySize();
65         break;
66       }
67     NotifySubMeshesHypothesisModification();
68   }
69 }
70
71 //=============================================================================
72 /*!
73  *  
74  */
75 //=============================================================================
76 void BLSURFPlugin_Hypothesis::SetPhySize(double theVal)
77 {
78   if (theVal != _phySize) {
79     _phySize = theVal;
80     NotifySubMeshesHypothesisModification();
81   }
82 }
83
84 //=============================================================================
85 /*!
86  *  
87  */
88 //=============================================================================
89 void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh)
90 {
91   if (theGeometricMesh != _geometricMesh) {
92     _geometricMesh = theGeometricMesh;
93     switch( _geometricMesh ) {
94       case DefaultGeom:
95       default:
96         _angleMeshS = GetDefaultAngleMeshS();
97         _gradation  = GetDefaultGradation();
98         break;
99       }
100     NotifySubMeshesHypothesisModification();
101   }
102 }
103
104 //=============================================================================
105 /*!
106  *  
107  */
108 //=============================================================================
109 void BLSURFPlugin_Hypothesis::SetAngleMeshS(double theVal)
110 {
111   if (theVal != _angleMeshS) {
112     _angleMeshS = theVal;
113     NotifySubMeshesHypothesisModification();
114   }
115 }
116
117 //=============================================================================
118 /*!
119  *  
120  */
121 //=============================================================================
122 void BLSURFPlugin_Hypothesis::SetGradation(double theVal)
123 {
124   if (theVal != _gradation) {
125     _gradation = theVal;
126     NotifySubMeshesHypothesisModification();
127   }
128 }
129
130 //=============================================================================
131 /*!
132  *  
133  */
134 //=============================================================================
135 void BLSURFPlugin_Hypothesis::SetQuadAllowed(bool theVal)
136 {
137   if (theVal != _quadAllowed) {
138     _quadAllowed = theVal;
139     NotifySubMeshesHypothesisModification();
140   }
141 }
142
143 //=============================================================================
144 /*!
145  *  
146  */
147 //=============================================================================
148 void BLSURFPlugin_Hypothesis::SetDecimesh(bool theVal)
149 {
150   if (theVal != _decimesh) {
151     _decimesh = theVal;
152     NotifySubMeshesHypothesisModification();
153   }
154 }
155
156 //=============================================================================
157 /*!
158  *  
159  */
160 //=============================================================================
161 ostream & BLSURFPlugin_Hypothesis::SaveTo(ostream & save)
162 {
163 //   save << _maxSize << " " << _fineness;
164
165 //   if (_fineness == UserDefined)
166 //     save << " " << _growthRate << " " << _nbSegPerEdge << " " << _nbSegPerRadius;
167
168 //   save << " " << (int)_secondOrder << " " << (int)_optimize;
169
170   return save;
171 }
172
173 //=============================================================================
174 /*!
175  *  
176  */
177 //=============================================================================
178 istream & BLSURFPlugin_Hypothesis::LoadFrom(istream & load)
179 {
180 //   bool isOK = true;
181 //   int is;
182 //   double val;
183
184 //   isOK = (load >> val);
185 //   if (isOK)
186 //     _maxSize = val;
187 //   else
188 //     load.clear(ios::badbit | load.rdstate());
189
190 //   isOK = (load >> is);
191 //   if (isOK)
192 //     SetFineness((Fineness) is);
193 //   else
194 //     load.clear(ios::badbit | load.rdstate());
195
196 //   if (_fineness == UserDefined)
197 //   {
198 //     isOK = (load >> val);
199 //     if (isOK)
200 //       _growthRate = val;
201 //     else
202 //       load.clear(ios::badbit | load.rdstate());
203
204 //     isOK = (load >> val);
205 //     if (isOK)
206 //       _nbSegPerEdge = val;
207 //     else
208 //       load.clear(ios::badbit | load.rdstate());
209
210 //     isOK = (load >> val);
211 //     if (isOK)
212 //       _nbSegPerRadius = val;
213 //     else
214 //       load.clear(ios::badbit | load.rdstate());
215 //   }
216
217 //   isOK = (load >> is);
218 //   if (isOK)
219 //     _secondOrder = (bool) is;
220 //   else
221 //     load.clear(ios::badbit | load.rdstate());
222
223 //   isOK = (load >> is);
224 //   if (isOK)
225 //     _optimize = (bool) is;
226 //   else
227 //     load.clear(ios::badbit | load.rdstate());
228   return load;
229 }
230
231 //=============================================================================
232 /*!
233  *  
234  */
235 //=============================================================================
236 ostream & operator <<(ostream & save, BLSURFPlugin_Hypothesis & hyp)
237 {
238   return hyp.SaveTo( save );
239 }
240
241 //=============================================================================
242 /*!
243  *  
244  */
245 //=============================================================================
246 istream & operator >>(istream & load, BLSURFPlugin_Hypothesis & hyp)
247 {
248   return hyp.LoadFrom( load );
249 }
250
251
252 //================================================================================
253 /*!
254  * \brief Does nothing
255  * \param theMesh - the built mesh
256  * \param theShape - the geometry of interest
257  * \retval bool - always false
258  */
259 //================================================================================
260 bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh*   theMesh,
261                                                       const TopoDS_Shape& theShape)
262 {
263   return false;
264 }
265
266 //=============================================================================
267 BLSURFPlugin_Hypothesis::PhysicalMesh BLSURFPlugin_Hypothesis::GetDefaultPhysicalMesh()
268 {
269   return PhysicalUserDefined;
270 }
271
272 //=============================================================================
273 double BLSURFPlugin_Hypothesis::GetDefaultPhySize()
274 {
275   return 10;
276 }
277
278 //=============================================================================
279 BLSURFPlugin_Hypothesis::GeometricMesh BLSURFPlugin_Hypothesis::GetDefaultGeometricMesh()
280 {
281   return DefaultGeom;
282 }
283
284 //=============================================================================
285 double BLSURFPlugin_Hypothesis::GetDefaultAngleMeshS()
286 {
287   return 8;
288 }
289
290 //=============================================================================
291 double BLSURFPlugin_Hypothesis::GetDefaultGradation()
292 {
293   return 1.1;
294 }
295
296 //=============================================================================
297 bool BLSURFPlugin_Hypothesis::GetDefaultQuadAllowed()
298 {
299   return false;
300 }
301
302 //=============================================================================
303 bool BLSURFPlugin_Hypothesis::GetDefaultDecimesh()
304 {
305   return false;
306 }