Skip to main content

BodySpec

Struct BodySpec 

Source
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: bool

Whether 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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn ends(&self, on: CoedgeOn) -> GeopResult<(usize, usize)>

The vertex a coedge running along on starts at, and the one it ends at.

Source

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.

Source

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.

Source

pub fn is_wire(&self) -> bool

Whether it describes a wire: vertices, but no faces.

Source

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

Source

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

Source

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.

Trait Implementations§

Source§

impl Clone for BodySpec

Source§

fn clone(&self) -> BodySpec

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BodySpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BodySpec

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for BodySpec

Source§

fn eq(&self, other: &BodySpec) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for BodySpec

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for BodySpec

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.