Skip to main content

Part

Struct Part 

Source
pub struct Part<S: Scalar> { /* private fields */ }
Expand description

A complete, editable CAD part: its boundary-representation topology, the sketches and datums used to build it, and a name for every one of those entities.

The fields are private: the only way to change a part is through its methods, each of which forwards straight to the identically named Model operation, registers every vertex/edge/face/solid it created under the name the caller supplied, and forgets the name of every one it deleted. That keeps the invariant Part::check_names checks — every entity has exactly one name, and every name one entity — true by construction rather than by each caller’s diligence.

Implementations§

Source§

impl<S: Scalar> Part<S>

Source

pub fn add_datum( &mut self, datum: Datum<S>, name: impl Into<String>, ) -> GeopResult<DatumId>

Adds datum to the part under name. Fails, leaving the part unchanged, if name is already taken.

Source

pub fn datum(&self, id: DatumId) -> GeopResult<&Datum<S>>

Source

pub fn datums(&self) -> impl Iterator<Item = (DatumId, &Datum<S>)>

Every datum, in the order they were added.

Source§

impl<S: Scalar> Part<S>

Source

pub fn insert_vertex( &mut self, point: Vector3<S>, name: impl Into<String>, ) -> GeopResult<VertexId>

Forwards to geop_core_topology::Model::insert_vertex: a vertex on nothing yet, about to be split into an edge (see Part::split_edge_at_vertex).

Source

pub fn insert_edge( &mut self, edge: Edge<S>, name: impl Into<String>, ) -> GeopResult<EdgeId>

Forwards to geop_core_topology::Model::insert_edge: an edge on no face yet, about to be spliced into its faces (see Part::splice_edge_into_face).

Source

pub fn merge_vertex( &mut self, vertex_into_id: VertexId, vertex_deleted_id: VertexId, ) -> GeopResult<()>

Forwards to geop_core_topology::Model::merge_vertex, forgetting the name of the vertex it deletes. The survivor keeps its own name.

Source

pub fn merge_edge( &mut self, edge_into_id: EdgeId, edge_deleted_id: EdgeId, reversed: bool, ) -> GeopResult<()>

Forwards to geop_core_topology::Model::merge_edge, forgetting the name of the edge it deletes. The survivor keeps its own name.

Source

pub fn reverse_face(&mut self, face_id: FaceId) -> GeopResult<()>

Forwards to geop_core_topology::Model::reverse_face. Creates and deletes nothing.

Source

pub fn splice_edge_into_face( &mut self, edge_id: EdgeId, face_id: FaceId, max_nodes: usize, min_subdivision_size: S, new_face_name: impl Into<String>, ) -> GeopResult<Option<FaceId>>

Forwards to geop_core_topology::Model::splice_edge_into_face.

Whether that creates a face depends on how the edge’s ends sit on the face’s boundary, which a caller imprinting a traced curve cannot know beforehand — so new_face_name is the name for the face if one is created, and unused otherwise.

Source

pub fn split_edge_at_vertex( &mut self, edge_id: EdgeId, edge_t: S, vertex_id: VertexId, max_nodes: usize, min_subdivision_size: S, new_edge_name: impl Into<String>, ) -> GeopResult<EdgeId>

Forwards to geop_core_topology::Model::split_edge_at_vertex, naming the new edge it creates: the (vertex -> end) segment, while edge_id keeps the (start -> vertex) one and its name.

Source

pub fn assemble_solid( &mut self, consumed: &[SolidId], keep: &[FaceId], solid_name: impl Into<String>, ) -> GeopResult<Option<SolidId>>

Forwards to geop_core_topology::Model::assemble_solid, naming the solid it creates (if any) and forgetting the names of everything it deletes.

Source

pub fn merge_solids(&mut self, into: SolidId, from: SolidId) -> GeopResult<()>

Forwards to geop_core_topology::Model::merge_solids, forgetting the name of the solid it deletes.

Source§

impl<S: Scalar> Part<S>

Source

pub fn mvfs( &mut self, point: Vector3<S>, vertex_name: impl Into<String>, face_name: impl Into<String>, solid_name: impl Into<String>, ) -> GeopResult<(VertexId, FaceId, SolidId)>

Forwards to geop_core_topology::Model::mvfs, naming the new vertex, face and solid it creates.

Source

