Insertion of weighted point with info in CGAL regu

2019-04-15 08:38发布

问题:

I'm facing a problem that I hope some others have faced before because I can't find a way out !

I have a regular triangulation in CGAL in which I wish to insert some weighted points with info std::pair<myweightpoint, myinfo> one by one and to get the handle to the vertex (Vertex_handle) once it is inserted ! The thing is that there is no such function. It exists several functions to insert :

  • Vertex_handleRegular_triangulation::insert( const Weighted_point & p ) ;

That returns a Vertex_handle which is cool but does not take weighted points WITH INFO which is very important for me and what I do with those vertices.

  • std::ptrdiff_tRegular_triangulation::insert( WeightedPointWithInfoInputIterator first, WeightedPointWithInfoInputIterator last ) ;

Which allows me to insert some weighted points with info (which is good) but doesn't gives me a handle to the inserted vertex. Moreover, since I am inserting points one at a time, for now I'm doing things like this :

v_wpoints.resize(1) ;
v_wpoints[0] = std::make_pair(myweightpoint, myinfo) ;
rt.insert(v_wpoints.begin(), v_wpoints.end()) ;

which seems really dirty. So, my questions are : why isn't there a function like that :

Vertex_handle Regular_triangulation::insert( const Weighted_point_with_info & p ) ;

and how can I do to insert a weighted point with info in the regular triangulation and get the handle to the vertex inserted.

Thanks a lot.

回答1:

What you can do is:

Vertex_handle v = rt.insert(wp);
v->info()=the_info;