The SKIRT project
advanced radiative transfer for astrophysics
Public Member Functions | Protected Types | Protected Member Functions | Private Attributes | List of all members
PathSegmentGenerator Class Referenceabstract

#include <PathSegmentGenerator.hpp>

Public Member Functions

 PathSegmentGenerator ()
 
virtual ~PathSegmentGenerator ()
 
double ds ()
 
int m ()
 
virtual bool next ()=0
 
void start (const SpatialGridPath *path)
 
void start (Position bfr, Direction bfk)
 

Protected Types

enum class  State { Unknown , Inside , Outside }
 

Protected Member Functions

Direction k ()
 
double kx () const
 
double ky () const
 
double kz () const
 
bool moveInside (const Box &box, double eps)
 
void propagater (double ds)
 
void propagaterx (double ds)
 
void propagatery (double ds)
 
void propagaterz (double ds)
 
void propagateToNextAfter ()
 
Position r ()
 
double rx () const
 
double ry () const
 
double rz () const
 
void setEmptySegment (double ds=0.)
 
void setrx (double rx)
 
void setry (double ry)
 
void setrz (double rz)
 
void setSegment (int m, double ds)
 
void setState (State state)
 
State state () const
 

Private Attributes

double _ds
 
double _kx
 
double _ky
 
double _kz
 
int _m
 
double _rx
 
double _ry
 
double _rz
 
State _state
 

Detailed Description

PathSegmentGenerator is the abstract base class for classes that calculate and return the segments of a path through a spatial grid segment by segment. This base class offers the public interface for obtaining the segments one by one after initializing the path with a given starting position and direction. A subclass must be provided for each type of spatial grid. Usually, this subclass is implemented as a private class inside the corresponding SpatialGrid subclass.

In addition to the public interface, the PathSegmentGenerator class also offers facilities for use by subclasses. These include functions to access the position and direction of the path, to set the cell index and path length for the next segment, and to help track the state of the generator.

Member Enumeration Documentation

◆ State

enum class PathSegmentGenerator::State
strongprotected

This enumeration lists the states that are passed through by most path segment generators. The start() function sets the state to Unknown.

Constructor & Destructor Documentation

◆ PathSegmentGenerator()

PathSegmentGenerator::PathSegmentGenerator ( )
inline

The constructor creates a path segment generator initialized to an invalid path. To start path segment generation, call the start() function.

◆ ~PathSegmentGenerator()

virtual PathSegmentGenerator::~PathSegmentGenerator ( )
inlinevirtual

The destructor does what it is expected to do.

Member Function Documentation

◆ ds()

double PathSegmentGenerator::ds ( )
inline

This function returns the length of the current path segment inside the spatial cell crossed by the segment. The value is defined only after a call to the next() function returned true.

◆ k()

Direction PathSegmentGenerator::k ( )
inlineprotected

This function returns the path's direction. This value is initialized by the start() function and remains immutable during segment generation for the path.

◆ kx()

double PathSegmentGenerator::kx ( ) const
inlineprotected

This function returns the x component of the path's direction. This value is initialized by the start() function and remains immutable during segment generation for the path.

◆ ky()

double PathSegmentGenerator::ky ( ) const
inlineprotected

This function returns the y component of the path's direction. This value is initialized by the start() function and remains immutable during segment generation for the path.

◆ kz()

double PathSegmentGenerator::kz ( ) const
inlineprotected

This function returns the z component of the path's direction. This value is initialized by the start() function and remains immutable during segment generation for the path.

◆ m()

int PathSegmentGenerator::m ( )
inline

This function returns the index of the spatial cell crossed by the current path segment. The value is defined only after a call to the next() function returned true.

◆ moveInside()

bool PathSegmentGenerator::moveInside ( const Box box,
double  eps 
)
protected

This function calculates the segment needed to advance the path along its direction from its current position to the closest position inside the specified box (a cuboid aligned with the coordinate axes).

