Subject: CGAL users discussion list
List archive
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] how to construct a 2d Triangulation explicitly
- Date: Mon, 23 May 2011 08:43:27 +0200
If you want to create your own triangulation, all operations
must be done at the TDS level. The TDS knows nothing about
finite or infinite simplices, they are simply simplices.
So the answer is yes, you need to create them.
S.
魏华祎 wrote:
Hi, Sebastien,
Thanks for your reply. Yes, you are right, the infinite vertex is already present there. But, what about the infinite faces? Do I need create them explicitly? The output of tri.number_of_faces() is still three. It should be two.
Huayi
On Sun, May 22, 2011 at 11:29 PM, Sebastien Loriot (GeometryFactory) <sloriot.ml <http://sloriot.ml>@gmail.com <http://gmail.com>> wrote:
The infinite vertex is already present in the triangulation even
when empty, so you don't need to create it.
S.
魏华祎 wrote:
Hi, everyone,
I have a 2d simple triangulation with four vertices:
p1 = (0,0), p2 = (1,0), p3 = (1,1), p4 = ( 0,1), and two
triangles: (p2, p3, p1) and (p4,p1,p3). And I want to construct
a object of Triangulation_2 class, explicitly ( not write these
information into files, then use >> read them). The following is
my code. But at last, I got five finite vertices and three
finite faces. I am confused, can anyone give me some
suggestions about it? Thanks very much!
By the way, I follow the code of the "file_input" member
function in Triangulation_data_structure_2.h to write my own code.
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/IO/Color.h>
#include <CGAL/Triangulation_2.h>
#include <CGAL/Triangulation_face_base_2.h>
#include <CGAL/Triangulation_vertex_base_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_2<K> Vb;
typedef CGAL::Triangulation_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
typedef CGAL::Triangulation_2<K,Tds> Triangulation;
typedef Triangulation::Face_handle Face_handle;
typedef Triangulation::Vertex_handle Vertex_handle;
typedef Triangulation::Point Point;
typedef Triangulation::Finite_vertices_iterator Fvi;
int main(){
int n = 4, m = 2, d = 2;
std::vector<Point> P(4);
P[0] = Point(0,0);
P[1] = Point(1,0);
P[2] = Point(1,1);
P[3] = Point(0,1);
std::vector<Vertex_handle> V(n+1);
std::vector<Face_handle> F(m);
Triangulation tri;
tri.tds().set_dimension(d);
// if I comment the following two lines, there will four finite
vertices, but still three faces
V[0] = tri.tds().create_vertex(); tri.set_infinite_vertex(V[0]); // set the infinite vertex of tri
// create the vertex_handles
for(int i = 1; i< 5;i++){
V[i] = tri.tds().create_vertex();
V[i]->set_point(P[i-1]);
}
//create the first face and set its vertices
F[0] = tri.create_face();
F[0]->set_vertex(0,V[2]);
V[2]->set_face(F[0]);
F[0]->set_vertex(1,V[3]);
V[3]->set_face(F[0]);
F[0]->set_vertex(2,V[1]);
V[1]->set_face(F[0]);
// create the second face and set its vertices
F[1] = tri.create_face();
F[1]->set_vertex(0,V[4]);
V[4]->set_face(F[1]);
F[1]->set_vertex(1,V[1]);
V[1]->set_face(F[1]);
F[1]->set_vertex(2,V[3]);
V[3]->set_face(F[1]);
// set neighbor information
F[0]->set_neighbor(0,F[1]);
F[1]->set_neighbor(0,F[0]);
std::cout<<tri.number_of_vertices()<<std::endl<<tri.number_of_faces()<<std::endl;
return 0;
}
-- You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
- [cgal-discuss] how to construct a 2d Triangulation explicitly, 魏华祎, 05/23/2011
- Re: [cgal-discuss] how to construct a 2d Triangulation explicitly, Sebastien Loriot (GeometryFactory), 05/23/2011
- Re: [cgal-discuss] how to construct a 2d Triangulation explicitly, 魏华祎, 05/23/2011
- Re: [cgal-discuss] how to construct a 2d Triangulation explicitly, Sebastien Loriot (GeometryFactory), 05/23/2011
- Re: [cgal-discuss] how to construct a 2d Triangulation explicitly, 魏华祎, 05/23/2011
- Re: [cgal-discuss] how to construct a 2d Triangulation explicitly, Sebastien Loriot (GeometryFactory), 05/23/2011
- Re: [cgal-discuss] how to construct a 2d Triangulation explicitly, 魏华祎, 05/23/2011
- Re: [cgal-discuss] how to construct a 2d Triangulation explicitly, Sebastien Loriot (GeometryFactory), 05/23/2011
- Re: [cgal-discuss] how to construct a 2d Triangulation explicitly, 魏华祎, 05/23/2011
- Re: [cgal-discuss] how to construct a 2d Triangulation explicitly, Laurent Rineau (GeometryFactory), 05/23/2011
- Re: [cgal-discuss] how to construct a 2d Triangulation explicitly, Sebastien Loriot (GeometryFactory), 05/23/2011
Archive powered by MHonArc 2.6.16.