I'm a newbie to CGAL and also C++ (Actually I'm a C developer and just moved to C++ in order to use CGAL).
I found that by mixing 2-3 examples provided in the CGAL documentation, I can do what I want with CGAL. If I run each code separately and take the output and introduce it to the second code, everything is fine. (In one of them I need to manually remove the normal vectors which are generated with the positions).
I use 1-Normal_estimation 2-edge_aware_upsampling 3-advancing_front_surface_reconstruction. I want to make them a single code because I need to run it over many samples.
The problem is that the first two codes are dealing with a pair
datatype.
typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_3 Point;
typedef K::Vector_3 Vector;
typedef std::pair<Point, Vector> PointVectorPair;
std::list<PointVectorPair> points;
However the last code works with
std::vector<Point> points_n;
I want to have a function that gives me the first part of std::list<std::pair<Point , Vector>>
which is Points
:
points_n = magic_function(points);
what is magic_function
?
You need to iterate over the std::list
and copy the Point
from each pair and push it into vector. If you have at least C++ 11 support you could do something like this:
std::vector<Point> magic_function(const std::list<PointVectorPair>& list)
{
std::vector<Point> out;//a temporary object to store the output
for(auto&& p: list)// for each pair in the list
{
out.push_back(std::get<0>(p)); //copy the point and push it on to the vector
}
return out; //return the vector of points
}
Or if you don't want to copy the point but rather would like to move it you could do:
std::vector<Point> magic_function(const std::list<PointVectorPair>& list)
{
std::vector<Point> out;//a temporary object to store the output
for(auto&& p: list)// for each pair in the list
{
out.push_back(std::move(std::get<0>(p))); //move the point to the vector
}
return out; //return the vector of points
}