Skip to Content.
Sympa Menu

cgal-discuss - Convex hull and Polyhedron_3

Subject: CGAL users discussion list

List archive

Convex hull and Polyhedron_3


Chronological Thread 
  • From: Laurent Le Guillou <>
  • To:
  • Subject: Convex hull and Polyhedron_3
  • Date: Tue, 04 Sep 2007 16:12:40 +0200
  • Organization: LPNHE - Université Paris 6 Pierre et Marie Curie


Dear CGAL aficionados,

I have a problem with convex hull and polyhedron objects.

In my code, I am using a sort of extended polyhedron (see
below) where vertices have extra info attached to them.
Now I need to compute the convex hull of a set of such
enriched points (Points + extra info attached to each Point),
and copy the resulting hull into a polyhedron for later
manipulations. But I do not understand how to keep
the extra info attached to the points: in the resulting
hull polyhedron, points are just Point_3 instances, without
any more info ; I tried several things but either it does
not compile or it does not work (extra info is empty).
I tried to copy the Hull into my enriched polyhedron but
it does not compile at all...

After reading some docs and sample code I understand I
have to provide some extended "Traits" class, but it does not
seems very simple. Do you have any sample code ? my Polyhedron
and my Hull classes should be able to manage the same
"extended Point" elements, how do I provide to both the
needed "Traits" ? Has anybody already done anything like
this, or at least some customized Traits class ?

Thanks in advance,

Cheers,

Laurent

PS: below is the way I extended the Polyhedron by attaching
info to each vertex.

/* -*- Mode: C++ -*- */

/////////////////////////////////////////////////////////////////////////////

#ifndef __MEMBRANE_H__
#define __MEMBRANE_H__

#include <CGAL/Simple_cartesian.h>
#include <CGAL/HalfedgeDS_list.h>
#include <CGAL/Polyhedron_3.h>

#include <CGAL/polyhedron_cut_plane_3.h>

#include <CGAL/IO/Color.h>

#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <algorithm>

/////////////////////////////////////////////////////////////////////////////

#include "Types.h"


/////////////////////////////////////////////////////////////////////////////
////
//// class MembraneVertex
////
/////////////////////////////////////////////////////////////////////////////

template <class Refs, class T, class P, class Velocity, class Force>
class MembraneVertex : public CGAL::HalfedgeDS_vertex_base<Refs, T, P> {
protected:
double _mass;
Velocity _velocity;
Force _force;

public:
typedef CGAL::Tag_true Supports_removal;

MembraneVertex() { // repeat mandatory constructors
_velocity = Velocity(0.,0.,0.);
_force = Force(0.,0.,0.);
}

MembraneVertex(const P& pt) :
CGAL::HalfedgeDS_vertex_base<Refs, T, P>(pt) {
_velocity = Velocity(0.,0.,0.);
_force = Force(0.,0.,0.);
}

inline const double& mass() const { return _mass; }
inline double& mass() { return _mass; }

inline const Velocity& velocity() const { return _velocity; }
inline Velocity& velocity() { return _velocity; }

inline const Force& force() const { return _force; }
inline Force& force() { return _force; }

------------------------------------------------------------------------

};


/////////////////////////////////////////////////////////////////////////////
////
//// struct MembraneItems
////
/////////////////////////////////////////////////////////////////////////////

struct MembraneItems : public CGAL::Polyhedron_items_3 {

template <class Refs, class Traits>
struct Vertex_wrapper {
typedef typename Traits::Point_3 Point;
typedef typename Traits::Vector_3 Velocity;
typedef typename Traits::Vector_3 Force;
typedef MembraneVertex<Refs, CGAL::Tag_true,
Point, Velocity, Force> Vertex;
};

};

/////////////////////////////////////////////////////////////////////////////
////
//// class Membrane
////
/////////////////////////////////////////////////////////////////////////////

class Membrane : public CGAL::Polyhedron_3<Kernel, MembraneItems,
CGAL::HalfedgeDS_list> {
private:

// ---------------------------------------------------

double _mass;

public:

// ---------------------------------------------------

typedef CGAL::Tag_true Supports_removal;

typedef Membrane::Halfedge_const_handle Halfedge_const_handle;
typedef Membrane::Halfedge_handle Halfedge_handle;
typedef Membrane::Halfedge_const_iterator Halfedge_const_iterator;
typedef Membrane::Halfedge_iterator Halfedge_iterator;
typedef Membrane::Edge_const_iterator Edge_const_iterator;
typedef Membrane::Edge_iterator Edge_iterator;
typedef Membrane::Vertex_const_handle Vertex_const_handle;
typedef Membrane::Vertex_handle Vertex_handle;
typedef Membrane::Vertex_const_iterator Vertex_const_iterator;
typedef Membrane::Vertex_iterator Vertex_iterator;
typedef Membrane::Facet_const_handle Facet_const_handle;
typedef Membrane::Facet_handle Facet_handle;
typedef Membrane::Facet_const_iterator Facet_const_iterator;
typedef Membrane::Facet_iterator Facet_iterator;
typedef Membrane::Halfedge_around_facet_const_circulator
Halfedge_around_facet_const_circulator;
typedef Membrane::Halfedge_around_facet_circulator
Halfedge_around_facet_circulator;
typedef Membrane::Halfedge_around_vertex_const_circulator
Halfedge_around_vertex_const_circulator;
typedef Membrane::Halfedge_around_vertex_circulator
Halfedge_around_vertex_circulator;

// ---------------------------------------------------

Membrane() {} // repeat mandatory constructors

// ---------------------------------------------------
// Access functions

inline const double & mass() const { return _mass; }
inline double & mass() { return _mass; }

Point centroid() const;
Membrane transform(const Transformation &t) const;
double area();
double volume() const;

// ---------------------------------------------------
// Initialisation

void init();

void distribute_matter();

void set_vertices_velocity(const Vector & velocity);
void set_vertices_force(const Vector & force);

// Apply force (Newton law)

void update_vertices_velocity(double dt);
void update_vertices_position(double dt);

};

//-----------------------------------------------------------------------

#endif



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


Fax +33 1 44 27 46 38


GSM +33 6 20 05 75 22

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