[−][src]Trait plexus::geometry::Geometry
Graph geometry.
Specifies the types used to represent geometry for vertices, arcs, edges,
and faces in a graph. Arbitrary types can be used, including ()
for no
geometry at all.
Geometry is vertex-based. Geometric operations depend on understanding the positional data in vertices, and operational traits mostly apply to such positional data.
Examples
use decorum::R64; use nalgebra::{Point3, Vector4}; use num::One; use plexus::geometry::convert::{AsPosition, IntoGeometry}; use plexus::geometry::Geometry; use plexus::graph::MeshGraph; use plexus::prelude::*; use plexus::primitive::sphere::UvSphere; // Vertex-only geometry with a position and color. #[derive(Clone, Copy, Eq, Hash, PartialEq)] pub struct VertexGeometry { pub position: Point3<R64>, pub color: Vector4<R64>, } impl Geometry for VertexGeometry { type Vertex = Self; type Arc = (); type Edge = (); type Face = (); } impl AsPosition for VertexGeometry { type Target = Point3<R64>; fn as_position(&self) -> &Self::Target { &self.position } fn as_position_mut(&mut self) -> &mut Self::Target { &mut self.position } } // Create a mesh from a sphere primitive and map the geometry data. let mut graph = UvSphere::new(8, 8) .polygons_with_position() .map_vertices(|position| VertexGeometry { position: position.into_geometry(), color: Vector4::new(One::one(), One::one(), One::one(), One::one()), }) .collect::<MeshGraph<VertexGeometry>>();
Associated Types
Loading content...Implementations on Foreign Types
impl Geometry for ()
[src]
impl<T> Geometry for Point2<T> where
T: Clone,
[src]
T: Clone,
impl<T> Geometry for Point3<T> where
T: Clone,
[src]
T: Clone,
impl<T> Geometry for Point2<T> where
T: Clone,
[src]
T: Clone,
impl<T> Geometry for Point3<T> where
T: Clone,
[src]
T: Clone,
impl<T> Geometry for Point2<T> where
T: Scalar,
[src]
T: Scalar,
impl<T> Geometry for Point3<T> where
T: Scalar,
[src]
Loading content...
T: Scalar,
Implementors
impl<T> Geometry for Duplet<T> where
T: Clone,
[src]
T: Clone,
impl<T> Geometry for Triplet<T> where
T: Clone,
[src]
T: Clone,