1 // Copyright (C) 2007-2021 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, or (at your option) any later version.
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,
47 : SMESH_Hypothesis(hypId, 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()
66 //=============================================================================
68 * StdMeshers_NumberOfLayers::SetNumberOfLayers
70 * Sets <number of segments> parameter value
72 //=============================================================================
74 void StdMeshers_NumberOfLayers::SetNumberOfLayers(int numberOfLayers)
76 if ( _nbLayers != numberOfLayers ) {
77 if ( numberOfLayers <= 0 )
78 throw SALOME_Exception(LOCALIZED("numberOfLayers must be more than zero"));
79 _nbLayers = numberOfLayers;
81 NotifySubMeshesHypothesisModification();
85 //=============================================================================
87 * StdMeshers_NumberOfLayers::GetNumberOfLayers
89 * Returns <number of layers> parameter value
91 //=============================================================================
93 int StdMeshers_NumberOfLayers::GetNumberOfLayers() const
98 //=============================================================================
102 //=============================================================================
104 ostream & StdMeshers_NumberOfLayers::SaveTo(ostream & save)
110 //=============================================================================
114 //=============================================================================
116 istream & StdMeshers_NumberOfLayers::LoadFrom(istream & load)
119 isOK = static_cast<bool>(load >> _nbLayers);
121 load.clear(ios::badbit | load.rdstate());
125 //=============================================================================
129 //=============================================================================
131 ostream & operator <<(ostream & save, StdMeshers_NumberOfLayers & hyp)
133 return hyp.SaveTo( save );
136 //=============================================================================
140 //=============================================================================
142 istream & operator >>(istream & load, StdMeshers_NumberOfLayers & hyp)
144 return hyp.LoadFrom( load );
147 //================================================================================
149 * \brief Initialize start and end length by the mesh built on the geometry
150 * \param theMesh - the built mesh
151 * \param theShape - the geometry of interest
152 * \retval bool - true if parameter values have been successfully defined
154 //================================================================================
156 bool StdMeshers_NumberOfLayers::SetParametersByMesh(const SMESH_Mesh* ,
157 const TopoDS_Shape& )
162 //================================================================================
164 * \brief Initialize my parameter values by default parameters.
165 * \retval bool - true if parameter values have been successfully defined
167 //================================================================================
169 bool StdMeshers_NumberOfLayers::SetParametersByDefaults(const TDefaults& dflts,
170 const SMESH_Mesh* theMesh)
172 if ( dflts._elemLength )
173 return theMesh ? (_nbLayers = int( theMesh->GetShapeDiagonalSize() / dflts._elemLength/ 2.)) : 0;