0

我正在使用 SFML,我想对一组随机点进行 delaunay 三角剖分。

http://www.cs.cmu.edu/~quake/triangle.html

我正在使用 triangle++,一个 c++ 包装器

http://www.compgeom.com/~piyush/scripts/triangle/

我添加了那些#defines

#define REDUCED  
#define ANSI_DECLARATORS  
#define TRILIBRARY  
#define CDT_ONLY  
#define NO_TIMER  
#define CYGWIN  

这个编译,它运行良好,但现在它计算了这些东西,我如何得到顶点之间的边缘?

4

2 回答 2

0

使用 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.  
于 2013-11-22T01:08:08.677 回答
0

这不是很清楚,但 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 代码,因此它非常易于使用。

于 2013-11-22T14:56:15.753 回答