diff --git a/CMakeLists.txt b/CMakeLists.txt index 724e56269..3df0ff0df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 ---------------------------------- diff --git a/src/Mod/Points/App/AppPointsPy.cpp b/src/Mod/Points/App/AppPointsPy.cpp index 129b2bd4b..59d53e71d 100644 --- a/src/Mod/Points/App/AppPointsPy.cpp +++ b/src/Mod/Points/App/AppPointsPy.cpp @@ -35,7 +35,7 @@ #include // PCL test -#ifdef HAVE_PCL +#ifdef HAVE_PCL_IO # include # include # include @@ -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 cloud_in; pcl::io::loadPLYFile(Name,cloud_in); - for(pcl::PointCloud::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::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 cloud_in; + pcl::io::loadPLYFile(Name,cloud_in); + + for (pcl::PointCloud::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"); } diff --git a/src/Mod/Points/App/CMakeLists.txt b/src/Mod/Points/App/CMakeLists.txt index db5c836eb..2e3a3378f 100644 --- a/src/Mod/Points/App/CMakeLists.txt +++ b/src/Mod/Points/App/CMakeLists.txt @@ -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) diff --git a/src/Mod/ReverseEngineering/App/AppReverseEngineeringPy.cpp b/src/Mod/ReverseEngineering/App/AppReverseEngineeringPy.cpp index 7768b2b4a..a716cd114 100644 --- a/src/Mod/ReverseEngineering/App/AppReverseEngineeringPy.cpp +++ b/src/Mod/ReverseEngineering/App/AppReverseEngineeringPy.cpp @@ -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 */ diff --git a/src/Mod/ReverseEngineering/App/CMakeLists.txt b/src/Mod/ReverseEngineering/App/CMakeLists.txt index b3e64f467..e7338f6c2 100644 --- a/src/Mod/ReverseEngineering/App/CMakeLists.txt +++ b/src/Mod/ReverseEngineering/App/CMakeLists.txt @@ -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 diff --git a/src/Mod/ReverseEngineering/App/SurfaceTriangulation.cpp b/src/Mod/ReverseEngineering/App/SurfaceTriangulation.cpp index a503806f5..e31c01a56 100644 --- a/src/Mod/ReverseEngineering/App/SurfaceTriangulation.cpp +++ b/src/Mod/ReverseEngineering/App/SurfaceTriangulation.cpp @@ -30,7 +30,7 @@ #include // http://svn.pointclouds.org/pcl/tags/pcl-1.5.1/test/ -#if defined(PCL_FOUND) +#if defined(HAVE_PCL_SURFACE) #include #include #include @@ -165,5 +165,5 @@ void SurfaceTriangulation::perform() //std::vector states = gp3.getPointStates(); } -#endif // PCL_FOUND +#endif // HAVE_PCL_SURFACE