40 #ifndef PCL_IO_PLY_IO_H_ 41 #define PCL_IO_PLY_IO_H_ 43 #include <pcl/io/boost.h> 44 #include <pcl/io/file_io.h> 45 #include <pcl/io/ply/ply_parser.h> 46 #include <pcl/PolygonMesh.h> 89 , origin_ (
Eigen::Vector4f::Zero ())
90 , orientation_ (
Eigen::Matrix3f::Zero ())
93 , vertex_offset_before_ (0)
95 , rgb_offset_before_ (0)
105 , origin_ (
Eigen::Vector4f::Zero ())
106 , orientation_ (
Eigen::Matrix3f::Zero ())
109 , vertex_offset_before_ (0)
111 , rgb_offset_before_ (0)
114 , r_(0), g_(0), b_(0)
124 orientation_ = p.orientation_;
125 range_grid_ = p.range_grid_;
126 polygons_ = p.polygons_;
155 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
156 int &ply_version,
int &data_type,
unsigned int &data_idx,
const int offset = 0);
172 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
int& ply_version,
const int offset = 0);
187 Eigen::Vector4f origin;
188 Eigen::Quaternionf orientation;
190 return read (file_name, cloud, origin, orientation, ply_version, offset);
202 template<
typename Po
intT>
inline int 208 ply_version, offset);
232 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
233 int& ply_version,
const int offset = 0);
252 parse (
const std::string& istream_filename);
260 infoCallback (
const std::string& filename, std::size_t line_number,
const std::string& message)
262 PCL_DEBUG (
"[pcl::PLYReader] %s:%lu: %s\n", filename.c_str (), line_number, message.c_str ());
271 warningCallback (
const std::string& filename, std::size_t line_number,
const std::string& message)
273 PCL_WARN (
"[pcl::PLYReader] %s:%lu: %s\n", filename.c_str (), line_number, message.c_str ());
282 errorCallback (
const std::string& filename, std::size_t line_number,
const std::string& message)
284 PCL_ERROR (
"[pcl::PLYReader] %s:%lu: %s\n", filename.c_str (), line_number, message.c_str ());
291 boost::tuple<boost::function<void ()>, boost::function<void ()> >
292 elementDefinitionCallback (
const std::string& element_name, std::size_t count);
295 endHeaderCallback ();
301 template <
typename ScalarType> boost::function<void (ScalarType)>
302 scalarPropertyDefinitionCallback (
const std::string& element_name,
const std::string& property_name);
308 template <
typename SizeType,
typename ScalarType>
309 boost::tuple<boost::function<void (SizeType)>, boost::function<void (ScalarType)>, boost::function<void ()> >
310 listPropertyDefinitionCallback (
const std::string& element_name,
const std::string& property_name);
315 template <
typename SizeType>
void 316 vertexListPropertyBeginCallback (
const std::string& property_name, SizeType size);
321 template <
typename ContentType>
void 322 vertexListPropertyContentCallback (ContentType value);
326 vertexListPropertyEndCallback ();
332 template<
typename Scalar>
void 333 vertexScalarPropertyCallback (Scalar value);
362 originXCallback (
const float& value) { origin_[0] = value; }
368 originYCallback (
const float& value) { origin_[1] = value; }
374 originZCallback (
const float& value) { origin_[2] = value; }
380 orientationXaxisXCallback (
const float& value) { orientation_ (0,0) = value; }
386 orientationXaxisYCallback (
const float& value) { orientation_ (0,1) = value; }
392 orientationXaxisZCallback (
const float& value) { orientation_ (0,2) = value; }
398 orientationYaxisXCallback (
const float& value) { orientation_ (1,0) = value; }
404 orientationYaxisYCallback (
const float& value) { orientation_ (1,1) = value; }
410 orientationYaxisZCallback (
const float& value) { orientation_ (1,2) = value; }
416 orientationZaxisXCallback (
const float& value) { orientation_ (2,0) = value; }
422 orientationZaxisYCallback (
const float& value) { orientation_ (2,1) = value; }
428 orientationZaxisZCallback (
const float& value) { orientation_ (2,2) = value; }
434 cloudHeightCallback (
const int &height) { cloud_->height = height; }
440 cloudWidthCallback (
const int &width) { cloud_->width = width; }
447 template<
typename Scalar>
void 448 appendScalarProperty (
const std::string& name,
const size_t& count = 1);
456 amendProperty (
const std::string& old_name,
const std::string& new_name, uint8_t datatype = 0);
460 vertexBeginCallback ();
464 vertexEndCallback ();
468 rangeGridBeginCallback ();
484 rangeGridVertexIndicesEndCallback ();
488 rangeGridEndCallback ();
492 objInfoCallback (
const std::string& line);
496 faceBeginCallback ();
512 faceVertexIndicesEndCallback ();
519 Eigen::Vector4f origin_;
522 Eigen::Matrix3f orientation_;
526 size_t vertex_count_;
527 int vertex_offset_before_;
529 std::vector<std::vector <int> > *range_grid_;
530 size_t rgb_offset_before_;
533 std::vector<pcl::Vertices> *polygons_;
535 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
568 const Eigen::Vector4f &origin,
569 const Eigen::Quaternionf &orientation,
571 bool use_camera =
true)
573 return (generateHeader (cloud, origin, orientation,
true, use_camera, valid_points));
587 const Eigen::Vector4f &origin,
588 const Eigen::Quaternionf &orientation,
590 bool use_camera =
true)
592 return (generateHeader (cloud, origin, orientation,
false, use_camera, valid_points));
606 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
607 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
609 bool use_camera =
true);
621 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
622 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
623 bool use_camera =
true);
635 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
636 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
637 const bool binary =
false)
640 return (this->writeBinary (file_name, cloud, origin, orientation,
true));
642 return (this->writeASCII (file_name, cloud, origin, orientation, 8,
true));
657 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
658 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
660 bool use_camera =
true)
663 return (this->writeBinary (file_name, cloud, origin, orientation, use_camera));
665 return (this->writeASCII (file_name, cloud, origin, orientation, 8, use_camera));
680 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
681 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
683 bool use_camera =
true)
685 return (
write (file_name, *cloud, origin, orientation, binary, use_camera));
696 template<
typename Po
intT>
inline int 697 write (
const std::string &file_name,
700 bool use_camera =
true)
709 return (this->
write (file_name, blob, origin, orientation, binary, use_camera));
719 const Eigen::Vector4f &origin,
720 const Eigen::Quaternionf &orientation,
726 writeContentWithCameraASCII (
int nr_points,
729 const Eigen::Vector4f &origin,
730 const Eigen::Quaternionf &orientation,
734 writeContentWithRangeGridASCII (
int nr_points,
737 std::ostringstream& fs,
738 int& nb_valid_points);
756 return (p.
read (file_name, cloud));
769 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation)
773 return (p.
read (file_name, cloud, origin, orientation, ply_version));
781 template<
typename Po
intT>
inline int 785 return (p.
read (file_name, cloud));
801 return (p.
read (file_name, mesh));
815 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
816 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
817 bool binary_mode =
false,
bool use_camera =
true)
820 return (w.
write (file_name, cloud, origin, orientation, binary_mode, use_camera));
830 template<
typename Po
intT>
inline int 834 return (w.
write<
PointT> (file_name, cloud, binary_mode));
843 template<
typename Po
intT>
inline int 847 return (w.
write<
PointT> (file_name, cloud,
false));
855 template<
typename Po
intT>
inline int 869 template<
typename Po
intT>
int 871 const std::vector<int> &indices,
bool binary_mode =
false)
878 return (w.
write<
PointT> (file_name, cloud_out, binary_mode));
900 #endif //#ifndef PCL_IO_PLY_IO_H_ void fromPCLPointCloud2(const pcl::PCLPointCloud2 &msg, pcl::PointCloud< PointT > &cloud, const MsgFieldMap &field_map)
Convert a PCLPointCloud2 binary data blob into a pcl::PointCloud<T> object using a field_map.
PLYReader(const PLYReader &p)
int write(const std::string &file_name, const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin=Eigen::Vector4f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity(), const bool binary=false)
Save point cloud data to a PLY file containing n-D points.
std::string generateHeaderASCII(const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin, const Eigen::Quaternionf &orientation, int valid_points, bool use_camera=true)
Generate the header of a PLY v.7 file format.
This file defines compatibility wrappers for low level I/O functions.
int savePLYFile(const std::string &file_name, const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin=Eigen::Vector4f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity(), bool binary_mode=false, bool use_camera=true)
Save point cloud data to a PLY file containing n-D points.
void read(std::istream &stream, Type &value)
Function for reading data from a stream.
Point Cloud Data (FILE) file format writer.
PCL_EXPORTS void copyPointCloud(const pcl::PCLPointCloud2 &cloud_in, const std::vector< int > &indices, pcl::PCLPointCloud2 &cloud_out)
Extract the indices of a given point cloud as a new point cloud.
int write(const std::string &file_name, const pcl::PCLPointCloud2::ConstPtr &cloud, const Eigen::Vector4f &origin=Eigen::Vector4f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity(), bool binary=false, bool use_camera=true)
Save point cloud data to a PLY file containing n-D points.
int read(const std::string &file_name, pcl::PointCloud< PointT > &cloud, const int offset=0)
Read a point cloud data from any PLY file, and convert it to the given template format.
std::string generateHeaderBinary(const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin, const Eigen::Quaternionf &orientation, int valid_points, bool use_camera=true)
Generate the header of a PLY v.7 file format.
Eigen::Vector4f sensor_origin_
Sensor acquisition pose (origin/translation).
int savePLYFileBinary(const std::string &file_name, const pcl::PointCloud< PointT > &cloud)
Templated version for saving point cloud data to a PLY file containing a specific given cloud format.
Point Cloud Data (PLY) file format writer.
int savePLYFileASCII(const std::string &file_name, const pcl::PointCloud< PointT > &cloud)
Templated version for saving point cloud data to a PLY file containing a specific given cloud format.
Class ply_parser parses a PLY file and generates appropriate atomic parsers for the body.
Point Cloud Data (FILE) file format reader interface.
int read(const std::string &file_name, pcl::PCLPointCloud2 &cloud, Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &ply_version, const int offset=0)
Read a point cloud data from a PLY file and store it into a pcl/PCLPointCloud2.
int write(const std::string &file_name, const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin=Eigen::Vector4f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity(), bool binary=false, bool use_camera=true)
Save point cloud data to a PLY file containing n-D points.
Eigen::Quaternionf sensor_orientation_
Sensor acquisition pose (rotation).
boost::shared_ptr< ::pcl::PCLPointCloud2 const > ConstPtr
int loadPLYFile(const std::string &file_name, pcl::PCLPointCloud2 &cloud)
Load a PLY v.6 file into a templated PointCloud type.
PointCloud represents the base class in PCL for storing collections of 3D points.
int write(const std::string &file_name, const pcl::PointCloud< PointT > &cloud, bool binary=false, bool use_camera=true)
Save point cloud data to a PLY file containing n-D points.
void toPCLPointCloud2(const pcl::PointCloud< PointT > &cloud, pcl::PCLPointCloud2 &msg)
Convert a pcl::PointCloud<T> object to a PCLPointCloud2 binary data blob.
int read(const std::string &file_name, pcl::PCLPointCloud2 &cloud, const int offset=0)
Read a point cloud data from a PLY file and store it into a pcl/PCLPointCloud2.
Point Cloud Data (PLY) file format reader.
void write(std::ostream &stream, Type value)
Function for writing data to a stream.
A point structure representing Euclidean xyz coordinates, and the RGB color.