Shiokaze Framework
A research-oriented fluid solver for computer graphics
shape3 Struct Reference

Structure that defines a three dimensional shape such as width, height and depth. More...

#include <shape.h>

Public Member Functions

 shape3 (const unsigned gn[DIM2])
 Constructor for shape3. More...
 
 shape3 (unsigned w, unsigned h, unsigned d)
 Constructor for shape2. More...
 
 shape3 ()
 Constructor for shape3.
 
bool operator== (const shape3 &shape) const
 Get if this shape is equal to the input shape. More...
 
bool operator!= (const shape3 &shape) const
 Get if this shape is different from the input shape. More...
 
unsigned operator[] (unsigned idx) const
 Get the number of a specified dimensional of this shape. More...
 
unsigned & operator[] (unsigned idx)
 Get the writable number of a specified dimensional of this shape. More...
 
shape3 operator+ (const shape3 &rhs) const
 Get an expanded shape by the input shape. More...
 
void operator+= (const shape3 &rhs)
 Expand this shape by the input shape. More...
 
shape3 operator- (const shape3 &rhs) const
 Get an shrunk shape by the input shape. More...
 
void operator-= (const shape3 &rhs)
 Shrink the shape by the input shape. More...
 
shape3 operator* (double s) const
 Get a scaled shape by the input number. More...
 
void operator*= (double v)
 Scale this shape by the input number. More...
 
shape3 operator/ (double s) const
 Get a scaled (by division) shape by the input number. More...
 
void operator/= (double v)
 Scale this shape (by division) by the input number. More...
 
void get (unsigned &w, unsigned &h, unsigned &d) const
 Get the dimensional numbers of this shape. More...
 
void get (unsigned gn[DIM3]) const
 Get the dimensional numbers of this shape. More...
 
vec3d box (double dx) const
 Get the world coordinate size of the shape. More...
 
bool operator< (const shape2 &rhs) const
 Compare the hash from the input shape. More...
 
size_t hash () const
 Get the hash number of this shape.
 
shape3 cell () const
 Get the shape for the cell-centered grid from this shape.
 
shape3 nodal () const
 Get the shape for the nodal defined grid from this shape.
 
shape3 face (int dim) const
 Get the shape for the staggered grid of a specified dimension from this shape. More...
 
shape3 edge (int dim) const
 Get the shape of edge of a specified dimension from this shape. More...
 
vec3i find_cell (const vec3d &p) const
 Find the nearest cell position from the input fractional position. More...
 
template<class T >
vec3i find_node (const vec3< T > &p) const
 Find the nearest nodal position from the input fractional position. More...
 
template<class T >
vec3i find_edge (const vec3< T > &p, unsigned dim) const
 Find the nearest edge position from the input fractional position. More...
 
template<class T >
vec3i find_face (const vec3< T > &p, unsigned dim) const
 Find the nearest facial position (in the context of staggered grid) from the input fractional position. More...
 
double dx () const
 Get the length of grid cell size.
 
unsigned max () const
 Get the maximal number in all the dimensions.
 
vec3i clamp (const vec3i &pi) const
 Get the new constrained position within the index space of this shape. More...
 
vec3i clamp (int i, int j, int k) const
 Get the new constrained position within the index space of this shape. More...
 
bool out_of_bounds (int i, int j, int k) const
 Get if the position is outside of the index space of this shape. More...
 
bool out_of_bounds (const vec3i &pi) const
 Get if the position is outside of the index space of this shape. More...
 
bool on_edge (int i, int j, int k) const
 Get if the position lies on the edge of the index space of this shape. More...
 
bool on_edge (const vec3i &pi) const
 Get if the position lies on the edge of the index space of this shape. More...
 
size_t count () const
 Count the number of cells of the grid of this shape. More...
 
bool empty () const
 Get if all the lengthes of this shape is zero. More...
 
size_t encode (int i, int j, int k) const
 Encode an index position to an integer. More...
 
size_t encode (const vec3i &pi) const
 Encode an index position to an integer. More...
 
vec3i decode (size_t value) const
 Decode from an integer to an index coordinate. More...
 
