65 inPlaceFilter(output);
79 const size_t pointsCount(cloud.
features.cols());
86 throw InvalidField(
"SphericalityDataPointsFilter: Error, no eigValues found in descriptors.");
91 for(
unsigned int i = 0; i < labelDim ; ++i)
93 if (insertDim != descDim)
94 throw InvalidField(
"SurfaceNormalDataPointsFilter: Error, descriptor labels do not match descriptor data");
97 const size_t unidimensionalDescriptorDimension(1);
100 boost::optional<View> sphericality;
101 boost::optional<View> unstructureness;
102 boost::optional<View> structureness;
105 cloudLabels.push_back(
Label(
"sphericality", unidimensionalDescriptorDimension));
106 if (keepUnstructureness)
107 cloudLabels.push_back(
Label(
"unstructureness", unidimensionalDescriptorDimension));
108 if (keepStructureness)
109 cloudLabels.push_back(
Label(
"structureness", unidimensionalDescriptorDimension));
116 if (eigValues.rows() != 3)
118 throw InvalidField(
"SphericalityDataPointsFilter: Error, the number of eigValues is not 3.");
122 if (keepUnstructureness)
124 if (keepStructureness)
128 for (
size_t i = 0; i < pointsCount; ++i)
131 Vector eig_vals_col = eigValues.col(i);
133 std::sort(eig_vals_col.data(),eig_vals_col.data()+eig_vals_col.size());
137 T unstructurenessVal;
142 if (eig_vals_col(2) < std::numeric_limits<T>::min() ||
143 eig_vals_col(1) < 0.0 ||
144 eig_vals_col(0) < 0.0)
148 sphericalityVal = std::numeric_limits<T>::quiet_NaN();
149 unstructurenessVal = std::numeric_limits<T>::quiet_NaN();
150 structurenessVal = std::numeric_limits<T>::quiet_NaN();
152 }
else if (eig_vals_col(1) < std::numeric_limits<T>::min()) {
154 sphericalityVal = 0.0;
155 unstructurenessVal = 0.0;
156 structurenessVal = 0.0;
161 unstructurenessVal = eig_vals_col(0) / eig_vals_col(2);
162 structurenessVal = (eig_vals_col(1) / eig_vals_col(2)) *
163 ((eig_vals_col(1) - eig_vals_col(0)) / sqrt(eig_vals_col(0)*eig_vals_col(0) + eig_vals_col(1)*eig_vals_col(1)));
164 sphericalityVal = unstructurenessVal - structurenessVal;
169 (sphericality.get())(0,i) = sphericalityVal;
172 (unstructureness.get())(0,i) = unstructurenessVal;
174 (structureness.get())(0,i) = structurenessVal;