【问题标题】:CGAL Constrained_Delaunay_Triangulation and Triangulation_vertex_base_with_infoCGAL Constrained_Delaunay_Triangulation 和 Triangulation_vertex_base_with_info
【发布时间】:2014-04-06 09:44:06
【问题描述】:

我是 CGAL 的新手。目前,我正在开发一个需要将域与 Delaunay 三角剖分网格化的应用程序。 在这个应用程序中,我需要跟踪节点(顶点)和元素(边缘)。为此,我使用 Triangulation_vertex_base_with_info 为每个顶点提供唯一索引,并使用这些顶点索引跟踪边缘。 我使用了手动示例中的代码:

 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
 #include <CGAL/Delaunay_triangulation_2.h>
 #include <CGAL/Triangulation_vertex_base_with_info_2.h>
 #include <vector>
 typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
 typedef CGAL::Triangulation_vertex_base_with_info_2<unsigned, K> Vb;
 typedef CGAL::Triangulation_data_structure_2<Vb> Tds;
 typedef CGAL::Delaunay_triangulation_2<K, Tds> Delaunay;
 typedef Delaunay::Point Point;
 int main()
 {
    std::vector< std::pair<Point,unsigned> > points;
    points.push_back( std::make_pair(Point(0,0),0) );
    points.push_back( std::make_pair(Point(1,0),1) );
    points.push_back( std::make_pair(Point(0,1),2) );
    points.push_back( std::make_pair(Point(14,4),3) );
    points.push_back( std::make_pair(Point(2,2),4) );
    points.push_back( std::make_pair(Point(-4,0),5) );
    Delaunay T;
    T.insert( points.begin(),points.end() );
    CGAL_assertion( T.number_of_vertices() == 6 );
    // check that the info was correctly set.
    Delaunay::Finite_vertices_iterator vit;
    for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit)
    if( points[ vit->info() ].first != vit->point() ){
    std::cerr << "Error different info" << std::endl;
    exit(EXIT_FAILURE);
    }
    std::cout << "OK" << std::endl;
    return 0;
 }

我尝试使用 Delaunay_triangulation_2 的 Constrained_Delaunay_triangulation_2。这是代码:

 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
 #include <CGAL/Constrained_Delaunay_triangulation_2.h>
 #include <CGAL/Triangulation_vertex_base_with_info_2.h>
 #include <vector>
 typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
 typedef CGAL::Triangulation_vertex_base_with_info_2<unsigned, K> Vb;
 typedef CGAL::Triangulation_data_structure_2<Vb> Tds;
 typedef CGAL::Constrained_Delaunay_triangulation_2<K, Tds> Delaunay;
 typedef Delaunay::Point Point;
 int main()
 {
    std::vector< std::pair<Point,unsigned> > points;
    points.push_back( std::make_pair(Point(0,0),0) );
    points.push_back( std::make_pair(Point(1,0),1) );
    points.push_back( std::make_pair(Point(0,1),2) );
    points.push_back( std::make_pair(Point(14,4),3) );
    points.push_back( std::make_pair(Point(2,2),4) );
    points.push_back( std::make_pair(Point(-4,0),5) );
    Delaunay T;
    T.insert( points.begin(),points.end() );
    CGAL_assertion( T.number_of_vertices() == 6 );
    // check that the info was correctly set.
    Delaunay::Finite_vertices_iterator vit;
    for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit)
    {
          std::cout << "Index : " << vit->info() << " x : " << vit->point().x() << " y : " << vit->point().y() << std::endl;
    }
    std::cout << "OK" << std::endl;
    return 0;
 }

当我编译这段代码时,我得到一个奇怪的错误:p(我没有发布所有错误,因为达到了块限制):

C:/QtSDK-i686/bin/mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'C:/Users/houssam/Documents/build-learn_cgal-Desktop-Release'
g++ -c -march=i686 -mtune=core2 -pipe -fno-keep-inline-dllexport -O2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -I..\learn_cgal -I"." -I"c:\QtSDK-i686\mkspecs\win32-g++" -o release\main.o ..\learn_cgal\main.cpp
In file included from c:/QtSDK-i686/include/CGAL/Constrained_Delaunay_triangulation_2.h:25:0,
                 from ..\learn_cgal\main.cpp:2:
