三角网格剖分工具 Triangle 安装及使用

本文介绍了Triangle的相关内容,包括资源获取,可从指定网址下载源码;安装方面,triangle目录有两个主体程序,在CentOS下编译showme需先安装X11相关库;还说明了Triangle剖分网格的方法,编写控制文件后用程序剖分,可用showme查看结果。

0 Triangle资源

  下载Triangle源码,见http://www.cs.cmu.edu/~quake/triangle.html

1 Triangle安装

  triangle目录下共有两个主体程序:triangle网格剖分程序,showme可视化程序。可以直接进入triangle目录,make编译。但因为其中showme只能在X Windows下使用,所以在CentOS下编译make只会将triangle编译好,而编译showme时会报错。

  在其README中有提示可以分别编译Triangle和showme,其中triangle编译命令如下:

    cc -O -o triangle triangle.c -lm

  对于showme来说,首先要安装X11相关的库。

  具体安装步骤如下:

  1.       执行yum install libX11-devel,安装相关软件
  2.       执行cc -O -o showme showme.c -lX11对showme进行编译

  最后生成的可执行文件可以对Triangle生成的网格进行可视化。

2 Triangle剖分网格

  首先根据自己的设计形状,编写XX.poly(我称之为控制文件,估计不太准去)。

文件名  xx.poly,编写格式如下:

# Points(点信息)
15 2 0 1   

(15个点  二维坐标  第三项??  是否有标记(1-有,0-没有))
# outer extend boundary
0   -5000 0 0
1   -5000 -5000 0
2   5000  -5000 0
3   5000  0 0
# research boundary
4   -200  0 0
5   -200  -200 0
6   200  -200  0
7   200  0  0
# tunnel boundary
8   -200  -94  0
9   -200  -106 0
10  0  -106  0
11  0  -94   0

# add source point marker is 99
12   0    -95    99
13   0    -100    99
14   0    -105    99

# Segments with boundary markers.(线)
12 1(12条线   标记(1-有,0-没有))
# outer extend boundary
0    0    1    1
1    1    2    2
2    2    3    3
3    0    3    4
# research boundary
4       4       5    5
5    5    6    5
6    6    7    5
7    7    4    5
# tunnel boundary
8    8    9    5
9    9    10    5
10    10    11    5
11    11    8    5

# hole(空洞)
1(1个空洞)
0 -100 -100(0号空洞,二维坐标(x y))

# regions(区域)
2(2个区域)
0    -2000    -2000     -1    5000  (0号区域  x  y  标记为-1  最大面积5000)    
1    100    -150    1    1               (1号区域  x  y  标记为1    最大面积1)

 

编辑好控制文件即可利用Triangle程序进行剖分

./triangle -pq30zaneA xx.poly

可用showme程序查看网格剖分情况

./showme xx.*

Triangle生成的三角网格需要用showme可视化,但是该软件只能在X Windows下使用,所以在CentOS下编译showme,首先需要安装X11相关的库,

执行yum install libX11-devel
安装完成后执行cc -O -o showme showme.c -lX11

对showme进行编译,生成相应的执行文件,可以对Triangle生成的任意文件进行显示。

 

/*****************************************************************************/ /* */ /* 888888888 ,o, / 888 */ /* 888 88o88o " o8888o 88o8888o o88888o 888 o88888o */ /* 888 888 888 88b 888 888 888 888 888 d888 88b */ /* 888 888 888 o88^o888 888 888 "88888" 888 8888oo888 */ /* 888 888 888 C888 888 888 888 / 888 q888 */ /* 888 888 888 "88o^888 888 888 Cb 888 "88oooo" */ /* "8oo8D */ /* */ /* A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator. */ /* (triangle.c) */ /* */ /* Version 1.6 */ /* July 28, 2005 */ /* */ /* Copyright 1993, 1995, 1997, 1998, 2002, 2005 */ /* Jonathan Richard Shewchuk */ /* 2360 Woolsey #H */ /* Berkeley, California 94705-1927 */ /* jrs@cs.berkeley.edu */ /* */ /* This program may be freely redistributed under the condition that the */ /* copyright notices (including this entire header and the copyright */ /* notice printed when the `-h' switch is selected) are not removed, and */ /* no compensation is received. Private, research, and institutional */ /* use is free. You may distribute modified versions of this code UNDER */ /* THE CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE TO IT IN THE */ /* SAME FILE REMAIN UNDER COPYRIGHT OF THE ORIGINAL AUTHOR, BOTH SOURCE */ /* AND OBJECT CODE ARE MADE FREELY AVAILABLE WITHOUT CHARGE, AND CLEAR */ /* NOTICE IS GIVEN OF THE MODIFICATIONS. Distribution of this code as */ /* part of a commercial system is permissible ONLY BY DIRECT ARRANGEMENT */ /* WITH THE AUTHOR. (If you are not directly supplying this code to a */ /* customer, and you are instead telling them how they can obtain it for */ /* free, then you are not required to make any arrangement with me.)
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值