[分享][原创]V8i下用代码实现Mesh from Points的功能

[转载Bentley中文知识库原贴] MicroStation迷:MicroStation V8XM/V8i下有个很"酷"的功能:根据一大堆点生成一个Mesh曲面。该功能对应的API函数在V8i SDK中才公布。如下为使用代码样例:
Private void createMeshFromPoints (void)
{
if (!mdlSelect_isActive ())
{
mdlDialog_openAlert ("您需要先用选择集选中一大堆点!");
return;
}
MSElement el;
ElementRef elRef;
DgnModelRefP modelRef;
int numPnts = mdlSelect_numSelected();
DPoint3d *pts = reinterpret_cast(_alloca(numPnts*sizeof(DPoint3d)));
DPoint3d ends[100];
for (int i=0; i {
mdlSelect_getElement (i, &elRef, &modelRef);
elementRef_getElement (elRef, &el, elementRef_getElemSize(elRef));
mdlLinear_extract (ends, NULL, &el, modelRef);
pts[i] = ends[0];
}
MSElementDescrP pEd = NULL;
if (ERROR == mdlMesh_newPolyfaceFromXYTriangulation (&pEd, pts, numPnts))
{
mdlDialog_openAlert ("构造Mesh曲面时出错!");
return;
}
mdlElmdscr_add (pEd);
mdlElmdscr_freeAll (&pEd);
}
生成的图形如下: