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)
94 , range_grid_ (nullptr)
95 , rgb_offset_before_ (0)
103 : origin_ (
Eigen::Vector4f::Zero ())
104 , orientation_ (
Eigen::Matrix3f::Zero ())
107 , vertex_offset_before_ (0)
108 , range_grid_ (nullptr)
109 , rgb_offset_before_ (0)
111 , polygons_ (nullptr)
112 , r_(0), g_(0), b_(0)
122 orientation_ = p.orientation_;
123 range_grid_ = p.range_grid_;
124 polygons_ = p.polygons_;
153 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
154 int &ply_version,
int &data_type,
unsigned int &data_idx,
const int offset = 0)
override;
170 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
int& ply_version,
const int offset = 0)
override;
185 Eigen::Vector4f origin;
186 Eigen::Quaternionf orientation;
188 return read (file_name, cloud, origin, orientation, ply_version, offset);
200 template<
typename Po
intT>
inline int
206 ply_version, offset);
230 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
231 int& ply_version,
const int offset = 0);
250 parse (
const std::string& istream_filename);
258 infoCallback (
const std::string& filename, std::size_t line_number,
const std::string& message)
260 PCL_DEBUG (
"[pcl::PLYReader] %s:%lu: %s\n", filename.c_str (), line_number, message.c_str ());
269 warningCallback (
const std::string& filename, std::size_t line_number,
const std::string& message)
271 PCL_WARN (
"[pcl::PLYReader] %s:%lu: %s\n", filename.c_str (), line_number, message.c_str ());
280 errorCallback (
const std::string& filename, std::size_t line_number,
const std::string& message)
282 PCL_ERROR (
"[pcl::PLYReader] %s:%lu: %s\n", filename.c_str (), line_number, message.c_str ());
289 std::tuple<std::function<void ()>, std::function<void ()> >
290 elementDefinitionCallback (
const std::string& element_name, std::size_t count);
293 endHeaderCallback ();
299 template <
typename ScalarType> std::function<void (ScalarType)>
300 scalarPropertyDefinitionCallback (
const std::string& element_name,
const std::string& property_name);
306 template <
typename SizeType,
typename ScalarType>
307 std::tuple<std::function<void (SizeType)>, std::function<void (ScalarType)>, std::function<void ()> >
308 listPropertyDefinitionCallback (
const std::string& element_name,
const std::string& property_name);
313 template <
typename SizeType>
void
314 vertexListPropertyBeginCallback (
const std::string& property_name, SizeType size);
319 template <
typename ContentType>
void
320 vertexListPropertyContentCallback (ContentType value);
324 vertexListPropertyEndCallback ();
330 template<
typename Scalar>
void
331 vertexScalarPropertyCallback (Scalar value);
360 originXCallback (
const float& value) { origin_[0] = value; }
366 originYCallback (
const float& value) { origin_[1] = value; }
372 originZCallback (
const float& value) { origin_[2] = value; }
378 orientationXaxisXCallback (
const float& value) { orientation_ (0,0) = value; }
384 orientationXaxisYCallback (
const float& value) { orientation_ (0,1) = value; }
390 orientationXaxisZCallback (
const float& value) { orientation_ (0,2) = value; }
396 orientationYaxisXCallback (
const float& value) { orientation_ (1,0) = value; }
402 orientationYaxisYCallback (
const float& value) { orientation_ (1,1) = value; }
408 orientationYaxisZCallback (
const float& value) { orientation_ (1,2) = value; }
414 orientationZaxisXCallback (
const float& value) { orientation_ (2,0) = value; }
420 orientationZaxisYCallback (
const float& value) { orientation_ (2,1) = value; }
426 orientationZaxisZCallback (
const float& value) { orientation_ (2,2) = value; }
432 cloudHeightCallback (
const int &height) { cloud_->height = height; }
438 cloudWidthCallback (
const int &width) { cloud_->width = width; }
445 template<
typename Scalar>
void
446 appendScalarProperty (
const std::string& name,
const std::size_t& count = 1);
454 amendProperty (
const std::string& old_name,
const std::string& new_name, std::uint8_t datatype = 0);
458 vertexBeginCallback ();
462 vertexEndCallback ();
466 rangeGridBeginCallback ();
482 rangeGridVertexIndicesEndCallback ();
486 rangeGridEndCallback ();
490 objInfoCallback (
const std::string& line);
494 faceBeginCallback ();
510 faceVertexIndicesEndCallback ();
517 Eigen::Vector4f origin_;
520 Eigen::Matrix3f orientation_;
524 std::size_t vertex_count_;
525 int vertex_offset_before_;
527 std::vector<std::vector <int> > *range_grid_;
528 std::size_t rgb_offset_before_;
531 std::vector<pcl::Vertices> *polygons_;
537 std::int32_t r_, g_, b_;
539 std::uint32_t a_, rgba_;
566 const Eigen::Vector4f &origin,
567 const Eigen::Quaternionf &orientation,
569 bool use_camera =
true)
571 return (generateHeader (cloud, origin, orientation,
true, use_camera, valid_points));
585 const Eigen::Vector4f &origin,
586 const Eigen::Quaternionf &orientation,
588 bool use_camera =
true)
590 return (generateHeader (cloud, origin, orientation,
false, use_camera, valid_points));
604 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
605 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
607 bool use_camera =
true);
619 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
620 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
621 bool use_camera =
true);
633 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
634 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
635 const bool binary =
false)
override
638 return (this->writeBinary (file_name, cloud, origin, orientation,
true));
639 return (this->writeASCII (file_name, cloud, origin, orientation, 8,
true));
654 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
655 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
657 bool use_camera =
true)
660 return (this->writeBinary (file_name, cloud, origin, orientation, use_camera));
661 return (this->writeASCII (file_name, cloud, origin, orientation, 8, use_camera));
676 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
677 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
679 bool use_camera =
true)
681 return (
write (file_name, *cloud, origin, orientation, binary, use_camera));
692 template<
typename Po
intT>
inline int
693 write (
const std::string &file_name,
696 bool use_camera =
true)
705 return (this->
write (file_name, blob, origin, orientation, binary, use_camera));
715 const Eigen::Vector4f &origin,
716 const Eigen::Quaternionf &orientation,
722 writeContentWithCameraASCII (
int nr_points,
725 const Eigen::Vector4f &origin,
726 const Eigen::Quaternionf &orientation,
730 writeContentWithRangeGridASCII (
int nr_points,
733 std::ostringstream& fs,
734 int& nb_valid_points);
752 return (p.
read (file_name, cloud));
765 Eigen::Vector4f &origin, Eigen::Quaternionf &orientation)
769 return (p.
read (file_name, cloud, origin, orientation, ply_version));
777 template<
typename Po
intT>
inline int
781 return (p.
read (file_name, cloud));
797 return (p.
read (file_name, mesh));
811 const Eigen::Vector4f &origin = Eigen::Vector4f::Zero (),
812 const Eigen::Quaternionf &orientation = Eigen::Quaternionf::Identity (),
813 bool binary_mode =
false,
bool use_camera =
true)
816 return (w.
write (file_name, cloud, origin, orientation, binary_mode, use_camera));
826 template<
typename Po
intT>
inline int
830 return (w.
write<
PointT> (file_name, cloud, binary_mode));
839 template<
typename Po
intT>
inline int
843 return (w.
write<
PointT> (file_name, cloud,
false));
851 template<
typename Po
intT>
inline int
865 template<
typename Po
intT>
int
867 const std::vector<int> &indices,
bool binary_mode =
false)
874 return (w.
write<
PointT> (file_name, cloud_out, binary_mode));