#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define APPROX_VOXEL_COUNT 10000000.f
int gProgress = -1;
bool onProgress( float v )
{
int progress = (int)( 10.f * v );
if ( progress != gProgress )
{
gProgress = progress;
printf( "%d%%...\n", progress * 10 );
}
return true;
}
int main(
int argc,
char* argv[] )
{
int rc = EXIT_FAILURE;
if ( argc != 3 && argc != 4 )
{
fprintf( stderr, "Usage: %s OFFSET_VALUE INPUT [OUTPUT]", argv[0] );
goto out;
}
float offsetValue = atof( argv[1] );
if ( !isfinite( offsetValue ) )
{
fprintf( stderr, "Incorrect offset value: %s", argv[1] );
goto out;
}
const char* input = argv[2];
const char* output = ( argc == 3 ) ? argv[2] : argv[3];
if ( errorString )
{
fprintf( stderr,
"Failed to load inputMesh: %s",
mrStringData( errorString ) );
goto out;
}
.region = NULL,
};
if ( errorString )
{
fprintf( stderr,
"Failed to perform offset: %s",
mrStringData( errorString ) );
goto out_inputMesh;
}
if ( errorString )
{
fprintf( stderr,
"Failed to save inputMesh: %s",
mrStringData( errorString ) );
goto out_outputMesh;
}
rc = EXIT_SUCCESS;
out_outputMesh:
out_inputMesh:
out:
return rc;
}
struct MRMesh MRMesh
Definition MRMeshC/MRMeshFwd.h:43
typedefMR_EXTERN_C_BEGIN struct MRString MRString
Definition MRMeshC/MRMeshFwd.h:32
MR_EXTERN_C_BEGIN struct MRMeshPart MRMeshPart
stores reference on whole mesh (if region is NULL) or on its part (if region pointer is valid)
MRMESHC_API void mrMeshFree(MRMesh *mesh)
deallocates a Mesh object
MRMESHC_API MROffsetParameters mrOffsetParametersNew(void)
initializes a default instance
MRMESHC_API float mrSuggestVoxelSize(MRMeshPart mp, float approxNumVoxels)
computes size of a cubical voxel to get approximately given number of voxels during rasterization
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)
MRMESHC_API MRMesh * mrOffsetMesh(MRMeshPart mp, float offset, const MROffsetParameters *params, MRString **errorString)
stores reference on whole mesh (if region is NULL) or on its part (if region pointer is valid)
Definition MRMeshC/MRMeshPart.h:9
const MRMesh * mesh
Definition MRMeshC/MRMeshPart.h:10
Definition MRMeshC/MROffset.h:12
float voxelSize
Definition MRMeshC/MROffset.h:15
MRProgressCallback callBack
Progress callback.
Definition MRMeshC/MROffset.h:17