Hi Yifei,
This code uses C++ templates and is difficult to read. The
instruction "put(point_pmap, &pwn, point)" is equivalent to
"pwn.first = point" when pwn is of type Pwn =
std::pair<Point,Vector> and point_pmap is of type
First_of_pair_property_map<Pwn>.
You should probably read the implementation of boost::put() and
CGAL::First_of_pair_property_map<Pwn>() if you want to
understand the details.
Best regards,
Laurent Saboret
Le 09/08/2011 09:38, Yifei Li a écrit :
On Mon, Aug 8, 2011 at 9:34 AM, Laurent
Saboret <>
wrote:
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().
Yes, I can see that. But I'm still a bit confused. In
function read_xyz_points_and_normals(), the position and
normal are saved in "point_pmap" and "normal_pmap" as seen by
the code:
put(point_pmap, &pwn, point); //
point_pmap[&pwn] = point
put(normal_pmap, &pwn, normal); //
normal_pmap[&pwn] = normal
At the same time, they are also saved in the
container output:
*output++=pwn;
What's the point of this duplication? Thanks
Best regards,
Laurent Saboret
Le 08/08/2011 11:29, Yifei Li a écrit :
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
|