“30” “30”](mstkla.md#EXAMPLE) “30” “30”](utilities.md) “30” “30”](linking.md)

/ *

==========================================================================

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

  Example program with MSTKLA

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

==========================================================================

*

#include <stdio.h>

#include <stdlib.h>

#include “mstkla.h”

#include “gmtkla.h”

int main(int argc, char *argv[]) {

  char *meshname;

  PMeshObj mesh;

  PMeshVert vert, rverts[8];

  PMeshRegn reg, oreg;

  ElType type;

  int nv, nf, nr, nrv, i, j, *rfside, nrf, ngr, ngf;

  double xyz[3];

  PGeomEntity gent;

  PGeomFace *rflist, *gflist;

  PGeomRegn *grlist;

 

  ***/

 

  MSTKLA_Init();

  GMTKLA_Init();

 

  ***/

  mesh = MESH_Create();

  MESH_InitFromFile(mesh, argv[1], argv[2], 1, &meshname);

 

  ***/

 

  ngr = GM_NumRegions();

  fprintf(stderr,”Number of model regions: %d

n”,ngr);

 

  ngf = GM_NumFaces();

  fprintf(stderr,”Number of model faces: %d

n”,ngf);

 

  ***/

  GM_Regions(&ngr, &grlist);

 

  ***/

     bounding this region

**     **/*

 

  for (i = 0; i < ngr; i++) {

    fprintf(stderr,”Region %-d

n:

n”,(i+1));

 

    ***/

 

    GR_Faces(grlist[i],&nrf,&rflist,&rfside);

 

    fprintf(stderr,”  %d Faces

n”,nrf);

    for (j = 0; j < nrf; j++) {

      fprintf(stderr,”Face %-d  Dir %-d Type %-d

n”,

       GF_Number(rflist[j]),rfside[j],GF_Type(rflist[j]));

   

 

  for (i = 0; i < ngr; i++)

    GR_Delete(grlist[i]);

  free(grlist);

  */

***  /

     don’t get deleted

**     **/*

  GM_Faces(&ngf, &gflist);

  for (i = 0; i < ngf; i++)

    GF_Delete(gflist[i]);

  free(gflist);

 

  ***/

  fprintf(stderr,”Number of nodes in mesh:

t%d

n”,MESH_NumVertices(mesh));

  fprintf(stderr,”Number of elements in mesh:

t%d

n”,MESH_NumRegions(mesh));

  ***/

**/

  nv = MESH_NumVertices(mesh);

  for (i = 0; i < nv; i++) {

    vert = MESH_Vertex(mesh,i);

    if (MV_Type(mesh,vert) == VDELETED MV_Type(mesh,vert) == VIGNORE)

      continue;

    ***/

       the mesh vertex

**       **/*

    gent = MV_GMentity(mesh,vert);

    ***/

    MV_Coords(mesh, vert, xyz);

    if (gent)

      fprintf(stderr,”V%-d [ G%-d (order %1d) —  %lf %lf %lf

n”,

       MV_Number(mesh,vert),GEnt_Number(gent), MV_GMtype(mesh,vert),

       xyz[0],xyz[1],xyz[2]);

    else

      fprintf(stderr,”V%-d [ G

n”,

       MV_Number(mesh,vert),MV_GMtype(mesh,vert),

       xyz[0],xyz[1],xyz[2]);

 

  fprintf(stderr,”

n

n”);

  nr = MESH_NumRegions(mesh);

  ***/

**/

  for (i = 0; i < nr; i++) {

    reg = MESH_Region(mesh,i);

    ***/

    type = MR_Type(mesh,reg);

 

    ***/

    MR_Vertices(mesh, reg, &nrv, (PMeshVert *) rverts);

 

    ***/

**/

    gent = MR_GMentity(mesh,reg);

    if (GEnt_Type(gent) != GREGION)

      fprintf(stderr,”Mesh Region not classified on model region???

n”);

 

    fprintf(stderr,”R%-d [ G%-d — “, MR_Number(mesh,reg), GEnt_Number(gent));

    for (j = 0; j < nrv; j++)

      fprintf(stderr,”%d  “, MV_Number(mesh,rverts[j]));

    fprintf(stderr,”

n”);

 

 

  ***/

  for (i = 0; i < nr; i++) {

    reg = MESH_Region(mesh,i);

    fprintf(stderr,”Region %-d neighbors: “, MR_Number(mesh,reg));

    type = MR_Type(mesh,reg);

    nf = RType_NumFaces(type);

    for (j = 0; j < nf; j++) {

      ***/

      oreg = MR_FaceNebr(mesh,reg,j);

      if (oreg) { ***/

         fprintf(stderr,”R%-d “,MR_Number(mesh,oreg));

     

   

    fprintf(stderr,”

n”);

 

 

 

 

 “30” “30”](mstkla.md#EXAMPLE) “30” “30”](utilities.md) “30” “30”](linking.md)