[vtkusers] VTK render coordinates

kenichiro yoshimi rccm.kyoshimi at gmail.com
Mon Jun 19 22:29:06 EDT 2017


Hi Randall,

Are plane parameters A, B, C and D in an equation Ax + By + Cz + D =
0? In that case, solving equality for z looks incorrect.

Thanks,
yoshimi

2017-06-20 7:49 GMT+09:00 Toepfer, Randall <randall at scandy.co>:
> I have a mesh in vtk.  I created a function to convert the mesh to point
> cloud library pcl::PointCloud.
>
> int vtk2pcl(vtkPolyData* poly_data, pcl::PointCloud<pcl::PointXYZ>::Ptr&
> pcl_cloud)
> {
>   pcl_cloud->clear();
>
>   vtkSmartPointer<vtkPoints> mesh_points = poly_data->GetPoints();
>   vtkIdType nr_points = mesh_points->GetNumberOfPoints();
>   if (nr_points == 0)
>     return 0;
>
>   pcl_cloud->points.resize(nr_points);
>   double point_xyz[3];
>   for (vtkIdType i = 0; i < mesh_points->GetNumberOfPoints(); ++i)
>   {
>     mesh_points->GetPoint(i, &point_xyz[0]);
>     pcl_cloud->points[i].x = static_cast<float>(point_xyz[0]);
>     pcl_cloud->points[i].y = static_cast<float>(point_xyz[1]);
>     pcl_cloud->points[i].z = static_cast<float>(point_xyz[2]);
>   }
>   pcl_cloud->width = static_cast<uint32_t>(pcl_cloud->points.size());
>   pcl_cloud->height = 1;
>   pcl_cloud->is_dense = true;
>
>   return (static_cast<int>(nr_points));
> }
>
> I then use this point cloud in PCL's segmentation methods to find planes in
> my mesh.
>
> If I compare the bounds and centroid of my mesh to my point cloud - both are
> equal.
>
> I display the planes in VTK:
>
> auto A = plane[0];
> auto B = plane[1];
> auto C = plane[2];
> auto D = plane[3];
> double z = (-1 * D) / (-1 * ((A * min_x) + (B * 1)) * C);
> plane_source->SetCenter(min_x, 1, z);
> z = (-1 * D) / (-1 * ((A * min_x) + (B * max_y)) * C);
> plane_source->SetPoint1(min_x, max_y, z);
> z = (-1 * D) / (-1 * ((A * max_x) + (B * max_y)) * C);
> plane_source->SetPoint2(max_x, max_y, z);
>
> plane_source->Update();
>
> vtkPolyData* vtk_plane = plane_source->GetOutput();
> // Create a mapper and actor
> vtkSmartPointer<vtkPolyDataMapper> mapper =
> vtkSmartPointer<vtkPolyDataMapper>::New();
> mapper->SetInputData(vtk_plane);
> vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
> actor->SetMapper(mapper);
>
>
> I display the mesh in VTK:
>
> // vtkPolyData* mesh ....
> auto mesh_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
> mesh_mapper->SetInputData(mesh);
> auto mesh_actor = vtkSmartPointer<vtkActor>::New();
> mesh_actor->SetMapper(mesh_mapper.GetPointer());
>
> renderer->AddActor(mesh_actor);
>
>
> VTK shows my planes but the mesh and planes aren't aligned correctly.
> Shouldn't they be aligned since my bounds and centroid are equal?  How do
> they get unaligned?
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>


More information about the vtkusers mailing list