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)
103 , origin_ (
Eigen::Vector4f::Zero ())
104 , orientation_ (
Eigen::Matrix3f::Zero ())
107 , vertex_offset_before_ (0)
109 , rgb_offset_before_ (0)
120 orientation_ = p.orientation_;
121 range_grid_ = p.range_grid_;
122 polygons_ = p.polygons_;
151 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
152 int &ply_version,
int &data_type,
unsigned int &data_idx,
const int offset = 0);
168 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
int& ply_version,
const int offset = 0);
183 Eigen::Vector4f origin;
184 Eigen::Quaternionf orientation;
186 return read (file_name, cloud, origin, orientation, ply_version, offset);
198 template<
typename Po
intT>
inline int
204 ply_version, offset);
228 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
229 int& ply_version,
const int offset = 0);
248 parse (
const std::string& istream_filename);
256 infoCallback (
const std::string& filename, std::size_t line_number,
const std::string& message)
258 PCL_DEBUG (
"[pcl::PLYReader] %s:%lu: %s\n", filename.c_str (), line_number, message.c_str ());
267 warningCallback (
const std::string& filename, std::size_t line_number,
const std::string& message)
269 PCL_WARN (
"[pcl::PLYReader] %s:%lu: %s\n", filename.c_str (), line_number, message.c_str ());
278 errorCallback (
const std::string& filename, std::size_t line_number,
const std::string& message)
280 PCL_ERROR (
"[pcl::PLYReader] %s:%lu: %s\n", filename.c_str (), line_number, message.c_str ());
287 boost::tuple<boost::function<void ()>, boost::function<void ()> >
288 elementDefinitionCallback (
const std::string& element_name, std::size_t count);
291 endHeaderCallback ();
297 template <
typename ScalarType> boost::function<void (ScalarType)>
298 scalarPropertyDefinitionCallback (
const std::string& element_name,
const std::string& property_name);
304 template <
typename SizeType,
typename ScalarType>
305 boost::tuple<boost::function<void (SizeType)>, boost::function<void (ScalarType)>, boost::function<void ()> >
306 listPropertyDefinitionCallback (
const std::string& element_name,
const std::string& property_name);
311 template <
typename SizeType>
void
312 vertexListPropertyBeginCallback (
const std::string& property_name, SizeType size);
317 template <
typename ContentType>
void
318 vertexListPropertyContentCallback (ContentType value);
322 vertexListPropertyEndCallback ();
328 template<
typename Scalar>
void
329 vertexScalarPropertyCallback (Scalar value);
358 originXCallback (
const float& value) { origin_[0] = value; }
364 originYCallback (
const float& value) { origin_[1] = value; }
370 originZCallback (
const float& value) { origin_[2] = value; }
376 orientationXaxisXCallback (
const float& value) { orientation_ (0,0) = value; }
382 orientationXaxisYCallback (
const float& value) { orientation_ (0,1) = value; }
388 orientationXaxisZCallback (
const float& value) { orientation_ (0,2) = value; }
394 orientationYaxisXCallback (
const float& value) { orientation_ (1,0) = value; }
400 orientationYaxisYCallback (
const float& value) { orientation_ (1,1) = value; }
406 orientationYaxisZCallback (
const float& value) { orientation_ (1,2) = value; }
412 orientationZaxisXCallback (
const float& value) { orientation_ (2,0) = value; }
418 orientationZaxisYCallback (
const float& value) { orientation_ (2,1) = value; }
424 orientationZaxisZCallback (
const float& value) { orientation_ (2,2) = value; }
430 cloudHeightCallback (
const int &height) { cloud_->height = height; }
436 cloudWidthCallback (
const int &width) { cloud_->width = width; }
443 template<
typename Scalar>
void
444 appendScalarProperty (
const std::string& name,
const size_t& count = 1);
452 amendProperty (
const std::string& old_name,
const std::string& new_name, uint8_t datatype = 0);
456 vertexBeginCallback ();
460 vertexEndCallback ();
464 rangeGridBeginCallback ();
480 rangeGridVertexIndicesEndCallback ();
484 rangeGridEndCallback ();
488 objInfoCallback (
const std::string& line);
492 faceBeginCallback ();
508 faceVertexIndicesEndCallback ();
515 Eigen::Vector4f origin_;
518 Eigen::Matrix3f orientation_;
522 size_t vertex_count_;
523 int vertex_offset_before_;
525 std::vector<std::vector <int> > *range_grid_;
526 size_t rgb_offset_before_;
529 std::vector<pcl::Vertices> *polygons_;
531 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
558 const Eigen::Vector4f &origin,
559 const Eigen::Quaternionf &orientation,
561 bool use_camera =
true)
563 return (generateHeader (cloud, origin, orientation,
true, use_camera, valid_points));
577 const Eigen::Vector4f &origin,
578 const Eigen::Quaternionf &orientation,
580 bool use_camera =
true)
582 return (generateHeader (cloud, origin, orientation,
false, use_camera, valid_points));
596 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
597 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
599 bool use_camera =
true);
611 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
612 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
613 bool use_camera =
true);
625 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
626 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
627 const bool binary =
false)
630 return (this->writeBinary (file_name, cloud, origin, orientation,
true));
632 return (this->writeASCII (file_name, cloud, origin, orientation, 8,
true));
647 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
648 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
650 bool use_camera =
true)
653 return (this->writeBinary (file_name, cloud, origin, orientation, use_camera));
655 return (this->writeASCII (file_name, cloud, origin, orientation, 8, use_camera));
670 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
671 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
673 bool use_camera =
true)
675 return (
write (file_name, *cloud, origin, orientation, binary, use_camera));
686 template<
typename Po
intT>
inline int
687 write (
const std::string &file_name,
690 bool use_camera =
true)
699 return (this->
write (file_name, blob, origin, orientation, binary, use_camera));
709 const Eigen::Vector4f &origin,
710 const Eigen::Quaternionf &orientation,
716 writeContentWithCameraASCII (
int nr_points,
719 const Eigen::Vector4f &origin,
720 const Eigen::Quaternionf &orientation,
724 writeContentWithRangeGridASCII (
int nr_points,
727 std::ostringstream& fs,
728 int& nb_valid_points);
746 return (p.
read (file_name, cloud));
759 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation)
763 return (p.
read (file_name, cloud, origin, orientation, ply_version));
771 template<
typename Po
intT>
inline int
775 return (p.
read (file_name, cloud));
791 return (p.
read (file_name, mesh));
805 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
806 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
807 bool binary_mode =
false,
bool use_camera =
true)
810 return (w.
write (file_name, cloud, origin, orientation, binary_mode, use_camera));
820 template<
typename Po
intT>
inline int
824 return (w.
write<
PointT> (file_name, cloud, binary_mode));
833 template<
typename Po
intT>
inline int
837 return (w.
write<
PointT> (file_name, cloud,
false));
845 template<
typename Po
intT>
inline int
859 template<
typename Po
intT>
int
861 const std::vector<int> &indices,
bool binary_mode =
false)
868 return (w.
write<
PointT> (file_name, cloud_out, binary_mode));
890 #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 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.
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.
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.
Eigen::Quaternionf sensor_orientation_
Sensor acquisition pose (rotation).
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.
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 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.
Eigen::Vector4f sensor_origin_
Sensor acquisition pose (origin/translation).
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.