simplification of cloud collection

This commit is contained in:
Anatoly Baksheev 2014-01-11 16:44:01 +04:00
parent e3ff28dacc
commit f930f2f19d
2 changed files with 8 additions and 10 deletions

View File

@ -112,15 +112,8 @@ void cv::viz::WCloudCollection::addCloud(InputArray cloud, InputArray colors, co
vtkSmartPointer<vtkCloudMatSource> source = vtkSmartPointer<vtkCloudMatSource>::New(); vtkSmartPointer<vtkCloudMatSource> source = vtkSmartPointer<vtkCloudMatSource>::New();
source->SetColorCloud(cloud, colors); source->SetColorCloud(cloud, colors);
vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New(); vtkSmartPointer<vtkPolyData> polydata = VtkUtils::TransformPolydata(source->GetOutputPort(), pose);
transform->SetMatrix(pose.matrix.val);
vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
transform_filter->SetInputConnection(source->GetOutputPort());
transform_filter->SetTransform(transform);
transform_filter->Update();
vtkSmartPointer<vtkPolyData> polydata = transform_filter->GetOutput();
vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this)); vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this));
CV_Assert("Incompatible widget type." && actor); CV_Assert("Incompatible widget type." && actor);

View File

@ -256,17 +256,22 @@ namespace cv
return normals_generator->GetOutput(); return normals_generator->GetOutput();
} }
static vtkSmartPointer<vtkPolyData> TransformPolydata(vtkSmartPointer<vtkPolyData> polydata, const Affine3d& pose) static vtkSmartPointer<vtkPolyData> TransformPolydata(vtkSmartPointer<vtkAlgorithmOutput> algorithm_output_port, const Affine3d& pose)
{ {
vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New(); vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
transform->SetMatrix(vtkmatrix(pose.matrix)); transform->SetMatrix(vtkmatrix(pose.matrix));
vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New(); vtkSmartPointer<vtkTransformPolyDataFilter> transform_filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
transform_filter->SetTransform(transform); transform_filter->SetTransform(transform);
transform_filter->SetInputConnection(polydata->GetProducerPort()); transform_filter->SetInputConnection(algorithm_output_port);
transform_filter->Update(); transform_filter->Update();
return transform_filter->GetOutput(); return transform_filter->GetOutput();
} }
static vtkSmartPointer<vtkPolyData> TransformPolydata(vtkSmartPointer<vtkPolyData> polydata, const Affine3d& pose)
{
return TransformPolydata(polydata->GetProducerPort(), pose);
}
}; };
} }
} }