BrunoLevy / geogram

a programming library with geometric algorithms
Other
1.9k stars 129 forks source link

problem of delaunay #9

Closed tyc1998 closed 2 years ago

tyc1998 commented 2 years ago

I'm having issues with GEO::delaunay, the resulting mesh is of poor quality, even -1 in the cell_to_v array. I have read your demo carefully and found no problem with my code usage, I hope to get your help, best wishes! Code is as follows:

    GEO::CmdLine::import_arg_group("standard");
    GEO::CmdLine::import_arg_group("pre");
    GEO::CmdLine::import_arg_group("algo");

    GEO::Delaunay::initialize();
    GEO::Delaunay_var T = GEO::Delaunay::create(3, "BDEL");
    //T->set_reorder(true);
    //T->set_thread_safe(true);
    T->set_keeps_infinite(true);
    T->set_vertices(vd_.size() / 3, vd_.data());

    std::vector<Vector4i> indice;
    indice.resize(T->nb_cells());
    const auto& tet2v = T->cell_to_v();
    for (int i = 0; i < indice.size(); ++i) {
        for (int j = 0; j < 4; ++j) {
            indice[i][j] = T->cell_vertex(i, j);
        }
    }
BrunoLevy commented 2 years ago

Since you called T->set_keep_infinite(true), it creates "infinite" tetrahedra (that connect three vertices of the convex hull and the infinite vertex, of index -1). If you do not want them, simply remove the line with T->set_keep_infinite(true). What do you mean by "the resulting mesh is of poor quality" ? Delaunay triangulation is a well-defined mathematical concept: there is (nearly) a unique Delaunay triangulation for a given set of points. Maybe what you need is a 3D mesher, that decices where to put the points. For that, see the functions in mesh_tetrahedralize.h (that use tetgen).

BrunoLevy commented 2 years ago

Received a DM indicating that the problem was in the input pointset, not in the code, so I'm closing this issue.