在 3D space 中使用 CGAL 的 Delaunay 创建表面网格,并将点作为输入

Create a surface mesh using CGAL's Delaunay in 3D space with points as input

我想在 3D 中使用 CGAL 的 Delaunay 创建表面网格 space,并将点作为输入。

现在我已经从 CGAL 获得了 3D Delaunay 的工作版本,但现在我只想 return 从这个结果中得到一个表面。我发现了这个:

Surface_mesh_complex_2_in_triangulation_3<Delaunay>

据说我可以在上面提到的 Surface Mesh 构造函数中输入我的 delaunay 结果,但我不知道从那时起该去哪里。

我也读过泊松曲面重建,但我希望我的输入点也出现在我的输出中;我只想要 delaunay 结果中的三角形。

main.cpp

// test vector
std::vector<glm::vec3> l_Vec = { glm::vec3( -10,-10,-10 ), glm::vec3( -10,-10,10 ),glm::vec3( -10,10,-10 ),glm::vec3( -10,10,10 ),glm::vec3( 0,0,0 ), glm::vec3( 10,-10,-10 ), glm::vec3( 10,-10,10 ),glm::vec3( 10,10,-10 ),glm::vec3( 10,10,10 ) };
clsDelaunay3D l_Delaunay;
l_Delaunay.Triangulate( l_Vec );
SurfaceMesh sm( l_Delaunay.GetTriangulation( ) );
// what to do next?

clsDelaunay3D.h

#pragma once
#include "stdafx_CGAL.h"
#include "stdafx.h"

namespace GenerationLib
{
template<class GT, class Vb = CGAL::Triangulation_vertex_base_3<GT>>
class My_vertex_base : public Vb
{
public:
    typedef typename Vb::Vertex_handle  Vertex_handle;
    typedef typename Vb::Point          Point;
    typedef typename Vb::Cell_handle    Cell_handle;

    template<class TDS2>
    struct Rebind_TDS
    {
        typedef typename Vb::template Rebind_TDS<TDS2>::Other   Vb2;
        typedef My_vertex_base<GT, Vb2>                         Other;
    };

    My_vertex_base( )
    {
    }

    My_vertex_base( const Point&p ) : Vb( p )
    {
    }

    My_vertex_base( const Point&p, Cell_handle c ) : Vb( p, c )
    {
    }

    Vertex_handle vh;
    Cell_handle ch;
};

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_data_structure_3<My_vertex_base<K>> Tds;
typedef CGAL::Delaunay_triangulation_3<K, Tds> Delaunay;
typedef Delaunay::Vertex_handle Vertex_handle;
typedef Delaunay::Point Point;

typedef CGAL::Surface_mesh_complex_2_in_triangulation_3<Delaunay> SurfaceMesh;

class clsDelaunay3D
{
public:
    clsDelaunay3D( );
    ~clsDelaunay3D( );
    void Init( );
    void AddPoint( glm::vec3 Position );
    void Triangulate( std::vector<glm::vec3> Points );
    Delaunay::All_vertices_iterator GetAllVerticesIteratorBegin( );
    Delaunay::All_vertices_iterator GetAllVerticesIteratorEnd( );
    Delaunay::Finite_vertices_iterator GetOuterVerticesIteratorBegin( );
    Delaunay::Finite_vertices_iterator GetOuterVerticesIteratorEnd( );

    Delaunay::All_edges_iterator GetAllEdgesIteratorBegin( );
    Delaunay::All_edges_iterator GetAllEdgesIteratorEnd( );
    Delaunay::Finite_edges_iterator GetOuterEdgesIteratorBegin( );
    Delaunay::Finite_edges_iterator GetOuterEdgesIteratorEnd( );

    Delaunay::All_facets_iterator GetAllFacetsIteratorBegin( );
    Delaunay::All_facets_iterator GetAllFacetsIteratorEnd( );
    Delaunay::Finite_facets_iterator GetOuterFacetsIteratorBegin( );
    Delaunay::Finite_facets_iterator GetOuterFacetsIteratorEnd( );

    Delaunay::All_cells_iterator GetAllCellsIteratorBegin( );
    Delaunay::All_cells_iterator GetAllCellsIteratorEnd( );
    Delaunay::Finite_cells_iterator GetOuterCellsIteratorBegin( );
    Delaunay::Finite_cells_iterator GetOuterCellsIteratorEnd( );

