Subject: CGAL users discussion list
List archive
- From: Genís <>
- To:
- Subject: [cgal-discuss] Triangulation with custom info on vertices
- Date: Thu, 12 Nov 2009 16:47:06 +0100
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=noQzD+uHLoPIzH8eedwjoak4BkmjgsDx/4zbCUHKx36RjRBmVlQUhmO52M1EXWWiym AoZefYZuMKOMQBWBGkbALP03rKXtbHSB01Tuag8ukXmEPCS2FS3kuBSl7gPHUSWgN3uV QPB4/bA/PRJREnm1zo4CcX71EszOOuwZ8sgK8=
Hi.
I am working on an app. for my college and dealing with Delaunay triangulations with custom vertex info. I have observed a weird behaviour when the information that is stored in those vertices are pointers no another data. Let's see these two stupid examples, where every vertex stores some kind of identifier: a int type in the first one and a pointer to an int in the second one:
/******************* FIRST EXAMPLE **************************/
typedef CGAL::Cartesian<double> K;
typedef CGAL::Triangulation_vertex_base_with_info_2<int,K> Vb;
typedef CGAL::Triangulation_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
typedef CGAL::Delaunay_triangulation_2<K,Tds> Delaunay;
typedef Delaunay::Vertex_handle Vertex_handle;
Delaunay t;
std::list<K::Point_2> l;
l.push_back(K::Point_2(0,1));
l.push_back(K::Point_2(1,2));
l.push_back(K::Point_2(1,2));
l.push_back(K::Point_2(2,2));
std::list<int> aux;
int i = 0;
for(list<K::Point_2>::const_iterator it = v.begin();
it != v.end(); it++){
Vertex_handle vh = t.insert(*it);
aux.push_back(i++);
vh->info() = aux.back();
}
for(Delaunay::Finite_edges_iterator it = t.finite_edges_begin ();
it!= t.finite_edges_end(); it++){
Vertex_handle vh1 = it->first->vertex(t.cw(it->second));
Vertex_handle vh2 = it->first->vertex(t.ccw(it->second));
std::cout << vh1->info() << " , "<<vh2->info()<<std::endl;
}
/**************************** SECOND EXAMPLE ************************/
typedef CGAL::Cartesian<double> K;
typedef CGAL::Triangulation_vertex_base_with_info_2<int*,K> Vb;
typedef CGAL::Triangulation_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
typedef CGAL::Delaunay_triangulation_2<K,Tds> Delaunay;
typedef Delaunay::Vertex_handle Vertex_handle;
Delaunay t;
std::list<K::Point_2> l;
l.push_back(K::Point_2(0,1));
l.push_back(K::Point_2(1,2));
l.push_back(K::Point_2(1,2));
l.push_back(K::Point_2(2,2));
std::list<int> aux;
int i = 0;
for(list<K::Point_2>::const_iterator it = v.begin();
it != v.end(); it++){
Vertex_handle vh = t.insert(*it);
aux.push_back(i++);
vh->info() =&(aux.back());
}
for(Delaunay::Finite_edges_iterator it = t.finite_edges_begin ();
it!= t.finite_edges_end(); it++){
Vertex_handle vh1 = it->first->vertex(t.cw(it->second));
Vertex_handle vh2 = it->first->vertex(t.ccw(it->second));
std::cout << *vh1->info() << " , "<<*vh2->info()<<std::endl;
}
/*************************** END *******************************/
That are silly examples. Of course, when I work with real data I have hundreds of points in the triangulation.
I would expect exactly the same output on both examples. Instead of that, I get that from the first one:
3 , 2
2 , 1
0 , 2
1 , 0
1 , 3
That was normal. Those pairs are the identifiers of the ends of each edge. Then in the second one I get this:
3 , 2
2 , 1073741824
0 , 2
1073741824 , 0
1073741824 , 3
Why I get that "1073741824" every time it should print just an "1". In the app. I am working on I really must store pointers to objects in the vertex info, not the instances itselves. Probably I am doing sth stupid, but I can't see what it is. When working with the data I have to deal with I get pointers to objects I didn't create, at least voluntarily.
Thanks for all
-------------
Genís Aguilar López
- [cgal-discuss] Triangulation with custom info on vertices, Genís, 11/12/2009
- Re: [cgal-discuss] Triangulation with custom info on vertices, mailtogenis, 11/12/2009
Archive powered by MHonArc 2.6.16.