我是CGAL的新手。目前我正在开发一个需要使用Delaunay三角剖分的网格域的应用程序。在这个应用程序中,我需要跟踪节点(Vertex)和元素(Edge)。为此,我使用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我真的不明白发生了什么。你能解释一下吗?
发布于 2014-04-07 00:09:51
你的face类需要从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。
https://stackoverflow.com/questions/22892314
复制相似问题