+ do pcl components checks

This commit is contained in:
wmayer 2014-08-28 01:51:58 +02:00
parent a579bdce72
commit fd821fb7b4
6 changed files with 40 additions and 24 deletions

View File

@ -529,7 +529,7 @@ else(FREECAD_LIBPACK_USE)
# -------------------------------- pcl ----------------------------------
find_package(PCL COMPONENTS common kdtree features surface)
find_package(PCL COMPONENTS common kdtree features surface io)
# -------------------------------- ODE ----------------------------------

View File

@ -35,7 +35,7 @@
#include <App/Property.h>
// PCL test
#ifdef HAVE_PCL
#ifdef HAVE_PCL_IO
# include <iostream>
# include <pcl/io/ply_io.h>
# include <pcl/point_types.h>
@ -53,7 +53,7 @@ static PyObject *
open(PyObject *self, PyObject *args)
{
const char* Name;
if (! PyArg_ParseTuple(args, "s",&Name))
if (!PyArg_ParseTuple(args, "s",&Name))
return NULL;
PY_TRY {
@ -73,9 +73,8 @@ open(PyObject *self, PyObject *args)
pcFeature->Points.setValue( pkTemp );
}
#ifdef HAVE_PCL
else
if (file.hasExtension("ply")) {
#ifdef HAVE_PCL_IO
else if (file.hasExtension("ply")) {
// create new document import
App::Document *pcDoc = App::GetApplication().newDocument("Unnamed");
Points::Feature *pcFeature = (Points::Feature *)pcDoc->addObject("Points::Feature", file.fileNamePure().c_str());
@ -85,13 +84,9 @@ open(PyObject *self, PyObject *args)
pcl::PointCloud<pcl::PointXYZRGB> cloud_in;
pcl::io::loadPLYFile<pcl::PointXYZRGB>(Name,cloud_in);
for(pcl::PointCloud<pcl::PointXYZRGB>::const_iterator it = cloud_in.begin();it!=cloud_in.end();++it)
pkTemp.push_back(Base::Vector3d(it->x,it->y,it->z));
for (pcl::PointCloud<pcl::PointXYZRGB>::const_iterator it = cloud_in.begin();it!=cloud_in.end();++it)
pkTemp.push_back(Base::Vector3d(it->x,it->y,it->z));
pcFeature->Points.setValue( pkTemp );
}
#endif
else {
@ -130,6 +125,25 @@ insert(PyObject *self, PyObject *args)
pkTemp.load(Name);
pcFeature->Points.setValue( pkTemp );
}
#ifdef HAVE_PCL_IO
else if (file.hasExtension("ply")) {
App::Document *pcDoc = App::GetApplication().getDocument(DocName);
if (!pcDoc) {
pcDoc = App::GetApplication().newDocument(DocName);
}
Points::Feature *pcFeature = (Points::Feature *)pcDoc->addObject("Points::Feature", file.fileNamePure().c_str());
Points::PointKernel pkTemp;
// pcl test
pcl::PointCloud<pcl::PointXYZRGB> cloud_in;
pcl::io::loadPLYFile<pcl::PointXYZRGB>(Name,cloud_in);
for (pcl::PointCloud<pcl::PointXYZRGB>::const_iterator it = cloud_in.begin();it!=cloud_in.end();++it)
pkTemp.push_back(Base::Vector3d(it->x,it->y,it->z));
pcFeature->Points.setValue( pkTemp );
}
#endif
else {
Py_Error(PyExc_Exception,"unknown file ending");
}

View File

@ -2,9 +2,11 @@ if(WIN32)
add_definitions(-DFCAppPoints)
endif(WIN32)
if(PCL_FOUND)
add_definitions(-DHAVE_PCL)
endif(PCL_FOUND)
if(PCL_IO_FOUND)
add_definitions(-DHAVE_PCL_IO)
elseif(PCL_FOUND)
message(WARNING "pcl installed but io component not found")
endif(PCL_IO_FOUND)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
@ -19,8 +21,8 @@ include_directories(
set(Points_LIBS
FreeCADApp
${PCL_LIBRARIES}
${PCL_DEBUG_LIBRARIES}
${PCL_COMMON_LIBRARIES}
${PCL_IO_LIBRARIES}
)
generate_from_xml(PointsPy)

View File

@ -79,7 +79,7 @@ static PyObject * approxSurface(PyObject *self, PyObject *args)
} PY_CATCH;
}
#if defined(PCL_FOUND)
#if defined(HAVE_PCL_SURFACE)
static PyObject *
triangulate(PyObject *self, PyObject *args)
{
@ -101,7 +101,7 @@ triangulate(PyObject *self, PyObject *args)
/* registration table */
struct PyMethodDef ReverseEngineering_methods[] = {
{"approxSurface" , approxSurface, 1},
#if defined(PCL_FOUND)
#if defined(HAVE_PCL_SURFACE)
{"triangulate" , triangulate, 1},
#endif
{NULL, NULL} /* end of table marker */

View File

@ -4,9 +4,9 @@ else(MSVC)
add_definitions(-DHAVE_LIMITS_H -DHAVE_CONFIG_H)
endif(MSVC)
if (PCL_FOUND)
add_definitions(-DPCL_FOUND)
endif(PCL_FOUND)
if (PCL_SURFACE_FOUND AND PCL_FEATURES_FOUND AND PCL_KDTREE_FOUND)
add_definitions(-DHAVE_PCL_SURFACE)
endif ()
include_directories(
${CMAKE_SOURCE_DIR}/src

View File

@ -30,7 +30,7 @@
#include <Mod/Mesh/App/Core/MeshKernel.h>
// http://svn.pointclouds.org/pcl/tags/pcl-1.5.1/test/
#if defined(PCL_FOUND)
#if defined(HAVE_PCL_SURFACE)
#include <pcl/pcl_config.h>
#include <pcl/point_types.h>
#include <pcl/features/normal_3d.h>
@ -165,5 +165,5 @@ void SurfaceTriangulation::perform()
//std::vector<int> states = gp3.getPointStates();
}
#endif // PCL_FOUND
#endif // HAVE_PCL_SURFACE