[][src]Trait plexus::graph::GraphGeometry

pub trait GraphGeometry: Sized {
    type Vertex: Copy;
    type Arc: Copy + Default;
    type Edge: Copy + Default;
    type Face: Copy + Default;
}

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 exposed by the AsPosition trait.

Examples

use decorum::N64;
use nalgebra::{Point3, Vector4};
use num::Zero;
use plexus::graph::{GraphGeometry, MeshGraph};
use plexus::prelude::*;
use plexus::primitive::generate::Position;
use plexus::primitive::sphere::UvSphere;
use plexus::{AsPosition, IntoGeometry};

// Vertex-only geometry with position and color data.
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
pub struct Vertex {
    pub position: Point3<N64>,
    pub color: Vector4<N64>,
}

impl GraphGeometry for Vertex {
    type Vertex = Self;
    type Arc = ();
    type Edge = ();
    type Face = ();
}

impl AsPosition for Vertex {
    type Position = Point3<N64>;

    fn as_position(&self) -> &Self::Position {
        &self.position
    }

    fn as_position_mut(&mut self) -> &mut Self::Position {
        &mut self.position
    }
}

// Create a mesh from a sphere primitive and map the geometry data.
let mut graph = UvSphere::new(8, 8)
    .polygons::<Position<Point3<N64>>>()
    .map_vertices(|position| Vertex {
        position,
        color: Zero::zero(),
    })
    .collect::<MeshGraph<Vertex>>();

Associated Types

type Vertex: Copy

type Arc: Copy + Default

type Edge: Copy + Default

type Face: Copy + Default

Loading content...

Implementations on Foreign Types

impl GraphGeometry for ()[src]

type Vertex = ()

type Arc = ()

type Edge = ()

type Face = ()

impl<T> GraphGeometry for (T, T) where
    T: Copy
[src]

type Vertex = Self

type Arc = ()

type Edge = ()

type Face = ()

impl<T> GraphGeometry for (T, T, T) where
    T: Copy
[src]

type Vertex = Self

type Arc = ()

type Edge = ()

type Face = ()

impl<T> GraphGeometry for [T; 2] where
    T: Copy
[src]

type Vertex = Self

type Arc = ()

type Edge = ()

type Face = ()

impl<T> GraphGeometry for [T; 3] where
    T: Copy
[src]

type Vertex = Self

type Arc = ()

type Edge = ()

type Face = ()

impl<T> GraphGeometry for Point2<T> where
    Self: Copy
[src]

type Vertex = Self

type Arc = ()

type Edge = ()

type Face = ()

impl<T> GraphGeometry for Point3<T> where
    Self: Copy
[src]

type Vertex = Self

type Arc = ()

type Edge = ()

type Face = ()

impl<T> GraphGeometry for Point2<T> where
    Self: Copy
[src]

type Vertex = Self

type Arc = ()

type Edge = ()

type Face = ()

impl<T> GraphGeometry for Point3<T> where
    Self: Copy
[src]

type Vertex = Self

type Arc = ()

type Edge = ()

type Face = ()

impl<T, D> GraphGeometry for Point<T, D> where
    T: Scalar,
    D: DimName,
    DefaultAllocator: Allocator<T, D>,
    Self: Copy
[src]

type Vertex = Self

type Arc = ()

type Edge = ()

type Face = ()

Loading content...

Implementors

Loading content...