Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Using edge_collapse with an inherited polyhedron_3 class

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Using edge_collapse with an inherited polyhedron_3 class


Chronological Thread 
  • From: calvin_cw <>
  • To:
  • Subject: Re: [cgal-discuss] Using edge_collapse with an inherited polyhedron_3 class
  • Date: Tue, 2 Jun 2020 02:54:28 -0500 (CDT)
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=SoftFail ; spf=Pass
  • Ironport-phdr: 9a23:94nZLx9WzNawz/9uRHKM819IXTAuvvDOBiVQ1KB30eocTK2v8tzYMVDF4r011RmVBNidsqkawLOO4ujJYi8p2d65qncMcZhBBVcuqP49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6JvjvGo7Vks+7y/2+94fcbglVhDexe65+IRu3oAneq8UanY9vIbstxxXUpXdFZ/5Yzn5yK1KJmBb86Maw/Jp9/ClVpvks6c1OX7jkcqohVbBXAygoPG4z5M3wqBnMVhCP6WcGUmUXiRVHHQ7I5wznU5jrsyv6su192DSGPcDzULs5Vyiu47ttRRT1jioMKjw3/3zNisFogqxVoAyvqR99zI7afY+aO+ZxcKzGcNMGR2dNQtpdWzBdDo+iaYYEEuoPPfxfr4n4v1YBsQGxBQ2yBOPuzD9HnmP53KMn2OkmDQ7JxgggH8wPsHTStNr6KKkTXPu1zKnP0TXDaulZ2Tb56ITSbh8hpvSMUKt2fMHMxkYhCxnLgU+MqYz5ITyVzOINvnCY4udiS++hhG0qpgVxrzWh2MoglInEi4YJx1zY+it0wYU4KNylRUB0fdKpFIVcuiWVOoZ5Rs4sQ39ktik7x7AEv5OwYSYEyJMixxHFavyHdZCF4hT5W+mKOjh4gGxqdKijiBa19EitzPD3WMqs0FtSsyZIlt3BumoD2hHQ8MSKSfpw8l2g1DuO0Q3Y9/tKLloulaXBLp4s2r4wmYQXsUTEBiL2nkr7gLWQdko+4een8ODnbav8qpCAMI90jxnyMqUomsOhHeQ1KhUCUmyf9Oim2rDu/lf1TbZLg/Esk6TUsYjWJcEBqa64Bw9V3Jwj6xG6Dzq+zNsXh30HLExEeBKBl4fmJ1/PLev4Dfe4n1SslS1kx/HCPrH7HprNKX3DnK/7fblh805c1BYzzddH6p1IBbEOOvbzVlbsu9zZFR82LxG0w/38CNhmzYMfWWePAreDP6/IsF+I4PgvI+iWa4MPtjb9Matt2/m7hnAwnRoRfLKiwIAMQHG+BPVvZUuDMlT2hdJUGm4OoAs4e+f1wAmJWDpNZnCFVL0U5jYnDYunCcHIQYX70+/J5zuyApADPjMOMVuLC3q9L9zYCcdJUzqbJ4paqhJBTaKoEtRz1RaysQb7z/xsKe+GonRJ56Km78B84qjorT938DV1C8qH1GTUFDN0mX8NTj4ymqt4pB4mkwrR4e1Dm/VdUOdrybZJXwM9bMOOybA8Ddn4UAbMONyOTQT/Tw==

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/



Archive powered by MHonArc 2.6.19+.

Top of Page