From 0472b528a5d2a2871dc9a917fc1420ca3f7b47b7 Mon Sep 17 00:00:00 2001 From: maxwelljhuang Date: Wed, 6 May 2026 14:52:29 -0700 Subject: [PATCH] chore: finish converting load_nft.rs to arlog_*! macros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Completes the conversion of crates/core/examples/load_nft.rs from a half-converted state (22 remaining println! calls alongside 1 existing arlog_i!) to uniform arlog_*! usage. CLAUDE.md §2 names load_nft.rs as the canonical example for newcomers, so getting this consistent matters beyond the mechanical cleanup. All 22 sites classified as arlog_i!, including four inside bounded enumeration loops (pyramid scales, pages, image lists). The loops are one-shot enumerations of loaded NFT data with N ~1-10, not per-frame detection paths -- matching the PR 1 precedent in debug_labeling.rs where a take(10) enumeration loop also uses arlog_i!. Trailing \n stripped from four format strings per the established convention (the log backend handles line structure). Imports and Cargo.toml unchanged -- the existing use webarkitlib_rs::arlog_i; and the existing [[example]] block already cover this PR. Part 2 of 4 for #90. --- crates/core/examples/load_nft.rs | 59 ++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/crates/core/examples/load_nft.rs b/crates/core/examples/load_nft.rs index b63e985..163ac71 100644 --- a/crates/core/examples/load_nft.rs +++ b/crates/core/examples/load_nft.rs @@ -72,14 +72,14 @@ fn main() { let marker_name = "pinball"; arlog_i!("Loading NFT marker: '{}'", marker_name); - println!("========================================\n"); + arlog_i!("========================================"); // --------------------------------------------------------------- // Step 1: Load KPM data (.fset3) // C++: kpmLoadRefDataSet(datasetPathname, "fset3", &refDataSet) // --------------------------------------------------------------- let fset3_path = data_dir.join(format!("{}.fset3", marker_name)); - println!("Reading {}.fset3 ...", marker_name); + arlog_i!("Reading {}.fset3 ...", marker_name); let ref_data = KpmRefDataSet::load(&fset3_path).expect("failed to load .fset3"); @@ -89,31 +89,35 @@ fn main() { // kpmMergeRefDataSet(&refDataSet, &refDataSet2) // Here we just load a single marker (page 0). let page_no = 0; - println!(" Assigned page no. {}", page_no); - println!( + arlog_i!(" Assigned page no. {}", page_no); + arlog_i!( " KPM features: {}, pages: {}", - ref_data.num, ref_data.page_num + ref_data.num, + ref_data.page_num ); for page in &ref_data.page_info { - println!( + arlog_i!( " Page {}: {} images in pyramid", - page.page_no, page.image_num + page.page_no, + page.image_num ); for img in &page.image_info { - println!( + arlog_i!( " image_no={}, {}x{}", - img.image_no, img.width, img.height + img.image_no, + img.width, + img.height ); } } - println!(" Done.\n"); + arlog_i!(" Done."); // --------------------------------------------------------------- // Step 2: Load AR2 image set (.iset) // C++: loaded internally by ar2ReadSurfaceSet → imageSet // --------------------------------------------------------------- let iset_path = data_dir.join(format!("{}.iset", marker_name)); - println!("Reading {}.iset ...", marker_name); + arlog_i!("Reading {}.iset ...", marker_name); let image_set = AR2ImageSetT::load(&iset_path).expect("failed to load .iset"); @@ -126,14 +130,14 @@ fn main() { let height_nft = base.ysize; let dpi_nft = base.dpi; - println!(" NFT num. of ImageSet: {}", image_set.num()); - println!(" NFT marker width : {}", width_nft); - println!(" NFT marker height : {}", height_nft); - println!(" NFT marker dpi : {:.0}", dpi_nft); + arlog_i!(" NFT num. of ImageSet: {}", image_set.num()); + arlog_i!(" NFT marker width : {}", width_nft); + arlog_i!(" NFT marker height : {}", height_nft); + arlog_i!(" NFT marker dpi : {:.0}", dpi_nft); // Print all scales. for (i, scale) in image_set.scale.iter().enumerate() { - println!( + arlog_i!( " scale[{}]: {}x{} @ {:.1} DPI ({} bytes)", i, scale.xsize, @@ -142,25 +146,25 @@ fn main() { scale.img_bw.len() ); } - println!(" Done.\n"); + arlog_i!(" Done."); // --------------------------------------------------------------- // Step 3: Load AR2 feature set (.fset) // C++: loaded internally by ar2ReadSurfaceSet → featureSet // --------------------------------------------------------------- let fset_path = data_dir.join(format!("{}.fset", marker_name)); - println!("Reading {}.fset ...", marker_name); + arlog_i!("Reading {}.fset ...", marker_name); let feature_set = AR2FeatureSetT::load(&fset_path).expect("failed to load .fset"); let total_features: usize = feature_set.list.iter().map(|fp| fp.num()).sum(); - println!( + arlog_i!( " AR2 feature scales: {}, total features: {}", feature_set.num(), total_features ); for (i, fp) in feature_set.list.iter().enumerate() { - println!( + arlog_i!( " scale[{}]: {} features, DPI range {:.1}\u{2013}{:.1}", i, fp.num(), @@ -168,18 +172,21 @@ fn main() { fp.maxdpi ); } - println!(" Done.\n"); + arlog_i!(" Done."); // --------------------------------------------------------------- // Summary // --------------------------------------------------------------- - println!("========================================"); - println!("Loading of NFT data complete."); - println!( + arlog_i!("========================================"); + arlog_i!("Loading of NFT data complete."); + arlog_i!( " Marker '{}': {}x{} @ {:.0} DPI", - marker_name, width_nft, height_nft, dpi_nft + marker_name, + width_nft, + height_nft, + dpi_nft ); - println!( + arlog_i!( " {} KPM features, {} AR2 features across {} scales", ref_data.num, total_features,