diff --git a/src/struct_pb/protoc-plugin/example/zpointcloud.cpp b/src/struct_pb/protoc-plugin/example/zpointcloud.cpp index 6ba4308e3..d1ade31ed 100644 --- a/src/struct_pb/protoc-plugin/example/zpointcloud.cpp +++ b/src/struct_pb/protoc-plugin/example/zpointcloud.cpp @@ -27,11 +27,11 @@ ::inner_class::ZPointCloudXYZIT StructToClass(inner_struct::sp_cZPointCloudXYZIT // ClassToStruct declaration inner_struct::spZPointCloudXYZIT ClassToStruct(::inner_class::ZPointCloudXYZIT const& in) { ::inner_struct::spZPointCloudXYZIT result = std::make_shared(); - pcl::PointCloud::Ptr pc_result = result; // stupid code , need solve *(std::shared_ptr<::inner_struct::ZFrame>)result = ClassToStruct(in.header()); // 解压点云 std::stringstream compressed_pcl_pointcloud(in.pcl_compressed_pc()); - s_compress.decodePointCloud(compressed_pcl_pointcloud, pc_result); + // decodePointCloud 的参数定义成了智能指针的引用, 所以不能存在转换. 只有是 const T& 和 std::shared_ptr, 可以使用多态,即直接使用子类对象或者子类智能指针 + s_compress.decodePointCloud(compressed_pcl_pointcloud, (pcl::PointCloud::Ptr&)result); return result; } diff --git a/src/struct_pb/protoc-plugin/example/zpointcloud.hpp b/src/struct_pb/protoc-plugin/example/zpointcloud.hpp index ef54aa1a7..259aff6ef 100644 --- a/src/struct_pb/protoc-plugin/example/zpointcloud.hpp +++ b/src/struct_pb/protoc-plugin/example/zpointcloud.hpp @@ -12,8 +12,13 @@ namespace inner_struct { +// template +// struct ZPointCloud : public ZFrame, public pcl::PointCloud<_PointType> { + +// }; + template -struct ZPointCloud : public ZFrame, public pcl::PointCloud<_PointType> { +struct ZPointCloud : public pcl::PointCloud<_PointType>, public ZFrame { };