1 // Copyright (C) 2007-2012 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
23 // SMESH SMESH : idl implementation based on 'SMESH' unit's classes
24 // File : StdMeshers_NumberOfLayers.cxx
25 // Author : Edward AGAPOV
28 #include "StdMeshers_NumberOfLayers.hxx"
31 #include "SMESH_Mesh.hxx"
32 #include "utilities.h"
37 //=============================================================================
39 * StdMeshers_NumberOfLayers::StdMeshers_NumberOfLayers
43 //=============================================================================
45 StdMeshers_NumberOfLayers::StdMeshers_NumberOfLayers(int hypId, int studyId,
47 : SMESH_Hypothesis(hypId, studyId, gen)
49 _name = "NumberOfLayers"; // used by RadialPrism_3D
50 _param_algo_dim = 3; // 3D
54 //=============================================================================
56 * StdMeshers_NumberOfLayers::~StdMeshers_NumberOfLayers
60 //=============================================================================
62 StdMeshers_NumberOfLayers::~StdMeshers_NumberOfLayers()
64 MESSAGE( "StdMeshers_NumberOfLayers::~StdMeshers_NumberOfLayers" );
67 //=============================================================================
69 * StdMeshers_NumberOfLayers::SetNumberOfLayers
71 * Sets <number of segments> parameter value
73 //=============================================================================
75 void StdMeshers_NumberOfLayers::SetNumberOfLayers(int numberOfLayers)
76 throw ( SALOME_Exception )
78 if ( _nbLayers != numberOfLayers ) {
79 if ( numberOfLayers <= 0 )
80 throw SALOME_Exception(LOCALIZED("numberOfLayers must be positive"));
81 _nbLayers = numberOfLayers;
83 NotifySubMeshesHypothesisModification();
87 //=============================================================================
89 * StdMeshers_NumberOfLayers::GetNumberOfLayers
91 * Returns <number of layers> parameter value
93 //=============================================================================
95 int StdMeshers_NumberOfLayers::GetNumberOfLayers() const
100 //=============================================================================
104 //=============================================================================
106 ostream & StdMeshers_NumberOfLayers::SaveTo(ostream & save)
112 //=============================================================================
116 //=============================================================================
118 istream & StdMeshers_NumberOfLayers::LoadFrom(istream & load)
121 isOK = (load >> _nbLayers);
123 load.clear(ios::badbit | load.rdstate());
127 //=============================================================================
131 //=============================================================================
133 ostream & operator <<(ostream & save, StdMeshers_NumberOfLayers & hyp)
135 return hyp.SaveTo( save );
138 //=============================================================================
142 //=============================================================================
144 istream & operator >>(istream & load, StdMeshers_NumberOfLayers & hyp)
146 return hyp.LoadFrom( load );
149 //================================================================================
151 * \brief Initialize start and end length by the mesh built on the geometry
152 * \param theMesh - the built mesh
153 * \param theShape - the geometry of interest
154 * \retval bool - true if parameter values have been successfully defined
156 //================================================================================
158 bool StdMeshers_NumberOfLayers::SetParametersByMesh(const SMESH_Mesh* ,
159 const TopoDS_Shape& )
164 //================================================================================
166 * \brief Initialize my parameter values by default parameters.
167 * \retval bool - true if parameter values have been successfully defined
169 //================================================================================
171 bool StdMeshers_NumberOfLayers::SetParametersByDefaults(const TDefaults& dflts,
172 const SMESH_Mesh* theMesh)
174 if ( dflts._elemLength )
175 return theMesh ? (_nbLayers = int( theMesh->GetShapeDiagonalSize() / dflts._elemLength/ 2.)) : 0;