【问题标题】:Refine mesh obtained with CGAL::Advancing_front_surface_reconstruction细化使用 CGAL::Advancing_front_surface_reconstruction 获得的网格
【发布时间】:2016-02-04 04:31:35
【问题描述】:

我使用先进的前表面重建来重建 3D 表面网格,并希望对其进行细化。我怎样才能做到这一点?

这是用于通过文件进行细化的表面重建的代码的一部分:

#include <CGAL/Advancing_front_surface_reconstruction.h>
#include <CGAL/compute_average_spacing.h>

#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_data_structure_3.h>

#include <CGAL/Polyhedron_3.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Polygon_mesh_processing/refine.h>
#include <CGAL/Polygon_mesh_processing/fair.h>

typedef CGAL::Advancing_front_surface_reconstruction<> Reconstruction;
typedef Reconstruction::Triangulation_3 Triangulation_3;
typedef Reconstruction::Triangulation_data_structure_2 TDS_2;
typedef Reconstruction::Outlier_range Outlier_range;
typedef Reconstruction::Boundary_range Boundary_range;
typedef Reconstruction::Vertex_on_boundary_range Vertex_on_boundary_range;
typedef Reconstruction::Vertex_handle Vertex_handle;

typedef CGAL::Polyhedron_3<CGALMesher::Kernel> Polyhedron;
typedef CGAL::Surface_mesh<CGALMesher::Point> Mesh;
typedef CGAL::cpp11::array<std::size_t,3> Facet;

struct Construct {
        Mesh& mesh;
        template<typename PointIterator>
        Construct(Mesh& mesh, PointIterator b, PointIterator e) : mesh(mesh) {
                for (; b != e; ++b) {
                        boost::graph_traits<Mesh>::vertex_descriptor v;
                        v = add_vertex(mesh);
                        mesh.point(v) = *b;
                }
        }
        Construct& operator=(const Facet f) {
                typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
                typedef boost::graph_traits<Mesh>::vertices_size_type size_type;
                mesh.add_face(vertex_descriptor(static_cast<size_type>(f[0])),
                                vertex_descriptor(static_cast<size_type>(f[1])),
                                vertex_descriptor(static_cast<size_type>(f[2])));
                return *this;
        }
        Construct&
        operator*() {
                return *this;
        }
        Construct&
        operator++() {
                return *this;
        }
        Construct operator++(int) {
                return *this;
        }
};

void CGALMesher::AdvancingFrontMesher(std::vector<Point>& points) {

        Mesh m;
        Construct construct(m,points.begin(),points.end());

        CGAL::advancing_front_surface_reconstruction(points.begin(), points.end(), construct);

        std::ofstream mesh_off("mesh.off");
        mesh_off << m;
        mesh_off.close();

        std::ifstream input("mesh.off");
        Polyhedron poly;
        if ( !input || !(input >> poly) || poly.empty() ) {
                std::cerr << "Not a valid off file." << std::endl;
        }
        input.close();

        std::vector<Polyhedron::Facet_handle>  new_facets;
        std::vector<Polyhedron::Vertex_handle> new_vertices;

        CGAL::Polygon_mesh_processing::refine(poly,
                                  faces(poly),
                                  std::back_inserter(new_facets),
                                  std::back_inserter(new_vertices),
                                  CGAL::Polygon_mesh_processing::parameters::density_control_factor(3));

        std::ofstream refined_off("refined.off");
        refined_off << poly;
        refined_off.close();
        std::cout << "Refinement added " << new_vertices.size() << " vertices." << std::endl;
}

【问题讨论】:

    标签: cgal


    【解决方案1】:

    从重建算法中提取多面体表面后,您可以使用多边形网格处理包中的refine() 函数。也可以使用fair()

    更彻底地,您可以使用像 one 这样的重新网格划分算法。在 CGAL 4.8 中,还会有 isotropic_remeshing() 主控中已经可用的函数 branch

    【讨论】:

    • 我在上面贴了部分表面重建的代码。据我了解,在进行多面体表面之前,我必须将从重建获得的三角剖分转换为 3D Delaunay 三角剖分中的 2D 复合体。但是我不明白如何实现这一点。
    • 结帐this 示例。
    • 我编辑了上面的代码,现在它可以工作了。但是我通过一个文件传递网格。有什么办法可以避免这种情况,直接去细化吗?
    • 只需在m上调用refine
    • 你的意思是:CGAL::Polygon_mesh_processing::refine(m, ...)?必须有一组类型。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多