Vtk point cloud important

2,333 views

Published on

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

Vtk point cloud important

  1. 1. Wiki3DVision ForumGeneral Category => 3D Reconstruction => Topic started by:dashan on July 19, 2010, 05:25:15 PMTitle: How I display 3D model using imported point clouddata with VTKPost by: dashan on July 19, 2010, 05:25:15 PMStep 1: vtkRenderWindow *renWin = vtkRenderWindow::New(); vtkRenderWindowInteractor *iren =vtkRenderWindowInteractor::New(); iren->SetRenderWindow(renWin);Step 2: Input Point Cloud FILE *stream; if( (stream = fopen( "c:pointcloud.txt", "r" )) == NULL ) { printf( "The file data.txt was not openedn" ); // return; } fscanf(stream,"%d", &num); for(int i=0;i<num;i++){ //fscanf(stream,"%f %f %f %d %d %d", &tmpdata[0],&tmpdata[1],&tmpdata[2], &tmpcol[0], &tmpcol[1],&tmpcol[2]);//with color fscanf(stream,"%f %f %f", &tmpdata[0],&tmpdata[1],&tmpdata[2]);//without color mypoint_1[0]=tmpdata[0];
  2. 2. mypoint_1[1]=tmpdata[1]; mypoint_1[2]=tmpdata[2]; //colors->InsertNextTuple3(tmpcol[0], tmpcol[1],tmpcol[2]); cloud_1->InsertNextPoint(mypoint_1); } fclose(stream);Step 3: vtkPolyData* polydata_1 = vtkPolyData::New(); polydata_1->SetPoints(cloud_1);Step 4: Build mesh vtkDelaunay2D* del2d_1 = vtkDelaunay2D::New(); del2d_1->SetInput((vtkPointSet*)polydata_1); del2d_1->SetTolerance(0.005); del2d_1->Update();Step 5: vtkRenderer* ren_surf = vtkRenderer::New(); // create a render ren_surf->SetBackground(0.475, 0.722, 0.15); renWin->AddRenderer(ren_surf); // bind render with a renderwindow vtkDataSetMapper* mapper = vtkDataSetMapper::New(); mapper->SetInput(del2d_1->GetOutput()); vtkActor* act = vtkActor::New(); act->SetMapper(mapper); ren_surf->AddActor(act); renWin->SetSize(800, 600); iren->Initialize();
  3. 3. iren->Start(); renWin->Render();Completed! The dispay image is attached below. Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC

×