Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Why do we need the property map parameters in read_xyz_points_and_normals()

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Why do we need the property map parameters in read_xyz_points_and_normals()


Chronological Thread 
  • From: Laurent Saboret <>
  • To:
  • Subject: Re: [cgal-discuss] Why do we need the property map parameters in read_xyz_points_and_normals()
  • Date: Mon, 08 Aug 2011 15:34:02 +0200

Hi Yifei,

Property maps are a generalization of std maps. Using C++ templates, they allow to retrieve an information (eg a point position) from a map, from an object's field, from a C array, ...

In the example below, "point_pmap" and "normal_pmap" are temporary variables used by read_xyz_points_and_normals() to write the position and normal in the Pwn point type.
They are not used after the end of read_xyz_points_and_normals().

Best regards,
Laurent Saboret


Le 08/08/2011 11:29, Yifei Li a écrit :
Laurent,

I did look at the links you gave me. However, although property maps are passed as parameters in those examples, they are never used later. For example, in examples/Point_set_processing_3/read_write_xyz_point_set_example.cpp
 
typedef std::pair<Point,Vector> Pwn; 
CGAL::read_xyz_points_and_normals(in, std::back_inserter(points), CGAL::First_of_pair_property_map<Pwn>(), CGAL::Second_of_pair_property_map<Pwn>())

the third and fourth parameter are two temporary variables only used in this function call, I don't understand the point of doing this. Without the third and fourth parameters, I would still be able to get the coordinate and normal information by iterating through the container points.

Also I took a look at the source code (read_xyz_points.h) and have a question regarding the following code:

else if (std::istringstream(line) >> x >> y >> z >> nx >> ny >> nz)
    {
      Point point(x,y,z);
      Vector normal(nx,ny,nz);
      Enriched_point pwn;
      put(point_pmap,  &pwn, point);  // point_pmap[&pwn] = point
      put(normal_pmap, &pwn, normal); // normal_pmap[&pwn] = normal
      *output++ = pwn;
    }

if I understand correctly, a property map consists of (key,value) pairs, just like std::map. In the above code, the address of a temporary variable, pwn, is used as key, and the container output stores all the keys. But what's the point of using the address of a temporary variable as key? How would you access the keys later?

Thanks

On Mon, Aug 8, 2011 at 4:44 AM, Laurent Saboret <> wrote:
Hi Yifei,

The "point_pmap" and "normal_pmap" property maps are used to access the point or normal information inside the "output" point type, so as to let the user decide upon the implementation of a point with normal.
See the property maps documentation at
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Point_set_processing_3/Chapter_main.html#Section_56.2

An example is provided in this documentation, and other examples are provided in "Surface Reconstruction from Point Sets" chapter
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Surface_reconstruction_points_3/Chapter_main.html

Best regards,
Laurent Saboret


Le 08/08/2011 09:24, Yifei Li a écrit :

Hi all,

read_xyz_points_and_normals(std::stream& in , OutputIterator output, PointPMap point_pmap, NormalPMap normal_pmap) is used to read coordinates and normals from a file (see CGAL/IO/read_xyz_points_and_normals.h). I don't understand what the parameters point_pmap and normal_pmap are useful for. It sounds like they are used to hold coordinates and normals respectively, but  I think output is used for this purpose too. I guess I may use the function in the following way:

typedef std::vector< std::pair<Point,Vector> > points;
read_xyz_points_and_normals(input,std::back_inserter(points));


I appreciate your help.

Yifei


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





Archive powered by MHonArc 2.6.16.

Top of Page