<commit_before>/*
 * Software License Agreement (BSD License)
 *
 *  Copyright (c) 2009, <NAME>, Inc.
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 *   * Neither the name of <NAME>, Inc. nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 *
 * $Id$
 *
 */

#ifndef PCL_IO_PCD_IO_H_
#define PCL_IO_PCD_IO_H_

#include "pcl/io/file_io.h"

namespace pcl
{
  /** \brief Point Cloud Data (PCD) file format reader.
    * \author <NAME>
    * \ingroup io
    */
  class PCL_EXPORTS PCDReader : public FileReader
  {
    public:
      /** \brief Various PCD file versions.
        *
        * PCD_V6 represents PCD files with version .6, which contain the following fields:
        * <ul>
        *  <li> lines beginning with # are treated as comments</li>
        *  <li> FIELDS ...</li>
        *  <li> SIZE ...</li>
        *  <li> TYPE ...</li>
        *  <li> COUNT ...</li>
        *  <li> WIDTH ...</li>
        *  <li> HEIGHT ...</li>
        *  <li> POINTS ...</li>
        *  <li> DATA ascii/binary</li>
        * </ul>
        * Everything that follows <b>DATA</b> is intepreted as data points and
        * will be read accordingly.
        *
        * PCD_V7 represents PCD files with version .7 and has an important
        * addon: it adds sensor origin/orientation (aka viewpoint) information
        * to a dataset through the use of a new header field:
        * <ul>
        *  <li> VIEWPOINT tx ty tz qw qx qy qz</li>
        * </ul>
        */
      enum
      {
        PCD_V6 = 0,
        PCD_V7 = 1
      };

      /** \brief Read a point cloud data header from a PCD file. 
        *
        * Load only the meta information (number of points, their types, etc),
        * and not the points themselves, from a given PCD file. Useful for fast
        * evaluation of the underlying data structure.
        *
        * Returns:
        *  * < 0 (-1) on error
        *  * > 0 on success
        * \param file_name the name of the file to load
        * \param cloud the resultant point cloud dataset (only the header will be filled)
        * \param origin the sensor acquisition origin (only for > PCD_V7 - null if not present)
        * \param orientation the sensor acquisition orientation (only for > PCD_V7 - identity if not present)
        * \param pcd_version the PCD version of the file (either PCD_V6 or PCD_V7)
        * \param binary_data is true if the PCD file contains binary data, false if ascii 
        * \param data_idx the offset of cloud data within the file
        */
      int 
      readHeader (const std::string &file_name, sensor_msgs::PointCloud2 &cloud, 
                  Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &pcd_version,
                  bool &binary_data, int &data_idx);

      /** \brief Read a point cloud data from a PCD file and store it into a sensor_msgs/PointCloud2.
        * \param file_name the name of the file containing the actual PointCloud data
        * \param cloud the resultant PointCloud message read from disk
        * \param origin the sensor acquisition origin (only for > PCD_V7 - null if not present)
        * \param orientation the sensor acquisition orientation (only for > PCD_V7 - identity if not present)
        * \param pcd_version the PCD version of the file (either PCD_V6 or PCD_V7)
        */
      int 
      read (const std::string &file_name, sensor_msgs::PointCloud2 &cloud, 
            Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &pcd_version);

      /** \brief Read a point cloud data from a PCD file (PCD_V6 only!) and store it into a sensor_msgs/PointCloud2.
        * 
        * \note This function is provided for backwards compatibility only and
        * it can only read PCD_V6 files correctly, as sensor_msgs::PointCloud2
        * does not contain a sensor origin/orientation. Reading any file 
        * > PCD_V6 will generate a warning. 
        *
        * \param file_name the name of the file containing the actual PointCloud data
        * \param cloud the resultant PointCloud message read from disk
        */
      int 
      read (const std::string &file_name, sensor_msgs::PointCloud2 &cloud);

      /** \brief Read a point cloud data from any PCD file, and convert it to the given template format.
        * \param file_name the name of the file containing the actual PointCloud data
        * \param cloud the resultant PointCloud message read from disk
        */
      template<typename PointT> inline int
      read (const std::string &file_name, pcl::PointCloud<PointT> &cloud)
      {
        sensor_msgs::PointCloud2 blob;
        int pcd_version;
        int res = read (file_name, blob, cloud.sensor_origin_, cloud.sensor_orientation_, 
                        pcd_version);

        // Exit in case of error
        if (res < 0)
          return res;
        pcl::fromROSMsg (blob, cloud);
        return 0;
      }
  };

