From 79e5c346cffbbe18c8fc51c4e3a8e4026d853831 Mon Sep 17 00:00:00 2001
From: imrn99 <95699343+imrn99@users.noreply.github.com>
Date: Thu, 12 Dec 2024 13:48:58 +0100
Subject: [PATCH 1/3] update manifests

---
 examples/Cargo.toml          | 2 +-
 honeycomb-core/Cargo.toml    | 5 ++---
 honeycomb-kernels/Cargo.toml | 2 +-
 honeycomb/Cargo.toml         | 2 +-
 4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/examples/Cargo.toml b/examples/Cargo.toml
index 573dfb063..459b4cc5a 100644
--- a/examples/Cargo.toml
+++ b/examples/Cargo.toml
@@ -11,7 +11,7 @@ publish = false
 autoexamples = false
 
 [dev-dependencies]
-honeycomb-core = { workspace = true, features = ["io"] }
+honeycomb-core = { workspace = true }
 honeycomb-render = { workspace = true }
 honeycomb-kernels = { workspace = true }
 rand = { workspace = true, features = ["small_rng"] }
diff --git a/honeycomb-core/Cargo.toml b/honeycomb-core/Cargo.toml
index b06939f7f..55c6f0c94 100644
--- a/honeycomb-core/Cargo.toml
+++ b/honeycomb-core/Cargo.toml
@@ -12,8 +12,7 @@ keywords.workspace = true
 authors.workspace = true
 publish = true
 
-[features]
-io = ["dep:vtkio"]
+# [features]
 
 # deps
 
@@ -24,7 +23,7 @@ loom.workspace= true
 num-traits.workspace = true
 stm.workspace = true
 thiserror.workspace = true
-vtkio = { workspace = true, optional = true }
+vtkio.workspace = true
 
 [build-dependencies]
 rustversion.workspace = true
diff --git a/honeycomb-kernels/Cargo.toml b/honeycomb-kernels/Cargo.toml
index 2b7c9416c..658db82e6 100644
--- a/honeycomb-kernels/Cargo.toml
+++ b/honeycomb-kernels/Cargo.toml
@@ -13,7 +13,7 @@ authors.workspace = true
 publish = true
 
 [dependencies]
-honeycomb-core = { workspace = true, features = ["io"] }
+honeycomb-core.workspace = true
 num-traits.workspace = true
 rayon = "1.10.0"
 thiserror.workspace = true
diff --git a/honeycomb/Cargo.toml b/honeycomb/Cargo.toml
index a4655b30c..998b6c250 100644
--- a/honeycomb/Cargo.toml
+++ b/honeycomb/Cargo.toml
@@ -18,6 +18,6 @@ kernels = ["dep:honeycomb-kernels"]
 render = ["dep:honeycomb-render"]
 
 [dependencies]
-honeycomb-core = { workspace = true, features = ["io"] }
+honeycomb-core = { workspace = true }
 honeycomb-kernels = { workspace = true, optional = true }
 honeycomb-render = { workspace = true, optional = true }

From 502aae554d1562fc1f826979cd39b8629fb16310 Mon Sep 17 00:00:00 2001
From: imrn99 <95699343+imrn99@users.noreply.github.com>
Date: Thu, 12 Dec 2024 13:51:53 +0100
Subject: [PATCH 2/3] remove feature gates

---
 honeycomb-core/src/cmap/builder/io/tests.rs  | 2 +-
 honeycomb-core/src/cmap/builder/mod.rs       | 4 +---
 honeycomb-core/src/cmap/builder/structure.rs | 3 ---
 honeycomb-core/src/cmap/dim2/mod.rs          | 4 +---
 4 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/honeycomb-core/src/cmap/builder/io/tests.rs b/honeycomb-core/src/cmap/builder/io/tests.rs
