This commit is contained in:
Hanno Braun 2024-10-30 01:30:36 +01:00
parent c2eb84c84b
commit 0c46ec8d3b
2 changed files with 8 additions and 7 deletions

View File

@ -1,15 +1,16 @@
use std::fs::File; use std::fs::File;
pub fn export( use crate::mesh::Mesh;
vertices: impl IntoIterator<Item = [f64; 3]>,
triangles: impl IntoIterator<Item = [usize; 3]>, pub fn export(mesh: Mesh) -> anyhow::Result<()> {
) -> anyhow::Result<()> { let vertices = mesh
let vertices = vertices .vertices
.into_iter() .into_iter()
.map(|[x, y, z]| threemf::model::Vertex { x, y, z }) .map(|[x, y, z]| threemf::model::Vertex { x, y, z })
.collect(); .collect();
let triangles = triangles let triangles = mesh
.triangles
.into_iter() .into_iter()
.map(|[v1, v2, v3]| threemf::model::Triangle { v1, v2, v3 }) .map(|[v1, v2, v3]| threemf::model::Triangle { v1, v2, v3 })
.collect(); .collect();

View File

@ -4,6 +4,6 @@ mod model;
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {
let mesh = model::model()?; let mesh = model::model()?;
export::export(mesh.vertices, mesh.triangles)?; export::export(mesh)?;
Ok(()) Ok(())
} }