Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[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 //             & Aurelien ALLEAUME (DISTENE)
25 // Date      : 28/03/2006
26 // Project   : SALOME
27 //=============================================================================
28
29 using namespace std;
30 #include <BLSURFPlugin_Hypothesis.hxx>
31 #include <utilities.h>
32
33 //=============================================================================
34 /*!
35  *  
36  */
37 //=============================================================================
38 BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis (int hypId, int studyId,
39                                                   SMESH_Gen * gen)
40   : SMESH_Hypothesis(hypId, studyId, gen),
41     _topology(GetDefaultTopology()),
42     _physicalMesh(GetDefaultPhysicalMesh()),
43     _phySize(GetDefaultPhySize()),
44     _geometricMesh(GetDefaultGeometricMesh()),
45     _angleMeshS(GetDefaultAngleMeshS()),
46     _gradation(GetDefaultGradation()),
47     _quadAllowed(GetDefaultQuadAllowed()),
48     _decimesh(GetDefaultDecimesh())
49 {
50   _name = "BLSURF_Parameters";
51   _param_algo_dim = 2;
52 }
53
54 //=============================================================================
55 /*!
56  *  
57  */
58 //=============================================================================
59 void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology)
60 {
61   if (theTopology != _topology) {
62     _topology = theTopology;
63     NotifySubMeshesHypothesisModification();
64   }
65 }
66
67 //=============================================================================
68 /*!
69  *  
70  */
71 //=============================================================================
72 void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh)
73 {
74   if (thePhysicalMesh != _physicalMesh) {
75     _physicalMesh = thePhysicalMesh;
76     switch( _physicalMesh ) {
77       case DefaultSize:
78       default:
79         _phySize = GetDefaultPhySize();
80         break;
81       }
82     NotifySubMeshesHypothesisModification();
83   }
84 }
85
86 //=============================================================================
87 /*!
88  *  
89  */
90 //=============================================================================
91 void BLSURFPlugin_Hypothesis::SetPhySize(double theVal)
92 {
93   if (theVal != _phySize) {
94     _phySize = theVal;
95     NotifySubMeshesHypothesisModification();
96   }
97 }
98
99 //=============================================================================
100 /*!
101  *  
102  */
103 //=============================================================================
104 void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh)
105 {
106   if (theGeometricMesh != _geometricMesh) {
107     _geometricMesh = theGeometricMesh;
108     switch( _geometricMesh ) {
109       case DefaultGeom:
110       default:
111         _angleMeshS = GetDefaultAngleMeshS();
112         _gradation  = GetDefaultGradation();
113         break;
114       }
115     NotifySubMeshesHypothesisModification();
116   }
117 }
118
119 //=============================================================================
120 /*!
121  *  
122  */
123 //=============================================================================
124 void BLSURFPlugin_Hypothesis::SetAngleMeshS(double theVal)
125 {
126   if (theVal != _angleMeshS) {
127     _angleMeshS = theVal;
128     NotifySubMeshesHypothesisModification();
129   }
130 }
131
132 //=============================================================================
133 /*!
134  *  
135  */
136 //=============================================================================
137 void BLSURFPlugin_Hypothesis::SetGradation(double theVal)
138 {
139   if (theVal != _gradation) {
140     _gradation = theVal;
141     NotifySubMeshesHypothesisModification();
142   }
143 }
144
145 //=============================================================================
146 /*!
147  *  
148  */
149 //=============================================================================
150 void BLSURFPlugin_Hypothesis::SetQuadAllowed(bool theVal)
151 {
152   if (theVal != _quadAllowed) {
153     _quadAllowed = theVal;
154     NotifySubMeshesHypothesisModification();
155   }
156 }
157
158 //=============================================================================
159 /*!
160  *  
161  */
162 //=============================================================================
163 void BLSURFPlugin_Hypothesis::SetDecimesh(bool theVal)
164 {
165   if (theVal != _decimesh) {
166     _decimesh = theVal;
167     NotifySubMeshesHypothesisModification();
168   }
169 }
170
171 //=============================================================================
172 /*!
173  *  
174  */
175 //=============================================================================
176 ostream & BLSURFPlugin_Hypothesis::SaveTo(ostream & save)
177 {
178 //   save << _maxSize << " " << _fineness;
179
180 //   if (_fineness == UserDefined)
181 //     save << " " << _growthRate << " " << _nbSegPerEdge << " " << _nbSegPerRadius;
182
183 //   save << " " << (int)_secondOrder << " " << (int)_optimize;
184
185   return save;
186 }
187
188 //=============================================================================
189 /*!
190  *  
191  */
192 //=============================================================================
193 istream & BLSURFPlugin_Hypothesis::LoadFrom(istream & load)
194 {
195 //   bool isOK = true;
196 //   int is;
197 //   double val;
198
199 //   isOK = (load >> val);
200 //   if (isOK)
201 //     _maxSize = val;
202 //   else
203 //     load.clear(ios::badbit | load.rdstate());
204
205 //   isOK = (load >> is);
206 //   if (isOK)
207 //     SetFineness((Fineness) is);
208 //   else
209 //     load.clear(ios::badbit | load.rdstate());
210
211 //   if (_fineness == UserDefined)
212 //   {
213 //     isOK = (load >> val);
214 //     if (isOK)
215 //       _growthRate = val;
216 //     else
217 //       load.clear(ios::badbit | load.rdstate());
218
219 //     isOK = (load >> val);
220 //     if (isOK)
221 //       _nbSegPerEdge = val;
222 //     else
223 //       load.clear(ios::badbit | load.rdstate());
224
225 //     isOK = (load >> val);
226 //     if (isOK)
227 //       _nbSegPerRadius = val;
228 //     else
229 //       load.clear(ios::badbit | load.rdstate());
230 //   }
231
232 //   isOK = (load >> is);
233 //   if (isOK)
234 //     _secondOrder = (bool) is;
235 //   else
236 //     load.clear(ios::badbit | load.rdstate());
237
238 //   isOK = (load >> is);
239 //   if (isOK)
240 //     _optimize = (bool) is;
241 //   else
242 //     load.clear(ios::badbit | load.rdstate());
243   return load;
244 }
245
246 //=============================================================================
247 /*!
248  *  
249  */
250 //=============================================================================
251 ostream & operator <<(ostream & save, BLSURFPlugin_Hypothesis & hyp)
252 {
253   return hyp.SaveTo( save );
254 }
255
256 //=============================================================================
257 /*!
258  *  
259  */
260 //=============================================================================
261 istream & operator >>(istream & load, BLSURFPlugin_Hypothesis & hyp)
262 {
263   return hyp.LoadFrom( load );
264 }
265
266
267 //================================================================================
268 /*!
269  * \brief Does nothing
270  * \param theMesh - the built mesh
271  * \param theShape - the geometry of interest
272  * \retval bool - always false
273  */
274 //================================================================================
275 bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh*   theMesh,
276                                                       const TopoDS_Shape& theShape)
277 {
278   return false;
279 }
280
281 //=============================================================================
282 BLSURFPlugin_Hypothesis::Topology BLSURFPlugin_Hypothesis::GetDefaultTopology()
283 {
284   return FromCAD;
285 }
286
287 //=============================================================================
288 BLSURFPlugin_Hypothesis::PhysicalMesh BLSURFPlugin_Hypothesis::GetDefaultPhysicalMesh()
289 {
290   return PhysicalUserDefined;
291 }
292
293 //=============================================================================
294 double BLSURFPlugin_Hypothesis::GetDefaultPhySize()
295 {
296   return 10;
297 }
298
299 //=============================================================================
300 BLSURFPlugin_Hypothesis::GeometricMesh BLSURFPlugin_Hypothesis::GetDefaultGeometricMesh()
301 {
302   return DefaultGeom;
303 }
304
305 //=============================================================================
306 double BLSURFPlugin_Hypothesis::GetDefaultAngleMeshS()
307 {
308   return 8;
309 }
310
311 //=============================================================================
312 double BLSURFPlugin_Hypothesis::GetDefaultGradation()
313 {
314   return 1.1;
315 }
316
317 //=============================================================================
318 bool BLSURFPlugin_Hypothesis::GetDefaultQuadAllowed()
319 {
320   return false;
321 }
322
323 //=============================================================================
324 bool BLSURFPlugin_Hypothesis::GetDefaultDecimesh()
325 {
326   return false;
327 }