Skip to content

Commit

Permalink
Make smesh compile with vtk9
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed May 9, 2021
1 parent 20e7563 commit 0cfea3f
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 57 deletions.
9 changes: 7 additions & 2 deletions src/3rdParty/salomesmesh/inc/SMDS_MeshElement.hxx
Expand Up @@ -40,11 +40,16 @@

#include <vtkType.h>
#include <vtkCellType.h>
#include <vtkCellArray.h>

//typedef unsigned short UShortType;
typedef short ShortType;
typedef int LongType;

#ifdef VTK_CELL_ARRAY_V2
typedef const vtkIdType* vtkIdTypePtr;
#else
typedef vtkIdType* vtkIdTypePtr;
#endif
class SMDS_MeshNode;
class SMDS_MeshEdge;
class SMDS_MeshFace;
Expand Down Expand Up @@ -192,7 +197,7 @@ protected:
//! Element index in vector SMDS_Mesh::myNodes or SMDS_Mesh::myCells
int myID;
//! index in vtkUnstructuredGrid
int myVtkID;
vtkIdType myVtkID;
//! SMDS_Mesh identification in SMESH
ShortType myMeshId;
//! SubShape and SubMesh identification in SMESHDS
Expand Down
4 changes: 4 additions & 0 deletions src/3rdParty/salomesmesh/inc/SMDS_UnstructuredGrid.hxx
Expand Up @@ -95,7 +95,11 @@ public:
std::map<int, std::map<long,int> >& nodeQuadDomains);
vtkCellLinks* GetLinks()
{
#ifdef VTK_CELL_ARRAY_V2
return static_cast<vtkCellLinks*>(GetCellLinks());
#else
return Links;
#endif
}
SMDS_Downward* getDownArray(unsigned char vtkType)
{
Expand Down
9 changes: 8 additions & 1 deletion src/3rdParty/salomesmesh/src/SMDS/SMDS_BallElement.cpp
Expand Up @@ -67,10 +67,16 @@ void SMDS_BallElement::SetDiameter(double diameter)
bool SMDS_BallElement::ChangeNode (const SMDS_MeshNode * node)
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
#ifdef VTK_CELL_ARRAY_V2
vtkNew<vtkIdList> cellPoints;
grid->GetCellPoints(myVtkID, cellPoints.GetPointer());
cellPoints->SetId(0, node->getVtkId());
#else
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
pts[0] = node->getVtkId();
#endif
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return true;
}
Expand All @@ -83,7 +89,8 @@ void SMDS_BallElement::Print (std::ostream & OS) const
const SMDS_MeshNode* SMDS_BallElement::GetNode (const int ind) const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType npts, *pts;
vtkIdType npts;
vtkIdTypePtr pts;
grid->GetCellPoints( myVtkID, npts, pts );
return SMDS_Mesh::_meshList[myMeshId]->FindNodeVtk( pts[ 0 ]);
}
Expand Down
44 changes: 22 additions & 22 deletions src/3rdParty/salomesmesh/src/SMDS/SMDS_Downward.cpp
Expand Up @@ -303,7 +303,7 @@ int SMDS_Down1D::getNodeSet(int cellId, int* nodeSet)
void SMDS_Down1D::setNodes(int cellId, int vtkId)
{
vtkIdType npts = 0;
vtkIdType *pts; // will refer to the point id's of the face
vtkIdTypePtr pts; // will refer to the point id's of the face
_grid->GetCellPoints(vtkId, npts, pts);
// MESSAGE(vtkId << " " << npts << " " << _nbDownCells);
//ASSERT(npts == _nbDownCells);
Expand Down Expand Up @@ -357,7 +357,7 @@ int SMDS_Down1D::computeVtkCells(int *pts, std::vector<int>& vtkIds)
{
vtkIdType point = pts[i];
int numCells = _grid->GetLinks()->GetNcells(point);
vtkIdType *cells = _grid->GetLinks()->GetCells(point);
vtkIdTypePtr cells = _grid->GetLinks()->GetCells(point);
for (int j = 0; j < numCells; j++)
{
int vtkCellId = cells[j];
Expand Down Expand Up @@ -532,7 +532,7 @@ int SMDS_Down2D::computeVolumeIds(int cellId, int* ids)
// --- find point id's of the face

vtkIdType npts = 0;
vtkIdType *pts; // will refer to the point id's of the face
vtkIdTypePtr pts; // will refer to the point id's of the face
_grid->GetCellPoints(cellId, npts, pts);
vector<int> nodes;
for (int i = 0; i < npts; i++)
Expand Down Expand Up @@ -577,7 +577,7 @@ int SMDS_Down2D::computeVolumeIdsFromNodesFace(int* pts, int npts, int* ids)
vtkIdType point = pts[i];
int numCells = _grid->GetLinks()->GetNcells(point);
//MESSAGE("cells pour " << i << " " << numCells);
vtkIdType *cells = _grid->GetLinks()->GetCells(point);
vtkIdTypePtr cells = _grid->GetLinks()->GetCells(point);
for (int j = 0; j < numCells; j++)
{
int vtkCellId = cells[j];
Expand Down Expand Up @@ -627,7 +627,7 @@ int SMDS_Down2D::computeVolumeIdsFromNodesFace(int* pts, int npts, int* ids)
void SMDS_Down2D::setTempNodes(int cellId, int vtkId)
{
vtkIdType npts = 0;
vtkIdType *pts; // will refer to the point id's of the face
vtkIdTypePtr pts; // will refer to the point id's of the face
_grid->GetCellPoints(vtkId, npts, pts);
// MESSAGE(vtkId << " " << npts << " " << _nbNodes);
//ASSERT(npts == _nbNodes);
Expand Down Expand Up @@ -795,7 +795,7 @@ void SMDS_Down3D::getNodeIds(int cellId, std::set<int>& nodeSet)
{
int vtkId = this->_vtkCellIds[cellId];
vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(vtkId, npts, nodes);
for (int i = 0; i < npts; i++)
nodeSet.insert(nodes[i]);
Expand Down Expand Up @@ -1126,7 +1126,7 @@ void SMDS_DownTetra::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& o
//MESSAGE("cellId = " << cellId);

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(this->_vtkCellIds[cellId], npts, nodes);

set<int> tofind;
Expand Down Expand Up @@ -1178,7 +1178,7 @@ void SMDS_DownTetra::computeFacesWithNodes(int cellId, ListElemByNodesType& face
// --- find point id's of the volume

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(cellId, npts, nodes);

// --- create all the ordered list of node id's for each face
Expand Down Expand Up @@ -1234,7 +1234,7 @@ void SMDS_DownQuadTetra::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType
//MESSAGE("cellId = " << cellId);

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(this->_vtkCellIds[cellId], npts, nodes);

set<int> tofind;
Expand Down Expand Up @@ -1288,7 +1288,7 @@ void SMDS_DownQuadTetra::computeFacesWithNodes(int cellId, ListElemByNodesType&
// --- find point id's of the volume

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(cellId, npts, nodes);

// --- create all the ordered list of node id's for each face
Expand Down Expand Up @@ -1357,7 +1357,7 @@ void SMDS_DownPyramid::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>&
//MESSAGE("cellId = " << cellId);

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(this->_vtkCellIds[cellId], npts, nodes);

set<int> tofind;
Expand Down Expand Up @@ -1435,7 +1435,7 @@ void SMDS_DownPyramid::computeFacesWithNodes(int cellId, ListElemByNodesType& fa
// --- find point id's of the volume

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(cellId, npts, nodes);

// --- create all the ordered list of node id's for each face
Expand Down Expand Up @@ -1500,7 +1500,7 @@ void SMDS_DownQuadPyramid::getOrderedNodesOfFace(int cellId, std::vector<vtkIdTy
//MESSAGE("cellId = " << cellId);

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(this->_vtkCellIds[cellId], npts, nodes);

set<int> tofind;
Expand Down Expand Up @@ -1580,7 +1580,7 @@ void SMDS_DownQuadPyramid::computeFacesWithNodes(int cellId, ListElemByNodesType
// --- find point id's of the volume

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(cellId, npts, nodes);

// --- create all the ordered list of node id's for each face
Expand Down Expand Up @@ -1660,7 +1660,7 @@ void SMDS_DownPenta::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& o
//MESSAGE("cellId = " << cellId);

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(this->_vtkCellIds[cellId], npts, nodes);

set<int> tofind;
Expand Down Expand Up @@ -1744,7 +1744,7 @@ void SMDS_DownPenta::computeFacesWithNodes(int cellId, ListElemByNodesType& face
// --- find point id's of the volume

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(cellId, npts, nodes);

// --- create all the ordered list of node id's for each face
Expand Down Expand Up @@ -1810,7 +1810,7 @@ void SMDS_DownQuadPenta::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType
//MESSAGE("cellId = " << cellId);

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(this->_vtkCellIds[cellId], npts, nodes);

set<int> tofind;
Expand Down Expand Up @@ -1896,7 +1896,7 @@ void SMDS_DownQuadPenta::computeFacesWithNodes(int cellId, ListElemByNodesType&
// --- find point id's of the volume

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(cellId, npts, nodes);

// --- create all the ordered list of node id's for each face
Expand Down Expand Up @@ -1981,7 +1981,7 @@ void SMDS_DownHexa::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& or
//MESSAGE("cellId = " << cellId);

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(this->_vtkCellIds[cellId], npts, nodes);

set<int> tofind;
Expand Down Expand Up @@ -2036,7 +2036,7 @@ void SMDS_DownHexa::computeFacesWithNodes(int cellId, ListElemByNodesType& faces
// --- find point id's of the volume

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(cellId, npts, nodes);

// --- create all the ordered list of node id's for each face
Expand Down Expand Up @@ -2112,7 +2112,7 @@ void SMDS_DownQuadHexa::getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>
//MESSAGE("cellId = " << cellId);

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(this->_vtkCellIds[cellId], npts, nodes);

set<int> tofind;
Expand Down Expand Up @@ -2167,7 +2167,7 @@ void SMDS_DownQuadHexa::computeFacesWithNodes(int cellId, ListElemByNodesType& f
// --- find point id's of the volume

vtkIdType npts = 0;
vtkIdType *nodes; // will refer to the point id's of the volume
vtkIdTypePtr nodes; // will refer to the point id's of the volume
_grid->GetCellPoints(cellId, npts, nodes);

// --- create all the ordered list of node id's for each face
Expand Down
6 changes: 5 additions & 1 deletion src/3rdParty/salomesmesh/src/SMDS/SMDS_Mesh.cpp
Expand Up @@ -4768,7 +4768,11 @@ void SMDS_Mesh::dumpGrid(string ficdump)
ficcon << endl;
}
ficcon << "-------------------------------- connectivity " << nbPoints << endl;
vtkCellLinks *links = myGrid->GetCellLinks();
#ifdef VTK_CELL_ARRAY_V2
vtkCellLinks *links = static_cast<vtkCellLinks*>(myGrid->GetCellLinks());
#else
vtkCellLinks *links = myGrid->GetCellLinks();
#endif
for (int i=0; i<nbPoints; i++)
{
int ncells = links->GetNcells(i);
Expand Down
12 changes: 12 additions & 0 deletions src/3rdParty/salomesmesh/src/SMDS/SMDS_Mesh0DElement.cpp
Expand Up @@ -146,6 +146,17 @@ bool SMDS_Mesh0DElement::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbN
if ( nbNodes == 1 )
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
#ifdef VTK_CELL_ARRAY_V2
vtkNew<vtkIdList> cellPoints;
grid->GetCellPoints(myVtkID, cellPoints.GetPointer());
if (nbNodes != cellPoints->GetNumberOfIds())
{
MESSAGE("ChangeNodes problem: not the same number of nodes " << cellPoints->GetNumberOfIds() << " -> " << nbNodes);
return false;
}
myNode = nodes[0];
cellPoints->SetId(0, myNode->getVtkId());
#else
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
Expand All @@ -156,6 +167,7 @@ bool SMDS_Mesh0DElement::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbN
}
myNode = nodes[0];
pts[0] = myNode->getVtkId();
#endif

SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return true;
Expand Down
10 changes: 5 additions & 5 deletions src/3rdParty/salomesmesh/src/SMDS/SMDS_MeshNode.cpp
Expand Up @@ -191,7 +191,7 @@ class SMDS_MeshNode_MyInvIterator: public SMDS_ElemIterator
SMDS_ElemIteratorPtr SMDS_MeshNode::
GetInverseElementIterator(SMDSAbs_ElementType type) const
{
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
vtkCellLinks::Link l = static_cast<vtkCellLinks*>(SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks())->GetLink(myVtkID);
//MESSAGE("myID " << myID << " ncells " << l.ncells);
return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type));
}
Expand Down Expand Up @@ -251,7 +251,7 @@ elementsIterator(SMDSAbs_ElementType type) const
return SMDS_MeshElement::elementsIterator(SMDSAbs_Node);
else
{
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
vtkCellLinks::Link l = static_cast<vtkCellLinks*>(SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks())->GetLink(myVtkID);
return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type));
}
}
Expand Down Expand Up @@ -350,7 +350,7 @@ void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME)
const SMDS_MeshCell *cell = dynamic_cast<const SMDS_MeshCell*> (ME);
assert(cell);
SMDS_UnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkCellLinks *Links = grid->GetCellLinks();
vtkCellLinks *Links = static_cast<vtkCellLinks*>(grid->GetCellLinks());
Links->ResizeCellList(myVtkID, 1);
Links->AddCellReference(cell->getVtkId(), myVtkID);
}
Expand All @@ -366,7 +366,7 @@ void SMDS_MeshNode::ClearInverseElements()

bool SMDS_MeshNode::emptyInverseElements()
{
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
vtkCellLinks::Link l = static_cast<vtkCellLinks*>(SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks())->GetLink(myVtkID);
return (l.ncells == 0);
}

Expand All @@ -378,7 +378,7 @@ bool SMDS_MeshNode::emptyInverseElements()

int SMDS_MeshNode::NbInverseElements(SMDSAbs_ElementType type) const
{
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
vtkCellLinks::Link l = static_cast<vtkCellLinks*>(SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks())->GetLink(myVtkID);

if ( type == SMDSAbs_All )
return l.ncells;
Expand Down

0 comments on commit 0cfea3f

Please sign in to comment.