c:/QtSDK-i686/include/CGAL/Constrained_triangulation_2.h: In instantiation of 'CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Vertex_handle CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::insert(const Point&, CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Locate_type, CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Face_handle, int) [with Gt = CGAL::Epick; Tds = CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> >; Itag = CGAL::No_intersection_tag; CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Vertex_handle = CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick, CGAL::Triangulation_vertex_base_2<CGAL::Epick, CGAL::Triangulation_ds_vertex_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> > > > >, CGAL::Default>, false>; CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Point = CGAL::Point_2<CGAL::Epick>; CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Locate_type = CGAL::Triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> > >::Locate_type; CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Face_handle = CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> > >, CGAL::Default>, false>]':
c:/QtSDK-i686/include/CGAL/Constrained_triangulation_2.h:396:55:   required from 'CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Vertex_handle CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::insert(const Point&, CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Face_handle) [with Gt = CGAL::Epick; Tds = CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> >; Itag = CGAL::No_intersection_tag; CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Vertex_handle = CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick, CGAL::Triangulation_vertex_base_2<CGAL::Epick, CGAL::Triangulation_ds_vertex_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> > > > >, CGAL::Default>, false>; CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Point = CGAL::Point_2<CGAL::Epick>; CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Face_handle = CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> > >, CGAL::Default>, false>]'
c:/QtSDK-i686/include/CGAL/Constrained_Delaunay_triangulation_2.h:879:41:   required from 'CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Vertex_handle CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::insert(const Point&, CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Face_handle) [with Gt = CGAL::Epick; Tds = CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> >; Itag = CGAL::No_intersection_tag; CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Vertex_handle = CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick, CGAL::Triangulation_vertex_base_2<CGAL::Epick, CGAL::Triangulation_ds_vertex_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> > > > >, CGAL::Default>, false>; CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Point = CGAL::Point_2<CGAL::Epick>; CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Face_handle = CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> > >, CGAL::Default>, false>]'
c:/QtSDK-i686/include/CGAL/Constrained_Delaunay_triangulation_2.h:294:40:   required from 'std::ptrdiff_t CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::insert_with_info(InputIterator, InputIterator) [with Tuple_or_pair = std::pair<CGAL::Point_2<CGAL::Epick>, unsigned int>; InputIterator = __gnu_cxx::__normal_iterator<std::pair<CGAL::Point_2<CGAL::Epick>, unsigned int>*, std::vector<std::pair<CGAL::Point_2<CGAL::Epick>, unsigned int> > >; Gt = CGAL::Epick; Tds = CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> >; Itag = CGAL::No_intersection_tag; std::ptrdiff_t = int]'
c:/QtSDK-i686/include/CGAL/Constrained_Delaunay_triangulation_2.h:318:28:   required from 'std::ptrdiff_t CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::insert(InputIterator, InputIterator, typename boost::enable_if<boost::is_convertible<typename CGAL::internal::Get_iterator_value_type<InputIterator>::type, std::pair<typename CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Geom_traits::Point_2, typename CGAL::internal::Info_check<typename Tds::Vertex>::type> > >::type*) [with InputIterator = __gnu_cxx::__normal_iterator<std::pair<CGAL::Point_2<CGAL::Epick>, unsigned int>*, std::vector<std::pair<CGAL::Point_2<CGAL::Epick>, unsigned int> > >; Gt = CGAL::Epick; Tds = CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> >; Itag = CGAL::No_intersection_tag; std::ptrdiff_t = int; typename boost::enable_if<boost::is_convertible<typename CGAL::internal::Get_iterator_value_type<InputIterator>::type, std::pair<typename CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Geom_traits::Point_2, typename CGAL::internal::Info_check<typename Tds::Vertex>::type> > >::type = void]'
..\learn_cgal\main.cpp:20:43:   required from here
c:/QtSDK-i686/include/CGAL/Constrained_triangulation_2.h:411:34: error: 'class CGAL::Triangulation_ds_face_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> > >' has no member named 'is_constrained'
   if ( lt == Triangulation::EDGE && loc->is_constrained(li) ){
                                  ^
In file included from ..\learn_cgal\main.cpp:2:0:
c:/QtSDK-i686/include/CGAL/Constrained_Delaunay_triangulation_2.h: In instantiation of 'bool CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::is_flipable(CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Face_handle, int, bool) const [with Gt = CGAL::Epick; Tds = CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> >; Itag = CGAL::No_intersection_tag; CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Face_handle = CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> > >, CGAL::Default>, false>]':
c:/QtSDK-i686/include/CGAL/Constrained_Delaunay_triangulation_2.h:765:23:   required from 'void CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::propagating_flip(CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Face_handle, int, int) [with Gt = CGAL::Epick; Tds = CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> >; Itag = CGAL::No_intersection_tag; CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Face_handle = CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> > >, CGAL::Default>, false>]'
c:/QtSDK-i686/include/CGAL/Constrained_Delaunay_triangulation_2.h:718:25:   required from 'void CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::flip_around(CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Vertex_handle) [with Gt = CGAL::Epick; Tds = CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> >; Itag = CGAL::No_intersection_tag; CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Vertex_handle = CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick, CGAL::Triangulation_vertex_base_2<CGAL::Epick, CGAL::Triangulation_ds_vertex_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> > > > >, CGAL::Default>, false>]'
c:/QtSDK-i686/include/CGAL/Constrained_Delaunay_triangulation_2.h:880:17:   required from 'CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Vertex_handle CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::insert(const Point&, CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Face_handle) [with Gt = CGAL::Epick; Tds = CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> >; Itag = CGAL::No_intersection_tag; CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Vertex_handle = CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick, CGAL::Triangulation_vertex_base_2<CGAL::Epick, CGAL::Triangulation_ds_vertex_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> > > > >, CGAL::Default>, false>; CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Point = CGAL::Point_2<CGAL::Epick>; CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::Face_handle = CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> > >, CGAL::Default>, false>]'
c:/QtSDK-i686/include/CGAL/Constrained_Delaunay_triangulation_2.h:294:40:   required from 'std::ptrdiff_t CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::insert_with_info(InputIterator, InputIterator) [with Tuple_or_pair = std::pair<CGAL::Point_2<CGAL::Epick>, unsigned int>; InputIterator = __gnu_cxx::__normal_iterator<std::pair<CGAL::Point_2<CGAL::Epick>, unsigned int>*, std::vector<std::pair<CGAL::Point_2<CGAL::Epick>, unsigned int> > >; Gt = CGAL::Epick; Tds = CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> >; Itag = CGAL::No_intersection_tag; std::ptrdiff_t = int]'
c:/QtSDK-i686/include/CGAL/Constrained_Delaunay_triangulation_2.h:318:28:   required from 'std::ptrdiff_t CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, Itag>::insert(InputIterator, InputIterator, typename boost::enable_if<boost::is_convertible<typename CGAL::internal::Get_iterator_value_type<InputIterator>::type, std::pair<typename CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Geom_traits::Point_2, typename CGAL::internal::Info_check<typename Tds::Vertex>::type> > >::type*) [with InputIterator = __gnu_cxx::__normal_iterator<std::pair<CGAL::Point_2<CGAL::Epick>, unsigned int>*, std::vector<std::pair<CGAL::Point_2<CGAL::Epick>, unsigned int> > >; Gt = CGAL::Epick; Tds = CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<unsigned int, CGAL::Epick> >; Itag = CGAL::No_intersection_tag; std::ptrdiff_t = int; typename boost::enable_if<boost::is_convertible<typename CGAL::internal::Get_iterator_value_type<InputIterator>::type, std::pair<typename CGAL::Constrained_triangulation_2<Gt, Tds, Itag>::Geom_traits::Point_2, typename CGAL::internal::Info_check<typename Tds::Vertex>::type> > >::type = void]'
..\learn_cgal\main.cpp:20:43:   required from here

我真的不明白发生了什么。你能解释一下吗?

【问题讨论】:

    标签: c++ cgal


    【解决方案1】:

    你的人脸类需要继承自Contrained_triangulation_face_base_2,这样:

    #include <CGAL/Triangulation_face_base_with_info_2.h>
    
    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;
    

    请参阅文档中的示例 Example: Triangulating a Polygonal Domain

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多