5.8 KiB
Executable File
GENERATOR
| GENERATOR |
|---|
| Mozilla/4.05C-SGI [en] (X11; I; IRIX64 6.5 IP28) [Netscape] |
"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;
***/
- Initialization **/
MSTKLA_Init();
GMTKLA_Init();
***/
- Create a mesh object and fill in the data after reading from a file **/
mesh = MESH_Create();
MESH_InitFromFile(mesh, argv[1], argv[2], 1, &meshname);
***/
- Model info **/
ngr = GM_NumRegions();
fprintf(stderr,"Number of model regions: %d
n",ngr);
ngf = GM_NumFaces();
fprintf(stderr,"Number of model faces: %d
n",ngf);
***/
- Get all the regions in the model **/
GM_Regions(&ngr, &grlist);
***/
- Loop through the regions and print out info about the faces***
*** bounding this region***
*** **/
for (i = 0; i < ngr; i++) {
fprintf(stderr,"Region %-d
n:
n",(i+1));
***/
- Faces of the region **/
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);
*/
- Just get the all the faces of the model **/
*** /
- Delete the objects containing that info - the surfaces themselves***
*** don't get deleted***
*** **/
GM_Faces(&ngf, &gflist);
for (i = 0; i < ngf; i++)
GF_Delete(gflist[i]);
free(gflist);
***/
- Mesh Info **/
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));
***/
- Loop through each mesh vertex and print some info about it
**/
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;
***/
- Get the classification (model entity that mesh entity is on) of***
*** the mesh vertex***
*** **/
gent = MV_GMentity(mesh,vert);
***/
- Get the coordinates of the mesh vertex **/
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
- (order %1d) --- %lf %lf %lf
n",
MV_Number(mesh,vert),MV_GMtype(mesh,vert),
xyz[0],xyz[1],xyz[2]);
fprintf(stderr,"
n
n");
nr = MESH_NumRegions(mesh);
***/
- Loop through each mesh regions and print some info about it
**/
for (i = 0; i < nr; i++) {
reg = MESH_Region(mesh,i);
***/
- Region type - TET, PYRAMID, PRISM, HEX? **/
type = MR_Type(mesh,reg);
***/
- Vertices of region aka nodes of element **/
MR_Vertices(mesh, reg, &nrv, (PMeshVert *) rverts);
***/
- Classification of mesh region i.e. what model region it is in
**/
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");
***/
- Loop through the regions of the mesh and print the face neighbor info **/
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++) {
***/
- Find the other region sharing face 'j' of 'reg' **/
oreg = MR_FaceNebr(mesh,reg,j);
if (oreg) { ***/
- a region exists on the other side of face, print info **/
fprintf(stderr,"R%-d ",MR_Number(mesh,oreg));
fprintf(stderr,"
n");
"30"
"30"](mstkla.md#EXAMPLE)
"30"
"30"](utilities.md)
"30"
"30"](linking.md)