Crate truck_topology

Source
Expand description

Topological structs: vertex, edge, wire, face, shell, and solid

§Examples

The following sample code is a description of a topological tetrahedron as a solid model by this package.

use truck_topology::*;

// Create vertices. A tetrahedron has four vertices.
let v = Vertex::news(&[(), (), (), ()]);

// Create edges. Vertex is implemented the Copy trait.
let edge = [
    Edge::new(&v[0], &v[1], ()),
    Edge::new(&v[0], &v[2], ()),
    Edge::new(&v[0], &v[3], ()),
    Edge::new(&v[1], &v[2], ()),
    Edge::new(&v[1], &v[3], ()),
    Edge::new(&v[2], &v[3], ()),
];

// Create boundaries of faces as the wire.
// Edge is implemented the Copy trait.
let wire = vec![
    Wire::from_iter(vec![&edge[0], &edge[3], &edge[1].inverse()]),
    Wire::from_iter(vec![&edge[1], &edge[5], &edge[2].inverse()]),
    Wire::from_iter(vec![&edge[2], &edge[4].inverse(), &edge[0].inverse()]),
    Wire::from_iter(vec![&edge[3], &edge[5], &edge[4].inverse()]),
];

// Create faces by the boundary wires.
// The boundary of face must be simple and closed.
let mut face: Vec<Face<_, _, _>> = wire.into_iter().map(|wire| Face::new(vec![wire], ())).collect();
face[3].invert();

// Create shell of faces. Shell can be created by the Vec<Face>.
let shell: Shell<_, _, _> = face.into();

// Create a tetrahedron solid by the boundary shell.
// The boundaries of a solid must be closed and oriented.
let solid = Solid::new(vec![shell]);

§Elements and containers

Main structures in truck_topology consist 4 topological elements and 2 topological containers.

§Topological elements

The following structures are topological elements.

Except Solid, each topological element has a unique id for each instance. In higher-level packages, by mapping this id to geometric information, you can draw a solid shape.

§Topological containers

The following structures are topological container.

The entities of Wire and Shell are std::collections::VecDeque<Edge> and std::vec::Vec<Face>, respectively, and many methods inherited by Deref and DerefMut. These containers are used for creating higher-dimentional topological elements and checked the regularity (e.g. connectivity, closedness, and so on) before creating these elements.

§Features

  • nightly – Use features available only in a nightly toolchain.
  • rclite – Use of rclite::Arc instead of std::syn::Arc. The latter uses more memory and is potentially slower than the former. On by default.

Modules§

compress
Serialized topological data exchange format
errors
classifies the errors that can occur in this crate.
face
Defines the boundary iterator.
format
Display structs for debug or display topological elements
shell
classifies shell conditions and defines the face iterators.
wire
define the edge iterators and the vertex iterator.

Structs§

Edge
Edge, which consists two vertices.
Face
Face, attached to a simple and closed wire.
Shell
Shell, a connected compounded faces.
Solid
Solid, attached to a closed shells.
Vertex
Vertex, the minimum topological unit.
Wire
Wire, a path or cycle which consists some edges.

Enums§

EdgeDisplayFormat
Configuration for edge display format.
FaceDisplayFormat
Configuration for face display format
ShellDisplayFormat
Configuration for shell display format
SolidDisplayFormat
Configuration for solid display format
VertexDisplayFormat
configuration for vertex display format.
WireDisplayFormat
Configuration for wire display format.

Type Aliases§

EdgeID
The id that does not depend on the direction of the edge.
FaceID
The id that does not depend on the direction of the face.
Result
Result with crate’s errors.
VertexID
The id of vertex. Copy trait is implemented.