细化使用 CGAL::Advancing_front_surface_reconstruction 获得的网格



>我使用先进的前表面重建重建了一个 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;
}

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

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

相关内容

  • 没有找到相关文章

最新更新