Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] about the function incident_vertices() and output iterator

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] about the function incident_vertices() and output iterator


Chronological Thread 
  • From: "Laurent Rineau (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] about the function incident_vertices() and output iterator
  • Date: Thu, 22 Jan 2009 15:49:07 +0100
  • Organization: GeometryFactory

On Thursday 22 January 2009 15:30:21 Kwok Jasper wrote:
> Thank you very much
>
> and for the following for calling the incident_vertices function
>
> > > typedef CGAL::Exact_predicates_inexact_constructions_kernel K1;
> > > typedef CGAL::Delaunay_triangulation_3<K1> Triangulation;
> > > typedef Triangulation::Point Point_tr;
> > >
> > > Triangulation Tr;
> > >
> > > Vertex_handle v = Tr.insert(Point_tr(0,0,0));
> > > Tr.insert(Point_tr(40,20,10));
> > > //...insert some more
> > > points
> > >
> > > vector<Vertex_handle> con;
> > > con.resize(800);
> > >
> > > vector <Vertex_handle>::iterator start_inci = con.begin();
> > > vector<Vertex_handle>::iterator end_inci = con.end();
> > > vector<Vertex_handle>::iterator curr_inci;
> > >
> > > for(curr_inci = start_inci; curr_inci != end_inci; ++curr_inci)
> > > {
> > > //do sth with the vertex handles.
> > > }
>
> may I ask if it is a proper way to use it.
> In the method , I use con.resize(800);
> If I didn't use the resize() function there.
> then it have a exception telling that the iterator cannot be deferenced
> May I ask if the above code is a proper way to use the incident_vertices()

Hi,

The above code does not use incident_vertices() at all!

To fill a vector, you do not really need to use resize. The function
vector<T>::push_back(T) adds an element at the end of the vector, and
increases it size.

The usual way to use incident_vertices is the following:

#include <iterators>

// create an empty vector
std::vector<Vertex_handle> container;

t.incident_vertices(v, std::back_inserter(container));
// 'container' now contains handles for all vertices incident to 'v'

std::back_inserter is a function from the STL that creates a special "output
iterator" from a container. That output iterator internaly calls 'push_back'.

--
Laurent Rineau, PhD
Engineer at GeometryFactory
http://www.geometryfactory.com/




Archive powered by MHonArc 2.6.16.

Top of Page