[vtkusers] Surface Rendering from point set.
Alex Liu
tehsunnliu at yahoo.com
Mon Nov 21 03:36:56 EST 2016
Hello World!
I'm working on a project in which I'm given DICOM files. I've extracted the
DICOM images to openCV.
>From openCV I've extracted Points for each DICOM Image/Slice. I'm trying to
construct a 3D view of the detected face Points. As I'm new to VTK I'm
facing some problems.
I've Points(x,y,z) for all the images right now. and I can display the
points on the screen, please see the attachment.
Point Cloud Face
<http://vtk.1045678.n5.nabble.com/file/n5741245/Point_Cloud_Face.png>
Right now I want to calculate Normals for all the points with Normals facing
out from the face. In MeshLab there is a function to calculate Normals for
points set. And i get this result
MeshLab Point set Normals
<http://vtk.1045678.n5.nabble.com/file/n5741245/MeshLab_Points_With_Normals.png>
My Code.
vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
polyData->SetPoints(vtkPts); // vtkPts contains all the points in x, y, z
of the face.
vtkSmartPointer<vtkVertexGlyphFilter> glyphFilter =
vtkSmartPointer<vtkVertexGlyphFilter>::New();
glyphFilter->SetInputData(polyData);
glyphFilter->Update();
// Im not sure here if Im using the right function to calculate Points
Normals
// But I get the same output in blue as in attached image
MeshLab_Points_With_Normals.png
vtkSmartPointer<vtkPolyDataNormals> polyDataNormals =
vtkSmartPointer<vtkPolyDataNormals>::New();
polyDataNormals->SetInputConnection(glyphFilter->GetOutputPort());
polyDataNormals->FlipNormalsOff();
polyDataNormals->ComputePointNormalsOn();
polyDataNormals->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(glyphFilter->GetOutputPort());
// Display image
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(glyphFilter->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetColor(0.0, 0.0, 0.9); //(R,G,B)
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(actor);
renderer->SetBackground(0.9, 0.9, 0.9); // Background color Gray
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
renderWindow->SetPosition(400, 200);
renderWindow->SetSize(612, 612);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
renderWindowInteractor->Start();
I'm trying to get output like in MeshLab, with a smooth surface.
Help will be really appreciated.
Thank you.
Alex
-----
Alex Liu
+15574855474
--
View this message in context: http://vtk.1045678.n5.nabble.com/Surface-Rendering-from-point-set-tp5741245.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list