@@ -41,6 +41,12 @@ pub struct ReconstructSubcommandArgs {
4141 /// Optional base directory for all output files (default: current working directory)
4242 #[ arg( help_heading = ARGS_IO , long, value_parser = value_parser!( PathBuf ) ) ]
4343 pub output_dir : Option < PathBuf > ,
44+ /// Index of the first input file to process when processing a sequence of files (default: lowest index of the sequence)
45+ #[ arg( help_heading = ARGS_IO , long) ]
46+ pub start_index : Option < usize > ,
47+ /// Index of the last input file to process when processing a sequence of files (default: highest index of the sequence)
48+ #[ arg( help_heading = ARGS_IO , long) ]
49+ pub end_index : Option < usize > ,
4450
4551 /// The particle radius of the input data
4652 #[ arg( help_heading = ARGS_BASIC , long) ]
@@ -271,6 +277,7 @@ mod arguments {
271277 use std:: convert:: TryFrom ;
272278 use std:: fs;
273279 use std:: path:: { Path , PathBuf } ;
280+ use std:: str:: FromStr ;
274281 use walkdir:: WalkDir ;
275282
276283 /// All arguments that can be supplied to the surface reconstruction tool converted to useful types
@@ -386,6 +393,7 @@ mod arguments {
386393 output_density_map_points_file : Option < PathBuf > ,
387394 output_density_map_grid_file : Option < PathBuf > ,
388395 output_octree_file : Option < PathBuf > ,
396+ sequence_range : ( Option < usize > , Option < usize > ) ,
389397 /// Whether to enable normal computation for all files
390398 compute_normals : bool ,
391399 /// Whether to use SPH interpolation to compute the normals for all files
@@ -403,6 +411,7 @@ mod arguments {
403411 output_density_map_points_file : Option < P > ,
404412 output_density_map_grid_file : Option < P > ,
405413 output_octree_file : Option < P > ,
414+ sequence_range : ( Option < usize > , Option < usize > ) ,
406415 compute_normals : bool ,
407416 sph_normals : bool ,
408417 attributes : Vec < String > ,
@@ -414,6 +423,12 @@ mod arguments {
414423 let output_density_map_grid_file = output_density_map_grid_file. map ( |p| p. into ( ) ) ;
415424 let output_octree_file = output_octree_file. map ( |p| p. into ( ) ) ;
416425
426+ if let ( Some ( start) , Some ( end) ) = sequence_range {
427+ if start > end {
428+ return Err ( anyhow ! ( "Invalid input sequence range: \" {} to {}\" " , start, end) ) ;
429+ }
430+ }
431+
417432 if let Some ( output_base_path) = output_base_path {
418433 let output_file = output_base_path. join ( output_file) ;
419434
@@ -439,6 +454,7 @@ mod arguments {
439454 output_density_map_grid_file : output_density_map_grid_file
440455 . map ( |f| output_base_path. join ( f) ) ,
441456 output_octree_file : output_octree_file. map ( |f| output_base_path. join ( f) ) ,
457+ sequence_range,
442458 compute_normals,
443459 sph_normals,
444460 attributes,
@@ -451,6 +467,7 @@ mod arguments {
451467 output_density_map_points_file,
452468 output_density_map_grid_file,
453469 output_octree_file,
470+ sequence_range,
454471 compute_normals,
455472 sph_normals,
456473 attributes,
@@ -511,6 +528,19 @@ mod arguments {
511528 let index = & input_re
512529 . captures ( & entry_name)
513530 . expect ( "there should be a match" ) [ 1 ] ;
531+ let index_usize = usize:: from_str ( index) . expect ( "index should be convertible to usize" ) ;
532+
533+ if let Some ( start) = self . sequence_range . 0 {
534+ if index_usize < start {
535+ continue ;
536+ }
537+ }
538+
539+ if let Some ( end) = self . sequence_range . 1 {
540+ if index_usize > end {
541+ continue ;
542+ }
543+ }
514544
515545 let input_filename_i = entry_name. as_ref ( ) ;
516546 let input_file_i = input_dir. join ( input_filename_i) ;
@@ -533,9 +563,11 @@ mod arguments {
533563 }
534564
535565 info ! (
536- "Found {} input files matching the pattern \" {}\" " ,
566+ "Found {} input files matching the pattern \" {}\" between in range {} to {} " ,
537567 paths. len( ) ,
538- input_re_str
568+ input_re_str,
569+ self . sequence_range. 0 . map( |i| i. to_string( ) ) . unwrap_or_else( || "*" . to_string( ) ) ,
570+ self . sequence_range. 1 . map( |i| i. to_string( ) ) . unwrap_or_else( || "*" . to_string( ) ) ,
539571 ) ;
540572 paths
541573 } else {
@@ -582,6 +614,7 @@ mod arguments {
582614 args. output_dm_points . clone ( ) ,
583615 args. output_dm_grid . clone ( ) ,
584616 args. output_octree . clone ( ) ,
617+ ( args. start_index , args. end_index ) ,
585618 args. normals . into_bool ( ) ,
586619 args. sph_normals . into_bool ( ) ,
587620 args. interpolate_attributes . clone ( ) ,
@@ -641,6 +674,7 @@ mod arguments {
641674 args. output_dm_points . clone ( ) ,
642675 args. output_dm_grid . clone ( ) ,
643676 args. output_octree . clone ( ) ,
677+ ( args. start_index , args. end_index ) ,
644678 args. normals . into_bool ( ) ,
645679 args. sph_normals . into_bool ( ) ,
646680 args. interpolate_attributes . clone ( ) ,
0 commit comments