#include <MRCMesh/MRBitSet.h>
#include <MRCMesh/MRMesh.h>
#include <MRCMesh/MRMeshExtrude.h>
#include <MRCMesh/MRMeshLoad.h>
#include <MRCMesh/MRMeshSave.h>
#include <MRCMesh/MRRegionBoundary.h>
#include <MRCMesh/MRVector.h>
#include <MRCMisc/expected_MR_Mesh_std_string.h>
#include <MRCMisc/expected_void_std_string.h>
#include <MRCMisc/std_string.h>
#include <stdio.h>
#include <stdlib.h>
{
int rc = EXIT_FAILURE;
MR_expected_MR_Mesh_std_string* meshEx = MR_MeshLoad_fromAnySupportedFormat( "mesh.stl", NULL, NULL );
MR_Mesh*
mesh = MR_expected_MR_Mesh_std_string_value_mut( meshEx );
{
fprintf( stderr, "Failed to load mesh: %s\n", MR_std_string_data( MR_expected_MR_Mesh_std_string_error( meshEx ) ) );
MR_expected_MR_Mesh_std_string_Destroy( meshEx );
return 1;
}
MR_FaceBitSet* facesToExtrude = MR_FaceBitSet_DefaultConstruct();
MR_FaceBitSet_autoResizeSet( facesToExtrude, (MR_FaceId){1}, NULL );
MR_FaceBitSet_autoResizeSet( facesToExtrude, (MR_FaceId){2}, NULL );
MR_makeDegenerateBandAroundRegion(
mesh, facesToExtrude, NULL );
MR_VertBitSet* vertsToMove = MR_getIncidentVerts( MR_Mesh_Get_topology(
mesh ), facesToExtrude );
MR_Vector3f*
points = MR_VertCoords_data_mut( MR_Mesh_GetMutable_points(
mesh ) );
MR_Vector3f
shift = MR_Vector3f_plusZ();
size_t numPoints = MR_VertCoords_size( MR_Mesh_GetMutable_points(
mesh ) );
for ( size_t i = 0; i < numPoints; ++i )
if ( MR_VertBitSet_test( vertsToMove, (MR_VertId){ (int)i } ) )
MR_Mesh_invalidateCaches(
mesh, NULL );
MR_expected_void_std_string* saveEx = MR_MeshSave_toAnySupportedFormat(
mesh,
"extrudedMesh.stl", NULL, NULL);
if ( MR_expected_void_std_string_error( saveEx ) )
fprintf( stderr, "Failed to save mesh: %s\n", MR_std_string_data( MR_expected_void_std_string_error( saveEx ) ) );
else
rc = EXIT_SUCCESS;
MR_expected_void_std_string_Destroy( saveEx );
MR_VertBitSet_Destroy( vertsToMove );
MR_FaceBitSet_Destroy( facesToExtrude );
MR_expected_MR_Mesh_std_string_Destroy( meshEx );
return rc;
}
VertCoords & points() const