Subject: CGAL users discussion list
List archive
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] Using edge_collapse with an inherited polyhedron_3 class
- Date: Tue, 9 Jun 2020 08:49:20 +0200
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
- Ironport-phdr: 9a23:1yA2fxy3qE0u4x3XCy+O+j09IxM/srCxBDY+r6Qd2uMVIJqq85mqBkHD//Il1AaPAdyGrasZ0KGG7ejJYi8p2d65qncMcZhBBVcuqP49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6JvjvGo7Vks+7y/2+94fcbglVhDexe65+IRW4oAnetcQbgJZpJ7osxBfOvnZGYfldy3lyJVKUkRb858Ow84Bm/i9Npf8v9NNOXLvjcaggQrNWEDopM2Yu5M32rhbDVheA5mEdUmoNjBVFBRXO4QzgUZfwtiv6sfd92DWfMMbrQ704RSiu4qF2QxLulSwJNSM28HvPh8JtkqxbrhKvqR9xzYHab46aNuZxcKzGcNMGR2dMRNpdWzBPD46+aYYEEuoPPfxfr4n4v1YCowawChe3C+z10T9Imn720rM80+88Fw/G2xYgH9MJsHTIsd75MKYcXv6yzKnN0zrDc+lW2Df95ofSbh8hvfaMXahwcMbUx0UkCgTIjk6UqYziJTOV1+MNs3SB4+plUeKikGEnqwRrrTiuwscgkJXGhoUQyl3d8yhy3Yk6K8GiRkFhfd6kDIVftzucN4ZuXM8vQG5ltDokx7AGupO1cyYHxpspyhLCdvGLbYmF7gztWeuPPzt0mXxrdb2xiRuv/kWs1uPxW8mo3VhEsiZIj9/BvW0D2RzU78iIUPp9/kG51DaJzQ/c8fpLIUQqmqbBN5Ehxbswm5wOukrABi/7gFv6gLOSe0k++eWl6/7rbqv4qpOBLYN5hQPzPrwwlsOlHeg0Lw0DUHaH9eum0bDv41H1TKhPg/A4iKbVrozWKMEfq6GkHQNY14cu5hihADqp1dkVmXsKIVFYdB+ClYfkP03BLOz+APyimVqjii1ryOrDPrD5ApXCMHzDkLD5cLZ48UFcyQ4zwclR5pJOF70NOfzzV0DzudDCAR85NAu0w+njCNpjzI8RRWWPAqqBPKPTt1+H+P4vLvGSaIMJvDvxMfso6v70gXMnh1MRYLOl0JQVZXygG/RpOUSZYX7igtcbFmcKuxIzTPfuiF2FSz5TZnGyX74m6jE+DIKrFojDRoW3j7yA2Ce3BIFZZmdDClyUC3fna52EW+sQaCKVOsJujjMEWqKlS4M4yB6utRT6xKZ6LurP4S0Vronj1dhw5+3Ljx4+7z10D8KH02GMVW54hG0IRyVllJx49Edyw1PG3aljiOFDDvRS4elIW0E0L83y1et/XprJVwjIZcuIRVDuZtK8ADYtBpIeztgLblpnCvurhQzExTvrSfdBjLiMHp0z7uTZ21D+Is98zzDN06x33ApueddGKWDz3v03zAPUHYOcyxzFxZbvTrwV2Wv2zEnG1XCH5RgKXwt5UKGDVncaNBOP/IbJo3jaRrrrMowJdw5IyMqMMKxPM4S7glBPRfOlM9PbMTvoxjWAQC2Qz7bJV7LEPmUQ2CKHVRoBmgEXuGmcbE0wWnjnrGXZAzhjU1noZhG0/A==
Pb 1:
namespace boost {
template <>
struct boost::graph_traits<feSurfaceMesh> : <--------- extra boost:: namespace here
Pb 2:
template <typename T>
struct graph_has_property<feSurfaceMesh, T>
: public CGAL::graph_has_property<feSurfaceMesh::Base,T>
{};
feSurfaceMesh::Base should be replaced by Poly_3.
With those fixes it compiles for me.
Sebastien.
On 6/2/20 9:54 AM, calvin_cw ( via cgal-discuss Mailing List) wrote:
I updated the code to reflect that this code will compile fully on 4.12.1 ,
but not in 5.0.2
=========================================================================
#include <iostream>
#include <fstream>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polyhedron_3.h>
// Extended polyhedron items which include an id() field
#include <CGAL/Polyhedron_items_with_id_3.h>
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
#include
<CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h>
typedef CGAL::Simple_cartesian<double>
Kernel;
template <class Refs, class ID>
class feEdge_Surf : public CGAL::HalfedgeDS_halfedge_base< Refs,
CGAL::Tag_true, CGAL::Tag_true, CGAL::Tag_true >
{
typedef ID size_type;
private:
size_type mID;
public:
size_type& id() { return mID; }
size_type const& id() const { return mID; }
};
template <class Refs, class Traits, class ID>
class feFace_Surf : public CGAL::HalfedgeDS_face_base<Refs, CGAL::Tag_true,
typename Traits::Plane_3>
{
typedef ID size_type;
private:
size_type mID;
public:
size_type& id() { return mID; }
size_type const& id() const { return mID; }
};
template <class Refs, class Traits, class ID>
class feNode_Surf : public CGAL::HalfedgeDS_vertex_base< Refs,
CGAL::Tag_true, typename Traits::Point_3 >
{
typedef ID size_type;
private:
size_type mID;
public:
size_type& id() { return mID; }
size_type const& id() const { return mID; }
};
class feSurf_Elements : public CGAL::Polyhedron_items_3
{
public:
template <class Refs, class Traits>
struct Vertex_wrapper
{
typedef feNode_Surf<Refs, Traits, std::size_t> Vertex;
};
template <class Refs, class Traits>
struct Halfedge_wrapper {
typedef feEdge_Surf<Refs, std::size_t> Halfedge;
};
template <class Refs, class Traits>
struct Face_wrapper {
typedef feFace_Surf<Refs, Traits, std::size_t> Face;
};
};
typedef CGAL::Polyhedron_3<Kernel, feSurf_Elements>::Point_3
Point_fe;
typedef CGAL::Polyhedron_3<Kernel, feSurf_Elements> Poly_3;
template<class Kernel, class feSurf_Elements>
class feSurfMesh : public Poly_3
{
public:
typedef Point_fe Base;
};
typedef feSurfMesh<Kernel, feSurf_Elements>
feSurfaceMesh;
namespace boost {
template <>
struct boost::graph_traits<feSurfaceMesh> :
public boost::graph_traits<Poly_3>
{};
} // namespace boost
namespace boost {
template <class Tag>
struct property_map<feSurfaceMesh, Tag> :
public property_map<Poly_3, Tag>
{};
} //namespace boost
namespace CGAL {
template <typename T>
struct graph_has_property<feSurfaceMesh, T>
: public CGAL::graph_has_property<feSurfaceMesh::Base, T>
{};
}
typedef CGAL::Simple_cartesian<double> Kernel;
//typedef Kernel::Point_3 Point;
// Setup an enriched polyhedron type which stores an id() field in the items
typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_with_id_3>
Surface_mesh;
typedef boost::graph_traits<Surface_mesh>::halfedge_descriptor
halfedge_descriptor;
typedef boost::graph_traits<Surface_mesh>::vertex_descriptor
vertex_descriptor;
typedef boost::graph_traits<feSurfaceMesh>::halfedge_descriptor
halfedge_descriptor_fe;
typedef boost::graph_traits<feSurfaceMesh>::vertex_descriptor
vertex_descriptor_fe;
namespace SMS = CGAL::Surface_mesh_simplification;
int main(int argc, char** argv)
{
Surface_mesh surface_mesh;
std::ifstream is(argv[1]);
is >> surface_mesh;
if (!CGAL::is_triangle_mesh(surface_mesh)) {
std::cerr << "Input geometry is not triangulated." <<
std::endl;
return EXIT_FAILURE;
}
// The items in this polyhedron have an "id()" field
// which the default index maps used in the algorithm
// need to get the index of a vertex/edge.
// However, the Polyhedron_3 class doesn't assign any value to
// this id(), so we must do it here:
int index = 0;
for (halfedge_descriptor hd : halfedges(surface_mesh)) {
hd->id() = index++;
}
index = 0;
for (vertex_descriptor vd : vertices(surface_mesh)) {
vd->id() = index++;
}
// In this example, the simplification stops when the number of
undirected
edges
// drops below 10% of the initial count
SMS::Count_ratio_stop_predicate<Surface_mesh> stop(0.1);
// The index maps are not explicitelty passed as in the previous
// example because the surface mesh items have a proper id() field.
// On the other hand, we pass here explicit cost and placement
// function which differ from the default policies, ommited in
// the previous example.
int r = SMS::edge_collapse(surface_mesh, stop);
SMS::Count_ratio_stop_predicate<feSurfaceMesh> stop_fe(0.1);
feSurfaceMesh feSurf3D;
int e = SMS::edge_collapse(feSurf3D, stop_fe);
std::cout << "\nFinished...\n" << r << " edges removed.\n"
<< (surface_mesh.size_of_halfedges() / 2) << " final
edges.\n";
std::ofstream os(argc > 2 ? argv[2] : "out.off");
os.precision(17);
os << surface_mesh;
return EXIT_SUCCESS;
}
==============================================================
if anyone has a solution to what is the error stemming from the 5.0, that
would be the most helpful. thanks!
Stay safe!
--
Sent from: http://cgal-discuss.949826.n4.nabble.com/
- Re: [cgal-discuss] Using edge_collapse with an inherited polyhedron_3 class, calvin_cw, 06/02/2020
- Re: [cgal-discuss] Using edge_collapse with an inherited polyhedron_3 class, calvin_cw, 06/09/2020
- Re: [cgal-discuss] Using edge_collapse with an inherited polyhedron_3 class, Sebastien Loriot (GeometryFactory), 06/09/2020
Archive powered by MHonArc 2.6.19+.