Point Cloud Library (PCL)  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
correspondence.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2010-2011, Willow Garage, Inc.
00006  *
00007  *  All rights reserved.
00008  *
00009  *  Redistribution and use in source and binary forms, with or without
00010  *  modification, are permitted provided that the following conditions
00011  *  are met:
00012  *
00013  *   * Redistributions of source code must retain the above copyright
00014  *     notice, this list of conditions and the following disclaimer.
00015  *   * Redistributions in binary form must reproduce the above
00016  *     copyright notice, this list of conditions and the following
00017  *     disclaimer in the documentation and/or other materials provided
00018  *     with the distribution.
00019  *   * Neither the name of Willow Garage, Inc. nor the names of its
00020  *     contributors may be used to endorse or promote products derived
00021  *     from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  *  $Id: correspondence.h 3746 2011-12-31 22:19:47Z rusu $
00037  */
00038 #ifndef PCL_COMMON_CORRESPONDENCE_H_
00039 #define PCL_COMMON_CORRESPONDENCE_H_
00040 
00041 #include <Eigen/Core>
00042 #include <boost/shared_ptr.hpp>
00043 #include <Eigen/Geometry>
00044 #include <vector>
00045 
00046 namespace pcl
00047 {
00054   struct Correspondence
00055   {
00057     int index_query;
00059     int index_match;
00061     float distance;
00062     
00066     inline Correspondence () : index_query (0), index_match (-1), 
00067                                distance (std::numeric_limits<float>::max ())
00068     {}
00069 
00071     inline Correspondence (int _index_query, int _index_match, float _distance) : 
00072       index_query (_index_query), index_match (_index_match), distance (_distance)
00073     {}
00074     
00075     EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
00076   };
00077   
00079   inline std::ostream& 
00080   operator << (std::ostream& os, const Correspondence& c)
00081   {
00082     os << c.index_query << " " << c.index_match << " " << c.distance;
00083     return (os);
00084   }
00085 
00086   typedef std::vector< pcl::Correspondence, Eigen::aligned_allocator<pcl::Correspondence> > Correspondences;
00087   typedef boost::shared_ptr<Correspondences> CorrespondencesPtr;
00088   typedef boost::shared_ptr<const Correspondences > CorrespondencesConstPtr;
00089 
00103   void
00104   getRejectedQueryIndices (const pcl::Correspondences &correspondences_before,
00105                            const pcl::Correspondences &correspondences_after,
00106                            std::vector<int>& indices,
00107                            bool presorting_required = true);
00108 
00114   struct PointCorrespondence3D : public Correspondence
00115   {
00116     Eigen::Vector3f point1;  
00117     Eigen::Vector3f point2;  
00118 
00119     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00120   };
00121   typedef std::vector<PointCorrespondence3D, Eigen::aligned_allocator<PointCorrespondence3D> > PointCorrespondences3DVector;
00122 
00128   struct PointCorrespondence6D : public PointCorrespondence3D
00129   {
00130     Eigen::Affine3f transformation;  
00131 
00132     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00133   };
00134   typedef std::vector<PointCorrespondence6D, Eigen::aligned_allocator<PointCorrespondence6D> > PointCorrespondences6DVector;
00135 
00141   inline bool
00142   isBetterCorrespondence (const Correspondence &pc1, const Correspondence &pc2)
00143   {
00144     return (pc1.distance > pc2.distance);
00145   }
00146 }
00147 
00148 #endif /* PCL_COMMON_CORRESPONDENCE_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines