提交 dea2f165 编写于 作者: H Hordur Johannsson

Added a vtk viewer skeleton so that the glut dependency can be dropped in the...

Added a vtk viewer skeleton so that the glut dependency can be dropped in the range image simulation.

git-svn-id: svn+ssh://svn.pointclouds.org/pcl/trunk@3247 a9d63959-f2ad-4865-b262-bf0e56cfafb6
上级 8c3cca59
PCL_ADD_EXECUTABLE(range-test ${SUBSYS_NAME} range_test.cpp)
target_link_libraries(range-test pcl_common pcl_simulation pcl_io glut)
include_directories(${VTK_INCLUDE_DIRS})
PCL_ADD_EXECUTABLE(range-test-v2 ${SUBSYS_NAME} range_test_v2.cpp)
target_link_libraries (range-test-v2 ${VTK_IO_TARGET_LINK_LIBRARIES} glut
pcl_simulation pcl_common pcl_io pcl_range_image pcl_visualization)
#pcl_surface pcl_features
#add_executable(range-test-drive-pcl-version range_test_drive_pcl_version.cpp)
#pods_use_pkg_config_packages(range-test-drive-pcl-version
# pcl_simulation-1.4 pcl_io-1.4 )
#target_link_libraries (range-test-drive-pcl-version glut )
#pods_install_executables(range-test-drive-pcl-version)
PCL_ADD_EXECUTABLE(range_viewer ${SUBSYS_NAME} range_viewer.cpp)
target_link_libraries(range_viewer pcl_common pcl_io pcl_visualization)
......@@ -407,8 +407,8 @@ void load_PCDstack_model(const std::vector<std::string> & files)
{
std::cout << "Load model: " << *file << std::endl;
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>);
if (pcl::io::loadPCDFile<pcl::PointXYZRGB> (*file, *cloud) == -1) //* load the file
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBA>);
if (pcl::io::loadPCDFile<pcl::PointXYZRGBA> (*file, *cloud) == -1) //* load the file
{
PCL_ERROR ("Couldn't read file %s \n", file->c_str()) ;
exit (-1);
......@@ -457,15 +457,22 @@ void initialize(int argc, char** argv)
if (method==0){
cout << method << " pcd file stack\n";
cout << map_file << endl;
cout << "TODO: parse the file path from something like:\n";
cout << " /data/rgbd/freenect/2011_06_10_trolley/submaps_new/submap_0*\n";
printHelp (argc, argv);
exit(-1);
// printHelp (argc, argv);
// exit(-1);
// this used to work:
std::vector<std::string> files;
for (int i=1; i<argc; ++i) files.push_back(argv[i]);
}else if (method==1){
int map_arg_index = find_argument(argc, argv, "-map");
if (map_arg_index != -1) {
for (int i=map_arg_index+1; i<argc; ++i) files.push_back(argv[i]);
}
load_PCDstack_model(files);
} else if (method==1) {
//map_file = "/home/mfallon/data/models/obj_samples/teapot.obj";
cout << "About to read: " << map_file.c_str() << endl;
load_PolygonMesh_model(map_file);
......@@ -540,5 +547,5 @@ int main(int argc, char** argv)
glutMotionFunc(on_motion);
glutPassiveMotionFunc(on_passive_motion);
glutEntryFunc(on_entry);
glutMainLoop();
}
\ No newline at end of file
glutMainLoop();
}
#include <GL/gl.h>
#include <Eigen/Geometry>
#include <pcl/common/common.h>
#include <pcl/io/pcd_io.h>
#include <cfloat>
#include <pcl/visualization/point_cloud_handlers.h>
#include <pcl/visualization/image_viewer.h>
#include <pcl/visualization/window.h>
#include <pcl/console/print.h>
#include <pcl/console/parse.h>
#include <pcl/console/time.h>
#include <vtkPolyDataReader.h>
#include <vtkProp.h>
namespace pcl
{
namespace simulation
{
class OpenGLProp : public vtkProp {
public:
static OpenGLProp*
New ();
virtual int
RenderOpaqueGeometry (vtkViewport * viewport);
};
int
OpenGLProp::RenderOpaqueGeometry(vtkViewport * viewport)
{
glBegin(GL_TRIANGLES);
glVertex3f(1.0, 1.0, 0);
glVertex3f(0.0, 1.0, 0);
glVertex3f(0.0, 0.0, 0);
glEnd();
return 1;
}
vtkStandardNewMacro(OpenGLProp);
class RangeViewer : public pcl::visualization::Window
{
public:
RangeViewer (const std::string& window_name);
virtual ~RangeViewer ();
boost::signals2::connection
registerMouseCallback (boost::function<void (const pcl::visualization::MouseEvent&)> event)
{ return pcl::visualization::Window::registerMouseCallback (event); }
boost::signals2::connection
registerKeyboardCallback (boost::function<void (const pcl::visualization::KeyboardEvent&)> event)
{ return pcl::visualization::Window::registerKeyboardCallback (event); }
private:
vtkRenderer* renderer_;
OpenGLProp* prop_;
};
RangeViewer::RangeViewer (const std::string& window_name) : pcl::visualization::Window(window_name)
{
prop_ = OpenGLProp::New();
win_->SetSize (500, 500);
renderer_ = vtkRenderer::New();
renderer_->AddActor( prop_ );
renderer_->SetBackground( 0.1, 0.2, 0.4 );
renderer_->SetViewport(0.0, 0.0, 1.0, 1.0);
win_->AddRenderer( renderer_ );
}
RangeViewer::~RangeViewer ()
{
renderer_->Delete();
prop_->Delete();
}
}
}
class RangeVisualization
{
public:
RangeVisualization ();
void
spin ();
void
on_keyboard (const pcl::visualization::KeyboardEvent& event);
void
on_mouse (const pcl::visualization::MouseEvent& event);
private:
boost::shared_ptr<pcl::simulation::RangeViewer> viewer_;
};
RangeVisualization::RangeVisualization ()
{
viewer_.reset (new pcl::simulation::RangeViewer ("Range Simulation"));
viewer_->registerMouseCallback (boost::bind (&RangeVisualization::on_mouse, this, _1));
viewer_->registerKeyboardCallback (boost::bind (&RangeVisualization::on_keyboard, this, _1));
}
void
RangeVisualization::on_keyboard (const pcl::visualization::KeyboardEvent& event)
{
}
void
RangeVisualization::on_mouse (const pcl::visualization::MouseEvent& event)
{
}
void
RangeVisualization::spin ()
{
viewer_->spin ();
}
int
main (int argc, char** argv)
{
RangeVisualization range_viz;
range_viz.spin ();
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册