pub trait Shape: Send + Sync + Clone {
type Trace: Clone + Eq + Send + Trace;
type Storage: Default + Send;
type Workspace: Default + Send;
type TapeStorage: Default + Send;
type PointEval: TracingEvaluator<Data = f32, Trace = Self::Trace, TapeStorage = Self::TapeStorage> + Send + Sync;
type IntervalEval: TracingEvaluator<Data = Interval, Trace = Self::Trace, TapeStorage = Self::TapeStorage> + Send + Sync;
type FloatSliceEval: BulkEvaluator<Data = f32, TapeStorage = Self::TapeStorage> + Send + Sync;
type GradSliceEval: BulkEvaluator<Data = Grad, TapeStorage = Self::TapeStorage> + Send + Sync;
type TransformedShape: Shape;
Show 15 methods
// Required methods
fn point_tape(
&self,
storage: Self::TapeStorage
) -> <Self::PointEval as TracingEvaluator>::Tape;
fn interval_tape(
&self,
storage: Self::TapeStorage
) -> <Self::IntervalEval as TracingEvaluator>::Tape;
fn float_slice_tape(
&self,
storage: Self::TapeStorage
) -> <Self::FloatSliceEval as BulkEvaluator>::Tape;
fn grad_slice_tape(
&self,
storage: Self::TapeStorage
) -> <Self::GradSliceEval as BulkEvaluator>::Tape;
fn simplify(
&self,
trace: &Self::Trace,
storage: Self::Storage,
workspace: &mut Self::Workspace
) -> Result<Self, Error>
where Self: Sized;
fn recycle(self) -> Option<Self::Storage>;
fn size(&self) -> usize;
fn tile_sizes_3d() -> &'static [usize];
fn tile_sizes_2d() -> &'static [usize];
fn apply_transform(
self,
mat: Matrix4<f32>
) -> <Self as Shape>::TransformedShape;
// Provided methods
fn new_point_eval() -> Self::PointEval { ... }
fn new_interval_eval() -> Self::IntervalEval { ... }
fn new_float_slice_eval() -> Self::FloatSliceEval { ... }
fn new_grad_slice_eval() -> Self::GradSliceEval { ... }
fn simplify_tree_during_meshing(_d: usize) -> bool { ... }
}Expand description
A shape represents an implicit surface
It is mostly agnostic to how that surface is represented; we simply require that the shape can generate evaluators of various kinds.
Shapes are shared between threads, so they should be cheap to clone. In
most cases, they’re a thin wrapper around an Arc<..>.
Required Associated Types§
sourcetype Trace: Clone + Eq + Send + Trace
type Trace: Clone + Eq + Send + Trace
Associated type traces collected during tracing evaluation
sourcetype TapeStorage: Default + Send
type TapeStorage: Default + Send
Associated type for storage used by tapes
For simplicity, we require that every tape use the same type for storage. This could change in the future!
sourcetype PointEval: TracingEvaluator<Data = f32, Trace = Self::Trace, TapeStorage = Self::TapeStorage> + Send + Sync
type PointEval: TracingEvaluator<Data = f32, Trace = Self::Trace, TapeStorage = Self::TapeStorage> + Send + Sync
Associated type for single-point tracing evaluation
sourcetype IntervalEval: TracingEvaluator<Data = Interval, Trace = Self::Trace, TapeStorage = Self::TapeStorage> + Send + Sync
type IntervalEval: TracingEvaluator<Data = Interval, Trace = Self::Trace, TapeStorage = Self::TapeStorage> + Send + Sync
Associated type for single interval tracing evaluation
sourcetype FloatSliceEval: BulkEvaluator<Data = f32, TapeStorage = Self::TapeStorage> + Send + Sync
type FloatSliceEval: BulkEvaluator<Data = f32, TapeStorage = Self::TapeStorage> + Send + Sync
Associated type for evaluating many points in one call
sourcetype GradSliceEval: BulkEvaluator<Data = Grad, TapeStorage = Self::TapeStorage> + Send + Sync
type GradSliceEval: BulkEvaluator<Data = Grad, TapeStorage = Self::TapeStorage> + Send + Sync
Associated type for evaluating many gradients in one call
sourcetype TransformedShape: Shape
type TransformedShape: Shape
Associated type returned when applying a transform
This is normally TransformedShape<Self>, but if
Self is already TransformedShape, then the transform is stacked
(instead of creating a wrapped object).
Required Methods§
sourcefn point_tape(
&self,
storage: Self::TapeStorage
) -> <Self::PointEval as TracingEvaluator>::Tape
fn point_tape( &self, storage: Self::TapeStorage ) -> <Self::PointEval as TracingEvaluator>::Tape
Returns an evaluation tape for a point evaluator
sourcefn interval_tape(
&self,
storage: Self::TapeStorage
) -> <Self::IntervalEval as TracingEvaluator>::Tape
fn interval_tape( &self, storage: Self::TapeStorage ) -> <Self::IntervalEval as TracingEvaluator>::Tape
Returns an evaluation tape for an interval evaluator
sourcefn float_slice_tape(
&self,
storage: Self::TapeStorage
) -> <Self::FloatSliceEval as BulkEvaluator>::Tape
fn float_slice_tape( &self, storage: Self::TapeStorage ) -> <Self::FloatSliceEval as BulkEvaluator>::Tape
Returns an evaluation tape for a float slice evaluator
sourcefn grad_slice_tape(
&self,
storage: Self::TapeStorage
) -> <Self::GradSliceEval as BulkEvaluator>::Tape
fn grad_slice_tape( &self, storage: Self::TapeStorage ) -> <Self::GradSliceEval as BulkEvaluator>::Tape
Returns an evaluation tape for a float slice evaluator
sourcefn simplify(
&self,
trace: &Self::Trace,
storage: Self::Storage,
workspace: &mut Self::Workspace
) -> Result<Self, Error>where
Self: Sized,
fn simplify(
&self,
trace: &Self::Trace,
storage: Self::Storage,
workspace: &mut Self::Workspace
) -> Result<Self, Error>where
Self: Sized,
Computes a simplified tape using the given trace, and reusing storage
sourcefn recycle(self) -> Option<Self::Storage>
fn recycle(self) -> Option<Self::Storage>
Attempt to reclaim storage from this shape
This may fail, because shapes are Clone and are often implemented
using an Arc around a heavier data structure.
sourcefn size(&self) -> usize
fn size(&self) -> usize
Returns a size associated with this shape
This is underspecified and only used for unit testing; for tape-based shapes, it’s typically the length of the tape,
sourcefn tile_sizes_3d() -> &'static [usize]
fn tile_sizes_3d() -> &'static [usize]
Recommended tile sizes for 3D rendering
sourcefn tile_sizes_2d() -> &'static [usize]
fn tile_sizes_2d() -> &'static [usize]
Recommended tile sizes for 2D rendering
sourcefn apply_transform(self, mat: Matrix4<f32>) -> <Self as Shape>::TransformedShape
fn apply_transform(self, mat: Matrix4<f32>) -> <Self as Shape>::TransformedShape
Returns a shape with the given transform applied
Provided Methods§
sourcefn new_point_eval() -> Self::PointEval
fn new_point_eval() -> Self::PointEval
Builds a new point evaluator
sourcefn new_interval_eval() -> Self::IntervalEval
fn new_interval_eval() -> Self::IntervalEval
Builds a new interval evaluator
sourcefn new_float_slice_eval() -> Self::FloatSliceEval
fn new_float_slice_eval() -> Self::FloatSliceEval
Builds a new float slice evaluator
sourcefn new_grad_slice_eval() -> Self::GradSliceEval
fn new_grad_slice_eval() -> Self::GradSliceEval
Builds a new gradient slice evaluator
sourcefn simplify_tree_during_meshing(_d: usize) -> bool
fn simplify_tree_during_meshing(_d: usize) -> bool
Indicates whether we run tape simplification at the given cell depth during meshing.
By default, this is always true; for evaluators where simplification is more expensive than evaluation (i.e. the JIT), it may only be true at certain depths.