X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FNETGENPlugin%2FNETGENPlugin_Hypothesis.cxx;h=e33e401bb2bc06236c276098e1ee2d52f6db9358;hb=4280b9f4db542da7ba7deb00d9a2345291095bfd;hp=d5f43cd4230c52ea9b1bbb2695c7e391e50882cf;hpb=8e59f8e772dbdd8344da880cf460c42f450d99e7;p=plugins%2Fnetgenplugin.git diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis.cxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis.cxx index d5f43cd..e33e401 100644 --- a/src/NETGENPlugin/NETGENPlugin_Hypothesis.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis.cxx @@ -1,35 +1,40 @@ -// NETGENPlugin : C++ implementation +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2006 OPEN CASCADE, CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + +// NETGENPlugin : C++ implementation // File : NETGENPlugin_Hypothesis.cxx // Author : Michael Sazonov (OCN) // Date : 28/03/2006 // Project : SALOME -// $Header$ -//============================================================================= +// +#include "NETGENPlugin_Hypothesis.hxx" + +#include "NETGENPlugin_Mesher.hxx" +#include "SMESH_Mesh.hxx" -using namespace std; -#include #include +using namespace std; + //============================================================================= /*! * @@ -39,15 +44,19 @@ NETGENPlugin_Hypothesis::NETGENPlugin_Hypothesis (int hypId, int studyId, SMESH_Gen * gen) : SMESH_Hypothesis(hypId, studyId, gen), _maxSize (GetDefaultMaxSize()), + _minSize (0), _growthRate (GetDefaultGrowthRate()), _nbSegPerEdge (GetDefaultNbSegPerEdge()), _nbSegPerRadius(GetDefaultNbSegPerRadius()), _fineness (GetDefaultFineness()), _secondOrder (GetDefaultSecondOrder()), - _optimize (GetDefaultOptimize()) + _optimize (GetDefaultOptimize()), + _localSize (GetDefaultLocalSize()), + _quadAllowed (GetDefaultQuadAllowed()) { _name = "NETGEN_Parameters"; _param_algo_dim = 3; + _localSize.clear(); } //============================================================================= @@ -64,6 +73,20 @@ void NETGENPlugin_Hypothesis::SetMaxSize(double theSize) } } +//============================================================================= +/*! + * + */ +//============================================================================= +void NETGENPlugin_Hypothesis::SetMinSize(double theSize) +{ + if (theSize != _minSize) + { + _minSize = theSize; + NotifySubMeshesHypothesisModification(); + } +} + //============================================================================= /*! * @@ -183,6 +206,69 @@ void NETGENPlugin_Hypothesis::SetNbSegPerRadius(double theVal) } } +//============================================================================= +/*! + * + */ +//============================================================================= +void NETGENPlugin_Hypothesis::SetLocalSizeOnEntry(const std::string& entry, double localSize) +{ + if(_localSize[entry] != localSize) + { + _localSize[entry] = localSize; + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= +double NETGENPlugin_Hypothesis::GetLocalSizeOnEntry(const std::string& entry) +{ + TLocalSize::iterator it = _localSize.find( entry ); + if ( it != _localSize.end() ) + return it->second; + else + return -1.0; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void NETGENPlugin_Hypothesis::UnsetLocalSizeOnEntry(const std::string& entry) +{ + _localSize.erase(entry); + NotifySubMeshesHypothesisModification(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void NETGENPlugin_Hypothesis::SetQuadAllowed(bool theVal) +{ + if (theVal != _quadAllowed) + { + _quadAllowed = theVal; + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool NETGENPlugin_Hypothesis::GetDefaultQuadAllowed() +{ + return false; +} + //============================================================================= /*! * @@ -197,6 +283,18 @@ ostream & NETGENPlugin_Hypothesis::SaveTo(ostream & save) save << " " << (int)_secondOrder << " " << (int)_optimize; + TLocalSize::iterator it_sm = _localSize.begin(); + if (it_sm != _localSize.end()) { + save << " " << "__LOCALSIZE_BEGIN__"; + for ( ; it_sm != _localSize.end(); ++it_sm ) { + save << " " << it_sm->first + << " " << it_sm->second << "%#"; // "%#" is a mark of value end + } + save << " " << "__LOCALSIZE_END__"; + } + save << " " << _minSize; + save << " " << _quadAllowed; + return save; } @@ -255,6 +353,38 @@ istream & NETGENPlugin_Hypothesis::LoadFrom(istream & load) _optimize = (bool) is; else load.clear(ios::badbit | load.rdstate()); + + std::string option_or_sm; + bool hasLocalSize = false; + + isOK = (load >> option_or_sm); + if (isOK) + if (option_or_sm == "__LOCALSIZE_BEGIN__") + hasLocalSize = true; + + std::string smEntry, smValue; + while (isOK && hasLocalSize) { + isOK = (load >> smEntry); + if (isOK) { + if (smEntry == "__LOCALSIZE_END__") + break; + isOK = (load >> smValue); + } + if (isOK) { + std::istringstream tmp(smValue); + double val; + tmp >> val; + _localSize[ smEntry ] = val; + } + } + + if ( !hasLocalSize && !option_or_sm.empty() ) + _minSize = atof( option_or_sm.c_str() ); + + isOK = ( load >> _quadAllowed ); + if ( !isOK ) + _quadAllowed = GetDefaultQuadAllowed(); + return load; } @@ -288,11 +418,32 @@ istream & operator >>(istream & load, NETGENPlugin_Hypothesis & hyp) */ //================================================================================ bool NETGENPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, - const TopoDS_Shape& theShape) + const TopoDS_Shape& theShape) { return false; } +//================================================================================ +/*! + * \brief Initialize my parameter values by default parameters. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool NETGENPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, + const SMESH_Mesh* theMesh) +{ + _nbSegPerEdge = dflts._nbSegments; + _maxSize = dflts._elemLength; + + if ( dflts._shape && !dflts._shape->IsNull() ) + _minSize = NETGENPlugin_Mesher::GetDefaultMinSize( *dflts._shape, _maxSize ); + else if ( theMesh && theMesh->HasShapeToMesh() ) + _minSize = NETGENPlugin_Mesher::GetDefaultMinSize( theMesh->GetShapeToMesh(), _maxSize ); + + return _nbSegPerEdge && _maxSize > 0; +} + //============================================================================= /*! *