문제

I have written a program using cgal as follows:

typedef CGAL::Exact_predicates_inexact_constructions_kernel       K;
typedef CGAL::Triangulation_vertex_base_2<K>                      Vb;
typedef CGAL::Triangulation_face_base_with_info_2<FaceInfo2,K>    Fbb;
typedef CGAL::Constrained_triangulation_face_base_2<K,Fbb>        Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb>               TDS;
typedef CGAL::Exact_predicates_tag                                Itag;
typedef CGAL::Constrained_Delaunay_triangulation_2<K, TDS, Itag>  CDT;
typedef CDT::Point                                                Point;
typedef CGAL::Polygon_2<K>                                        Polygon_2;

int main( )
{

  //construct two non-intersecting nested polygons  
  Polygon_2 polygon1;
  polygon1.push_back(Point(0,0));
  polygon1.push_back(Point(2,0));
  polygon1.push_back(Point(2,2));
  polygon1.push_back(Point(0,2));
  CDT cdt;
  insert_polygon(cdt,polygon1);
  CDT::Finite_faces_iterator t=cdt.faces_begin();

for (t = cdt.finite_faces_begin(); t != cdt.finite_faces_end(); t++)
    {
      //how can i achieve that?

    }

}

I want to get vertices of the triangles from cdt.finite_faces_begin() to triangle which t point to that in each iteration of the for loop.

for example In the first iteration of the loop, I get the vertices of the first triangle and in the second iteration of the loop, i get vertices of the first+second triangles and in the third one,i get vertices first+second+third triangles and so on. how can i achieve that?

도움이 되었습니까?

해결책

If in the i'th iteratotion you want just the three vertices of the face use for(inti=0;i<3;++i){t->vertex(i);}, or t->vertex(i)->point().

If you do not want to get a vertex that you already got from a previous face, you must use a std::set<Vertex_handle> that you declare outside the loop.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top