-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2022 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
#ifdef _DEBUG_
#define DUMP(txt) \
-// cout << txt
+// std::cout << txt
#else
#define DUMP(txt)
#endif
#include <SMESH_HypoFilter.hxx>
#include <SMESH_MesherHelper.hxx>
#include <SMESH_subMesh.hxx>
+#include <SMESH_MeshEditor.hxx>
#include <SMESH_ControlPnt.hxx>
#include <list>
#include <TopoDS_Vertex.hxx>
#include <gp_Pnt.hxx>
+#include <Basics_DirUtils.hxx>
#include <Basics_Utils.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_wrap.hxx>
try {
OSD_File( fileName ).Remove();
}
- catch ( Standard_ProgramError ) {
+ catch ( Standard_ProgramError& ) {
MESSAGE("Can't remove file: " << fileName.ToCString() << " ; file does not exist or permission denied");
}
}
*/
//=============================================================================
-HexoticPlugin_Hexotic::HexoticPlugin_Hexotic(int hypId, int studyId, SMESH_Gen* gen)
- : SMESH_3D_Algo(hypId, studyId, gen)
+HexoticPlugin_Hexotic::HexoticPlugin_Hexotic(int hypId, SMESH_Gen* gen)
+ : SMESH_3D_Algo(hypId, gen)
{
- MESSAGE("HexoticPlugin_Hexotic::HexoticPlugin_Hexotic");
_name = "MG-Hexa";
_shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type
_onlyUnaryInput = false;
#endif
_computeCanceled = false;
- // Copy of what is done in BLSURFPLugin TODO : share the code
- smeshGen_i = SMESH_Gen_i::GetSMESHGen();
- CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager");
- SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject);
-
- myStudy = NULL;
- myStudy = aStudyMgr->GetStudyByID(_studyId);
- if ( !myStudy->_is_nil() )
- MESSAGE("myStudy->StudyId() = " << myStudy->StudyId());
}
//=============================================================================
HexoticPlugin_Hexotic::~HexoticPlugin_Hexotic()
{
- MESSAGE("HexoticPlugin_Hexotic::~HexoticPlugin_Hexotic");
}
bool HexoticPlugin_Hexotic::CheckBLSURFHypothesis( SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape )
{
- // MESSAGE("HexoticPlugin_Hexotic::CheckBLSURFHypothesis");
_blsurfHypo = NULL;
std::list<const SMESHDS_Hypothesis*>::const_iterator itl;
const TopoDS_Shape& aShape,
SMESH_Hypothesis::Hypothesis_Status& aStatus )
{
- // MESSAGE("HexoticPlugin_Hexotic::CheckHypothesis");
_hypothesis = NULL;
std::list<const SMESHDS_Hypothesis*>::const_iterator itl;
const std::list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape, false);
int nbHyp = hyps.size();
if (!nbHyp) {
+ // retrieve BLSURF hypothesis if no hexotic hypothesis has been set
+#ifdef WITH_BLSURFPLUGIN
+ CheckBLSURFHypothesis(aMesh, aShape);
+#endif
aStatus = SMESH_Hypothesis::HYP_OK;
return true; // can work with no hypothesis
}
int number = hexaOutput->GmfStatKwd( iMesh, what );
if ( number > 0 )
{
- // std::string aLine;
- // std::ifstream file(aFile.c_str());
- // while ( !file.eof() ) {
- // getline( file, aLine);
- // if ( aLine == aString ) {
- // getline( file, aLine);
- // std::istringstream stringFlux( aLine );
- // stringFlux >> number;
- number = ( number + defaultValue + std::abs(number - defaultValue) ) / 2;
- // break;
- // }
+ number = ( number + defaultValue + std::abs(number - defaultValue) ) / 2;
}
else
{
number = defaultValue;
}
- //file.close();
return number;
}
//=======================================================================
static void printWarning(const int nbExpected, std::string aString, const int nbFound) {
- cout << std::endl;
- cout << "WARNING : " << nbExpected << " " << aString << " expected, MG-Hexa has found " << nbFound << std::endl;
- cout << "=======" << std::endl;
- cout << std::endl;
+ std::cout << std::endl;
+ std::cout << "WARNING : " << nbExpected << " " << aString << " expected, MG-Hexa has found " << nbFound << std::endl;
+ std::cout << "=======" << std::endl;
+ std::cout << std::endl;
return;
}
//purpose :
//=======================================================================
-static void removeHexoticFiles(TCollection_AsciiString file_In, TCollection_AsciiString file_Out) {
+static void removeHexoticFiles(TCollection_AsciiString file_In, TCollection_AsciiString file_Out)
+{
removeFile( file_In );
removeFile( file_Out );
}
const SMESHDS_Mesh* theMeshDS)
{
int meshID = theHexaInput->GmfOpenMesh( theFile, GmfWrite, GMFVERSION, GMFDIMENSION);
-
+ theHexaInput->SetIsInputMesh( true ); // it's a mesh file
+
// nodes
- int iN = 0, nbNodes = theMeshDS->NbNodes();
+ int iN = 0;
+ smIdType nbNodes = theMeshDS->NbNodes();
theHexaInput->GmfSetKwd( meshID, GmfVertices, nbNodes );
std::map< const SMDS_MeshNode*, int, TIDCompare > node2IdMap;
SMDS_NodeIteratorPtr nodeIt = theMeshDS->nodesIterator();
SMDS_ElemIteratorPtr elemIt = theMeshDS->elementsIterator( SMDSAbs_Edge );
if ( elemIt->more() )
{
- int nbEdges = theMeshDS->GetMeshInfo().NbElements( SMDSAbs_Edge );
+ smIdType nbEdges = theMeshDS->GetMeshInfo().NbElements( SMDSAbs_Edge );
theHexaInput->GmfSetKwd(meshID, GmfEdges, nbEdges );
for ( int gmfID = 1; elemIt->more(); ++gmfID )
{
elemIt = theMeshDS->elementGeomIterator( SMDSGeom_TRIANGLE );
if ( elemIt->more() )
{
- int nbTria = theMeshDS->GetMeshInfo().NbElements( SMDSGeom_TRIANGLE );
+ smIdType nbTria = theMeshDS->GetMeshInfo().NbElements( SMDSGeom_TRIANGLE );
theHexaInput->GmfSetKwd(meshID, GmfTriangles, nbTria );
for ( int gmfID = 1; elemIt->more(); ++gmfID )
{
std::string token;
int shapeID, hexoticShapeID;
const int IdShapeRef = 2;
- int *tabID = 0;
+ std::vector< int > tabID;
double epsilon = Precision::Confusion();
std::map <std::string,int> mapField;
- SMDS_MeshNode** HexoticNode;
- TopoDS_Shape *tabCorner;
+ std::vector< SMDS_MeshNode*> HexoticNode;
+ std::vector< TopoDS_Shape > tabCorner;
const int nbDomains = countShape( theMesh, TopAbs_SHELL );
const int holeID = -1;
if ( nbDomains > 0 )
{
- tabID = new int[nbDomains];
-
- for (int i=0; i<nbDomains; i++)
- tabID[i] = 0;
+ tabID.resize( nbDomains, 0 );
if ( nbDomains == 1 )
tabID[0] = theMeshDS->ShapeToIndex( tabShape[0] );
}
else
{
- tabID = new int[1];
- tabID[0] = 1;
+ tabID.resize( 1, 1 );
}
SMDS_ElemIteratorPtr eIt = theMeshDS->elementsIterator();
int ver, dim;
int meshID = theHexaOutput->GmfOpenMesh( theFile, GmfRead, &ver, &dim );
+ int nbVerticesInShape = countShape( theMesh, TopAbs_VERTEX );
int nbVertices = getNbShape(theHexaOutput, meshID, GmfVertices );
- int nbCorners = getNbShape(theHexaOutput, meshID, GmfCorners, countShape( theMesh, TopAbs_VERTEX ));
+ int nbCorners = getNbShape(theHexaOutput, meshID, GmfCorners, nbVerticesInShape);
if ( nbVertices == 0 )
return false;
- tabCorner = new TopoDS_Shape[ nbCorners ];
- HexoticNode = new SMDS_MeshNode*[ nbVertices + 1 ];
+ tabCorner.resize( nbCorners );
+ HexoticNode.resize( nbVertices + 1 );
- if ( nbCorners > 0 )
- getShape(theMeshDS, TopAbs_VERTEX, tabCorner);
+ // get the shape vertices if the mesh lies on a shape (and this shape has corners)
+ if ( nbCorners > 0 && nbVerticesInShape > 0 )
+ getShape( theMeshDS, TopAbs_VERTEX, tabCorner.data() );
int nbNodes = theHexaOutput->GmfStatKwd( meshID, GmfVertices );
if ( nbNodes > 0 )
}
}
}
- cout << std::endl;
+ std::cout << std::endl;
// remove nodes in holes
if ( nbDomains > 1 )
theMeshDS->RemoveFreeNode( HexoticNode[i], subMesh, /*fromGroups=*/false );
}
}
- delete [] tabID;
- delete [] tabCorner;
- delete [] HexoticNode;
+
+ // avoid "Error: No mesh on sub-shape"
+ if ( theMesh->NbVolumes() > 0 )
+ {
+ SMESH_subMesh* smMain = theMesh->GetSubMesh( theMesh->GetShapeToMesh() );
+ SMESH_subMeshIteratorPtr smIt = smMain->getDependsOnIterator( /*includeSelf=*/true );
+ while ( smIt->more() )
+ {
+ SMESH_subMesh* sm = smIt->next();
+ if ( !sm->IsMeshComputed() )
+ sm->SetIsAlwaysComputed( true );
+ }
+ }
+
return true;
}
*/
//=============================================================================
-void HexoticPlugin_Hexotic::SetParameters(const HexoticPlugin_Hypothesis* hyp) {
-
- MESSAGE("HexoticPlugin_Hexotic::SetParameters");
+void HexoticPlugin_Hexotic::SetParameters(const HexoticPlugin_Hypothesis* hyp)
+{
if (hyp) {
_hexesMinLevel = hyp->GetHexesMinLevel();
_hexesMaxLevel = hyp->GetHexesMaxLevel();
_hexesMinSize = hyp->GetMinSize();
_hexesMaxSize = hyp->GetMaxSize();
+ _approxAngle = hyp->GetGeomApproxAngle();
_hexoticIgnoreRidges = hyp->GetHexoticIgnoreRidges();
_hexoticInvalidElements = hyp->GetHexoticInvalidElements();
_hexoticSharpAngleThreshold = hyp->GetHexoticSharpAngleThreshold();
_growth = hyp->GetGrowth();
_facesWithLayers = hyp->GetFacesWithLayers();
_imprintedFaces = hyp->GetImprintedFaces();
+ _keepFiles = hyp->GetKeepFiles();
+ _removeLogOnSuccess = hyp->GetRemoveLogOnSuccess();
+ _logInStandardOutput = hyp->GetStandardOutputLog();
}
else {
- cout << std::endl;
- cout << "WARNING : The MG-Hexa default parameters are taken into account" << std::endl;
- cout << "=======" << std::endl;
+ std::cout << std::endl;
+ std::cout << "WARNING : The MG-Hexa default parameters are taken into account" << std::endl;
+ std::cout << "=======" << std::endl;
_hexesMinLevel = hyp->GetDefaultHexesMinLevel();
_hexesMaxLevel = hyp->GetDefaultHexesMaxLevel();
_hexesMinSize = hyp->GetDefaultMinSize();
_hexesMaxSize = hyp->GetDefaultMaxSize();
+ _approxAngle = hyp->GetDefaultGeomApproxAngle();
_hexoticIgnoreRidges = hyp->GetDefaultHexoticIgnoreRidges();
_hexoticInvalidElements = hyp->GetDefaultHexoticInvalidElements();
_hexoticSharpAngleThreshold = hyp->GetDefaultHexoticSharpAngleThreshold();
_growth = hyp->GetDefaultGrowth();
_facesWithLayers = hyp->GetDefaultFacesWithLayers();
_imprintedFaces = hyp->GetDefaultImprintedFaces();
+ _keepFiles = hyp->GetDefaultKeepFiles();
+ _removeLogOnSuccess = hyp->GetDefaultRemoveLogOnSuccess();
+ _logInStandardOutput = hyp->GetDefaultStandardOutputLog();
}
}
*/
//================================================================================
-std::string HexoticPlugin_Hexotic::getHexoticCommand(const TCollection_AsciiString& Hexotic_In,
- const TCollection_AsciiString& Hexotic_Out,
- const TCollection_AsciiString& Hexotic_SizeMap_Prefix,
- const bool forExecutable) const
+std::string
+HexoticPlugin_Hexotic::getHexoticCommand(const TCollection_AsciiString& Hexotic_In,
+ const TCollection_AsciiString& Hexotic_Out,
+ const TCollection_AsciiString& Hexotic_SizeMap_Prefix,
+ const bool forExecutable) const
{
- cout << std::endl;
- cout << "MG-Hexa execution..." << std::endl;
- cout << _name << " parameters :" << std::endl;
- cout << " " << _name << " Verbosity = " << _hexoticVerbosity << std::endl;
- cout << " " << _name << " Max Memory = " << _hexoticMaxMemory << std::endl;
- cout << " " << _name << " Segments Min Level = " << _hexesMinLevel << std::endl;
- cout << " " << _name << " Segments Max Level = " << _hexesMaxLevel << std::endl;
- cout << " " << _name << " Segments Min Size = " << _hexesMinSize << std::endl;
- cout << " " << _name << " Segments Max Size = " << _hexesMaxSize << std::endl;
- cout << " " << "MG-Hexa can ignore ridges : " << (_hexoticIgnoreRidges ? "yes":"no") << std::endl;
- cout << " " << "MG-Hexa authorize invalide elements : " << ( _hexoticInvalidElements ? "yes":"no") << std::endl;
- cout << " " << _name << " Sharp angle threshold = " << _hexoticSharpAngleThreshold << " degrees" << std::endl;
- cout << " " << _name << " Number of threads = " << _hexoticNbProc << std::endl;
- cout << " " << _name << " Working directory = \"" << _hexoticWorkingDirectory << "\"" << std::endl;
- cout << " " << _name << " Sub. Dom mode = " << _hexoticSdMode << std::endl;
- cout << " " << _name << " Text options = \"" << _textOptions << "\"" << std::endl;
- cout << " " << _name << " Number of layers = " << _nbLayers << std::endl;
- cout << " " << _name << " Size of the first layer = " << _firstLayerSize << std::endl;
- cout << " " << _name << " Direction of the layers = " << ( _direction ? "Inward" : "Outward" ) << std::endl;
- cout << " " << _name << " Growth = " << _growth << std::endl;
+ std::cout << std::endl;
+ std::cout << "MG-Hexa execution..." << std::endl;
+ std::cout << _name << " parameters :" << std::endl;
+ std::cout << " " << _name << " Verbosity = " << _hexoticVerbosity << std::endl;
+ std::cout << " " << _name << " Max Memory = " << _hexoticMaxMemory << std::endl;
+ std::cout << " " << _name << " Segments Min Level = " << _hexesMinLevel << std::endl;
+ std::cout << " " << _name << " Segments Max Level = " << _hexesMaxLevel << std::endl;
+ std::cout << " " << _name << " Segments Min Size = " << _hexesMinSize << std::endl;
+ std::cout << " " << _name << " Segments Max Size = " << _hexesMaxSize << std::endl;
+ std::cout << " " << "MG-Hexa can ignore ridges : " << (_hexoticIgnoreRidges ? "yes":"no") << std::endl;
+ std::cout << " " << "MG-Hexa authorize invalide elements : " << ( _hexoticInvalidElements ? "yes":"no") << std::endl;
+ std::cout << " " << _name << " Sharp angle threshold = " << _hexoticSharpAngleThreshold << " degrees" << std::endl;
+ std::cout << " " << _name << " Number of threads = " << _hexoticNbProc << std::endl;
+ std::cout << " " << _name << " Working directory = \"" << _hexoticWorkingDirectory << "\"" << std::endl;
+ std::cout << " " << _name << " Sub. Dom mode = " << _hexoticSdMode << std::endl;
+ std::cout << " " << _name << " Text options = \"" << _textOptions << "\"" << std::endl;
+ std::cout << " " << _name << " Number of layers = " << _nbLayers << std::endl;
+ std::cout << " " << _name << " Size of the first layer = " << _firstLayerSize << std::endl;
+ std::cout << " " << _name << " Direction of the layers = " << ( _direction ? "Inward" : "Outward" ) << std::endl;
+ std::cout << " " << _name << " Growth = " << _growth << std::endl;
if (!_facesWithLayers.empty()) {
- cout << " " << _name << " Faces with layers = ";
+ std::cout << " " << _name << " Faces with layers = ";
for (size_t i = 0; i < _facesWithLayers.size(); i++)
{
- cout << _facesWithLayers.at(i);
+ std::cout << _facesWithLayers.at(i);
if ((i + 1) != _facesWithLayers.size())
- cout << ", ";
+ std::cout << ", ";
}
- cout << std::endl;
+ std::cout << std::endl;
}
if (!_imprintedFaces.empty()) {
- cout << " " << _name << " Imprinted faces = ";
+ std::cout << " " << _name << " Imprinted faces = ";
for (size_t i = 0; i < _imprintedFaces.size(); i++)
{
- cout << _imprintedFaces.at(i);
+ std::cout << _imprintedFaces.at(i);
if ((i + 1) != _imprintedFaces.size())
- cout << ", ";
+ std::cout << ", ";
}
- cout << std::endl;
+ std::cout << std::endl;
}
TCollection_AsciiString run_Hexotic("mg-hexa.exe");
- TCollection_AsciiString minl = " --min_level ", maxl = " --max_level ", angle = " --ridge_angle ";
- TCollection_AsciiString mins = " --min_size ", maxs = " --max_size ";
- TCollection_AsciiString in = " --in ", out = " --out ";
- TCollection_AsciiString sizeMap = " --read_sizemap ";
+ TCollection_AsciiString minl = " --min_level ", maxl = " --max_level ", angle = " --ridge_angle ";
+ TCollection_AsciiString mins = " --min_size ", maxs = " --max_size ";
+ TCollection_AsciiString in = " --in ", out = " --out ";
+ TCollection_AsciiString sizeMap = " --background_sizemap ";
+ TCollection_AsciiString sizeMapMesh = " --background_mesh ";
TCollection_AsciiString ignoreRidges = " --compute_ridges no ", invalideElements = " --allow_invalid_elements yes ";
- TCollection_AsciiString subdom = " --components ";
+ TCollection_AsciiString subdom = " --components ";
#ifndef WIN32
- TCollection_AsciiString proc = " --max_number_of_threads ";
+ TCollection_AsciiString proc = " --max_number_of_threads ";
#endif
- TCollection_AsciiString verb = " --verbose ";
- TCollection_AsciiString maxmem = " --max_memory ";
+ TCollection_AsciiString verb = " --verbose ";
+ TCollection_AsciiString maxmem = " --max_memory ";
- TCollection_AsciiString comNbLayers = " --number_of_boundary_layers ";
- TCollection_AsciiString comFirstLayerSize = " --height_of_the_first_layer ";
- TCollection_AsciiString comDirection = " --boundary_layers_subdomain_direction ";
- TCollection_AsciiString comGrowth = " --boundary_layers_geometric_progression ";
+ TCollection_AsciiString comNbLayers = " --number_of_boundary_layers ";
+ TCollection_AsciiString comFirstLayerSize = " --height_of_the_first_layer ";
+ TCollection_AsciiString comDirection = " --boundary_layers_subdomain_direction ";
+ TCollection_AsciiString comGrowth = " --boundary_layers_geometric_progression ";
TCollection_AsciiString comFacesWithLayers = " --boundary_layers_surface_ids ";
- TCollection_AsciiString comImptintedFaces = " --imprinted_surface_ids ";
+ TCollection_AsciiString comImptintedFaces = " --imprinted_surface_ids ";
TCollection_AsciiString minLevel, maxLevel, minSize, maxSize, sharpAngle, mode, nbproc, verbosity, maxMemory,
textOptions, nbLayers, firstLayerSize, direction, growth, facesWithLayers, imprintedFaces;
- minLevel = _hexesMinLevel;
- maxLevel = _hexesMaxLevel;
- minSize = _hexesMinSize;
- maxSize = _hexesMaxSize;
+ minLevel = _hexesMinLevel;
+ maxLevel = _hexesMaxLevel;
+ minSize = _hexesMinSize;
+ maxSize = _hexesMaxSize;
sharpAngle = _hexoticSharpAngleThreshold;
// Mode translation for mg-tetra 1.1
switch ( _hexoticSdMode )
mode = "all --manifold_geometry no";
break;
}
- nbproc = _hexoticNbProc;
- verbosity = _hexoticVerbosity;
- maxMemory = _hexoticMaxMemory;
- textOptions = (" " + _textOptions + " ").c_str();
- nbLayers = _nbLayers;
+ nbproc = _hexoticNbProc;
+ verbosity = _hexoticVerbosity;
+ maxMemory = _hexoticMaxMemory;
+ textOptions = (" " + _textOptions + " ").c_str();
+ nbLayers = _nbLayers;
firstLayerSize = _firstLayerSize;
- direction = _direction ? "1" : "-1";
- growth = _growth;
+ direction = _direction ? "1" : "-1";
+ growth = _growth;
for (size_t i = 0; i < _facesWithLayers.size(); i++)
{
facesWithLayers += _facesWithLayers[i];
if (_hexoticSharpAngleThreshold > 0)
run_Hexotic += angle + sharpAngle;
-
- if (_sizeMaps.begin() != _sizeMaps.end() && forExecutable )
- run_Hexotic += sizeMap + Hexotic_SizeMap_Prefix;
+
+ if ( !_sizeMaps.empty() && forExecutable )
+ run_Hexotic += ( sizeMap + Hexotic_SizeMap_Prefix + ".sol " +
+ sizeMapMesh + Hexotic_SizeMap_Prefix + ".mesh " );
if (_nbLayers > 0 &&
_firstLayerSize > 0 &&
// way to share it
TopoDS_Shape HexoticPlugin_Hexotic::entryToShape(std::string entry)
{
- MESSAGE("HexoticPlugin_Hexotic::entryToShape "<<entry );
- if ( myStudy->_is_nil() )
- throw SALOME_Exception("MG-Hexa plugin can't work w/o publishing in the study");
GEOM::GEOM_Object_var aGeomObj;
TopoDS_Shape S = TopoDS_Shape();
- SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
+ SALOMEDS::SObject_var aSObj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( entry.c_str() );
if (!aSObj->_is_nil()) {
CORBA::Object_var obj = aSObj->GetObject();
aGeomObj = GEOM::GEOM_Object::_narrow(obj);
aSObj->UnRegister();
}
if ( !aGeomObj->_is_nil() )
- S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
+ S = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aGeomObj.in() );
return S;
}
* \brief Produces a .mesh file with the size maps informations to give to Hexotic
*/
//================================================================================
+
std::vector<std::string> HexoticPlugin_Hexotic::writeSizeMapFile( MG_Hexotic_API* mgInput,
std::string sizeMapPrefix )
{
HexoticPlugin_Hypothesis::THexoticSizeMaps::iterator it;
-
+
std::vector<ControlPnt> points;
// Iterate on the size maps
for (it=_sizeMaps.begin(); it!=_sizeMaps.end(); it++)
mgInput->GmfOpenMesh( myVerticesFile.c_str(), GmfWrite, GMFVERSION, GMFDIMENSION );
int solFileID =
mgInput->GmfOpenMesh( mySolFile.c_str(), GmfWrite, GMFVERSION, GMFDIMENSION );
+
+ mgInput->SetIsInputMesh( false ); // they are not mesh files
int pointsNumber = points.size();
//=============================================================================
bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh& aMesh,
- const TopoDS_Shape& aShape)
+ const TopoDS_Shape& /*aShape*/)
{
_computeCanceled = false;
bool Ok = true;
SetParameters(_hypothesis);
- TCollection_AsciiString aTmpDir = _hexoticWorkingDirectory.c_str();
+ TCollection_AsciiString aTmpDir = Kernel_Utils::GetTmpDirByPath(_hexoticWorkingDirectory).c_str();
TCollection_AsciiString aQuote("");
#ifdef WIN32
aQuote = "\"";
Hexotic_Out = aTmpDir + "Hexotic"+getSuffix()+"_Out.mesh";
#ifdef WITH_BLSURFPLUGIN
bool defaultInputFile = true;
- if (_blsurfHypo && !_blsurfHypo->GetQuadAllowed()) {
+ if (_blsurfHypo && _blsurfHypo->GetElementType() == BLSURFPlugin_Hypothesis::Triangles ) {
Hexotic_In = _blsurfHypo->GetGMFFile().c_str();
if ( !Hexotic_In.IsEmpty() &&
SMESH_File( _blsurfHypo->GetGMFFile() ).exists() )
{
+ MESSAGE("Use output file from blsurf as input file from hexotic: " << Hexotic_In);
mgHexa.SetUseExecutable();
+ mgHexa.SetInputFile( _blsurfHypo->GetGMFFile() );
defaultInputFile = false;
}
}
splitQuads(aMesh); // quadrangles are no longer acceptable as input
if ( mgHexa.IsExecutable() )
{
- cout << std::endl;
- cout << "Creating MG-Hexa input mesh file : " << Hexotic_In << std::endl;
+ std::cout << std::endl;
+ std::cout << "Creating MG-Hexa input mesh file : " << Hexotic_In << std::endl;
}
writeInput( &mgHexa, Hexotic_In.ToCString(), meshDS );
#ifdef WITH_BLSURFPLUGIN
std::string run_Hexotic = getHexoticCommand(aQuote + Hexotic_In + aQuote, aQuote + Hexotic_Out + aQuote, Hexotic_SizeMap_Prefix, mgHexa.IsExecutable() );
run_Hexotic += std::string(" 1> ") + aQuote.ToCString() + aLogFileName.ToCString() + aQuote.ToCString(); // dump into file
mgHexa.SetLogFile( aLogFileName.ToCString() );
- cout << "Creating MG-Hexa log file : " << aLogFileName << std::endl;
+ std::cout << "Creating MG-Hexa log file : " << aLogFileName << std::endl;
- cout << std::endl;
- cout << "MG-Hexa command : " << run_Hexotic << std::endl;
+ std::cout << std::endl;
+ std::cout << "MG-Hexa command : " << run_Hexotic << std::endl;
if ( mgHexa.IsExecutable() )
{
// read a result
// --------------
- if ( mgHexa.IsExecutable() )
+ if ( mgHexa.IsExecutable() && SMESH_File( Hexotic_Out.ToCString() ).exists() )
{
#ifndef WIN32
modeFile_Out += Hexotic_Out;
&aHelper, _nbShape, tabShape, tabBox );
std::string log = mgHexa.GetLog();
+ hexahedraMessage = "failed";
if ( Ok )
{
hexahedraMessage = "success";
-#ifndef _DEBUG_
- removeFile(Hexotic_Out);
- removeFile(Hexotic_In);
- //removeFile(aLogFileName);
- for( size_t i=0; i<sizeMapFiles.size(); i++)
- {
- removeFile( TCollection_AsciiString( sizeMapFiles[i].c_str() ) );
- }
-#endif
+ if ( _removeLogOnSuccess )
+ removeFile( aLogFileName );
}
- else
+ else if ( !log.empty() )
{
- hexahedraMessage = "failed";
- if ( mgHexa.IsExecutable() )
- cout << "Problem with MG-Hexa output file " << Hexotic_Out.ToCString() << std::endl;
- // analyse log file
- if ( !log.empty() )
+ if( _computeCanceled )
+ error( "interruption initiated by user" );
+ else
{
+ // get problem description from the log file
char msgLic[] = " Dlim ";
- std::string log = mgHexa.GetLog();
const char* fileBeg = &log[0], *fileEnd = fileBeg + log.size();
if ( std::search( fileBeg, fileEnd, msgLic, msgLic+strlen(msgLic)) != fileEnd )
error("Licence problems.");
}
- if ( !errStr.empty() )
- error(errStr);
}
- cout << "Hexahedra meshing " << hexahedraMessage << std::endl;
- cout << std::endl;
+ else if ( !errStr.empty() )
+ {
+ // the log file is empty
+ removeFile( aLogFileName );
+ INFOS( "MG-Hexa Error, " << errStr);
+ error(COMPERR_ALGO_FAILED, errStr);
+ }
+
+ if ( !Ok && mgHexa.IsExecutable() )
+ std::cout << "Problem with MG-Hexa output file " << Hexotic_Out.ToCString() << std::endl;
+
+ if ( !_keepFiles )
+ {
+ if (! Ok && _computeCanceled )
+ removeFile( aLogFileName );
+ removeFile(Hexotic_Out);
+ removeFile(Hexotic_In);
+ for ( size_t i = 0; i < sizeMapFiles.size(); i++ )
+ removeFile( sizeMapFiles[i].c_str() );
+ }
+ std::cout << "Hexahedra meshing " << hexahedraMessage << std::endl;
+ std::cout << std::endl;
delete [] tabShape;
for (int i=0; i<_nbShape; i++)
_iShape = 0;
}
- if(_computeCanceled)
- return error(SMESH_Comment("interruption initiated by user"));
-
return Ok;
}
bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelper)
{
_computeCanceled = false;
-/*
- SMESH_ComputeErrorPtr myError = SMESH_ComputeError::New();
-*/
+
bool Ok = true;
TCollection_AsciiString hexahedraMessage;
TCollection_AsciiString aQuote("");
#ifdef WIN32
- aQuote = "\"";
+ aQuote = "\"";
#endif
SetParameters(_hypothesis);
Hexotic_In = aTmpDir + "Hexotic"+getSuffix()+"_In.mesh";
Hexotic_Out = aTmpDir + "Hexotic"+getSuffix()+"_Out.mesh";
Hexotic_SizeMap_Prefix = aTmpDir + "Hexotic_SizeMap";
-
+
MG_Hexotic_API mgHexa( _computeCanceled, _progress );
std::vector<std::string> sizeMapFiles = writeSizeMapFile( &mgHexa, Hexotic_SizeMap_Prefix.ToCString() );
std::string run_Hexotic = getHexoticCommand(aQuote + Hexotic_In + aQuote, aQuote + Hexotic_Out + aQuote, Hexotic_SizeMap_Prefix, mgHexa.IsExecutable());
run_Hexotic += std::string(" 1> ") + aQuote.ToCString() + aLogFileName.ToCString() + aQuote.ToCString(); // dump into file
mgHexa.SetLogFile( aLogFileName.ToCString() );
- cout << "Creating MG-Hexa log file : " << aLogFileName << std::endl;
+ std::cout << "Creating MG-Hexa log file : " << aLogFileName << std::endl;
removeHexoticFiles(Hexotic_In, Hexotic_Out);
splitQuads(aMesh); // quadrangles are no longer acceptable as input
- cout << std::endl;
- cout << "Creating MG-Hexa input mesh file : " << Hexotic_In << std::endl;
+ std::cout << std::endl;
+ std::cout << "Creating MG-Hexa input mesh file : " << Hexotic_In << std::endl;
writeInput( &mgHexa, Hexotic_In.ToCString(), aHelper->GetMeshDS() );
if ( mgHexa.IsExecutable() )
{
MESSAGE("HexoticPlugin_Hexotic::Compute");
- cout << std::endl;
- cout << "MG-Hexa command : " << run_Hexotic << std::endl;
+ std::cout << std::endl;
+ std::cout << "MG-Hexa command : " << run_Hexotic << std::endl;
std::string errStr;
Ok = mgHexa.Compute( run_Hexotic, errStr ); // run
// read a result
// --------------
- if ( mgHexa.IsExecutable() )
+ if ( mgHexa.IsExecutable() && SMESH_File( Hexotic_Out.ToCString() ).exists() )
{
modeFile_Out += Hexotic_Out;
system( modeFile_Out.ToCString() );
{
hexahedraMessage = "failed";
if ( mgHexa.IsExecutable() )
- cout << "Problem with MG-Hexa output file " << Hexotic_Out << std::endl;
+ std::cout << "Problem with MG-Hexa output file " << Hexotic_Out << std::endl;
if ( log.find( " license " ) != std::string::npos ||
log.find( " Dlim " ) != std::string::npos )
if ( !errStr.empty() )
error(errStr);
}
- cout << "Hexahedra meshing " << hexahedraMessage << std::endl;
- cout << std::endl;
+ std::cout << "Hexahedra meshing " << hexahedraMessage << std::endl;
+ std::cout << std::endl;
if(_computeCanceled)
return error(SMESH_Comment("interruption initiated by user"));
const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap)
{
- std::vector<int> aResVec(SMDSEntity_Last);
- for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aResVec[i] = 0;
+ std::vector<smIdType> aResVec(SMDSEntity_Last);
+ for(smIdType i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aResVec[i] = 0;
SMESH_subMesh * sm = aMesh.GetSubMesh(aShape);
aResMap.insert(std::make_pair(sm,aResVec));