-
C/C++->General->Additional include
directories
D:Program
filesCGAL-4.11auxiliarygmpinclude
D:Program filesboost_1_65_1
D:Program filesCGAL-4.11Buildinclude
D:Program filesCGAL-4.11include
C/C++->Preprocessor->Preprocesser
definitions
WIN32
_DEBUG
_CONSOLE
_LIB
_CRT_SECURE_NO_WARNINGS
Linker -> General -> Additional library
directories
D:Program
filesboost_1_65_1lib32-msvc-12.0
D:Program filesCGAL-4.11auxiliarygmplib
D:Program filesCGAL-4.11Buildlib
Linker -> Input ->
Additional Dependences
在
stdafx.h
文件中添加
#define
_SCL_SECURE_NO_WARNINGS
示例程序:
// straight_ : Defines the entry point
for the console application.
//
#include
#include
#include
#include
#includ
e
#include
#inc
lude
#include
#include
#include
using
namespace
std
;
typedef
CGAL
::
Exact_predicates_inexact_constr
uctions_kernel
K
;
typedef
K
< br>::
Point_2
Point
;
typedef
CGAL
::
Polygon_2
<
K
>
Polygon_2
;
typedef
CGAL
::
Polygon_with_holes_2
<
K
>
Po
lygon_with_holes
;
typedef
CGAL
::
Straight_skeleton_2
<
K
>
Ss
;
//typedef
CGAL::Delaunay_triangulation_2
typedef
CGAL
::
Delaunay_tr
iangulation_2
<
K
><
/p>
Delaunay
;
typedef
boost
::
shared_ptr
<
< br>Ss
>
SsPtr
;
int
global_w
,
global_h
;
std
::
vector
<<
/p>
Point
>
vertices
,
mypts
;
void
points_draw
()
{
}
void
points_add_p
oint
(
int
x
,
int
y
)
{
}
vertices
.
push_back
(
Po
int
(
x
,
global_h
-
y
));
glPopMatrix
();
p>
glutSwapBuffers
();
std
::
vector
<
Point
>::
p>
iterator
iter
;
glColor3f
(
1.0
,
1.0
,
1.0
);
glPointSize
(
8
);
p>
glBegin
(
GL_POINTS
);
for
(
iter
=
vertices
.
begin
();
iter
!=
vertices
.
end
();
iter
++)
glVertex2i
(
iter
->
hx
(),
iter
->
hy
());
glEnd
();
glPushMatrix
();
<
/p>
glClear
(
GL_COLOR_B
UFFER_BIT
);
glPushMatrix
();
void
init
(
void
)
{
}
void
points_clear
()
{
}
void
points_trian
gulation
()
{
glEnable
(
GL_LINE_STIPPLE
);
//
使用点画模式,即使用虚线来绘制
Voronoi
图
glLineStipple
(
p>
1
,
0x3333
);
< br>glColor3f
(
0.0
,
1.0
,
0.0
);
Delaunay
::
Edge_iterator
eit
;
//
遍历
Delaunay
的所有边,绘制
Delaunay
图的对偶图,即
Vorono
i
图
//
开始绘制
glPushMatrix
();
<
/p>
Delaunay
::
Finite_f
aces_iterator
fit
;
//
遍历
Delaunay
的所有面(有限面),将每个面的边画出来
glColor3f
(
0.0
,
0.0
,
1.0
);
for
(
fit
=
dt
.<
/p>
finite_faces_begin
();
< br>
fit
!=
dt
.
finite_faces_end
();
fit
++)
{
glB
egin
(
GL_LINE_LOOP
);
glVertex2i
(
fit
->
vertex
(
0
)->
point
().
hx
(),
p>
fit
->
vertex
< br>(
0
)->
point
().
hy
());
glVertex2i
(
fit
->
vertex
(
1
)->
point
().
hx
(),
fit
p>
->
vertex
(
1
)->
point
().
hy
());
glV
ertex2i
(
fit
->
vertex
(
2
)-
>
point
().
hx
(),
fit
->
vertex
(
2
)
->
point
().
hy
());
glEnd
();
< br>//Delaunay
数据结构,代表当前数据的一个且仅有一个的三角剖分,详
情请参考
Delaunay
dt
;
//
将所有点加入
dt
dt
.<
/p>
insert
(
vertices
.
begin
(),
vertices
.
end
());
//
输入数据
CGAL_manual
vertices
.
clear
();
glClear
(
GL_COLOR_BUF
FER_BIT
);
glPushMatrix
();
glPopMatrix
();
p>
glutSwapBuffers
();
glClearColor
(
0.0<
/p>
,
0.0
,
0.0
,
0.0
);
glShadeModel
(
GL_FLAT
< br>);
}
//
< br>完成
Delaunay
三角剖分的绘制,
Delaunay
图