mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-13 10:45:51 +00:00
Merge pull request #1595 from hannobraun/3mf
Update to latest version of 3mf-rs
This commit is contained in:
commit
c41f9cfe00
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -2745,6 +2745,16 @@ version = "1.0.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "74605f360ce573babfe43964cbe520294dcb081afbf8c108fc6e23036b4da2df"
|
checksum = "74605f360ce573babfe43964cbe520294dcb081afbf8c108fc6e23036b4da2df"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quick-xml"
|
||||||
|
version = "0.27.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ffc053f057dd768a56f62cd7e434c42c831d296968997e9ac1f76ea7c2d14c41"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.23"
|
version = "1.0.23"
|
||||||
@ -3454,10 +3464,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "threemf"
|
name = "threemf"
|
||||||
version = "0.3.1"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "03094907eeaa5743f1630c4fafdd9c68dbfb8d25c819786674298d46b4604ecc"
|
checksum = "bf108acc769867300099b3c5334f3dd9bf8c420522a7b7a5938ba0142643808e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"quick-xml",
|
||||||
|
"serde",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
|
@ -15,5 +15,5 @@ categories.workspace = true
|
|||||||
fj-interop.workspace = true
|
fj-interop.workspace = true
|
||||||
fj-math.workspace = true
|
fj-math.workspace = true
|
||||||
thiserror = "1.0.35"
|
thiserror = "1.0.35"
|
||||||
threemf = "0.3.1"
|
threemf = "0.4.0"
|
||||||
stl = "0.2.1"
|
stl = "0.2.1"
|
||||||
|
@ -43,26 +43,33 @@ pub fn export(mesh: &Mesh<Point<3>>, path: &Path) -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn export_3mf(mesh: &Mesh<Point<3>>, path: &Path) -> Result<(), Error> {
|
fn export_3mf(mesh: &Mesh<Point<3>>, path: &Path) -> Result<(), Error> {
|
||||||
let vertices = mesh.vertices().map(Into::into).collect();
|
let vertices = mesh
|
||||||
|
.vertices()
|
||||||
|
.map(|point| threemf::model::Vertex {
|
||||||
|
x: point.x.into_f64(),
|
||||||
|
y: point.y.into_f64(),
|
||||||
|
z: point.z.into_f64(),
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
let indices: Vec<_> = mesh.indices().collect();
|
let indices: Vec<_> = mesh.indices().collect();
|
||||||
let triangles = indices
|
let triangles = indices
|
||||||
.chunks(3)
|
.chunks(3)
|
||||||
.map(|triangle| {
|
.map(|triangle| threemf::model::Triangle {
|
||||||
[
|
v1: triangle[0] as usize,
|
||||||
triangle[0] as usize,
|
v2: triangle[1] as usize,
|
||||||
triangle[1] as usize,
|
v3: triangle[2] as usize,
|
||||||
triangle[2] as usize,
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mesh = threemf::TriangleMesh {
|
let mesh = threemf::Mesh {
|
||||||
vertices,
|
vertices: threemf::model::Vertices { vertex: vertices },
|
||||||
triangles,
|
triangles: threemf::model::Triangles {
|
||||||
|
triangle: triangles,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
threemf::write(path, &mesh)?;
|
threemf::write(path, mesh)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user