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>
impl<S: Scalar> Part<S>
Source§impl<S: Scalar> Part<S>
impl<S: Scalar> Part<S>
Sourcepub fn insert_vertex(
&mut self,
point: Vector3<S>,
name: impl Into<String>,
) -> GeopResult<VertexId>
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).
Sourcepub fn insert_edge(
&mut self,
edge: Edge<S>,
name: impl Into<String>,
) -> GeopResult<EdgeId>
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).
Sourcepub fn merge_vertex(
&mut self,
vertex_into_id: VertexId,
vertex_deleted_id: VertexId,
) -> GeopResult<()>
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.
Sourcepub fn merge_edge(
&mut self,
edge_into_id: EdgeId,
edge_deleted_id: EdgeId,
reversed: bool,
) -> GeopResult<()>
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.
Sourcepub fn reverse_face(&mut self, face_id: FaceId) -> GeopResult<()>
pub fn reverse_face(&mut self, face_id: FaceId) -> GeopResult<()>
Forwards to geop_core_topology::Model::reverse_face. Creates and
deletes nothing.
Sourcepub 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>>
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.
Sourcepub 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>
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.
Sourcepub fn assemble_solid(
&mut self,
consumed: &[SolidId],
keep: &[FaceId],
solid_name: impl Into<String>,
) -> GeopResult<Option<SolidId>>
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.
Sourcepub fn merge_solids(&mut self, into: SolidId, from: SolidId) -> GeopResult<()>
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>
impl<S: Scalar> Part<S>
Sourcepub 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)>
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.
Sourcepub 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)>
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.
Sourcepub 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)>
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.
Sourcepub 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)>
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.
Sourcepub 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)>
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).
Sourcepub fn mekr(
&mut self,
coedge1: CoedgeId,
coedge2: CoedgeId,
curve: NurbCurve3D<S>,
pcurve: NurbCurve2D<S>,
edge_name: impl Into<String>,
) -> GeopResult<(EdgeId, CoedgeId, CoedgeId)>
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.
Sourcepub fn mvr(
&mut self,
face_id: FaceId,
point: Vector3<S>,
vertex_name: impl Into<String>,
) -> GeopResult<VertexId>
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.
Sourcepub fn add_vertex_coedge(
&mut self,
after: CoedgeId,
vertex: VertexId,
pcurve: NurbCurve2D<S>,
) -> GeopResult<CoedgeId>
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.
Sourcepub fn kill_vertex_coedge(&mut self, coedge: CoedgeId) -> GeopResult<()>
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.
Sourcepub fn replace_face(
&mut self,
face_id: FaceId,
surface: NurbSurface3D<S>,
) -> GeopResult<()>
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.
Sourcepub fn replace_pcurve(
&mut self,
coedge_id: CoedgeId,
pcurve: NurbCurve2D<S>,
) -> GeopResult<()>
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.
Sourcepub fn kef(&mut self, edge: EdgeId, killed_face: FaceId) -> GeopResult<()>
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).
Sourcepub fn kemr(&mut self, ca_id: CoedgeId, cb_id: CoedgeId) -> GeopResult<()>
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).
Sourcepub fn ker(
&mut self,
coedge_backward: CoedgeId,
coedge_forward: CoedgeId,
) -> GeopResult<()>
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).
Sourcepub fn kve(
&mut self,
c_out: CoedgeId,
c_in: CoedgeId,
vertex: VertexId,
) -> GeopResult<()>
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.
Sourcepub fn kvfs(&mut self, solid: SolidId) -> GeopResult<()>
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.
Sourcepub fn kvr(&mut self, face_id: FaceId, vertex: VertexId) -> GeopResult<()>
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>
impl<S: Scalar> Part<S>
pub fn new() -> Self
Sourcepub fn topology(&self) -> &Model<S>
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.
pub fn names(&self) -> &NameRegistry
pub fn name_of(&self, id: impl Into<RefId>) -> Option<&str>
pub fn id_of(&self, name: &str) -> Option<RefId>
Sourcepub fn rename(
&mut self,
id: impl Into<RefId>,
new_name: impl Into<String>,
) -> GeopResult<()>
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.
Sourcepub fn check_names(&self) -> GeopResult<()>
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>
impl<S: Scalar> Part<S>
pub fn vertex_id(&self, name: &str) -> GeopResult<VertexId>
pub fn edge_id(&self, name: &str) -> GeopResult<EdgeId>
pub fn face_id(&self, name: &str) -> GeopResult<FaceId>
pub fn solid_id(&self, name: &str) -> GeopResult<SolidId>
pub fn sketch_id(&self, name: &str) -> GeopResult<SketchId>
pub fn datum_id(&self, name: &str) -> GeopResult<DatumId>
Sourcepub fn coedge_id(
&self,
edge_name: &str,
face_name: &str,
) -> GeopResult<CoedgeId>
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.
Sourcepub fn coedge_id_with_sense(
&self,
edge_name: &str,
face_name: &str,
sense: Sense,
) -> GeopResult<CoedgeId>
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>
impl<S: Scalar> Part<S>
Sourcepub fn add_sketch(
&mut self,
placed: PlacedSketch<S>,
name: impl Into<String>,
) -> GeopResult<SketchId>
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.
pub fn remove_sketch(&mut self, id: SketchId) -> GeopResult<()>
pub fn sketch(&self, id: SketchId) -> GeopResult<&PlacedSketch<S>>
Sourcepub fn sketches(&self) -> impl Iterator<Item = (SketchId, &PlacedSketch<S>)>
pub fn sketches(&self) -> impl Iterator<Item = (SketchId, &PlacedSketch<S>)>
Every sketch, in the order they were added.