for ( opIt = opts.begin(); opIt != opts.end(); ++opIt )
if ( !opIt->second.empty() ) {
MESSAGE("cadsurf_set_param(): " << opIt->first << " = " << opIt->second);
- cadsurf_set_param(css, opIt->first.c_str(), opIt->second.c_str());
+ set_param(css, opIt->first.c_str(), opIt->second.c_str());
}
const BLSURFPlugin_Hypothesis::TOptionValues & preCADopts = hyp->GetPreCADOptionValues();
switch (_physicalMesh)
{
case BLSURFPlugin_Hypothesis::PhysicalGlobalSize:
- cadsurf_set_param(css, "physical_size_mode", "global");
- cadsurf_set_param(css, "global_physical_size", _phySizeRel ? to_string_rel(_phySize).c_str() : to_string(_phySize).c_str());
+ set_param(css, "physical_size_mode", "global");
+ set_param(css, "global_physical_size", _phySizeRel ? to_string_rel(_phySize).c_str() : to_string(_phySize).c_str());
break;
case BLSURFPlugin_Hypothesis::PhysicalLocalSize:
- cadsurf_set_param(css, "physical_size_mode", "local");
- cadsurf_set_param(css, "global_physical_size", _phySizeRel ? to_string_rel(_phySize).c_str() : to_string(_phySize).c_str());
+ set_param(css, "physical_size_mode", "local");
+ set_param(css, "global_physical_size", _phySizeRel ? to_string_rel(_phySize).c_str() : to_string(_phySize).c_str());
useGradation = true;
break;
default:
- cadsurf_set_param(css, "physical_size_mode", "none");
+ set_param(css, "physical_size_mode", "none");
}
switch (_geometricMesh)
{
case BLSURFPlugin_Hypothesis::GeometricalGlobalSize:
- cadsurf_set_param(css, "geometric_size_mode", "global");
- cadsurf_set_param(css, "geometric_approximation", to_string(_angleMesh).c_str());
- cadsurf_set_param(css, "chordal_error", to_string(_chordalError).c_str());
+ set_param(css, "geometric_size_mode", "global");
+ set_param(css, "geometric_approximation", to_string(_angleMesh).c_str());
+ set_param(css, "chordal_error", to_string(_chordalError).c_str());
useGradation = true;
break;
case BLSURFPlugin_Hypothesis::GeometricalLocalSize:
- cadsurf_set_param(css, "geometric_size_mode", "local");
- cadsurf_set_param(css, "geometric_approximation", to_string(_angleMesh).c_str());
- cadsurf_set_param(css, "chordal_error", to_string(_chordalError).c_str());
+ set_param(css, "geometric_size_mode", "local");
+ set_param(css, "geometric_approximation", to_string(_angleMesh).c_str());
+ set_param(css, "chordal_error", to_string(_chordalError).c_str());
useGradation = true;
break;
default:
- cadsurf_set_param(css, "geometric_size_mode", "none");
+ set_param(css, "geometric_size_mode", "none");
}
- cadsurf_set_param(css, "min_size", _minSizeRel ? to_string_rel(_minSize).c_str() : to_string(_minSize).c_str());
- cadsurf_set_param(css, "max_size", _maxSizeRel ? to_string_rel(_maxSize).c_str() : to_string(_maxSize).c_str());
+ set_param(css, "min_size", _minSizeRel ? to_string_rel(_minSize).c_str() : to_string(_minSize).c_str());
+ set_param(css, "max_size", _maxSizeRel ? to_string_rel(_maxSize).c_str() : to_string(_maxSize).c_str());
if ( useGradation )
- cadsurf_set_param(css, "gradation", to_string(_gradation).c_str());
- cadsurf_set_param(css, "element_generation", _quadAllowed ? "quad_dominant" : "triangle");
+ set_param(css, "gradation", to_string(_gradation).c_str());
+ set_param(css, "element_generation", _quadAllowed ? "quad_dominant" : "triangle");
- cadsurf_set_param(css, "metric", _anisotropic ? "anisotropic" : "isotropic");
+ set_param(css, "metric", _anisotropic ? "anisotropic" : "isotropic");
if ( _anisotropic )
- cadsurf_set_param(css, "anisotropic_ratio", to_string(_anisotropicRatio).c_str());
- cadsurf_set_param(css, "remove_tiny_edges", _removeTinyEdges ? "1" : "0");
+ set_param(css, "anisotropic_ratio", to_string(_anisotropicRatio).c_str());
+ set_param(css, "remove_tiny_edges", _removeTinyEdges ? "1" : "0");
if ( _removeTinyEdges )
- cadsurf_set_param(css, "tiny_edge_length", to_string(_tinyEdgeLength).c_str());
- cadsurf_set_param(css, "force_bad_surface_element_removal", _badElementRemoval ? "1" : "0");
+ set_param(css, "tiny_edge_length", to_string(_tinyEdgeLength).c_str());
+ set_param(css, "force_bad_surface_element_removal", _badElementRemoval ? "1" : "0");
if ( _badElementRemoval )
- cadsurf_set_param(css, "bad_surface_element_aspect_ratio", to_string(_badElementAspectRatio).c_str());
- cadsurf_set_param(css, "optimisation", _optimizeMesh ? "yes" : "no");
- cadsurf_set_param(css, "element_order", _quadraticMesh ? "quadratic" : "linear");
- cadsurf_set_param(css, "verbose", to_string(_verb).c_str());
+ set_param(css, "bad_surface_element_aspect_ratio", to_string(_badElementAspectRatio).c_str());
+ set_param(css, "optimisation", _optimizeMesh ? "yes" : "no");
+ set_param(css, "element_order", _quadraticMesh ? "quadratic" : "linear");
+ set_param(css, "verbose", to_string(_verb).c_str());
_smp_phy_size = _phySizeRel ? _phySize*diagonal : _phySize;
if ( _verb > 0 )
}
}
+//================================================================================
+/*!
+ * \brief Throws an exception if a parameter name is wrong
+ */
+//================================================================================
+
+void BLSURFPlugin_BLSURF::set_param(cadsurf_session_t *css,
+ const char * option_name,
+ const char * option_value)
+{
+ status_t status = cadsurf_set_param(css, option_name, option_value );
+ if ( status != MESHGEMS_STATUS_OK )
+ {
+ if ( status == MESHGEMS_STATUS_UNKNOWN_PARAMETER ) {
+ throw SALOME_Exception
+ ( SMESH_Comment("Invalid name of CADSURF parameter: ") << option_name );
+ }
+ else if ( status == MESHGEMS_STATUS_NOLICENSE )
+ throw SALOME_Exception
+ ( "No valid license available" );
+ else
+ throw SALOME_Exception
+ ( SMESH_Comment("Unacceptable value of CADSURF parameter '")
+ << option_name << "': " << option_value);
+ }
+}
+
namespace
{
// --------------------------------------------------------------------------