cylinder.h
Go to the documentation of this file.
00001 
00060 #ifndef CYLINDER_H_
00061 #define CYLINDER_H_
00062 
00063 //general includes
00064 #include <math.h>
00065 #include <sstream>
00066 
00067 //cob includes
00068 #include "cob_3d_mapping_common/shape.h"
00069 #include "cob_3d_mapping_common/polygon.h"
00070 extern "C"
00071 {
00072 #include "gpc/gpc.h"
00073 }
00074 //boost includes
00075 #include <boost/shared_ptr.hpp>
00076 #include <boost/enable_shared_from_this.hpp>
00077 #include <boost/lexical_cast.hpp>
00078 //pcl includes
00079 #include <pcl/point_cloud.h>
00080 #include <pcl/point_types.h>
00081 #include <pcl/common/centroid.h>
00082 #include <pcl/common/eigen.h>
00083 #ifdef PCL_VERSION_COMPARE
00084 #include <pcl/common/transforms.h>
00085 #else
00086 #include <pcl/common/transform.h>
00087 #endif
00088 #include <pcl/segmentation/sac_segmentation.h>
00089 #include <pcl/registration/transforms.h>
00090 #include <pcl/sample_consensus/method_types.h>
00091 #include <pcl/ModelCoefficients.h>
00092 #include <pcl/exceptions.h>
00093 #include <pcl/common/common.h>
00094 
00095 namespace cob_3d_mapping
00096 {
00097 
00107   double
00108   radiusAndOriginFromCloud (pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr in_cloud, std::vector<int>& indices,
00109                             Eigen::Vector3f& origin, const Eigen::Vector3f& sym_axis);
00110 
00116   class Cylinder : public Polygon
00117   {
00118 
00119   public:
00124     typedef boost::shared_ptr<Cylinder> Ptr;
00125 
00129     Cylinder () :
00130         Polygon ()
00131     {
00132     }
00133 
00145     Cylinder (unsigned int id, Eigen::Vector3f origin, Eigen::Vector3f sym_axis, double radius,
00146               std::vector<std::vector<Eigen::Vector3f> >& contours_3d, std::vector<bool> holes,
00147               std::vector<float> color);
00148 
00160     Cylinder (unsigned int id, Eigen::Vector3f origin, Eigen::Vector3f sym_axis, double radius,
00161               std::vector<pcl::PointCloud<pcl::PointXYZ> >& contours_3d, std::vector<bool> holes,
00162               std::vector<float> color);
00163 
00164     //##############Methods to initialize cylinder and its paramers#########
00165 
00171     virtual void
00172     setContours3D (std::vector<std::vector<Eigen::Vector3f> >& contours_3d);
00173 
00179     virtual std::vector<std::vector<Eigen::Vector3f> >
00180     getContours3D ();
00181 
00190     virtual void
00191     updateAttributes (const Eigen::Vector3f &sym_axis, const Eigen::Vector3f &origin, const Eigen::Vector3f &z_axis);
00192 
00198     virtual void
00199     transform (Eigen::Affine3f & tf);
00200 
00201     //################## methods for merging############################
00208     virtual void
00209     getMergeCandidates (const std::vector<Polygon::Ptr>& cylinder_array, std::vector<int>& intersections);
00210 
00216     virtual void
00217     merge (std::vector<Polygon::Ptr>& poly_vec);
00218 
00224     virtual void
00225     setParamsFrom (Polygon::Ptr& p);
00226 
00233     void
00234     computePose (Eigen::Vector3f origin, Eigen::Vector3f z_axis);
00235 
00242     void
00243     computePose (Eigen::Vector3f origin, std::vector<std::vector<Eigen::Vector3f> >& contours_3d);
00244 
00248     void
00249     computeHeight ();
00250 
00256     void
00257     triangulate (list<TPPLPoly>& tri_list) const;
00258 
00259     //############## debugging methods ####################
00265     void
00266     dbgOut (pcl::PointCloud<pcl::PointXYZRGB>::Ptr points, std::string& name);
00267 
00272     void
00273     printAttributes (std::string & name);
00274 
00279     void
00280     dumpParams (std::string name);
00281 
00282     //################# member variables########################
00283     double r_; 
00284     double h_min_; 
00285     double h_max_; 
00286     Eigen::Vector3f sym_axis_; 
00287     //Eigen::Vector3f origin_;         /**< Origin of cylinder. */
00288 
00289   protected:
00290     /*
00291      * \brief Compute average cylinder from a set of cylinders.
00292      *
00293      * \param[in] poly_vec The set of cylinders.
00294      * \param[out] p_average The average cylinder.
00295      */
00296     virtual void
00297     computeAverage (const std::vector<Polygon::Ptr>& poly_vec, Polygon::Ptr& p_average);
00298 
00299   };
00300 }
00301 
00302 #endif


cob_3d_mapping_common
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:02:19