if ( !faceLayersIDs.empty() )
cmd << " --boundary_layer_surface_tags ";
for ( size_t i = 0; i < faceLayersIDs.size(); ++i )
- cmd << faceLayersIDs[i] << ",";
+ {
+ cmd << faceLayersIDs[i];
+ if (i<faceLayersIDs.size()-1)
+ cmd << ",";
+ }
// Don't need to set the height of the layer face by face since:
// - the same height is already set on all the faces with boundary_layer_global_initial_height
// - we don't allow the user to set different heights for specific faces for now
if ( !faceImprintingIDs.empty() )
cmd << " --boundary_layer_imprinting yes --boundary_layer_imprinting_tags ";
for ( size_t i = 0; i < faceImprintingIDs.size(); ++i )
- cmd << faceImprintingIDs[i] << ",";
+ {
+ cmd << faceImprintingIDs[i];
+ if (i<faceImprintingIDs.size()-1)
+ cmd << ",";
+ }
// faces with snapping
const std::vector<int>& faceSnappingIDs = hyp->GetFacesWithSnapping();
if ( !faceSnappingIDs.empty() )
cmd << " --boundary_layer_snapping yes --boundary_layer_snapping_tags ";
for ( size_t i = 0; i < faceSnappingIDs.size(); ++i )
- cmd << faceSnappingIDs[i] << ",";
+ {
+ cmd << faceSnappingIDs[i];
+ if (i<faceSnappingIDs.size()-1)
+ cmd << ",";
+ }
}
}
#include <SMESH_File.hxx>
#include <SMESH_MGLicenseKeyGen.hxx>
#include <Utils_SALOME_Exception.hxx>
+#include "utilities.h"
#include <cstring>
#include <iostream>
#include <iterator>
#include <vector>
+#include <sstream>
#ifdef USE_MG_LIBS
AddError( msg.c_str() );
}
+ //================================================================================
+ /*!
+ * \brief SetParam to define a parameter by its value
+ * \param [in] param - the parameter to set
+ * \param [in] valus - its value
+ * \return bool - Ok or not
+ */
+ //================================================================================
bool SetParam( const std::string& param, const std::string& value )
{
status_t ret = hybrid_set_param( _session, param.c_str(), value.c_str() );
return ( ret == STATUS_OK );
}
+
+ //================================================================================
+ /*!
+ * \brief SetTags to define boundary layers
+ * \param [in] param - the parameter to set
+ * \param [in] values - a list of ids separated by a comma
+ * \param [in] size - the size of the boundary layer
+ * \return bool - Ok or not
+ */
+ //================================================================================
+ bool SetTags( const std::string& param, const std::string& values, const std::string& size )
+ {
+ // constructing stream from the string
+ std::stringstream ss(values);
+ std::string s;
+ // for each string value separated by ',' call hybrid API to set the tag
+ while (getline(ss, s, ','))
+ {
+ status_t ret;
+ int tag = stoi(s);
+ if ( param=="boundary_layer_imprinting_tags" )
+ ret = hybrid_set_boundary_layer_imprinting_tag(_session, tag);
+ else if ( param=="boundary_layer_snapping_tags" )
+ ret = hybrid_set_boundary_layer_snapping_tag(_session, tag);
+ else if ( param=="boundary_layer_surface_tags" )
+ ret = hybrid_set_initial_height_on_surface_tag(_session, tag, stod(size));
+ if ( ret != STATUS_OK )
+ return false;
+ }
+ return true;
+ }
+
bool Cancelled()
{
return _cancelled_flag;
return nb;
}
+ int ReadNbPyramids()
+ {
+ integer nb = 0;
+ status_t ret = mesh_get_pyramid_count( _hybrid_mesh, & nb );
+
+ if ( ret != STATUS_OK ) MG_Error("mesh_get_pyramid_count problem");
+ return nb;
+ }
+
int ReadNbCorners()
{
return _corners.size();
// set parameters
std::string param, value;
- for ( size_t i = 1; i < args.size(); ++i )
+ std::string boundary_layer_size;
+
+ for ( size_t i = 1; i < args.size(); i=i+2 )
{
- // look for a param name; it starts from "-"
param = args[i];
- if ( param.size() < 2 || param[0] != '-')
+ value = args[i+1];
+ MESSAGE("param: " << param);
+ MESSAGE("value: " << value);
+
+ // skipping output redirection, it is not a param to set
+ if (param=="1>")
continue;
+
+ // removing -- from param
while ( param[0] == '-')
param = param.substr( 1 );
- value = "";
- while ( i+1 < args.size() && args[i+1][0] != '-' )
+ // store this value for boundary layer definition (needed by setTags after)
+ if (param == "boundary_layer_global_initial_height")
+ boundary_layer_size = value;
+
+ // set parameters with list of tags (string of ids separated by a comma)
+ if (param=="boundary_layer_imprinting_tags" || param=="boundary_layer_snapping_tags" || param=="boundary_layer_surface_tags")
{
- if ( strncmp( "1>", args[i+1].c_str(), 2 ) == 0 )
- break;
- if ( !value.empty() ) value += " ";
- value += args[++i];
+ if (!_libData->SetTags(param, value, boundary_layer_size))
+ std::cout << "Warning: error in SetTags(" << param << ", " << value << ", " << boundary_layer_size << ")" << std::endl;
}
- if ( !_libData->SetParam( param, value ))
+ // set other parameters
+ else if ( !_libData->SetParam( param, value ))
std::cout << "Warning: wrong param: '" << param <<"' = '" << value << "'" << std::endl;
}
case GmfQuadrilaterals: return _libData->ReadNbQuads();
case GmfTetrahedra: return _libData->ReadNbTetra();
case GmfPrisms: return _libData->ReadNbPrisms();
+ case GmfPyramids: return _libData->ReadNbPyramids();
case GmfHexahedra: return _libData->ReadNbHexa();
case GmfCorners: return _libData->ReadNbCorners();
default: return 0;