Skip to main content

Geometry

Trait Geometry 

Source
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§

Source

fn n_materials(&self) -> usize

Number of distinct materials.

Source

fn material(&self, index: usize) -> &Material

Material index (0..n_materials()).

Source

fn n_regions(&self) -> usize

Number of regions.

Source

fn material_index(&self, region: usize) -> usize

Index of the material filling region.

Source

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.

Source

fn entry_point(&self) -> [f64; 3]

Where a beam enters by default: the origin for a Stack, the centre of the front face for a VoxelGrid.

Source

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.

Source

fn in_vacuum(&self, pos: [f64; 3]) -> bool

Whether pos lies outside the target in vacuum, used to skip weak- collision partners that would lie beyond a surface. For a Stack this is in front of the front face only (as in the M0 engine).

Provided Methods§

Source

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.

Source

fn as_stack(&self) -> Option<&Stack>

This geometry as a layered Stack, if it is one. Tallies defined per layer (dose, depth-dose, interface transmission) need it.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§