Salome HOME
bos #20256: [CEA 18523] Porting SMESH to int 64 bits
[plugins/hexoticplugin.git] / src / HexoticPlugin / HexoticPlugin_Hexotic.cxx
index 8af68a4dede882731728113808f7bb9098e6cdeb..37bd68508ee54dfe84380ce3c7ac8c422dafac55 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2020  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
@@ -81,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");
   }
 }
@@ -351,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();
@@ -367,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 )
     {
@@ -383,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 )
     {
@@ -455,15 +456,17 @@ 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.resize( nbCorners );
   HexoticNode.resize( nbVertices + 1 );
 
-  if ( nbCorners > 0 )
+  // 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 );
@@ -903,7 +906,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);
@@ -986,7 +989,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;
@@ -1295,8 +1298,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));