implement own ply/pcd importer/exporter
This commit is contained in:
@@ -26,12 +26,6 @@
|
||||
# include <memory>
|
||||
#endif
|
||||
|
||||
// PCL test
|
||||
#ifdef HAVE_PCL_IO
|
||||
# include <iostream>
|
||||
# include <pcl/io/ply_io.h>
|
||||
# include <pcl/point_types.h>
|
||||
#endif
|
||||
|
||||
#include <CXX/Extensions.hxx>
|
||||
#include <CXX/Objects.hxx>
|
||||
@@ -93,14 +87,12 @@ private:
|
||||
if (file.hasExtension("asc")) {
|
||||
reader.reset(new AscReader);
|
||||
}
|
||||
#ifdef HAVE_PCL_IO
|
||||
else if (file.hasExtension("ply")) {
|
||||
reader.reset(new PlyReader);
|
||||
}
|
||||
else if (file.hasExtension("pcd")) {
|
||||
reader.reset(new PcdReader);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
throw Py::RuntimeError("Unsupported file extension");
|
||||
}
|
||||
@@ -207,14 +199,12 @@ private:
|
||||
if (file.hasExtension("asc")) {
|
||||
reader.reset(new AscReader);
|
||||
}
|
||||
#ifdef HAVE_PCL_IO
|
||||
else if (file.hasExtension("ply")) {
|
||||
reader.reset(new PlyReader);
|
||||
}
|
||||
else if (file.hasExtension("pcd")) {
|
||||
reader.reset(new PcdReader);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
throw Py::RuntimeError("Unsupported file extension");
|
||||
}
|
||||
@@ -324,14 +314,12 @@ private:
|
||||
if (file.hasExtension("asc")) {
|
||||
writer.reset(new AscWriter(kernel));
|
||||
}
|
||||
#ifdef HAVE_PCL_IO
|
||||
else if (file.hasExtension("ply")) {
|
||||
writer.reset(new PlyWriter(kernel));
|
||||
}
|
||||
else if (file.hasExtension("pcd")) {
|
||||
writer.reset(new PcdWriter(kernel));
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
throw Py::RuntimeError("Unsupported file extension");
|
||||
}
|
||||
|
||||
@@ -2,28 +2,18 @@ if(WIN32)
|
||||
add_definitions(-DFCAppPoints)
|
||||
endif(WIN32)
|
||||
|
||||
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}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${EIGEN3_INCLUDE_DIR}
|
||||
${PCL_INCLUDE_DIRS}
|
||||
${PYTHON_INCLUDE_DIRS}
|
||||
${QT_QTCORE_INCLUDE_DIR}
|
||||
${XercesC_INCLUDE_DIRS}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
set(Points_LIBS
|
||||
FreeCADApp
|
||||
${PCL_COMMON_LIBRARIES}
|
||||
${PCL_IO_LIBRARIES}
|
||||
)
|
||||
|
||||
generate_from_xml(PointsPy)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "Points.h"
|
||||
#include "Properties.h"
|
||||
#include <Eigen/Core>
|
||||
|
||||
namespace Points
|
||||
{
|
||||
@@ -79,13 +80,22 @@ public:
|
||||
void read(const std::string& filename);
|
||||
};
|
||||
|
||||
#ifdef HAVE_PCL_IO
|
||||
class PlyReader : public Reader
|
||||
{
|
||||
public:
|
||||
PlyReader();
|
||||
~PlyReader();
|
||||
void read(const std::string& filename);
|
||||
|
||||
private:
|
||||
std::size_t readHeader(std::istream&, std::string& format, std::size_t& offset,
|
||||
std::vector<std::string>& fields, std::vector<std::string>& types,
|
||||
std::vector<int>& sizes);
|
||||
void readAscii(std::istream&, std::size_t offset, Eigen::MatrixXd& data);
|
||||
void readBinary(bool swapByteOrder, std::istream&, std::size_t offset,
|
||||
const std::vector<std::string>& types,
|
||||
const std::vector<int>& sizes,
|
||||
Eigen::MatrixXd& data);
|
||||
};
|
||||
|
||||
class PcdReader : public Reader
|
||||
@@ -94,8 +104,16 @@ public:
|
||||
PcdReader();
|
||||
~PcdReader();
|
||||
void read(const std::string& filename);
|
||||
|
||||
private:
|
||||
std::size_t readHeader(std::istream&, std::string& format, std::vector<std::string>& fields,
|
||||
std::vector<std::string>& types, std::vector<int>& sizes);
|
||||
void readAscii(std::istream&, Eigen::MatrixXd& data);
|
||||
void readBinary(bool transpose, std::istream&,
|
||||
const std::vector<std::string>& types,
|
||||
const std::vector<int>& sizes,
|
||||
Eigen::MatrixXd& data);
|
||||
};
|
||||
#endif
|
||||
|
||||
class Writer
|
||||
{
|
||||
@@ -126,7 +144,6 @@ public:
|
||||
void write(const std::string& filename);
|
||||
};
|
||||
|
||||
#ifdef HAVE_PCL_IO
|
||||
class PlyWriter : public Writer
|
||||
{
|
||||
public:
|
||||
@@ -142,7 +159,6 @@ public:
|
||||
~PcdWriter();
|
||||
void write(const std::string& filename);
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace Points
|
||||
|
||||
|
||||
Reference in New Issue
Block a user