Go to the documentation of this file.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 #include "DistanceLimit.h"
00036 #include "pointmatcher/Functions.h"
00037
00038
00039
00040 template<typename T>
00041 DistanceLimitDataPointsFilter<T>::DistanceLimitDataPointsFilter(const Parameters& params) :
00042 PointMatcher<T>::DataPointsFilter("DistanceLimitDataPointsFilter",
00043 DistanceLimitDataPointsFilter::availableParameters(), params),
00044 dim(Parametrizable::get<unsigned>("dim")),
00045 dist(Parametrizable::get<T>("dist")),
00046 removeInside(Parametrizable::get<bool>("removeInside"))
00047 {
00048 }
00049
00050 template<typename T>
00051 typename PointMatcher<T>::DataPoints DistanceLimitDataPointsFilter<T>::filter(
00052 const DataPoints& input)
00053 {
00054 DataPoints output(input);
00055 inPlaceFilter(output);
00056 return output;
00057 }
00058
00059
00060 template<typename T>
00061 void DistanceLimitDataPointsFilter<T>::inPlaceFilter(
00062 DataPoints& cloud)
00063 {
00064 using namespace PointMatcherSupport;
00065
00066 if(dim >= cloud.features.rows() - 1)
00067 {
00068 throw InvalidParameter(
00069 (boost::format("DistanceLimitDataPointsFilter: Error, filtering on dimension number %1%, larger than authorized axis id %2%") % dim % (cloud.features.rows() - 2)).str());
00070 }
00071
00072 const int nbPointsIn = cloud.features.cols();
00073 const int nbRows = cloud.features.rows();
00074
00075 int j = 0;
00076 if(dim == -1)
00077 {
00078 const T absMaxDist = anyabs(dist);
00079 for(int i = 0; i < nbPointsIn; ++i)
00080 {
00081 if(removeInside)
00082 {
00083 if(cloud.features.col(i).head(nbRows-1).norm() > absMaxDist)
00084 {
00085 cloud.setColFrom(j, cloud, i);
00086 ++j;
00087 }
00088 }
00089 else
00090 {
00091 if(cloud.features.col(i).head(nbRows-1).norm() < absMaxDist)
00092 {
00093 cloud.setColFrom(j, cloud, i);
00094 ++j;
00095 }
00096 }
00097 }
00098 }
00099 else
00100 {
00101 for(int i = 0; i < nbPointsIn; ++i)
00102 {
00103 if(removeInside)
00104 {
00105 if((cloud.features(dim, i)) > dist)
00106 {
00107 cloud.setColFrom(j, cloud, i);
00108 ++j;
00109 }
00110 }
00111 else
00112 {
00113 if((cloud.features(dim, i)) < dist)
00114 {
00115 cloud.setColFrom(j, cloud, i);
00116 ++j;
00117 }
00118 }
00119 }
00120 }
00121
00122 cloud.conservativeResize(j);
00123 }
00124
00125 template struct DistanceLimitDataPointsFilter<float>;
00126 template struct DistanceLimitDataPointsFilter<double>;