+//=============================================================================
+//! Return option value. If isDefault provided, it can be a default value,
+// then *isDefault == true. If isDefault is not provided, the value will be
+// empty if it equals a default one.
+std::string HexoticPlugin_Hypothesis::GetOptionValue(const std::string& optionName,
+ bool* isDefault) const
+{
+ TOptionValues::const_iterator op_val = _option2value.find(optionName);
+ if (op_val == _option2value.end())
+ {
+ op_val = _customOption2value.find(optionName);
+ if (op_val == _customOption2value.end())
+ {
+ std::string msg = "Unknown MG-Tetra option: <" + optionName + ">";
+ throw std::invalid_argument(msg);
+ }
+ }
+ std::string val = op_val->second;
+ if ( isDefault ) *isDefault = ( val.empty() );
+
+ if ( val.empty() && isDefault )
+ {
+ op_val = _defaultOptionValues.find( optionName );
+ if (op_val != _defaultOptionValues.end())
+ val = op_val->second;
+ }
+ return val;
+}
+
+
+//=============================================================================
+bool HexoticPlugin_Hypothesis::HasOptionDefined( const std::string& optionName ) const
+{
+ bool isDefault = false;
+ try
+ {
+ GetOptionValue( optionName, &isDefault );
+ }
+ catch ( std::invalid_argument& )
+ {
+ return false;
+ }
+ return !isDefault;
+}
+
+//=============================================================================
+void HexoticPlugin_Hypothesis::ClearOption(const std::string& optionName)
+{
+ TOptionValues::iterator op_val = _customOption2value.find(optionName);
+ if (op_val != _customOption2value.end())
+ _customOption2value.erase(op_val);
+ else {
+ op_val = _option2value.find(optionName);
+ if (op_val != _option2value.end())
+ op_val->second.clear();
+ }
+}
+
+//=============================================================================
+HexoticPlugin_Hypothesis::TOptionValues HexoticPlugin_Hypothesis::GetOptionValues() const
+{
+ TOptionValues vals;
+ TOptionValues::const_iterator op_val = _option2value.begin();
+ for ( ; op_val != _option2value.end(); ++op_val )
+ vals.insert( make_pair( op_val->first, GetOptionValue( op_val->first, GET_DEFAULT() )));
+
+ return vals;
+}
+
+//================================================================================
+/*!
+ * \brief Converts a string to a bool
+ */
+//================================================================================
+
+bool HexoticPlugin_Hypothesis::ToBool(const std::string& str, bool* isOk )
+{
+ std::string s = str;
+ if ( isOk ) *isOk = true;
+
+ for ( size_t i = 0; i <= s.size(); ++i )
+ s[i] = tolower( s[i] );
+
+ if ( s == "1" || s == "true" || s == "active" || s == "yes" )
+ return true;
+
+ if ( s == "0" || s == "false" || s == "inactive" || s == "no" )
+ return false;
+
+ if ( isOk )
+ *isOk = false;
+ else {
+ std::string msg = "Not a Boolean value:'" + str + "'";
+ throw std::invalid_argument(msg);
+ }
+ return false;
+}
+
+//================================================================================
+/*!
+ * \brief Converts a string to a real value
+ */
+//================================================================================
+
+double HexoticPlugin_Hypothesis::ToDbl(const std::string& str, bool* isOk )
+{
+ if ( str.empty() ) throw std::invalid_argument("Empty value provided");
+
+ char * endPtr;
+ double val = strtod(&str[0], &endPtr);
+ bool ok = (&str[0] != endPtr);
+
+ if ( isOk ) *isOk = ok;
+
+ if ( !ok )
+ {
+ std::string msg = "Not a real value:'" + str + "'";
+ throw std::invalid_argument(msg);
+ }
+ return val;
+}
+
+//================================================================================
+/*!
+ * \brief Converts a string to a integer value
+ */
+//================================================================================
+
+int HexoticPlugin_Hypothesis::ToInt(const std::string& str, bool* isOk )
+{
+ if ( str.empty() ) throw std::invalid_argument("Empty value provided");
+
+ char * endPtr;
+ int val = (int)strtol( &str[0], &endPtr, 10);
+ bool ok = (&str[0] != endPtr);
+
+ if ( isOk ) *isOk = ok;
+
+ if ( !ok )
+ {
+ std::string msg = "Not an integer value:'" + str + "'";
+ throw std::invalid_argument(msg);
+ }
+ return val;
+}
+
+void HexoticPlugin_Hypothesis::SetAdvancedOption(const std::string& option)
+{
+ size_t wsPos = option.find(' ');
+ if ( wsPos == std::string::npos )
+ {
+ SetOptionValue( option, "" );
+ }
+ else
+ {
+ std::string opt( option, 0, wsPos );
+ std::string val( option, wsPos + 1 );
+ SetOptionValue( opt, val );
+ }
+}
+
+//=======================================================================
+//function : GetAdvancedOption
+//purpose : Return only options having NO corresponding member fields
+//=======================================================================
+
+std::string HexoticPlugin_Hypothesis::GetAdvancedOption( bool customOnly ) const
+{
+ // options having corresponding member fields
+ static std::set< std::string > toSkip = {
+ "min_level",
+ "max_level",
+ "compute_ridges",
+ "allow_invalid_elements",
+ "ridge_angle",
+ "max_number_of_threads",
+ "max_memory"
+ };
+
+ // Return only options having NO corresponding member fields
+
+ SMESH_Comment txt;
+
+ TOptionValues::const_iterator o2v = _option2value.begin();
+ if ( !customOnly )
+ {
+ for ( ; o2v != _option2value.end(); ++o2v )
+ if ( !o2v->second.empty() && !toSkip.count( o2v->first ))
+ {
+ if ( !txt.empty() )
+ txt << " ";
+ txt << "--" << o2v->first << " " << o2v->second;
+ }
+ }
+ for ( o2v = _customOption2value.begin(); o2v != _customOption2value.end(); ++o2v )
+ {
+ if ( !txt.empty() )
+ txt << " ";
+ // if ( o2v->first[0] != '-' )
+ // txt << "--";
+ txt << o2v->first << " " << o2v->second;
+ }
+ return txt;
+}
+
+bool HexoticPlugin_Hypothesis::AddSizeMap(std::string theEntry, double theSize)
+{