#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main( int argc, char* argv[] )
{
int rc = EXIT_FAILURE;
if ( argc != 3 )
{
fprintf( stderr, "Usage: %s INPUTFILE OUTPUTFILE", argv[0] );
goto out;
}
const char* inputFile = argv[1];
const char* outputFile = argv[2];
if ( errorString )
{
fprintf( stderr,
"Failed to load mesh: %s",
mrStringData( errorString ) );
goto out;
}
if ( verticesNum > 0 )
printf( "The first vertex coordinates: %f; %f; %f", vertices[0].x, vertices[0].y, vertices[0].z );
float* vertexData = malloc( sizeof( float ) * 3 * verticesNum );
memcpy( vertexData, vertices,
sizeof(
MRVector3f ) * verticesNum );
size_t facesNum = t->size;
if ( facesNum > 0 )
printf( "The first face's vertex ids: %d, %d, %d", faces[0][0].id, faces[0][1].id, faces[0][2].id );
int* faceData = malloc( sizeof( int ) * 3 * facesNum );
if ( errorString )
{
fprintf( stderr,
"Failed to save mesh: %s",
mrStringData( errorString ) );
goto out_mesh2;
}
rc = EXIT_SUCCESS;
out_mesh2:
out_faceData:
free( faceData );
out_t:
mrTriangulationFree( t );
out_vertexData:
free( vertexData );
out_mesh1:
out:
return rc;
}
MRVertId MRThreeVertIds[3]
a set of 3 vertices; useful for representing a face via its vertex indices
Definition MRMeshC/MRId.h:21
struct MRMesh MRMesh
Definition MRMeshC/MRMeshFwd.h:43
typedefMR_EXTERN_C_BEGIN struct MRString MRString
Definition MRMeshC/MRMeshFwd.h:32
MRMESHC_API const MRVector3f * mrMeshPoints(const MRMesh *mesh)
gets read-only access to the mesh vertex coordinates
MRMESHC_API MRTriangulation * mrMeshGetTriangulation(const MRMesh *mesh)
MRMESHC_API size_t mrMeshPointsNum(const MRMesh *mesh)
gets count of the mesh vertex coordinates
MRMESHC_API MRMesh * mrMeshFromTriangles(const MRVector3f *vertexCoordinates, size_t vertexCoordinatesNum, const MRThreeVertIds *t, size_t tNum)
constructs a mesh from vertex coordinates and a set of triangles with given ids
MRMESHC_API void mrMeshFree(MRMesh *mesh)
deallocates a Mesh object
MRMESHC_API void mrStringFree(MRString *str)
deallocates the string object
MR_EXTERN_C_BEGIN MRMESHC_API const char * mrStringData(const MRString *str)
gets read-only access to the string data
MRMESHC_API MRMesh * mrMeshLoadFromAnySupportedFormat(const char *file, MRString **errorStr)
MRMESHC_API void mrMeshSaveToAnySupportedFormat(const MRMesh *mesh, const char *file, MRString **errorStr)
three-dimensional vector
Definition MRMeshC/MRVector3.h:9