pub struct Cycle { /* private fields */ }Expand description
A cycle of connected half-edges
Implementations§
source§impl Cycle
impl Cycle
sourcepub fn new(half_edges: impl IntoIterator<Item = Handle<HalfEdge>>) -> Self
pub fn new(half_edges: impl IntoIterator<Item = Handle<HalfEdge>>) -> Self
Examples found in repository?
More examples
src/algorithms/transform/cycle.rs (line 23)
11 12 13 14 15 16 17 18 19 20 21 22 23 24
fn transform_with_cache(
self,
transform: &Transform,
objects: &mut Service<Objects>,
cache: &mut TransformCache,
) -> Self {
let half_edges = self.half_edges().map(|half_edge| {
half_edge
.clone()
.transform_with_cache(transform, objects, cache)
});
Self::new(half_edges)
}src/algorithms/sweep/edge.rs (line 174)
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 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 182 183
fn sweep_with_cache(
self,
path: impl Into<Vector<3>>,
cache: &mut SweepCache,
objects: &mut Service<Objects>,
) -> Self::Swept {
let (edge, color) = self;
let path = path.into();
let surface =
edge.curve().clone().sweep_with_cache(path, cache, objects);
// We can't use the edge we're sweeping from as the bottom edge, as that
// is not defined in the right surface. Let's create a new bottom edge,
// by swapping the surface of the original.
let bottom_edge = {
let vertices = edge.vertices();
let points_curve_and_surface = vertices.clone().map(|vertex| {
(vertex.position(), [vertex.position().t, Scalar::ZERO])
});
let curve = {
// Please note that creating a line here is correct, even if the
// global curve is a circle. Projected into the side surface, it
// is going to be a line either way.
let path =
SurfacePath::Line(Line::from_points_with_line_coords(
points_curve_and_surface,
));
Curve::new(
surface.clone(),
path,
edge.curve().global_form().clone(),
)
.insert(objects)
};
let vertices = {
let points_surface = points_curve_and_surface
.map(|(_, point_surface)| point_surface);
vertices
.each_ref_ext()
.into_iter_fixed()
.zip(points_surface)
.collect::<[_; 2]>()
.map(|(vertex, point_surface)| {
let surface_vertex = SurfaceVertex::new(
point_surface,
surface.clone(),
vertex.global_form().clone(),
)
.insert(objects);
Vertex::new(
vertex.position(),
curve.clone(),
surface_vertex,
)
.insert(objects)
})
};
HalfEdge::new(vertices, edge.global_form().clone()).insert(objects)
};
let side_edges = bottom_edge.vertices().clone().map(|vertex| {
(vertex, surface.clone()).sweep_with_cache(path, cache, objects)
});
let top_edge = {
let bottom_vertices = bottom_edge.vertices();
let surface_vertices = side_edges.clone().map(|edge| {
let [_, vertex] = edge.vertices();
vertex.surface_form().clone()
});
let points_curve_and_surface =
bottom_vertices.clone().map(|vertex| {
(vertex.position(), [vertex.position().t, Scalar::ONE])
});
let curve = {
let global = bottom_edge
.curve()
.global_form()
.clone()
.translate(path, objects);
// Please note that creating a line here is correct, even if the
// global curve is a circle. Projected into the side surface, it
// is going to be a line either way.
let path =
SurfacePath::Line(Line::from_points_with_line_coords(
points_curve_and_surface,
));
Curve::new(surface, path, global).insert(objects)
};
let global = GlobalEdge::new(
curve.global_form().clone(),
surface_vertices
.clone()
.map(|surface_vertex| surface_vertex.global_form().clone()),
)
.insert(objects);
let vertices = bottom_vertices
.each_ref_ext()
.into_iter_fixed()
.zip(surface_vertices)
.collect::<[_; 2]>()
.map(|(vertex, surface_form)| {
Vertex::new(vertex.position(), curve.clone(), surface_form)
.insert(objects)
});
HalfEdge::new(vertices, global).insert(objects)
};
let cycle = {
let a = bottom_edge;
let [d, b] = side_edges;
let c = top_edge;
let mut edges = [a, b, c, d];
// Make sure that edges are oriented correctly.
let mut i = 0;
while i < edges.len() {
let j = (i + 1) % edges.len();
let [_, prev_last] = edges[i].vertices();
let [next_first, _] = edges[j].vertices();
// Need to compare surface forms here, as the global forms might
// be coincident when sweeping circles, despite the vertices
// being different!
if prev_last.surface_form().id()
!= next_first.surface_form().id()
{
edges[j] = edges[j].clone().reverse(objects);
}
i += 1;
}
Cycle::new(edges).insert(objects)
};
let face = PartialFace {
exterior: Partial::from(cycle),
color: Some(color),
..Default::default()
};
face.build(objects).insert(objects)
}sourcepub fn surface(&self) -> &Handle<Surface>
pub fn surface(&self) -> &Handle<Surface>
Access the surface that the cycle is in
Examples found in repository?
More examples
src/validate/face.rs (line 68)
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
fn check_surface_identity(face: &Face) -> Result<(), Self> {
let surface = face.surface();
for interior in face.interiors() {
if surface.id() != interior.surface().id() {
return Err(Self::SurfaceMismatch {
surface: surface.clone(),
interior: interior.clone(),
face: face.clone(),
});
}
}
Ok(())
}sourcepub fn half_edges(&self) -> HalfEdgesOfCycle<'_>
pub fn half_edges(&self) -> HalfEdgesOfCycle<'_>
Access the half-edges that make up the cycle
Examples found in repository?
More examples
src/algorithms/approx/cycle.rs (line 25)
17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn approx_with_cache(
self,
tolerance: impl Into<Tolerance>,
cache: &mut Self::Cache,
) -> Self::Approximation {
let tolerance = tolerance.into();
let half_edges = self
.half_edges()
.map(|half_edge| half_edge.approx_with_cache(tolerance, cache))
.collect();
CycleApprox { half_edges }
}src/algorithms/transform/cycle.rs (line 17)
11 12 13 14 15 16 17 18 19 20 21 22 23 24
fn transform_with_cache(
self,
transform: &Transform,
objects: &mut Service<Objects>,
cache: &mut TransformCache,
) -> Self {
let half_edges = self.half_edges().map(|half_edge| {
half_edge
.clone()
.transform_with_cache(transform, objects, cache)
});
Self::new(half_edges)
}src/validate/cycle.rs (line 47)
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
fn check_half_edge_connections(cycle: &Cycle) -> Result<(), Self> {
for (a, b) in cycle.half_edges().circular_tuple_windows() {
let [_, prev] = a.vertices();
let [next, _] = b.vertices();
let prev = prev.surface_form();
let next = next.surface_form();
if prev.id() != next.id() {
return Err(Self::HalfEdgeConnection {
prev: prev.clone(),
next: next.clone(),
});
}
}
Ok(())
}Additional examples can be found in:
sourcepub fn winding(&self) -> Winding
pub fn winding(&self) -> Winding
Indicate the cycle’s winding, assuming a right-handed coordinate system
Please note that this is not the winding of the cycle, only one of the two possible windings, depending on the direction you look at the surface that the cycle is defined on from.
Examples found in repository?
More examples
src/validate/face.rs (line 81)
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
fn check_interior_winding(face: &Face) -> Result<(), Self> {
let exterior_winding = face.exterior().winding();
for interior in face.interiors() {
let interior_winding = interior.winding();
if exterior_winding == interior_winding {
return Err(Self::InvalidInteriorWinding {
exterior_winding,
interior_winding,
face: face.clone(),
});
}
assert_ne!(
exterior_winding,
interior.winding(),
"Interior cycles must have opposite winding of exterior cycle"
);
}
Ok(())
}Trait Implementations§
source§impl Approx for &Cycle
impl Approx for &Cycle
§type Approximation = CycleApprox
type Approximation = CycleApprox
The approximation of the object
§type Cache = CurveCache
type Cache = CurveCache
The cache used to cache approximation results
source§fn approx_with_cache(
self,
tolerance: impl Into<Tolerance>,
cache: &mut Self::Cache
) -> Self::Approximation
fn approx_with_cache(
self,
tolerance: impl Into<Tolerance>,
cache: &mut Self::Cache
) -> Self::Approximation
Approximate the object, using the provided cache Read more
source§impl HasPartial for Cycle
impl HasPartial for Cycle
§type Partial = PartialCycle
type Partial = PartialCycle
The type representing the partial variant of this object
source§impl Ord for Cycle
impl Ord for Cycle
source§impl PartialEq<Cycle> for Cycle
impl PartialEq<Cycle> for Cycle
source§impl PartialOrd<Cycle> for Cycle
impl PartialOrd<Cycle> for Cycle
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moresource§impl TransformObject for Cycle
impl TransformObject for Cycle
source§fn transform_with_cache(
self,
transform: &Transform,
objects: &mut Service<Objects>,
cache: &mut TransformCache
) -> Self
fn transform_with_cache(
self,
transform: &Transform,
objects: &mut Service<Objects>,
cache: &mut TransformCache
) -> Self
Transform the object using the provided cache
source§fn transform(self, transform: &Transform, objects: &mut Service<Objects>) -> Self
fn transform(self, transform: &Transform, objects: &mut Service<Objects>) -> Self
Transform the object
source§impl Validate for Cycle
impl Validate for Cycle
§type Error = CycleValidationError
type Error = CycleValidationError
The error that validation of the implementing type can result in
source§fn validate_with_config(&self, _: &ValidationConfig) -> Result<(), Self::Error>
fn validate_with_config(&self, _: &ValidationConfig) -> Result<(), Self::Error>
Validate the object
impl Eq for Cycle
impl StructuralEq for Cycle
impl StructuralPartialEq for Cycle
Auto Trait Implementations§
impl !RefUnwindSafe for Cycle
impl Send for Cycle
impl Sync for Cycle
impl Unpin for Cycle
impl !UnwindSafe for Cycle
Blanket Implementations§
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.