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. | |
Structure that defines a three dimensional shape such as width, height and depth.
|
inline |
Constructor for shape3.
[in] | gn | Array that defines numbers of the shape. |
|
inline |
Constructor for shape2.
[in] | w | Width. |
[in] | h | Height. |
[in] | d | Depth. |
|
inline |
Get the world coordinate size of the shape.
[in] | Grid | cell size. |
Get the new constrained position within the index space of this shape.
[in] | pi | Input position. |
|
inline |
Get the new constrained position within the index space of this shape.
[in] | i | Input position on x coordinate. |
[in] | j | Input position on y coordinate. |
|
inline |
Count the number of cells of the grid of this shape.
|
inline |
Decode from an integer to an index coordinate.
value | Encoded value. |
|
inline |
Get the shape of edge of a specified dimension from this shape.
[in] | dim | Input dimension. |
|
inline |
Get if all the lengthes of this shape is zero.
true
if the shape is empty false
otherwise.
|
inline |
Encode an index position to an integer.
pi | Index coordinate. |
|
inline |
Encode an index position to an integer.
i | Index coordinate on X axis. |
j | Index coordinate on Y axis. |
k | Index coordinate on Z axis. |
|
inline |
Get the shape for the staggered grid of a specified dimension from this shape.
[in] | dim | Input dimension. |
Find the nearest cell position from the input fractional position.
[in] | p | Fractional input position. |
Find the nearest edge position from the input fractional position.
[in] | p | Fractional input position. |
Find the nearest facial position (in the context of staggered grid) from the input fractional position.
[in] | p | Fractional input position. |
Find the nearest nodal position from the input fractional position.
[in] | p | Fractional input position. |
|
inline |
Perform a three dimensional serial loop operation.
[in] | func | Function that processes a loop. |
|
inline |
Get the dimensional numbers of this shape.
[out] | w | Width. |
[out] | h | Height. |
[out] | d | Depth. |
|
inline |
Get the dimensional numbers of this shape.
[out] | gn | One dimensional array that stores width, height and depth in this order. |
|
inline |
Perform a serial loop operation.
[in] | func | Function that processes a loop. If the function return true , the loop interrupts. |
|
inline |
Get if the position lies on the edge of the index space of this shape.
[in] | pi | Input position. |
true
if the input position lies on the edge of the index space, false
otherwise.
|
inline |
Get if the position lies on the edge of the index space of this shape.
[in] | i | Input position on x coordinate. |
[in] | j | Input position on y coordinate. |
[in] | k | Input position on z coordinate. |
true
if the input position lies on the edge of the index space, false
otherwise.
|
inline |
Get if this shape is different from the input shape.
[in] | shape | Shape to compare. |
|
inline |
Get a scaled shape by the input number.
[in] | s | Scaling factor. |
|
inline |
Scale this shape by the input number.
[in] | s | Scaling factor. |
Get an expanded shape by the input shape.
[in] | rhs | Input shape. |
|
inline |
Expand this shape by the input shape.
[in] | rhs | Input shape. |
Get an shrunk shape by the input shape.
[in] | rhs | Input shape. |
|
inline |
Shrink the shape by the input shape.
[in] | rhs | Input shape. |
|
inline |
Get a scaled (by division) shape by the input number.
[in] | s | Scaling factor. |
|
inline |
Scale this shape (by division) by the input number.
[in] | s | Scaling factor. |
|
inline |
Compare the hash from the input shape.
[in] | rhs | Shape to compare the hash. |
|
inline |
Get if this shape is equal to the input shape.
[in] | shape | Shape to compare. |
|
inline |
Get the writable number of a specified dimensional of this shape.
[in] | idx | Number of dimension. |
|
inline |
Get the number of a specified dimensional of this shape.
[in] | idx | Number of dimension. |
|
inline |
Get if the position is outside of the index space of this shape.
[in] | pi | Input position. |
true
if the input position is outside of the index space, false
otherwise.
|
inline |
Get if the position is outside of the index space of this shape.
[in] | i | Input position on x coordinate. |
[in] | j | Input position on y coordinate. |
[in] | k | Input position on z coordinate. |
true
if the input position is outside of the index space, false
otherwise.