Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Strange behavior of std::vector containing CGAL::Polyhedron_3<Traits>::Vertex pointers

Subject: CGAL users discussion list

List archive

[cgal-discuss] Strange behavior of std::vector containing CGAL::Polyhedron_3<Traits>::Vertex pointers


Chronological Thread 
  • From: Miltiadis Koutsokeras <>
  • To: "" <>
  • Subject: [cgal-discuss] Strange behavior of std::vector containing CGAL::Polyhedron_3<Traits>::Vertex pointers
  • Date: Wed, 16 Jul 2008 00:08:35 +0300

I'm experiencing some strange behavior while using an std::vector of CGAL::Polyhedron_3<Traits>::Vertex pointers.
While iterating through the container I watermark every element is labeled with the value -1 or 1 and its 1-ring neighbors with value 2. In every iteration labeling only the vertices that have a label equal to zero, because a vertex can be a neighbor of a
previous thus it's already labeled with 2. The strange thing is that I encounter vertices labeled with 1 or -1, although before the iteration all vertices labels are initialized with zeros. In the example code below I specify the condition that breaks. Can someone
please give me any tip about CGAL::Polyhedron_3<Traits>::Vertex pointers and why this behavior happens?

Code:
/**
* Embeds the watermark to the primitive.
*/
void embedWatermark(SpatialPrimitive& v, WatermarkPrimitive watermark)
{
#ifdef _DEBUG
assert(v.m_label == 0);
#endif

typedef typename SpatialPrimitive VertexType;
typedef typename VertexType::Halfedge_around_vertex_circulator Circ;
typedef typename VertexType::Vertex_handle Vertex_handle;

std::size_t neighbors_num = 0;

// loop through neighbors
Circ c = v.vertex_begin();
Circ end = c;
Vertex_handle neighbor;

CGAL_For_all(c, end)
{
neighbor = c->opposite()->vertex();
neighbors_num++;
neighbor->m_label = 2;
}

#ifdef _DEBUG
assert(neighbors_num == v.vertex_degree());
#endif
v.m_label = watermark;
}



/**
* Watermarks a list of vertices usign a list of watermark samples.
* @param chosen_verts List of vertices to watermark.
* @param watermark_samples List of watermark samples.
*/
void watermarkVertices(std::vector<Vertex *> chosen_verts, std::vector<short> watermark_samples)
{
#ifdef _DEBUG
unsigned int chosen_vertices_size = chosen_verts.size(),
watermark_samples_size = watermark_samples.size();
assert(chosen_vertices_size == watermark_samples_size);
#endif
std::vector<Vertex *>::iterator vertex_it = chosen_verts.begin();
std::vector<Vertex *>::const_iterator vertex_end = chosen_verts.end();
std::vector<short>::iterator sample_it = watermark_samples.begin();

for(; vertex_it != vertex_end; ++vertex_it, ++sample_it)
{
#ifdef _DEBUG
*// this assertion fails after some iterations
assert(((*vertex_it)->m_label == 0) || ((*vertex_it)->m_label == 2));*
#endif
if((*vertex_it)->m_label == 0)
{
embedWatermark(*(*vertex_it), *sample_it);
}
}
}

--
Koutsokeras Miltiadis

Computational Intelligence Laboratory (http://www.iit.demokritos.gr/cil/)
Institute of Informatics and Telecommunications
National Center for Scientific Research "Demokritos"
P.O. BOX 60228
GR-153 10 Agia Paraskevi, Athens, Greece.



  • [cgal-discuss] Strange behavior of std::vector containing CGAL::Polyhedron_3<Traits>::Vertex pointers, Miltiadis Koutsokeras, 07/15/2008

Archive powered by MHonArc 2.6.16.

Top of Page