1 // Copyright (C) 2007-2008 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
22 // NETGENPlugin : C++ implementation
23 // File : NETGENPlugin_Hypothesis.cxx
24 // Author : Michael Sazonov (OCN)
28 //=============================================================================
30 #include <NETGENPlugin_Hypothesis.hxx>
31 #include <utilities.h>
35 //=============================================================================
39 //=============================================================================
40 NETGENPlugin_Hypothesis::NETGENPlugin_Hypothesis (int hypId, int studyId,
42 : SMESH_Hypothesis(hypId, studyId, gen),
43 _maxSize (GetDefaultMaxSize()),
44 _growthRate (GetDefaultGrowthRate()),
45 _nbSegPerEdge (GetDefaultNbSegPerEdge()),
46 _nbSegPerRadius(GetDefaultNbSegPerRadius()),
47 _fineness (GetDefaultFineness()),
48 _secondOrder (GetDefaultSecondOrder()),
49 _optimize (GetDefaultOptimize())
51 _name = "NETGEN_Parameters";
55 //=============================================================================
59 //=============================================================================
60 void NETGENPlugin_Hypothesis::SetMaxSize(double theSize)
62 if (theSize != _maxSize)
65 NotifySubMeshesHypothesisModification();
69 //=============================================================================
73 //=============================================================================
74 void NETGENPlugin_Hypothesis::SetSecondOrder(bool theVal)
76 if (theVal != _secondOrder)
78 _secondOrder = theVal;
79 NotifySubMeshesHypothesisModification();
83 //=============================================================================
87 //=============================================================================
88 void NETGENPlugin_Hypothesis::SetOptimize(bool theVal)
90 if (theVal != _optimize)
93 NotifySubMeshesHypothesisModification();
97 //=============================================================================
101 //=============================================================================
102 void NETGENPlugin_Hypothesis::SetFineness(Fineness theFineness)
104 if (theFineness != _fineness)
106 _fineness = theFineness;
107 // the predefined values are taken from NETGEN 4.5 sources
118 _nbSegPerRadius = 1.5;
139 NotifySubMeshesHypothesisModification();
143 //=============================================================================
147 //=============================================================================
148 void NETGENPlugin_Hypothesis::SetGrowthRate(double theRate)
150 if (theRate != _growthRate)
152 _growthRate = theRate;
153 _fineness = UserDefined;
154 NotifySubMeshesHypothesisModification();
158 //=============================================================================
162 //=============================================================================
163 void NETGENPlugin_Hypothesis::SetNbSegPerEdge(double theVal)
165 if (theVal != _nbSegPerEdge)
167 _nbSegPerEdge = theVal;
168 _fineness = UserDefined;
169 NotifySubMeshesHypothesisModification();
173 //=============================================================================
177 //=============================================================================
178 void NETGENPlugin_Hypothesis::SetNbSegPerRadius(double theVal)
180 if (theVal != _nbSegPerRadius)
182 _nbSegPerRadius = theVal;
183 _fineness = UserDefined;
184 NotifySubMeshesHypothesisModification();
188 //=============================================================================
192 //=============================================================================
193 ostream & NETGENPlugin_Hypothesis::SaveTo(ostream & save)
195 save << _maxSize << " " << _fineness;
197 if (_fineness == UserDefined)
198 save << " " << _growthRate << " " << _nbSegPerEdge << " " << _nbSegPerRadius;
200 save << " " << (int)_secondOrder << " " << (int)_optimize;
205 //=============================================================================
209 //=============================================================================
210 istream & NETGENPlugin_Hypothesis::LoadFrom(istream & load)
216 isOK = (load >> val);
220 load.clear(ios::badbit | load.rdstate());
224 SetFineness((Fineness) is);
226 load.clear(ios::badbit | load.rdstate());
228 if (_fineness == UserDefined)
230 isOK = (load >> val);
234 load.clear(ios::badbit | load.rdstate());
236 isOK = (load >> val);
240 load.clear(ios::badbit | load.rdstate());
242 isOK = (load >> val);
244 _nbSegPerRadius = val;
246 load.clear(ios::badbit | load.rdstate());
251 _secondOrder = (bool) is;
253 load.clear(ios::badbit | load.rdstate());
257 _optimize = (bool) is;
259 load.clear(ios::badbit | load.rdstate());
263 //=============================================================================
267 //=============================================================================
268 ostream & operator <<(ostream & save, NETGENPlugin_Hypothesis & hyp)
270 return hyp.SaveTo( save );
273 //=============================================================================
277 //=============================================================================
278 istream & operator >>(istream & load, NETGENPlugin_Hypothesis & hyp)
280 return hyp.LoadFrom( load );
284 //================================================================================
286 * \brief Does nothing
287 * \param theMesh - the built mesh
288 * \param theShape - the geometry of interest
289 * \retval bool - always false
291 //================================================================================
292 bool NETGENPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh,
293 const TopoDS_Shape& theShape)
298 //=============================================================================
302 //=============================================================================
303 double NETGENPlugin_Hypothesis::GetDefaultMaxSize()
308 //=============================================================================
312 //=============================================================================
313 NETGENPlugin_Hypothesis::Fineness NETGENPlugin_Hypothesis::GetDefaultFineness()
318 //=============================================================================
322 //=============================================================================
323 double NETGENPlugin_Hypothesis::GetDefaultGrowthRate()
328 //=============================================================================
332 //=============================================================================
333 double NETGENPlugin_Hypothesis::GetDefaultNbSegPerEdge()
338 //=============================================================================
342 //=============================================================================
343 double NETGENPlugin_Hypothesis::GetDefaultNbSegPerRadius()
348 //=============================================================================
352 //=============================================================================
353 bool NETGENPlugin_Hypothesis::GetDefaultSecondOrder()
358 //=============================================================================
362 //=============================================================================
363 bool NETGENPlugin_Hypothesis::GetDefaultOptimize()