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

Structure that defines shape such as width, height. More...

#include <shape.h>

Public Member Functions

 shape2 (const unsigned gn[DIM2])
 Constructor for shape2. More...
 
 shape2 (unsigned w, unsigned h)
 Constructor for shape2. More...
 
 shape2 ()
 Constructor for shape2.
 
bool operator== (const shape2 &shape) const
 Get if this shape is equal to the input shape. More...
 
bool operator!= (const shape2 &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...
 
shape2 operator+ (const shape2 &rhs) const
 Get an expanded shape by the input shape. More...
 
void operator+= (const shape2 &rhs)
 Expand this shape by the input shape. More...
 
shape2 operator- (const shape2 &rhs) const
 Get an shrunk shape by the input shape. More...
 
void operator-= (const shape2 &rhs)
 Shrink the shape by the input shape. More...
 
shape2 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...
 
shape2 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) const
 Get the dimensional numbers of this shape. More...
 
void get (unsigned gn[DIM2]) const
 Get the dimensional numbers of this shape. More...
 
vec2d 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.
 
shape2 cell () const
 Get the shape for the cell-centered grid from this shape.
 
shape2 nodal () const
 Get the shape for the nodal defined grid from this shape.
 
shape2 face (int dim) const
 Get the shape for the staggered grid of a specified dimension from this shape. More...
 
template<class T >
vec2i find_cell (const vec2< T > &p) const
 Find the nearest cell position from the input fractional position. More...
 
template<class T >
vec2i find_node (const vec2< T > &p) const
 Find the nearest nodal position from the input fractional position. More...
 
template<class T >
vec2i find_face (const vec2< 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.
 
vec2i clamp (const vec2i &pi) const
 Get the new constrained position within the index space of this shape. More...
 
vec2i clamp (int i, int j) const
 Get the new constrained position within the index space of this shape. More...
 
bool out_of_bounds (int i, int j) const
 Get if the position is outside of the index space of this shape. More...
 
bool out_of_bounds (const vec2i &pi) const
 Get if the position is outside of the index space of this shape. More...
 
bool on_edge (int i, int j) const
 Get if the position lies on the edge of the index space of this shape. More...
 
bool on_edge (const vec2i &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) const
 Encode an index position to an integer. More...
 
size_t encode (const vec2i &pi) const
 Encode an index position to an integer. More...
 
vec2i decode (size_t value) const
 Decode from an integer to an index coordinate. More...
 
void for_each (std::function< void(int i, int j)> func) const
 Perform a two dimensional serial loop operation. More...
 
void interruptible_for_each (std::function< bool(int i, int j)> func) const
 Perform a serial loop operation. More...
 

Public Attributes

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

Detailed Description

Structure that defines shape such as width, height.

Structure that defines a two dimensional shape such as width, height.

Constructor & Destructor Documentation

◆ shape2() [1/2]

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

Constructor for shape2.

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

◆ shape2() [2/2]

shape2::shape2 ( unsigned  w,
unsigned  h 
)
inline

Constructor for shape2.

Parameters
[in]wWidth.
[in]hHeight.

Member Function Documentation

◆ box()

vec2d shape2::box ( double  dx) const
inline

Get the world coordinate size of the shape.

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

◆ clamp() [1/2]

vec2i shape2::clamp ( const vec2i 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]

vec2i shape2::clamp ( int  i,
int  j 
) 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 shape2::count ( ) const
inline

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

Returns
The number of total elements.

◆ decode()

vec2i shape2::decode ( size_t  value) const
inline

Decode from an integer to an index coordinate.

Returns
Decoded coordinate position.
Parameters
valueEncoded value.

◆ empty()

bool shape2::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 shape2::encode ( const vec2i pi) const
inline

Encode an index position to an integer.

Returns
Encoded integer.
Parameters
piIndex coordinate.

◆ encode() [2/2]

size_t shape2::encode ( int  i,
int  j 
) const
inline

Encode an index position to an integer.

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

◆ face()

shape2 shape2::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()

template<class T >
vec2i shape2::find_cell ( const vec2< T > &  p) const
inline

Find the nearest cell position from the input fractional position.

Parameters
[in]pFractional input position.

◆ find_face()

template<class T >
vec2i shape2::find_face ( const vec2< 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 >
vec2i shape2::find_node ( const vec2< T > &  p) const
inline

Find the nearest nodal position from the input fractional position.

Parameters
[in]pFractional input position.

◆ for_each()

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

Perform a two dimensional serial loop operation.

Parameters
[in]funcFunction that processes a loop.

◆ get() [1/2]

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

Get the dimensional numbers of this shape.

Parameters
[out]wWidth.
[out]hHeight.

◆ get() [2/2]

void shape2::get ( unsigned  gn[DIM2]) const
inline

Get the dimensional numbers of this shape.

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

◆ interruptible_for_each()

void shape2::interruptible_for_each ( std::function< bool(int i, int j)>  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 shape2::on_edge ( const vec2i 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 shape2::on_edge ( int  i,
int  j 
) 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.
Returns
true if the input position lies on the edge of the index space, false otherwise.

◆ operator!=()

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

Get if this shape is different from the input shape.

Parameters
[in]shapeShape to compare.

◆ operator*()

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

Get a scaled shape by the input number.

Parameters
[in]sScaling factor.
Returns
Scaled shape.

◆ operator*=()

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

Scale this shape by the input number.

Parameters
[in]sScaling factor.

◆ operator+()

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

Get an expanded shape by the input shape.

Parameters
[in]rhsInput shape.
Returns
Expanded shape.

◆ operator+=()

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

Expand this shape by the input shape.

Parameters
[in]rhsInput shape.

◆ operator-()

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

Get an shrunk shape by the input shape.

Parameters
[in]rhsInput shape.
Returns
Shrunk shape.

◆ operator-=()

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

Shrink the shape by the input shape.

Parameters
[in]rhsInput shape.

◆ operator/()

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

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

Parameters
[in]sScaling factor.
Returns
Scaled shape.

◆ operator/=()

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

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

Parameters
[in]sScaling factor.

◆ operator<()

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

Compare the hash from the input shape.

Parameters
[in]rhsShape to compare the hash.

◆ operator==()

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

Get if this shape is equal to the input shape.

Parameters
[in]shapeShape to compare.

◆ operator[]() [1/2]

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

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

Parameters
[in]idxNumber of dimension.

◆ operator[]() [2/2]

unsigned shape2::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 shape2::out_of_bounds ( const vec2i 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 shape2::out_of_bounds ( int  i,
int  j 
) 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.
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: