filter->SetInputData(polydata);
#endif
}
+ template<class Filter>
+ static void SetSourceData(vtkSmartPointer<Filter> filter, vtkPolyData* polydata)
+ {
+ #if VTK_MAJOR_VERSION <= 5
+ filter->SetSource(polydata);
+ #else
+ filter->SetSourceData(polydata);
+ #endif
+ }
+
+ template<class Filter>
+ static void SetInputData(vtkSmartPointer<Filter> filter, vtkImageData* polydata)
+ {
+ #if VTK_MAJOR_VERSION <= 5
+ filter->SetInput(polydata);
+ #else
+ filter->SetInputData(polydata);
+ #endif
+ }
template<class Filter>
static void AddInputData(vtkSmartPointer<Filter> filter, vtkPolyData *polydata)
static vtkSmartPointer<vtkPolyData> TransformPolydata(vtkSmartPointer<vtkPolyData> polydata, const Affine3d& pose)
{
- return TransformPolydata(polydata->GetProducerPort(), pose);
+ vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
+ transform->SetMatrix(vtkmatrix(pose.matrix));
+
+ vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
+ VtkUtils::SetInputData(transform_filter, polydata);
+ transform_filter->SetTransform(transform);
+ transform_filter->Update();
+ return transform_filter->GetOutput();
}
};
}
polydata->GetPointData()->SetScalars(colors);
vtkSmartPointer<vtkTubeFilter> tube_filter = vtkSmartPointer<vtkTubeFilter>::New();
- tube_filter->SetInputConnection(polydata->GetProducerPort());
+ VtkUtils::SetInputData(tube_filter, polydata);
tube_filter->SetRadius(axes->GetScaleFactor() / 50.0);
tube_filter->SetNumberOfSides(6);
tube_filter->Update();
// Extract the edges so we have the grid
vtkSmartPointer<vtkExtractEdges> extract_edges = vtkSmartPointer<vtkExtractEdges>::New();
- extract_edges->SetInputConnection(grid_data->GetProducerPort());
+ VtkUtils::SetInputData(extract_edges, grid_data);
extract_edges->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
// Frustum needs to be textured or else it can't be combined with image
vtkSmartPointer<vtkTextureMapToPlane> frustum_texture = vtkSmartPointer<vtkTextureMapToPlane>::New();
- frustum_texture->SetInputConnection(frustum->GetProducerPort());
+ VtkUtils::SetInputData(frustum_texture, frustum);
frustum_texture->SetSRange(0.0, 0.0); // Texture mapping with only one pixel
frustum_texture->SetTRange(0.0, 0.0); // from the image to have constant color
vtkSmartPointer<vtkAppendPolyData> append_filter = vtkSmartPointer<vtkAppendPolyData>::New();
append_filter->AddInputConnection(frustum_texture->GetOutputPort());
- append_filter->AddInputConnection(plane->GetProducerPort());
+ VtkUtils::AddInputData(append_filter, plane);
vtkSmartPointer<vtkActor> actor = getActor(image_widget);
actor->GetMapper()->SetInputConnection(append_filter->GetOutputPort());
// Frustum needs to be textured or else it can't be combined with image
vtkSmartPointer<vtkTextureMapToPlane> frustum_texture = vtkSmartPointer<vtkTextureMapToPlane>::New();
- frustum_texture->SetInputConnection(frustum->GetProducerPort());
+ VtkUtils::SetInputData(frustum_texture, frustum);
frustum_texture->SetSRange(0.0, 0.0); // Texture mapping with only one pixel
frustum_texture->SetTRange(0.0, 0.0); // from the image to have constant color
vtkSmartPointer<vtkAppendPolyData> append_filter = vtkSmartPointer<vtkAppendPolyData>::New();
append_filter->AddInputConnection(frustum_texture->GetOutputPort());
- append_filter->AddInputConnection(plane->GetProducerPort());
+ VtkUtils::AddInputData(append_filter, plane);
vtkSmartPointer<vtkActor> actor = getActor(image_widget);
actor->GetMapper()->SetInputConnection(append_filter->GetOutputPort());
{
Mat points = vtkTrajectorySource::ExtractPoints(_path);
vtkSmartPointer<vtkPolyData> polydata = getPolyData(WPolyLine(points, color));
- append_filter->AddInputConnection(polydata->GetProducerPort());
+ VtkUtils::AddInputData(append_filter, polydata);
}
if (display_mode & WTrajectory::FRAMES)
vtkSmartPointer<vtkTensorGlyph> tensor_glyph = vtkSmartPointer<vtkTensorGlyph>::New();
tensor_glyph->SetInputConnection(source->GetOutputPort());
- tensor_glyph->SetSourceConnection(glyph->GetProducerPort());
+ VtkUtils::SetSourceData(tensor_glyph, glyph);
tensor_glyph->ExtractEigenvaluesOff(); // Treat as a rotation matrix, not as something with eigenvalues
tensor_glyph->ThreeGlyphsOff();
tensor_glyph->SymmetricOff();
vtkSmartPointer<vtkTensorGlyph> tensor_glyph = vtkSmartPointer<vtkTensorGlyph>::New();
tensor_glyph->SetInputConnection(source->GetOutputPort());
- tensor_glyph->SetSourceConnection(glyph->GetProducerPort());
+ VtkUtils::SetSourceData(tensor_glyph, glyph);
tensor_glyph->ExtractEigenvaluesOff(); // Treat as a rotation matrix, not as something with eigenvalues
tensor_glyph->ThreeGlyphsOff();
tensor_glyph->SymmetricOff();
vtkSmartPointer<vtkTensorGlyph> tensor_glyph = vtkSmartPointer<vtkTensorGlyph>::New();
tensor_glyph->SetInputConnection(source->GetOutputPort());
- tensor_glyph->SetSourceConnection(glyph->GetProducerPort());
+ VtkUtils::SetSourceData(tensor_glyph, glyph);
tensor_glyph->ExtractEigenvaluesOff(); // Treat as a rotation matrix, not as something with eigenvalues
tensor_glyph->ThreeGlyphsOff();
tensor_glyph->SymmetricOff();
vtkSmartPointer<vtkPolyData> polydata = sphere_source->GetOutput();
polydata->GetCellData()->SetScalars(VtkUtils::FillScalars(polydata->GetNumberOfCells(), c));
- append_filter->AddInputConnection(polydata->GetProducerPort());
+ VtkUtils::AddInputData(append_filter, polydata);
if (i > 0)
{
line_source->Update();
vtkSmartPointer<vtkPolyData> polydata = line_source->GetOutput();
polydata->GetCellData()->SetScalars(VtkUtils::FillScalars(polydata->GetNumberOfCells(), c));
- append_filter->AddInputConnection(polydata->GetProducerPort());
+ VtkUtils::AddInputData(append_filter, polydata);
}
}
append_filter->Update();
viz.setBackgroundMeshLab();
viz.showWidget("coosys", WCoordinateSystem());
viz.showWidget("cloud1", WPaintedCloud(cloud), Affine3d(Vec3d(0.0, -CV_PI/2, 0.0), Vec3d(-1.5, 0.0, 0.0)));
- viz.showWidget("cloud2", WPaintedCloud(cloud, Vec3d(0.0, 0.0, -1.0), Vec3d(0.0, 0.0, 1.0)), Affine3d(Vec3d(0.0, CV_PI/2, 0.0), Vec3d(1.5, 0.0, 0.0)));
+ viz.showWidget("cloud2", WPaintedCloud(cloud, Vec3d(0.0, -0.75, -1.0), Vec3d(0.0, 0.75, 0.0)), Affine3d(Vec3d(0.0, CV_PI/2, 0.0), Vec3d(1.5, 0.0, 0.0)));
viz.showWidget("cloud3", WPaintedCloud(cloud, Vec3d(0.0, 0.0, -1.0), Vec3d(0.0, 0.0, 1.0), Color::blue(), Color::red()));
viz.showWidget("arrow", WArrow(Vec3d(0.0, 1.0, -1.0), Vec3d(0.0, 1.0, 1.0), 0.009, Color::raspberry()));
viz.spin();