Core 1.0
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
Array Class Reference

A core three dimensional grid structure. More...

#include <array.h>

Inheritance diagram for Array:
Box ArrayIndex DynamicArrayIndex ScalarField VectorField Voxel

Public Member Functions

 Array ()
 Empty. More...
 
 Array (const Box &, int, int, int)
 Create the array structure. More...
 
 ~Array ()
 Empty.
 
Array Extract (int, int, int, int, int, int) const
 Extract an sub-array. More...
 
int VertexSize () const
 Return the size of the array.
 
int VertexSize (int) const
 Get the size of the array for every axis. More...
 
Box Cell (int) const
 Return the geometry of the cell. More...
 
Box Cell (int, int, int) const
 Return the geometry of the cell. More...
 
Vector CellCenter (int, int, int) const
 Return the center of the cell. More...
 
void Scale (const Vector &)
 Scales the array structure. More...
 
void Scale (const double &)
 Scales the array structure. More...
 
Box GetBox () const
 Get the box of the array.
 
Vector CellDiagonal () const
 Return the cell diagonal.
 
Vector Vertex (int, int, int) const
 Compute the coordinates of a point on the grid. More...
 
int GetSizeX () const
 Get the size of the array for x axis.
 
int GetSizeY () const
 Get the size of the array for y axis.
 
int GetSizeZ () const
 Get the size of the array for z axis.
 
int CellSize () const
 Return the size of the voxel.
 
int CellSizeX () const
 Get the size of the voxel for x axis.
 
int CellSizeY () const
 Get the size of the voxel for y axis.
 
int CellSizeZ () const
 Get the size of the voxel for z axis.
 
bool IsEmpty () const
 Detect if the array is empty.
 
Box UnitCell () const
 Return the geometry of a generic cell. More...
 
void Resize (const Box &, int, int, int)
 Resize the voxel with the given parameters. More...
 
void VertexInteger (const Vector &, int &, int &, int &) const
 Compute the coordinates of a vertex inside a cell. More...
 
void VertexIntegerVolume (const Box &, int &, int &, int &, int &, int &, int &) const
 Compute the integer coordinates of the vertices of a box embedding an input box. More...
 
void CellInteger (const Vector &, int &, int &, int &) const
 Compute the coordinates of a vertex inside a cell. More...
 
void CellInteger (const Vector &, int &, int &, int &, double &, double &, double &) const
 Compute the point on the grid given an input point. More...
 
void CellIntegerVolume (const Box &, int &, int &, int &, int &, int &, int &) const
 Compute the integer coordinates of the cells of the array embedding an input box. More...
 
int Memory () const
 Compute the size of the array.
 
constexpr int VertexIndex (int, int, int) const
 Compute the index of a given vertex. More...
 
constexpr bool InsideVertexIndex (int, int, int) const
 Check if the indexes are within range. More...
 
constexpr bool InsideCellIndex (int, int, int) const
 Check if the indexes are within range. More...
 
void InverseVertexIndex (int, int &, int &, int &) const
 Compute the coordinates of a given vertex. More...
 
constexpr int CellIndex (int, int, int) const
 Compute the index of a given cell. More...
 
void InverseCellIndex (int, int &, int &, int &) const
 Compute the coordinates of a given cell. More...
 

Static Public Member Functions

static Array CubicCells (Box, int)
 Create an array with enforced cubic cells. More...
 

Protected Attributes

int nz
 Sizes.
 
Vector celldiagonal
 Cell diagonal.
 
Vector inversecelldiagonal
 Inverse cell diagonal.
 
- Protected Attributes inherited from Box
Vector a
 Lower vertex.
 
Vector b
 Upper vertex.
 

Friends

std::ostream & operator<< (std::ostream &, const Array &)
 Overloaded. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Box
 Box ()
 Empty.
 
 Box (const double &)
 Create a cube centered at the origin and of given half side length. More...
 
 Box (const Vector &)
 Create an empty box given one vertex. More...
 
 Box (const Vector &, const Vector &)
 Create a box given two opposite corners. More...
 
 Box (const Vector &, const double &)
 Create a box given a center point and the half side length. More...
 
 Box (const Vector &, const double &, const double &, const double &)
 Create a box given a center point and its width, length, and height. More...
 
 Box (const double &, const double &, const double &)
 Create a box given its sizes. More...
 
 Box (const Vector *, int)
 Creates the bounding box of a set of points. More...
 
 Box (const QVector< Vector > &)
 Creates the bounding box of a set of points. More...
 
 Box (const Box &, const Box &)
 Create a box embedding two boxes. More...
 
 Box (const Box &, const Frame &)
 Creates an axis aligned bounding box from a box and a frame. More...
 
 Box (const Box &, const FrameScaled &)
 Creates an axis aligned bounding box from a box and a frame. More...
 
 Box (const Box &, const Matrix &)
 Creates an axis aligned bounding box from a box and a transformation matrix. More...
 
 ~Box ()
 Empty.
 
Vectoroperator[] (int)
 Returns either end vertex of the box.
 
Vector operator[] (int) const
 Overloaded.
 
Vector Center () const
 Returns the center of the box.
 
Vector Vertex (int) const
 Returns the k-th vertex of the box. More...
 
Vector Vertex (int, int, int, int, int, int) const
 Compute the coordinates of a grid aligned point. More...
 
Segment Edge (int) const
 Compute the k-th edge segment of the box. More...
 
Plane Face (int) const
 Compute the k-th plane of the box. More...
 
Vector Size () const
 Compute the size (width, length and height) of a box. More...
 
Vector Diagonal () const
 Returns the diagonal of the box.
 
double Radius () const
 Returns the radius of the box, i.e. the length of the half diagonal of the box.
 
double R (const Vector &) const
 Computes the squared Euclidean distance between the box and a point. More...
 
double Signed (const Vector &) const
 Computes the signed distance between the box and a point. More...
 
Vector Normal (const Vector &) const
 Computes the normal vector between a point and a box. More...
 
double R (const Box &) const
 Compute the squared Euclidean distance between two boxes. More...
 
double RInfinity (const Box &) const
 Compute the maximum distance between two boxes. More...
 
int Intersect (const Ray &) const
 Check the intersection between a box and a ray. More...
 
int Intersect (const Ray &, double &, double &) const
 Computes the intersection between a box and a ray. More...
 
int Intersect (const Ray &, double &) const
 Compute the first positive intersection between the box and a ray. More...
 
int Intersect (const Ray &, double &, double &, Vector &, Vector &) const
 Compute the intersection between an axis aligned box and a ray. More...
 
int Intersect (const Ray &, double &, Vector &) const
 Compute the first positive intersection between the box and a ray. More...
 
int Intersect (const Vector &, const Vector &) const
 Check if a segment intersects an axis aligned box. More...
 
bool Intersect (const Box &) const
 Check if the box intersects another box. More...
 
bool Inside (const Box &) const
 Check if an argument box is inside the box. More...
 
bool Inside (const Vector &) const
 Check if a point is inside the box. More...
 
Box Intersection (const Box &) const
 Computes the intersection between two boxes. More...
 
int Difference (const Box &, Box *) const
 Computes the difference between two boxes. More...
 
bool Empty () const
 Check if a box is empty. More...
 
double Volume () const
 Compute the volume of a box.
 
double Area () const
 Compute the surface area of a box.
 
void SetCubic ()
 Creates the tightest embedding cube from an arbitrarilly shaped box. More...
 
void SetInscribedCubic ()
 Creates the biggest cube iscribed in the box. More...
 
Box Cube () const
 Return the tightest embedding cube from an arbitrarilly shaped box. More...
 
void Extend (const double &)
 Extend the limits of the box by a given distance. More...
 
