@@ -420,6 +420,16 @@ pub fn reconstruct_subcommand(cmd_args: &ReconstructSubcommandArgs) -> Result<()
420420 result
421421}
422422
423+ /// Struct to hold the result of the reconstruction pipeline
424+ pub struct PipelineResult < I : Index , R : Real > {
425+ /// Holds the reconstructed tri mesh with data if `generate_quads` was not set
426+ pub tri_mesh : Option < MeshWithData < R , TriMesh3d < R > > > ,
427+ /// Holds the reconstructed quad mesh with data if `generate_quads` was set
428+ pub tri_quad_mesh : Option < MeshWithData < R , MixedTriQuadMesh3d < R > > > ,
429+ /// Holds the surface reconstruction with no post-processing applied if `output_raw_mesh` was set
430+ pub raw_reconstruction : Option < SurfaceReconstruction < I , R > > ,
431+ }
432+
423433/// Conversion and validation of command line arguments
424434pub mod arguments {
425435 use super :: ReconstructSubcommandArgs ;
@@ -944,17 +954,9 @@ pub fn reconstruction_pipeline<I: Index, R: Real>(
944954 attributes : Vec < MeshAttribute < R > > ,
945955 params : & splashsurf_lib:: Parameters < R > ,
946956 postprocessing : & ReconstructionRunnerPostprocessingArgs ,
947- ) -> Result <
948- (
949- Option < MeshWithData < R , TriMesh3d < R > > > ,
950- Option < MeshWithData < R , MixedTriQuadMesh3d < R > > > ,
951- Option < SurfaceReconstruction < I , R > > ,
952- ) ,
953- anyhow:: Error ,
954- > {
957+ ) -> Result < PipelineResult < I , R > , anyhow:: Error > {
955958 // Perform the surface reconstruction
956- let reconstruction =
957- splashsurf_lib:: reconstruct_surface :: < I , R > ( particle_positions, params) ?;
959+ let reconstruction = splashsurf_lib:: reconstruct_surface :: < I , R > ( particle_positions, params) ?;
958960
959961 let reconstruction_output = if postprocessing. output_raw_mesh {
960962 Some ( reconstruction. clone ( ) )
@@ -1323,7 +1325,11 @@ pub fn reconstruction_pipeline<I: Index, R: Real>(
13231325 ) ,
13241326 ( None , Some ( _mesh) ) => {
13251327 info ! ( "Checking for mesh consistency not implemented for quad mesh at the moment." ) ;
1326- return Ok ( ( None , Some ( _mesh. to_owned ( ) ) , reconstruction_output) ) ;
1328+ return Ok ( PipelineResult {
1329+ tri_mesh : None ,
1330+ tri_quad_mesh : Some ( _mesh. to_owned ( ) ) ,
1331+ raw_reconstruction : reconstruction_output,
1332+ } ) ;
13271333 }
13281334 _ => unreachable ! ( ) ,
13291335 } {
@@ -1413,9 +1419,17 @@ pub fn reconstruction_pipeline<I: Index, R: Real>(
14131419 res. point_attributes = std:: mem:: take ( & mut mesh. point_attributes ) ;
14141420 res. cell_attributes = std:: mem:: take ( & mut mesh. cell_attributes ) ;
14151421
1416- Ok ( ( Some ( res) , None , reconstruction_output) )
1422+ Ok ( PipelineResult {
1423+ tri_mesh : Some ( res) ,
1424+ tri_quad_mesh : None ,
1425+ raw_reconstruction : reconstruction_output,
1426+ } )
14171427 }
1418- ( None , Some ( _mesh) ) => Ok ( ( None , Some ( _mesh. to_owned ( ) ) , reconstruction_output) ) ,
1428+ ( None , Some ( _mesh) ) => Ok ( PipelineResult {
1429+ tri_mesh : None ,
1430+ tri_quad_mesh : Some ( _mesh. to_owned ( ) ) ,
1431+ raw_reconstruction : reconstruction_output,
1432+ } ) ,
14191433 _ => unreachable ! ( ) ,
14201434 }
14211435}
@@ -1442,12 +1456,11 @@ pub(crate) fn reconstruction_pipeline_from_path<I: Index, R: Real>(
14421456 )
14431457 } ) ?;
14441458
1445- let ( tri_mesh, tri_quad_mesh, reconstruction) = reconstruction_pipeline :: < I , R > (
1446- & particle_positions,
1447- attributes,
1448- params,
1449- postprocessing,
1450- ) ?;
1459+ let PipelineResult {
1460+ tri_mesh,
1461+ tri_quad_mesh,
1462+ raw_reconstruction : reconstruction,
1463+ } = reconstruction_pipeline :: < I , R > ( & particle_positions, attributes, params, postprocessing) ?;
14511464
14521465 if postprocessing. output_raw_mesh {
14531466 profile ! ( "write surface mesh to file" ) ;
0 commit comments