Struct truck_topology::Solid
source · pub struct Solid<P, C, S> { /* private fields */ }
Expand description
Solid, attached to a closed shells.
Implementations§
source§impl<P: Clone, C: Clone, S: Clone> Solid<P, C, S>
impl<P: Clone, C: Clone, S: Clone> Solid<P, C, S>
sourcepub fn compress(&self) -> CompressedSolid<P, C, S>
pub fn compress(&self) -> CompressedSolid<P, C, S>
Compresses the solid into the serialized compressed solid.
sourcepub fn extract(csolid: CompressedSolid<P, C, S>) -> Result<Self>
pub fn extract(csolid: CompressedSolid<P, C, S>) -> Result<Self>
Extracts the serialized compressed shell into the shell.
source§impl<P, C, S> Solid<P, C, S>
impl<P, C, S> Solid<P, C, S>
sourcepub fn new(boundaries: Vec<Shell<P, C, S>>) -> Solid<P, C, S>
pub fn new(boundaries: Vec<Shell<P, C, S>>) -> Solid<P, C, S>
create the shell whose boundaries is boundary.
Panic
All boundary must be non-empty, connected, and closed manifold.
Examples found in repository?
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
pub fn debug_new(boundaries: Vec<Shell<P, C, S>>) -> Solid<P, C, S> {
match cfg!(debug_assertions) {
true => Solid::new(boundaries),
false => Solid::new_unchecked(boundaries),
}
}
/// Returns the reference of boundary shells
#[inline(always)]
pub const fn boundaries(&self) -> &Vec<Shell<P, C, S>> { &self.boundaries }
/// Returns the boundary shells
#[inline(always)]
pub fn into_boundaries(self) -> Vec<Shell<P, C, S>> { self.boundaries }
/// Returns an iterator over the faces.
#[inline(always)]
pub fn face_iter(&self) -> impl Iterator<Item = &Face<P, C, S>> {
self.boundaries.iter().flatten()
}
/// Returns an iterator over the edges.
#[inline(always)]
pub fn edge_iter(&self) -> impl Iterator<Item = Edge<P, C>> + '_ {
self.face_iter().flat_map(Face::boundaries).flatten()
}
/// Returns an iterator over the vertices.
#[inline(always)]
pub fn vertex_iter(&self) -> impl Iterator<Item = Vertex<P>> + '_ {
self.edge_iter().map(|edge| edge.front().clone())
}
/// invert all faces
#[inline(always)]
pub fn not(&mut self) {
self.boundaries
.iter_mut()
.flat_map(|shell| shell.face_iter_mut())
.for_each(|face| {
face.invert();
})
}
/// Returns a new solid whose surfaces are mapped by `surface_mapping`,
/// curves are mapped by `curve_mapping` and points are mapped by `point_mapping`.
/// # Remarks
/// Accessing geometry elements directly in the closure will result in a deadlock.
/// So, this method does not appear to the document.
#[doc(hidden)]
#[inline(always)]
pub fn try_mapped<Q, D, T>(
&self,
mut point_mapping: impl FnMut(&P) -> Option<Q>,
mut curve_mapping: impl FnMut(&C) -> Option<D>,
mut surface_mapping: impl FnMut(&S) -> Option<T>,
) -> Option<Solid<Q, D, T>> {
Some(Solid::debug_new(
self.boundaries()
.iter()
.map(move |shell| {
shell.try_mapped(&mut point_mapping, &mut curve_mapping, &mut surface_mapping)
})
.collect::<Option<Vec<_>>>()?,
))
}
/// Returns a new solid whose surfaces are mapped by `surface_mapping`,
/// curves are mapped by `curve_mapping` and points are mapped by `point_mapping`.
/// # Remarks
/// Accessing geometry elements directly in the closure will result in a deadlock.
/// So, this method does not appear to the document.
#[doc(hidden)]
#[inline(always)]
pub fn mapped<Q, D, T>(
&self,
mut point_mapping: impl FnMut(&P) -> Q,
mut curve_mapping: impl FnMut(&C) -> D,
mut surface_mapping: impl FnMut(&S) -> T,
) -> Solid<Q, D, T> {
Solid::debug_new(
self.boundaries()
.iter()
.map(move |shell| {
shell.mapped(&mut point_mapping, &mut curve_mapping, &mut surface_mapping)
})
.collect(),
)
}
/// Returns the consistence of the geometry of end vertices
/// and the geometry of edge.
#[inline(always)]
pub fn is_geometric_consistent(&self) -> bool
where
P: Tolerance,
C: BoundedCurve<Point = P>,
S: IncludeCurve<C>, {
self.boundaries()
.iter()
.all(|shell| shell.is_geometric_consistent())
}
/// Cuts one edge into two edges at vertex.
#[inline(always)]
pub fn cut_edge(
&mut self,
edge_id: EdgeID<C>,
vertex: &Vertex<P>,
) -> Option<(Edge<P, C>, Edge<P, C>)>
where
P: Clone,
C: Cut<Point = P> + SearchParameter<D1, Point = P>,
{
let res = self
.boundaries
.iter_mut()
.find_map(|shell| shell.cut_edge(edge_id, vertex));
#[cfg(debug_assertions)]
Solid::new(self.boundaries.clone());
res
}
/// Removes `vertex` from `self` by concat two edges on both sides.
#[inline(always)]
pub fn remove_vertex_by_concat_edges(&mut self, vertex_id: VertexID<P>) -> Option<Edge<P, C>>
where
P: Debug,
C: Concat<C, Point = P, Output = C> + Invertible + ParameterTransform, {
let res = self
.boundaries
.iter_mut()
.find_map(|shell| shell.remove_vertex_by_concat_edges(vertex_id));
#[cfg(debug_assertions)]
Solid::new(self.boundaries.clone());
res
}
sourcepub fn try_new(boundaries: Vec<Shell<P, C, S>>) -> Result<Solid<P, C, S>>
pub fn try_new(boundaries: Vec<Shell<P, C, S>>) -> Result<Solid<P, C, S>>
create the shell whose boundaries is boundary.
Failure
All boundary must be non-empty, connected, and closed manifold.
Examples found in repository?
More examples
sourcepub const fn new_unchecked(boundaries: Vec<Shell<P, C, S>>) -> Solid<P, C, S>
pub const fn new_unchecked(boundaries: Vec<Shell<P, C, S>>) -> Solid<P, C, S>
create the shell whose boundaries is boundary.
Remarks
This method is prepared only for performance-critical development and is not recommended. This method does NOT check whether all boundary is non-empty, connected, and closed. The programmer must guarantee this condition before using this method.
Examples found in repository?
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
pub fn try_new(boundaries: Vec<Shell<P, C, S>>) -> Result<Solid<P, C, S>> {
for shell in &boundaries {
if shell.is_empty() {
return Err(Error::EmptyShell);
} else if !shell.is_connected() {
return Err(Error::NotConnected);
} else if shell.shell_condition() != ShellCondition::Closed {
return Err(Error::NotClosedShell);
} else if !shell.singular_vertices().is_empty() {
return Err(Error::NotManifold);
}
}
Ok(Solid::new_unchecked(boundaries))
}
/// create the shell whose boundaries is boundary.
/// # Remarks
/// This method is prepared only for performance-critical development and is not recommended.
/// This method does NOT check whether all boundary is non-empty, connected, and closed.
/// The programmer must guarantee this condition before using this method.
#[inline(always)]
pub const fn new_unchecked(boundaries: Vec<Shell<P, C, S>>) -> Solid<P, C, S> {
Solid { boundaries }
}
/// create the shell whose boundaries is boundary.
/// # Remarks
/// This method checks whether all boundary is non-empty, connected, and closed in the debug mode.
/// The programmer must guarantee this condition before using this method.
#[inline(always)]
pub fn debug_new(boundaries: Vec<Shell<P, C, S>>) -> Solid<P, C, S> {
match cfg!(debug_assertions) {
true => Solid::new(boundaries),
false => Solid::new_unchecked(boundaries),
}
}
sourcepub fn debug_new(boundaries: Vec<Shell<P, C, S>>) -> Solid<P, C, S>
pub fn debug_new(boundaries: Vec<Shell<P, C, S>>) -> Solid<P, C, S>
create the shell whose boundaries is boundary.
Remarks
This method checks whether all boundary is non-empty, connected, and closed in the debug mode. The programmer must guarantee this condition before using this method.
Examples found in repository?
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
pub fn try_mapped<Q, D, T>(
&self,
mut point_mapping: impl FnMut(&P) -> Option<Q>,
mut curve_mapping: impl FnMut(&C) -> Option<D>,
mut surface_mapping: impl FnMut(&S) -> Option<T>,
) -> Option<Solid<Q, D, T>> {
Some(Solid::debug_new(
self.boundaries()
.iter()
.map(move |shell| {
shell.try_mapped(&mut point_mapping, &mut curve_mapping, &mut surface_mapping)
})
.collect::<Option<Vec<_>>>()?,
))
}
/// Returns a new solid whose surfaces are mapped by `surface_mapping`,
/// curves are mapped by `curve_mapping` and points are mapped by `point_mapping`.
/// # Remarks
/// Accessing geometry elements directly in the closure will result in a deadlock.
/// So, this method does not appear to the document.
#[doc(hidden)]
#[inline(always)]
pub fn mapped<Q, D, T>(
&self,
mut point_mapping: impl FnMut(&P) -> Q,
mut curve_mapping: impl FnMut(&C) -> D,
mut surface_mapping: impl FnMut(&S) -> T,
) -> Solid<Q, D, T> {
Solid::debug_new(
self.boundaries()
.iter()
.map(move |shell| {
shell.mapped(&mut point_mapping, &mut curve_mapping, &mut surface_mapping)
})
.collect(),
)
}
sourcepub const fn boundaries(&self) -> &Vec<Shell<P, C, S>> ⓘ
pub const fn boundaries(&self) -> &Vec<Shell<P, C, S>> ⓘ
Returns the reference of boundary shells
Examples found in repository?
More examples
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
pub fn try_mapped<Q, D, T>(
&self,
mut point_mapping: impl FnMut(&P) -> Option<Q>,
mut curve_mapping: impl FnMut(&C) -> Option<D>,
mut surface_mapping: impl FnMut(&S) -> Option<T>,
) -> Option<Solid<Q, D, T>> {
Some(Solid::debug_new(
self.boundaries()
.iter()
.map(move |shell| {
shell.try_mapped(&mut point_mapping, &mut curve_mapping, &mut surface_mapping)
})
.collect::<Option<Vec<_>>>()?,
))
}
/// Returns a new solid whose surfaces are mapped by `surface_mapping`,
/// curves are mapped by `curve_mapping` and points are mapped by `point_mapping`.
/// # Remarks
/// Accessing geometry elements directly in the closure will result in a deadlock.
/// So, this method does not appear to the document.
#[doc(hidden)]
#[inline(always)]
pub fn mapped<Q, D, T>(
&self,
mut point_mapping: impl FnMut(&P) -> Q,
mut curve_mapping: impl FnMut(&C) -> D,
mut surface_mapping: impl FnMut(&S) -> T,
) -> Solid<Q, D, T> {
Solid::debug_new(
self.boundaries()
.iter()
.map(move |shell| {
shell.mapped(&mut point_mapping, &mut curve_mapping, &mut surface_mapping)
})
.collect(),
)
}
/// Returns the consistence of the geometry of end vertices
/// and the geometry of edge.
#[inline(always)]
pub fn is_geometric_consistent(&self) -> bool
where
P: Tolerance,
C: BoundedCurve<Point = P>,
S: IncludeCurve<C>, {
self.boundaries()
.iter()
.all(|shell| shell.is_geometric_consistent())
}
sourcepub fn into_boundaries(self) -> Vec<Shell<P, C, S>> ⓘ
pub fn into_boundaries(self) -> Vec<Shell<P, C, S>> ⓘ
Returns the boundary shells
sourcepub fn face_iter(&self) -> impl Iterator<Item = &Face<P, C, S>>
pub fn face_iter(&self) -> impl Iterator<Item = &Face<P, C, S>>
Returns an iterator over the faces.
sourcepub fn edge_iter(&self) -> impl Iterator<Item = Edge<P, C>> + '_
pub fn edge_iter(&self) -> impl Iterator<Item = Edge<P, C>> + '_
Returns an iterator over the edges.
sourcepub fn vertex_iter(&self) -> impl Iterator<Item = Vertex<P>> + '_
pub fn vertex_iter(&self) -> impl Iterator<Item = Vertex<P>> + '_
Returns an iterator over the vertices.
sourcepub fn is_geometric_consistent(&self) -> boolwhere
P: Tolerance,
C: BoundedCurve<Point = P>,
S: IncludeCurve<C>,
pub fn is_geometric_consistent(&self) -> boolwhere
P: Tolerance,
C: BoundedCurve<Point = P>,
S: IncludeCurve<C>,
Returns the consistence of the geometry of end vertices and the geometry of edge.
sourcepub fn cut_edge(
&mut self,
edge_id: EdgeID<C>,
vertex: &Vertex<P>
) -> Option<(Edge<P, C>, Edge<P, C>)>where
P: Clone,
C: Cut<Point = P> + SearchParameter<D1, Point = P>,
pub fn cut_edge(
&mut self,
edge_id: EdgeID<C>,
vertex: &Vertex<P>
) -> Option<(Edge<P, C>, Edge<P, C>)>where
P: Clone,
C: Cut<Point = P> + SearchParameter<D1, Point = P>,
Cuts one edge into two edges at vertex.
sourcepub fn remove_vertex_by_concat_edges(
&mut self,
vertex_id: VertexID<P>
) -> Option<Edge<P, C>>where
P: Debug,
C: Concat<C, Point = P, Output = C> + Invertible + ParameterTransform,
pub fn remove_vertex_by_concat_edges(
&mut self,
vertex_id: VertexID<P>
) -> Option<Edge<P, C>>where
P: Debug,
C: Concat<C, Point = P, Output = C> + Invertible + ParameterTransform,
Removes vertex
from self
by concat two edges on both sides.
sourcepub fn cut_face_by_edge(&mut self, face_id: FaceID<S>, edge: Edge<P, C>) -> boolwhere
S: Clone,
pub fn cut_face_by_edge(&mut self, face_id: FaceID<S>, edge: Edge<P, C>) -> boolwhere
S: Clone,
Cut a face with face_id
by edge.
sourcepub fn display(
&self,
format: SolidDisplayFormat
) -> DebugDisplay<'_, Self, SolidDisplayFormat>
pub fn display(
&self,
format: SolidDisplayFormat
) -> DebugDisplay<'_, Self, SolidDisplayFormat>
Creates display struct for debugging the solid.