00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef PCL_REGISTRATION_CORRESPONDENCE_REJECTION_H_
00038 #define PCL_REGISTRATION_CORRESPONDENCE_REJECTION_H_
00039
00040 #include <pcl/registration/correspondence_types.h>
00041 #include <pcl/registration/correspondence_sorting.h>
00042
00043 namespace pcl
00044 {
00045 namespace registration
00046 {
00047
00051
00054
00055
00056
00057 class CorrespondenceRejector
00058 {
00059
00060 public:
00061
00063
00064 CorrespondenceRejector() : input_correspondences_() {};
00065
00067
00070 virtual inline void setInputCorrespondences(const CorrespondencesConstPtr &correspondences) { input_correspondences_ = correspondences; };
00071
00073
00074 inline CorrespondencesConstPtr getInputCorrespondences() { return input_correspondences_; };
00075
00076 inline void getCorrespondeces(pcl::registration::Correspondences &correspondences)
00077 {
00078
00079
00080 if ( !input_correspondences_ || (input_correspondences_->size() == 0) )
00081 return;
00082
00083 applyRejection(correspondences);
00084
00085
00086 }
00087
00089
00090 virtual inline void getCorrespondences(const pcl::registration::Correspondences& original_correspondences, pcl::registration::Correspondences& remaining_correspondences) = 0;
00091
00092 static bool compareCorrespondencesDistance(pcl::registration::Correspondence a, pcl::registration::Correspondence b) { return (a.distance < b.distance); }
00093
00094 inline void getRejectedQueryIndices(const std::vector<pcl::registration::Correspondence> &correspondences, std::vector<int>& indices)
00095 {
00096 if ( !input_correspondences_ || input_correspondences_->size() == 0 )
00097 {
00098 ROS_WARN ("[pcl::%s::getRejectedQueryIndices] Input correspondences not set (lookup of rejected correspondences _not_ possible).", getClassName ().c_str ());
00099 return;
00100 }
00101
00102 std::vector<int> indices_before, indices_after;
00103 indices_before.resize(input_correspondences_->size());
00104 for (unsigned int i = 0; i < input_correspondences_->size(); ++i)
00105 indices_before[i] = input_correspondences_->at(i).indexQuery;
00106 indices_after.resize(correspondences.size());
00107 for (unsigned int i = 0; i < correspondences.size(); ++i)
00108 indices_after[i] = correspondences.at(i).indexQuery;
00109
00110 std::vector<int> remaining_indices;
00111 set_difference (
00112 indices_before.begin (), indices_before.end (),
00113 indices_after.begin (), indices_after.end (),
00114 inserter (remaining_indices, remaining_indices.begin ()));
00115 indices = remaining_indices;
00116 }
00117
00118 protected:
00119
00121 std::string rejection_name_;
00122
00124 CorrespondencesConstPtr input_correspondences_;
00125
00127
00128 inline const std::string& getClassName () const { return (rejection_name_); }
00129
00131
00132 virtual void applyRejection(Correspondences &correspondences) = 0;
00133 };
00134
00135 }
00136 }
00137
00138
00139 #endif