  /** \brief Point Cloud Data (PCD) file format writer.
    * \author <NAME>
    * \ingroup io
    */
  class PCL_EXPORTS PCDWriter : public FileWriter
  {
    public:
      /** \brief Generate the header of a PCD v.7 file format
        * \param cloud the point cloud data message
        * \param origin the sensor acquisition origin
        * \param orientation the sensor acquisition orientation
        */<commit_msg>Fix: Add missing constructors and desctructors<commit_after>/*
 * Software License Agreement (BSD License)
 *
 *  Copyright (c) 2009, <NAME>, Inc.
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 *   * Neither the name of <NAME>, Inc. nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 *
 * $Id$
 *
 */

#ifndef PCL_IO_PCD_IO_H_
#define PCL_IO_PCD_IO_H_

#include "pcl/io/file_io.h"

namespace pcl
{
  /** \brief Point Cloud Data (PCD) file format reader.
    * \author <NAME>
    * \ingroup io
    */
  class PCL_EXPORTS PCDReader : public FileReader
  {
    public:
      /** Empty constructor */      
      PCDReader() : FileReader() {}
      /** Empty destructor */      
      ~PCDReader() {}
      /** \brief Various PCD file versions.
        *
        * PCD_V6 represents PCD files with version .6, which contain the following fields:
        * <ul>
        *  <li> lines beginning with # are treated as comments</li>
        *  <li> FIELDS ...</li>
        *  <li> SIZE ...</li>
        *  <li> TYPE ...</li>
        *  <li> COUNT ...</li>
        *  <li> WIDTH ...</li>
        *  <li> HEIGHT ...</li>
        *  <li> POINTS ...</li>
        *  <li> DATA ascii/binary</li>
        * </ul>
        * Everything that follows <b>DATA</b> is intepreted as data points and
        * will be read accordingly.
        *
        * PCD_V7 represents PCD files with version .7 and has an important
        * addon: it adds sensor origin/orientation (aka viewpoint) information
        * to a dataset through the use of a new header field:
        * <ul>
        *  <li> VIEWPOINT tx ty tz qw qx qy qz</li>
        * </ul>
        */
      enum
      {
        PCD_V6 = 0,
        PCD_V7 = 1
      };

      /** \brief Read a point cloud data header from a PCD file. 
        *
        * Load only the meta information (number of points, their types, etc),
        * and not the points themselves, from a given PCD file. Useful for fast
        * evaluation of the underlying data structure.
        *
        * Returns:
        *  * < 0 (-1) on error
        *  * > 0 on success
        * \param file_name the name of the file to load
        * \param cloud the resultant point cloud dataset (only the header will be filled)
        * \param origin the sensor acquisition origin (only for > PCD_V7 - null if not present)
        * \param orientation the sensor acquisition orientation (only for > PCD_V7 - identity if not present)
        * \param pcd_version the PCD version of the file (either PCD_V6 or PCD_V7)
        * \param binary_data is true if the PCD file contains binary data, false if ascii 
        * \param data_idx the offset of cloud data within the file
        */
      int 
      readHeader (const std::string &file_name, sensor_msgs::PointCloud2 &cloud, 
                  Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &pcd_version,
                  bool &binary_data, int &data_idx);

      /** \brief Read a point cloud data from a PCD file and store it into a sensor_msgs/PointCloud2.
        * \param file_name the name of the file containing the actual PointCloud data
        * \param cloud the resultant PointCloud message read from disk
        * \param origin the sensor acquisition origin (only for > PCD_V7 - null if not present)
        * \param orientation the sensor acquisition orientation (only for > PCD_V7 - identity if not present)
        * \param pcd_version the PCD version of the file (either PCD_V6 or PCD_V7)
        */
      int 
      read (const std::string &file_name, sensor_msgs::PointCloud2 &cloud, 
            Eigen::Vector4f &origin, Eigen::Quaternionf &orientation, int &pcd_version);

      /** \brief Read a point cloud data from a PCD file (PCD_V6 only!) and store it into a sensor_msgs/PointCloud2.
        * 
        * \note This function is provided for backwards compatibility only and
        * it can only read PCD_V6 files correctly, as sensor_msgs::PointCloud2
        * does not contain a sensor origin/orientation. Reading any file 
        * > PCD_V6 will generate a warning. 
        *
        * \param file_name the name of the file containing the actual PointCloud data
        * \param cloud the resultant PointCloud message read from disk
        */
      int 
      read (const std::string &file_name, sensor_msgs::PointCloud2 &cloud);

      /** \brief Read a point cloud data from any PCD file, and convert it to the given template format.
        * \param file_name the name of the file containing the actual PointCloud data
        * \param cloud the resultant PointCloud message read from disk
        */
      template<typename PointT> inline int
      read (const std::string &file_name, pcl::PointCloud<PointT> &cloud)
      {
        sensor_msgs::PointCloud2 blob;
        int pcd_version;
        int res = read (file_name, blob, cloud.sensor_origin_, cloud.sensor_orientation_, 
                        pcd_version);

        // Exit in case of error
        if (res < 0)
          return res;
        pcl::fromROSMsg (blob, cloud);
        return 0;
      }
  };

  /** \brief Point Cloud Data (PCD) file format writer.
    * \author <NAME>
    * \ingroup io
    */
  class PCL_EXPORTS PCDWriter : public FileWriter
  {
    public:
      PCDWriter() : FileWriter() {}
      ~PCDWriter() {}
      /** \brief Generate the header of a PCD v.7 file format
        * \param cloud the point cloud data message
        * \param origin the sensor acquisition origin
        * \param orientation the sensor acquisition orientation
        */
{'fraction_non_alphanumeric': 0.07710825795156113, 'fraction_numerical': 0.005544207761890867, 'mean_word_length': 2.384938271604938, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 79, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5869797', 'n_tokens_mistral': 3932, 'n_tokens_neox': 3743, 'n_words': 1623}