CGAL在VS中如何将Point_2点转换成普通数据类型

Point_2 points[5] = { Point_2(1,0), Point_2(10,5), Point_2(10,10), Point_2(6,6), Point_2(4,5) };//初始化赋值
double x[5], y[5];
x[i] = points[i].x();//注意不加()会导致出错
y[i] = points[i].y();//获取y
即可转换成普通数据类型
如果不带()会导致出现这样的错误出现错误

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以使用CGAL和PCL库来进行带有法线的云数据的转换。下面是一个简单的示例代码,展示了如何将CGAL云数据转换为PCL库PointNormal类型的云数据: ```cpp #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Point_with_normal_3.h> #include <CGAL/IO/read_xyz_points.h> #include <CGAL/property_map.h> #include <CGAL/IO/write_ply_points.h> #include <pcl/point_types.h> #include <pcl/io/pcd_io.h> #include <pcl/io/ply_io.h> #include <pcl/point_cloud.h> #include <pcl/features/normal_3d.h> typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef Kernel::Point_3 Point_3; typedef CGAL::Point_with_normal_3<Kernel> Point_with_normal_3; typedef std::vector< Point_with_normal_3 > PointList; int main() { // 读取带有法线的云数据 PointList points; std::ifstream stream("input.xyz"); if (!stream || !CGAL::read_xyz_points(stream, std::back_inserter(points), CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Point_with_normal_3>()). normal_map(CGAL::Second_of_pair_property_map<Point_with_normal_3>()))) { std::cerr << "Error: cannot read file!" << std::endl; return 1; } // 将云数据转换为PCL库PointNormal类型的云数据 pcl::PointCloud<pcl::PointNormal>::Ptr pcl_cloud(new pcl::PointCloud<pcl::PointNormal>); for (const auto& point : points) { pcl::PointNormal pcl_point; pcl_point.x = point.x(); pcl_point.y = point.y(); pcl_point.z = point.z(); pcl_point.normal_x = point.normal().x(); pcl_point.normal_y = point.normal().y(); pcl_point.normal_z = point.normal().z(); pcl_cloud->push_back(pcl_point); } // 保存PCL云数据 pcl::io::savePLYFile("output.ply", *pcl_cloud); return 0; } ``` 上述代码将从"input.xyz"文件读取带有法线的云数据,并将其转换为PCL库PointNormal类型的云数据。最后,将转换后的云数据保存为"output.ply"文件。你可以根据自己的需求修改文件路径和名称。 请确保已正确安装和配置CGAL和PCL库,并将相关头文件和库文件包含到你的项目。这样,你就可以使用上述示例代码将CGAL云数据转换为PCL库PointNormal类型的云数据了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值