在创建派生模板类

时间:2017-07-07 19:59:02

标签: c++ class templates derived-class point-cloud-library

我想写自己的PCL class,为此我从:pcl:Features class派生了我的班级。 当我尝试创建我的类的对象时,我得到了这个错误,我不知道我做错了什么:

/home/.../PCL_SANDBOX/sandbox_main.cpp:85: error: cannot declare variable ‘cs’ to be of abstract type ‘CloudSubtractor<pcl::PointXYZI, pcl::PointXYZI>’ CloudSubtractor<PointT,PointT> cs;

我想创建这样的对象;

CloudSubtractor<PointT,PointT> cs;  // this is where the error happens. main.cpp:85 

我的模板类标题如下。

#ifndef CLOUDSUBTRACTOR_H
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/features/feature.h>
#define CLOUDSUBTRACTOR_H

template <typename PointInT, typename PointOutT>
class CloudSubtractor: public pcl::Feature<PointInT, PointOutT> 
{

public:

    typedef boost::shared_ptr< CloudSubtractor<PointInT, PointOutT> > Ptr;
    typedef boost::shared_ptr< const CloudSubtractor<PointInT, PointOutT> > ConstPtr;
    typedef typename pcl::Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut;
    typedef typename pcl::Feature<PointInT, PointOutT>::PointCloudConstPtr PointCloudConstPtr;

      using pcl::Feature<PointInT, PointOutT>::feature_name_;
      using pcl::Feature<PointInT, PointOutT>::getClassName;
      using pcl::Feature<PointInT, PointOutT>::indices_;
      using pcl::Feature<PointInT, PointOutT>::input_;
      using pcl::Feature<PointInT, PointOutT>::k_;
      using pcl::Feature<PointInT, PointOutT>::search_radius_;
      using pcl::Feature<PointInT, PointOutT>::search_parameter_;


    CloudSubtractor () :
          pointIncrement_ (0.25)
          {
            feature_name_ = "CloudSubtractor";

          }

    inline void setPointIncrement(float inc) {pointIncrement_ = inc;}
    inline float getPointIncrement() {return pointIncrement_;}
    void applyDummyFunction(typename pcl::PointCloud<PointInT>::Ptr cloud_out);



    virtual ~CloudSubtractor ()
    {

    }

protected:
    /** \brief The grid spacing in x,yz, direction. Smaller values lead to to larger and denser point clouds (default: 0.25). */
    float pointIncrement_;
    /** \brief An input point cloud describing the surface that is to be used for nearest neighbors estimation. */


    using pcl::Feature<PointInT,PointOutT>::surface_;
};


template<typename PointInT, typename PointOutT>
void CloudSubtractor<PointInT, PointOutT>::applyDummyFunction(typename pcl::PointCloud<PointInT>::Ptr cloud_out)
{

    pcl::copyPointCloud(*surface_,*cloud_out);
    for (int i=0; i< surface_->size(); ++i){
        cloud_out->points[i].x = surface_->points[i].x + 3;
        cloud_out->points[i].y = surface_->points[i].y + 5;
    }
}
#endif // CLOUDSUBTRACTOR_H

我可以在此处找到我从中派生的feature.h文件:http://docs.pointclouds.org/1.7.0/feature_8h_source.html

0 个答案:

没有答案