pub fn mve( &mut self, coedge: CoedgeId, curve: NurbCurve3D<S>, pcurve: NurbCurve2D<S>, pcurve_reversed: NurbCurve2D<S>, p: Vector3<S>, vertex_name: impl Into<String>, edge_name: impl Into<String>, ) -> GeopResult<(VertexId, CoedgeId, CoedgeId, EdgeId)>

Forwards to geop_core_topology::Model::mve, naming the new vertex and edge it creates.

Source

pub fn mve_from_vertex( &mut self, face_id: FaceId, vertex: VertexId, curve: NurbCurve3D<S>, pcurve: NurbCurve2D<S>, pcurve_reversed: NurbCurve2D<S>, p: Vector3<S>, vertex_name: impl Into<String>, edge_name: impl Into<String>, ) -> GeopResult<(VertexId, CoedgeId, CoedgeId, EdgeId)>

Forwards to geop_core_topology::Model::mve_from_vertex, naming the new vertex and edge it creates.

Source

pub fn mef( &mut self, coedge1: CoedgeId, coedge2: CoedgeId, curve: NurbCurve3D<S>, pcurve: NurbCurve2D<S>, pcurve_reversed: NurbCurve2D<S>, new_surface: NurbSurface3D<S>, edge_name: impl Into<String>, face_name: impl Into<String>, ) -> GeopResult<(EdgeId, FaceId, CoedgeId, CoedgeId)>

Forwards to geop_core_topology::Model::mef, naming the new edge and face it creates.

Source

pub fn mer( &mut self, coedge1: CoedgeId, coedge2: CoedgeId, curve: NurbCurve3D<S>, pcurve: NurbCurve2D<S>, pcurve_reversed: NurbCurve2D<S>, existing_face_id: FaceId, edge_name: impl Into<String>, ) -> GeopResult<(EdgeId, CoedgeId, CoedgeId)>

Forwards to geop_core_topology::Model::mer, naming the new edge it creates (existing_face_id already has a name of its own).

Source

pub fn mekr( &mut self, coedge1: CoedgeId, coedge2: CoedgeId, curve: NurbCurve3D<S>, pcurve: NurbCurve2D<S>, edge_name: impl Into<String>, ) -> GeopResult<(EdgeId, CoedgeId, CoedgeId)>

Forwards to geop_core_topology::Model::mekr, naming the new edge it creates.

Source

pub fn mvr( &mut self, face_id: FaceId, point: Vector3<S>, vertex_name: impl Into<String>, ) -> GeopResult<VertexId>

Forwards to geop_core_topology::Model::mvr, naming the new vertex it creates.

Source

pub fn add_vertex_coedge( &mut self, after: CoedgeId, vertex: VertexId, pcurve: NurbCurve2D<S>, ) -> GeopResult<CoedgeId>

Forwards to geop_core_topology::Model::add_vertex_coedge. Creates no vertex/edge/face/solid of its own (only a coedge, which Part never names), so it takes no name argument.

Source

pub fn kill_vertex_coedge(&mut self, coedge: CoedgeId) -> GeopResult<()>

Forwards to geop_core_topology::Model::kill_vertex_coedge. Deletes no named entity, so it takes no name argument.

Source

pub fn replace_face( &mut self, face_id: FaceId, surface: NurbSurface3D<S>, ) -> GeopResult<()>

Forwards to geop_core_topology::Model::replace_face. Creates and deletes nothing: the face keeps its name with its new surface.

Source

pub fn replace_pcurve( &mut self, coedge_id: CoedgeId, pcurve: NurbCurve2D<S>, ) -> GeopResult<()>

Forwards to geop_core_topology::Model::replace_pcurve. Coedges are never named, so this takes no name.

Source

pub fn kef(&mut self, edge: EdgeId, killed_face: FaceId) -> GeopResult<()>

Forwards to geop_core_topology::Model::kef, forgetting the names of the edge and face it deletes (both already given as arguments).

Source

pub fn kemr(&mut self, ca_id: CoedgeId, cb_id: CoedgeId) -> GeopResult<()>

Forwards to geop_core_topology::Model::kemr, forgetting the name of the edge it deletes (ca_id/cb_id’s shared edge).

Source

pub fn ker( &mut self, coedge_backward: CoedgeId, coedge_forward: CoedgeId, ) -> GeopResult<()>

Forwards to geop_core_topology::Model::ker, forgetting the name of the edge it deletes (coedge_backward/coedge_forward’s shared edge).

