Skip to Content.
Sympa Menu

cgal-discuss - Re: Line_face_circulator

Subject: CGAL users discussion list

List archive

Re: Line_face_circulator


Chronological Thread 
  • From:
  • To:
  • Subject: Re: Line_face_circulator
  • Date: Thu, 17 Jan 2008 15:21:20 +0100

I don't like to leave questions unanswered, so here is the solution:

You need the function
do_intersect(Triangle_2..., Segment_2)
which is to be found in
CGAL/intersections.h

Here's the whole code:

#include <list>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
struct K : CGAL::Exact_predicates_inexact_constructions_kernel {};
#include <CGAL/Triangulation_euclidean_traits_xy_3.h>
typedef CGAL::Triangulation_euclidean_traits_xy_3<K> Gt;
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_face_base_2.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
#include <CGAL/intersections.h>

using namespace std;
class My_Vertex_info{};
typedef CGAL::Delaunay_triangulation_2<Gt,
CGAL::Triangulation_data_structure_2
<CGAL::Triangulation_vertex_base_with_info_2<My_Vertex_info,Gt>,
CGAL::Triangulation_face_base_2<Gt> > > Delaunay;
typedef Delaunay::Point CGAL_Point;
typedef CGAL::Exact_predicates_inexact_constructions_kernel My_kernel;

int main()
{
Delaunay dt;
CGAL_Point next_point1(1,1,0);
CGAL_Point next_point2(4,3,0);
CGAL_Point next_point3(1,4,0);
CGAL_Point next_point4(3,6,0);
Delaunay::Vertex_handle vh1 = dt.insert(next_point1);
Delaunay::Vertex_handle vh2 = dt.insert(next_point2);
Delaunay::Vertex_handle vh3 = dt.insert(next_point3);
Delaunay::Vertex_handle vh4 = dt.insert(next_point4);

CGAL_Point p1(3,3,1);
CGAL_Point p2(4,1,1);

My_kernel::Point_2 ps(p1.x(), p1.y());
My_kernel::Point_2 pe(p2.x(), p2.y());
My_kernel::Segment_2 l(ps,pe);

Delaunay::Line_face_circulator lfc = dt.line_walk(p1, p2);
cout<<circulator_size(lfc)<<endl;
list<Delaunay::Vertex_handle> My_vertices;
for(int i=0; i<(circulator_size(lfc)-2); i++)
{
Delaunay::Vertex_handle vh_test1 = lfc->vertex(0);
Delaunay::Vertex_handle vh_test2 = lfc->vertex(1);
Delaunay::Vertex_handle vh_test3 = lfc->vertex(2);
My_kernel::Point_2 p3(vh_test1->point()[0], vh_test1->point()[1]);
My_kernel::Point_2 p4(vh_test2->point()[0], vh_test2->point()[1]);
My_kernel::Point_2 p5(vh_test3->point()[0], vh_test3->point()[1]);
My_kernel::Triangle_2 t(p3,p4,p5);
if(do_intersect(t, l))
{
My_vertices.push_back(vh_test1);
My_vertices.push_back(vh_test2);
My_vertices.push_back(vh_test3);
}
lfc++;
}
My_vertices.sort();My_vertices.unique();
for(list<Delaunay::Vertex_handle>::const_iterator i = My_vertices.begin(); i
!= My_vertices.end(); i++)
{
cout<<((*i)->point())[0]<<" "<<((*i)->point())[1]<<"
"<<((*i)->point())[2]<<endl;
}


  • Line_face_circulator, novacheva, 01/16/2008
    • <Possible follow-up(s)>
    • Re: Line_face_circulator, novacheva, 01/17/2008

Archive powered by MHonArc 2.6.16.

Top of Page