Box Extended (const double &) const
 Extend the limits of the box by a given distance. More...
 
void Extend (const Vector &)
 Extend the limits of the box given a point. More...
 
void SetParallelepipedic (const double &, int &, int &, int &)
 Creates a parallelepipedic box whose dimensions are integer multiples of a given input reference size. More...
 
void SetParallelepipedic (int, int &, int &, int &)
 Inflates a box so that its dimensions should be a fraction of its maximum side length. More...
 
Box Sub (int) const
 Computes the sub-box in the n-th octant. More...
 
int Octant (const Vector &) const
 Compute the octant index of a vertex with respect to the box center. More...
 
void Translate (const Vector &)
 Translates a box. More...
 
Box Translated (const Vector &) const
 Translated box. More...
 
void Scale (const double &)
 Scales a box. More...
 
void Scale (const Vector &)
 Scales a box. More...
 
Box Scaled (const Vector &) const
 Scales a box and return the scaled box. More...
 
Box Offsetted (const Vector &) const
 Offets a box. More...
 
Box Centered () const
 Compute the box translated to origin. More...
 
Box Cut (const Vector &, const Vector &) const
 Compute the minimal box embedding the box cut by half space. More...
 
int IntegerAxis () const
 Compute the axis which has the greater length.
 
Vector RandomInside (Random &=Random::R239) const
 Generate a random vector inside the box. More...
 
Vector RandomSurface (Random &=Random::R239) const
 Generate a random vector on the surface of the box. More...
 
QVector< VectorPoisson (const double &, int, Random &=Random::R239) const
 Compute a Poisson sphere distribution inside a box. More...
 
- Static Protected Attributes inherited from Box
static constexpr const double epsilon = 1.0e-5
 Epsilon value used to check intersections and some round off errors and for ray intersection tests.
 
static const Box Infinity
 Largest box. More...
 
static const Box Null
 Null box, equivalent to: More...
 
static const Box Unit
 Unit box.
 
static const int edge [24]
 Edge vertex indexes.
 
static const Vector normal [6]
 Face normals.
 

Detailed Description

A core three dimensional grid structure.

An array is a three-dimensional box virtually decomposed into cells.

Constructor & Destructor Documentation

◆ Array() [1/2]

Array::Array ( )

Empty.

Empty array, with empty box.

◆ Array() [2/2]

Array::Array ( const Box box,
int  x,
int  y,
int  z 
)
explicit

Create the array structure.

Parameters
boxThe box.
x,y,zSize of the array.

Member Function Documentation

◆ Cell() [1/2]

Box Array::Cell ( int  c) const

Return the geometry of the cell.

Parameters
cInteger cell index.

◆ Cell() [2/2]

Box Array::Cell ( int  i,
int  j,
int  k 
) const

Return the geometry of the cell.

Parameters
i,j,kInteger coordinates of the cell.

◆ CellCenter()

Vector Array::CellCenter ( int  i,
int  j,
int  k 
) const

Return the center of the cell.

Parameters
i,j,kInteger coordinates of the cell.

◆ CellIndex()

constexpr int Array::CellIndex ( int  i,
int  j,
int  k 
) const
inlineconstexpr

Compute the index of a given cell.

Parameters
i,j,kInteger coordinates of the cell.

◆ CellInteger() [1/2]

void Array::CellInteger ( const Vector p,
int &  i,
int &  j,
int &  k 
) const
inline

Compute the coordinates of a vertex inside a cell.

Parameters
pPoint.
i,j,kInteger coordinates of the cell.

◆ CellInteger() [2/2]

void Array::CellInteger ( const Vector p,
int &  i,
int &  j,
int &  k,
double &  u,
double &  v,
double &  w 
) const
inline

Compute the point on the grid given an input point.

Parameters
pPoint.
i,j,kInteger coordinates of the cell.
u,v,wCoordinates of the point in the corresponding cell.

