Smesh: Remove the VTK_CELL_ARRAY_V2 compatibility define

This define was introduced in 9.0 for compatiblity with vtk 8.X, and removed for VTK 9.6. As we now support VTK>=9.1, it is not necessary to keep it.
This commit is contained in:
Louis Gombert
2025-11-27 19:45:04 +01:00
committed by Max Wilfinger
parent f5561f23a1
commit c5a14ec998
11 changed files with 7 additions and 128 deletions

View File

@@ -45,11 +45,7 @@
//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;

View File

@@ -95,14 +95,10 @@ public:
std::map<int, std::map<long,int> >& nodeQuadDomains);
vtkCellLinks* GetLinks()
{
#ifdef VTK_CELL_ARRAY_V2
#if VTK_VERSION_NUMBER_QUICK >= 90300000000
#if VTK_VERSION_NUMBER_QUICK >= 90300000000
return static_cast<vtkCellLinks*>(vtkUnstructuredGrid::GetLinks());
#else
return static_cast<vtkCellLinks*>(GetCellLinks());
#endif
#else
return Links;
return static_cast<vtkCellLinks*>(GetCellLinks());
#endif
}
SMDS_Downward* getDownArray(unsigned char vtkType)

View File

@@ -67,16 +67,9 @@ 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;
}

View File

@@ -4712,14 +4712,10 @@ void SMDS_Mesh::dumpGrid(string ficdump)
ficcon << endl;
}
ficcon << "-------------------------------- connectivity " << nbPoints << endl;
#ifdef VTK_CELL_ARRAY_V2
#if VTK_VERSION_NUMBER_QUICK >= 90300000000
#if VTK_VERSION_NUMBER_QUICK >= 90300000000
vtkCellLinks *links = static_cast<vtkCellLinks*>(myGrid->GetLinks());
#else
vtkCellLinks *links = static_cast<vtkCellLinks*>(myGrid->GetCellLinks());
#endif
#else
vtkCellLinks *links = myGrid->GetCellLinks();
vtkCellLinks *links = static_cast<vtkCellLinks*>(myGrid->GetCellLinks());
#endif
for (int i=0; i<nbPoints; i++)
{

View File

@@ -146,7 +146,6 @@ 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())
@@ -156,18 +155,6 @@ bool SMDS_Mesh0DElement::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbN
}
myNode = nodes[0];
cellPoints->SetId(0, myNode->getVtkId());
#else
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
if (nbNodes != npts)
{
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
return false;
}
myNode = nodes[0];
pts[0] = myNode->getVtkId();
#endif
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return true;

View File

@@ -341,11 +341,7 @@ void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes,
// (n1,n2,n3) and (id1,id2,...,idn1,id1,id2,...,idn2, ...)
// The Locations array in vtk 7.x kept the positions of the n's of the above array: (0, idn1 + 1, idn2 + 2).
// In vtk 9.x this array doesn't exist any more but its values can be determined with idni + i
#ifdef VTK_CELL_ARRAY_V2
vtkIdType oldLoc = ((vtkIdTypeArray *)(this->Connectivity->GetOffsetsArray()))->GetValue( j ) + j;
#else
vtkIdType oldLoc = this->Locations->GetValue(j);
#endif
vtkIdType nbpts;
vtkIdTypePtr oldPtsCell = 0;
this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell);
@@ -965,7 +961,6 @@ void SMDS_UnstructuredGrid::GetNodeIds(std::set<int>& nodeSet, int downId, unsig
*/
void SMDS_UnstructuredGrid::ModifyCellNodes(int vtkVolId, std::map<int, int> localClonedNodeIds)
{
#ifdef VTK_CELL_ARRAY_V2
vtkNew<vtkIdList> cellPoints;
this->GetCellPoints(vtkVolId, cellPoints.GetPointer());
for (vtkIdType i = 0; i < cellPoints->GetNumberOfIds(); i++)
@@ -979,22 +974,6 @@ void SMDS_UnstructuredGrid::ModifyCellNodes(int vtkVolId, std::map<int, int> loc
//this->AddReferenceToCell(pts[i], vtkVolId);
}
}
#else
vtkIdType npts = 0;
vtkIdType *pts; // will refer to the point id's of the face
this->GetCellPoints(vtkVolId, npts, pts);
for (int i = 0; i < npts; i++)
{
if (localClonedNodeIds.count(pts[i]))
{
vtkIdType oldpt = pts[i];
pts[i] = localClonedNodeIds[oldpt];
//MESSAGE(oldpt << " --> " << pts[i]);
//this->RemoveReferenceToCell(oldpt, vtkVolId);
//this->AddReferenceToCell(pts[i], vtkVolId);
}
}
#endif
}
/*! reorder the nodes of a face
@@ -1024,25 +1003,16 @@ void SMDS_UnstructuredGrid::BuildLinks()
this->Links->UnRegister(this);
}
#ifdef VTK_CELL_ARRAY_V2
this->Links = SMDS_CellLinks::New();
GetLinks()->Allocate(this->GetNumberOfPoints());
GetLinks()->Register(this);
//FIXME: vtk9
#if VTK_VERSION_NUMBER < VTK_VERSION_CHECK(9,3,0)
#if VTK_VERSION_NUMBER < VTK_VERSION_CHECK(9,3,0)
GetLinks()->BuildLinks(this);
#else
#else
GetLinks()->SetDataSet(this);
GetLinks()->BuildLinks();
#endif
GetLinks()->Delete();
#else
this->Links = SMDS_CellLinks::New();
this->Links->Allocate(this->GetNumberOfPoints());
this->Links->Register(this);
this->Links->BuildLinks(this, this->Connectivity);
this->Links->Delete();
#endif
GetLinks()->Delete();
}
/*! Create a volume (prism or hexahedron) by duplication of a face.

View File

@@ -67,7 +67,6 @@ bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode
bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
#ifdef VTK_CELL_ARRAY_V2
vtkNew<vtkIdList> cellPoints;
grid->GetCellPoints(myVtkID, cellPoints.GetPointer());
if (nbNodes != cellPoints->GetNumberOfIds())
@@ -79,20 +78,6 @@ bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
{
cellPoints->SetId(i, nodes[i]->getVtkId());
}
#else
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
if (nbNodes != npts)
{
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
return false;
}
for (int i = 0; i < nbNodes; i++)
{
pts[i] = nodes[i]->getVtkId();
}
#endif
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return true;
}

View File

@@ -101,7 +101,6 @@ void SMDS_VtkFace::initQuadPoly(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh
bool SMDS_VtkFace::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
#ifdef VTK_CELL_ARRAY_V2
vtkNew<vtkIdList> cellPoints;
grid->GetCellPoints(myVtkID, cellPoints.GetPointer());
if (nbNodes != cellPoints->GetNumberOfIds())
@@ -113,20 +112,6 @@ bool SMDS_VtkFace::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
{
cellPoints->SetId(i, nodes[i]->getVtkId());
}
#else
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
if (nbNodes != npts)
{
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
return false;
}
for (int i = 0; i < nbNodes; i++)
{
pts[i] = nodes[i]->getVtkId();
}
#endif
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return true;
}
@@ -372,18 +357,10 @@ SMDS_NodeIteratorPtr SMDS_VtkFace::interlacedNodesIterator() const
void SMDS_VtkFace::ChangeApex(SMDS_MeshNode* node)
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
#ifdef VTK_CELL_ARRAY_V2
vtkNew<vtkIdList> cellPoints;
grid->GetCellPoints(myVtkID, cellPoints.GetPointer());
grid->RemoveReferenceToCell(cellPoints->GetId(0), myVtkID);
cellPoints->SetId(0, node->getVtkId());
#else
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
grid->RemoveReferenceToCell(pts[0], myVtkID);
pts[0] = node->getVtkId();
#endif
node->AddInverseElement(this),
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
}

View File

@@ -133,7 +133,6 @@ void SMDS_VtkVolume::initPoly(const std::vector<vtkIdType>& nodeIds,
bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
#ifdef VTK_CELL_ARRAY_V2
vtkNew<vtkIdList> cellPoints;
grid->GetCellPoints(myVtkID, cellPoints.GetPointer());
if (nbNodes != cellPoints->GetNumberOfIds())
@@ -145,20 +144,6 @@ bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes
{
cellPoints->SetId(i, nodes[i]->getVtkId());
}
#else
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
if (nbNodes != npts)
{
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
return false;
}
for (int i = 0; i < nbNodes; i++)
{
pts[i] = nodes[i]->getVtkId();
}
#endif
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return true;
}

View File

@@ -400,14 +400,12 @@ void PropertyPostDataObject::SaveDocFile(Base::Writer& writer) const
xmlWriter->SetInputDataObject(m_dataObject);
xmlWriter->SetFileName(fi.filePath().c_str());
#ifdef VTK_CELL_ARRAY_V2
// Looks like an invalid data object that causes a crash with vtk9
vtkUnstructuredGrid* dataGrid = vtkUnstructuredGrid::SafeDownCast(m_dataObject);
if (dataGrid && (dataGrid->GetPiece() < 0 || dataGrid->GetNumberOfPoints() <= 0)) {
std::cerr << "PropertyPostDataObject::SaveDocFile: ignore empty vtkUnstructuredGrid\n";
return;
}
#endif
}
xmlWriter->SetDataModeToBinary();

View File

@@ -75,11 +75,7 @@
using namespace FemGui;
namespace sp = std::placeholders;
#ifdef VTK_CELL_ARRAY_V2
using vtkIdTypePtr = const vtkIdType*;
#else
using vtkIdTypePtr = vtkIdType*;
#endif
// ----------------------------------------------------------------------------