X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHexoticPlugin%2FHexoticPlugin_Hexotic.cxx;h=37bd68508ee54dfe84380ce3c7ac8c422dafac55;hb=c5067112430e3066cb4cfb25778dfb459bf6656f;hp=44ab61dc17a3f48b7e1d0c5e125e8fd06c862375;hpb=4a2284e8f0ccd8f0a15d7956799e9bed531f53c7;p=plugins%2Fhexoticplugin.git diff --git a/src/HexoticPlugin/HexoticPlugin_Hexotic.cxx b/src/HexoticPlugin/HexoticPlugin_Hexotic.cxx index 44ab61d..37bd685 100644 --- a/src/HexoticPlugin/HexoticPlugin_Hexotic.cxx +++ b/src/HexoticPlugin/HexoticPlugin_Hexotic.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D +// Copyright (C) 2007-2021 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 @@ -28,9 +28,13 @@ #include "utilities.h" +#ifdef WIN32 +#include +#endif + #ifdef _DEBUG_ #define DUMP(txt) \ -// cout << txt +// std::cout << txt #else #define DUMP(txt) #endif @@ -43,6 +47,7 @@ #include #include #include +#include #include #include @@ -76,7 +81,7 @@ static void removeFile( const TCollection_AsciiString& fileName ) 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"); } } @@ -87,10 +92,9 @@ static void removeFile( const TCollection_AsciiString& fileName ) */ //============================================================================= -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; @@ -104,15 +108,6 @@ HexoticPlugin_Hexotic::HexoticPlugin_Hexotic(int hypId, int studyId, SMESH_Gen* #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()); } //============================================================================= @@ -123,7 +118,6 @@ HexoticPlugin_Hexotic::HexoticPlugin_Hexotic(int hypId, int studyId, SMESH_Gen* HexoticPlugin_Hexotic::~HexoticPlugin_Hexotic() { - MESSAGE("HexoticPlugin_Hexotic::~HexoticPlugin_Hexotic"); } @@ -131,7 +125,6 @@ HexoticPlugin_Hexotic::~HexoticPlugin_Hexotic() bool HexoticPlugin_Hexotic::CheckBLSURFHypothesis( SMESH_Mesh& aMesh, const TopoDS_Shape& aShape ) { - // MESSAGE("HexoticPlugin_Hexotic::CheckBLSURFHypothesis"); _blsurfHypo = NULL; std::list::const_iterator itl; @@ -139,7 +132,8 @@ bool HexoticPlugin_Hexotic::CheckBLSURFHypothesis( SMESH_Mesh& aMesh, // If a BLSURF hypothesis is applied, get it SMESH_HypoFilter blsurfFilter; - blsurfFilter.Init( blsurfFilter.HasName( BLSURFPlugin_Hypothesis::GetHypType() )); + blsurfFilter.Init( blsurfFilter.HasName( BLSURFPlugin_Hypothesis::GetHypType(true) )); + blsurfFilter.Or ( blsurfFilter.HasName( BLSURFPlugin_Hypothesis::GetHypType(false))); std::list appliedHyps; aMesh.GetHypotheses( aShape, blsurfFilter, appliedHyps, false ); @@ -147,7 +141,9 @@ bool HexoticPlugin_Hexotic::CheckBLSURFHypothesis( SMESH_Mesh& aMesh, itl = appliedHyps.begin(); theHyp = (*itl); // use only the first hypothesis std::string hypName = theHyp->GetName(); - if (hypName == BLSURFPlugin_Hypothesis::GetHypType()) { + if (hypName == BLSURFPlugin_Hypothesis::GetHypType(true) || + hypName == BLSURFPlugin_Hypothesis::GetHypType(false) ) + { _blsurfHypo = static_cast (theHyp); ASSERT(_blsurfHypo); return true; @@ -167,7 +163,6 @@ bool HexoticPlugin_Hexotic::CheckHypothesis( SMESH_Mesh& const TopoDS_Shape& aShape, SMESH_Hypothesis::Hypothesis_Status& aStatus ) { - // MESSAGE("HexoticPlugin_Hexotic::CheckHypothesis"); _hypothesis = NULL; std::list::const_iterator itl; @@ -176,6 +171,10 @@ bool HexoticPlugin_Hexotic::CheckHypothesis( SMESH_Mesh& const std::list& 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 } @@ -251,23 +250,12 @@ static int getNbShape(MG_Hexotic_API* hexaOutput, int iMesh, GmfKwdCod what, int 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; } @@ -316,10 +304,10 @@ void getShape(Mesh* mesh, Shape shape, Tab *t_Shape) //======================================================================= 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; } @@ -328,7 +316,8 @@ static void printWarning(const int nbExpected, std::string aString, const int nb //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 ); } @@ -362,7 +351,8 @@ static void writeInput(MG_Hexotic_API* theHexaInput, int meshID = theHexaInput->GmfOpenMesh( theFile, GmfWrite, GMFVERSION, GMFDIMENSION); // 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(); @@ -378,7 +368,7 @@ static void writeInput(MG_Hexotic_API* theHexaInput, 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 ) { @@ -394,7 +384,7 @@ static void writeInput(MG_Hexotic_API* theHexaInput, 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 ) { @@ -434,28 +424,24 @@ static bool readResult(MG_Hexotic_API* theHexaOutput, std::string token; int shapeID, hexoticShapeID; const int IdShapeRef = 2; - int *tabID = 0; + std::vector< int > tabID; double epsilon = Precision::Confusion(); std::map 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; iShapeToIndex( tabShape[0] ); } else { - tabID = new int[1]; - tabID[0] = 1; + tabID.resize( 1, 1 ); } SMDS_ElemIteratorPtr eIt = theMeshDS->elementsIterator(); @@ -470,16 +456,18 @@ static bool readResult(MG_Hexotic_API* theHexaOutput, 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 ) @@ -620,7 +608,7 @@ static bool readResult(MG_Hexotic_API* theHexaOutput, } } } - cout << std::endl; + std::cout << std::endl; // remove nodes in holes if ( nbDomains > 1 ) @@ -632,9 +620,20 @@ static bool readResult(MG_Hexotic_API* theHexaOutput, 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; } @@ -644,14 +643,14 @@ static bool readResult(MG_Hexotic_API* theHexaOutput, */ //============================================================================= -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(); @@ -668,15 +667,19 @@ void HexoticPlugin_Hexotic::SetParameters(const HexoticPlugin_Hypothesis* hyp) { _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(); @@ -693,6 +696,9 @@ void HexoticPlugin_Hexotic::SetParameters(const HexoticPlugin_Hypothesis* hyp) { _growth = hyp->GetDefaultGrowth(); _facesWithLayers = hyp->GetDefaultFacesWithLayers(); _imprintedFaces = hyp->GetDefaultImprintedFaces(); + _keepFiles = hyp->GetDefaultKeepFiles(); + _removeLogOnSuccess = hyp->GetDefaultRemoveLogOnSuccess(); + _logInStandardOutput = hyp->GetDefaultStandardOutputLog(); } } @@ -730,79 +736,80 @@ static TCollection_AsciiString getSuffix() */ //================================================================================ -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 = " --read_sizemap "; 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 ) @@ -820,14 +827,14 @@ std::string HexoticPlugin_Hexotic::getHexoticCommand(const TCollection_AsciiStri 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]; @@ -897,19 +904,16 @@ std::string HexoticPlugin_Hexotic::getHexoticCommand(const TCollection_AsciiStri // way to share it TopoDS_Shape HexoticPlugin_Hexotic::entryToShape(std::string entry) { - MESSAGE("HexoticPlugin_Hexotic::entryToShape "<_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; } @@ -918,11 +922,12 @@ TopoDS_Shape HexoticPlugin_Hexotic::entryToShape(std::string entry) * \brief Produces a .mesh file with the size maps informations to give to Hexotic */ //================================================================================ + std::vector HexoticPlugin_Hexotic::writeSizeMapFile( MG_Hexotic_API* mgInput, std::string sizeMapPrefix ) { HexoticPlugin_Hypothesis::THexoticSizeMaps::iterator it; - + std::vector points; // Iterate on the size maps for (it=_sizeMaps.begin(); it!=_sizeMaps.end(); it++) @@ -984,7 +989,7 @@ std::vector HexoticPlugin_Hexotic::writeSizeMapFile( MG_Hexotic_API //============================================================================= bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape) + const TopoDS_Shape& /*aShape*/) { _computeCanceled = false; bool Ok = true; @@ -1040,11 +1045,12 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh& aMesh, 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(); defaultInputFile = false; } @@ -1056,8 +1062,8 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh& aMesh, 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 @@ -1073,10 +1079,10 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh& aMesh, 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() ) { @@ -1099,7 +1105,7 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh& aMesh, // read a result // -------------- - if ( mgHexa.IsExecutable() ) + if ( mgHexa.IsExecutable() && SMESH_File( Hexotic_Out.ToCString() ).exists() ) { #ifndef WIN32 modeFile_Out += Hexotic_Out; @@ -1113,38 +1119,48 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh& aMesh, &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 = writeSizeMapFile( &mgHexa, Hexotic_SizeMap_Prefix.ToCString() ); @@ -1204,14 +1215,14 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHel 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() ) { @@ -1225,8 +1236,8 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHel 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 @@ -1235,7 +1246,7 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHel // read a result // -------------- - if ( mgHexa.IsExecutable() ) + if ( mgHexa.IsExecutable() && SMESH_File( Hexotic_Out.ToCString() ).exists() ) { modeFile_Out += Hexotic_Out; system( modeFile_Out.ToCString() ); @@ -1252,7 +1263,7 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHel { 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 ) @@ -1261,8 +1272,8 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHel 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")); @@ -1287,8 +1298,8 @@ bool HexoticPlugin_Hexotic::Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, MapShapeNbElems& aResMap) { - std::vector aResVec(SMDSEntity_Last); - for(int i=SMDSEntity_Node; i aResVec(SMDSEntity_Last); + for(smIdType i=SMDSEntity_Node; i