suppersupperma 2017-07-24 08:16 采纳率: 0%
浏览 2592
已结题

CGAL中两个off文件做布尔运算

我使用了一个从网上下载的源码来进行测试,当使用简单的off数据的时候可以获得布尔运算的结果。但是当我把off文件换成较为复杂的不规则模型,比如说骆驼这种的数据的时候并不能获得布尔运算的结果。输出得到的数据依旧是我输入进去的第一个off文件。
下面这个是我所采用的源码。

 #include <iostream>
#include <fstream>
#include <time.h>
#include <string.h>

#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/Polyhedron_incremental_builder_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>

typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel>  Polyhedron;
typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron;
typedef Polyhedron::HalfedgeDS HalfedgeDS;

using namespace std;
int main()
{
    Polyhedron mesh1, mesh2, result;
    ifstream fin1("C:\\Users\\hm\\Desktop\\TestMesh\\torus.off", ios::in);
    fin1 >> mesh1;
    fin1.close();
    ifstream fin2("C:\\Users\\hm\\Desktop\\TestMesh\\cube.off", ios::in);
    fin2 >> mesh2;
    fin2.close();
    Nef_polyhedron nef1(mesh1);
    Nef_polyhedron nef2(mesh2);
    Nef_polyhedron out;
    clock_t start, finish;
    start = clock();
    out= nef1 - nef2;
    finish = clock();
    if (out.is_simple()) {
        out.convert_to_polyhedron(result);
        std::ofstream fout("d:\\CGAL_TEST6.off", ios::out);
        fout << result;
        fout.close();
    }
    else {
        std::cerr << "N1 is not a 2-manifold." << std::endl;
        return -1;
    }
    std::cout << "duration: " << finish - start << std::endl;
    system("pause");
    return 0;
}

图片说明
这个是我两个相交的off数据
图片说明
这个是我所获得的结果

  • 写回答

1条回答 默认 最新

  • devmiao 2017-07-24 13:20
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用