[vtkusers] View Surface

Nelson gnjoseph at gmail.com
Fri Feb 4 02:58:52 EST 2011


Hi All,

This code displays only the nodes. ( I have attached the screen shot ) How
can we view as a surface?

#include <vtkSmartPointer.h>
#include <vtkProperty.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkParticleReader.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkRenderer.h>
int main()
{

	// Read the file
	vtkSmartPointer<vtkParticleReader> reader =
vtkSmartPointer<vtkParticleReader>::New();
	reader->SetFileName ( "cube.txt" );
	reader->Update();
	std::cout << reader->GetOutput()->GetNumberOfCells() << std::endl;
	// Visualize
	vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
	mapper->SetInputConnection(reader->GetOutputPort());
	vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
	actor->SetMapper(mapper);
	actor->GetProperty()->SetPointSize(4);
	actor->GetProperty()->SetColor(1,0,0);
	vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
	vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
	renderWindow->AddRenderer(renderer);
	vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
	renderWindowInteractor->SetRenderWindow(renderWindow);
	renderer->AddActor(actor);
	renderer->SetBackground(.3, .6, .3); // Background color green
	
	vtkSmartPointer<vtkInteractorStyleTrackballCamera> style =
vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
	renderWindowInteractor->SetInteractorStyle( style );

	renderWindow->Render();
	renderWindowInteractor->Start();
	return EXIT_SUCCESS;
} http://vtk.1045678.n5.nabble.com/file/n3370577/sample.jpg 

-----
Best Regards,
Nelson
-- 
View this message in context: http://vtk.1045678.n5.nabble.com/View-Surface-tp3370577p3370577.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list