[vtkusers] How to read and visualize ".ply" file in VTK using C++ 2008
S. Akter
s_lina_cse at yahoo.com
Wed Jul 27 02:48:42 EDT 2011
Hello Everybody
I'm new to VTK and I'm working on a project that needs to read “.ply”
files. I test the following example taken from website that read “.ply” file in
visual c++ 2008 express edition. The program build and debug successfully but visualize
nothing. What are the wrong? I could not understand.
The following are the program code:
#include <vtkPolyData.h>
#include <vtkPLYReader.h>
#include <vtkSmartPointer.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
int main ( int argc, char *argv[]
)
{
// Verify input arguments
if(argc != 2)
{
std::cout << "Usage: " << argv[0] << "trucks.ply" << std::endl;
return EXIT_FAILURE;
}
std::string
inputFilename = argv[1];
vtkSmartPointer<vtkPLYReader> reader =
vtkSmartPointer<vtkPLYReader>::New();
reader->SetFileName ( inputFilename.c_str() );
// Visualize
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(reader->GetOutputPort());
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
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(0.1804,0.5451,0.3412); // Sea green
renderWindow->Render();
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}
After build I get the following output:
1>------ Build started: Project: ReadPLY, Configuration:
Debug Win32 ------
1>Compiling...
1>ReadPLY.cpp
1>Linking...
1>Embedding manifest...
1>Build log was saved at
"file://c:\VTK\Project\ReadPLY\binary\ReadPLY.dir\Debug\BuildLog.htm"
1>ReadPLY - 0 error(s), 0 warning(s)
2>------ Skipped Build: Project: ALL_BUILD, Configuration:
Debug Win32 ------
2>Project not selected to build for this solution
configuration
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 1
skipped ==========
After debugging I get the following output, but don’t
visualize anything
'ReadPLY.exe': Loaded
'C:\VTK\Project\ReadPLY\binary\Debug\ReadPLY.exe', Symbols loaded.
'ReadPLY.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
'ReadPLY.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
'ReadPLY.exe': Loaded 'C:\WINDOWS\system32\opengl32.dll'
'ReadPLY.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll'
'ReadPLY.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll'
'ReadPLY.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll'
'ReadPLY.exe': Loaded 'C:\WINDOWS\system32\secur32.dll'
'ReadPLY.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll'
'ReadPLY.exe': Loaded 'C:\WINDOWS\system32\user32.dll'
'ReadPLY.exe': Loaded 'C:\WINDOWS\system32\glu32.dll'
'ReadPLY.exe': Loaded 'C:\WINDOWS\system32\ddraw.dll'
'ReadPLY.exe': Loaded 'C:\WINDOWS\system32\dciman32.dll'
'ReadPLY.exe': Loaded
'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcp90d.dll'
'ReadPLY.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcr90d.dll'
'ReadPLY.exe': Loaded 'C:\WINDOWS\system32\imm32.dll'
'ReadPLY.exe': Loaded 'C:\WINDOWS\system32\lpk.dll'
'ReadPLY.exe': Loaded 'C:\WINDOWS\system32\usp10.dll'
The program '[2596]
ReadPLY.exe: Native' has exited with code 1 (0x1).
Thank you in
advance for any help or suggestions.
Regards
Salena
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110726/7d171799/attachment.htm>
More information about the vtkusers
mailing list