Point Cloud Library (PCL) 1.13.0
Loading...
Searching...
No Matches
box_clipper3D.h
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Point Cloud Library (PCL) - www.pointclouds.org
5 * Copyright (c) 2010-2011, Willow Garage, Inc.
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials provided
18 * with the distribution.
19 * * Neither the name of the copyright holder(s) nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37
38#pragma once
39
40#include <pcl/memory.h>
41#include <pcl/pcl_macros.h>
42#include "clipper3D.h"
43
44namespace pcl
45{
46 /**
47 * \author Suat Gedikli <gedikli@willowgarage.com>
48 * \brief Implementation of a box clipper in 3D. Actually it allows affine transformations, thus any parallelepiped in general pose.
49 * The affine transformation is used to transform the point before clipping it using the unit cube centered at origin and with an extend of -1 to +1 in each dimension
50 * \ingroup filters
51 */
52 template<typename PointT>
53 class BoxClipper3D : public Clipper3D<PointT>
54 {
55 public:
56
57 using Ptr = shared_ptr<BoxClipper3D<PointT> >;
58 using ConstPtr = shared_ptr<const BoxClipper3D<PointT> >;
59
60
61 /**
62 * \author Suat Gedikli <gedikli@willowgarage.com>
63 * \brief Constructor taking an affine transformation matrix, which allows also shearing of the clipping area
64 * \param[in] transformation the 3x3 affine transformation matrix that is used to describe the unit cube
65 */
66 BoxClipper3D (const Eigen::Affine3f& transformation);
67
68 /**
69 * \brief creates a BoxClipper object with a scaled box in general pose
70 * \param[in] rodrigues the rotation axis and angle given by the vector direction and length respectively
71 * \param[in] translation the position of the box center
72 * \param[in] box_size the size of the box for each dimension
73 */
74 BoxClipper3D (const Eigen::Vector3f& rodrigues, const Eigen::Vector3f& translation, const Eigen::Vector3f& box_size);
75
76 /**
77 * \brief Set the affine transformation
78 * \param[in] transformation
79 */
80 void setTransformation (const Eigen::Affine3f& transformation);
81
82 /**
83 * \brief sets the box in general pose given by the orientation position and size
84 * \param[in] rodrigues the rotation axis and angle given by the vector direction and length respectively
85 * \param[in] translation the position of the box center
86 * \param[in] box_size the size of the box for each dimension
87 */
88 void setTransformation (const Eigen::Vector3f& rodrigues, const Eigen::Vector3f& translation, const Eigen::Vector3f& box_size);
89
90 /**
91 * \brief virtual destructor
92 */
93 ~BoxClipper3D () noexcept override;
94
95 bool
96 clipPoint3D (const PointT& point) const override;
97
98 bool
99 clipLineSegment3D (PointT& from, PointT& to) const override;
100
101 void
102 clipPlanarPolygon3D (std::vector<PointT, Eigen::aligned_allocator<PointT> >& polygon) const override;
103
104 void
105 clipPlanarPolygon3D (const std::vector<PointT, Eigen::aligned_allocator<PointT> >& polygon, std::vector<PointT, Eigen::aligned_allocator<PointT> >& clipped_polygon) const override;
106
107 void
108 clipPointCloud3D (const pcl::PointCloud<PointT> &cloud_in, Indices& clipped, const Indices& indices = Indices ()) const override;
109
111 clone () const override;
112
113 protected:
114 float getDistance (const PointT& point) const;
115 void transformPoint (const PointT& pointIn, PointT& pointOut) const;
116 private:
117 /**
118 * \brief the affine transformation that is applied before clipping is done on the unit cube.
119 */
120 Eigen::Affine3f transformation_;
121
122 public:
124 };
125}
126
127#include <pcl/filters/impl/box_clipper3D.hpp>
Implementation of a box clipper in 3D. Actually it allows affine transformations, thus any parallelep...
void transformPoint(const PointT &pointIn, PointT &pointOut) const
Clipper3D< PointT > * clone() const override
polymorphic method to clone the underlying clipper with its parameters.
shared_ptr< const BoxClipper3D< PointT > > ConstPtr
float getDistance(const PointT &point) const
bool clipLineSegment3D(PointT &from, PointT &to) const override
bool clipPoint3D(const PointT &point) const override
interface to clip a single point
shared_ptr< BoxClipper3D< PointT > > Ptr
void clipPlanarPolygon3D(std::vector< PointT, Eigen::aligned_allocator< PointT > > &polygon) const override
void setTransformation(const Eigen::Affine3f &transformation)
Set the affine transformation.
~BoxClipper3D() noexcept override
virtual destructor
void clipPointCloud3D(const pcl::PointCloud< PointT > &cloud_in, Indices &clipped, const Indices &indices=Indices()) const override
interface to clip a point cloud
Base class for 3D clipper objects.
Definition clipper3D.h:55
PointCloud represents the base class in PCL for storing collections of 3D points.
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition memory.h:63
Defines functions, macros and traits for allocating and using memory.
Definition bfgs.h:10
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133
Defines all the PCL and non-PCL macros used.
A point structure representing Euclidean xyz coordinates, and the RGB color.