Subject: CGAL users discussion list
List archive
- From: "Laurent Rineau (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] how to construct a 2d Triangulation explicitly
- Date: Mon, 23 May 2011 11:16:32 +0200
- Organization: GeometryFactory
On lundi 23 mai 2011 03:00:28 魏华祎 wrote:
> 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]);
> }
Forget those low level functions! You do not know what they do. Just use the
insert() function:
// [... skipped the #include and typedef, please recopy them...]
int main(){
int n = 4;
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);
Triangulation tri;
for(int i = 1; i< 4;i++){
tri.insert(P[i]);
}
std::cout << tri.number_of_vertices() << std::endl
<< tri.number_of_faces() << std:endl;
}
Then after 'tri' is filled, you can navigate into it using the query
functions. See
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Triangulation_2_ref/Class_Triangulation_2.html
--
Laurent Rineau, PhD
R&D Engineer at GeometryFactory http://www.geometryfactory.com/
Release Manager of the CGAL Project http://www.cgal.org/
- [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.