Commit 56f9168a authored by Ozan Tonkal's avatar Ozan Tonkal

support VTK 6.0.0: cmakelist.txt might need to be refactored

parent 26005a19
...@@ -74,7 +74,11 @@ You can download the code from `here <../../../../samples/cpp/tutorial_code/viz/ ...@@ -74,7 +74,11 @@ You can download the code from `here <../../../../samples/cpp/tutorial_code/viz/
// Create mapper and actor // Create mapper and actor
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
#if VTK_MAJOR_VERSION <= 5
mapper->SetInput(polyData); mapper->SetInput(polyData);
#else
mapper->SetInputData(polyData);
#endif
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
......
...@@ -13,6 +13,9 @@ endmacro() ...@@ -13,6 +13,9 @@ endmacro()
macro(find_vtk) macro(find_vtk)
find_package(VTK 5.10.0 REQUIRED) find_package(VTK 5.10.0 REQUIRED)
if(NOT VTK_FOUND)
find_package(VTK 6.0.0 REQUIRED)
endif()
if(VTK_FOUND) if(VTK_FOUND)
if (BUILD_SHARED_LIBS OR (NOT BUILD_SHARED_LIBS AND NOT VTK_BUILD_SHARED_LIBS)) if (BUILD_SHARED_LIBS OR (NOT BUILD_SHARED_LIBS AND NOT VTK_BUILD_SHARED_LIBS))
find_qvtk() find_qvtk()
...@@ -43,7 +46,11 @@ include_directories(src) ...@@ -43,7 +46,11 @@ include_directories(src)
ocv_define_module(viz opencv_core) ocv_define_module(viz opencv_core)
if(DEFINED BUILD_opencv_viz AND BUILD_opencv_viz AND DEFINED HAVE_VTK AND HAVE_VTK) if(DEFINED BUILD_opencv_viz AND BUILD_opencv_viz AND DEFINED HAVE_VTK AND HAVE_VTK)
target_link_libraries(opencv_viz vtkCommon vtkWidgets vtkFiltering vtkRendering) if (${VTK_VERSION_MAJOR} EQUAL 5)
target_link_libraries(opencv_viz vtkCommon vtkWidgets vtkFiltering vtkRendering)
else()
target_link_libraries(opencv_viz vtkViewsCore vtkRenderingLOD vtkIOPLY vtkRenderingFreeTypeOpenGL vtkRenderingVolumeOpenGL vtkFiltersTexture)
endif()
if(APPLE) if(APPLE)
target_link_libraries(opencv_viz "-framework Cocoa") target_link_libraries(opencv_viz "-framework Cocoa")
endif() endif()
......
...@@ -175,7 +175,11 @@ cv::viz::CloudWidget::CloudWidget(InputArray _cloud, InputArray _colors) ...@@ -175,7 +175,11 @@ cv::viz::CloudWidget::CloudWidget(InputArray _cloud, InputArray _colors)
polydata->GetPointData()->SetScalars(scalars); polydata->GetPointData()->SetScalars(scalars);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
#if VTK_MAJOR_VERSION <= 5
mapper->SetInput(polydata); mapper->SetInput(polydata);
#else
mapper->SetInputData(polydata);
#endif
Vec3d minmax(scalars->GetRange()); Vec3d minmax(scalars->GetRange());
mapper->SetScalarRange(minmax.val); mapper->SetScalarRange(minmax.val);
...@@ -206,7 +210,11 @@ cv::viz::CloudWidget::CloudWidget(InputArray _cloud, const Color &color) ...@@ -206,7 +210,11 @@ cv::viz::CloudWidget::CloudWidget(InputArray _cloud, const Color &color)
vtkSmartPointer<vtkPolyData> polydata = CreateCloudWidget::create(cloud, nr_points); vtkSmartPointer<vtkPolyData> polydata = CreateCloudWidget::create(cloud, nr_points);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
#if VTK_MAJOR_VERSION <= 5
mapper->SetInput(polydata); mapper->SetInput(polydata);
#else
mapper->SetInputData(polydata);
#endif
bool interpolation = (polydata && polydata->GetNumberOfCells() != polydata->GetNumberOfVerts()); bool interpolation = (polydata && polydata->GetNumberOfCells() != polydata->GetNumberOfVerts());
...@@ -327,7 +335,11 @@ struct cv::viz::CloudCollectionWidget::CreateCloudWidget ...@@ -327,7 +335,11 @@ struct cv::viz::CloudCollectionWidget::CreateCloudWidget
{ {
// This is the first cloud // This is the first cloud
vtkSmartPointer<vtkDataSetMapper> mapper_new = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper_new = vtkSmartPointer<vtkDataSetMapper>::New();
#if VTK_MAJOR_VERSION <= 5
mapper_new->SetInputConnection(poly_data->GetProducerPort()); mapper_new->SetInputConnection(poly_data->GetProducerPort());
#else
mapper_new->SetInputData(poly_data);
#endif
mapper_new->SetScalarRange(minmax.val); mapper_new->SetScalarRange(minmax.val);
mapper_new->SetScalarModeToUsePointData(); mapper_new->SetScalarModeToUsePointData();
...@@ -349,8 +361,13 @@ struct cv::viz::CloudCollectionWidget::CreateCloudWidget ...@@ -349,8 +361,13 @@ struct cv::viz::CloudCollectionWidget::CreateCloudWidget
CV_Assert("Cloud Widget without data" && data); CV_Assert("Cloud Widget without data" && data);
vtkSmartPointer<vtkAppendPolyData> appendFilter = vtkSmartPointer<vtkAppendPolyData>::New(); vtkSmartPointer<vtkAppendPolyData> appendFilter = vtkSmartPointer<vtkAppendPolyData>::New();
#if VTK_MAJOR_VERSION <= 5
appendFilter->AddInputConnection(mapper->GetInput()->GetProducerPort()); appendFilter->AddInputConnection(mapper->GetInput()->GetProducerPort());
appendFilter->AddInputConnection(poly_data->GetProducerPort()); appendFilter->AddInputConnection(poly_data->GetProducerPort());
#else
appendFilter->AddInputData(data);
appendFilter->AddInputData(poly_data);
#endif
mapper->SetInputConnection(appendFilter->GetOutputPort()); mapper->SetInputConnection(appendFilter->GetOutputPort());
// Update the number of cloud points // Update the number of cloud points
...@@ -401,7 +418,11 @@ void cv::viz::CloudCollectionWidget::addCloud(InputArray _cloud, InputArray _col ...@@ -401,7 +418,11 @@ void cv::viz::CloudCollectionWidget::addCloud(InputArray _cloud, InputArray _col
vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New(); vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
transform_filter->SetTransform(transform); transform_filter->SetTransform(transform);
#if VTK_MAJOR_VERSION <= 5
transform_filter->SetInputConnection(polydata->GetProducerPort()); transform_filter->SetInputConnection(polydata->GetProducerPort());
#else
transform_filter->SetInputData(polydata);
#endif
transform_filter->Update(); transform_filter->Update();
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this)); vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this));
...@@ -436,7 +457,11 @@ void cv::viz::CloudCollectionWidget::addCloud(InputArray _cloud, const Color &co ...@@ -436,7 +457,11 @@ void cv::viz::CloudCollectionWidget::addCloud(InputArray _cloud, const Color &co
vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New(); vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
transform_filter->SetTransform(transform); transform_filter->SetTransform(transform);
#if VTK_MAJOR_VERSION <= 5
transform_filter->SetInputConnection(polydata->GetProducerPort()); transform_filter->SetInputConnection(polydata->GetProducerPort());
#else
transform_filter->SetInputData(polydata);
#endif
transform_filter->Update(); transform_filter->Update();
vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this)); vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this));
...@@ -571,7 +596,11 @@ cv::viz::CloudNormalsWidget::CloudNormalsWidget(InputArray _cloud, InputArray _n ...@@ -571,7 +596,11 @@ cv::viz::CloudNormalsWidget::CloudNormalsWidget(InputArray _cloud, InputArray _n
polyData->SetLines(lines); polyData->SetLines(lines);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
#if VTK_MAJOR_VERSION <= 5
mapper->SetInput(polyData); mapper->SetInput(polyData);
#else
mapper->SetInputData(polyData);
#endif
mapper->SetColorModeToMapScalars(); mapper->SetColorModeToMapScalars();
mapper->SetScalarModeToUsePointData(); mapper->SetScalarModeToUsePointData();
...@@ -707,7 +736,6 @@ cv::viz::MeshWidget::MeshWidget(const Mesh3d &mesh) ...@@ -707,7 +736,6 @@ cv::viz::MeshWidget::MeshWidget(const Mesh3d &mesh)
poly_grid->Allocate(1, 1); poly_grid->Allocate(1, 1);
poly_grid->InsertNextCell(polygon->GetCellType(), polygon->GetPointIds()); poly_grid->InsertNextCell(polygon->GetCellType(), polygon->GetPointIds());
poly_grid->SetPoints(points); poly_grid->SetPoints(points);
poly_grid->Update();
if (scalars) if (scalars)
poly_grid->GetPointData()->SetScalars(scalars); poly_grid->GetPointData()->SetScalars(scalars);
...@@ -724,7 +752,11 @@ cv::viz::MeshWidget::MeshWidget(const Mesh3d &mesh) ...@@ -724,7 +752,11 @@ cv::viz::MeshWidget::MeshWidget(const Mesh3d &mesh)
actor->GetProperty()->ShadingOff(); actor->GetProperty()->ShadingOff();
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
#if VTK_MAJOR_VERSION <= 5
mapper->SetInput(data); mapper->SetInput(data);
#else
mapper->SetInputData(data);
#endif
mapper->ImmediateModeRenderingOff(); mapper->ImmediateModeRenderingOff();
vtkIdType numberOfCloudPoints = nr_points * 0.1; vtkIdType numberOfCloudPoints = nr_points * 0.1;
......
...@@ -66,7 +66,7 @@ cv::viz::LineWidget::LineWidget(const Point3f &pt1, const Point3f &pt2, const Co ...@@ -66,7 +66,7 @@ cv::viz::LineWidget::LineWidget(const Point3f &pt1, const Point3f &pt2, const Co
line->Update(); line->Update();
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInput(line->GetOutput()); mapper->SetInputConnection(line->GetOutputPort());
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New(); vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -87,7 +87,7 @@ template<> cv::viz::LineWidget cv::viz::Widget::cast<cv::viz::LineWidget>() ...@@ -87,7 +87,7 @@ template<> cv::viz::LineWidget cv::viz::Widget::cast<cv::viz::LineWidget>()
struct cv::viz::PlaneWidget::SetSizeImpl struct cv::viz::PlaneWidget::SetSizeImpl
{ {
template<typename _Tp> template<typename _Tp>
static vtkSmartPointer<vtkPolyData> setSize(const Vec<_Tp, 3> &center, vtkSmartPointer<vtkPolyData> poly_data, double size) static vtkSmartPointer<vtkTransformPolyDataFilter> setSize(const Vec<_Tp, 3> &center, vtkSmartPointer<vtkAlgorithmOutput> poly_data_port, double size)
{ {
vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New(); vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
transform->PreMultiply(); transform->PreMultiply();
...@@ -96,11 +96,11 @@ struct cv::viz::PlaneWidget::SetSizeImpl ...@@ -96,11 +96,11 @@ struct cv::viz::PlaneWidget::SetSizeImpl
transform->Translate(-center[0], -center[1], -center[2]); transform->Translate(-center[0], -center[1], -center[2]);
vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New(); vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
transform_filter->SetInput(poly_data); transform_filter->SetInputConnection(poly_data_port);
transform_filter->SetTransform(transform); transform_filter->SetTransform(transform);
transform_filter->Update(); transform_filter->Update();
return transform_filter->GetOutput(); return transform_filter;
} }
}; };
...@@ -115,7 +115,7 @@ cv::viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, double size, const Color & ...@@ -115,7 +115,7 @@ cv::viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, double size, const Color &
plane->GetOrigin(p_center.val); plane->GetOrigin(p_center.val);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInput(SetSizeImpl::setSize(p_center, plane->GetOutput(), size)); mapper->SetInputConnection(SetSizeImpl::setSize(p_center, plane->GetOutputPort(), size)->GetOutputPort());
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New(); vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -136,7 +136,7 @@ cv::viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Point3f& pt, double ...@@ -136,7 +136,7 @@ cv::viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Point3f& pt, double
plane->SetCenter(p_center[0], p_center[1], p_center[2]); plane->SetCenter(p_center[0], p_center[1], p_center[2]);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInput(SetSizeImpl::setSize(p_center, plane->GetOutput(), size)); mapper->SetInputConnection(SetSizeImpl::setSize(p_center, plane->GetOutputPort(), size)->GetOutputPort());
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New(); vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -165,7 +165,7 @@ cv::viz::SphereWidget::SphereWidget(const Point3f &center, float radius, int sph ...@@ -165,7 +165,7 @@ cv::viz::SphereWidget::SphereWidget(const Point3f &center, float radius, int sph
sphere->Update(); sphere->Update();
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInput(sphere->GetOutput()); mapper->SetInputConnection(sphere->GetOutputPort());
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New(); vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -238,7 +238,7 @@ cv::viz::ArrowWidget::ArrowWidget(const Point3f& pt1, const Point3f& pt2, double ...@@ -238,7 +238,7 @@ cv::viz::ArrowWidget::ArrowWidget(const Point3f& pt1, const Point3f& pt2, double
transformPD->SetInputConnection(arrowSource->GetOutputPort()); transformPD->SetInputConnection(arrowSource->GetOutputPort());
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInput(transformPD->GetOutput()); mapper->SetInputConnection(transformPD->GetOutputPort());
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New(); vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -274,7 +274,7 @@ cv::viz::CircleWidget::CircleWidget(const Point3f& pt, double radius, double thi ...@@ -274,7 +274,7 @@ cv::viz::CircleWidget::CircleWidget(const Point3f& pt, double radius, double thi
tf->SetInputConnection(disk->GetOutputPort()); tf->SetInputConnection(disk->GetOutputPort());
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInput(tf->GetOutput()); mapper->SetInputConnection(tf->GetOutputPort());
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New(); vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -305,7 +305,7 @@ cv::viz::CylinderWidget::CylinderWidget(const Point3f& pt_on_axis, const Point3f ...@@ -305,7 +305,7 @@ cv::viz::CylinderWidget::CylinderWidget(const Point3f& pt_on_axis, const Point3f
tuber->SetNumberOfSides(numsides); tuber->SetNumberOfSides(numsides);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInput(tuber->GetOutput()); mapper->SetInputConnection(tuber->GetOutputPort());
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New(); vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -330,13 +330,13 @@ cv::viz::CubeWidget::CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bo ...@@ -330,13 +330,13 @@ cv::viz::CubeWidget::CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bo
{ {
vtkSmartPointer<vtkOutlineSource> cube = vtkSmartPointer<vtkOutlineSource>::New(); vtkSmartPointer<vtkOutlineSource> cube = vtkSmartPointer<vtkOutlineSource>::New();
cube->SetBounds(pt_min.x, pt_max.x, pt_min.y, pt_max.y, pt_min.z, pt_max.z); cube->SetBounds(pt_min.x, pt_max.x, pt_min.y, pt_max.y, pt_min.z, pt_max.z);
mapper->SetInput(cube->GetOutput()); mapper->SetInputConnection(cube->GetOutputPort());
} }
else else
{ {
vtkSmartPointer<vtkCubeSource> cube = vtkSmartPointer<vtkCubeSource>::New(); vtkSmartPointer<vtkCubeSource> cube = vtkSmartPointer<vtkCubeSource>::New();
cube->SetBounds(pt_min.x, pt_max.x, pt_min.y, pt_max.y, pt_min.z, pt_max.z); cube->SetBounds(pt_min.x, pt_max.x, pt_min.y, pt_max.y, pt_min.z, pt_max.z);
mapper->SetInput(cube->GetOutput()); mapper->SetInputConnection(cube->GetOutputPort());
} }
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New(); vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
...@@ -371,17 +371,25 @@ cv::viz::CoordinateSystemWidget::CoordinateSystemWidget(double scale) ...@@ -371,17 +371,25 @@ cv::viz::CoordinateSystemWidget::CoordinateSystemWidget(double scale)
axes_colors->InsertNextValue(1.0); axes_colors->InsertNextValue(1.0);
vtkSmartPointer<vtkPolyData> axes_data = axes->GetOutput(); vtkSmartPointer<vtkPolyData> axes_data = axes->GetOutput();
#if VTK_MAJOR_VERSION <= 5
axes_data->Update(); axes_data->Update();
#else
axes->Update();
#endif
axes_data->GetPointData()->SetScalars(axes_colors); axes_data->GetPointData()->SetScalars(axes_colors);
vtkSmartPointer<vtkTubeFilter> axes_tubes = vtkSmartPointer<vtkTubeFilter>::New(); vtkSmartPointer<vtkTubeFilter> axes_tubes = vtkSmartPointer<vtkTubeFilter>::New();
#if VTK_MAJOR_VERSION <= 5
axes_tubes->SetInput(axes_data); axes_tubes->SetInput(axes_data);
#else
axes_tubes->SetInputData(axes_data);
#endif
axes_tubes->SetRadius(axes->GetScaleFactor() / 50.0); axes_tubes->SetRadius(axes->GetScaleFactor() / 50.0);
axes_tubes->SetNumberOfSides(6); axes_tubes->SetNumberOfSides(6);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetScalarModeToUsePointData(); mapper->SetScalarModeToUsePointData();
mapper->SetInput(axes_tubes->GetOutput()); mapper->SetInputConnection(axes_tubes->GetOutputPort());
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New(); vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -456,7 +464,11 @@ cv::viz::PolyLineWidget::PolyLineWidget(InputArray _pointData, const Color &colo ...@@ -456,7 +464,11 @@ cv::viz::PolyLineWidget::PolyLineWidget(InputArray _pointData, const Color &colo
polyData->SetLines(cells); polyData->SetLines(cells);
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
#if VTK_MAJOR_VERSION <= 5
mapper->SetInput(polyData); mapper->SetInput(polyData);
#else
mapper->SetInputData(polyData);
#endif
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -491,7 +503,11 @@ struct cv::viz::GridWidget::GridImpl ...@@ -491,7 +503,11 @@ struct cv::viz::GridWidget::GridImpl
// Extract the edges so we have the grid // Extract the edges so we have the grid
vtkSmartPointer<vtkExtractEdges> filter = vtkSmartPointer<vtkExtractEdges>::New(); vtkSmartPointer<vtkExtractEdges> filter = vtkSmartPointer<vtkExtractEdges>::New();
#if VTK_MAJOR_VERSION <= 5
filter->SetInputConnection(grid->GetProducerPort()); filter->SetInputConnection(grid->GetProducerPort());
#else
filter->SetInputData(grid);
#endif
filter->Update(); filter->Update();
return filter->GetOutput(); return filter->GetOutput();
} }
...@@ -502,7 +518,11 @@ cv::viz::GridWidget::GridWidget(const Vec2i &dimensions, const Vec2d &spacing, c ...@@ -502,7 +518,11 @@ cv::viz::GridWidget::GridWidget(const Vec2i &dimensions, const Vec2d &spacing, c
vtkSmartPointer<vtkPolyData> grid = GridImpl::createGrid(dimensions, spacing); vtkSmartPointer<vtkPolyData> grid = GridImpl::createGrid(dimensions, spacing);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
#if VTK_MAJOR_VERSION <= 5
mapper->SetInputConnection(grid->GetProducerPort()); mapper->SetInputConnection(grid->GetProducerPort());
#else
mapper->SetInputData(grid);
#endif
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -547,7 +567,11 @@ cv::viz::GridWidget::GridWidget(const Vec4f &coefs, const Vec2i &dimensions, con ...@@ -547,7 +567,11 @@ cv::viz::GridWidget::GridWidget(const Vec4f &coefs, const Vec2i &dimensions, con
vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New(); vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
transform_filter->SetTransform(transform); transform_filter->SetTransform(transform);
#if VTK_MAJOR_VERSION <= 5
transform_filter->SetInputConnection(grid->GetProducerPort()); transform_filter->SetInputConnection(grid->GetProducerPort());
#else
transform_filter->SetInputData(grid);
#endif
transform_filter->Update(); transform_filter->Update();
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
...@@ -685,7 +709,11 @@ cv::viz::ImageOverlayWidget::ImageOverlayWidget(const Mat &image, const Rect &re ...@@ -685,7 +709,11 @@ cv::viz::ImageOverlayWidget::ImageOverlayWidget(const Mat &image, const Rect &re
// Need to flip the image as the coordinates are different in OpenCV and VTK // Need to flip the image as the coordinates are different in OpenCV and VTK
vtkSmartPointer<vtkImageFlip> flipFilter = vtkSmartPointer<vtkImageFlip>::New(); vtkSmartPointer<vtkImageFlip> flipFilter = vtkSmartPointer<vtkImageFlip>::New();
flipFilter->SetFilteredAxis(1); // Vertical flip flipFilter->SetFilteredAxis(1); // Vertical flip
#if VTK_MAJOR_VERSION <= 5
flipFilter->SetInputConnection(vtk_image->GetProducerPort()); flipFilter->SetInputConnection(vtk_image->GetProducerPort());
#else
flipFilter->SetInputData(vtk_image);
#endif
flipFilter->Update(); flipFilter->Update();
// Scale the image based on the Rect // Scale the image based on the Rect
...@@ -728,7 +756,11 @@ void cv::viz::ImageOverlayWidget::setImage(const Mat &image) ...@@ -728,7 +756,11 @@ void cv::viz::ImageOverlayWidget::setImage(const Mat &image)
// Need to flip the image as the coordinates are different in OpenCV and VTK // Need to flip the image as the coordinates are different in OpenCV and VTK
vtkSmartPointer<vtkImageFlip> flipFilter = vtkSmartPointer<vtkImageFlip>::New(); vtkSmartPointer<vtkImageFlip> flipFilter = vtkSmartPointer<vtkImageFlip>::New();
flipFilter->SetFilteredAxis(1); // Vertical flip flipFilter->SetFilteredAxis(1); // Vertical flip
#if VTK_MAJOR_VERSION <= 5
flipFilter->SetInputConnection(vtk_image->GetProducerPort()); flipFilter->SetInputConnection(vtk_image->GetProducerPort());
#else
flipFilter->SetInputData(vtk_image);
#endif
flipFilter->Update(); flipFilter->Update();
mapper->SetInputConnection(flipFilter->GetOutputPort()); mapper->SetInputConnection(flipFilter->GetOutputPort());
...@@ -754,7 +786,11 @@ cv::viz::Image3DWidget::Image3DWidget(const Mat &image, const Size &size) ...@@ -754,7 +786,11 @@ cv::viz::Image3DWidget::Image3DWidget(const Mat &image, const Size &size)
// Need to flip the image as the coordinates are different in OpenCV and VTK // Need to flip the image as the coordinates are different in OpenCV and VTK
vtkSmartPointer<vtkImageFlip> flipFilter = vtkSmartPointer<vtkImageFlip>::New(); vtkSmartPointer<vtkImageFlip> flipFilter = vtkSmartPointer<vtkImageFlip>::New();
flipFilter->SetFilteredAxis(1); // Vertical flip flipFilter->SetFilteredAxis(1); // Vertical flip
#if VTK_MAJOR_VERSION <= 5
flipFilter->SetInputConnection(vtk_image->GetProducerPort()); flipFilter->SetInputConnection(vtk_image->GetProducerPort());
#else
flipFilter->SetInputData(vtk_image);
#endif
flipFilter->Update(); flipFilter->Update();
Vec3d plane_center(size.width * 0.5, size.height * 0.5, 0.0); Vec3d plane_center(size.width * 0.5, size.height * 0.5, 0.0);
...@@ -802,7 +838,11 @@ cv::viz::Image3DWidget::Image3DWidget(const Vec3f &position, const Vec3f &normal ...@@ -802,7 +838,11 @@ cv::viz::Image3DWidget::Image3DWidget(const Vec3f &position, const Vec3f &normal
// Need to flip the image as the coordinates are different in OpenCV and VTK // Need to flip the image as the coordinates are different in OpenCV and VTK
vtkSmartPointer<vtkImageFlip> flipFilter = vtkSmartPointer<vtkImageFlip>::New(); vtkSmartPointer<vtkImageFlip> flipFilter = vtkSmartPointer<vtkImageFlip>::New();
flipFilter->SetFilteredAxis(1); // Vertical flip flipFilter->SetFilteredAxis(1); // Vertical flip
#if VTK_MAJOR_VERSION <= 5
flipFilter->SetInputConnection(vtk_image->GetProducerPort()); flipFilter->SetInputConnection(vtk_image->GetProducerPort());
#else
flipFilter->SetInputData(vtk_image);
#endif
flipFilter->Update(); flipFilter->Update();
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New(); vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New();
...@@ -875,7 +915,11 @@ void cv::viz::Image3DWidget::setImage(const Mat &image) ...@@ -875,7 +915,11 @@ void cv::viz::Image3DWidget::setImage(const Mat &image)
// Need to flip the image as the coordinates are different in OpenCV and VTK // Need to flip the image as the coordinates are different in OpenCV and VTK
vtkSmartPointer<vtkImageFlip> flipFilter = vtkSmartPointer<vtkImageFlip>::New(); vtkSmartPointer<vtkImageFlip> flipFilter = vtkSmartPointer<vtkImageFlip>::New();
flipFilter->SetFilteredAxis(1); // Vertical flip flipFilter->SetFilteredAxis(1); // Vertical flip
#if VTK_MAJOR_VERSION <= 5
flipFilter->SetInputConnection(vtk_image->GetProducerPort()); flipFilter->SetInputConnection(vtk_image->GetProducerPort());
#else
flipFilter->SetInputData(vtk_image);
#endif
flipFilter->Update(); flipFilter->Update();
// Apply the texture // Apply the texture
...@@ -915,7 +959,11 @@ struct cv::viz::CameraPositionWidget::ProjectImage ...@@ -915,7 +959,11 @@ struct cv::viz::CameraPositionWidget::ProjectImage
// Need to flip the image as the coordinates are different in OpenCV and VTK // Need to flip the image as the coordinates are different in OpenCV and VTK
vtkSmartPointer<vtkImageFlip> flipFilter = vtkSmartPointer<vtkImageFlip>::New(); vtkSmartPointer<vtkImageFlip> flipFilter = vtkSmartPointer<vtkImageFlip>::New();
flipFilter->SetFilteredAxis(1); // Vertical flip flipFilter->SetFilteredAxis(1); // Vertical flip
#if VTK_MAJOR_VERSION <= 5
flipFilter->SetInputConnection(vtk_image->GetProducerPort()); flipFilter->SetInputConnection(vtk_image->GetProducerPort());
#else
flipFilter->SetInputData(vtk_image);
#endif
flipFilter->Update(); flipFilter->Update();
Vec3d plane_center(0.0, 0.0, scale); Vec3d plane_center(0.0, 0.0, scale);
...@@ -962,7 +1010,7 @@ struct cv::viz::CameraPositionWidget::ProjectImage ...@@ -962,7 +1010,7 @@ struct cv::viz::CameraPositionWidget::ProjectImage
frustumSource->Update(); frustumSource->Update();
vtkSmartPointer<vtkExtractEdges> filter = vtkSmartPointer<vtkExtractEdges>::New(); vtkSmartPointer<vtkExtractEdges> filter = vtkSmartPointer<vtkExtractEdges>::New();
filter->SetInput(frustumSource->GetOutput()); filter->SetInputConnection(frustumSource->GetOutputPort());
filter->Update(); filter->Update();
// Frustum needs to be textured or else it can't be combined with image // Frustum needs to be textured or else it can't be combined with image
...@@ -1000,17 +1048,25 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(double scale) ...@@ -1000,17 +1048,25 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(double scale)
axes_colors->InsertNextValue(1.0); axes_colors->InsertNextValue(1.0);
vtkSmartPointer<vtkPolyData> axes_data = axes->GetOutput(); vtkSmartPointer<vtkPolyData> axes_data = axes->GetOutput();
#if VTK_MAJOR_VERSION <= 5
axes_data->Update(); axes_data->Update();
#else
axes->Update();
#endif
axes_data->GetPointData()->SetScalars(axes_colors); axes_data->GetPointData()->SetScalars(axes_colors);
vtkSmartPointer<vtkTubeFilter> axes_tubes = vtkSmartPointer<vtkTubeFilter>::New(); vtkSmartPointer<vtkTubeFilter> axes_tubes = vtkSmartPointer<vtkTubeFilter>::New();
#if VTK_MAJOR_VERSION <= 5
axes_tubes->SetInput(axes_data); axes_tubes->SetInput(axes_data);
#else
axes_tubes->SetInputData(axes_data);
#endif
axes_tubes->SetRadius(axes->GetScaleFactor() / 50.0); axes_tubes->SetRadius(axes->GetScaleFactor() / 50.0);
axes_tubes->SetNumberOfSides(6); axes_tubes->SetNumberOfSides(6);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetScalarModeToUsePointData(); mapper->SetScalarModeToUsePointData();
mapper->SetInput(axes_tubes->GetOutput()); mapper->SetInputConnection(axes_tubes->GetOutputPort());
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New(); vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -1046,11 +1102,11 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(const Matx33f &K, double sca ...@@ -1046,11 +1102,11 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(const Matx33f &K, double sca
frustumSource->Update(); frustumSource->Update();
vtkSmartPointer<vtkExtractEdges> filter = vtkSmartPointer<vtkExtractEdges>::New(); vtkSmartPointer<vtkExtractEdges> filter = vtkSmartPointer<vtkExtractEdges>::New();
filter->SetInput(frustumSource->GetOutput()); filter->SetInputConnection(frustumSource->GetOutputPort());
filter->Update(); filter->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInput(filter->GetOutput()); mapper->SetInputConnection(filter->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -1085,11 +1141,11 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(const Vec2f &fov, double sca ...@@ -1085,11 +1141,11 @@ cv::viz::CameraPositionWidget::CameraPositionWidget(const Vec2f &fov, double sca
// Extract the edges so we have the grid // Extract the edges so we have the grid
vtkSmartPointer<vtkExtractEdges> filter = vtkSmartPointer<vtkExtractEdges>::New(); vtkSmartPointer<vtkExtractEdges> filter = vtkSmartPointer<vtkExtractEdges>::New();
filter->SetInput(frustumSource->GetOutput()); filter->SetInputConnection(frustumSource->GetOutputPort());
filter->Update(); filter->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInput(filter->GetOutput()); mapper->SetInputConnection(filter->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -1151,7 +1207,11 @@ struct cv::viz::TrajectoryWidget::ApplyPath ...@@ -1151,7 +1207,11 @@ struct cv::viz::TrajectoryWidget::ApplyPath
transform->SetMatrix(mat_trans); transform->SetMatrix(mat_trans);
vtkSmartPointer<vtkTransformPolyDataFilter> filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New(); vtkSmartPointer<vtkTransformPolyDataFilter> filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
#if VTK_MAJOR_VERSION <= 5
filter->SetInput(new_data); filter->SetInput(new_data);
#else
filter->SetInputData(new_data);
#endif
filter->SetTransform(transform); filter->SetTransform(transform);
filter->Update(); filter->Update();
...@@ -1202,7 +1262,11 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector<Affine3f> &path, i ...@@ -1202,7 +1262,11 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector<Affine3f> &path, i
colors->FillComponent(2, color[0]); colors->FillComponent(2, color[0]);
polyData->GetPointData()->SetScalars(colors); polyData->GetPointData()->SetScalars(colors);
#if VTK_MAJOR_VERSION <= 5
appendFilter->AddInputConnection(polyData->GetProducerPort()); appendFilter->AddInputConnection(polyData->GetProducerPort());
#else
appendFilter->AddInputData(polyData);
#endif
} }
if ((~display_mode & 3) ^ TrajectoryWidget::DISPLAY_FRAMES) if ((~display_mode & 3) ^ TrajectoryWidget::DISPLAY_FRAMES)
...@@ -1222,11 +1286,19 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector<Affine3f> &path, i ...@@ -1222,11 +1286,19 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector<Affine3f> &path, i
axes_colors->InsertNextTuple3(0,0,255); axes_colors->InsertNextTuple3(0,0,255);
vtkSmartPointer<vtkPolyData> axes_data = axes->GetOutput(); vtkSmartPointer<vtkPolyData> axes_data = axes->GetOutput();
#if VTK_MAJOR_VERSION <= 5
axes_data->Update(); axes_data->Update();
#else
axes->Update();
#endif
axes_data->GetPointData()->SetScalars(axes_colors); axes_data->GetPointData()->SetScalars(axes_colors);
vtkSmartPointer<vtkTubeFilter> axes_tubes = vtkSmartPointer<vtkTubeFilter>::New(); vtkSmartPointer<vtkTubeFilter> axes_tubes = vtkSmartPointer<vtkTubeFilter>::New();
#if VTK_MAJOR_VERSION <= 5
axes_tubes->SetInput(axes_data); axes_tubes->SetInput(axes_data);
#else
axes_tubes->SetInputData(axes_data);
#endif
axes_tubes->SetRadius(axes->GetScaleFactor() / 50.0); axes_tubes->SetRadius(axes->GetScaleFactor() / 50.0);
axes_tubes->SetNumberOfSides(6); axes_tubes->SetNumberOfSides(6);
axes_tubes->Update(); axes_tubes->Update();
...@@ -1236,7 +1308,7 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector<Affine3f> &path, i ...@@ -1236,7 +1308,7 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector<Affine3f> &path, i
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetScalarModeToUsePointData(); mapper->SetScalarModeToUsePointData();
mapper->SetInput(appendFilter->GetOutput()); mapper->SetInputConnection(appendFilter->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -1272,14 +1344,14 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector<Affine3f> &path, c ...@@ -1272,14 +1344,14 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector<Affine3f> &path, c
// Extract the edges // Extract the edges
vtkSmartPointer<vtkExtractEdges> filter = vtkSmartPointer<vtkExtractEdges>::New(); vtkSmartPointer<vtkExtractEdges> filter = vtkSmartPointer<vtkExtractEdges>::New();
filter->SetInput(frustumSource->GetOutput()); filter->SetInputConnection(frustumSource->GetOutputPort());
filter->Update(); filter->Update();
vtkSmartPointer<vtkAppendPolyData> appendFilter = vtkSmartPointer<vtkAppendPolyData>::New(); vtkSmartPointer<vtkAppendPolyData> appendFilter = vtkSmartPointer<vtkAppendPolyData>::New();
ApplyPath::applyPath(filter->GetOutput(), appendFilter, path); ApplyPath::applyPath(filter->GetOutput(), appendFilter, path);
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInput(appendFilter->GetOutput()); mapper->SetInputConnection(appendFilter->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -1312,14 +1384,14 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector<Affine3f> &path, c ...@@ -1312,14 +1384,14 @@ cv::viz::TrajectoryWidget::TrajectoryWidget(const std::vector<Affine3f> &path, c
// Extract the edges // Extract the edges
vtkSmartPointer<vtkExtractEdges> filter = vtkSmartPointer<vtkExtractEdges>::New(); vtkSmartPointer<vtkExtractEdges> filter = vtkSmartPointer<vtkExtractEdges>::New();
filter->SetInput(frustumSource->GetOutput()); filter->SetInputConnection(frustumSource->GetOutputPort());
filter->Update(); filter->Update();
vtkSmartPointer<vtkAppendPolyData> appendFilter = vtkSmartPointer<vtkAppendPolyData>::New(); vtkSmartPointer<vtkAppendPolyData> appendFilter = vtkSmartPointer<vtkAppendPolyData>::New();
ApplyPath::applyPath(filter->GetOutput(), appendFilter, path); ApplyPath::applyPath(filter->GetOutput(), appendFilter, path);
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInput(appendFilter->GetOutput()); mapper->SetInputConnection(appendFilter->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
...@@ -1410,7 +1482,7 @@ cv::viz::SpheresTrajectoryWidget::SpheresTrajectoryWidget(const std::vector<Affi ...@@ -1410,7 +1482,7 @@ cv::viz::SpheresTrajectoryWidget::SpheresTrajectoryWidget(const std::vector<Affi
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetScalarModeToUseCellData(); mapper->SetScalarModeToUseCellData();
mapper->SetInput(appendFilter->GetOutput()); mapper->SetInputConnection(appendFilter->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
......
...@@ -325,7 +325,11 @@ void cv::viz::Viz3d::VizImpl::createActorFromVTKDataSet(const vtkSmartPointer<vt ...@@ -325,7 +325,11 @@ void cv::viz::Viz3d::VizImpl::createActorFromVTKDataSet(const vtkSmartPointer<vt
actor = vtkSmartPointer<vtkLODActor>::New(); actor = vtkSmartPointer<vtkLODActor>::New();
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
#if VTK_MAJOR_VERSION <= 5
mapper->SetInput(data); mapper->SetInput(data);
#else
mapper->SetInputData(data);
#endif
if (use_scalars) if (use_scalars)
{ {
......
...@@ -369,9 +369,13 @@ namespace cv ...@@ -369,9 +369,13 @@ namespace cv
{ {
// Create the vtk image // Create the vtk image
output->SetDimensions(image.cols, image.rows, 1); output->SetDimensions(image.cols, image.rows, 1);
#if VTK_MAJOR_VERSION <= 5
output->SetNumberOfScalarComponents(image.channels()); output->SetNumberOfScalarComponents(image.channels());
output->SetScalarTypeToUnsignedChar(); output->SetScalarTypeToUnsignedChar();
output->AllocateScalars(); output->AllocateScalars();
#else
output->AllocateScalars(VTK_UNSIGNED_CHAR, image.channels());
#endif
int i_chs = image.channels(); int i_chs = image.channels();
if (i_chs > 1) if (i_chs > 1)
......
...@@ -93,7 +93,11 @@ cv::viz::Widget cv::viz::Widget::fromPlyFile(const String &file_name) ...@@ -93,7 +93,11 @@ cv::viz::Widget cv::viz::Widget::fromPlyFile(const String &file_name)
vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New(); vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New(); vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
#if VTK_MAJOR_VERSION <= 5
mapper->SetInput(data); mapper->SetInput(data);
#else
mapper->SetInputData(data);
#endif
vtkSmartPointer<vtkDataArray> scalars = data->GetPointData()->GetScalars(); vtkSmartPointer<vtkDataArray> scalars = data->GetPointData()->GetScalars();
if (scalars) if (scalars)
...@@ -183,9 +187,13 @@ void cv::viz::Widget::setRenderingProperty(int property, double value) ...@@ -183,9 +187,13 @@ void cv::viz::Widget::setRenderingProperty(int property, double value)
if (!actor->GetMapper()->GetInput()->GetPointData()->GetNormals()) if (!actor->GetMapper()->GetInput()->GetPointData()->GetNormals())
{ {
vtkSmartPointer<vtkPolyDataNormals> normals = vtkSmartPointer<vtkPolyDataNormals>::New(); vtkSmartPointer<vtkPolyDataNormals> normals = vtkSmartPointer<vtkPolyDataNormals>::New();
#if VTK_MAJOR_VERSION <= 5
normals->SetInput(actor->GetMapper()->GetInput()); normals->SetInput(actor->GetMapper()->GetInput());
#else
normals->SetInputData(actor->GetMapper()->GetInput());
#endif
normals->Update(); normals->Update();
vtkDataSetMapper::SafeDownCast(actor->GetMapper())->SetInput(normals->GetOutput()); vtkDataSetMapper::SafeDownCast(actor->GetMapper())->SetInputConnection(normals->GetOutputPort());
} }
actor->GetProperty()->SetInterpolationToGouraud(); actor->GetProperty()->SetInterpolationToGouraud();
break; break;
...@@ -195,9 +203,13 @@ void cv::viz::Widget::setRenderingProperty(int property, double value) ...@@ -195,9 +203,13 @@ void cv::viz::Widget::setRenderingProperty(int property, double value)
if (!actor->GetMapper()->GetInput()->GetPointData()->GetNormals()) if (!actor->GetMapper()->GetInput()->GetPointData()->GetNormals())
{ {
vtkSmartPointer<vtkPolyDataNormals> normals = vtkSmartPointer<vtkPolyDataNormals>::New(); vtkSmartPointer<vtkPolyDataNormals> normals = vtkSmartPointer<vtkPolyDataNormals>::New();
#if VTK_MAJOR_VERSION <= 5
normals->SetInput(actor->GetMapper()->GetInput()); normals->SetInput(actor->GetMapper()->GetInput());
#else
normals->SetInputData(actor->GetMapper()->GetInput());
#endif
normals->Update(); normals->Update();
vtkDataSetMapper::SafeDownCast(actor->GetMapper())->SetInput(normals->GetOutput()); vtkDataSetMapper::SafeDownCast(actor->GetMapper())->SetInputConnection(normals->GetOutputPort());
} }
actor->GetProperty()->SetInterpolationToPhong(); actor->GetProperty()->SetInterpolationToPhong();
break; break;
......
...@@ -74,7 +74,11 @@ TriangleWidget::TriangleWidget(const Point3f &pt1, const Point3f &pt2, const Poi ...@@ -74,7 +74,11 @@ TriangleWidget::TriangleWidget(const Point3f &pt1, const Point3f &pt2, const Poi
// Create mapper and actor // Create mapper and actor
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
#if VTK_MAJOR_VERSION <= 5
mapper->SetInput(polyData); mapper->SetInput(polyData);
#else
mapper->SetInputData(polyData);
#endif
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper); actor->SetMapper(mapper);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment