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_properties_counter_ (0)
94 , vertex_offset_before_ (0)
97 , range_grid_vertex_indices_element_index_ (0)
98 , rgb_offset_before_ (0)
105 , origin_ (Eigen::Vector4f::Zero ())
106 , orientation_ (Eigen::Matrix3f::Zero ())
109 , vertex_properties_counter_ (0)
110 , vertex_offset_before_ (0)
113 , range_grid_vertex_indices_element_index_ (0)
114 , rgb_offset_before_ (0)
124 orientation_ = p.orientation_;
125 range_grid_ = p.range_grid_;
154 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
155 int &ply_version,
int &data_type,
unsigned int &data_idx,
const int offset = 0);
171 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
int& ply_version,
const int offset = 0);
191 Eigen::Vector4f origin;
192 Eigen::Quaternionf orientation;
194 return read (file_name, cloud, origin, orientation, ply_version, offset);
206 template<
typename Po
intT>
inline int
212 ply_version, offset);
225 parse (
const std::string& istream_filename);
233 infoCallback (
const std::string& filename, std::size_t line_number,
const std::string& message)
235 PCL_DEBUG (
"[pcl::PLYReader] %s:%lu: %s\n", filename.c_str (), line_number, message.c_str ());
244 warningCallback (
const std::string& filename, std::size_t line_number,
const std::string& message)
246 PCL_WARN (
"[pcl::PLYReader] %s:%lu: %s\n", filename.c_str (), line_number, message.c_str ());
255 errorCallback (
const std::string& filename, std::size_t line_number,
const std::string& message)
257 PCL_ERROR (
"[pcl::PLYReader] %s:%lu: %s\n", filename.c_str (), line_number, message.c_str ());
264 boost::tuple<boost::function<void ()>, boost::function<void ()> >
265 elementDefinitionCallback (
const std::string& element_name, std::size_t count);
268 endHeaderCallback ();
274 template <
typename ScalarType> boost::function<void (ScalarType)>
275 scalarPropertyDefinitionCallback (
const std::string& element_name,
const std::string& property_name);
281 template <
typename SizeType,
typename ScalarType>
282 boost::tuple<boost::function<void (SizeType)>, boost::function<void (ScalarType)>, boost::function<void ()> >
283 listPropertyDefinitionCallback (
const std::string& element_name,
const std::string& property_name);
288 template <
typename SizeType>
void
289 vertexListPropertyBeginCallback (
const std::string& property_name, SizeType size);
294 template <
typename ContentType>
void
295 vertexListPropertyContentCallback (ContentType value);
299 vertexListPropertyEndCallback ();
384 originXCallback (
const float& value) { origin_[0] = value; }
390 originYCallback (
const float& value) { origin_[1] = value; }
396 originZCallback (
const float& value) { origin_[2] = value; }
402 orientationXaxisXCallback (
const float& value) { orientation_ (0,0) = value; }
408 orientationXaxisYCallback (
const float& value) { orientation_ (0,1) = value; }
414 orientationXaxisZCallback (
const float& value) { orientation_ (0,2) = value; }
420 orientationYaxisXCallback (
const float& value) { orientation_ (1,0) = value; }
426 orientationYaxisYCallback (
const float& value) { orientation_ (1,1) = value; }
432 orientationYaxisZCallback (
const float& value) { orientation_ (1,2) = value; }
438 orientationZaxisXCallback (
const float& value) { orientation_ (2,0) = value; }
444 orientationZaxisYCallback (
const float& value) { orientation_ (2,1) = value; }
450 orientationZaxisZCallback (
const float& value) { orientation_ (2,2) = value; }
456 cloudHeightCallback (
const int &height) { cloud_->height = height; }
462 cloudWidthCallback (
const int &width) { cloud_->width = width; }
470 appendDoubleProperty (
const std::string& name,
const size_t& count = 1);
478 appendFloatProperty (
const std::string& name,
const size_t& count = 1);
486 appendIntProperty (
const std::string& name,
const size_t& count = 1);
494 appendUnsignedIntProperty (
const std::string& name,
const size_t& count = 1);
502 appendShortProperty (
const std::string& name,
const size_t& count = 1);
510 appendUnsignedShortProperty (
const std::string& name,
const size_t& count = 1);
518 appendCharProperty (
const std::string& name,
const size_t& count = 1);
526 appendUnsignedCharProperty (
const std::string& name,
const size_t& count = 1);
534 amendProperty (
const std::string& old_name,
const std::string& new_name, uint8_t datatype = 0);
538 vertexBeginCallback ();
542 vertexEndCallback ();
546 rangeGridBeginCallback ();
562 rangeGridVertexIndicesEndCallback ();
566 rangeGridEndCallback ();
570 objInfoCallback (
const std::string& line);
573 Eigen::Vector4f origin_;
576 Eigen::Matrix3f orientation_;
580 size_t vertex_count_, vertex_properties_counter_;
581 int vertex_offset_before_;
583 std::vector<std::vector <int> > *range_grid_;
584 size_t range_count_, range_grid_vertex_indices_element_index_;
585 size_t rgb_offset_before_;
588 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
615 const Eigen::Vector4f &origin,
616 const Eigen::Quaternionf &orientation,
618 bool use_camera =
true)
620 return (generateHeader (cloud, origin, orientation,
true, use_camera, valid_points));
634 const Eigen::Vector4f &origin,
635 const Eigen::Quaternionf &orientation,
637 bool use_camera =
true)
639 return (generateHeader (cloud, origin, orientation,
false, use_camera, valid_points));
653 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
654 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
656 bool use_camera =
true);
668 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
669 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
670 bool use_camera =
true);
682 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
683 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
684 const bool binary =
false)
687 return (this->writeBinary (file_name, cloud, origin, orientation,
true));
689 return (this->writeASCII (file_name, cloud, origin, orientation, 8,
true));
704 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
705 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
707 bool use_camera =
true)
710 return (this->writeBinary (file_name, cloud, origin, orientation, use_camera));
712 return (this->writeASCII (file_name, cloud, origin, orientation, 8, use_camera));
727 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
728 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
730 bool use_camera =
true)
732 return (
write (file_name, *cloud, origin, orientation, binary, use_camera));
743 template<
typename Po
intT>
inline int
744 write (
const std::string &file_name,
747 bool use_camera =
true)
756 return (this->
write (file_name, blob, origin, orientation, binary, use_camera));
766 const Eigen::Vector4f &origin,
767 const Eigen::Quaternionf &orientation,
773 writeContentWithCameraASCII (
int nr_points,
776 const Eigen::Vector4f &origin,
777 const Eigen::Quaternionf &orientation,
781 writeContentWithRangeGridASCII (
int nr_points,
784 std::ostringstream& fs,
785 int& nb_valid_points);
803 return (p.
read (file_name, cloud));
816 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation)
820 return (p.
read (file_name, cloud, origin, orientation, ply_version));
828 template<
typename Po
intT>
inline int
832 return (p.
read (file_name, cloud));
845 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
846 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
847 bool binary_mode =
false,
bool use_camera =
true)
850 return (w.
write (file_name, cloud, origin, orientation, binary_mode, use_camera));
860 template<
typename Po
intT>
inline int
864 return (w.
write<
PointT> (file_name, cloud, binary_mode));
873 template<
typename Po
intT>
inline int
877 return (w.
write<
PointT> (file_name, cloud,
false));
885 template<
typename Po
intT>
inline int
899 template<
typename Po
intT>
int
901 const std::vector<int> &indices,
bool binary_mode =
false)
908 return (w.
write<
PointT> (file_name, cloud_out, binary_mode));
930 #endif //#ifndef PCL_IO_PLY_IO_H_
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.
Point Cloud Data (PLY) file format reader.
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.
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.
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 (FILE) file format reader interface.
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.
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).
PLYReader(const PLYReader &p)
boost::shared_ptr< ::pcl::PCLPointCloud2 const > ConstPtr
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...
void toPCLPointCloud2(const pcl::PointCloud< PointT > &cloud, pcl::PCLPointCloud2 &msg)
Convert a pcl::PointCloud<T> object to a PCLPointCloud2 binary data blob.
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...
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 read(const std::string &file_name, pcl::PCLPointCloud2 &cloud, const int offset=0)
Read a point cloud data from a PLY file (PLY_V6 only!) 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(), const bool binary=false)
Save point cloud data to a PLY file containing n-D points.
Point Cloud Data (PLY) file format writer.
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::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.
Eigen::Quaternionf sensor_orientation_
Sensor acquisition pose (rotation).
int loadPLYFile(const std::string &file_name, pcl::PCLPointCloud2 &cloud)
Load a PLY v.6 file into a templated PointCloud type.
Point Cloud Data (FILE) file format writer.
void read(std::istream &stream, Type &value)
Function for reading data from a stream.
A point structure representing Euclidean xyz coordinates, and the RGB color.
void write(std::ostream &stream, Type value)
Function for writing data to a stream.