Back to index

salome-smesh  6.5.0
StdMeshers_NumberOfLayers.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SMESH SMESH : idl implementation based on 'SMESH' unit's classes
00024 //  File   : StdMeshers_NumberOfLayers.cxx
00025 //  Author : Edward AGAPOV
00026 //  Module : SMESH
00027 //
00028 #include "StdMeshers_NumberOfLayers.hxx"
00029 
00030 
00031 #include "SMESH_Mesh.hxx"
00032 #include "utilities.h"
00033 
00034 using namespace std;
00035 
00036 
00037 //=============================================================================
00043 //=============================================================================
00044 
00045 StdMeshers_NumberOfLayers::StdMeshers_NumberOfLayers(int hypId, int studyId,
00046                                                      SMESH_Gen * gen)
00047   : SMESH_Hypothesis(hypId, studyId, gen)
00048 {
00049   _name = "NumberOfLayers"; // used by RadialPrism_3D
00050   _param_algo_dim = 3; // 3D
00051   _nbLayers = 1;
00052 }
00053 
00054 //=============================================================================
00060 //=============================================================================
00061 
00062 StdMeshers_NumberOfLayers::~StdMeshers_NumberOfLayers()
00063 {
00064   MESSAGE( "StdMeshers_NumberOfLayers::~StdMeshers_NumberOfLayers" );
00065 }
00066 
00067 //=============================================================================
00073 //=============================================================================
00074 
00075 void StdMeshers_NumberOfLayers::SetNumberOfLayers(int numberOfLayers)
00076   throw ( SALOME_Exception )
00077 {
00078   if ( _nbLayers != numberOfLayers ) {
00079     if ( numberOfLayers <= 0 )
00080       throw SALOME_Exception(LOCALIZED("numberOfLayers must be positive"));
00081     _nbLayers = numberOfLayers;
00082 
00083     NotifySubMeshesHypothesisModification();
00084   }
00085 }
00086 
00087 //=============================================================================
00093 //=============================================================================
00094 
00095 int StdMeshers_NumberOfLayers::GetNumberOfLayers() const
00096 {
00097   return _nbLayers;
00098 }
00099 
00100 //=============================================================================
00104 //=============================================================================
00105 
00106 ostream & StdMeshers_NumberOfLayers::SaveTo(ostream & save)
00107 {
00108   save << _nbLayers;
00109   return save;
00110 }
00111 
00112 //=============================================================================
00116 //=============================================================================
00117 
00118 istream & StdMeshers_NumberOfLayers::LoadFrom(istream & load)
00119 {
00120   bool isOK = true;
00121   isOK = (load >> _nbLayers);
00122   if (!isOK)
00123     load.clear(ios::badbit | load.rdstate());
00124   return load;
00125 }
00126 
00127 //=============================================================================
00131 //=============================================================================
00132 
00133 ostream & operator <<(ostream & save, StdMeshers_NumberOfLayers & hyp)
00134 {
00135   return hyp.SaveTo( save );
00136 }
00137 
00138 //=============================================================================
00142 //=============================================================================
00143 
00144 istream & operator >>(istream & load, StdMeshers_NumberOfLayers & hyp)
00145 {
00146   return hyp.LoadFrom( load );
00147 }
00148 
00149 //================================================================================
00156 //================================================================================
00157 
00158 bool StdMeshers_NumberOfLayers::SetParametersByMesh(const SMESH_Mesh*   ,
00159                                                     const TopoDS_Shape& )
00160 {
00161   return false;
00162 }
00163 
00164 //================================================================================
00169 //================================================================================
00170 
00171 bool StdMeshers_NumberOfLayers::SetParametersByDefaults(const TDefaults&  dflts,
00172                                                         const SMESH_Mesh* theMesh)
00173 {
00174   if ( dflts._elemLength )
00175     return theMesh ? (_nbLayers = int( theMesh->GetShapeDiagonalSize() / dflts._elemLength/ 2.)) : 0;
00176   return false;
00177 }
00178