}
InitMesh(pMesh, amount);
REAL x,y,z;
for ( int j=3; j<amount+3; ++j)
{
fscanf( fp, "%lg %lg %lg", &x, &y, &z);
((VERTEX2D_PTR)(pMesh->pVerArr+j))->x = x;
((VERTEX2D_PTR)(pMesh->pVerArr+j))->y = y;
}
fclose(fp);
}
// Algorithm IncrementalDelaunay(V)
// Input: 由 n 个点组成的二维点集 V
// Output: Delaunay 三角剖分 DT
// 1.add a appropriate triangle boudingbox to contain V ( such as: we can use triangle abc, a=(0,
3M), b=(-3M,-3M), c=(3M, 0), M=Max({|x1|,|x2|,|x3|,...} U {|y1|,|y2|,|y3|,...}))
// 2.initialize DT(a,b,c) as triangle abc
// 3.for i <- 1 to n
// do (Insert(DT(a,b,c,v1,v2,...,vi-1), vi))
// 4.remove the boundingbox and relative triangle which cotains any vertex of triangle abc from
DT(a,b,c,v1,v2,...,vn) and return DT(v1,v2,...,vn).
void IncrementalDelaunay(MESH_PTR pMesh)
{
// Add a appropriate triangle boudingbox to contain V
AddBoundingBox(pMesh);
// Get a vertex/point vi from V and Insert(vi)
for (int i=3; i<pMesh->vertex_num+3; i++)
{
Insert(pMesh, i);
}
// Remove the bounding box
RemoveBoundingBox(pMesh);
}
// The format of output file should be as follows:
// triangle index
// x1 y1 (the coordinate of first vertex of triangle)