Point Cloud Library (PCL)  1.5.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
point_types.hpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Willow Garage, Inc. nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  * $Id: point_types.hpp 4702 2012-02-23 09:39:33Z gedikli $
00035  *
00036  */
00037 
00038 #ifndef PCL_IMPL_POINT_TYPES_HPP_
00039 #define PCL_IMPL_POINT_TYPES_HPP_
00040 
00041 // Define all PCL point types
00042 #define PCL_POINT_TYPES         \
00043   (pcl::PointXYZ)               \
00044   (pcl::PointXYZI)              \
00045   (pcl::PointXYZL)              \
00046   (pcl::Label)                  \
00047   (pcl::PointXYZRGBA)           \
00048   (pcl::PointXYZRGB)            \
00049   (pcl::PointXYZRGBL)           \
00050   (pcl::PointXYZHSV)            \
00051   (pcl::PointXY)                \
00052   (pcl::InterestPoint)          \
00053   (pcl::Axis)                   \
00054   (pcl::Normal)                 \
00055   (pcl::PointNormal)            \
00056   (pcl::PointXYZRGBNormal)      \
00057   (pcl::PointXYZINormal)        \
00058   (pcl::PointWithRange)         \
00059   (pcl::PointWithViewpoint)     \
00060   (pcl::MomentInvariants)       \
00061   (pcl::PrincipalRadiiRSD)      \
00062   (pcl::Boundary)               \
00063   (pcl::PrincipalCurvatures)    \
00064   (pcl::PFHSignature125)        \
00065   (pcl::PFHRGBSignature250)     \
00066   (pcl::PPFSignature)           \
00067   (pcl::PPFRGBSignature)        \
00068   (pcl::NormalBasedSignature12) \
00069   (pcl::FPFHSignature33)        \
00070   (pcl::VFHSignature308)        \
00071   (pcl::Narf36)                 \
00072   (pcl::IntensityGradient)      \
00073   (pcl::PointWithScale)         \
00074   (pcl::ReferenceFrame)
00075 
00076 // Define all point types that include XYZ data
00077 #define PCL_XYZ_POINT_TYPES   \
00078   (pcl::PointXYZ)             \
00079   (pcl::PointXYZI)            \
00080   (pcl::PointXYZL)            \
00081   (pcl::PointXYZRGBA)         \
00082   (pcl::PointXYZRGB)          \
00083   (pcl::PointXYZRGBL)         \
00084   (pcl::PointXYZHSV)          \
00085   (pcl::InterestPoint)        \
00086   (pcl::PointNormal)          \
00087   (pcl::PointXYZRGBNormal)    \
00088   (pcl::PointXYZINormal)      \
00089   (pcl::PointWithRange)       \
00090   (pcl::PointWithViewpoint)   \
00091   (pcl::PointWithScale)
00092 
00093 // Define all point types with XYZ and label
00094 #define PCL_XYZL_POINT_TYPES  \
00095   (pcl::PointXYZL)            \
00096   (pcl::PointXYZRGBL)       
00097 
00098 
00099 // Define all point types that include normal[3] data
00100 #define PCL_NORMAL_POINT_TYPES  \
00101   (pcl::Normal)                 \
00102   (pcl::PointNormal)            \
00103   (pcl::PointXYZRGBNormal)      \
00104   (pcl::PointXYZINormal)
00105 
00106 // Define all point types that represent features
00107 #define PCL_FEATURE_POINT_TYPES \
00108   (pcl::PFHSignature125)        \
00109   (pcl::PFHRGBSignature250)     \
00110   (pcl::PPFSignature)           \
00111   (pcl::PPFRGBSignature)        \
00112   (pcl::NormalBasedSignature12) \
00113   (pcl::FPFHSignature33)        \
00114   (pcl::VFHSignature308)        \
00115   (pcl::Narf36)
00116 
00117 namespace pcl
00118 {
00119 
00120 #define PCL_ADD_POINT4D \
00121   EIGEN_ALIGN16 \
00122   union { \
00123     float data[4]; \
00124     struct { \
00125       float x; \
00126       float y; \
00127       float z; \
00128     }; \
00129   }; \
00130   inline Eigen::Map<Eigen::Vector3f> getVector3fMap () { return (Eigen::Vector3f::Map (data)); } \
00131   inline const Eigen::Map<const Eigen::Vector3f> getVector3fMap () const { return (Eigen::Vector3f::Map (data)); } \
00132   inline Eigen::Map<Eigen::Vector4f, Eigen::Aligned> getVector4fMap () { return (Eigen::Vector4f::MapAligned (data)); } \
00133   inline const Eigen::Map<const Eigen::Vector4f, Eigen::Aligned> getVector4fMap () const { return (Eigen::Vector4f::MapAligned (data)); } \
00134   inline Eigen::Map<Eigen::Array3f> getArray3fMap () { return (Eigen::Array3f::Map (data)); } \
00135   inline const Eigen::Map<const Eigen::Array3f> getArray3fMap () const { return (Eigen::Array3f::Map (data)); } \
00136   inline Eigen::Map<Eigen::Array4f, Eigen::Aligned> getArray4fMap () { return (Eigen::Array4f::MapAligned (data)); } \
00137   inline const Eigen::Map<const Eigen::Array4f, Eigen::Aligned> getArray4fMap () const { return (Eigen::Array4f::MapAligned (data)); }
00138 
00139 #define PCL_ADD_NORMAL4D \
00140   EIGEN_ALIGN16 \
00141   union { \
00142     float data_n[4]; \
00143     float normal[3]; \
00144     struct { \
00145       float normal_x; \
00146       float normal_y; \
00147       float normal_z; \
00148     }; \
00149   }; \
00150   inline Eigen::Map<Eigen::Vector3f> getNormalVector3fMap () { return (Eigen::Vector3f::Map (data_n)); } \
00151   inline const Eigen::Map<const Eigen::Vector3f> getNormalVector3fMap () const { return (Eigen::Vector3f::Map (data_n)); } \
00152   inline Eigen::Map<Eigen::Vector4f, Eigen::Aligned> getNormalVector4fMap () { return (Eigen::Vector4f::MapAligned (data_n)); } \
00153   inline const Eigen::Map<const Eigen::Vector4f, Eigen::Aligned> getNormalVector4fMap () const { return (Eigen::Vector4f::MapAligned (data_n)); }
00154 
00155   typedef Eigen::Map<Eigen::Array3f> Array3fMap;
00156   typedef const Eigen::Map<const Eigen::Array3f> Array3fMapConst;
00157   typedef Eigen::Map<Eigen::Array4f, Eigen::Aligned> Array4fMap;
00158   typedef const Eigen::Map<const Eigen::Array4f, Eigen::Aligned> Array4fMapConst;
00159   typedef Eigen::Map<Eigen::Vector3f> Vector3fMap;
00160   typedef const Eigen::Map<const Eigen::Vector3f> Vector3fMapConst;
00161   typedef Eigen::Map<Eigen::Vector4f, Eigen::Aligned> Vector4fMap;
00162   typedef const Eigen::Map<const Eigen::Vector4f, Eigen::Aligned> Vector4fMapConst;
00163 
00164   struct _PointXYZ
00165   {
00166     PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4])
00167     
00168     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00169   };
00170 
00171   /*struct PointXYZ
00172    {
00173    ADD_4D_POINT_WITH_XYZ;  // This adds the members x,y,z which can also be accessed using the point (which is float[4])
00174    //inline PointXYZ() {}
00175    //inline PointXYZ(float x, float y, float z) : x(x), y(y), z(z) {}
00176    };*/
00180   struct EIGEN_ALIGN16 PointXYZ : public _PointXYZ
00181   {
00182     inline PointXYZ ()
00183     {
00184       x = y = z = 0.0f;
00185       data[3] = 1.0f;
00186     }
00187 
00188     inline PointXYZ (float _x, float _y, float _z)
00189     { x = _x; y = _y; z = _z; data[3] = 1.0f;}
00190 
00191     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00192   };
00193 
00194   inline std::ostream& operator << (std::ostream& os, const PointXYZ& p)
00195   {
00196     os << "(" << p.x << "," << p.y << "," << p.z << ")";
00197     return (os);
00198   }
00199 
00219   struct RGB
00220   {
00221     union
00222     {
00223       struct
00224       {
00225         uint8_t b;
00226         uint8_t g;
00227         uint8_t r;
00228         uint8_t a;
00229       };
00230       uint32_t rgba;
00231     };
00232   };
00233 
00237   struct EIGEN_ALIGN16 _PointXYZI
00238   {
00239     PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4])
00240     union
00241     {
00242       struct
00243       {
00244         float intensity;
00245       };
00246       float data_c[4];
00247     };
00248     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00249   };
00250 
00251   struct PointXYZI : public _PointXYZI
00252   {
00253     inline PointXYZI ()
00254     {
00255       x = y = z = 0.0f; 
00256       data[3] = 1.0f;
00257       intensity = 0.0f;
00258     }
00259     inline PointXYZI (float _intensity)
00260     {
00261       x = y = z = 0.0f; 
00262       data[3] = 1.0f;
00263       intensity = _intensity;
00264     }
00265   };
00266 
00267   inline std::ostream& operator << (std::ostream& os, const PointXYZI& p)
00268   {
00269     os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.intensity << ")";
00270     return (os);
00271   }
00272 
00273   struct EIGEN_ALIGN16 PointXYZL
00274   {
00275     PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4])
00276     uint32_t label;
00277     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00278   };
00279   inline std::ostream& operator << (std::ostream& os, const PointXYZL& p)
00280   {
00281     os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.label << ")";
00282     return (os);
00283   }
00284   
00285   struct Label
00286   {
00287     uint32_t label;   
00288   };
00289   
00290   inline std::ostream& operator << (std::ostream& os, const Label& p)
00291   {
00292     os << "(" << p.label << ")";
00293     return (os);
00294   }
00295 
00316   struct EIGEN_ALIGN16 _PointXYZRGBA
00317   {
00318     PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4])
00319     EIGEN_ALIGN16
00320     union
00321     {
00322       struct
00323       {
00324         uint8_t b;
00325         uint8_t g;
00326         uint8_t r;
00327         uint8_t _unused;
00328       };
00329       uint32_t rgba;
00330     };
00331 
00332     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00333   };
00334 
00335   struct PointXYZRGBA : public _PointXYZRGBA
00336   {
00337     inline Eigen::Vector3i getRGBVector3i () { return (Eigen::Vector3i (r, g, b)); }
00338     inline const Eigen::Vector3i getRGBVector3i () const { return (Eigen::Vector3i (r, g, b)); }
00339     inline Eigen::Vector4i getRGBVector4i () { return (Eigen::Vector4i (r, g, b, 0)); }
00340     inline const Eigen::Vector4i getRGBVector4i () const { return (Eigen::Vector4i (r, g, b, 0)); }
00341   };
00342 
00343   inline std::ostream& operator << (std::ostream& os, const PointXYZRGBA& p)
00344   {
00345     unsigned char* rgba_ptr = (unsigned char*)&p.rgba;
00346     os << "(" << p.x << "," << p.y << "," << p.z << " - " << (int)(*rgba_ptr) << "," << (int)(*(rgba_ptr+1)) << "," << (int)(*(rgba_ptr+2)) << "," <<(int)(*(rgba_ptr+3)) << ")";
00347     return (os);
00348   }
00349 
00350   struct EIGEN_ALIGN16 _PointXYZRGB
00351   {
00352     PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4])
00353     union
00354     {
00355       union
00356       {
00357         struct
00358         {
00359           uint8_t b;
00360           uint8_t g;
00361           uint8_t r;
00362           uint8_t _unused;
00363         };
00364         float rgb;
00365       };
00366       uint32_t rgba;
00367     };
00368 
00369     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00370   };
00371 
00372   struct EIGEN_ALIGN16 _PointXYZRGBL
00373   {
00374     PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4])
00375     union
00376     {
00377       union
00378       {
00379         struct
00380         {
00381           uint8_t b;
00382           uint8_t g;
00383           uint8_t r;
00384           uint8_t a;
00385         };
00386         float rgb;
00387       };
00388       uint32_t rgba;
00389       uint32_t label;
00390     };
00391     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00392   };
00393 
00425   struct EIGEN_ALIGN16 PointXYZRGB : public _PointXYZRGB
00426   {
00427     inline PointXYZRGB ()
00428     {
00429       x = y = z = 0.0f; 
00430       data[3] = 1.0f;
00431       r = g = b = _unused = 0;
00432     }
00433     inline PointXYZRGB (uint8_t _r, uint8_t _g, uint8_t _b)
00434     {
00435       x = y = z = 0.0f; 
00436       data[3] = 1.0f;
00437       r = _r;
00438       g = _g;
00439       b = _b;
00440       _unused = 0;
00441     }
00442 
00443     inline Eigen::Vector3i getRGBVector3i () { return (Eigen::Vector3i (r, g, b)); }
00444     inline const Eigen::Vector3i getRGBVector3i () const { return (Eigen::Vector3i (r, g, b)); }
00445     inline Eigen::Vector4i getRGBVector4i () { return (Eigen::Vector4i (r, g, b, 0)); }
00446     inline const Eigen::Vector4i getRGBVector4i () const { return (Eigen::Vector4i (r, g, b, 0)); }
00447 
00448     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00449   };
00450   inline std::ostream& operator << (std::ostream& os, const PointXYZRGB& p)
00451   {
00452     os << "(" << p.x << "," << p.y << "," << p.z << " - " << (int) p.r << "," << (int) p.g << "," << (int) p.b << ")";
00453     return (os);
00454   }
00455 
00456   struct EIGEN_ALIGN16 PointXYZRGBL : public _PointXYZRGBL
00457   {
00458     inline PointXYZRGBL ()
00459     {
00460       x = y = z = 0.0f; 
00461       data[3] = 1.0f;
00462       r = g = b = 0; 
00463       label = 255;
00464     }
00465     inline PointXYZRGBL (uint8_t _r, uint8_t _g, uint8_t _b, uint32_t _label)
00466     {
00467       x = y = z = 0.0f; 
00468       data[3] = 1.0f;
00469       r = _r;
00470       g = _g;
00471       b = _b;
00472       label = _label;
00473     }
00474     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00475   };
00476   inline std::ostream& operator << (std::ostream& os, const PointXYZRGBL& p)
00477   {
00478     os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.r << "," << p.g << "," << p.b << " - " << p.label << ")";
00479     return (os);
00480   }
00481 
00482   struct _PointXYZHSV
00483   {
00484     PCL_ADD_POINT4D;    // This adds the members x,y,z which can also be accessed using the point (which is float[4])
00485     union
00486     {
00487       struct
00488       {
00489         float h;
00490         float s;
00491         float v;
00492       };
00493       float data_c[4];
00494     };
00495     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00496   } EIGEN_ALIGN16;
00497 
00498   struct EIGEN_ALIGN16 PointXYZHSV : public _PointXYZHSV
00499   {
00500     inline PointXYZHSV ()
00501     {
00502       x = y = z = 0.0f; data[3] = 1.0f;
00503       h = s = v = data_c[3] = 0;
00504     }
00505     inline PointXYZHSV (float _h, float _v, float _s)
00506     {
00507       h = _h; v = _v; s = _s;
00508       data_c[3] = 0;
00509     }
00510     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00511   };
00512   inline std::ostream& operator << (std::ostream& os, const PointXYZHSV& p)
00513   {
00514     os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.h << " , " <<  p.s << " , " << p.v << ")";
00515     return (os);
00516   }
00517 
00518 
00522   struct PointXY
00523   {
00524     float x;
00525     float y;
00526   };
00527   inline std::ostream& operator << (std::ostream& os, const PointXY& p)
00528   {
00529     os << "(" << p.x << "," << p.y << ")";
00530     return (os);
00531   }
00532 
00536   struct EIGEN_ALIGN16 InterestPoint
00537   {
00538     PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4])
00539     union
00540     {
00541       struct
00542       {
00543         float strength;
00544       };
00545       float data_c[4];
00546     };
00547     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00548   };
00549   inline std::ostream& operator << (std::ostream& os, const InterestPoint& p)
00550   {
00551     os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.strength << ")";
00552     return (os);
00553   }
00554 
00558   struct EIGEN_ALIGN16 _Normal
00559   {
00560     PCL_ADD_NORMAL4D; // This adds the member normal[3] which can also be accessed using the point (which is float[4])
00561     union
00562     {
00563       struct
00564       {
00565         float curvature;
00566       };
00567       float data_c[4];
00568     };
00569     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00570   };
00571 
00572   struct Normal : public _Normal
00573   {
00574     inline Normal ()
00575     {
00576       normal_x = normal_y = normal_z = data_n[3] = 0.0f;
00577     }
00578 
00579     inline Normal (float n_x, float n_y, float n_z)
00580     { normal_x = n_x; normal_y = n_y; normal_z = n_z; data_n[3] = 0.0f; }
00581 
00582     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00583   };
00584 
00585   inline std::ostream& operator << (std::ostream& os, const Normal& p)
00586   {
00587     os << "(" << p.normal[0] << "," << p.normal[1] << "," << p.normal[2] << " - " << p.curvature << ")";
00588     return (os);
00589   }
00590 
00594   struct EIGEN_ALIGN16 _Axis
00595   {
00596     PCL_ADD_NORMAL4D;
00597     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00598   };
00599 
00600   struct EIGEN_ALIGN16 Axis : public _Axis
00601   {
00602     inline Axis ()
00603     {
00604       normal_x = normal_y = normal_z = data_n[3] = 0.0f;
00605     }
00606 
00607     inline Axis (float n_x, float n_y, float n_z)
00608     { normal_x = n_x; normal_y = n_y; normal_z = n_z; data_n[3] = 0.0f; }
00609 
00610     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00611   };
00612 
00613   inline std::ostream& operator << (std::ostream& os, const Axis& p)
00614   {
00615     os << "(" << p.normal[0] << "," << p.normal[1] << "," << p.normal[2] << ")";
00616     return os;
00617   }
00618 
00619   inline std::ostream& operator << (std::ostream& os, const _Axis& p)
00620   {
00621     os << "(" << p.normal[0] << "," << p.normal[1] << "," << p.normal[2] << ")";
00622     return os;
00623   }
00624 
00628   struct EIGEN_ALIGN16 PointNormal
00629   {
00630     PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4])
00631     PCL_ADD_NORMAL4D; // This adds the member normal[3] which can also be accessed using the point (which is float[4])
00632     union
00633     {
00634       struct
00635       {
00636         float curvature;
00637       };
00638       float data_c[4];
00639     };
00640     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00641   };
00642   inline std::ostream& operator << (std::ostream& os, const PointNormal& p)
00643   {
00644     os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.normal[0] << "," << p.normal[1] << "," << p.normal[2] << " - " << p.curvature << ")";
00645     return (os);
00646   }
00647 
00677   struct EIGEN_ALIGN16 _PointXYZRGBNormal
00678   {
00679     PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4])
00680     PCL_ADD_NORMAL4D; // This adds the member normal[3] which can also be accessed using the point (which is float[4])
00681     union
00682     {
00683       struct
00684       {
00685         // RGB union
00686         union
00687         {
00688           struct
00689           {
00690             uint8_t b;
00691             uint8_t g;
00692             uint8_t r;
00693             uint8_t _unused;
00694           };
00695           float rgb;
00696           uint32_t rgba;
00697         };
00698         float curvature;
00699       };
00700       float data_c[4];
00701     };
00702     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00703   };
00704   struct PointXYZRGBNormal : public _PointXYZRGBNormal
00705   {
00706     inline PointXYZRGBNormal ()
00707     {
00708       x = y = z = 0.0f; data[3] = 1.0f;
00709       r = g = b = _unused = 0;
00710       normal_x = normal_y = normal_z = data_n[3] = 0.0f;
00711     }
00712 
00713     inline Eigen::Vector3i getRGBVector3i () { return (Eigen::Vector3i (r, g, b)); }
00714     inline const Eigen::Vector3i getRGBVector3i () const { return (Eigen::Vector3i (r, g, b)); }
00715     inline Eigen::Vector4i getRGBVector4i () { return (Eigen::Vector4i (r, g, b, 0)); }
00716     inline const Eigen::Vector4i getRGBVector4i () const { return (Eigen::Vector4i (r, g, b, 0)); }
00717   };
00718   inline std::ostream& operator << (std::ostream& os, const PointXYZRGBNormal& p)
00719   {
00720     os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.rgb << " - " << p.normal[0] << "," << p.normal[1] << "," << p.normal[2] << " - " << p.r << ", " << p.g << ", " << p.b << " - " << p.curvature << ")";
00721     return (os);
00722   }
00723 
00727   struct EIGEN_ALIGN16 PointXYZINormal
00728   {
00729     PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4])
00730     PCL_ADD_NORMAL4D; // This adds the member normal[3] which can also be accessed using the point (which is float[4])
00731     union
00732     {
00733       struct
00734       {
00735         float intensity;
00736         float curvature;
00737       };
00738       float data_c[4];
00739     };
00740     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00741   };
00742   inline std::ostream& operator << (std::ostream& os, const PointXYZINormal& p)
00743   {
00744     os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.intensity << " - " << p.normal[0] << "," << p.normal[1] << "," << p.normal[2] << " - " << p.curvature << ")";
00745     return (os);
00746   }
00747 
00751   struct EIGEN_ALIGN16 PointWithRange
00752   {
00753     PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4])
00754     union
00755     {
00756       struct
00757       {
00758         float range;
00759       };
00760       float data_c[4];
00761     };
00762     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00763   };
00764   inline std::ostream& operator << (std::ostream& os, const PointWithRange& p)
00765   {
00766     os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.range << ")";
00767     return (os);
00768   }
00769 
00770   struct EIGEN_ALIGN16 _PointWithViewpoint
00771   {
00772     PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4])
00773     union
00774     {
00775       struct
00776       {
00777         float vp_x;
00778         float vp_y;
00779         float vp_z;
00780       };
00781       float data_c[4];
00782     };
00783     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00784   };
00785 
00789   struct EIGEN_ALIGN16 PointWithViewpoint : public _PointWithViewpoint
00790   {
00791     PointWithViewpoint(float _x=0.0f, float _y=0.0f, float _z=0.0f, float _vp_x=0.0f, float _vp_y=0.0f, float _vp_z=0.0f)
00792     {
00793       x=_x; y=_y; z=_z; data[3] = 1.0f;
00794       vp_x=_vp_x; vp_y=_vp_y; vp_z=_vp_z;
00795     }
00796   };
00797   inline std::ostream& operator << (std::ostream& os, const PointWithViewpoint& p)
00798   {
00799     os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.vp_x << "," << p.vp_y << "," << p.vp_z << ")";
00800     return (os);
00801   }
00802 
00806   struct MomentInvariants
00807   {
00808     float j1, j2, j3;
00809   };
00810   inline std::ostream& operator << (std::ostream& os, const MomentInvariants& p)
00811   {
00812     os << "(" << p.j1 << "," << p.j2 << "," << p.j3 << ")";
00813     return (os);
00814   }
00815 
00819   struct PrincipalRadiiRSD
00820   {
00821     float r_min, r_max;
00822   };
00823   inline std::ostream& operator << (std::ostream& os, const PrincipalRadiiRSD& p)
00824   {
00825     os << "(" << p.r_min << "," << p.r_max << ")";
00826     return (os);
00827   }
00828 
00832   struct Boundary
00833   {
00834     uint8_t boundary_point;
00835   };
00836   inline std::ostream& operator << (std::ostream& os, const Boundary& p)
00837   {
00838     os << p.boundary_point;
00839     return (os);
00840   }
00841 
00845   struct PrincipalCurvatures
00846   {
00847     union
00848     {
00849       float principal_curvature[3];
00850       struct
00851       {
00852         float principal_curvature_x;
00853         float principal_curvature_y;
00854         float principal_curvature_z;
00855       };
00856     };
00857     float pc1;
00858     float pc2;
00859   };
00860   inline std::ostream& operator << (std::ostream& os, const PrincipalCurvatures& p)
00861   {
00862     os << "(" << p.principal_curvature[0] << "," << p.principal_curvature[1] << "," << p.principal_curvature[2] << " - " << p.pc1 << "," << p.pc2 << ")";
00863     return (os);
00864   }
00865 
00869   struct PFHSignature125
00870   {
00871     float histogram[125];
00872   };
00873   inline std::ostream& operator << (std::ostream& os, const PFHSignature125& p)
00874   {
00875     for (int i = 0; i < 125; ++i)
00876     os << (i == 0 ? "(" : "") << p.histogram[i] << (i < 124 ? ", " : ")");
00877     return (os);
00878   }
00879 
00883   struct PFHRGBSignature250
00884   {
00885     float histogram[250];
00886   };
00887   inline std::ostream& operator << (std::ostream& os, const PFHRGBSignature250& p)
00888   {
00889     for (int i = 0; i < 250; ++i)
00890     os << (i == 0 ? "(" : "") << p.histogram[i] << (i < 249 ? ", " : ")");
00891     return (os);
00892   }
00893 
00897   struct PPFSignature
00898   {
00899     float f1, f2, f3, f4;
00900     float alpha_m;
00901   };
00902   inline std::ostream& operator << (std::ostream& os, const PPFSignature& p)
00903   {
00904     os << "(" << p.f1 << ", " << p.f2 << ", " << p.f3 << ", " << p.f4 << ", " << p.alpha_m << ")";
00905     return (os);
00906   }
00907 
00911    struct PPFRGBSignature
00912    {
00913      float f1, f2, f3, f4;
00914      float r_ratio, g_ratio, b_ratio;
00915      float alpha_m;
00916    };
00917    inline std::ostream& operator << (std::ostream& os, const PPFRGBSignature& p)
00918    {
00919      os << "(" << p.f1 << ", " << p.f2 << ", " << p.f3 << ", " << p.f4 << ", " <<
00920          p.r_ratio << ", " << p.g_ratio << ", " << p.b_ratio << ", " << p.alpha_m << ")";
00921      return (os);
00922    }
00923 
00928   struct NormalBasedSignature12
00929   {
00930     float values[12];
00931   };
00932   inline std::ostream& operator << (std::ostream& os, const NormalBasedSignature12& p)
00933   {
00934     for (int i = 0; i < 12; ++i)
00935     os << (i == 0 ? "(" : "") << p.values[i] << (i < 11 ? ", " : ")");
00936     return (os);
00937   }
00938   
00942   struct ShapeContext
00943   {
00944     std::vector<float> descriptor;
00945     float rf[9];
00946   };
00947 
00948   inline std::ostream& operator << (std::ostream& os, const ShapeContext& p)
00949   {
00950     for (int i = 0; i < 9; ++i)
00951     os << (i == 0 ? "(" : "") << p.rf[i] << (i < 8 ? ", " : ")");
00952     for (size_t i = 0; i < p.descriptor.size (); ++i)
00953     os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < p.descriptor.size()-1 ? ", " : ")");
00954     return (os);
00955   }
00956 
00960   struct SHOT
00961   {
00962     std::vector<float> descriptor;
00963     float rf[9];
00964   };
00965 
00966   inline std::ostream& operator << (std::ostream& os, const SHOT& p)
00967   {
00968     for (int i = 0; i < 9; ++i)
00969     os << (i == 0 ? "(" : "") << p.rf[i] << (i < 8 ? ", " : ")");
00970     for (size_t i = 0; i < p.descriptor.size (); ++i)
00971     os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < p.descriptor.size()-1 ? ", " : ")");
00972     return (os);
00973   }
00974 
00978   struct EIGEN_ALIGN16 _ReferenceFrame
00979   {
00980     _Axis x_axis;
00981     _Axis y_axis;
00982     _Axis z_axis;
00983     union
00984     {
00985       struct
00986       {
00987         float confidence;
00988       };
00989       float data_c[4];
00990     };
00991 
00992     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00993   };
00994 
00995   struct EIGEN_ALIGN16 ReferenceFrame : public _ReferenceFrame
00996   {
00997     ReferenceFrame ()
00998     { confidence = 0.; }
00999 
01000     ReferenceFrame (_Axis const &x, _Axis const &y, _Axis const &z, float c = 1.0)
01001     {
01002       x_axis = x;
01003       y_axis = y;
01004       z_axis = z;
01005       confidence = c;
01006     }
01007     
01008     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
01009   };
01010 
01011   inline std::ostream& operator << (std::ostream& os, const ReferenceFrame& p)
01012   {
01013     os << "(" << p.x_axis << "," << p.y_axis << "," << p.z_axis << " - " << p.confidence << ")";
01014     return (os);
01015   }
01016 
01020   struct FPFHSignature33
01021   {
01022     float histogram[33];
01023   };
01024   inline std::ostream& operator << (std::ostream& os, const FPFHSignature33& p)
01025   {
01026     for (int i = 0; i < 33; ++i)
01027     os << (i == 0 ? "(" : "") << p.histogram[i] << (i < 32 ? ", " : ")");
01028     return (os);
01029   }
01030 
01034   struct VFHSignature308
01035   {
01036     float histogram[308];
01037   };
01038   inline std::ostream& operator << (std::ostream& os, const VFHSignature308& p)
01039   {
01040     for (int i = 0; i < 308; ++i)
01041     os << (i == 0 ? "(" : "") << p.histogram[i] << (i < 307 ? ", " : ")");
01042     return (os);
01043   }
01044 
01048   struct GFPFHSignature16
01049   {
01050       float histogram[16];
01051       static int descriptorSize() { return 16; }
01052   };
01053   inline std::ostream& operator << (std::ostream& os, const GFPFHSignature16& p)
01054   {
01055     for (int i = 0; i < p.descriptorSize (); ++i)
01056     os << (i == 0 ? "(" : "") << p.histogram[i] << (i < (p.descriptorSize () - 1) ? ", " : ")");
01057     return (os);
01058   }
01059 
01063   struct Narf36
01064   {
01065     float x, y, z, roll, pitch, yaw;
01066     float descriptor[36];
01067   };
01068   inline std::ostream& operator << (std::ostream& os, const Narf36& p)
01069   {
01070     os << p.x<<","<<p.y<<","<<p.z<<" - "<<p.roll*360.0/M_PI<<"deg,"<<p.pitch*360.0/M_PI<<"deg,"<<p.yaw*360.0/M_PI<<"deg - ";
01071     for (int i = 0; i < 36; ++i)
01072     os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < 35 ? ", " : ")");
01073     return (os);
01074   }
01075 
01079   struct BorderDescription
01080   {
01081     int x, y;
01082     BorderTraits traits;
01083     //std::vector<const BorderDescription*> neighbors;
01084   };
01085 
01086   inline std::ostream& operator << (std::ostream& os, const BorderDescription& p)
01087   {
01088     os << "(" << p.x << "," << p.y << ")";
01089     return (os);
01090   }
01091 
01095   struct IntensityGradient
01096   {
01097     union
01098     {
01099       float gradient[3];
01100       struct
01101       {
01102         float gradient_x;
01103         float gradient_y;
01104         float gradient_z;
01105       };
01106     };
01107   };
01108   inline std::ostream& operator << (std::ostream& os, const IntensityGradient& p)
01109   {
01110     os << "(" << p.gradient[0] << "," << p.gradient[1] << "," << p.gradient[2] << ")";
01111     return (os);
01112   }
01113 
01117   template <int N>
01118   struct Histogram
01119   {
01120     float histogram[N];
01121   };
01122   template <int N>
01123   inline std::ostream& operator << (std::ostream& os, const Histogram<N>& p)
01124   {
01125     for (int i = 0; i < N; ++i)
01126     os << (i == 0 ? "(" : "") << p.histogram[i] << (i < N-1 ? ", " : ")");
01127     return (os);
01128   }
01129 
01133   struct EIGEN_ALIGN16 PointWithScale
01134   {
01135     PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4])
01136     float scale;
01137     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
01138   };
01139   inline std::ostream& operator << (std::ostream& os, const PointWithScale& p)
01140   {
01141     os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.scale << ")";
01142     return (os);
01143   }
01144 
01148   struct EIGEN_ALIGN16 PointSurfel
01149   {
01150     PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4])
01151     PCL_ADD_NORMAL4D; // This adds the member normal[3] which can also be accessed using the point (which is float[4])
01152     union
01153     {
01154       struct
01155       {
01156         uint32_t rgba;
01157         float radius;
01158         float confidence;
01159         float curvature;
01160       };
01161       float data_c[4];
01162     };
01163     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
01164   };
01165   inline std::ostream& operator << (std::ostream& os, const PointSurfel& p)
01166   {
01167     unsigned char* rgba_ptr = (unsigned char*)&p.rgba;
01168     os <<
01169     "(" << p.x << "," << p.y << "," << p.z << " - " <<
01170     p.normal_x << "," << p.normal_y << "," << p.normal_z << " - " <<
01171     (int)(*rgba_ptr) << "," << (int)(*(rgba_ptr+1)) << "," << (int)(*(rgba_ptr+2)) << "," <<(int)(*(rgba_ptr+3)) << " - " <<
01172     p.radius << " - " << p.confidence << " - " << p.curvature << ")";
01173     return (os);
01174   }
01175 
01179   template <typename PointT> inline bool
01180   isFinite (const PointT &pt)
01181   {
01182     return (pcl_isfinite (pt.x) && pcl_isfinite (pt.y) && pcl_isfinite (pt.z));
01183   }
01184 
01185   // specification for pcl::Normal
01186   template <> inline bool
01187   isFinite<pcl::Normal> (const pcl::Normal &n)
01188   {
01189     return (pcl_isfinite (n.normal_x) && pcl_isfinite (n.normal_y) && pcl_isfinite (n.normal_z));
01190   }
01191 
01195   template <typename PointT> inline bool
01196   isFiniteFast (const PointT& pt)
01197   {
01198     return (pcl_isfinite (pt.x));
01199   }
01200 
01201   // specification for pcl::Normal
01202   template <> inline bool
01203   isFiniteFast<pcl::Normal> (const pcl::Normal& n)
01204   {
01205     return (pcl_isfinite (n.normal_x));
01206   }
01207 } // End namespace
01208 
01209 // Preserve API for PCL users < 1.4
01210 #include <pcl/common/distances.h>
01211 
01212 #endif