pub trait Geometry: Sync {
// Required methods
fn n_materials(&self) -> usize;
fn material(&self, index: usize) -> &Material;
fn n_regions(&self) -> usize;
fn material_index(&self, region: usize) -> usize;
fn locate(&self, pos: [f64; 3]) -> Option<usize>;
fn entry_point(&self) -> [f64; 3];
fn exit(
&self,
region: usize,
pos: [f64; 3],
dir: [f64; 3],
limit: f64,
) -> Option<Exit>;
fn in_vacuum(&self, pos: [f64; 3]) -> bool;
// Provided methods
fn flight(
&self,
region: usize,
pos: [f64; 3],
dir: [f64; 3],
limit: f64,
) -> Flight { ... }
fn as_stack(&self) -> Option<&Stack> { ... }
}Expand description
The engine-facing description of a target. See the module docs for the
contract. Implemented by Stack, VoxelGrid, MeshGeometry and
CsgGeometry.
Required Methods§
Sourcefn n_materials(&self) -> usize
fn n_materials(&self) -> usize
Number of distinct materials.
Sourcefn material_index(&self, region: usize) -> usize
fn material_index(&self, region: usize) -> usize
Index of the material filling region.
Sourcefn locate(&self, pos: [f64; 3]) -> Option<usize>
fn locate(&self, pos: [f64; 3]) -> Option<usize>
The region containing pos, or None outside the target (or for a
non-finite position). Ownership of shared faces: see the module docs.
Sourcefn entry_point(&self) -> [f64; 3]
fn entry_point(&self) -> [f64; 3]
Sourcefn exit(
&self,
region: usize,
pos: [f64; 3],
dir: [f64; 3],
limit: f64,
) -> Option<Exit>
fn exit( &self, region: usize, pos: [f64; 3], dir: [f64; 3], limit: f64, ) -> Option<Exit>
The first event along the straight flight from pos (inside region,
or on one of its faces) in the unit direction dir, if it happens at
a path length of at most limit; otherwise None. The event is a
change of material, a periodic wrap, or leaving the target.
dir must be a finite unit vector; a zero or non-finite direction
returns None.
Provided Methods§
Sourcefn flight(
&self,
region: usize,
pos: [f64; 3],
dir: [f64; 3],
limit: f64,
) -> Flight
fn flight( &self, region: usize, pos: [f64; 3], dir: [f64; 3], limit: f64, ) -> Flight
Geometry::exit, also reporting the region the flight ends in when
there is no event, so a transport engine can keep its particle’s
region consistent with its position after crossing same-material
faces. The default suits a geometry whose regions are each a whole
material run along every flight (a Stack, where leaving a layer is
always an event): without an event the region is unchanged.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".