if ((diff2min <= displacement.array()).all() && (diff2max >= displacement.array()).all())
if ((diff2min <= displacement.array()).all() && (diff2max >= displacement.array()).all())
neighbors[ni] = leaf_layout_[((ijk + displacement - min_b_).dot(divb_mul_))]; // .at() can be omitted
neighbors[ni] = leaf_layout_[((ijk + displacement - min_b_).dot(divb_mul_))]; // .at() can be omitted
else
else
neighbors[ni] = -1; // cell is out of bounds, consider it empty
neighbors[ni] = -1; // cell is out of bounds, consider it empty
}
}
return (neighbors);
return (neighbors);
}
}
/** \brief Returns the layout of the leafs for fast access to cells relative to current position.
/** \brief Returns the layout of the leafs for fast access to cells relative to current position.
* \note position at (i-min_x) + (j-min_y)*div_x + (k-min_z)*div_x*div_y holds the index of the element at coordinates (i,j,k) in the grid (-1 if empty)
* \note position at (i-min_x) + (j-min_y)*div_x + (k-min_z)*div_x*div_y holds the index of the element at coordinates (i,j,k) in the grid (-1 if empty)
*/
*/
inline std::vector<int>
inline std::vector<int>
getLeafLayout() const { return (leaf_layout_); }
getLeafLayout() const
{
return (leaf_layout_);
}
/** \brief Returns the corresponding (i,j,k) coordinates in the grid of point (x,y,z).
/** \brief Returns the corresponding (i,j,k) coordinates in the grid of point (x,y,z).
* \param[in] x the X point coordinate to get the (i, j, k) index at
* \param[in] x the X point coordinate to get the (i, j, k) index at
* \param[in] y the Y point coordinate to get the (i, j, k) index at
* \param[in] y the Y point coordinate to get the (i, j, k) index at
* \param[in] z the Z point coordinate to get the (i, j, k) index at
* \param[in] z the Z point coordinate to get the (i, j, k) index at
*/
*/
inline Eigen::Vector3i
inline Eigen::Vector3i
getGridCoordinates(float x, float y, float z) const
getGridCoordinates(float x, float y, float z) const
int idx = ((Eigen::Vector4i() << ijk, 0).finished() - min_b_).dot(divb_mul_);
int idx = ((Eigen::Vector4i() << ijk, 0).finished() - min_b_).dot(divb_mul_);
if (idx < 0 || idx >= static_cast<int>(leaf_layout_.size())) // this checks also if leaf_layout_.size () == 0 i.e. everything was computed as needed
if (idx < 0 || idx >= static_cast<int>(leaf_layout_.size()))
// this checks also if leaf_layout_.size () == 0 i.e. everything was computed as needed
{
{
//if (verbose)
// PCL_ERROR ("[pcl::%s::getCentroidIndexAt] Specified coordinate is outside grid bounds, or leaf layout is not saved, make sure to call setSaveLeafLayout(true) and filter(output) first!\n", getClassName ().c_str ());
return (-1);
return (-1);
}
}
return (leaf_layout_[idx]);
return (leaf_layout_[idx]);
}
}
/** \brief Provide the name of the field to be used for filtering data. In conjunction with \a setFilterLimits,
* points having values outside this interval will be discarded.
* \param[in] field_name the name of the field that contains values used for filtering
/** \brief Get the field filter limits (min/max) set by the user. The default values are -FLT_MAX, FLT_MAX.
/** \brief Get the field filter limits (min/max) set by the user. The default values are -std::numeric_limits<float>::max(), std::numeric_limits<float>::max().
* \param[out] limit_min the minimum allowed field value
* \param[out] limit_min the minimum allowed field value
* \param[out] limit_max the maximum allowed field value
* \param[out] limit_max the maximum allowed field value