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 #ifndef PCL_FILTERS_IMPL_BOX_CLIPPER3D_HPP
00036 #define PCL_FILTERS_IMPL_BOX_CLIPPER3D_HPP
00037
00038 #include <pcl/filters/box_clipper3D.h>
00039
00040 template<typename PointT>
00041 pcl::BoxClipper3D<PointT>::BoxClipper3D (const Eigen::Affine3f& transformation)
00042 : transformation_ (transformation)
00043 {
00044
00045 }
00046
00048 template<typename PointT>
00049 pcl::BoxClipper3D<PointT>::BoxClipper3D (const Eigen::Vector3f& rodrigues, const Eigen::Vector3f& translation, const Eigen::Vector3f& box_size)
00050 {
00051 setTransformation (rodrigues, translation, box_size);
00052 }
00053
00055 template<typename PointT>
00056 pcl::BoxClipper3D<PointT>::~BoxClipper3D () throw ()
00057 {
00058 }
00059
00061 template<typename PointT> void
00062 pcl::BoxClipper3D<PointT>::setTransformation (const Eigen::Affine3f& transformation)
00063 {
00064 transformation_ = transformation;
00065
00066 }
00067
00069 template<typename PointT> void
00070 pcl::BoxClipper3D<PointT>::setTransformation (const Eigen::Vector3f& rodrigues, const Eigen::Vector3f& translation, const Eigen::Vector3f& box_size)
00071 {
00072 transformation_ = Eigen::Translation3f (translation) * Eigen::AngleAxisf(rodrigues.norm (), rodrigues.normalized ()) * Eigen::Scaling (box_size);
00073
00074 }
00075
00077 template<typename PointT> pcl::Clipper3D<PointT>*
00078 pcl::BoxClipper3D<PointT>::clone () const
00079 {
00080 return new BoxClipper3D<PointT> (transformation_);
00081 }
00082
00084 template<typename PointT> void
00085 pcl::BoxClipper3D<PointT>::transformPoint (const PointT& pointIn, PointT& pointOut) const
00086 {
00087 const Eigen::Vector4f& point = pointIn.getVector4fMap ();
00088 pointOut.getVector4fMap () = transformation_ * point;
00089
00090
00091 if (point [3] != 1)
00092 {
00093
00094 if (point [3] != 0)
00095 {
00096 pointOut.x += (1 - point [3]) * transformation_.data () [ 9];
00097 pointOut.y += (1 - point [3]) * transformation_.data () [10];
00098 pointOut.z += (1 - point [3]) * transformation_.data () [11];
00099 }
00100 else
00101 {
00102 pointOut.x += transformation_.data () [ 9];
00103 pointOut.y += transformation_.data () [10];
00104 pointOut.z += transformation_.data () [11];
00105 }
00106 }
00107 }
00108
00110
00111 template<typename PointT> bool
00112 pcl::BoxClipper3D<PointT>::clipPoint3D (const PointT& point) const
00113 {
00114 return (fabs(transformation_.data () [ 0] * point.x +
00115 transformation_.data () [ 3] * point.y +
00116 transformation_.data () [ 6] * point.z +
00117 transformation_.data () [ 9]) <= 1 &&
00118 fabs(transformation_.data () [ 1] * point.x +
00119 transformation_.data () [ 4] * point.y +
00120 transformation_.data () [ 7] * point.z +
00121 transformation_.data () [10]) <= 1 &&
00122 fabs(transformation_.data () [ 2] * point.x +
00123 transformation_.data () [ 5] * point.y +
00124 transformation_.data () [ 8] * point.z +
00125 transformation_.data () [11]) <= 1 );
00126 }
00127
00129
00132 template<typename PointT> bool
00133 pcl::BoxClipper3D<PointT>::clipLineSegment3D (PointT& point1, PointT& point2) const
00134 {
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 return false;
00179 }
00180
00182
00185 template<typename PointT> void
00186 pcl::BoxClipper3D<PointT>::clipPlanarPolygon3D (const std::vector<PointT>& polygon, std::vector<PointT>& clipped_polygon) const
00187 {
00188
00189 clipped_polygon.clear ();
00190 }
00191
00193
00196 template<typename PointT> void
00197 pcl::BoxClipper3D<PointT>::clipPlanarPolygon3D (std::vector<PointT>& polygon) const
00198 {
00199
00200 polygon.clear ();
00201 }
00202
00204
00205 template<typename PointT> void
00206 pcl::BoxClipper3D<PointT>::clipPointCloud3D (const pcl::PointCloud<PointT>& cloud_in, std::vector<int>& clipped, const std::vector<int>& indices) const
00207 {
00208 if (indices.empty ())
00209 {
00210 clipped.reserve (cloud_in.size ());
00211 for (register unsigned pIdx = 0; pIdx < cloud_in.size (); ++pIdx)
00212 if (clipPoint3D (cloud_in[pIdx]))
00213 clipped.push_back (pIdx);
00214 }
00215 else
00216 {
00217 for (std::vector<int>::const_iterator iIt = indices.begin (); iIt != indices.end (); ++iIt)
00218 if (clipPoint3D (cloud_in[*iIt]))
00219 clipped.push_back (*iIt);
00220 }
00221 }
00222 #endif //PCL_FILTERS_IMPL_BOX_CLIPPER3D_HPP