How do I construct a WritablePropertyMap?

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I construct a WritablePropertyMap?

Iasonm
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 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 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, but I did not understand much..

Could anyone suggest a way of creating the property map I need?

Best Regards,
Iason
Reply | Threaded
Open this post in threaded view
|

Re: How do I construct a WritablePropertyMap?

Sebastien Loriot (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


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


Reply | Threaded
Open this post in threaded view
|

Re: How do I construct a WritablePropertyMap?

Iasonm
Thanks for your response Sebastien.

After reading your code  I wrote:
using vd=boost::graph_traits<CGALPolyhedron>::vertex_descriptor;
std::map<vd,Kernel::Vector_3>* normals;        CGAL::Polygon_mesh_processing::compute_vertex_normals(P,normals); (since I want to compute vertex and not face normals)

But I get:

/usr/include/CGAL/Polygon_mesh_processing/compute_normal.h:228: error: no matching function for call to ‘put(std::map<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Point_3<CGAL::Epick> > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Point_3<CGAL::Epick> > > > > >, CGAL::Vector_3<CGAL::Epick> >&, CGAL::HDS_graph_traits<CGAL::Polyhedron_3<CGAL::Epick> >::vertex_descriptor&, CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double, CGAL::Epick>, CGAL::Epick>::Vector_3&)’
     put(vnm, v, vec);
        ^
That propably means that the put fuction cannot recognize vnm ( I passed) as a valid argument?



On 1 November 2016 at 09:50, Sebastien Loriot (GeometryFactory) <[hidden email]> wrote:
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


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



Reply | Threaded
Open this post in threaded view
|

Re: How do I construct a WritablePropertyMap?

andreas.fabri
In reply to this post by Iasonm
Hello,

I just added an example:
https://github.com/CGAL/cgal/pull/1638

Best,

Andreas

On 31/10/2016 12:46, 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

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

phone: +33.492.954.912    skype: andreas.fabri

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


Reply | Threaded
Open this post in threaded view
|

Re: How do I construct a WritablePropertyMap?

andreas.fabri
In reply to this post by Iasonm
You must
#include <boost/property_map/property_map.hpp>

and write
compute_vertex_normals(P,boost::make_assoc_property_map(normals))

On 01/11/2016 09:45, Iason Manolas wrote:

> Thanks for your response Sebastien.
>
> After reading your code  I wrote:
> using vd=boost::graph_traits<CGALPolyhedron>::vertex_descriptor;
> std::map<vd,Kernel::Vector_3>* normals;
> CGAL::Polygon_mesh_processing::compute_vertex_normals(P,normals); (since
> I want to compute vertex and not face normals)
>
> But I get:
>
> /usr/include/CGAL/Polygon_mesh_processing/compute_normal.h:228: error:
> no matching function for call to
> ‘put(std::map<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,
> CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
> std::allocator<int> >, CGAL::Boolean_tag<true>,
> CGAL::Point_3<CGAL::Epick> > > >,
> std::allocator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,
> CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
> std::allocator<int> >, CGAL::Boolean_tag<true>,
> CGAL::Point_3<CGAL::Epick> > > > > >, CGAL::Vector_3<CGAL::Epick> >&,
> CGAL::HDS_graph_traits<CGAL::Polyhedron_3<CGAL::Epick>
>>::vertex_descriptor&,
> CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double,
> CGAL::Epick>, CGAL::Epick>::Vector_3&)’
>      put(vnm, v, vec);
>         ^
> That propably means that the put fuction cannot recognize vnm ( I
> passed) as a valid argument?
>
>
>
> On 1 November 2016 at 09:50, Sebastien Loriot (GeometryFactory)
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     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
>     <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
>     <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
>         <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
>         <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
>         <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
>
>
>
>     --
>     You are currently subscribed to cgal-discuss.
>     To unsubscribe or access the archives, go to
>     https://sympa.inria.fr/sympa/info/cgal-discuss
>     <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

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


Reply | Threaded
Open this post in threaded view
|

Re: How do I construct a WritablePropertyMap?

Iasonm
In reply to this post by andreas.fabri
That was quick! Thanks for your prompt reply.
boost::make_assoc_property_map(normals) was missing. It converts to an Lvalue Property Map which provides the operator[] which is need in the put function that was throwing the previously mentioned error (?) .

Best Regards,
Iason

On 1 November 2016 at 10:50, Andreas Fabri <[hidden email]> wrote:
Hello,

I just added an example:
https://github.com/CGAL/cgal/pull/1638

Best,

Andreas

On 31/10/2016 12:46, 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

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

phone: <a href="tel:%2B33.492.954.912" value="+33492954912" target="_blank">+33.492.954.912    skype: andreas.fabri


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



Reply | Threaded
Open this post in threaded view
|

Re: How do I construct a WritablePropertyMap?

Iasonm
In reply to this post by andreas.fabri
My program crashes when I call compute_vertex_normals.
The stack calling the function that crashes is:
4.In compute_normal.h at line 183: (!is_border(he,pmesh))
3.In helpers.h at line 45: face(hd,g)
2.In graph_traits_Polyhedron_3.h at line: 420: h->face();
1.In HalfedgeDS_halfedge_base.h at line 327: face()

The error I get in Qt creator is SIGSEGV which after searching found out that propably means: "Trying to access pointer with invalid value."
My guess was that I had not correctly initialized the Polyhedron but everything seems fine..

Any idea why this happens? 

Best Regards,
Iason Manolas

On 1 November 2016 at 10:53, Andreas Fabri <[hidden email]> wrote:
You must
#include <boost/property_map/property_map.hpp>

and write
compute_vertex_normals(P,boost::make_assoc_property_map(normals))


On 01/11/2016 09:45, Iason Manolas wrote:
Thanks for your response Sebastien.

After reading your code  I wrote:
using vd=boost::graph_traits<CGALPolyhedron>::vertex_descriptor;
std::map<vd,Kernel::Vector_3>* normals;
CGAL::Polygon_mesh_processing::compute_vertex_normals(P,normals); (since
I want to compute vertex and not face normals)

But I get:

/usr/include/CGAL/Polygon_mesh_processing/compute_normal.h:228: error:
no matching function for call to
‘put(std::map<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,
CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
std::allocator<int> >, CGAL::Boolean_tag<true>,
CGAL::Point_3<CGAL::Epick> > > >,
std::allocator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,
CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
std::allocator<int> >, CGAL::Boolean_tag<true>,
CGAL::Point_3<CGAL::Epick> > > > > >, CGAL::Vector_3<CGAL::Epick> >&,
CGAL::HDS_graph_traits<CGAL::Polyhedron_3<CGAL::Epick>
::vertex_descriptor&,
CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double,
CGAL::Epick>, CGAL::Epick>::Vector_3&)’
     put(vnm, v, vec);
        ^
That propably means that the put fuction cannot recognize vnm ( I
passed) as a valid argument?



On 1 November 2016 at 09:50, Sebastien Loriot (GeometryFactory)
<[hidden email] <mailto:[hidden email]>> wrote:

    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
    <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
    <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
        <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
        <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
        <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



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




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

phone: <a href="tel:%2B33.492.954.912" value="+33492954912" target="_blank">+33.492.954.912    skype: andreas.fabri

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



Reply | Threaded
Open this post in threaded view
|

Re: How do I construct a WritablePropertyMap?

Sebastien Loriot (GeometryFactory)
What is your polyhedron type?

Sebastien.

On 11/04/2016 02:59 PM, Iason Manolas wrote:

> My program crashes when I call compute_vertex_normals.
> The stack calling the function that crashes is:
> 4.In *compute_normal.h*at line 183: *(!is_border**(he,pmesh))*
> 3.In *helpers.h* at line 45: *face(hd,g)*
> 2.In *graph_traits_Polyhedron_3.h* at line: 420: *h->face();*
> 1.In H*alfedgeDS_halfedge_base.h* at line 327:*face()*
>
> The error I get in Qt creator is SIGSEGV
> <http://stackoverflow.com/questions/2454192/whats-sigsegv-segmentation-fault-in-qt>
> which after searching found out that propably means: "Trying to access
> pointer with invalid value."
> My guess was that I had not correctly initialized the Polyhedron but
> everything seems fine..
>
> Any idea why this happens?
>
> Best Regards,
> Iason Manolas
>
> On 1 November 2016 at 10:53, Andreas Fabri
> <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     You must
>     #include <boost/property_map/property_map.hpp>
>
>     and write
>     compute_vertex_normals(P,boost::make_assoc_property_map(normals))
>
>
>     On 01/11/2016 09:45, Iason Manolas wrote:
>
>         Thanks for your response Sebastien.
>
>         After reading your code  I wrote:
>         using vd=boost::graph_traits<CGALPolyhedron>::vertex_descriptor;
>         std::map<vd,Kernel::Vector_3>* normals;
>         CGAL::Polygon_mesh_processing::compute_vertex_normals(P,normals); (since
>         I want to compute vertex and not face normals)
>
>         But I get:
>
>         /usr/include/CGAL/Polygon_mesh_processing/compute_normal.h:228:
>         error:
>         no matching function for call to
>         ‘put(std::map<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,
>         CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
>         std::allocator<int> >, CGAL::Boolean_tag<true>,
>         CGAL::Point_3<CGAL::Epick> > > >,
>         std::allocator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,
>         CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
>         std::allocator<int> >, CGAL::Boolean_tag<true>,
>         CGAL::Point_3<CGAL::Epick> > > > > >,
>         CGAL::Vector_3<CGAL::Epick> >&,
>         CGAL::HDS_graph_traits<CGAL::Polyhedron_3<CGAL::Epick>
>
>             ::vertex_descriptor&,
>
>         CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double,
>         CGAL::Epick>, CGAL::Epick>::Vector_3&)’
>              put(vnm, v, vec);
>                 ^
>         That propably means that the put fuction cannot recognize vnm ( I
>         passed) as a valid argument?
>
>
>
>         On 1 November 2016 at 09:50, Sebastien Loriot (GeometryFactory)
>         <[hidden email] <mailto:[hidden email]>
>         <mailto:[hidden email] <mailto:[hidden email]>>> wrote:
>
>             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
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
>         <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
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
>         <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
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
>         <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
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
>         <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
>         <http://doc.cgal.org/latest/Property_map/index.html>
>                 <http://doc.cgal.org/latest/Property_map/index.html
>         <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
>
>
>
>             --
>             You are currently subscribed to cgal-discuss.
>             To unsubscribe or access the archives, go to
>             https://sympa.inria.fr/sympa/info/cgal-discuss
>         <https://sympa.inria.fr/sympa/info/cgal-discuss>
>             <https://sympa.inria.fr/sympa/info/cgal-discuss
>         <https://sympa.inria.fr/sympa/info/cgal-discuss>>
>
>
>
>
>     --
>     Andreas Fabri, PhD
>     Chief Officer, GeometryFactory
>     Editor, The CGAL Project
>
>     phone: +33.492.954.912 <tel:%2B33.492.954.912>    skype: andreas.fabri
>
>     --
>     You are currently subscribed to cgal-discuss.
>     To unsubscribe or access the archives, go to
>     https://sympa.inria.fr/sympa/info/cgal-discuss
>     <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


Reply | Threaded
Open this post in threaded view
|

Re: How do I construct a WritablePropertyMap?

Iasonm
CGAL::Polyhedron_3<CGAL::Exact_predicates_inexact_constructions_kernel>

On 4 November 2016 at 16:10, Sebastien Loriot (GeometryFactory) <[hidden email]> wrote:
What is your polyhedron type?

Sebastien.

On 11/04/2016 02:59 PM, Iason Manolas wrote:
My program crashes when I call compute_vertex_normals.
The stack calling the function that crashes is:
4.In *compute_normal.h*at line 183: *(!is_border**(he,pmesh))*
3.In *helpers.h* at line 45: *face(hd,g)*
2.In *graph_traits_Polyhedron_3.h* at line: 420: *h->face();*
1.In H*alfedgeDS_halfedge_base.h* at line 327:*face()*

The error I get in Qt creator is SIGSEGV
<http://stackoverflow.com/questions/2454192/whats-sigsegv-segmentation-fault-in-qt>
which after searching found out that propably means: "Trying to access
pointer with invalid value."
My guess was that I had not correctly initialized the Polyhedron but
everything seems fine..

Any idea why this happens?

Best Regards,
Iason Manolas

On 1 November 2016 at 10:53, Andreas Fabri
<[hidden email]
<mailto:[hidden email]>> wrote:

    You must
    #include <boost/property_map/property_map.hpp>

    and write
    compute_vertex_normals(P,boost::make_assoc_property_map(normals))


    On 01/11/2016 09:45, Iason Manolas wrote:

        Thanks for your response Sebastien.

        After reading your code  I wrote:
        using vd=boost::graph_traits<CGALPolyhedron>::vertex_descriptor;
        std::map<vd,Kernel::Vector_3>* normals;
        CGAL::Polygon_mesh_processing::compute_vertex_normals(P,normals); (since
        I want to compute vertex and not face normals)

        But I get:

        /usr/include/CGAL/Polygon_mesh_processing/compute_normal.h:228:
        error:
        no matching function for call to
        ‘put(std::map<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,
        CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
        std::allocator<int> >, CGAL::Boolean_tag<true>,
        CGAL::Point_3<CGAL::Epick> > > >,
        std::allocator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,
        CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
        std::allocator<int> >, CGAL::Boolean_tag<true>,
        CGAL::Point_3<CGAL::Epick> > > > > >,
        CGAL::Vector_3<CGAL::Epick> >&,
        CGAL::HDS_graph_traits<CGAL::Polyhedron_3<CGAL::Epick>

            ::vertex_descriptor&,

        CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double,
        CGAL::Epick>, CGAL::Epick>::Vector_3&)’
             put(vnm, v, vec);
                ^
        That propably means that the put fuction cannot recognize vnm ( I
        passed) as a valid argument?



        On 1 November 2016 at 09:50, Sebastien Loriot (GeometryFactory)
        <[hidden email] <mailto:[hidden email]>
        <mailto:[hidden email] <mailto:[hidden email]>>> wrote:

            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
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>

        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
        <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
        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>

        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
        <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
        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>

        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
        <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
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>

        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
        <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
        <http://doc.cgal.org/latest/Property_map/index.html>
                <http://doc.cgal.org/latest/Property_map/index.html
        <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



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




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

    phone: <a href="tel:%2B33.492.954.912" value="+33492954912" target="_blank">+33.492.954.912 <tel:%2B33.492.954.912>    skype: andreas.fabri

    --
    You are currently subscribed to cgal-discuss.
    To unsubscribe or access the archives, go to
    https://sympa.inria.fr/sympa/info/cgal-discuss
    <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



Reply | Threaded
Open this post in threaded view
|

Re: How do I construct a WritablePropertyMap?

Iasonm
This is my code.
Do you think there could be something wrong with my cgal distribution?

Iason


On 4 November 2016 at 16:17, Iason Manolas <[hidden email]> wrote:
CGAL::Polyhedron_3<CGAL::Exact_predicates_inexact_constructions_kernel>

On 4 November 2016 at 16:10, Sebastien Loriot (GeometryFactory) <[hidden email]> wrote:
What is your polyhedron type?

Sebastien.

On 11/04/2016 02:59 PM, Iason Manolas wrote:
My program crashes when I call compute_vertex_normals.
The stack calling the function that crashes is:
4.In *compute_normal.h*at line 183: *(!is_border**(he,pmesh))*
3.In *helpers.h* at line 45: *face(hd,g)*
2.In *graph_traits_Polyhedron_3.h* at line: 420: *h->face();*
1.In H*alfedgeDS_halfedge_base.h* at line 327:*face()*

The error I get in Qt creator is SIGSEGV
<http://stackoverflow.com/questions/2454192/whats-sigsegv-segmentation-fault-in-qt>
which after searching found out that propably means: "Trying to access
pointer with invalid value."
My guess was that I had not correctly initialized the Polyhedron but
everything seems fine..

Any idea why this happens?

Best Regards,
Iason Manolas

On 1 November 2016 at 10:53, Andreas Fabri
<[hidden email]
<mailto:[hidden email]>> wrote:

    You must
    #include <boost/property_map/property_map.hpp>

    and write
    compute_vertex_normals(P,boost::make_assoc_property_map(normals))


    On 01/11/2016 09:45, Iason Manolas wrote:

        Thanks for your response Sebastien.

        After reading your code  I wrote:
        using vd=boost::graph_traits<CGALPolyhedron>::vertex_descriptor;
        std::map<vd,Kernel::Vector_3>* normals;
        CGAL::Polygon_mesh_processing::compute_vertex_normals(P,normals); (since
        I want to compute vertex and not face normals)

        But I get:

        /usr/include/CGAL/Polygon_mesh_processing/compute_normal.h:228:
        error:
        no matching function for call to
        ‘put(std::map<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,
        CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
        std::allocator<int> >, CGAL::Boolean_tag<true>,
        CGAL::Point_3<CGAL::Epick> > > >,
        std::allocator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,
        CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
        std::allocator<int> >, CGAL::Boolean_tag<true>,
        CGAL::Point_3<CGAL::Epick> > > > > >,
        CGAL::Vector_3<CGAL::Epick> >&,
        CGAL::HDS_graph_traits<CGAL::Polyhedron_3<CGAL::Epick>

            ::vertex_descriptor&,

        CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double,
        CGAL::Epick>, CGAL::Epick>::Vector_3&)’
             put(vnm, v, vec);
                ^
        That propably means that the put fuction cannot recognize vnm ( I
        passed) as a valid argument?



        On 1 November 2016 at 09:50, Sebastien Loriot (GeometryFactory)
        <[hidden email] <mailto:[hidden email]>
        <mailto:[hidden email] <mailto:[hidden email]>>> wrote:

            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
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>

        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
        <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
        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>

        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
        <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
        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>

        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
        <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
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>

        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
        <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
        <http://doc.cgal.org/latest/Property_map/index.html>
                <http://doc.cgal.org/latest/Property_map/index.html
        <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



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




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

    phone: <a href="tel:%2B33.492.954.912" value="+33492954912" target="_blank">+33.492.954.912 <tel:%2B33.492.954.912>    skype: andreas.fabri

    --
    You are currently subscribed to cgal-discuss.
    To unsubscribe or access the archives, go to
    https://sympa.inria.fr/sympa/info/cgal-discuss
    <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




Reply | Threaded
Open this post in threaded view
|

Re: How do I construct a WritablePropertyMap?

Sebastien Loriot (GeometryFactory)
Could you check P.is_valid() returns true before calling compute_normals?

On 11/04/2016 03:58 PM, Iason Manolas wrote:

> This
> <https://github.com/IasonManolas/Thesis/blob/meshScene/mypolyhedron.h>
> is my code.
> Do you think there could be something wrong with my cgal distribution?
>
> Iason
>
>
> On 4 November 2016 at 16:17, Iason Manolas <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     CGAL::Polyhedron_3<CGAL::Exact_predicates_inexact_constructions_kernel>
>
>     On 4 November 2016 at 16:10, Sebastien Loriot (GeometryFactory)
>     <[hidden email] <mailto:[hidden email]>> wrote:
>
>         What is your polyhedron type?
>
>         Sebastien.
>
>         On 11/04/2016 02:59 PM, Iason Manolas wrote:
>
>             My program crashes when I call compute_vertex_normals.
>             The stack calling the function that crashes is:
>             4.In *compute_normal.h*at line 183: *(!is_border**(he,pmesh))*
>             3.In *helpers.h* at line 45: *face(hd,g)*
>             2.In *graph_traits_Polyhedron_3.h* at line: 420: *h->face();*
>             1.In H*alfedgeDS_halfedge_base.h* at line 327:*face()*
>
>             The error I get in Qt creator is SIGSEGV
>             <http://stackoverflow.com/questions/2454192/whats-sigsegv-segmentation-fault-in-qt
>             <http://stackoverflow.com/questions/2454192/whats-sigsegv-segmentation-fault-in-qt>>
>             which after searching found out that propably means: "Trying
>             to access
>             pointer with invalid value."
>             My guess was that I had not correctly initialized the
>             Polyhedron but
>             everything seems fine..
>
>             Any idea why this happens?
>
>             Best Regards,
>             Iason Manolas
>
>             On 1 November 2016 at 10:53, Andreas Fabri
>             <[hidden email]
>             <mailto:[hidden email]>
>             <mailto:[hidden email]
>             <mailto:[hidden email]>>> wrote:
>
>                 You must
>                 #include <boost/property_map/property_map.hpp>
>
>                 and write
>
>             compute_vertex_normals(P,boost::make_assoc_property_map(normals))
>
>
>                 On 01/11/2016 09:45, Iason Manolas wrote:
>
>                     Thanks for your response Sebastien.
>
>                     After reading your code  I wrote:
>                     using
>             vd=boost::graph_traits<CGALPolyhedron>::vertex_descriptor;
>                     std::map<vd,Kernel::Vector_3>* normals;
>
>             CGAL::Polygon_mesh_processing::compute_vertex_normals(P,normals);
>             (since
>                     I want to compute vertex and not face normals)
>
>                     But I get:
>
>
>             /usr/include/CGAL/Polygon_mesh_processing/compute_normal.h:228:
>                     error:
>                     no matching function for call to
>
>             ‘put(std::map<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,
>
>             CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
>                     std::allocator<int> >, CGAL::Boolean_tag<true>,
>                     CGAL::Point_3<CGAL::Epick> > > >,
>
>             std::allocator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,
>
>             CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
>                     std::allocator<int> >, CGAL::Boolean_tag<true>,
>                     CGAL::Point_3<CGAL::Epick> > > > > >,
>                     CGAL::Vector_3<CGAL::Epick> >&,
>                     CGAL::HDS_graph_traits<CGAL::Polyhedron_3<CGAL::Epick>
>
>                         ::vertex_descriptor&,
>
>
>             CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double,
>                     CGAL::Epick>, CGAL::Epick>::Vector_3&)’
>                          put(vnm, v, vec);
>                             ^
>                     That propably means that the put fuction cannot
>             recognize vnm ( I
>                     passed) as a valid argument?
>
>
>
>                     On 1 November 2016 at 09:50, Sebastien Loriot
>             (GeometryFactory)
>                     <[hidden email] <mailto:[hidden email]>
>             <mailto:[hidden email] <mailto:[hidden email]>>
>                     <mailto:[hidden email]
>             <mailto:[hidden email]> <mailto:[hidden email]
>             <mailto:[hidden email]>>>> wrote:
>
>                         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
>             <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>
>
>             <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
>             <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>>
>
>
>             <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
>             <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>
>
>             <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
>             <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
>             <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>
>
>             <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
>             <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>>
>
>
>             <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
>             <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>
>
>             <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
>             <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
>             <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>
>
>             <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
>             <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>>
>
>
>             <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
>             <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>
>
>             <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
>             <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
>             <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>
>
>             <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
>             <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>>
>
>
>             <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
>             <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>
>
>             <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
>             <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
>             <http://doc.cgal.org/latest/Property_map/index.html>
>                     <http://doc.cgal.org/latest/Property_map/index.html
>             <http://doc.cgal.org/latest/Property_map/index.html>>
>
>             <http://doc.cgal.org/latest/Property_map/index.html
>             <http://doc.cgal.org/latest/Property_map/index.html>
>                     <http://doc.cgal.org/latest/Property_map/index.html
>             <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
>
>
>
>                         --
>                         You are currently subscribed to cgal-discuss.
>                         To unsubscribe or access the archives, go to
>                         https://sympa.inria.fr/sympa/info/cgal-discuss
>             <https://sympa.inria.fr/sympa/info/cgal-discuss>
>                     <https://sympa.inria.fr/sympa/info/cgal-discuss
>             <https://sympa.inria.fr/sympa/info/cgal-discuss>>
>                         <https://sympa.inria.fr/sympa/info/cgal-discuss
>             <https://sympa.inria.fr/sympa/info/cgal-discuss>
>                     <https://sympa.inria.fr/sympa/info/cgal-discuss
>             <https://sympa.inria.fr/sympa/info/cgal-discuss>>>
>
>
>
>
>                 --
>                 Andreas Fabri, PhD
>                 Chief Officer, GeometryFactory
>                 Editor, The CGAL Project
>
>                 phone: +33.492.954.912 <tel:%2B33.492.954.912>
>             <tel:%2B33.492.954.912>    skype: andreas.fabri
>
>                 --
>                 You are currently subscribed to cgal-discuss.
>                 To unsubscribe or access the archives, go to
>                 https://sympa.inria.fr/sympa/info/cgal-discuss
>             <https://sympa.inria.fr/sympa/info/cgal-discuss>
>                 <https://sympa.inria.fr/sympa/info/cgal-discuss
>             <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
>         <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


Reply | Threaded
Open this post in threaded view
|

Re: How do I construct a WritablePropertyMap?

Iasonm
ah! you are right, it is not valid..
So probably  there is something wrong with the way i build it?

I use the following code to build it:

using Kernel=CGAL::Exact_predicates_inexact_constructions_kernel;
using CGALPolyhedron=CGAL::Polyhedron_3<Kernel>;
using HalfedgeDS=CGALPolyhedron::HalfedgeDS;

template<class HDS>
class  PolyhedronBuilder:public CGAL::Modifier_base<HDS>
{
public:


    Mesh         M;

    PolyhedronBuilder(){}
    explicit PolyhedronBuilder(const Mesh& model):M{model}{}
    void operator()(HDS& hds)
    {
        typedef typename HDS::Vertex    Vertex;
        typedef typename Vertex::Point     Point;

        CGAL::Polyhedron_incremental_builder_3<HDS> B(hds,true);
        B.begin_surface(M.vertices.size(),M.indices.size()/3);

        //add vertices
        for(const auto& vert:M.vertices)
            B.add_vertex(Point(vert.Position.x,vert.Position.y,vert.Position.z));

        //add faces
        for(uint i=0;i<M.indices.size()/3;i+=3)
        {
            B.begin_facet();
            B.add_vertex_to_facet(M.indices[i]);
            B.add_vertex_to_facet(M.indices[i+1]);
            B.add_vertex_to_facet(M.indices[i+2]);
            B.end_facet();
        }
        B.end_surface();

    }
};

and then:
PolyhedronBuilder<HalfedgeDS> builder(mesh);
myPolyhedron.delegate(builder);

which was based on .



On 7 November 2016 at 10:24, Sebastien Loriot (GeometryFactory) <[hidden email]> wrote:
Could you check P.is_valid() returns true before calling compute_normals?

On 11/04/2016 03:58 PM, Iason Manolas wrote:
This
<https://github.com/IasonManolas/Thesis/blob/meshScene/mypolyhedron.h>
is my code.
Do you think there could be something wrong with my cgal distribution?

Iason


On 4 November 2016 at 16:17, Iason Manolas <[hidden email]
<mailto:[hidden email]>> wrote:

    CGAL::Polyhedron_3<CGAL::Exact_predicates_inexact_constructions_kernel>

    On 4 November 2016 at 16:10, Sebastien Loriot (GeometryFactory)
    <[hidden email] <mailto:[hidden email]>> wrote:

        What is your polyhedron type?

        Sebastien.

        On 11/04/2016 02:59 PM, Iason Manolas wrote:

            My program crashes when I call compute_vertex_normals.
            The stack calling the function that crashes is:
            4.In *compute_normal.h*at line 183: *(!is_border**(he,pmesh))*
            3.In *helpers.h* at line 45: *face(hd,g)*
            2.In *graph_traits_Polyhedron_3.h* at line: 420: *h->face();*
            1.In H*alfedgeDS_halfedge_base.h* at line 327:*face()*

            The error I get in Qt creator is SIGSEGV
            <http://stackoverflow.com/questions/2454192/whats-sigsegv-segmentation-fault-in-qt
            <http://stackoverflow.com/questions/2454192/whats-sigsegv-segmentation-fault-in-qt>>
            which after searching found out that propably means: "Trying
            to access
            pointer with invalid value."
            My guess was that I had not correctly initialized the
            Polyhedron but
            everything seems fine..

            Any idea why this happens?

            Best Regards,
            Iason Manolas

            On 1 November 2016 at 10:53, Andreas Fabri
            <[hidden email]
            <mailto:[hidden email]>
            <mailto:[hidden email]

            <mailto:[hidden email]>>> wrote:

                You must
                #include <boost/property_map/property_map.hpp>

                and write

            compute_vertex_normals(P,boost::make_assoc_property_map(normals))


                On 01/11/2016 09:45, Iason Manolas wrote:

                    Thanks for your response Sebastien.

                    After reading your code  I wrote:
                    using
            vd=boost::graph_traits<CGALPolyhedron>::vertex_descriptor;
                    std::map<vd,Kernel::Vector_3>* normals;

            CGAL::Polygon_mesh_processing::compute_vertex_normals(P,normals);
            (since
                    I want to compute vertex and not face normals)

                    But I get:


            /usr/include/CGAL/Polygon_mesh_processing/compute_normal.h:228:
                    error:
                    no matching function for call to

            ‘put(std::map<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,

            CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
                    std::allocator<int> >, CGAL::Boolean_tag<true>,
                    CGAL::Point_3<CGAL::Epick> > > >,

            std::allocator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,

            CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
                    std::allocator<int> >, CGAL::Boolean_tag<true>,
                    CGAL::Point_3<CGAL::Epick> > > > > >,
                    CGAL::Vector_3<CGAL::Epick> >&,
                    CGAL::HDS_graph_traits<CGAL::Polyhedron_3<CGAL::Epick>

                        ::vertex_descriptor&,


            CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double,
                    CGAL::Epick>, CGAL::Epick>::Vector_3&)’
                         put(vnm, v, vec);
                            ^
                    That propably means that the put fuction cannot
            recognize vnm ( I
                    passed) as a valid argument?



                    On 1 November 2016 at 09:50, Sebastien Loriot
            (GeometryFactory)
                    <[hidden email] <mailto:[hidden email]>
            <mailto:[hidden email] <mailto:[hidden email]>>
                    <mailto:[hidden email]
            <mailto:[hidden email]> <mailto:[hidden email]
            <mailto:[hidden email]>>>> wrote:

                        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
            <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>

            <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
            <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>>


            <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
            <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>

            <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
            <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
            <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>

            <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
            <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>>


            <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
            <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>

            <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
            <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
            <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>

            <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
            <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>>


            <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
            <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>

            <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
            <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
            <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>

            <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
            <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>>


            <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
            <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>

            <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
            <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
            <http://doc.cgal.org/latest/Property_map/index.html>
                    <http://doc.cgal.org/latest/Property_map/index.html
            <http://doc.cgal.org/latest/Property_map/index.html>>

            <http://doc.cgal.org/latest/Property_map/index.html
            <http://doc.cgal.org/latest/Property_map/index.html>
                    <http://doc.cgal.org/latest/Property_map/index.html
            <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



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




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

                phone: <a href="tel:%2B33.492.954.912" value="+33492954912" target="_blank">+33.492.954.912 <tel:%2B33.492.954.912>
            <tel:%2B33.492.954.912>    skype: andreas.fabri

                --
                You are currently subscribed to cgal-discuss.
                To unsubscribe or access the archives, go to
                https://sympa.inria.fr/sympa/info/cgal-discuss
            <https://sympa.inria.fr/sympa/info/cgal-discuss>
                <https://sympa.inria.fr/sympa/info/cgal-discuss
            <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
        <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



Reply | Threaded
Open this post in threaded view
|

Re: How do I construct a WritablePropertyMap?

Sebastien Loriot (GeometryFactory)

You probably have an face orientation issue.
You can try calling orient_polygon_soup()

http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__repairing__grp.html#gaadc5bac3072b11d2313e40043c729d0a

Note that in case of non-manifold vertices, those will be duplicated.

Sebastien.


On 11/07/2016 10:00 AM, Iason Manolas wrote:

> ah! you are right, it is not valid..
> So probably  there is something wrong with the way i build it?
>
> I use the following code to build it:
>
> using Kernel=CGAL::Exact_predicates_inexact_constructions_kernel;
> using CGALPolyhedron=CGAL::Polyhedron_3<Kernel>;
> using HalfedgeDS=CGALPolyhedron::HalfedgeDS;
>
> template<class HDS>
> class  PolyhedronBuilder:public CGAL::Modifier_base<HDS>
> {
> public:
>
>
>     Mesh         M;
>
>     PolyhedronBuilder(){}
>     explicit PolyhedronBuilder(const Mesh& model):M{model}{}
>     void operator()(HDS& hds)
>     {
>         typedef typename HDS::Vertex    Vertex;
>         typedef typename Vertex::Point     Point;
>
>         CGAL::Polyhedron_incremental_builder_3<HDS> B(hds,true);
>         B.begin_surface(M.vertices.size(),M.indices.size()/3);
>
>         //add vertices
>         for(const auto& vert:M.vertices)
>
> B.add_vertex(Point(vert.Position.x,vert.Position.y,vert.Position.z));
>
>         //add faces
>         for(uint i=0;i<M.indices.size()/3;i+=3)
>         {
>             B.begin_facet();
>             B.add_vertex_to_facet(M.indices[i]);
>             B.add_vertex_to_facet(M.indices[i+1]);
>             B.add_vertex_to_facet(M.indices[i+2]);
>             B.end_facet();
>         }
>         B.end_surface();
>
>     }
> };
>
> and then:
> PolyhedronBuilder<HalfedgeDS> builder(mesh);
> myPolyhedron.delegate(builder);
>
> which was based on
> <http://doc.cgal.org/latest/Polyhedron/classCGAL_1_1Polyhedron__incremental__builder__3.html>
> .
>
>
>
> On 7 November 2016 at 10:24, Sebastien Loriot (GeometryFactory)
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Could you check P.is_valid() returns true before calling
>     compute_normals?
>
>     On 11/04/2016 03:58 PM, Iason Manolas wrote:
>
>         This
>         <https://github.com/IasonManolas/Thesis/blob/meshScene/mypolyhedron.h
>         <https://github.com/IasonManolas/Thesis/blob/meshScene/mypolyhedron.h>>
>         is my code.
>         Do you think there could be something wrong with my cgal
>         distribution?
>
>         Iason
>
>
>         On 4 November 2016 at 16:17, Iason Manolas <[hidden email]
>         <mailto:[hidden email]>
>         <mailto:[hidden email] <mailto:[hidden email]>>> wrote:
>
>
>         CGAL::Polyhedron_3<CGAL::Exact_predicates_inexact_constructions_kernel>
>
>             On 4 November 2016 at 16:10, Sebastien Loriot (GeometryFactory)
>             <[hidden email] <mailto:[hidden email]>
>         <mailto:[hidden email] <mailto:[hidden email]>>> wrote:
>
>                 What is your polyhedron type?
>
>                 Sebastien.
>
>                 On 11/04/2016 02:59 PM, Iason Manolas wrote:
>
>                     My program crashes when I call compute_vertex_normals.
>                     The stack calling the function that crashes is:
>                     4.In *compute_normal.h*at line 183:
>         *(!is_border**(he,pmesh))*
>                     3.In *helpers.h* at line 45: *face(hd,g)*
>                     2.In *graph_traits_Polyhedron_3.h* at line: 420:
>         *h->face();*
>                     1.In H*alfedgeDS_halfedge_base.h* at line 327:*face()*
>
>                     The error I get in Qt creator is SIGSEGV
>
>         <http://stackoverflow.com/questions/2454192/whats-sigsegv-segmentation-fault-in-qt
>         <http://stackoverflow.com/questions/2454192/whats-sigsegv-segmentation-fault-in-qt>
>
>         <http://stackoverflow.com/questions/2454192/whats-sigsegv-segmentation-fault-in-qt
>         <http://stackoverflow.com/questions/2454192/whats-sigsegv-segmentation-fault-in-qt>>>
>                     which after searching found out that propably means:
>         "Trying
>                     to access
>                     pointer with invalid value."
>                     My guess was that I had not correctly initialized the
>                     Polyhedron but
>                     everything seems fine..
>
>                     Any idea why this happens?
>
>                     Best Regards,
>                     Iason Manolas
>
>                     On 1 November 2016 at 10:53, Andreas Fabri
>                     <[hidden email]
>         <mailto:[hidden email]>
>                     <mailto:[hidden email]
>         <mailto:[hidden email]>>
>                     <mailto:[hidden email]
>         <mailto:[hidden email]>
>
>                     <mailto:[hidden email]
>         <mailto:[hidden email]>>>> wrote:
>
>                         You must
>                         #include <boost/property_map/property_map.hpp>
>
>                         and write
>
>
>         compute_vertex_normals(P,boost::make_assoc_property_map(normals))
>
>
>                         On 01/11/2016 09:45, Iason Manolas wrote:
>
>                             Thanks for your response Sebastien.
>
>                             After reading your code  I wrote:
>                             using
>
>         vd=boost::graph_traits<CGALPolyhedron>::vertex_descriptor;
>                             std::map<vd,Kernel::Vector_3>* normals;
>
>
>         CGAL::Polygon_mesh_processing::compute_vertex_normals(P,normals);
>                     (since
>                             I want to compute vertex and not face normals)
>
>                             But I get:
>
>
>
>         /usr/include/CGAL/Polygon_mesh_processing/compute_normal.h:228:
>                             error:
>                             no matching function for call to
>
>
>         ‘put(std::map<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,
>
>
>         CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
>                             std::allocator<int> >, CGAL::Boolean_tag<true>,
>                             CGAL::Point_3<CGAL::Epick> > > >,
>
>
>         std::allocator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,
>
>
>         CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
>                             std::allocator<int> >, CGAL::Boolean_tag<true>,
>                             CGAL::Point_3<CGAL::Epick> > > > > >,
>                             CGAL::Vector_3<CGAL::Epick> >&,
>
>         CGAL::HDS_graph_traits<CGAL::Polyhedron_3<CGAL::Epick>
>
>                                 ::vertex_descriptor&,
>
>
>
>         CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double,
>                             CGAL::Epick>, CGAL::Epick>::Vector_3&)’
>                                  put(vnm, v, vec);
>                                     ^
>                             That propably means that the put fuction cannot
>                     recognize vnm ( I
>                             passed) as a valid argument?
>
>
>
>                             On 1 November 2016 at 09:50, Sebastien Loriot
>                     (GeometryFactory)
>                             <[hidden email]
>         <mailto:[hidden email]> <mailto:[hidden email]
>         <mailto:[hidden email]>>
>                     <mailto:[hidden email]
>         <mailto:[hidden email]> <mailto:[hidden email]
>         <mailto:[hidden email]>>>
>                             <mailto:[hidden email]
>         <mailto:[hidden email]>
>                     <mailto:[hidden email]
>         <mailto:[hidden email]>> <mailto:[hidden email]
>         <mailto:[hidden email]>
>                     <mailto:[hidden email]
>         <mailto:[hidden email]>>>>> wrote:
>
>                                 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
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>>
>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>>>
>
>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>>
>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
>         <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
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>>
>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>>>
>
>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>>
>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
>         <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
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>>
>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>>>
>
>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>>
>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>
>
>         <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
>         <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
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>>
>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>>>
>
>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>>
>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>
>
>         <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
>         <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
>         <http://doc.cgal.org/latest/Property_map/index.html>
>                     <http://doc.cgal.org/latest/Property_map/index.html
>         <http://doc.cgal.org/latest/Property_map/index.html>>
>
>         <http://doc.cgal.org/latest/Property_map/index.html
>         <http://doc.cgal.org/latest/Property_map/index.html>
>                     <http://doc.cgal.org/latest/Property_map/index.html
>         <http://doc.cgal.org/latest/Property_map/index.html>>>
>
>                     <http://doc.cgal.org/latest/Property_map/index.html
>         <http://doc.cgal.org/latest/Property_map/index.html>
>                     <http://doc.cgal.org/latest/Property_map/index.html
>         <http://doc.cgal.org/latest/Property_map/index.html>>
>
>         <http://doc.cgal.org/latest/Property_map/index.html
>         <http://doc.cgal.org/latest/Property_map/index.html>
>                     <http://doc.cgal.org/latest/Property_map/index.html
>         <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
>
>
>
>                                 --
>                                 You are currently subscribed to
>         cgal-discuss.
>                                 To unsubscribe or access the archives, go to
>
>         https://sympa.inria.fr/sympa/info/cgal-discuss
>         <https://sympa.inria.fr/sympa/info/cgal-discuss>
>                     <https://sympa.inria.fr/sympa/info/cgal-discuss
>         <https://sympa.inria.fr/sympa/info/cgal-discuss>>
>
>         <https://sympa.inria.fr/sympa/info/cgal-discuss
>         <https://sympa.inria.fr/sympa/info/cgal-discuss>
>                     <https://sympa.inria.fr/sympa/info/cgal-discuss
>         <https://sympa.inria.fr/sympa/info/cgal-discuss>>>
>
>         <https://sympa.inria.fr/sympa/info/cgal-discuss
>         <https://sympa.inria.fr/sympa/info/cgal-discuss>
>                     <https://sympa.inria.fr/sympa/info/cgal-discuss
>         <https://sympa.inria.fr/sympa/info/cgal-discuss>>
>
>         <https://sympa.inria.fr/sympa/info/cgal-discuss
>         <https://sympa.inria.fr/sympa/info/cgal-discuss>
>                     <https://sympa.inria.fr/sympa/info/cgal-discuss
>         <https://sympa.inria.fr/sympa/info/cgal-discuss>>>>
>
>
>
>
>                         --
>                         Andreas Fabri, PhD
>                         Chief Officer, GeometryFactory
>                         Editor, The CGAL Project
>
>                         phone: +33.492.954.912 <tel:%2B33.492.954.912>
>         <tel:%2B33.492.954.912>
>                     <tel:%2B33.492.954.912>    skype: andreas.fabri
>
>                         --
>                         You are currently subscribed to cgal-discuss.
>                         To unsubscribe or access the archives, go to
>                         https://sympa.inria.fr/sympa/info/cgal-discuss
>         <https://sympa.inria.fr/sympa/info/cgal-discuss>
>                     <https://sympa.inria.fr/sympa/info/cgal-discuss
>         <https://sympa.inria.fr/sympa/info/cgal-discuss>>
>                         <https://sympa.inria.fr/sympa/info/cgal-discuss
>         <https://sympa.inria.fr/sympa/info/cgal-discuss>
>                     <https://sympa.inria.fr/sympa/info/cgal-discuss
>         <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
>         <https://sympa.inria.fr/sympa/info/cgal-discuss>
>                 <https://sympa.inria.fr/sympa/info/cgal-discuss
>         <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
>     <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


Reply | Threaded
Open this post in threaded view
|

Re: How do I construct a WritablePropertyMap?

Iasonm
This actually worked!

Iason

On 7 November 2016 at 17:20, Sebastien Loriot (GeometryFactory) <[hidden email]> wrote:

You probably have an face orientation issue.
You can try calling orient_polygon_soup()

http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__repairing__grp.html#gaadc5bac3072b11d2313e40043c729d0a

Note that in case of non-manifold vertices, those will be duplicated.

Sebastien.



On 11/07/2016 10:00 AM, Iason Manolas wrote:
ah! you are right, it is not valid..
So probably  there is something wrong with the way i build it?

I use the following code to build it:

using Kernel=CGAL::Exact_predicates_inexact_constructions_kernel;
using CGALPolyhedron=CGAL::Polyhedron_3<Kernel>;
using HalfedgeDS=CGALPolyhedron::HalfedgeDS;

template<class HDS>
class  PolyhedronBuilder:public CGAL::Modifier_base<HDS>
{
public:


    Mesh         M;

    PolyhedronBuilder(){}
    explicit PolyhedronBuilder(const Mesh& model):M{model}{}
    void operator()(HDS& hds)
    {
        typedef typename HDS::Vertex    Vertex;
        typedef typename Vertex::Point     Point;

        CGAL::Polyhedron_incremental_builder_3<HDS> B(hds,true);
        B.begin_surface(M.vertices.size(),M.indices.size()/3);

        //add vertices
        for(const auto& vert:M.vertices)

B.add_vertex(Point(vert.Position.x,vert.Position.y,vert.Position.z));

        //add faces
        for(uint i=0;i<M.indices.size()/3;i+=3)
        {
            B.begin_facet();
            B.add_vertex_to_facet(M.indices[i]);
            B.add_vertex_to_facet(M.indices[i+1]);
            B.add_vertex_to_facet(M.indices[i+2]);
            B.end_facet();
        }
        B.end_surface();

    }
};

and then:
PolyhedronBuilder<HalfedgeDS> builder(mesh);
myPolyhedron.delegate(builder);

which was based on
<http://doc.cgal.org/latest/Polyhedron/classCGAL_1_1Polyhedron__incremental__builder__3.html>
.



On 7 November 2016 at 10:24, Sebastien Loriot (GeometryFactory)
<[hidden email] <mailto:[hidden email]>> wrote:

    Could you check P.is_valid() returns true before calling
    compute_normals?

    On 11/04/2016 03:58 PM, Iason Manolas wrote:

        This
        <https://github.com/IasonManolas/Thesis/blob/meshScene/mypolyhedron.h
        <https://github.com/IasonManolas/Thesis/blob/meshScene/mypolyhedron.h>>
        is my code.
        Do you think there could be something wrong with my cgal
        distribution?

        Iason


        On 4 November 2016 at 16:17, Iason Manolas <[hidden email]
        <mailto:[hidden email]>
        <mailto:[hidden email] <mailto:[hidden email]>>> wrote:


        CGAL::Polyhedron_3<CGAL::Exact_predicates_inexact_constructions_kernel>

            On 4 November 2016 at 16:10, Sebastien Loriot (GeometryFactory)
            <[hidden email] <mailto:[hidden email]>
        <mailto:[hidden email] <mailto:[hidden email]>>> wrote:

                What is your polyhedron type?

                Sebastien.

                On 11/04/2016 02:59 PM, Iason Manolas wrote:

                    My program crashes when I call compute_vertex_normals.
                    The stack calling the function that crashes is:
                    4.In *compute_normal.h*at line 183:
        *(!is_border**(he,pmesh))*
                    3.In *helpers.h* at line 45: *face(hd,g)*
                    2.In *graph_traits_Polyhedron_3.h* at line: 420:
        *h->face();*
                    1.In H*alfedgeDS_halfedge_base.h* at line 327:*face()*

                    The error I get in Qt creator is SIGSEGV

        <http://stackoverflow.com/questions/2454192/whats-sigsegv-segmentation-fault-in-qt
        <http://stackoverflow.com/questions/2454192/whats-sigsegv-segmentation-fault-in-qt>

        <http://stackoverflow.com/questions/2454192/whats-sigsegv-segmentation-fault-in-qt
        <http://stackoverflow.com/questions/2454192/whats-sigsegv-segmentation-fault-in-qt>>>
                    which after searching found out that propably means:
        "Trying
                    to access
                    pointer with invalid value."
                    My guess was that I had not correctly initialized the
                    Polyhedron but
                    everything seems fine..

                    Any idea why this happens?

                    Best Regards,
                    Iason Manolas

                    On 1 November 2016 at 10:53, Andreas Fabri
                    <[hidden email]
        <mailto:[hidden email]>
                    <mailto:[hidden email]
        <mailto:[hidden email]>>
                    <mailto:[hidden email]
        <mailto:[hidden email]>

                    <mailto:[hidden email]
        <mailto:[hidden email]>>>> wrote:

                        You must
                        #include <boost/property_map/property_map.hpp>

                        and write


        compute_vertex_normals(P,boost::make_assoc_property_map(normals))


                        On 01/11/2016 09:45, Iason Manolas wrote:

                            Thanks for your response Sebastien.

                            After reading your code  I wrote:
                            using

        vd=boost::graph_traits<CGALPolyhedron>::vertex_descriptor;
                            std::map<vd,Kernel::Vector_3>* normals;


        CGAL::Polygon_mesh_processing::compute_vertex_normals(P,normals);
                    (since
                            I want to compute vertex and not face normals)

                            But I get:



        /usr/include/CGAL/Polygon_mesh_processing/compute_normal.h:228:
                            error:
                            no matching function for call to


        ‘put(std::map<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,


        CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
                            std::allocator<int> >, CGAL::Boolean_tag<true>,
                            CGAL::Point_3<CGAL::Epick> > > >,


        std::allocator<CGAL::HalfedgeDS_in_place_list_vertex<CGAL::I_Polyhedron_vertex<CGAL::HalfedgeDS_vertex_base<CGAL::HalfedgeDS_list_types<CGAL::Epick,


        CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>,
                            std::allocator<int> >, CGAL::Boolean_tag<true>,
                            CGAL::Point_3<CGAL::Epick> > > > > >,
                            CGAL::Vector_3<CGAL::Epick> >&,

        CGAL::HDS_graph_traits<CGAL::Polyhedron_3<CGAL::Epick>

                                ::vertex_descriptor&,



        CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double,
                            CGAL::Epick>, CGAL::Epick>::Vector_3&)’
                                 put(vnm, v, vec);
                                    ^
                            That propably means that the put fuction cannot
                    recognize vnm ( I
                            passed) as a valid argument?



                            On 1 November 2016 at 09:50, Sebastien Loriot
                    (GeometryFactory)
                            <[hidden email]
        <mailto:[hidden email]> <mailto:[hidden email]
        <mailto:[hidden email]>>
                    <mailto:[hidden email]
        <mailto:[hidden email]> <mailto:[hidden email]
        <mailto:[hidden email]>>>
                            <mailto:[hidden email]
        <mailto:[hidden email]>
                    <mailto:[hidden email]
        <mailto:[hidden email]>> <mailto:[hidden email]
        <mailto:[hidden email]>
                    <mailto:[hidden email]
        <mailto:[hidden email]>>>>> wrote:

                                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
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>

        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>>


        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>

        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>>>



        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>

        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>>


        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html>

        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/associative_property_map.html
        <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
        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>

        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>>


        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>

        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>>>



        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>

        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>>


        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html>

        <http://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2compute_normals_example_8cpp-example.html
        <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
        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>

        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>>


        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>

        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>>>



        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>

        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>>


        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e>

        <http://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#gad46aaf003999b2939f3f9e4f6fa58d0e
        <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
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>

        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>>


        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>

        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>>>



        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>

        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>>


        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html>

        <http://www.boost.org/doc/libs/1_62_0/libs/property_map/doc/WritablePropertyMap.html
        <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
        <http://doc.cgal.org/latest/Property_map/index.html>
                    <http://doc.cgal.org/latest/Property_map/index.html
        <http://doc.cgal.org/latest/Property_map/index.html>>

        <http://doc.cgal.org/latest/Property_map/index.html
        <http://doc.cgal.org/latest/Property_map/index.html>
                    <http://doc.cgal.org/latest/Property_map/index.html
        <http://doc.cgal.org/latest/Property_map/index.html>>>

                    <http://doc.cgal.org/latest/Property_map/index.html
        <http://doc.cgal.org/latest/Property_map/index.html>
                    <http://doc.cgal.org/latest/Property_map/index.html
        <http://doc.cgal.org/latest/Property_map/index.html>>

        <http://doc.cgal.org/latest/Property_map/index.html
        <http://doc.cgal.org/latest/Property_map/index.html>
                    <http://doc.cgal.org/latest/Property_map/index.html
        <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



                                --
                                You are currently subscribed to
        cgal-discuss.
                                To unsubscribe or access the archives, go to

        https://sympa.inria.fr/sympa/info/cgal-discuss
        <https://sympa.inria.fr/sympa/info/cgal-discuss>
                    <https://sympa.inria.fr/sympa/info/cgal-discuss
        <https://sympa.inria.fr/sympa/info/cgal-discuss>>

        <https://sympa.inria.fr/sympa/info/cgal-discuss
        <https://sympa.inria.fr/sympa/info/cgal-discuss>
                    <https://sympa.inria.fr/sympa/info/cgal-discuss
        <https://sympa.inria.fr/sympa/info/cgal-discuss>>>

        <https://sympa.inria.fr/sympa/info/cgal-discuss
        <https://sympa.inria.fr/sympa/info/cgal-discuss>
                    <https://sympa.inria.fr/sympa/info/cgal-discuss
        <https://sympa.inria.fr/sympa/info/cgal-discuss>>

        <https://sympa.inria.fr/sympa/info/cgal-discuss
        <https://sympa.inria.fr/sympa/info/cgal-discuss>
                    <https://sympa.inria.fr/sympa/info/cgal-discuss
        <https://sympa.inria.fr/sympa/info/cgal-discuss>>>>




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

                        phone: <a href="tel:%2B33.492.954.912" value="+33492954912" target="_blank">+33.492.954.912 <tel:%2B33.492.954.912>
        <tel:%2B33.492.954.912>
                    <tel:%2B33.492.954.912>    skype: andreas.fabri

                        --
                        You are currently subscribed to cgal-discuss.
                        To unsubscribe or access the archives, go to
                        https://sympa.inria.fr/sympa/info/cgal-discuss
        <https://sympa.inria.fr/sympa/info/cgal-discuss>
                    <https://sympa.inria.fr/sympa/info/cgal-discuss
        <https://sympa.inria.fr/sympa/info/cgal-discuss>>
                        <https://sympa.inria.fr/sympa/info/cgal-discuss
        <https://sympa.inria.fr/sympa/info/cgal-discuss>
                    <https://sympa.inria.fr/sympa/info/cgal-discuss
        <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
        <https://sympa.inria.fr/sympa/info/cgal-discuss>
                <https://sympa.inria.fr/sympa/info/cgal-discuss
        <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
    <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