solidCreateMesh(PolygonElmDescr,PolygonFilePos);
Private void solidCreateMesh(MSElementDescr *edP,ULong filePos)
{
MSElementDescr *remainingEdPP = NULL;
MSElementDescr *ppMeshED = NULL;
KIBODY *pBody = NULL;
KIENTITY_LIST *bodyListPP = NULL;
KIENTITY_LIST *templateListPP = NULL;
KIENTITY_LIST *transformListPP = NULL;
Transform *pTran = NULL;
Dpoint3d *vertices = NULL;
long *facets = NULL;
long numFacets = 0;
long numVertices = 0;
int status = 0, i = 0;
int nItems = 0, c = 0;
mdlKISolid_beginCurrTrans (mdlModelRef_getActive());
status = mdlKISolid_elementToBodyList (&bodyListPP, &templateListPP,&transformListPP ,&remainingEdPP,edP,MASTERFILE, filePos, TRUE, TRUE, TRUE);
mdlKISolid_endCurrTrans ();
if (status == SUCCESS && bodyListPP != NULL)
{
for (i = 0L;
SUCCESS == mdlKISolid_listNthEl (&pBody, bodyListPP, i) &&
SUCCESS == mdlKISolid_listNthEl (&pTran, transformListPP, i);
i++)
{
status = mdlKISolid_facetBody(&vertices, &numVertices, &facets,&numFacets, pBody, pTran, 3,1, .5, 0.0 );
if (numVertices == 0 || vertices == NULL)
continue;
mdlKISolid_beginCurrTrans (mdlModelRef_getActive());
mdlCurrTrans_transformPointArray (vertices, vertices, numVertices);
mdlKISolid_endCurrTrans ();
for ( i = 0; i + 2 < numFacets * 3; i += 3)
{
facets[i] = abs (facets[i]);
}
mdlMesh_newPolyfaceDirect (&ppMeshED, NULL, facets, 3,numFacets, vertices, numVertices, TRUE);
mdlElmdscr_add (ppMeshED);
mdlElmdscr_display (ppMeshED, 0, NORMALDRAW);
}
}
if (ppMeshED)
mdlElmdscr_freeAll (&ppMeshED);
if (pBody)
mdlKISolid_freeBody( pBody );
if (bodyListPP)
{
mdlKISolid_listCount(&nItems, bodyListPP);
for(c = 0; c < nItems; c++)
{
KIENTITY *entP = NULL;
mdlKISolid_listNthEl(&entP, bodyListPP, c);
mdlKISolid_deleteEntity(entP);
}
mdlKISolid_listDelete(&bodyListPP);
}
}
By using this function i got a output mesh element as shown in the image fig1.
fig2 is the polygon drawn programmatically by the user.