Skip to content

Commit 7dfb4b6

Browse files
authored
Support VTK 9, drop support for VTK <6, fix CI test build on macOS (#733)
* fix: Support VTK 9 * enh: Drop support for VTK<6 * fix: Replace deprecated bind2nd * fix: Missing include in Viewer source file * fixup: Missing include of vtkIdList.h * fixup: Add missing include of vtkNew.h * fix: Download URL of VTK, use curl -L flag to follow redirects * enh: Use VTK 8.2.0 for CI test build on macOS * fix: Use Homebrew to install VTK 8.2 or 9.0 on macOS * fixup: Use keg-only vtk@8.2 Homebrew installation if available * fixup: brew install vtk@8.2 has no —without-python flag * fixup: Homebrew vtk formula has no —without-python flag * fixup: travis.sh script syntax * enh: Remove vtk_prefix before building VTK from source files * tmp: Enable verbose Bash output for install_depends.sh * fixup: Use VTK 8.2.0 build from source files * enh: Add Travis CI environment variable DEBUG_VTK_BUILD * fix: Set CMake policy CMP0057 to NEW for Boost installed by homebrew vtk@8.2 * tmp * fix: install_depends.sh renamed VTK 9 cache variables * fix: VTK 9 CMake cache variable options * ci: Use VTK 9.0 installed with Homebrew * fix: Remove unused variable from install_depends.h * fix: Prefix rm command with “run” * fixup: Add missing include of vtkVersionMacros.h * fix: member access into incomplete type 'vtkIdTypeArray'
1 parent c21910e commit 7dfb4b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+827
-811
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ env:
2020
# - On Ubuntu, use default version installed by apt-get
2121
# - On macOS, build recent VTK version from sources and cache installation
2222
- LINUX_VTK_VERSION=6.0.0
23-
- MACOS_VTK_VERSION=8.1.0
23+
- MACOS_VTK_VERSION=9.0 # Homebrew versions: 8.2, 9.0; otherwise build from sources
2424
- WITH_CCACHE=ON # speed up MIRTK build itself using ccache
2525
- WITH_ARPACK=OFF # requires time consuming build of gcc on macOS
2626
- WITH_UMFPACK=OFF # ARPACK & UMFPACK dependencies come in pairs

Applications/config/Depends.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@
5757
if (MIRTK_Image_FOUND)
5858
# command: calculate
5959
if (MIRTK_Image_WITH_VTK)
60-
basis_find_package(VTK 8|7|6 REQUIRED COMPONENTS vtkCommonCore vtkCommonDataModel)
60+
basis_find_package(VTK REQUIRED COMPONENTS vtkCommonCore vtkCommonDataModel)
6161
endif ()
6262
endif ()
6363

6464
# ----------------------------------------------------------------------------
6565
# Dependencies of point set commands
6666
if (MIRTK_PointSet_FOUND)
6767
# command: all point set commands, info
68-
basis_find_package(VTK 8|7|6 REQUIRED
68+
basis_find_package(VTK REQUIRED
6969
COMPONENTS
7070
vtkCommonCore
7171
vtkCommonDataModel

Applications/src/aggregate-images.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ double GiniCoefficient(Array<T> &samples)
369369
if (shift <= static_cast<T>(0)) {
370370
if (numeric_limits<T>::is_integer) shift -= static_cast<T>(1);
371371
else shift -= static_cast<T>(1e-6);
372-
Transform(samples, bind2nd(minus<T>(), shift));
372+
Transform(samples, bind(minus<T>(), std::placeholders::_1, shift));
373373
}
374374
Sort(samples);
375375
for (int i = 0; i < n; ++i) {
@@ -408,7 +408,7 @@ double EntropyIndex(Array<T> &samples, int alpha = 1)
408408
if (shift <= static_cast<T>(0)) {
409409
if (numeric_limits<T>::is_integer) shift -= static_cast<T>(1);
410410
else shift -= static_cast<T>(1e-6);
411-
Transform(samples, bind2nd(minus<T>(), shift));
411+
Transform(samples, bind(minus<T>(), std::placeholders::_1, shift));
412412
}
413413
// Compute mean value
414414
double mean = 0.;

Applications/src/calculate-surface-attributes.cc

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,17 @@ BorderPointMask(vtkPolyData *surface, vtkDataArray *point_labels,
249249
mask = NewVtkDataArray(VTK_UNSIGNED_CHAR, surface->GetNumberOfPoints(), 1, "BorderMask");
250250
double label;
251251
if (cell_labels) {
252-
vtkPolyDataGetPointCellsNumCellsType ncells;
253-
vtkIdType *cells;
252+
vtkNew<vtkIdList> cellIds;
254253
for (vtkIdType ptId = 0; ptId < surface->GetNumberOfPoints(); ++ptId) {
255-
surface->GetPointCells(ptId, ncells, cells);
256-
if (ncells == 1) {
254+
surface->GetPointCells(ptId, cellIds.GetPointer());
255+
if (cellIds->GetNumberOfIds() == 1) {
257256
mask->SetComponent(ptId, 0, 1.);
258257
} else {
259258
mask->SetComponent(ptId, 0, 0.);
260-
if (ncells > 0) {
261-
label = cell_labels->GetComponent(cells[0], 0);
262-
for (vtkPolyDataGetPointCellsNumCellsType i = 1; i < ncells; ++i) {
263-
if (cell_labels->GetComponent(cells[i], 0) != label) {
259+
if (cellIds->GetNumberOfIds() > 0) {
260+
label = cell_labels->GetComponent(cellIds->GetId(0), 0);
261+
for (vtkIdType i = 1; i < cellIds->GetNumberOfIds(); ++i) {
262+
if (cell_labels->GetComponent(cellIds->GetId(i), 0) != label) {
264263
mask->SetComponent(ptId, 0, 1.);
265264
break;
266265
}
@@ -307,18 +306,17 @@ BorderCellMask(vtkPolyData *surface, vtkDataArray *cell_labels, bool edge_nbrs =
307306
}
308307
}
309308
} else {
310-
vtkPolyDataGetPointCellsNumCellsType ncells;
311-
vtkIdType npts, *pts, *cells;
309+
vtkNew<vtkIdList> cellIds, ptIds;
312310
for (vtkIdType cellId = 0; cellId < surface->GetNumberOfCells(); ++cellId) {
313311
mask->SetComponent(cellId, 0, 0.);
314312
label = cell_labels->GetComponent(cellId, 0);
315-
surface->GetCellPoints(cellId, npts, pts);
316-
for (vtkIdType i = 0; i < npts; ++i) {
317-
surface->GetPointCells(pts[i], ncells, cells);
318-
for (vtkPolyDataGetPointCellsNumCellsType j = 0; j < ncells; ++j) {
319-
if (cell_labels->GetComponent(cells[j], 0) != label) {
313+
surface->GetCellPoints(cellId, ptIds.GetPointer());
314+
for (vtkIdType i = 0; i < ptIds->GetNumberOfIds(); ++i) {
315+
surface->GetPointCells(ptIds->GetId(i), cellIds.GetPointer());
316+
for (vtkIdType j = 0; j < cellIds->GetNumberOfIds(); ++j) {
317+
if (cell_labels->GetComponent(cellIds->GetId(j), 0) != label) {
320318
mask->SetComponent(cellId, 0, 1.);
321-
i = npts; // break all inner loops
319+
i = ptIds->GetNumberOfIds(); // break all inner loops
322320
break;
323321
}
324322
}

Applications/src/convert-pointset-to-mat.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "mirtk/PointSetIO.h"
2626
#include "mirtk/PointSetUtils.h"
2727

28+
#include "vtkNew.h"
2829
#include "vtkSmartPointer.h"
2930
#include "vtkPolyData.h"
3031
#include "vtkCellArray.h"
@@ -172,9 +173,11 @@ int main(int argc, char *argv[])
172173
vtkIdType i = 0;
173174
vtkCellArray *cells = polydata->GetPolys();
174175
cells->InitTraversal();
175-
vtkIdType npts, *pts;
176-
while (cells->GetNextCell(npts, pts)) {
177-
F(i, 0) = pts[0]+1, F(i, 1) = pts[1]+1, F(i, 2) = pts[2]+1;
176+
vtkNew<vtkIdList> ptIds;
177+
while (cells->GetNextCell(ptIds.GetPointer())) {
178+
F(i, 0) = ptIds->GetId(0) + 1;
179+
F(i, 1) = ptIds->GetId(1) + 1;
180+
F(i, 2) = ptIds->GetId(2) + 1;
178181
++i;
179182
}
180183
mxArray *var = MatrixToMxArray(F);

Applications/src/convert-pointset.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "mirtk/PointSetUtils.h"
2828
#include "mirtk/EuclideanDistanceTransform.h"
2929

30+
#include "vtkNew.h"
3031
#include "vtkPolyData.h"
3132
#include "vtkUnstructuredGrid.h"
3233
#include "vtkImageData.h"

Applications/src/copy-pointset-attributes.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "mirtk/PointSetIO.h"
2424
#include "mirtk/PointSetUtils.h"
2525

26+
#include "vtkNew.h"
2627
#include "vtkSmartPointer.h"
2728
#include "vtkPointSet.h"
2829
#include "vtkPointData.h"
@@ -249,9 +250,9 @@ ConvertPointToCellLabels(vtkPointSet *pset, vtkDataArray *labels,
249250
double label;
250251
OrderedMap<double, int> hist;
251252
OrderedMap<double, int>::iterator bin;
252-
vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New();
253+
vtkNew<vtkIdList> ptIds;
253254
for (vtkIdType cellId = 0; cellId < pset->GetNumberOfCells(); ++cellId) {
254-
pset->GetCellPoints(cellId, ptIds);
255+
pset->GetCellPoints(cellId, ptIds.GetPointer());
255256
for (int j = 0; j < labels->GetNumberOfComponents(); ++j) {
256257
hist.clear();
257258
for (vtkIdType i = 0; i < ptIds->GetNumberOfIds(); ++i) {
@@ -274,9 +275,9 @@ ConvertPointToCellLabels(vtkPointSet *pset, vtkDataArray *labels,
274275
case UnanimousVote: {
275276
const double invalid = NaN;
276277
double label;
277-
vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New();
278+
vtkNew<vtkIdList> ptIds;
278279
for (vtkIdType cellId = 0; cellId < pset->GetNumberOfCells(); ++cellId) {
279-
pset->GetCellPoints(cellId, ptIds);
280+
pset->GetCellPoints(cellId, ptIds.GetPointer());
280281
for (int j = 0; j < labels->GetNumberOfComponents(); ++j) {
281282
if (ptIds->GetNumberOfIds() == 0) {
282283
label = invalid;
@@ -319,9 +320,9 @@ ConvertCellToPointLabels(vtkPointSet *pset, vtkDataArray *labels,
319320
double label;
320321
OrderedMap<double, int> hist;
321322
OrderedMap<double, int>::iterator bin;
322-
vtkSmartPointer<vtkIdList> cellIds = vtkSmartPointer<vtkIdList>::New();
323+
vtkNew<vtkIdList> cellIds;
323324
for (vtkIdType ptId = 0; ptId < pset->GetNumberOfPoints(); ++ptId) {
324-
pset->GetPointCells(ptId, cellIds);
325+
pset->GetPointCells(ptId, cellIds.GetPointer());
325326
for (int j = 0; j < labels->GetNumberOfComponents(); ++j) {
326327
hist.clear();
327328
for (vtkIdType i = 0; i < cellIds->GetNumberOfIds(); ++i) {
@@ -344,9 +345,9 @@ ConvertCellToPointLabels(vtkPointSet *pset, vtkDataArray *labels,
344345
case UnanimousVote: {
345346
double label;
346347
const double invalid = NaN;
347-
vtkSmartPointer<vtkIdList> cellIds = vtkSmartPointer<vtkIdList>::New();
348+
vtkNew<vtkIdList> cellIds;
348349
for (vtkIdType ptId = 0; ptId < pset->GetNumberOfPoints(); ++ptId) {
349-
pset->GetPointCells(ptId, cellIds);
350+
pset->GetPointCells(ptId, cellIds.GetPointer());
350351
for (int j = 0; j < labels->GetNumberOfComponents(); ++j) {
351352
if (cellIds->GetNumberOfIds() == 0) {
352353
label = invalid;

Applications/src/evaluate-distance.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,15 +468,14 @@ int main(int argc, char *argv[])
468468
vtkNew<vtkCellLocator> locator;
469469
locator->SetDataSet(target);
470470
locator->BuildLocator();
471-
vtkSmartPointer<vtkIdList> ptIds;
472-
ptIds = vtkSmartPointer<vtkIdList>::New();
471+
vtkNew<vtkIdList> ptIds;
473472

474473
for (vtkIdType ptId = 0; ptId < target->GetNumberOfPoints(); ++ptId) {
475474
source->GetPoint(ptId, a);
476475
locator->FindClosestPoint(a, b, cellId, subId, dist);
477476
dist = sqrt(dist);
478477
if (mask) {
479-
target->GetCellPoints(cellId, ptIds);
478+
target->GetCellPoints(cellId, ptIds.GetPointer());
480479
for (vtkIdType i = 0; i < ptIds->GetNumberOfIds(); ++i) {
481480
if (mask->GetComponent(ptIds->GetId(i), 0) != 0.) {
482481
if (dist > hausdorff_dist) hausdorff_dist = dist;

Applications/src/evaluate-distortion.cc

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,20 @@ enum DistortionMeasure
9797
// -----------------------------------------------------------------------------
9898
double Angle(vtkPolyData *mesh, vtkIdType cellId, vtkIdType ptId)
9999
{
100-
vtkIdType npts, *pts, i[3] = {0, 1, 2};
101-
mesh->GetCellPoints(cellId, npts, pts);
102-
for (vtkIdType j = 0; j < npts; ++j) {
103-
if (pts[j] == ptId) {
100+
vtkIdType i[3] = {0, 1, 2};
101+
vtkNew<vtkIdList> ptIds;
102+
mesh->GetCellPoints(cellId, ptIds.GetPointer());
103+
for (vtkIdType j = 0; j < ptIds->GetNumberOfIds(); ++j) {
104+
if (ptIds->GetId(j) == ptId) {
104105
i[0] = i[j];
105106
i[j] = 0;
106107
break;
107108
}
108109
}
109110
double p[3][3], ab, ac, bc;
110-
mesh->GetPoint(pts[0], p[i[0]]);
111-
mesh->GetPoint(pts[1], p[i[1]]);
112-
mesh->GetPoint(pts[2], p[i[2]]);
111+
mesh->GetPoint(ptIds->GetId(0), p[i[0]]);
112+
mesh->GetPoint(ptIds->GetId(1), p[i[1]]);
113+
mesh->GetPoint(ptIds->GetId(2), p[i[2]]);
113114
ab = pow(p[1][0] - p[0][0], 2) + pow(p[1][1] - p[0][1], 2) + pow(p[1][2] - p[0][2], 2);
114115
ac = pow(p[2][0] - p[0][0], 2) + pow(p[2][1] - p[0][1], 2) + pow(p[2][2] - p[0][2], 2);
115116
bc = pow(p[2][0] - p[1][0], 2) + pow(p[2][1] - p[1][1], 2) + pow(p[2][2] - p[1][2], 2);
@@ -131,37 +132,38 @@ AngularDistortion(vtkPolyData *orig, vtkPolyData *mesh)
131132
array->SetNumberOfComponents(2);
132133
array->SetNumberOfTuples(npoints);
133134

134-
vtkPolyDataGetPointCellsNumCellsType ncells1, ncells2;
135-
vtkIdType *cells1, *cells2;
135+
vtkNew<vtkIdList> cellIds1, cellIds2;
136+
136137
double sum1, sum2;
137138
Array<double> angles1, angles2;
138139
double ratio, avg_ratio, max_ratio;
139140

140141
for (vtkIdType ptId = 0; ptId < npoints; ++ptId) {
141-
orig->GetPointCells(ptId, ncells1, cells1);
142-
mesh->GetPointCells(ptId, ncells2, cells2);
143-
if (ncells1 != ncells2) {
142+
orig->GetPointCells(ptId, cellIds1.GetPointer());
143+
mesh->GetPointCells(ptId, cellIds2.GetPointer());
144+
if (cellIds1->GetNumberOfIds() != cellIds2->GetNumberOfIds()) {
144145
FatalError("AngularDistortion: Point " << ptId << " belongs to different number of cells in the two meshes!");
145146
}
146-
angles1.resize(ncells1);
147-
angles2.resize(ncells2);
148-
for (vtkPolyDataGetPointCellsNumCellsType i = 0; i < ncells1; ++i) {
149-
if (cells1[i] != cells2[i]) {
147+
const vtkIdType ncells = cellIds1->GetNumberOfIds();
148+
angles1.resize(ncells);
149+
angles2.resize(ncells);
150+
for (vtkIdType i = 0; i < ncells; ++i) {
151+
if (cellIds1->GetId(i) != cellIds2->GetId(i)) {
150152
FatalError("AngularDistortion: Lists of cell IDs to which point " << ptId << " belongs differ!");
151153
}
152-
angles1[i] = Angle(orig, cells1[i], ptId);
153-
angles2[i] = Angle(mesh, cells2[i], ptId);
154+
angles1[i] = Angle(orig, cellIds1->GetId(i), ptId);
155+
angles2[i] = Angle(mesh, cellIds2->GetId(i), ptId);
154156
}
155157
sum1 = Accumulate(angles1);
156158
sum2 = Accumulate(angles2);
157159
avg_ratio = .0;
158160
max_ratio = .0;
159-
for (vtkPolyDataGetPointCellsNumCellsType i = 0; i < ncells1; ++i) {
161+
for (vtkIdType i = 0; i < ncells; ++i) {
160162
ratio = (angles1[i] / sum1) / (angles2[i] / sum2);
161163
max_ratio = max(max_ratio, ratio);
162164
avg_ratio += ratio;
163165
}
164-
avg_ratio /= ncells1;
166+
avg_ratio /= ncells;
165167
array->SetComponent(ptId, 0, avg_ratio);
166168
array->SetComponent(ptId, 1, max_ratio);
167169
}

Applications/src/evaluate-surface-mesh.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -356,16 +356,17 @@ int main(int argc, char *argv[])
356356
surface.TakeReference(input->NewInstance());
357357
surface->SetPoints(input->GetPoints());
358358
surface->Allocate(input->GetNumberOfCells());
359-
vtkIdType cellId, npts, *pts;
359+
vtkIdType cellId;
360+
vtkNew<vtkIdList> ptIds;
360361
vtkSmartPointer<vtkIdTypeArray> origCellIds;
361362
origCellIds = vtkSmartPointer<vtkIdTypeArray>::New();
362363
origCellIds->SetName("OriginalIds");
363364
origCellIds->SetNumberOfComponents(1);
364365
origCellIds->SetNumberOfTuples(selection.size());
365366
surface->GetCellData()->AddArray(origCellIds);
366367
for (auto origCellId : selection) {
367-
input->GetCellPoints(origCellId, npts, pts);
368-
cellId = surface->InsertNextCell(input->GetCellType(origCellId), npts, pts);
368+
input->GetCellPoints(origCellId, ptIds.GetPointer());
369+
cellId = surface->InsertNextCell(input->GetCellType(origCellId), ptIds.GetPointer());
369370
origCellIds->SetValue(cellId, origCellId);
370371
}
371372
surface->BuildLinks();
@@ -442,14 +443,14 @@ int main(int argc, char *argv[])
442443
input->GetPointData()->RemoveArray(pointIds->GetName());
443444
input->GetPointData()->AddArray(pointIds);
444445
// Add surface component IDs cell data
445-
vtkIdType npts, *pts;
446+
vtkNew<vtkIdList> ptIds;
446447
output->BuildLinks();
447448
cellIds = NewVtkDataArray(ncomp < 256 ? VTK_UNSIGNED_CHAR :
448449
(ncomp < 65535 ? VTK_UNSIGNED_SHORT : VTK_INT),
449450
surface->GetNumberOfCells(), 1, COMPONENT_ID);
450451
for (vtkIdType cellId = 0; cellId < output->GetNumberOfCells(); ++cellId) {
451-
output->GetCellPoints(cellId, npts, pts);
452-
cellIds->SetComponent(cellId, 0, (npts == 0 ? 0. : compIds->GetComponent(pts[0], 0)));
452+
output->GetCellPoints(cellId, ptIds.GetPointer());
453+
cellIds->SetComponent(cellId, 0, (ptIds->GetNumberOfIds() == 0 ? 0. : compIds->GetComponent(ptIds->GetId(0), 0)));
453454
}
454455
AddCellData(input, surface, cellIds);
455456
}
@@ -601,15 +602,14 @@ int main(int argc, char *argv[])
601602
collisions.Run();
602603

603604
if (output_name) {
604-
vtkIdType *cells;
605-
vtkPolyDataGetPointCellsNumCellsType ncells;
605+
vtkNew<vtkIdList> cellIds;
606606
vtkSmartPointer<vtkDataArray> mask;
607607
mask = NewVtkDataArray(VTK_UNSIGNED_CHAR, surface->GetNumberOfPoints(), 1, "CollisionMask");
608608
for (vtkIdType ptId = 0; ptId < surface->GetNumberOfPoints(); ++ptId) {
609609
mask->SetComponent(ptId, 0, 0.);
610-
surface->GetPointCells(ptId, ncells, cells);
611-
for (vtkPolyDataGetPointCellsNumCellsType i = 0; i < ncells; ++i) {
612-
if (collisions.GetCollisionType(cells[i]) != SurfaceCollisions::NoCollision) {
610+
surface->GetPointCells(ptId, cellIds.GetPointer());
611+
for (vtkIdType i = 0; i < cellIds->GetNumberOfIds(); ++i) {
612+
if (collisions.GetCollisionType(cellIds->GetId(i)) != SurfaceCollisions::NoCollision) {
613613
mask->SetComponent(ptId, 0, 1.);
614614
break;
615615
}

0 commit comments

Comments
 (0)