Subject: CGAL users discussion list
List archive
- From: Juliano Costa <>
- To:
- Subject: [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3.
- Date: Sat, 1 Aug 2009 17:19:45 -0300
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=d+dFGGteEdVlQKEuoW8mBQH1lko49w2v6eILZrVIb/cnO5a/aqqPQ7oUuL5WU1+yiw RfPvOHq5cCmPEQeu2jejRRkDnaLsTVvRg7Y/07g5/sj1qwZNYKmIT7M4Ch6nkJRe7bX0 YyUVFFp56wI/rHiY9qVLm37EOGgfII7pbn1mE=
Hello,
I'm researching CGAL for 3D Triangulations.
To do so I'm providing to the CGAL::Delaunay_triangulation_3, 8 points of a 3D Cube.
Then I ran an Edge iterator and I got a result which is one of the diagonals of my cube.
I wasn't expecting to get this Edge.
If I run the finite_cells_iterator the result is even more strange to me because, If I try to draw the cells
in the order they are given my cube doesn't look right.
What is the right way to draw the triangles? Using edges iterators?
It seems that I didn't understand Delaunay triangulations 3 right.
Of course I'm aware that CGAL result is correct, or maybe my source code is wrong but, can someone please help me to understand it?
Is there any way to use CGAL library to get only the 12 triangles from the cube surface (2 triangles per side of the cube)?
The code I've been compiling on VS2005 32bit is right below.
Thanks anyone in advance!
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_vertex_base_with_info_3.h>
#include <conio.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_vertex_base_with_info_3.h>
#include <conio.h>
struct K : CGAL::Exact_predicates_inexact_constructions_kernel {};
typedef CGAL::Triangulation_vertex_base_with_info_3<unsigned long, K> Vb;
typedef CGAL::Triangulation_data_structure_3<Vb> Tds;
typedef CGAL::Delaunay_triangulation_3<K, Tds> Delaunay;
typedef Delaunay::Point Point;
typedef Delaunay::Vertex_handle Vertex_handle;
typedef CGAL::Triangulation_vertex_base_with_info_3<unsigned long, K> Vb;
typedef CGAL::Triangulation_data_structure_3<Vb> Tds;
typedef CGAL::Delaunay_triangulation_3<K, Tds> Delaunay;
typedef Delaunay::Point Point;
typedef Delaunay::Vertex_handle Vertex_handle;
int main()
{
Delaunay T;
{
Delaunay T;
Vertex_handle vh;
vh = T.insert(Point(-1,0,0));
vh->info() = 1; //attaching an index for each point from 1 to 8.
vh->info() = 1; //attaching an index for each point from 1 to 8.
vh = T.insert(Point(1,0,0));
vh->info() = 2;
vh = T.insert(Point(-1,0,1));
vh->info() = 3;
vh = T.insert(Point(1,0,1));
vh->info() = 4;
vh = T.insert(Point(-1,1,0));
vh->info() = 5;
vh = T.insert(Point(1,1,0));
vh->info() = 6;
vh = T.insert(Point(-1,1,1));
vh->info() = 7;
vh = T.insert(Point(1,1,1));
vh->info() = 2;
vh = T.insert(Point(-1,0,1));
vh->info() = 3;
vh = T.insert(Point(1,0,1));
vh->info() = 4;
vh = T.insert(Point(-1,1,0));
vh->info() = 5;
vh = T.insert(Point(1,1,0));
vh->info() = 6;
vh = T.insert(Point(-1,1,1));
vh->info() = 7;
vh = T.insert(Point(1,1,1));
vh->info() = 8;
int ct=0;
std::cout<<std::endl<<"Finite_edges_iterator:"<<std::endl;
for(Delaunay::Finite_edges_iterator eit=T.finite_edges_begin();eit!=T.finite_edges_end();eit++)
{
unsigned long i1 =eit->first->vertex(eit->second)->info();
unsigned long i2=eit->first->vertex(eit->third)->info();
std::cout<<" Edge: ("<<i1<<","<<i2<<")."<<std::endl;
}
ct=0;
std::cout<<std::endl<<"Finite_cells_iterator:"<<std::endl;
for(Delaunay::Finite_cells_iterator fcit=T.finite_cells_begin();fcit!=T.finite_cells_end();fcit++)
{
std::cout<<"Cell "<<ct++<<": "<<(fcit->vertex(0))->info()<<","<<(fcit->vertex(1))->info()<<","<<(fcit->vertex(2))->info()<<","<<(fcit->vertex(3))->info()<<std::endl;
}
{
std::cout<<"Cell "<<ct++<<": "<<(fcit->vertex(0))->info()<<","<<(fcit->vertex(1))->info()<<","<<(fcit->vertex(2))->info()<<","<<(fcit->vertex(3))->info()<<std::endl;
}
std::cout<<"Type anything to close!";
_getch();
return 0;
}
The output /*(in reduced number of lines)*/ is:
Finite_edges_iterator:
Edge: (1,3). Edge: (1,5). Edge: (3,5). Edge: (2,1). Edge: (2,3). Edge: (2,5). Edge: (6,8). Edge: (6,7).
Edge: (8,7). Edge: (8,4). Edge: (4,7). Edge: (2,4). Edge: (4,3). Edge: (2,6). Edge: (4,6). Edge: (6,5).
Edge: (3,7). Edge: (2,7). Edge: (7,5).
Edge: (1,3). Edge: (1,5). Edge: (3,5). Edge: (2,1). Edge: (2,3). Edge: (2,5). Edge: (6,8). Edge: (6,7).
Edge: (8,7). Edge: (8,4). Edge: (4,7). Edge: (2,4). Edge: (4,3). Edge: (2,6). Edge: (4,6). Edge: (6,5).
Edge: (3,7). Edge: (2,7). Edge: (7,5).
//Edge 2,7 is a diagonal of my cube!!!!! Is that right for a delaunay triangulation????
Finite_cells_iterator:
Cell 0: 2,1,3,5 Cell 1: 6,4,8,7 Cell 2: 3,4,2,7 Cell 3: 2,4,6,7 Cell 4: 2,7,6,5 Cell 5: 3,7,2,5
Cell 0: 2,1,3,5 Cell 1: 6,4,8,7 Cell 2: 3,4,2,7 Cell 3: 2,4,6,7 Cell 4: 2,7,6,5 Cell 5: 3,7,2,5
- [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3., Juliano Costa, 08/01/2009
- [cgal-discuss] Re: Newbie question about CGAL Hierarchy Triangulation 3., Juliano Costa, 08/02/2009
- Re: [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3., Mariette Yvinec, 08/03/2009
- Re: [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3., Juliano Costa, 08/03/2009
- Re: [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3., Manuel Caroli, 08/05/2009
- Re: [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3., Juliano Costa, 08/05/2009
- Re: [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3., Manuel Caroli, 08/05/2009
- Re: [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3., Juliano Costa, 08/05/2009
- Re: [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3., Manuel Caroli, 08/05/2009
- Re: [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3., Juliano Costa, 08/07/2009
- Re: [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3., Manuel Caroli, 08/10/2009
- Re: [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3., Juliano Costa, 08/05/2009
- Re: [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3., Manuel Caroli, 08/05/2009
- Re: [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3., Juliano Costa, 08/05/2009
- Re: [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3., Manuel Caroli, 08/05/2009
- Re: [cgal-discuss] Newbie question about CGAL Hierarchy Triangulation 3., Juliano Costa, 08/03/2009
Archive powered by MHonArc 2.6.16.