Skip to content

[Question] SurfaceMesh to PointSet #6184

Description

@maximecharriere

First of all, sorry for asking a question in the Issues section. Where would you prefer us to ask questions?

I'm currenly learning to use Boost and Cgal.
To convert a SurfaceMesh to a PointSet I'm using :

using Scalar = typename double;
using Kernel = typename CGAL::Simple_cartesian<Scalar>;
using Point_3 = typename Kernel::Point_3;
using Mesh = typename CGAL::Surface_mesh<Point_3>;
using Point_set_3 = typename CGAL::Point_set_3<Point_3>;

Point_set_3 SurfaceMeshToPointSet(const Mesh& sMesh) {
	Mesh::Property_map<Mesh::vertex_index, Point_3> pointsPm = sMesh.points();
	Mesh::Property_map<Mesh::vertex_index, Vector_3> normalsPm;
	bool haveNormal;
	std::tie(normalsPm, haveNormal) = sMesh.property_map<Mesh::vertex_index, Vector_3>("v:normal");

	Point_set_3 pointSet;
	if (haveNormal) pointSet.add_normal_map();
	for (auto vi : sMesh.vertices()) {
		haveNormal ? pointSet.insert(pointsPm[vi], normalsPm[vi]) : pointSet.insert(pointsPm[vi]);
	}
        return pointSet;
}

Is there a build in solution, or a one line way to do it ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions