1 // NETGENPlugin : C++ implementation
3 // Copyright (C) 2006 OPEN CASCADE, CEA/DEN, EDF R&D
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.
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.
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
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : NETGENPlugin_Hypothesis.cxx
23 // Author : Michael Sazonov (OCN)
27 //=============================================================================
29 #include <NETGENPlugin_Hypothesis.hxx>
30 #include <utilities.h>
34 //=============================================================================
38 //=============================================================================
39 NETGENPlugin_Hypothesis::NETGENPlugin_Hypothesis (int hypId, int studyId,
41 : SMESH_Hypothesis(hypId, studyId, gen),
42 _maxSize (GetDefaultMaxSize()),
43 _growthRate (GetDefaultGrowthRate()),
44 _nbSegPerEdge (GetDefaultNbSegPerEdge()),
45 _nbSegPerRadius(GetDefaultNbSegPerRadius()),
46 _fineness (GetDefaultFineness()),
47 _secondOrder (GetDefaultSecondOrder()),
48 _optimize (GetDefaultOptimize())
50 _name = "NETGEN_Parameters";
54 //=============================================================================
58 //=============================================================================
59 void NETGENPlugin_Hypothesis::SetMaxSize(double theSize)
61 if (theSize != _maxSize)
64 NotifySubMeshesHypothesisModification();
68 //=============================================================================
72 //=============================================================================
73 void NETGENPlugin_Hypothesis::SetSecondOrder(bool theVal)
75 if (theVal != _secondOrder)
77 _secondOrder = theVal;
78 NotifySubMeshesHypothesisModification();
82 //=============================================================================
86 //=============================================================================
87 void NETGENPlugin_Hypothesis::SetOptimize(bool theVal)
89 if (theVal != _optimize)
92 NotifySubMeshesHypothesisModification();
96 //=============================================================================
100 //=============================================================================
101 void NETGENPlugin_Hypothesis::SetFineness(Fineness theFineness)
103 if (theFineness != _fineness)
105 _fineness = theFineness;
106 // the predefined values are taken from NETGEN 4.5 sources
117 _nbSegPerRadius = 1.5;
138 NotifySubMeshesHypothesisModification();
142 //=============================================================================
146 //=============================================================================
147 void NETGENPlugin_Hypothesis::SetGrowthRate(double theRate)
149 if (theRate != _growthRate)
151 _growthRate = theRate;
152 _fineness = UserDefined;
153 NotifySubMeshesHypothesisModification();
157 //=============================================================================
161 //=============================================================================
162 void NETGENPlugin_Hypothesis::SetNbSegPerEdge(double theVal)
164 if (theVal != _nbSegPerEdge)
166 _nbSegPerEdge = theVal;
167 _fineness = UserDefined;
168 NotifySubMeshesHypothesisModification();
172 //=============================================================================
176 //=============================================================================
177 void NETGENPlugin_Hypothesis::SetNbSegPerRadius(double theVal)
179 if (theVal != _nbSegPerRadius)
181 _nbSegPerRadius = theVal;
182 _fineness = UserDefined;
183 NotifySubMeshesHypothesisModification();
187 //=============================================================================
191 //=============================================================================
192 ostream & NETGENPlugin_Hypothesis::SaveTo(ostream & save)
194 save << _maxSize << " " << _fineness;
196 if (_fineness == UserDefined)
197 save << " " << _growthRate << " " << _nbSegPerEdge << " " << _nbSegPerRadius;
199 save << " " << (int)_secondOrder << " " << (int)_optimize;
204 //=============================================================================
208 //=============================================================================
209 istream & NETGENPlugin_Hypothesis::LoadFrom(istream & load)
215 isOK = (load >> val);
219 load.clear(ios::badbit | load.rdstate());
223 SetFineness((Fineness) is);
225 load.clear(ios::badbit | load.rdstate());
227 if (_fineness == UserDefined)
229 isOK = (load >> val);
233 load.clear(ios::badbit | load.rdstate());
235 isOK = (load >> val);
239 load.clear(ios::badbit | load.rdstate());
241 isOK = (load >> val);
243 _nbSegPerRadius = val;
245 load.clear(ios::badbit | load.rdstate());
250 _secondOrder = (bool) is;
252 load.clear(ios::badbit | load.rdstate());
256 _optimize = (bool) is;
258 load.clear(ios::badbit | load.rdstate());
262 //=============================================================================
266 //=============================================================================
267 ostream & operator <<(ostream & save, NETGENPlugin_Hypothesis & hyp)
269 return hyp.SaveTo( save );
272 //=============================================================================
276 //=============================================================================
277 istream & operator >>(istream & load, NETGENPlugin_Hypothesis & hyp)
279 return hyp.LoadFrom( load );
283 //================================================================================
285 * \brief Does nothing
286 * \param theMesh - the built mesh
287 * \param theShape - the geometry of interest
288 * \retval bool - always false
290 //================================================================================
291 bool NETGENPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh,
292 const TopoDS_Shape& theShape)
297 //=============================================================================
301 //=============================================================================
302 double NETGENPlugin_Hypothesis::GetDefaultMaxSize()
307 //=============================================================================
311 //=============================================================================
312 NETGENPlugin_Hypothesis::Fineness NETGENPlugin_Hypothesis::GetDefaultFineness()
317 //=============================================================================
321 //=============================================================================
322 double NETGENPlugin_Hypothesis::GetDefaultGrowthRate()
327 //=============================================================================
331 //=============================================================================
332 double NETGENPlugin_Hypothesis::GetDefaultNbSegPerEdge()
337 //=============================================================================
341 //=============================================================================
342 double NETGENPlugin_Hypothesis::GetDefaultNbSegPerRadius()
347 //=============================================================================
351 //=============================================================================
352 bool NETGENPlugin_Hypothesis::GetDefaultSecondOrder()
357 //=============================================================================
361 //=============================================================================
362 bool NETGENPlugin_Hypothesis::GetDefaultOptimize()