Source

pub fn kve( &mut self, c_out: CoedgeId, c_in: CoedgeId, vertex: VertexId, ) -> GeopResult<()>

Forwards to geop_core_topology::Model::kve, forgetting the names of the edge (c_out/c_in’s shared edge) and vertex it deletes.

Source

pub fn kvfs(&mut self, solid: SolidId) -> GeopResult<()>

Forwards to geop_core_topology::Model::kvfs, forgetting the names of the vertex, face and solid it deletes. Model::kvfs doesn’t hand those ids back (it just takes solid), so they’re read off the still-intact topology first, the same way Model::kvfs itself finds them; if that shape isn’t there, Model::kvfs below rejects it for the same reason, so nothing is left half-forgotten.

Source

pub fn kvr(&mut self, face_id: FaceId, vertex: VertexId) -> GeopResult<()>

Forwards to geop_core_topology::Model::kvr, forgetting the name of the vertex it deletes (already given as an argument).

Source§

impl<S: Scalar> Part<S>

Source

pub fn new() -> Self

Source

pub fn topology(&self) -> &Model<S>

The part’s topology, to query. Changing it goes through Part’s own methods, so that names stay in sync.

Source

pub fn names(&self) -> &NameRegistry

Source

pub fn name_of(&self, id: impl Into<RefId>) -> Option<&str>

Source

pub fn id_of(&self, name: &str) -> Option<RefId>

Source

pub fn rename( &mut self, id: impl Into<RefId>, new_name: impl Into<String>, ) -> GeopResult<()>

Gives id the name new_name instead — see NameRegistry::rename for the one situation this is for.

Source

pub fn check_names(&self) -> GeopResult<()>

Checks the invariant every method keeps: every vertex, edge, face, solid, sketch and datum has a name, and every name belongs to one of them.

Source§

impl<S: Scalar> Part<S>

Source

pub fn vertex_id(&self, name: &str) -> GeopResult<VertexId>

Source

pub fn edge_id(&self, name: &str) -> GeopResult<EdgeId>

Source

pub fn face_id(&self, name: &str) -> GeopResult<FaceId>

Source

pub fn solid_id(&self, name: &str) -> GeopResult<SolidId>

Source

pub fn sketch_id(&self, name: &str) -> GeopResult<SketchId>

Source

pub fn datum_id(&self, name: &str) -> GeopResult<DatumId>

Source

pub fn coedge_id( &self, edge_name: &str, face_name: &str, ) -> GeopResult<CoedgeId>

The unique coedge of edge_name lying on face_name. An edge shared by two distinct faces has exactly one coedge per face, so this pair identifies it unambiguously — except for a connector edge geop_core_topology::Model::mve or geop_core_topology::Model::mekr mints, both of whose coedges sit on the very same face; resolve one of those with Part::coedge_id_with_sense instead.

Source

pub fn coedge_id_with_sense( &self, edge_name: &str, face_name: &str, sense: Sense, ) -> GeopResult<CoedgeId>

The coedge of edge_name on face_name with sense sense — needed only for a connector edge whose two coedges both sit on one face (see Part::coedge_id’s own doc comment), where the plain (edge, face) pair is ambiguous.

Source§

impl<S: Scalar> Part<S>

Source

pub fn add_sketch( &mut self, placed: PlacedSketch<S>, name: impl Into<String>, ) -> GeopResult<SketchId>

Adds placed to the part under name. Fails, leaving the part unchanged, if name is already taken.

Source

pub fn remove_sketch(&mut self, id: SketchId) -> GeopResult<()>

Source

pub fn sketch(&self, id: SketchId) -> GeopResult<&PlacedSketch<S>>

Source

pub fn sketches(&self) -> impl Iterator<Item = (SketchId, &PlacedSketch<S>)>

Every sketch, in the order they were added.

Trait Implementations§

Source§

impl<S: Clone + Scalar> Clone for Part<S>

Source§

fn clone(&self) -> Part<S>

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<S: Scalar> Default for Part<S>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S> Freeze for Part<S>

§

impl<S> RefUnwindSafe for Part<S>
where S: RefUnwindSafe,

§

impl<S> Send for Part<S>

§

impl<S> Sync for Part<S>

§

impl<S> Unpin for Part<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Part<S>

§

impl<S> UnwindSafe for Part<S>

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> 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.