◆ CellIntegerVolume()

void Array::CellIntegerVolume ( const Box box,
int &  ax,
int &  ay,
int &  az,
int &  bx,
int &  by,
int &  bz 
) const

Compute the integer coordinates of the cells of the array embedding an input box.

The coordinates are clamped to the size of the array.

Parameters
boxBox.
ax,ay,az,bx,by,bzInteger coordinates of the two points a and b.

◆ CubicCells()

Array Array::CubicCells ( Box  box,
int  n 
)
inlinestatic

Create an array with enforced cubic cells.

Parameters
boxThe box.
nMaximum subdivision.
See also
Box::SetParallelepipedic

◆ Extract()

Array Array::Extract ( int  xa,
int  ya,
int  za,
int  xb,
int  yb,
int  zb 
) const

Extract an sub-array.

Compute the coordinates of the box and set the subdivision.

Parameters
xa,ya,za,xb,yb,zbInteger position of the array vertices.

◆ InsideCellIndex()

constexpr bool Array::InsideCellIndex ( int  i,
int  j,
int  k 
) const
inlineconstexpr

Check if the indexes are within range.

Parameters
i,j,kInteger coordinates of the vertex.

◆ InsideVertexIndex()

constexpr bool Array::InsideVertexIndex ( int  i,
int  j,
int  k 
) const
inlineconstexpr

Check if the indexes are within range.

Parameters
i,j,kInteger coordinates of the vertex.

◆ InverseCellIndex()

void Array::InverseCellIndex ( int  c,
int &  i,
int &  j,
int &  k 
) const
inline

Compute the coordinates of a given cell.

Parameters
cIndex of the cell.
i,j,kInteger coordinates of the cell.

◆ InverseVertexIndex()

void Array::InverseVertexIndex ( int  c,
int &  i,
int &  j,
int &  k 
) const
inline

Compute the coordinates of a given vertex.

Parameters
cIndex of the vertex.
i,j,kInteger coordinates of the vertex.

◆ Resize()

void Array::Resize ( const Box box,
int  x,
int  y,
int  z 
)

Resize the voxel with the given parameters.

Parameters
boxThe box.
x,y,zSizes.

◆ Scale() [1/2]

void Array::Scale ( const double &  s)

Scales the array structure.

Parameters
sScaling factor.

◆ Scale() [2/2]

void Array::Scale ( const Vector s)

Scales the array structure.

Parameters
sScaling vector.

◆ UnitCell()

Box Array::UnitCell ( ) const

Return the geometry of a generic cell.

This is a box, centered at origin, with the right size.

◆ Vertex()

Vector Array::Vertex ( int  i,
int  j,
int  k 
) const
inline

Compute the coordinates of a point on the grid.

Parameters
i,j,kInteger coordinates.

◆ VertexIndex()

constexpr int Array::VertexIndex ( int  i,
int  j,
int  k 
) const
inlineconstexpr

Compute the index of a given vertex.

Parameters
i,j,kInteger coordinates of the vertex.

◆ VertexInteger()

void Array::VertexInteger ( const Vector p,
int &  i,
int &  j,
int &  k 
) const
inline

Compute the coordinates of a vertex inside a cell.

Parameters
pPoint.
i,j,kInteger coordinates of the cell.

◆ VertexIntegerVolume()

void Array::VertexIntegerVolume ( const Box box,
int &  ax,
int &  ay,
int &  az,
int &  bx,
int &  by,
int &  bz 
) const

Compute the integer coordinates of the vertices of a box embedding an input box.

The coordinates are clamped to the size of the array.

Parameters
boxBox.
ax,ay,az,bx,by,bzInteger coordinates of the two points a and b.

◆ VertexSize()

int Array::VertexSize ( int  i) const
inline

Get the size of the array for every axis.

Parameters
iAxis.

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  s,
const Array a 
)
friend

Overloaded.

Parameters
sStream.
aThe array.