Loading...
Searching...
No Matches
crop_box.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2009-2011, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id: crop_box.h 1370 2011-06-19 01:06:01Z jspricke $
*
*/
#pragma once
#include <pcl/filters/filter_indices.h>
namespace pcl
{
/** \brief CropBox is a filter that allows the user to filter all the data
* inside of a given box.
*
* \author Justin Rosen
* \ingroup filters
*/
template<typename PointT>
class CropBox : public FilterIndices<PointT>
{
using Filter<PointT>::getClassName;
using PointCloud = typename Filter<PointT>::PointCloud;
using PointCloudPtr = typename PointCloud::Ptr;
using PointCloudConstPtr = typename PointCloud::ConstPtr;
public:
PCL_MAKE_ALIGNED_OPERATOR_NEW
using Ptr = shared_ptr<CropBox<PointT> >;
using ConstPtr = shared_ptr<const CropBox<PointT> >;
/** \brief Constructor.
* \param[in] extract_removed_indices Set to true if you want to be able to extract the indices of points being removed (default = false).
*/
CropBox (bool extract_removed_indices = false) :
FilterIndices<PointT> (extract_removed_indices),
min_pt_ (Eigen::Vector4f (-1, -1, -1, 1)),
max_pt_ (Eigen::Vector4f (1, 1, 1, 1)),
rotation_ (Eigen::Vector3f::Zero ()),
translation_ (Eigen::Vector3f::Zero ()),
transform_ (Eigen::Affine3f::Identity ())
{
filter_name_ = "CropBox";
}
/** \brief Set the minimum point of the box
* \param[in] min_pt the minimum point of the box
*/
inline void
setMin (const Eigen::Vector4f &min_pt)
{
min_pt_ = min_pt;
}
/** \brief Get the value of the minimum point of the box, as set by the user
* \return the value of the internal \a min_pt parameter.
*/
inline Eigen::Vector4f
getMin () const
{
return (min_pt_);
}
/** \brief Set the maximum point of the box
* \param[in] max_pt the maximum point of the box
*/
inline void
setMax (const Eigen::Vector4f &max_pt)
{
max_pt_ = max_pt;
}
/** \brief Get the value of the maximum point of the box, as set by the user
* \return the value of the internal \a max_pt parameter.
*/
inline Eigen::Vector4f
getMax () const
{
return (max_pt_);
}
/** \brief Set a translation value for the box
* \param[in] translation the (tx,ty,tz) values that the box should be translated by
*/
inline void
setTranslation (const Eigen::Vector3f &translation)
{
translation_ = translation;
}
/** \brief Get the value of the box translation parameter as set by the user. */
Eigen::Vector3f
getTranslation () const
{
return (translation_);
}
/** \brief Set a rotation value for the box
* \param[in] rotation the (rx,ry,rz) values that the box should be rotated by
*/
inline void
setRotation (const Eigen::Vector3f &rotation)
{
rotation_ = rotation;
}
/** \brief Get the value of the box rotatation parameter, as set by the user. */
inline Eigen::Vector3f
getRotation () const
{
return (rotation_);
}
/** \brief Set a transformation that should be applied to the cloud before filtering
* \param[in] transform an affine transformation that needs to be applied to the cloud before filtering
*/
inline void
setTransform (const Eigen::Affine3f &transform)
{
transform_ = transform;
}
/** \brief Get the value of the transformation parameter, as set by the user. */
inline Eigen::Affine3f
getTransform () const
{
return (transform_);
}
protected:
using PCLBase<PointT>::input_;
using PCLBase<PointT>::indices_;
using Filter<PointT>::filter_name_;
using FilterIndices<PointT>::negative_;
using FilterIndices<PointT>::keep_organized_;
using FilterIndices<PointT>::user_filter_value_;
using FilterIndices<PointT>::extract_removed_indices_;
using FilterIndices<PointT>::removed_indices_;
/** \brief Sample of point indices
* \param[out] indices the resultant point cloud indices
*/
void
applyFilter (Indices &indices) override;
private:
/** \brief The minimum point of the box. */
Eigen::Vector4f min_pt_;
/** \brief The maximum point of the box. */
Eigen::Vector4f max_pt_;
/** \brief The 3D rotation for the box. */
Eigen::Vector3f rotation_;
/** \brief The 3D translation for the box. */
Eigen::Vector3f translation_;
/** \brief The affine transform applied to the cloud. */
Eigen::Affine3f transform_;
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/** \brief CropBox is a filter that allows the user to filter all the data
* inside of a given box.
*
* \author Justin Rosen
* \ingroup filters
*/
template<>
class PCL_EXPORTS CropBox<pcl::PCLPointCloud2> : public FilterIndices<pcl::PCLPointCloud2>
{
using Filter<pcl::PCLPointCloud2>::filter_name_;
using Filter<pcl::PCLPointCloud2>::getClassName;
using PCLPointCloud2 = pcl::PCLPointCloud2;
using PCLPointCloud2Ptr = PCLPointCloud2::Ptr;
using PCLPointCloud2ConstPtr = PCLPointCloud2::ConstPtr;
public:
PCL_MAKE_ALIGNED_OPERATOR_NEW
/** \brief Constructor.
* \param[in] extract_removed_indices Set to true if you want to be able to extract the indices of points being removed (default = false).
*/
CropBox (bool extract_removed_indices = false) :
FilterIndices<pcl::PCLPointCloud2>::FilterIndices (extract_removed_indices),
min_pt_(Eigen::Vector4f (-1, -1, -1, 1)),
max_pt_(Eigen::Vector4f (1, 1, 1, 1)),
translation_ (Eigen::Vector3f::Zero ()),
rotation_ (Eigen::Vector3f::Zero ()),
transform_(Eigen::Affine3f::Identity ())
{
filter_name_ = "CropBox";
}
/** \brief Set the minimum point of the box
* \param[in] min_pt the minimum point of the box
*/
inline void
setMin (const Eigen::Vector4f& min_pt)
{
min_pt_ = min_pt;
}
/** \brief Get the value of the minimum point of the box, as set by the user
* \return the value of the internal \a min_pt parameter.
*/
inline Eigen::Vector4f
getMin () const
{
return (min_pt_);
}
/** \brief Set the maximum point of the box
* \param[in] max_pt the maximum point of the box
*/
inline void
setMax (const Eigen::Vector4f &max_pt)
{
max_pt_ = max_pt;
}
/** \brief Get the value of the maxiomum point of the box, as set by the user
* \return the value of the internal \a max_pt parameter.
*/
inline Eigen::Vector4f
getMax () const
{
return (max_pt_);
}
/** \brief Set a translation value for the box
* \param[in] translation the (tx,ty,tz) values that the box should be translated by
*/
inline void
setTranslation (const Eigen::Vector3f &translation)
{
translation_ = translation;
}
/** \brief Get the value of the box translation parameter as set by the user. */
inline Eigen::Vector3f
getTranslation () const
{
return (translation_);
}
/** \brief Set a rotation value for the box
* \param[in] rotation the (rx,ry,rz) values that the box should be rotated by
*/
inline void
setRotation (const Eigen::Vector3f &rotation)
{
rotation_ = rotation;
}
/** \brief Get the value of the box rotatation parameter, as set by the user. */
inline Eigen::Vector3f
getRotation () const
{
return (rotation_);
}
/** \brief Set a transformation that should be applied to the cloud before filtering
* \param[in] transform an affine transformation that needs to be applied to the cloud before filtering
*/
inline void
setTransform (const Eigen::Affine3f &transform)
{
transform_ = transform;
}
/** \brief Get the value of the transformation parameter, as set by the user. */
inline Eigen::Affine3f
getTransform () const
{
return (transform_);
}
protected:
/** \brief Sample of point indices into a separate PointCloud
* \param output the resultant point cloud
*/
void
applyFilter (PCLPointCloud2 &output) override;
/** \brief Sample of point indices
* \param indices the resultant point cloud indices
*/
void
applyFilter (Indices &indices) override;
/** \brief The minimum point of the box. */
Eigen::Vector4f min_pt_;
/** \brief The maximum point of the box. */
Eigen::Vector4f max_pt_;
/** \brief The 3D translation for the box. */
Eigen::Vector3f translation_;
/** \brief The 3D rotation for the box. */
Eigen::Vector3f rotation_;
/** \brief The affine transform applied to the cloud. */
Eigen::Affine3f transform_;
};
}
#ifdef PCL_NO_PRECOMPILE
#include <pcl/filters/impl/crop_box.hpp>
#endif
pcl::CropBox< pcl::PCLPointCloud2 >::applyFilter
void applyFilter(PCLPointCloud2 &output) override
Sample of point indices into a separate PointCloud.
pcl::CropBox< pcl::PCLPointCloud2 >::getTranslation
Eigen::Vector3f getTranslation() const
Get the value of the box translation parameter as set by the user.
Definition crop_box.h:274
pcl::CropBox< pcl::PCLPointCloud2 >::translation_
Eigen::Vector3f translation_
The 3D translation for the box.
Definition crop_box.h:329
pcl::CropBox< pcl::PCLPointCloud2 >::setMax
void setMax(const Eigen::Vector4f &max_pt)
Set the maximum point of the box.
Definition crop_box.h:249
pcl::CropBox< pcl::PCLPointCloud2 >::applyFilter
void applyFilter(Indices &indices) override
Sample of point indices.
pcl::CropBox< pcl::PCLPointCloud2 >::setTransform
void setTransform(const Eigen::Affine3f &transform)
Set a transformation that should be applied to the cloud before filtering.
Definition crop_box.h:299
pcl::CropBox< pcl::PCLPointCloud2 >::transform_
Eigen::Affine3f transform_
The affine transform applied to the cloud.
Definition crop_box.h:333
pcl::CropBox< pcl::PCLPointCloud2 >::CropBox
PCL_MAKE_ALIGNED_OPERATOR_NEW CropBox(bool extract_removed_indices=false)
Constructor.
Definition crop_box.h:216
pcl::CropBox< pcl::PCLPointCloud2 >::getMax
Eigen::Vector4f getMax() const
Get the value of the maxiomum point of the box, as set by the user.
Definition crop_box.h:258
pcl::CropBox< pcl::PCLPointCloud2 >::setMin
void setMin(const Eigen::Vector4f &min_pt)
Set the minimum point of the box.
Definition crop_box.h:231
pcl::CropBox< pcl::PCLPointCloud2 >::getRotation
Eigen::Vector3f getRotation() const
Get the value of the box rotatation parameter, as set by the user.
Definition crop_box.h:290
pcl::CropBox< pcl::PCLPointCloud2 >::setRotation
void setRotation(const Eigen::Vector3f &rotation)
Set a rotation value for the box.
Definition crop_box.h:283
pcl::CropBox< pcl::PCLPointCloud2 >::setTranslation
void setTranslation(const Eigen::Vector3f &translation)
Set a translation value for the box.
Definition crop_box.h:267
pcl::CropBox< pcl::PCLPointCloud2 >::rotation_
Eigen::Vector3f rotation_
The 3D rotation for the box.
Definition crop_box.h:331
pcl::CropBox< pcl::PCLPointCloud2 >::max_pt_
Eigen::Vector4f max_pt_
The maximum point of the box.
Definition crop_box.h:327
pcl::CropBox< pcl::PCLPointCloud2 >::getMin
Eigen::Vector4f getMin() const
Get the value of the minimum point of the box, as set by the user.
Definition crop_box.h:240
pcl::CropBox< pcl::PCLPointCloud2 >::getTransform
Eigen::Affine3f getTransform() const
Get the value of the transformation parameter, as set by the user.
Definition crop_box.h:306
pcl::CropBox< pcl::PCLPointCloud2 >::min_pt_
Eigen::Vector4f min_pt_
The minimum point of the box.
Definition crop_box.h:325
pcl::CropBox
CropBox is a filter that allows the user to filter all the data inside of a given box.
Definition crop_box.h:54
pcl::CropBox::setRotation
void setRotation(const Eigen::Vector3f &rotation)
Set a rotation value for the box.
Definition crop_box.h:137
pcl::CropBox::getRotation
Eigen::Vector3f getRotation() const
Get the value of the box rotatation parameter, as set by the user.
Definition crop_box.h:144
pcl::CropBox::applyFilter
void applyFilter(Indices &indices) override
Sample of point indices.
Definition crop_box.hpp:51
pcl::CropBox::CropBox
CropBox(bool extract_removed_indices=false)
Constructor.
Definition crop_box.h:70
pcl::CropBox::setTransform
void setTransform(const Eigen::Affine3f &transform)
Set a transformation that should be applied to the cloud before filtering.
Definition crop_box.h:153
pcl::CropBox::getMax
Eigen::Vector4f getMax() const
Get the value of the maximum point of the box, as set by the user.
Definition crop_box.h:112
pcl::CropBox::getMin
Eigen::Vector4f getMin() const
Get the value of the minimum point of the box, as set by the user.
Definition crop_box.h:94
pcl::CropBox::Ptr
shared_ptr< CropBox< PointT > > Ptr
Definition crop_box.h:64
pcl::CropBox::setMin
void setMin(const Eigen::Vector4f &min_pt)
Set the minimum point of the box.
Definition crop_box.h:85
pcl::CropBox::setTranslation
void setTranslation(const Eigen::Vector3f &translation)
Set a translation value for the box.
Definition crop_box.h:121
pcl::CropBox::ConstPtr
shared_ptr< const CropBox< PointT > > ConstPtr
Definition crop_box.h:65
pcl::CropBox::getTranslation
Eigen::Vector3f getTranslation() const
Get the value of the box translation parameter as set by the user.
Definition crop_box.h:128
pcl::CropBox::setMax
void setMax(const Eigen::Vector4f &max_pt)
Set the maximum point of the box.
Definition crop_box.h:103
pcl::CropBox::getTransform
Eigen::Affine3f getTransform() const
Get the value of the transformation parameter, as set by the user.
Definition crop_box.h:160
pcl::Filter
Filter represents the base filter class.
Definition filter.h:81
pcl::Filter::extract_removed_indices_
bool extract_removed_indices_
Set to true if we want to return the indices of the removed points.
Definition filter.h:161
pcl::Filter::getClassName
const std::string & getClassName() const
Get a string representation of the name of this class.
Definition filter.h:174
pcl::Filter::filter_name_
std::string filter_name_
The filter name.
Definition filter.h:158
pcl::Filter::removed_indices_
IndicesPtr removed_indices_
Indices of the points that are removed.
Definition filter.h:155
pcl::FilterIndices
FilterIndices represents the base class for filters that are about binary point removal.
Definition filter_indices.h:75
pcl::FilterIndices::user_filter_value_
float user_filter_value_
The user given value that the filtered point dimensions should be set to (default = NaN).
Definition filter_indices.h:173
pcl::FilterIndices::keep_organized_
bool keep_organized_
False = remove points (default), true = redefine points, keep structure.
Definition filter_indices.h:170
pcl::FilterIndices::negative_
bool negative_
False = normal filter behavior (default), true = inverted behavior.
Definition filter_indices.h:167
pcl::PCLBase
PCL base class.
Definition pcl_base.h:70
pcl::PCLBase::input_
PointCloudConstPtr input_
The input point cloud dataset.
Definition pcl_base.h:147
pcl::PCLBase::indices_
IndicesPtr indices_
A pointer to the vector of point indices to use.
Definition pcl_base.h:150
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition point_cloud.h:173
pcl::PointCloud::Ptr
shared_ptr< PointCloud< PointT > > Ptr
Definition point_cloud.h:413
pcl::PointCloud::ConstPtr
shared_ptr< const PointCloud< PointT > > ConstPtr
Definition point_cloud.h:414
PCL_MAKE_ALIGNED_OPERATOR_NEW
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition memory.h:86
Eigen
Definition bfgs.h:10
pcl
Definition convolution.h:46
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133
pcl::PCLPointCloud2
Definition PCLPointCloud2.h:17
pcl::PCLPointCloud2::Ptr
shared_ptr< ::pcl::PCLPointCloud2 > Ptr
Definition PCLPointCloud2.h:35
pcl::PCLPointCloud2::ConstPtr
shared_ptr< const ::pcl::PCLPointCloud2 > ConstPtr
Definition PCLPointCloud2.h:36
pcl::PointXYZRGB
A point structure representing Euclidean xyz coordinates, and the RGB color.
Definition point_types.hpp:594