index d4463a43c..ddad27d00 100644
--- a/honeycomb-core/src/cmap/builder/io/tests.rs
+++ b/honeycomb-core/src/cmap/builder/io/tests.rs
@@ -36,7 +36,7 @@ fn io_read() {
     assert_eq!(six_count, 1);
 }
 
-#[cfg(all(test, feature = "io"))]
+#[cfg(test)]
 const VTK_ASCII: &[u8] = b"
 # vtk DataFile Version 2.0
 cmap
diff --git a/honeycomb-core/src/cmap/builder/mod.rs b/honeycomb-core/src/cmap/builder/mod.rs
index dd4e59c57..53d350138 100644
--- a/honeycomb-core/src/cmap/builder/mod.rs
+++ b/honeycomb-core/src/cmap/builder/mod.rs
@@ -3,10 +3,8 @@
 // ------ MODULE DECLARATIONS
 
 pub mod grid;
-pub mod structure;
-
-#[cfg(feature = "io")]
 pub mod io;
+pub mod structure;
 
 // ------ RE-EXPORTS
 
diff --git a/honeycomb-core/src/cmap/builder/structure.rs b/honeycomb-core/src/cmap/builder/structure.rs
index a75fba371..1b5bda44f 100644
--- a/honeycomb-core/src/cmap/builder/structure.rs
+++ b/honeycomb-core/src/cmap/builder/structure.rs
@@ -4,7 +4,6 @@ use crate::prelude::{AttributeBind, CMap2, GridDescriptor};
 use crate::{attributes::AttrStorageManager, geometry::CoordsFloat};
 
 use thiserror::Error;
-#[cfg(feature = "io")]
 use vtkio::Vtk;
 
 // ------ CONTENT
