[vtkusers] Weird white edges while trying to convert point cloud to mesh
Franse
franz.berwein at groupion.com
Sat Jul 23 10:41:48 EDT 2011
Hallo fellow VTK users,
Recently I've been trying to learn VTK and so far I'm quite satisfied with
it. But now I have encountered a problem I cannot fix on my own and need
some help to do so.
As you can see from the attached screenshot, there are weird white edges on
the triangulated point cloud. Where do they come from and how can I get rid
of them?
Altogether I want to convert a XYZ point cloud to a mesh and view, alter and
the mesh as an STL file. As far as I know, the result of a Delaunay3D filter
is a triangulated point cloud a.k.a. an unstructured grid. How can I get to
a mesh from there? I would like to fill the holes in there. I am still a
little bewildered by the conversions between different formats in VTK. There
is an abundance of options to go, but finding the right one can be hard.
Thanks in advance for your help!
Franz
http://vtk.1045678.n5.nabble.com/file/n4626151/white_edges.jpg
My code so far looks like that:
#include <vtkSmartPointer.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkSimplePointsReader.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkProperty.h>
#include <vtkSTLWriter.h>
#include <vtkCleanPolyData.h>
#include <vtkDelaunay3D.h>
#include <vtkDataSetMapper.h>
#include <vtkFillHolesFilter.h>
#include <vtkWindowedSincPolyDataFilter.h>
int main(int argc, char* argv[])
{
// verify argument 2: <exe> <xyz file>
if ( argc != 2 )
{
std::cout << "Usage: " << argv[0]
<< " filename.asc" << std::endl;
return EXIT_FAILURE;
}
// read the file
vtkSmartPointer<vtkSimplePointsReader> reader =
vtkSmartPointer<vtkSimplePointsReader>::New();
reader->SetFileName(argv[1]);
reader->Update();
// visualization pipeline: mapper -> actor -> renderer
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(reader->GetOutputPort());
mapper->ScalarVisibilityOff();
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
//actor->GetProperty()->SetPointSize(1);//
actor->GetProperty()->SetColor(1,0,0);
// Clean the polydata. This will remove duplicate points that may be
// present in the input data.
vtkSmartPointer<vtkCleanPolyData> cleaner =
vtkSmartPointer<vtkCleanPolyData>::New();
cleaner->SetInputConnection (reader->GetOutputPort());
cleaner->SetTolerance(0.006);//0.007
cleaner->Update();
// Generate a tetrahedral mesh from the input points. By
// default, the generated volume is the convex hull of the points.
vtkSmartPointer<vtkDelaunay3D> delaunay3D =
vtkSmartPointer<vtkDelaunay3D>::New();
delaunay3D->SetInputConnection (cleaner->GetOutputPort());
delaunay3D->SetOffset(2.5);
delaunay3D->SetAlpha(0.6);
//delaunay3D->SetTolerance(0.001);
/*vtkSmartPointer<vtkFillHolesFilter> fillHolesFilter =
vtkSmartPointer<vtkFillHolesFilter>::New();
fillHolesFilter->SetInputConnection(delaunay3D->GetOutputPort());
//fillHolesFilter->set
fillHolesFilter->Update();*/
vtkSmartPointer<vtkDataSetMapper> delaunayMapper =
vtkSmartPointer<vtkDataSetMapper>::New();
delaunayMapper->SetInputConnection(delaunay3D->GetOutputPort());
vtkSmartPointer<vtkActor> delaunayActor =
vtkSmartPointer<vtkActor>::New();
delaunayActor->SetMapper(delaunayMapper);
delaunayActor->GetProperty()->SetInterpolationToPhong();
delaunayActor->GetProperty()->ShadingOn();
// Visualize
vtkSmartPointer<vtkRenderer> delaunayRenderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->SetSize(500,400);
renderWindow->AddRenderer(delaunayRenderer);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
delaunayRenderer->AddActor(delaunayActor);
delaunayRenderer->SetBackground(0.5, 0.5, 0.9);
// Render and interact
renderWindow->Render();
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}
--
View this message in context: http://vtk.1045678.n5.nabble.com/Weird-white-edges-while-trying-to-convert-point-cloud-to-mesh-tp4626151p4626151.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list