Subject: CGAL users discussion list
List archive
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] How do I construct a WritablePropertyMap?
- Date: Tue, 1 Nov 2016 08:50:37 +0100
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
- Ironport-phdr: 9a23:PZDwARWds/yHz9j0IvUMCA4DO13V8LGtZVwlr6E/grcLSJyIuqrYZhSHt8tkgFKBZ4jH8fUM07OQ6PG6HzxYqs/Z4ThCKMUKDEBVz51O3kQJO42sNw7SFLbSdSs0HcBPBhdO3kqQFgxrIvv4fEDYuXao7DQfSV3VPAtxIfnpSMaJ15zkn7P6x5qGaApBgH+xYKh5MQ6thQTXrMgfx4V4eYgrzR6c6EBFce1N2WJlIxq3mAz94dv4vLFu9CFdp+gw2cdLTaLgbuVyBehDCDM8MmcposjvnRbGRAqLoHAbVzNFwVJzHwHZ4USiDd/KuSzgu78l1Q==
- Organization: GeometryFactory
A writable property map, as describe in the concept of the boost web
site is a mecanism that allow to generically associate a property
(the value type) to a given object (the key).
If you want to associate a normal to a facet of a Polyhedron, here is a simple example (not tested):
struct Poly_normal_map{
typedef Polyhedron::Facet_handle key_type;
typedef Kernel::Vector_3 value_type;
typedef boost::writable_property_map_tag category;
std::map<Polyhedron::Facet_handle, Kernel::Vector_3>* normals;
Poly_normal_map() : normals(NULL)
{}
Poly_normal_map(std::map<Polyhedron::Facet_handle,
Kernel::Vector_3>& n)
: normals(*n)
{}
friend void put(Poly_normal_map pnm,
Polyhedron::Facet_handle fh,
const Kernel::Vector_3& n
{
CGAL_assertion(pnm.normals!=0);
pnm.normals.insert( std::make_pair(fh, n) );
}
};
std::map<Polyhedron::Facet_handle, Kernel::Vector_3> normals;
Poly_normal_map vpm(normals); //vpm is you writable property map
If you want to make the property map read-write, you can add
a get function:
friend const value_type& get(Poly_normal_map pnm,
Polyhedron::Facet_handle fh)
{
CGAL_assertion(pnm.normals!=0);
return pnm.normals[fh];
}
and update the category tag.
Note that the code I've written is roughly equivalent to using a
boost::associative_property_map (http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html) :
std::map<Polyhedron::Facet_handle, Kernel::Vector_3> normals;
boost::associative_property_map<
std::map<Polyhedron::Facet_handle,
Kernel::Vector_3> > vpm(normals);
If you're not stuck with Polyhedron_3, you can use class
Surface_mesh that comes with its own property mechanism
as illustrated in this example:
http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
Sebastien.
On 10/31/2016 12:46 PM, Iason Manolas wrote:
Hi,
I am new to CGAL. I have constructed a CGAL::Polyhedron_3 and now I want
to compute the normal vector for each of its vertices. So I found the
Polygon Mesh Processing package which happens to have a function
<http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>
doing exactly what I want . In the above link I found out that the
second argument was of type VertexNormalMap which is a model of
WritablePropertyMap. There was a link
<http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>
to boost libraries explaining(?) what writable property map is .
Unfortunately this is my first encounter with property maps and
consequently I am a bit confused..
I also had a look at cgal's explanation of property maps page
<http://doc.cgal.org/latest/Property_map/index.html >, but I did not
understand much..
Could anyone suggest a way of creating the property map I need?
Best Regards,
Iason
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Sebastien Loriot (GeometryFactory), 11/01/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Iason Manolas, 11/01/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Andreas Fabri, 11/01/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Iason Manolas, 11/04/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Sebastien Loriot (GeometryFactory), 11/04/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Iason Manolas, 11/04/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Iason Manolas, 11/04/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Sebastien Loriot (GeometryFactory), 11/07/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Iason Manolas, 11/07/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Sebastien Loriot (GeometryFactory), 11/07/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Iason Manolas, 11/10/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Iason Manolas, 11/04/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Iason Manolas, 11/04/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Sebastien Loriot (GeometryFactory), 11/04/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Iason Manolas, 11/04/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Andreas Fabri, 11/01/2016
- Re: [cgal-discuss] How do I construct a WritablePropertyMap?, Iason Manolas, 11/01/2016
Archive powered by MHonArc 2.6.18.