Skip to Content.
Sympa Menu

cgal-discuss - Attaching extra info to Facet AND Vertex in a Polyhedron structure ?

Subject: CGAL users discussion list

List archive

Attaching extra info to Facet AND Vertex in a Polyhedron structure ?


Chronological Thread 
  • From: Laurent Le Guillou <>
  • To:
  • Subject: Attaching extra info to Facet AND Vertex in a Polyhedron structure ?
  • Date: Tue, 13 Mar 2007 10:52:22 +0100
  • Organization: LPNHE - Université Paris 6 Pierre et Marie Curie


Hi all,

I am trying to attach some extra information (in fact, dynamic
information like speed, density, mass, elasticity, etc...) to all
vertices, facets and edges of a Polyhedron structure.

I tried different ways but I could not find the proper one
to do that with CGAL.

Here follows my last attempt. I do not understand why I can
easily extend Facets but not Vertices the same way.
What is the problem ? How should I do ?

May be there another CGAL 3D structure better suited for my
problem, but I did not find it.

Thanks in advance for your help.

Laurent
-----------------------------------------------------------------------

#include <CGAL/Cartesian.h>
#include <CGAL/Polyhedron_3.h>

using std::cout;
using std::endl;

// A vertex type with dynamic information.
template <class Refs>
struct My_vertex : public CGAL::HalfedgeDS_vertex_base<Refs> {
double vx, vy, vz;
};

// A face type with more information.
template <class Refs>
struct My_face : public CGAL::HalfedgeDS_face_base<Refs> {
double density;
};

//An items type using my face (and my vertex)
struct My_items : public CGAL::Polyhedron_items_3 {

template <class Refs, class Traits> // The problem
struct Vertex_wrapper { // is here
typedef My_vertex<Refs> Vertex; //
};

template <class Refs, class Traits>
struct Face_wrapper {
typedef My_face<Refs> Face;
};

};

typedef CGAL::Cartesian<double> Kernel;
typedef CGAL::Polyhedron_3<Kernel, My_items> Polyhedron;
typedef Polyhedron::Vertex_iterator Vertex_iterator;
typedef Polyhedron::Facet_iterator Facet_iterator;
typedef Polyhedron::Halfedge_handle Halfedge_handle;
typedef CGAL::Aff_transformation_3<Kernel> Transformation;
typedef CGAL::Vector_3<Kernel> Vector;
typedef CGAL::Point_3<Kernel> Point;
typedef Polyhedron::Halfedge::Halfedge_around_facet_circulator
Halfedge_around_facet_circulator;



int main() {
Point p( 1.0, 0.0, 0.0);
Point q( 0.0, 1.0, 0.0);
Point r( 0.0, 0.0, 1.0);
Point s( 0.0, 0.0, 0.0);

double density[] = { 1.2, 1.3, 1.4, 1.5 };

Polyhedron P;
Halfedge_handle h = P.make_tetrahedron(p, q, r, s);

int i=0;
for(Facet_iterator f = P.facets_begin() ;
f != P.facets_end() ; f++, i++) {
f->density = density[i];
}

for(Vertex_iterator v = P.vertices_begin() ;
v != P.vertices_end() ; v++) {
v->vx = v->vy = v->vz = 0.0;
cout << (*v).point() << endl;
}

for(Facet_iterator f = P.facets_begin() ;
f != P.facets_end() ; f++) {
cout << "facet: " << endl;
cout << " density: " << f->density << endl;
}

return 0;
}



-----------------------------------------------------------------------
Laurent LE GUILLOU Tel +33 1 44 27 39 93


Fax +33 1 44 27 46 38



LPNHE - Université Paris 6
Bureau 412 - Tour 33 RdC
Campus de Jussieu
4 place Jussieu
75252 Paris Cedex 05




Archive powered by MHonArc 2.6.16.

Top of Page