Simple Example (C specification)

Hello Mesh

#include
#include "iMesh.h"


int main( int argc, char *argv[] )
{
/* create the Mesh instance */
char *options = NULL;
iMesh_Instance mesh;
int ierr, options_len = 0;
iMesh_newMesh(options, &mesh, &ierr,
options_len);


/* load the mesh */
iMesh_load(mesh, argv[1], options, &ierr,
strlen(argv[1]), options_len);


/* report the number of elements of each dimension */
for (int dim = iBase_VERTEX; dim <= iBase_REGION; dim++) {
int numd;
iMesh_getNumOfType(mesh, 0, dim, &numd, &ierr);
std::cout << "Number of " << dim << "d elements = "
<< numd << std::endl;
}
return true;}


The Makefile

Implementations will have a file called iMesh-Defs.inc in their lib directories which can be included in a makefile and which provides the following variables:
  • IMESH_LIBS: everything you need to link to this iMesh implementation, including both -L and -l args to the linker. This should specifically include any backend or auxiliary libraries.
  • IMESH_INCLUDES: path for iMesh include files (including any trailing /iMesh, if needed.
  • IMESH_DEPS: key files that, if changed, should cause the app to re-link. This may be more of an implementation developer convenience than anything else.
For example:

include ../../iMesh-Defs.inc

HELLOiMesh: HELLOiMesh.o ${IMESH_DEPS}
$(CXX) $(CXXFLAGS) -o $@ HELLOiMesh.o ${IMESH_LIBS}

.cpp.o:
${CXX} -c ${CXXFLAGS} ${IMESH_INCLUDES} $<