void for_each (std::function< void(int i, int j, int k)> func) const
 Perform a three dimensional serial loop operation. More...
 
void interruptible_for_each (std::function< bool(int i, int j, int k)> func) const
 Perform a serial loop operation. More...
 

Public Attributes

unsigned w
 Width of the shape.
 
unsigned h
 Height of the shape.
 
unsigned d
 Depth of the shape.
 

Detailed Description

Structure that defines a three dimensional shape such as width, height and depth.

Constructor & Destructor Documentation

◆ shape3() [1/2]

shape3::shape3 ( const unsigned  gn[DIM2])
inline

Constructor for shape3.

Parameters
[in]gnArray that defines numbers of the shape.

◆ shape3() [2/2]

shape3::shape3 ( unsigned  w,
unsigned  h,
unsigned  d 
)
inline

Constructor for shape2.

Parameters
[in]wWidth.
[in]hHeight.
[in]dDepth.

Member Function Documentation

◆ box()

vec3d shape3::box ( double  dx) const
inline

Get the world coordinate size of the shape.

Parameters
[in]Gridcell size.
Returns
Maximal corner position.

◆ clamp() [1/2]

vec3i shape3::clamp ( const vec3i pi) const
inline

Get the new constrained position within the index space of this shape.

Parameters
[in]piInput position.
Returns
Constrained new position.

◆ clamp() [2/2]

vec3i shape3::clamp ( int  i,
int  j,
int  k 
) const
inline

Get the new constrained position within the index space of this shape.

Parameters
[in]iInput position on x coordinate.
[in]jInput position on y coordinate.
Returns
Constrained new position.

◆ count()

size_t shape3::count ( ) const
inline

Count the number of cells of the grid of this shape.

Returns
The number of total elements.

◆ decode()

vec3i shape3::decode ( size_t  value) const
inline

Decode from an integer to an index coordinate.

Returns
Decoded coordinate position.
Parameters
valueEncoded value.

◆ edge()

shape3 shape3::edge ( int  dim) const
inline

Get the shape of edge of a specified dimension from this shape.

Parameters
[in]dimInput dimension.

◆ empty()

bool shape3::empty ( ) const
inline

Get if all the lengthes of this shape is zero.

Returns
true if the shape is empty false otherwise.

◆ encode() [1/2]

size_t shape3::encode ( const vec3i pi) const
inline

Encode an index position to an integer.

Returns
Encoded integer.
Parameters
piIndex coordinate.

◆ encode() [2/2]

size_t shape3::encode ( int  i,
int  j,
int  k 
) const
inline

Encode an index position to an integer.

Returns
Encoded integer.
Parameters
iIndex coordinate on X axis.
jIndex coordinate on Y axis.
kIndex coordinate on Z axis.

◆ face()

shape3 shape3::face ( int  dim) const
inline

Get the shape for the staggered grid of a specified dimension from this shape.

Parameters
[in]dimInput dimension.

◆ find_cell()

vec3i shape3::find_cell ( const vec3d p) const
inline

Find the nearest cell position from the input fractional position.

Parameters
[in]pFractional input position.

◆ find_edge()

template<class T >
vec3i shape3::find_edge ( const vec3< T > &  p,
unsigned  dim 
) const
inline

Find the nearest edge position from the input fractional position.

Parameters
[in]pFractional input position.

◆ find_face()

template<class T >
vec3i shape3::find_face ( const vec3< T > &  p,
unsigned  dim 
) const
inline

Find the nearest facial position (in the context of staggered grid) from the input fractional position.

Parameters
[in]pFractional input position.

◆ find_node()

template<class T >
vec3i shape3::find_node ( const vec3< T > &  p) const
inline

Find the nearest nodal position from the input fractional position.

Parameters
[in]pFractional input position.

◆ for_each()

void shape3::for_each ( std::function< void(int i, int j, int k)>  func) const
inline

Perform a three dimensional serial loop operation.

Parameters
[in]funcFunction that processes a loop.

◆ get() [1/2]

void shape3::get ( unsigned &  w,
unsigned &  h,
unsigned &  d 
) const
inline