@@ -53,7 +52,6 @@ pub struct CMapBuilder<T>
 where
     T: CoordsFloat,
 {
-    #[cfg(feature = "io")]
     pub(super) vtk_file: Option<Vtk>,
     pub(super) grid_descriptor: Option<GridDescriptor<T>>,
     pub(super) attributes: AttrStorageManager,
@@ -177,7 +175,6 @@ impl<T: CoordsFloat> CMapBuilder<T> {
     ///
     /// See [`CMapBuilder`] example.
     pub fn build(self) -> Result<CMap2<T>, BuilderError> {
-        #[cfg(feature = "io")]
         if let Some(vfile) = self.vtk_file {
             // build from vtk
             // this routine should return a Result instead of the map directly
diff --git a/honeycomb-core/src/cmap/dim2/mod.rs b/honeycomb-core/src/cmap/dim2/mod.rs
index 6d5c57a9e..7a59a878c 100644
--- a/honeycomb-core/src/cmap/dim2/mod.rs
+++ b/honeycomb-core/src/cmap/dim2/mod.rs
@@ -9,15 +9,13 @@
 
 pub mod basic_ops;
 pub mod embed;
+pub mod io;
 pub mod links;
 pub mod orbits;
 pub mod sews;
 pub mod structure;
 pub mod utils;
 
-#[cfg(feature = "io")]
-pub mod io;
-
 // ------ CONTENT
 
 /// Number of beta functions defined for [`CMap2`].

From c4567cc4c36ca587e0a17be100b179b110aa05fd Mon Sep 17 00:00:00 2001
From: imrn99 <95699343+imrn99@users.noreply.github.com>
Date: Thu, 12 Dec 2024 14:00:35 +0100
Subject: [PATCH 3/3] reorg io files

---
 .../src/cmap/builder/{io/mod.rs => io.rs}     | 28 ++----
 honeycomb-core/src/cmap/builder/io/tests.rs   | 93 ------------------
 honeycomb-core/src/cmap/builder/tests.rs      | 94 ++++++++++++++++++-
 honeycomb-core/src/cmap/dim2/mod.rs           |  2 +-
 .../src/cmap/dim2/{io.rs => serialize.rs}     | 17 +---
 5 files changed, 103 insertions(+), 131 deletions(-)
 rename honeycomb-core/src/cmap/builder/{io/mod.rs => io.rs} (95%)
 delete mode 100644 honeycomb-core/src/cmap/builder/io/tests.rs
 rename honeycomb-core/src/cmap/dim2/{io.rs => serialize.rs} (91%)

diff --git a/honeycomb-core/src/cmap/builder/io/mod.rs b/honeycomb-core/src/cmap/builder/io.rs
similarity index 95%
rename from honeycomb-core/src/cmap/builder/io/mod.rs
rename to honeycomb-core/src/cmap/builder/io.rs
index 1e19c31e2..5c4723180 100644
--- a/honeycomb-core/src/cmap/builder/io/mod.rs
+++ b/honeycomb-core/src/cmap/builder/io.rs
@@ -1,19 +1,13 @@
-//! Input/Output features implementation
-//!
-//! The support for I/O is currently very restricted since this is not the focus of this project.
-//! Maps can be built from and serialized to VTK legacy files (both binary and ASCII). The
-//! `DATASET` of the VTK file should be `UNSTRUCTURED_GRID`, and only a given set of `CELL_TYPES`
-//! are supported, because of orientation and dimension restriction.
-
-// ------ IMPORTS
 use crate::prelude::{BuilderError, CMap2, CMapBuilder, DartIdType, Vertex2, VertexIdType};
 use crate::{attributes::AttrStorageManager, geometry::CoordsFloat};
-use num_traits::Zero;
+
 use std::collections::BTreeMap;
+
+use num_traits::Zero;
 use vtkio::model::{CellType, DataSet, VertexNumbers};
 use vtkio::{IOBuffer, Vtk};
 
-// ------ CONTENT
+// --- descriptor impls
 
 impl<T: CoordsFloat> CMapBuilder<T> {
     /// Import and set the VTK file that will be used when building the map.
@@ -32,14 +26,6 @@ impl<T: CoordsFloat> CMapBuilder<T> {
 
 /// Create a [`CMapBuilder`] from an imported VTK file.
 ///
-/// This implementation is roughly equivalent to the following:
-///
-/// ```rust,no_run
-/// # use honeycomb_core::prelude::CMapBuilder;
-/// // `CMapBuilder::from_vtk_file("some/path/to/file.vtk")`, or:
-/// let builder = CMapBuilder::<f64>::default().vtk_file("some/path/to/file.vtk");
-/// ```
-///
 /// # Panics
 ///
 /// This function may panic if the file cannot be loaded.
@@ -54,6 +40,8 @@ impl<T: CoordsFloat, P: AsRef<std::path::Path> + std::fmt::Debug> From<P> for CM
     }
 }
 
+// --- building routine
+
 macro_rules! if_predicate_return_err {
     ($pr: expr, $er: expr) => {
         if $pr {
@@ -315,7 +303,3 @@ pub fn build_2d_from_vtk<T: CoordsFloat>(
     }
     Ok(cmap)
 }
-
-// ------ TESTS
-#[cfg(test)]
-mod tests;
diff --git a/honeycomb-core/src/cmap/builder/io/tests.rs b/honeycomb-core/src/cmap/builder/io/tests.rs
deleted file mode 100644
index ddad27d00..000000000
--- a/honeycomb-core/src/cmap/builder/io/tests.rs
+++ /dev/null
@@ -1,93 +0,0 @@
-// ------ IMPORTS
-
-use crate::attributes::AttrStorageManager;
-use crate::prelude::{CMap2, DartIdType, Orbit2, OrbitPolicy};
-use vtkio::Vtk;
-
-// ------ CONTENT
-
-#[test]
-fn io_read() {
-    let vtk = Vtk::parse_legacy_be(VTK_ASCII).unwrap();
-    // unwrap is fine since we know the VTK_ASCII const is correct
-    let cmap: CMap2<f32> = super::build_2d_from_vtk(vtk, AttrStorageManager::default()).unwrap();
-
-    // check result
-    let faces: Vec<_> = cmap.iter_faces().collect();
-    assert_eq!(faces.len(), 4);
-    assert_eq!(cmap.iter_edges().count(), 12);
-    assert_eq!(cmap.iter_vertices().count(), 9);
-
-    let mut n_vertices_per_face: Vec<usize> = faces
-        .iter()
-        .map(|id| Orbit2::new(&cmap, OrbitPolicy::Face, *id as DartIdType).count())
-        .collect();
-    let (mut three_count, mut four_count, mut six_count): (usize, usize, usize) = (0, 0, 0);
-    while let Some(n) = n_vertices_per_face.pop() {
-        match n {
-            3 => three_count += 1,
-            4 => four_count += 1,
-            6 => six_count += 1,
-            _ => panic!("cmap was built incorrectly"),
-        }
-    }
-    assert_eq!(three_count, 2);
-    assert_eq!(four_count, 1);
-    assert_eq!(six_count, 1);
-}
-
-#[cfg(test)]
-const VTK_ASCII: &[u8] = b"
-# vtk DataFile Version 2.0
-cmap
-ASCII
-
-DATASET UNSTRUCTURED_GRID
-POINTS 9 float
-0 0 0  1 0 0  1 1 0
-0 1 0  2 0 0  2 1 0
-2 2 0  1 3 0  0 2 0
-
-CELLS 17 54
-1 0
-1 4
-1 6
-1 7
-1 8
-2 0 1
-2 3 0
-2 1 4
-2 4 5
-2 5 6
-2 6 7
-2 7 8
-2 8 3
-4 0 1 2 3
-3 1 4 5
-3 1 5 2
-6 3 2 5 6 7 8
-
-CELL_TYPES 17
-1
-1
-1
-1
-1
-3
-3
-3
-3
-3
-3
-3
-3
-9
-5
-5
-7
-
-
-POINT_DATA 9
-
-CELL_DATA 17
-";
diff --git a/honeycomb-core/src/cmap/builder/tests.rs b/honeycomb-core/src/cmap/builder/tests.rs
index a80e213b8..52184e8b5 100644
--- a/honeycomb-core/src/cmap/builder/tests.rs
+++ b/honeycomb-core/src/cmap/builder/tests.rs
@@ -1,4 +1,7 @@
-use crate::prelude::{CMap2, CMapBuilder, GridDescriptor};
+use crate::attributes::AttrStorageManager;
+use crate::prelude::{CMap2, CMapBuilder, DartIdType, GridDescriptor, Orbit2, OrbitPolicy};
+
+use vtkio::Vtk;
 
 // --- basic
 
@@ -357,3 +360,92 @@ fn splitsquare_cmap2_correctness() {
     assert_eq!(cmap.beta::<2>(23), 0);
     assert_eq!(cmap.beta::<2>(24), 0);
 }
+
+// --- IO
+
+#[test]
+fn io_read() {
+    let vtk = Vtk::parse_legacy_be(VTK_ASCII).unwrap();
+    // unwrap is fine since we know the VTK_ASCII const is correct
+    let cmap: CMap2<f32> =
+        super::io::build_2d_from_vtk(vtk, AttrStorageManager::default()).unwrap();
+
+    // check result
+    let faces: Vec<_> = cmap.iter_faces().collect();
+    assert_eq!(faces.len(), 4);
+    assert_eq!(cmap.iter_edges().count(), 12);
+    assert_eq!(cmap.iter_vertices().count(), 9);
+
+    let mut n_vertices_per_face: Vec<usize> = faces
+        .iter()
+        .map(|id| Orbit2::new(&cmap, OrbitPolicy::Face, *id as DartIdType).count())
+        .collect();
+    let (mut three_count, mut four_count, mut six_count): (usize, usize, usize) = (0, 0, 0);
+    while let Some(n) = n_vertices_per_face.pop() {
+        match n {
+            3 => three_count += 1,
+            4 => four_count += 1,
+            6 => six_count += 1,
+            _ => panic!("cmap was built incorrectly"),
+        }
+    }
+    assert_eq!(three_count, 2);
+    assert_eq!(four_count, 1);
+    assert_eq!(six_count, 1);
+}
+
+#[cfg(test)]
+const VTK_ASCII: &[u8] = b"
+# vtk DataFile Version 2.0
+cmap
+ASCII
+
+DATASET UNSTRUCTURED_GRID
+POINTS 9 float
+0 0 0  1 0 0  1 1 0
+0 1 0  2 0 0  2 1 0
+2 2 0  1 3 0  0 2 0
+
+CELLS 17 54
+1 0
+1 4
+1 6
+1 7
+1 8
+2 0 1
+2 3 0
+2 1 4
+2 4 5
+2 5 6
+2 6 7
+2 7 8
+2 8 3
+4 0 1 2 3
+3 1 4 5
+3 1 5 2
+6 3 2 5 6 7 8
+
+CELL_TYPES 17
+1
+1
+1
+1
+1
+3
+3
+3
+3
+3
+3
+3
+3
+9
+5
+5
+7
+
+
+POINT_DATA 9
+
+CELL_DATA 17
+";
diff --git a/honeycomb-core/src/cmap/dim2/mod.rs b/honeycomb-core/src/cmap/dim2/mod.rs
index 7a59a878c..f51fd9450 100644
--- a/honeycomb-core/src/cmap/dim2/mod.rs
+++ b/honeycomb-core/src/cmap/dim2/mod.rs
@@ -9,9 +9,9 @@
 
 pub mod basic_ops;
 pub mod embed;
-pub mod io;
 pub mod links;
 pub mod orbits;
+pub mod serialize;
 pub mod sews;
 pub mod structure;
 pub mod utils;
diff --git a/honeycomb-core/src/cmap/dim2/io.rs b/honeycomb-core/src/cmap/dim2/serialize.rs
similarity index 91%
rename from honeycomb-core/src/cmap/dim2/io.rs
rename to honeycomb-core/src/cmap/dim2/serialize.rs
index fb2418366..c22c3d372 100644
--- a/honeycomb-core/src/cmap/dim2/io.rs
+++ b/honeycomb-core/src/cmap/dim2/serialize.rs
@@ -1,12 +1,3 @@
-//! Input/Output features implementation
-//!
-//! The support for I/O is currently very restricted since this is not the focus of this project.
-//! Maps can be built from and serialized to VTK legacy files (both binary and ASCII). The
-//! `DATASET` of the VTK file should be `UNSTRUCTURED_GRID`, and only a given set of `CELL_TYPES`
-//! are supported, because of orientation and dimension restriction.
-
-// ------ IMPORTS
-
 use crate::cmap::{EdgeIdType, FaceIdType};
 use crate::geometry::CoordsFloat;
 use crate::prelude::{CMap2, DartIdType, Orbit2, OrbitPolicy, VertexIdType, NULL_DART_ID};
@@ -20,9 +11,9 @@ use vtkio::{
     IOBuffer,
 };
 
-// ------ CONTENT
+// --- VTK
 
-/// **Serializing methods**
+/// **Serialization methods**
 impl<T: CoordsFloat + 'static> CMap2<T> {
     /// Generate a legacy VTK file from the map.
     ///
@@ -77,9 +68,7 @@ impl<T: CoordsFloat + 'static> CMap2<T> {
     }
 }
 
-// --- internals
-
-/// Internal building routine for [`CMap2::to_vtk_file`].
+/// Internal building routine for VTK serialization.
 fn build_unstructured_piece<T>(map: &CMap2<T>) -> UnstructuredGridPiece
 where
     T: CoordsFloat + 'static,