我试图了解 CGAL 中的三角剖分是如何工作的,我想编辑多边形三角剖分上的面。该程序是:
#include <CGAL/Point_2.h>
#include <CGAL/Triangulation_2.h>
#include <CGAL/Triangulation_euclidean_traits_2.h>
#include <vector>
typedef CGAL::Cartesian<double> TutorialR;
typedef CGAL::Point_2<TutorialR> Point;
typedef CGAL::Vector_2<TutorialR> Vector;
typedef CGAL::Segment_2<TutorialR> Segment;
typedef CGAL::Triangle_2<TutorialR> Triangle;
typedef CGAL::Circle_2<TutorialR> Circle;
typedef CGAL::Bbox_2 Bbox;
typedef CGAL::Aff_transformation_2<TutorialR> Transformation;
typedef CGAL::Polygon_traits_2<TutorialR> Polygon_traits;
typedef std::list< Point > Polygon_Container;
typedef CGAL::Polygon_2< Polygon_traits, Polygon_Container > Polygon;
typedef CGAL::Triangulation_euclidean_traits_2<TutorialR> EucliTraits;
typedef CGAL::Triangulation_vertex_base_2<EucliTraits> TrianVbase;
typedef CGAL::Triangulation_face_base_2<EucliTraits> TrianFbase;
typedef CGAL::Triangulation_default_data_structure_2<
EucliTraits, TrianVbase, TrianFbase> TrianDs;
typedef CGAL::Triangulation_2<EucliTraits, TrianDs> Triangulation;
typedef Triangulation::Face_iterator Face_iterator;
typedef Triangulation::Face Face;
typedef Face::Face_handle Face_handle;
int main()
{
const int numPoints1 = 4;
static Point points1[numPoints1] = {
Point(1, 0.3),
Point(0.0, -0.9),
Point(-1, 0)
};
Point point2(0.0, 0.0);
Point point3(-1,1);
std::vector<Point> points4(3);
points4[0] = Point(1, 0.9);
points4[1] = Point(1.4, -0.3);
points4[2] = Point(0.6, 0);
Triangulation tr; // create an empty triangulation
tr.insert(points1, points1+numPoints1); // insert array of Point-s
tr.insert(point2); // insert interior Point
tr.insert(point3); // insert exterior Point
tr.insert(points4.begin(),points4.end()); // insert vector of Point-s
// std::cout << tr;
// short hand type definitions
Face_iterator it = tr.faces_begin(),
beyond = tr.faces_end();
Face face;
Face_handle neighbor;
while(it != beyond) {
face = *it; //get face
++it; //advance the iterator
int count = 0; //initialize counter
for (int i=0; i<3;++i) { //for index 0,1,2
neighbor = face.neighbor(i); //get neighbor
if (tr.is_infinite(neighbor)) { //test its infinity
++count;
}
}
std::cout << tr.triangle(face) << std::endl
<< "has " << count << " infinite neighbor(s)" <<std::endl;
}
}
编译给了我一个 tr.triangle(face) 的转换错误,但我不明白为什么。有人能帮我吗?