【问题标题】:Has anyone already used the Triangle/Triangle++ library in a C++ project ? (delaunay triangulation)有没有人在 C++ 项目中使用过 Triangle/Triangle++ 库? (德劳内三角剖分)
【发布时间】:2013-11-21 22:24:05
【问题描述】:
【问题讨论】:
标签:
c++
visual-c++
triangulation
delaunay
【解决方案1】:
使用 numberoftriangles、trianglelist、pointlist。对于每个三角形,您在 trianglelist 中有 3 个数字,它们是三角形 3 个角的 pointlist 内的索引。它们不会直接给你顶点,但你可以很容易地从那里得到它们。
如果还不清楚,请告诉我。
for (int i = 0; i < numberoftriangles; ++i) {
int point1Index = trianglelist[i * 3 + 0];
int point2Index = trianglelist[i * 3 + 1];
int point3Index = trianglelist[i * 3 + 2];
REAL point1X = pointlist[2 * point1Index + 0];
REAL point1Y = pointlist[2 * point1Index + 1];
... etc
}
/* `trianglelist': An array of triangle corners. The first triangle's */
/* first corner is at index [0], followed by its other two corners in */
/* counterclockwise order, followed by any other nodes if the triangle */
/* represents a nonlinear element. Each triangle occupies */
/* `numberofcorners' ints. */
/* `pointlist': An array of point coordinates. The first point's x */
/* coordinate is at index [0] and its y coordinate at index [1], followed */
/* by the coordinates of the remaining points. Each point occupies two */
/* REALs.
【解决方案2】:
这不是很清楚,但是fiterator意味着面迭代器,而面是三角形。
Org、Dest 和 Apex 是这些顶点的索引。
for(Delaunay::fIterator fit = delobject.fbegin();
fit != delobject.fend();
++fit)
{
cout << " Org " << delobject.Org(fit) << ", "
<< " Dest " << delobject.Dest(fit) << ", "
<< " Apex " << delobject.Apex(fit) << //" \t: Area = "
}
别忘了,Triangle++ 并不需要你输入实际的 Triangle.c 代码,所以它真的很容易使用。