Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] polyhedron with user defined extra information on the vertices

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] polyhedron with user defined extra information on the vertices


Chronological Thread 
  • From: Andreas Fabri <>
  • To:
  • Subject: Re: [cgal-discuss] polyhedron with user defined extra information on the vertices
  • Date: Wed, 18 May 2016 12:44:53 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=None ; spf=None
  • Ironport-phdr: 9a23:sgC6jRSZ7pyt0lw+zEQMSxytS9psv+yvbD5Q0YIujvd0So/mwa65YhSN2/xhgRfzUJnB7Loc0qyN4/GmAjRLu83JmUtBWaIPfidNsd8RkQ0kDZzNImzAB9muURYHGt9fXkRu5XCxPBsdMs//Y1rPvi/6tmZKSV3BPAZ4bt74BpTVx5zukbviqtuIO04S33KUWvBbElaflU3prM4YgI9veO4a6yDihT92QdlQ3n5iPlmJnhzxtY+a9Z9n9DlM6bp6r5YTGfayQqIjULYNDCg6K3tno4rwpBzbRE2O4GEdWyMYiF1TEg3d5Vb7WJn29SD1v+441CiBNtDtVuMJXy+/5fJrVAPwk3VAcCUo9XnezM12lqNS5hy74AduxpbdJ4CTOv05dazUeZYWRHFKQ91KBBBGV4izZo9KA+saNvtDtKH8oUEPpF2wH1qCHuTqnxZOimX71LZy/e0rCwCOiAUmE8gDuW+Sotz/LqY6Xu2yyaTU1yTNZvhK3i3sroPPd0Zy8rm3QbtsfJ+JmgEUHATfgwDIpA==
  • Organization: GeometryFactory


It is in fact hashable, but the container then is not a std::map
but a boost::unordered_map

andreas

On 18/05/2016 12:39, Pádraig Ó Conbhuí wrote:
Hi Pratyush,

You can also use a std::map to store extra data, since Vertex_handle is
hashable. So something like

std::map<Polyhedron::Vertex_handle, double> my_values;
my_values[vertex_handle_i] = double_value;

could be the easiest solution, without having to play about with
changing the template parameters.

Cheers,
Paddy

On Wed, May 18, 2016 at 9:54 AM, Pratyush Pranav
<
<mailto:>>
wrote:

Hi Sebastian,

Thanks for pointing out the relevant material.

Now, I try to write a basic code (a modification of one of the
examples to have colour on the faces of the tetrahedron from the
CGAL documentation), to be able to have some of my own items on the
vertices, and also have access to point() on the vertex (this is
what is giving me problems). Could you please help me with where I
am going wrong? Below is the code.

pratyush

————————————————————

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polyhedron_3.h>
// A face type with a color member variable.

typedef CGAL::Simple_cartesian<double> Kernel;


template <class Refs, class Traits>
struct My_vertex : public CGAL::HalfedgeDS_vertex_base<Refs> {
typedef typename Traits::Point_3 Point;
double value;
long index;
};
// An items type using my face.
struct My_items : public CGAL::Polyhedron_items_3 {
template <class Refs, class Traits>
struct Vertex_wrapper {
typedef My_vertex<Refs,Traits> Vertex;
};
};


typedef Kernel::Point_3 Point_3;
typedef CGAL::Polyhedron_3<Kernel,My_items> Polyhedron;
typedef Polyhedron::Halfedge_handle Halfedge_handle;
typedef Polyhedron::Vertex_handle Vertex_handle;
int main() {
Point_3 p( 0.0, 0.0, 0.0);
Point_3 q( 1.0, 0.0, 0.0);
Point_3 r( 0.0, 1.0, 0.0);
Point_3 s( 0.0, 0.0, 1.0);
Polyhedron P;
P.make_tetrahedron(p,q,r,s);
Vertex_handle v = P.vertices_begin();
//v->value = 3.14;
v->index = 1;
std::cerr<<v->point()<<" "<<v->index<<std::endl;
return 0;
}





> On 17 May 2016, at 10:03, Sebastien Loriot (GeometryFactory)

<

<mailto:>>
wrote:
>
> It is possible using a custom items traits (second template
parameter).
> The concept is documented here:
> http://doc.cgal.org/latest/Polyhedron/classPolyhedronItems__3.html
>
> For an example see how ids are added to simplices in
CGAL/Polyhedron_items_with_id_3.h
>
> Note that using the class Surface_mesh would allow you to do
property assignment at run-time.
>
> http://doc.cgal.org/latest/Surface_mesh/
>
>
> Best,
>
> Sebastien.
>
> On 05/15/2016 02:43 PM, Pratyush Pranav wrote:
>> Hi,
>>
>> I would like to know if it is possible to derive a polyhedron_3
in such a way that i can store a couple of extra information on the
vertices (specifically each vertex should have two additional
variables associated with it, one of a double type, and another one
of long or int type).
>>
>> any leads would be great! thanks in advance!
>>
>> pratyush
>>
>
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://sympa.inria.fr/sympa/info/cgal-discuss
>
>


--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss




--
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912 skype: andreas.fabri



Archive powered by MHonArc 2.6.18.

Top of Page