1

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) の変換エラーが発生しますが、その理由がわかりません。誰かが私を助けることができますか?

4

1 に答える 1

3

三角形関数は、Face_handle引数として を想定しています。また、typedef を少し単純化します。

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Triangulation_2.h>
#include <vector>

typedef CGAL::Exact_predicates_inexact_constructions_kernel  Kernel;
typedef CGAL::Point_2<Kernel>                                Point;
typedef CGAL::Triangulation_2<Kernel>                        Triangulation;
typedef Triangulation::Face_iterator                         Face_iterator;
typedef Triangulation::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

  // short hand type definitions
  Face_iterator it = tr.faces_begin(),       
  beyond = tr.faces_end();                   
  Face_handle 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;

  }
}
于 2013-07-23T20:28:43.400 に答える