From f4a735468905694f71f5e6a9f3b959fcc43bc9bd Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 10 Oct 2019 16:03:10 +0300 Subject: [PATCH] #17846 [CEA] SHA 90dbc5f1 and MG-Hybrid advanced parameters --- src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx | 4 +-- src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx | 17 ++++++------ src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx | 2 +- .../HYBRIDPlugin_Hypothesis_i.cxx | 26 ++++++++++++++----- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx index 6cc4efb..5b3fda6 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx @@ -1519,7 +1519,7 @@ bool HYBRIDPlugin_HYBRID::Compute(SMESH_Mesh& theMesh, // run hybrid mesher // ----------------- - std::string cmd = HYBRIDPlugin_Hypothesis::CommandToRun( _hyp, theMesh ); + std::string cmd = HYBRIDPlugin_Hypothesis::CommandToRun( _hyp ); if ( mgHybrid.IsExecutable() ) { @@ -1721,7 +1721,7 @@ bool HYBRIDPlugin_HYBRID::Compute(SMESH_Mesh& theMesh, // run hybrid mesher // ----------------- - std::string cmd = HYBRIDPlugin_Hypothesis::CommandToRun( _hyp, theMesh ); + std::string cmd = HYBRIDPlugin_Hypothesis::CommandToRun( _hyp ); if ( mgHybrid.IsExecutable() ) { diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx index 4ef1873..e704b23 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx @@ -1996,19 +1996,18 @@ bool HYBRIDPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, */ //================================================================================ -std::string HYBRIDPlugin_Hypothesis::CommandToRun(const HYBRIDPlugin_Hypothesis* hyp, - SMESH_Mesh& mesh) +std::string HYBRIDPlugin_Hypothesis::CommandToRun(const HYBRIDPlugin_Hypothesis* hyp) { SMESH_Comment cmd = GetExeName(); // check if any option is overridden by hyp->_option2value bool p_h = ( hyp && hyp->HasOptionDefined("-h")); bool p_v = ( hyp && hyp->HasOptionDefined("-v")); - bool p_blsd = ( hyp && hyp->HasOptionDefined("--normal_direction ")); - bool p_hotfl = ( hyp && hyp->HasOptionDefined("--boundary_layer_global_initial_height ")); - bool p_nobl = ( hyp && hyp->HasOptionDefined("--number_of_boundary_layers ")); - bool p_blgp = ( hyp && hyp->HasOptionDefined("--boundary_layer_geometric_progression ")); - bool p_eg = ( hyp && hyp->HasOptionDefined("--element_generation ")); - bool p_cs = ( hyp && hyp->HasOptionDefined("--global_physical_size ")); + bool p_blsd = ( hyp && hyp->HasOptionDefined("--normal_direction")); + bool p_hotfl = ( hyp && hyp->HasOptionDefined("--boundary_layer_global_initial_height")); + bool p_nobl = ( hyp && hyp->HasOptionDefined("--number_of_boundary_layers")); + bool p_blgp = ( hyp && hyp->HasOptionDefined("--boundary_layer_geometric_progression")); + bool p_eg = ( hyp && hyp->HasOptionDefined("--element_generation")); + bool p_cs = ( hyp && hyp->HasOptionDefined("--global_physical_size")); bool nolayers = false; bool layersOnAllWrap = hyp ? hyp->myLayersOnAllWrap : DefaultLayersOnAllWrap(); @@ -2193,7 +2192,7 @@ void HYBRIDPlugin_Hypothesis::SetOptionValue(const std::string& optionName, if (op_val == _option2value.end()) { op_val = _customOption2value.find( optionName ); - if ( op_val != _customOption2value.end() && op_val->second != optionValue ) + if ( op_val == _customOption2value.end() || op_val->second != optionValue ) NotifySubMeshesHypothesisModification(); _customOption2value[ optionName ] = optionValue; return; diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx index 93832c6..a7cf569 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx @@ -325,7 +325,7 @@ public: /*! * \brief Return command to run hybrid mesher excluding file prefix (-f) */ - static std::string CommandToRun(const HYBRIDPlugin_Hypothesis* hyp, SMESH_Mesh& mesh); + static std::string CommandToRun(const HYBRIDPlugin_Hypothesis* hyp); /*! * \brief Return a unique file name */ diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx index c1755cd..851bb46 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx @@ -544,6 +544,9 @@ void HYBRIDPlugin_Hypothesis_i::SetOptionValue(const char* optionName, const cha else if ( name == "boundary_layer_max_element_angle" ) SetBoundaryLayersMaxElemAngle( GetImpl()->ToDbl( optionValue )); + else if ( name == "boundary_layer_height_relative_to_local_surface_size" ) + SetHeightIsRelative( GetImpl()->ToBool( optionValue )); + else if ( name == "gradation" ) SetGradation( GetImpl()->ToDbl( optionValue )); @@ -755,7 +758,7 @@ void HYBRIDPlugin_Hypothesis_i::SetAdvancedOption(const char* optionsAndValues) { if ( !optionsAndValues ) return; - SMESH::TPythonDump dump; + //SMESH::TPythonDump dump; std::istringstream strm( optionsAndValues ); std::istream_iterator sIt( strm ), sEnd; @@ -775,19 +778,30 @@ void HYBRIDPlugin_Hypothesis_i::SetAdvancedOption(const char* optionsAndValues) AddOption( option.c_str(), "" ); } } - dump << _this() << ".SetAdvancedOption( '" << optionsAndValues << "' )"; + //dump << _this() << ".SetAdvancedOption( '" << optionsAndValues << "' )"; } //============================================================================= void HYBRIDPlugin_Hypothesis_i::AddOption(const char* optionName, const char* optionValue) { - ASSERT(myBaseImpl); + if ( strncmp( "--", optionName, 2 ) == 0 ) + optionName += 2; + bool valueChanged = ( !this->GetImpl()->HasOptionDefined(optionName) || this->GetImpl()->GetOptionValue(optionName) != optionValue ); - if (valueChanged) { - this->GetImpl()->SetOptionValue(optionName, optionValue); - SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )"; + if ( valueChanged ) + { + SetOptionValue(optionName, optionValue); + + SMESH_Comment optVal("--"); + optVal << optionName << " " << optionValue; + std::string cmd = ::HYBRIDPlugin_Hypothesis::CommandToRun( GetImpl() ); + if ( cmd.find( optVal ) == std::string::npos ) + { + this->GetImpl()->SetOptionValue(optionName, optionValue); + SMESH::TPythonDump() << _this() << ".AddOption( '" << optionName << "', '" << optionValue << "' )"; + } } } -- 2.39.2