Io 如何使用CGAL::read_ply_points()读取二进制ply文件?

Io 如何使用CGAL::read_ply_points()读取二进制ply文件?,io,cgal,Io,Cgal,这里是CGAL的新用户。 我目前正在试用“向OpenGR.cpp注册”示例 用于读取ply文件的函数CGAL::read_ply_points()似乎在二进制格式上不起作用,但在给定ASCII ply文件时,它起作用。在读取二进制文件时,是否需要设置任何额外的标志 这是我当前读取ply文件的代码 #include <CGAL/property_map.h> #include <fstream> #include <iostream> #include <

这里是CGAL的新用户。 我目前正在试用“向OpenGR.cpp注册”示例

用于读取ply文件的函数CGAL::read_ply_points()似乎在二进制格式上不起作用,但在给定ASCII ply文件时,它起作用。在读取二进制文件时,是否需要设置任何额外的标志

这是我当前读取ply文件的代码

#include <CGAL/property_map.h>
#include <fstream>
#include <iostream>
#include <utility>
#include <vector>

typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_3 Point_3;
typedef K::Vector_3 Vector_3;
typedef std::pair<Point_3, Vector_3> Pwn;
typedef CGAL::First_of_pair_property_map<Pwn> Point_map;
typedef CGAL::Second_of_pair_property_map<Pwn> Normal_map;

namespace params = CGAL::parameters;

int main(int argc, const char** argv) {
    const char* fname1 = "data/reference.ply";
    const char* fname2 = "data/1.ply";
    std::vector<Pwn> pwns1, pwns2;
    std::ifstream input(fname1);
    if (!input ||
        !CGAL::read_ply_points(input, std::back_inserter(pwns1),
            CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Pwn>()).
            normal_map(Normal_map())))
    {
        std::cerr << "Error: cannot read file " << fname1 << std::endl;
        return EXIT_FAILURE;
    }
    input.close();
    input.open(fname2);
    if (!input ||
        !CGAL::read_ply_points(input, std::back_inserter(pwns2),
            CGAL::parameters::point_map(Point_map()).
            normal_map(Normal_map())))
    {
        std::cerr << "Error: cannot read file " << fname2 << std::endl;
        return EXIT_FAILURE;
    }
    input.close();
    std::cerr << "SUCCESS" << std::endl;
    return EXIT_SUCCESS;
}
#包括
#包括
#包括
#包括
#包括
typedef CGAL::简单笛卡尔K;
typedef K::Point_3 Point_3;
typedef K::Vector_3 Vector_3;
typedef std::pair Pwn;
typedef CGAL::第一对属性映射点映射;
typedef CGAL::第二对属性映射法线映射;
namespace params=CGAL::parameters;
int main(int argc,常量字符**argv){
const char*fname1=“data/reference.ply”;
const char*fname2=“数据/1.ply”;
std::载体pwns1,pwns2;
std::ifstream输入(fname1);
如果(!输入||
!CGAL::读取层点(输入,标准::返回插入器(pwns1),
CGAL::parameters::point\u map(CGAL::第一个\u对\u属性\u map())。
法线映射(法线映射()))
{

std::cerr您需要为流构造函数提供std::ios\u base::binary:
std::ifstream输入(fname1,std::ios_base::binary);