Get the dimensional numbers of this shape.

Parameters
[out]wWidth.
[out]hHeight.
[out]dDepth.

◆ get() [2/2]

void shape3::get ( unsigned  gn[DIM3]) const
inline

Get the dimensional numbers of this shape.

Parameters
[out]gnOne dimensional array that stores width, height and depth in this order.

◆ interruptible_for_each()

void shape3::interruptible_for_each ( std::function< bool(int i, int j, int k)>  func) const
inline

Perform a serial loop operation.

Parameters
[in]funcFunction that processes a loop. If the function return true, the loop interrupts.

◆ on_edge() [1/2]

bool shape3::on_edge ( const vec3i pi) const
inline

Get if the position lies on the edge of the index space of this shape.

Parameters
[in]piInput position.
Returns
true if the input position lies on the edge of the index space, false otherwise.

◆ on_edge() [2/2]

bool shape3::on_edge ( int  i,
int  j,
int  k 
) const
inline

Get if the position lies on the edge of the index space of this shape.

Parameters
[in]iInput position on x coordinate.
[in]jInput position on y coordinate.
[in]kInput position on z coordinate.
Returns
true if the input position lies on the edge of the index space, false otherwise.

◆ operator!=()

bool shape3::operator!= ( const shape3 shape) const
inline

Get if this shape is different from the input shape.

Parameters
[in]shapeShape to compare.

◆ operator*()

shape3 shape3::operator* ( double  s) const
inline

Get a scaled shape by the input number.

Parameters
[in]sScaling factor.
Returns
Scaled shape.

◆ operator*=()

void shape3::operator*= ( double  v)
inline

Scale this shape by the input number.

Parameters
[in]sScaling factor.

◆ operator+()

shape3 shape3::operator+ ( const shape3 rhs) const
inline

Get an expanded shape by the input shape.

Parameters
[in]rhsInput shape.
Returns
Expanded shape.

◆ operator+=()

void shape3::operator+= ( const shape3 rhs)
inline

Expand this shape by the input shape.

Parameters
[in]rhsInput shape.

◆ operator-()

shape3 shape3::operator- ( const shape3 rhs) const
inline

Get an shrunk shape by the input shape.

Parameters
[in]rhsInput shape.
Returns
Shrunk shape.

◆ operator-=()

void shape3::operator-= ( const shape3 rhs)
inline

Shrink the shape by the input shape.

Parameters
[in]rhsInput shape.

◆ operator/()

shape3 shape3::operator/ ( double  s) const
inline

Get a scaled (by division) shape by the input number.

Parameters
[in]sScaling factor.
Returns
Scaled shape.

◆ operator/=()

void shape3::operator/= ( double  v)
inline

Scale this shape (by division) by the input number.

Parameters
[in]sScaling factor.

◆ operator<()

bool shape3::operator< ( const shape2 rhs) const
inline

Compare the hash from the input shape.

Parameters
[in]rhsShape to compare the hash.

◆ operator==()

bool shape3::operator== ( const shape3 shape) const
inline

Get if this shape is equal to the input shape.

Parameters
[in]shapeShape to compare.

◆ operator[]() [1/2]

unsigned& shape3::operator[] ( unsigned  idx)
inline

Get the writable number of a specified dimensional of this shape.

Parameters
[in]idxNumber of dimension.

◆ operator[]() [2/2]

unsigned shape3::operator[] ( unsigned  idx) const
inline

Get the number of a specified dimensional of this shape.

Parameters
[in]idxNumber of dimension.

◆ out_of_bounds() [1/2]

bool shape3::out_of_bounds ( const vec3i pi) const
inline

Get if the position is outside of the index space of this shape.

Parameters
[in]piInput position.
Returns
true if the input position is outside of the index space, false otherwise.

◆ out_of_bounds() [2/2]

bool shape3::out_of_bounds ( int  i,
int  j,
int  k 
) const
inline

Get if the position is outside of the index space of this shape.

Parameters
[in]iInput position on x coordinate.
[in]jInput position on y coordinate.
[in]kInput position on z coordinate.
Returns
true if the input position is outside of the index space, false otherwise.

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