If the path does not intersect the box, the function returns false. In that case, the state is set to Outside and no segment is available (the path position and segment values are undefined). If the original position is inside the box or the path does intersect the box, the function returns true. In that case, the state is set to Inside, the position is adjusted to be inside the box if necessary, the segment cell index is set to -1 indicating a segment outside of the box, and the segment length is set to the distance between the new and original positions. If the original position was inside the box, the segment length is set to zero.

◆ next()

virtual bool PathSegmentGenerator::next ( )
pure virtual

This function calculates the next path segment and stores its cell index and path length in data members that can be accessed through the m() and ds() functions. It should be called only after the path has been intialized through the start() function. The next() function returns true if a path segment is available and false if there are no more segments in the path. In the latter case, the values returned by the m() and ds() functions are undefined.

This function must be implemented by each subclass.

◆ propagater()

void PathSegmentGenerator::propagater ( double  ds)
inlineprotected

This function advances the path's position along the path's direction for the specified distance.

◆ propagaterx()

void PathSegmentGenerator::propagaterx ( double  ds)
inlineprotected

This function advances the x component of the path's position along the path's direction for the specified distance.

◆ propagatery()

void PathSegmentGenerator::propagatery ( double  ds)
inlineprotected

This function advances the y component of the path's position along the path's direction for the specified distance.

◆ propagaterz()

void PathSegmentGenerator::propagaterz ( double  ds)
inlineprotected

This function advances the z component of the path's position along the path's direction for the specified distance.

◆ propagateToNextAfter()

void PathSegmentGenerator::propagateToNextAfter ( )
inlineprotected

This function advances each component of the path's position to the next representable double-precision flaoting point number in the path's direction.

◆ r()

Position PathSegmentGenerator::r ( )
inlineprotected

This function returns the path's position. This value is initialized by the start() function and can be updated from a subclass through various functions offered by this base class.

◆ rx()

double PathSegmentGenerator::rx ( ) const
inlineprotected

This function returns the x component of the path's position. This value is initialized by the start() function and can be updated from a subclass through various functions offered by this base class.

◆ ry()

double PathSegmentGenerator::ry ( ) const
inlineprotected

This function returns the y component of the path's position. This value is initialized by the start() function and can be updated from a subclass through various functions offered by this base class.

◆ rz()

double PathSegmentGenerator::rz ( ) const
inlineprotected

This function returns the y component of the path's position. This value is initialized by the start() function and can be updated from a subclass through various functions offered by this base class.

◆ setEmptySegment()

void PathSegmentGenerator::setEmptySegment ( double  ds = 0.)
inlineprotected

This function sets the information for the current path segment to a cell number of -1, indicating a path segment outside of the grid, and the specified segment length. If the argument is omitted, a length of zero is assumed.

◆ setrx()

void PathSegmentGenerator::setrx ( double  rx)
inlineprotected

This function sets the x component of the path's position to the specified value.

◆ setry()

void PathSegmentGenerator::setry ( double  ry)
inlineprotected

This function sets the y component of the path's position to the specified value.

◆ setrz()

void PathSegmentGenerator::setrz ( double  rz)
inlineprotected

This function sets the z component of the path's position to the specified value.

◆ setSegment()

void PathSegmentGenerator::setSegment ( int  m,
double  ds 
)
inlineprotected

This function sets the information for the current path segment to the specified cell number and segment length.

◆ setState()

void PathSegmentGenerator::setState ( State  state)
inlineprotected

This function sets the current state of the generator to the specified value.

◆ start() [1/2]

void PathSegmentGenerator::start ( const SpatialGridPath path)
inline

This function initializes path segment generation for the starting position \({\bf{r}}\) and the direction \({\bf{k}}\) specified by the SpatialGridPath instance passed as an argument. The function must be called before calling the next() function for the first time, or to re-initialize the generator for a fresh path.

◆ start() [2/2]

void PathSegmentGenerator::start ( Position  bfr,
Direction  bfk 
)
inline

This function initializes path segment generation for the specified starting position \({\bf{r}}\) and direction \({\bf{k}}\). The function must be called before calling the next() function for the first time, or to re-initialize the generator for a fresh path.

◆ state()

State PathSegmentGenerator::state ( ) const
inlineprotected

This function returns the current state of the generator.


The documentation for this class was generated from the following file: