artem-ogre / CDT

Constrained Delaunay Triangulation (C++)
https://artem-ogre.github.io/CDT/
Mozilla Public License 2.0
1.07k stars 133 forks source link

About the environment of QT #5

Closed yumianhuli2 closed 4 years ago

yumianhuli2 commented 4 years ago

I'm sorry I haven't used QT!Please introduce the installation environment and version of QT,and how to use your code in QT?Thank you!

artem-ogre commented 4 years ago

You only need Qt if you would like to run the demo tool. The library itself can be just used by copying header files.

To build .pro file you would need qmake which comes with Qt. Please refer to the docs: https://doc.qt.io/qt-5/qmake-running.html

Or you could open .pro in QtCreator which supports qmake out of the box.

Does this answer your question?

yumianhuli2 commented 4 years ago

You only need Qt if you would like to run the demo tool. The library itself can be just used by copying header files.

To build .pro file you would need qmake which comes with Qt. Please refer to the docs: https://doc.qt.io/qt-5/qmake-running.html

Or you could open .pro in QtCreator which supports qmake out of the box.

Does this answer your question?

Hi! I copyed header files,and got results,but if I put point8 which inside the Concave polygon,the result is not right,the code is below:

#include <iostream>
#include "CDT.h"
#include "VerifyTopology.h"
#include "CDTUtils.h"

using Triangulation = CDT::Triangulation<float>;

typedef float CoordType;
typedef CDT::V2d<CoordType> V2d;
typedef CDT::Edge Edge;

int main() {
    std::cout << "Hello, World!" << std::endl;

    std::vector<V2d> pts;

    std::vector<Edge> edges;

    Triangulation cdt =
            Triangulation(CDT::FindingClosestPoint::BoostRTree);
    //point0
    pts.push_back({-1,0});
    //point1
    pts.push_back({1,0});
    //point2
    pts.push_back({1,1});
    //point3
    pts.push_back({0.5,1});
    //point4
    pts.push_back({0.5,2});
    //point5
    pts.push_back({-0.5,2});
    //point6
    pts.push_back({-0.5,1});
    //point7
    pts.push_back({-1,1});
    //point8
    pts.push_back({0.75,0.5});

    cdt.insertVertices(pts);

    edges.push_back(Edge(0, 1));
    edges.push_back(Edge(1, 2));
    edges.push_back(Edge(2, 3));
    edges.push_back(Edge(3, 4));
    edges.push_back(Edge(4, 5));
    edges.push_back(Edge(5, 6));
    edges.push_back(Edge(6, 7));
    edges.push_back(Edge(7, 0));
    cdt.insertEdges(edges);
    cdt.eraseOuterTriangles();

    std::cout<<cdt.triangles.size()<<std::endl;

    for (int j = 0; j <cdt.triangles.size(); ++j) {
        for (int k = 0; k < cdt.triangles[j].vertices.size(); ++k) {
            std::cout<<cdt.triangles[j].vertices[k]<<std::endl;
        }
    }
    return 0;
}

and I got indexs 8 0 1 8 2 3 8 3 6 8 4 5 3 3 5 6 0 6 7 2 8 1 0 8 6

but If I delete point8 ,the result is fine,so How can I fix this,Thank you very much!

artem-ogre commented 4 years ago

Your output looks valid: there are 8 triangles as shown in the picture above.

yumianhuli2 commented 4 years ago

Your output looks valid: there are 8 triangles as shown in the picture above.

Oh! Yes!I added an extra 8,so... 1、By the way, If both the points and the constraint edges are correct,Is your library suitable for any situation? 2、Is it possible to directly implement to 3d points? Thank you!

artem-ogre commented 4 years ago

1、By the way, If both the points and the constraint edges are correct,Is your library suitable for any situation?

I'm not quite sure what is the question here. The library uses robust predicates, so it should work with any input that satisfies requirement of no duplicate points and no intersecting constraint edges.

2、Is it possible to directly implement to 3d points?

Triangulation is a 2D problem, for 3D you would need a tetrahedrization library. CDT only does triangulation in 2D

yumianhuli2 commented 4 years ago

1、By the way, If both the points and the constraint edges are correct,Is your library suitable for any situation?

I'm not quite sure what is the question here. The library uses robust predicates, so it should work with any input that satisfies requirement of no duplicate points and no intersecting constraint edges.

2、Is it possible to directly implement to 3d points?

Triangulation is a 2D problem, for 3D you would need a tetrahedrization library. CDT only does triangulation in 2D

ok!I will make a mapping from 2d points to 3d points and use it in my work!Thank you!

artem-ogre commented 4 years ago

ok!I will make a mapping from 2d points to 3d points and use it in my work!Thank you!

Yes, if you just need to get a surface from 3D points, you could discard Z coordinate and use X and Y for triangulation :)

yumianhuli2 commented 4 years ago

ok!I will make a mapping from 2d points to 3d points and use it in my work!Thank you!

Yes, if you just need to get a surface from 3D points, you could discard Z coordinate and use X and Y for triangulation :)

Yes,surface! but Could you plz provide a library link available for point cloud constrained-delaunay triangulation?

artem-ogre commented 4 years ago

If you want to make 2.5D surface (single Z for every X and Y) out of point cloud, just ignore Z. But if you would like to have a full 3D surface (folding, multiple Z at X and Y) then CDT can not do that.

yumianhuli2 commented 4 years ago

If you want to make 2.5D surface (single Z for every X and Y) out of point cloud, just ignore Z. But if you would like to have a full 3D surface (folding, multiple Z at X and Y) then CDT can not do that.

Got it!