    Delaunay GetTriangulation( );

    void Destroy( );
private:
    Delaunay m_Triangulation;
};
}

clsDelaunay3D.cpp

#pragma once
#include "stdafx_CGAL.h"
#include "stdafx.h"
#include "clsDelaunay3D.h"

namespace GenerationLib
{
clsDelaunay3D::clsDelaunay3D( )
{

}

clsDelaunay3D::~clsDelaunay3D( )
{

}

void clsDelaunay3D::Init( )
{

}

void clsDelaunay3D::AddPoint( glm::vec3 a_Position )
{
    Vertex_handle vertex = m_Triangulation.insert( Point( a_Position.x, a_Position.y, a_Position.z ) );
}

void clsDelaunay3D::Triangulate( std::vector<glm::vec3> a_Points )
{
    std::vector<Point> l_DelPoints;
    for (unsigned int i = 0; i < a_Points.size( ); ++i)
    {
        l_DelPoints.push_back( Point( a_Points[ i ].x, a_Points[ i ].y, a_Points[ i ].z ) );
    }
    m_Triangulation.insert( l_DelPoints.begin( ), l_DelPoints.end( ) );
}

Delaunay::All_vertices_iterator clsDelaunay3D::GetAllVerticesIteratorBegin( )
{
    return m_Triangulation.all_vertices_begin( );
}

Delaunay::All_vertices_iterator clsDelaunay3D::GetAllVerticesIteratorEnd( )
{
    return m_Triangulation.all_vertices_end( );
}

Delaunay::Finite_vertices_iterator clsDelaunay3D::GetOuterVerticesIteratorBegin( )
{
    return m_Triangulation.finite_vertices_begin( );
}

Delaunay::Finite_vertices_iterator clsDelaunay3D::GetOuterVerticesIteratorEnd( )
{
    return m_Triangulation.finite_vertices_end( );
}

Delaunay::All_edges_iterator clsDelaunay3D::GetAllEdgesIteratorBegin( )
{
    return m_Triangulation.all_edges_begin( );
}

Delaunay::All_edges_iterator clsDelaunay3D::GetAllEdgesIteratorEnd( )
{
    return m_Triangulation.all_edges_end( );
}

Delaunay::Finite_edges_iterator clsDelaunay3D::GetOuterEdgesIteratorBegin( )
{
    return m_Triangulation.finite_edges_begin( );
}

Delaunay::Finite_edges_iterator clsDelaunay3D::GetOuterEdgesIteratorEnd( )
{
    return m_Triangulation.finite_edges_end( );
}

Delaunay::All_facets_iterator clsDelaunay3D::GetAllFacetsIteratorBegin( )
{
    return m_Triangulation.all_facets_begin( );
}

Delaunay::All_facets_iterator clsDelaunay3D::GetAllFacetsIteratorEnd( )
{
    return m_Triangulation.all_facets_end( );
}

Delaunay::Finite_facets_iterator clsDelaunay3D::GetOuterFacetsIteratorBegin( )
{
    return m_Triangulation.finite_facets_begin( );
}

Delaunay::Finite_facets_iterator clsDelaunay3D::GetOuterFacetsIteratorEnd( )
{
    return m_Triangulation.finite_facets_end( );
}

Delaunay::All_cells_iterator clsDelaunay3D::GetAllCellsIteratorBegin( )
{
    return m_Triangulation.all_cells_begin( );
}

Delaunay::All_cells_iterator clsDelaunay3D::GetAllCellsIteratorEnd( )
{
    return m_Triangulation.all_cells_end( );
}

Delaunay::Finite_cells_iterator clsDelaunay3D::GetOuterCellsIteratorBegin( )
{
    return m_Triangulation.finite_cells_begin( );
}

Delaunay::Finite_cells_iterator clsDelaunay3D::GetOuterCellsIteratorEnd( )
{
    return m_Triangulation.finite_cells_end( );
}

Delaunay clsDelaunay3D::GetTriangulation( )
{
    return m_Triangulation;
}

void clsDelaunay3D::Destroy( )
{

}
}

如果谁有更好的方法请告诉我。

您应该使用 surface reconstruction algorithms

而不是 Delaunay 三角剖分