Skip to content

Commit 601b7ea

Browse files
committed
Format and fix path in tutorial example
1 parent c1c2026 commit 601b7ea

File tree

4 files changed

+27
-19
lines changed

4 files changed

+27
-19
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ the structures that store these attributes. For more details see the
211211
Using the `io` module we can load and store meshes. To save our triangle mesh to a file, we can
212212
simply call `save_trimesh` specifying a path:
213213
```rust
214-
meshx::io::save_trimesh(&mesh, "../tests/artifacts/tutorial_trimesh.vtk").unwrap();
214+
meshx::io::save_trimesh(&mesh, "tests/artifacts/tutorial_trimesh.vtk").unwrap();
215215
```
216216

217217
This can then be loaded from another application like ParaView. Here is our mesh with the
@@ -222,7 +222,7 @@ Screenshot](https://raw.githubusercontent.com/elrnv/meshx/master/assets/tutorial
222222
We can also load this file back using `load_trimesh`.
223223

224224
```rust
225-
let loaded_mesh = meshx::io::load_trimesh("../tests/artifacts/tutorial_trimesh.vtk").unwrap();
225+
let loaded_mesh = meshx::io::load_trimesh("tests/artifacts/tutorial_trimesh.vtk").unwrap();
226226
```
227227

228228
See the [`io`](https://docs.rs/meshx/latest/meshx/io/index.html) module for supported formats.

examples/tutorial.rs

+24-12
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ fn main() {
66

77
// Four corners of a [0,0]x[1,1] square in the xy-plane.
88
let vertices = vec![
9-
[0.0f64, 0.0, 0.0],
10-
[1.0, 0.0, 0.0],
11-
[0.0, 1.0, 0.0],
12-
[1.0, 1.0, 0.0],
9+
[0.0f64, 0.0, 0.0],
10+
[1.0, 0.0, 0.0],
11+
[0.0, 1.0, 0.0],
12+
[1.0, 1.0, 0.0],
1313
];
1414

1515
// Two triangles making up a square.
@@ -23,7 +23,7 @@ fn main() {
2323
/*
2424
* Simple count queries
2525
*/
26-
26+
2727
println!("number of vertices: {}", mesh.num_vertices());
2828
println!("number of faces: {}", mesh.num_faces());
2929
println!("number of face-edges: {}", mesh.num_face_edges());
@@ -37,14 +37,26 @@ fn main() {
3737
println!("face 1: {:?}", mesh.face(1));
3838

3939
// Face-edge topology:
40-
println!("face-edge index of edge 2 on face 1: {:?}", mesh.face_edge(1, 2));
40+
println!(
41+
"face-edge index of edge 2 on face 1: {:?}",
42+
mesh.face_edge(1, 2)
43+
);
4144
println!("edge index of face-edge 5: {:?}", mesh.edge(5));
42-
println!("edge index of edge 2 on face 1: {:?}", mesh.face_to_edge(1, 2));
43-
45+
println!(
46+
"edge index of edge 2 on face 1: {:?}",
47+
mesh.face_to_edge(1, 2)
48+
);
49+
4450
// Face-vertex topology:
45-
println!("face-vertex index of vertex 1 on face 0: {:?}", mesh.face_vertex(0, 1));
51+
println!(
52+
"face-vertex index of vertex 1 on face 0: {:?}",
53+
mesh.face_vertex(0, 1)
54+
);
4655
println!("vertex index of face-vertex 1: {:?}", mesh.vertex(1));
47-
println!("vertex index of vertex 1 on face 0: {:?}", mesh.face_vertex(0, 1));
56+
println!(
57+
"vertex index of vertex 1 on face 0: {:?}",
58+
mesh.face_vertex(0, 1)
59+
);
4860

4961
/*
5062
* Attributes
@@ -68,10 +80,10 @@ fn main() {
6880
* IO: loading and saving meshes
6981
*/
7082

71-
meshx::io::save_trimesh(&mesh, "../tests/artifacts/tutorial_trimesh.vtk")
83+
meshx::io::save_trimesh(&mesh, "tests/artifacts/tutorial_trimesh.vtk")
7284
.expect("Failed to save the tutorial triangle mesh");
7385

74-
let loaded_mesh = meshx::io::load_trimesh("../tests/artifacts/tutorial_trimesh.vtk")
86+
let loaded_mesh = meshx::io::load_trimesh("tests/artifacts/tutorial_trimesh.vtk")
7587
.expect("Failed to load the tutorial triangle mesh");
7688

7789
assert_eq!(mesh, loaded_mesh);

src/io.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,7 @@ pub fn load_trimesh<T: Real, P: AsRef<Path>>(file: P) -> Result<TriMesh<T>, Erro
273273
}
274274

275275
/// Saves a triangle mesh to a file.
276-
pub fn save_trimesh<T: Real, P: AsRef<Path>>(
277-
trimesh: &TriMesh<T>,
278-
file: P,
279-
) -> Result<(), Error> {
276+
pub fn save_trimesh<T: Real, P: AsRef<Path>>(trimesh: &TriMesh<T>, file: P) -> Result<(), Error> {
280277
save_polymesh_impl(&PolyMesh::from(trimesh.clone()), file.as_ref())
281278
}
282279

src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//! This library is designed to simplify interoperability between different 3D applications using mesh data
88
//! structures. `meshx` also provides common mesh types and APIs to work with attributes.
99
10-
1110
#[macro_use]
1211
extern crate meshx_derive;
1312

0 commit comments

Comments
 (0)