pub struct BodySpec {
pub vertices: Vec<Vector3>,
pub edges: Vec<EdgeSpec>,
pub faces: Vec<FaceSpec>,
pub shells: Vec<Vec<usize>>,
pub solid: bool,
}Expand description
A body to build, its entities referring to each other by their index in
the lists here: a solid, a sheet, or — with no faces — a wire. It
serializes exactly (see geop_core_math::exact): a body kept to be
built again is the body that was described.
Fields§
§vertices: Vec<Vector3>§edges: Vec<EdgeSpec>§faces: Vec<FaceSpec>§shells: Vec<Vec<usize>>Each shell’s faces. Every face is in exactly one.
solid: boolWhether the shells bound a solid — then they must be closed, every edge used by exactly two faces — or are each a sheet of their own.
Implementations§
Source§impl BodySpec
impl BodySpec
Sourcepub fn new(solid: bool) -> Self
pub fn new(solid: bool) -> Self
An empty description, to add a body’s entities to: of a solid if
solid, else of sheets or a wire.
Sourcepub fn sheet_on(surface: NurbSurface3D) -> GeopResult<Self>
pub fn sheet_on(surface: NurbSurface3D) -> GeopResult<Self>
A sheet of one face on surface over the whole of its domain,
bounded by the surface’s four sides, each its boundary row (see
boundary_curve): what cuts a body along a surface, as a split
does. Fails for a surface not clamped at a side, or one a side of
which collapses to a point — a pole has no edge.
Sourcepub fn square_face(
&self,
surface: NurbSurface3D,
corners: [usize; 4],
sides: [CoedgeOn; 4],
) -> GeopResult<FaceSpec>
pub fn square_face( &self, surface: NurbSurface3D, corners: [usize; 4], sides: [CoedgeOn; 4], ) -> GeopResult<FaceSpec>
A face on surface over the unit square of its parameters (see
FaceSpec::on_unit_square), its corners at the vertices corners:
each side along the edge — or at the vertex — sides gives, each
edge in the sense it runs from one corner to the next. Fails for an
edge that does not join its side’s corners.
Sourcepub fn placed(&self, pose: &Pose) -> Self
pub fn placed(&self, pose: &Pose) -> Self
The same body moved by the rigid motion pose: its vertices, edge
curves and surfaces moved, its pcurves — on surfaces moved with the
same parametrization — as they are.
Sourcepub fn split_vertex(
&mut self,
v: usize,
moved: &[(usize, bool)],
point: Vector3,
curve: Curve3,
pcurve: impl FnMut(usize, Sense) -> GeopResult<Curve2>,
) -> GeopResult<(usize, usize)>
pub fn split_vertex( &mut self, v: usize, moved: &[(usize, bool)], point: Vector3, curve: Curve3, pcurve: impl FnMut(usize, Sense) -> GeopResult<Curve2>, ) -> GeopResult<(usize, usize)>
Takes the vertex v apart: the edge ends moved — an edge, and
whether its end (or else its start) — go to a new vertex at point,
and a new edge on curve, from v to the new vertex, runs between
them in every loop the move breaks, its pcurve on face f, run in
sense, pcurve(f, sense). The new vertex and the new edge.
Sourcepub fn ends(&self, on: CoedgeOn) -> GeopResult<(usize, usize)>
pub fn ends(&self, on: CoedgeOn) -> GeopResult<(usize, usize)>
The vertex a coedge running along on starts at, and the one it
ends at.
Sourcepub fn edge_uses(&self) -> Vec<Vec<(usize, Sense, &Curve2)>>
pub fn edge_uses(&self) -> Vec<Vec<(usize, Sense, &Curve2)>>
Per edge, every use of it by a face’s coedge — the face, the coedge’s sense and its pcurve — in the order of the faces.
Sourcepub fn vertex_faces(&self) -> GeopResult<Vec<FacesAround>>
pub fn vertex_faces(&self) -> GeopResult<Vec<FacesAround>>
Per vertex, every face around it once, in the order of the faces, with where the vertex is on the face’s surface: where the first of the face’s coedges arriving there ends.
Sourcepub fn check(&self) -> GeopResult<()>
pub fn check(&self) -> GeopResult<()>
Checks that the description is a consistent body: every index names something, every loop closes up — each coedge ends where the next one starts — every face is in exactly one shell, every edge and vertex is used, and an edge is used at most twice, then in opposite senses — and, for a solid, exactly twice. A wire’s edges are used by no face, and its vertices need not be used at all: a point on its own is a vertex of the wire.
Source§impl BodySpec
impl BodySpec
Sourcepub fn merged(
&self,
edge_may_go: impl Fn(usize) -> bool,
vertex_may_go: impl Fn(usize) -> bool,
) -> GeopResult<(BodySpec, Merged)>
pub fn merged( &self, edge_may_go: impl Fn(usize) -> bool, vertex_may_go: impl Fn(usize) -> bool, ) -> GeopResult<(BodySpec, Merged)>
The same body without topology it does not need (see the module docs): every two faces across an edge that lie on one surface made one, on the surface of the one first in order — the older, for a body described in the order its faces were made — and then every vertex that only two edges of the same two faces meet at dropped, the two edges made one, the first in order. Also says where each entity went.
Two faces are asked whether they lie on one surface only if
edge_may_go lets every edge between them go, and two edges are
joined only if vertex_may_go lets the vertex between them go. A
boolean lets go what it left behind itself, so that an edge a step
drew on purpose stays; an edit lets go all.
Source§impl BodySpec
impl BodySpec
Sourcepub fn of_triangles(
points: &[Vector3],
triangles: &[[usize; 3]],
) -> GeopResult<BodySpec>
pub fn of_triangles( points: &[Vector3], triangles: &[[usize; 3]], ) -> GeopResult<BodySpec>
The body the triangles triangles make, each three indices into
points, counter-clockwise seen from the side its face points to:
a solid where every edge is shared by two triangles, a sheet where
some are by one. A triangle whose corners repeat an index has no
area and no edge of its own, and is left out. Refused, naming the
triangle: corners in one line, and an edge shared by more than two
triangles or by two running it the same way.