2013-11-21 48 views
0

我正在使用SFML,我想对随机设置的点进行delaunay三角测量。有没有人在C++项目中使用Triangle/Triangle ++库? (delaunay三角测量)

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

我用三角++,C++的包装

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

我说那些#defines

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

这将编译,它运行的罚款,但现在,它计算那些东西,我怎么得到顶点之间的边缘?

回答

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.c代码,所以这是很容易使用。

0

使用numberoftriangles,trianglelist,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. 
+0

我忘了提及我正在使用C++包装三角形++ – jokoon