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 // SMESH SMESH : idl implementation based on 'SMESH' unit's classes
23 // File : StdMeshers_NumberOfLayers.cxx
24 // Author : Edward AGAPOV
27 #include "StdMeshers_NumberOfLayers.hxx"
30 #include "SMESH_Mesh.hxx"
31 #include "utilities.h"
36 //=============================================================================
38 * StdMeshers_NumberOfLayers::StdMeshers_NumberOfLayers
42 //=============================================================================
44 StdMeshers_NumberOfLayers::StdMeshers_NumberOfLayers(int hypId, int studyId,
46 : SMESH_Hypothesis(hypId, studyId, gen)
48 _name = "NumberOfLayers"; // used by RadialPrism_3D
49 _param_algo_dim = 3; // 3D
53 //=============================================================================
55 * StdMeshers_NumberOfLayers::~StdMeshers_NumberOfLayers
59 //=============================================================================
61 StdMeshers_NumberOfLayers::~StdMeshers_NumberOfLayers()
63 MESSAGE( "StdMeshers_NumberOfLayers::~StdMeshers_NumberOfLayers" );
66 //=============================================================================
68 * StdMeshers_NumberOfLayers::SetNumberOfLayers
70 * Sets <number of segments> parameter value
72 //=============================================================================
74 void StdMeshers_NumberOfLayers::SetNumberOfLayers(int numberOfLayers)
75 throw ( SALOME_Exception )
77 if ( _nbLayers != numberOfLayers ) {
78 if ( numberOfLayers <= 0 )
79 throw SALOME_Exception(LOCALIZED("numberOfLayers must be positive"));
80 _nbLayers = numberOfLayers;
82 NotifySubMeshesHypothesisModification();
86 //=============================================================================
88 * StdMeshers_NumberOfLayers::GetNumberOfLayers
90 * Returns <number of layers> parameter value
92 //=============================================================================
94 int StdMeshers_NumberOfLayers::GetNumberOfLayers() const
99 //=============================================================================
103 //=============================================================================
105 ostream & StdMeshers_NumberOfLayers::SaveTo(ostream & save)
111 //=============================================================================
115 //=============================================================================
117 istream & StdMeshers_NumberOfLayers::LoadFrom(istream & load)
120 isOK = (load >> _nbLayers);
122 load.clear(ios::badbit | load.rdstate());
126 //=============================================================================
130 //=============================================================================
132 ostream & operator <<(ostream & save, StdMeshers_NumberOfLayers & hyp)
134 return hyp.SaveTo( save );
137 //=============================================================================
141 //=============================================================================
143 istream & operator >>(istream & load, StdMeshers_NumberOfLayers & hyp)
145 return hyp.LoadFrom( load );
148 //================================================================================
150 * \brief Initialize start and end length by the mesh built on the geometry
151 * \param theMesh - the built mesh
152 * \param theShape - the geometry of interest
153 * \retval bool - true if parameter values have been successfully defined
155 //================================================================================
157 bool StdMeshers_NumberOfLayers::SetParametersByMesh(const SMESH_Mesh* ,
158 const TopoDS_Shape& )
163 //================================================================================
165 * \brief Initialize my parameter values by default parameters.
166 * \retval bool - true if parameter values have been successfully defined
168 //================================================================================
170 bool StdMeshers_NumberOfLayers::SetParametersByDefaults(const TDefaults& dflts,
171 const SMESH_Mesh* theMesh)
173 if ( dflts._elemLength )
174 return bool( theMesh ? _nbLayers = int( theMesh->GetShapeDiagonalSize() / dflts._elemLength/ 2.) : 0);