]> SALOME platform Git repositories - plugins/hexoticplugin.git/blobdiff - src/HexoticPlugin/HexoticPlugin_Hexotic.cxx
Salome HOME
Copyright update 2022
[plugins/hexoticplugin.git] / src / HexoticPlugin / HexoticPlugin_Hexotic.cxx
index 887e868203299c65f360a84dd792bb3c6152b98f..4c6ec601551f1b1eb749cba2a959241172d07a52 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2020  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
@@ -67,6 +67,7 @@
 #include <TopoDS_Vertex.hxx>
 #include <gp_Pnt.hxx>
 
+#include <Basics_DirUtils.hxx>
 #include <Basics_Utils.hxx>
 #include <GEOMImpl_Types.hxx>
 #include <GEOM_wrap.hxx>
@@ -81,7 +82,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");
   }
 }
@@ -349,9 +350,11 @@ static void writeInput(MG_Hexotic_API*     theHexaInput,
                        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();
@@ -367,7 +370,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 )
     {
@@ -383,7 +386,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 )
     {
@@ -787,7 +790,8 @@ HexoticPlugin_Hexotic::getHexoticCommand(const TCollection_AsciiString& Hexotic_
   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 sizeMap      = " --background_sizemap ";
+  TCollection_AsciiString sizeMapMesh  = " --background_mesh ";
   TCollection_AsciiString ignoreRidges = " --compute_ridges no ", invalideElements = " --allow_invalid_elements yes ";
   TCollection_AsciiString subdom       = " --components ";
 #ifndef WIN32
@@ -867,9 +871,10 @@ HexoticPlugin_Hexotic::getHexoticCommand(const TCollection_AsciiString& Hexotic_
 
   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 &&
@@ -905,7 +910,7 @@ TopoDS_Shape HexoticPlugin_Hexotic::entryToShape(std::string entry)
 {
   GEOM::GEOM_Object_var aGeomObj;
   TopoDS_Shape S = TopoDS_Shape();
-  SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->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);
@@ -951,6 +956,8 @@ std::vector<std::string> HexoticPlugin_Hexotic::writeSizeMapFile( MG_Hexotic_API
     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();
   
@@ -988,7 +995,7 @@ std::vector<std::string> 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;
@@ -1024,7 +1031,7 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh&          aMesh,
 
     SetParameters(_hypothesis);
 
-    TCollection_AsciiString aTmpDir = _hexoticWorkingDirectory.c_str();
+    TCollection_AsciiString aTmpDir = Kernel_Utils::GetTmpDirByPath(_hexoticWorkingDirectory).c_str();
     TCollection_AsciiString aQuote("");
 #ifdef WIN32
     aQuote = "\"";
@@ -1051,6 +1058,7 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh&          aMesh,
       {
         MESSAGE("Use output file from blsurf as input file from hexotic: " << Hexotic_In);
         mgHexa.SetUseExecutable();
+        mgHexa.SetInputFile( _blsurfHypo->GetGMFFile() );
         defaultInputFile = false;
       }
     }
@@ -1297,8 +1305,8 @@ bool HexoticPlugin_Hexotic::Evaluate(SMESH_Mesh&         aMesh,
                                      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));