2013-11-21 53 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