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

A base three-dimensional field of real values. More...

#include <scalarfield.h>

Inheritance diagram for ScalarField:
Array Box

Public Member Functions

 ScalarField (bool=true)
 Empty. More...
 
 ScalarField (const Array &, const double &=0.0, bool=true)
 Create the field structure. More...
 
 ScalarField (const Box &, int, int, int, const double &=0.0, bool=true)
 Create the field structure. More...
 
 ScalarField (const Box &, int, int, int, const QVector< double > &, bool=true)
 Create the field structure. More...
 
 ~ScalarField ()
 Empty.
 
void GetRange (double &, double &) const
 Get the range of the field. More...
 
double Integral () const
 Get the integral of the scalar field. More...
 
virtual Vector Gradient (int, int, int) const
 Compute the gradient at a given sample. More...
 
virtual Matrix Hessian (int, int, int) const
 Compute the Hessian symmetric matrix of the field. More...
 
virtual double Value (int, int, int) const
 Access to array of data. More...
 
virtual double K () const
 Compute the Lipschitz constant of the field.
 
Vector Normal (const Vector &) const
 Compute the normal. More...
 
void CutEpsilon (const double &=1e-6)
 Set all values in the field that are lower than epsilon to true zero. More...
 
double at (int, int, int) const
 Return the field value at a given array vertex. More...
 
double & operator() (int, int, int)
 Return the field value at a given array vertex. More...
 
double at (int) const
 Return the data in the field. More...
 
double & operator[] (int)
 Return the data in the field. More...
 
ScalarFieldoperator+= (const ScalarField &)
 Sum two scalar fields. More...
 
ScalarFieldoperator*= (const double &)
 Scale the values of a scalar field. More...
 
virtual double Value (const Vector &) const
 Get the field value with world coordinate system. More...
 
virtual double BicubicValue (const Vector &) const
 Return the intensity at a point. More...
 
Vector Gradient (const Vector &) const
 Compute the gradient. More...
 
virtual Matrix Hessian (const Vector &) const
 Compute the Hessian symmetric matrix of the field function. More...
 
void Translate (const Vector &)
 Translate the domain of the scalar field. More...
 
void Scale (const Vector &)
 Scale the domain of the scalar field. More...
 
int Memory () const
 Compute the size of the scalarfield.
 
void Polygonize (Mesh &) const
 Polygonization. More...
 
void Dual (Mesh &) const
 Polygonization using Dual Marching Cubes. More...
 
int DualCellCode (int, int, int) const
 Compute the configuration for the voxel corners of the cell. More...
 
void Save (const QString &) const
 Save as data file. More...
 
void Read (const QString &)
 Read data file. More...
 
void DualVertex (int, int, int, int, Vector &) const
 Compute the dual point. More...
 
- Public Member Functions inherited from Array
 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 Attributes

static int TriangleTable [256][16]
 Two dimensionnal array storing the straddling edges for every marching cubes configuration.
 
static int edgeTable [256]
 Array storing straddling edges for every marching cubes configuration.
 

Protected Member Functions

void Blend (const double &, double[4]) const
 Compute the blending coefficients using cubic polynomials. More...
 
- 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...
 

Protected Attributes

bool sign
 Sign convention, used for normal computation.
 
QVector< double > field
 Field samples.
 
- Protected Attributes inherited from Array
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.
 

Static Protected Attributes

static constexpr double Epsilon = 1.0e-6
 Epsilon value for partial derivatives.
 
- 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.
 

Additional Inherited Members

- Static Public Member Functions inherited from Array
static Array CubicCells (Box, int)
 Create an array with enforced cubic cells. More...
 

Detailed Description

A base three-dimensional field of real values.

Constructor & Destructor Documentation

◆ ScalarField() [1/4]

ScalarField::ScalarField ( bool  s = true)
inline

Empty.

Constructor.

Parameters
sSign, by default, set sign convention to true, i.e., negative values inside and positive outside.

◆ ScalarField() [2/4]

ScalarField::ScalarField ( const Array a,
const double &  v = 0.0,
bool  s = true 
)

Create the field structure.

Parameters
aThe array.
vDefault value of field.
sSign, by default, set sign convention to true, i.e., negative values inside and positive outside.

◆ ScalarField() [3/4]

ScalarField::ScalarField ( const Box box,
int  x,
int  y,
int  z,
const double &  v = 0.0,
bool  s = true 
)

Create the field structure.

Parameters
boxThe box.
x,y,zSize of the array.
vDefault value of field.
sSign, by default, set sign convention to true, i.e., negative values inside and positive outside.

◆ ScalarField() [4/4]

ScalarField::ScalarField ( const Box box,
int  x,
int  y,
int  z,
const QVector< double > &  v,
bool  s = true 
)

Create the field structure.

Parameters
boxThe box.
x,y,zSize of the array.
vArray of scalar values.
sSign, by default, set sign convention to true, i.e., negative values inside and positive outside.

Member Function Documentation

◆ at() [1/2]

double ScalarField::at ( int  c) const
inline

Return the data in the field.

Parameters
cIndex.

◆ at() [2/2]

double ScalarField::at ( int  i,
int  j,
int  k 
) const
inline

Return the field value at a given array vertex.

Parameters
i,j,kInteger coordinates of the vertex.

◆ BicubicValue()

double ScalarField::BicubicValue ( const Vector p) const
virtual

Return the intensity at a point.

The function returns -1.0 if point sample is outside the bounding box. Otherwise, the intensity is computed by blending the intensity at the vertices of the voxel grid with cubic polynomials.

Parameters
pPoint.

◆ Blend()

void ScalarField::Blend ( const double &  u,
double  b[4] 
) const
protected

Compute the blending coefficients using cubic polynomials.

After Allen Van Gelder and Jane Wilhels, Topological considerations in iso-surface generation, ACM Transactions on Graphics, 13(4):21-28, 1994.

◆ CutEpsilon()

void ScalarField::CutEpsilon ( const double &  e = 1e-6)

Set all values in the field that are lower than epsilon to true zero.

Parameters
eEpsilon coefficient.

◆ Dual()

void ScalarField::Dual ( Mesh g) const

Polygonization using Dual Marching Cubes.

This function implements a modified version of the dual marching cubes presented in: G. Nielson. Dual Marching Cubes. Proceedings of the Conference on Visualization, 489-496, 2004.

A vertex in standard marching cubes is shared by 4 faces (as it lies on an edge, thus shared by four cubes), thus the dual mesh is made from quadrangles. Manifold mesh is produced by using the modifications described in R. Wenger. Isosurfaces: Geometry, Topology, and Algorithms.

Parameters
gReturned mesh.

◆ DualCellCode()

int ScalarField::DualCellCode ( int  cx,
int  cy,
int  cz 
) const

Compute the configuration for the voxel corners of the cell.

Parameters
cx,cy,czCell coordinates.

◆ DualVertex()

void ScalarField::DualVertex ( int  cx,
int  cy,
int  cz,
int  c,
Vector v 
) const

Compute the dual point.

The dual point is defined as the mean of the face vertices belonging to the marching cubes face.

Parameters
cConfiguration.
cx,cy,czCoordinates.
vReturned vertex.

◆ GetRange()

void ScalarField::GetRange ( double &  a,
double &  b 
) const

Get the range of the field.

Parameters
a,bReturned minimum and maximum.

◆ Gradient() [1/2]

Vector ScalarField::Gradient ( const Vector p) const

Compute the gradient.

Parameters
pPoint.

◆ Gradient() [2/2]

Vector ScalarField::Gradient ( int  i,
int  j,
int  k 
) const
virtual

Compute the gradient at a given sample.

Parameters
i,j,kInteger coordinates of the sample.

◆ Hessian() [1/2]

Matrix ScalarField::Hessian ( const Vector p) const
virtual

Compute the Hessian symmetric matrix of the field function.

Parameters
pPoint.
Returns
Hessian matrix.

◆ Hessian() [2/2]

Matrix ScalarField::Hessian ( int  i,
int  j,
int  k 
) const
virtual

Compute the Hessian symmetric matrix of the field.

Parameters
i,j,kInteger coordinates of the point.
Returns
Hessian matrix.

◆ Integral()

double ScalarField::Integral ( ) const

Get the integral of the scalar field.

Simply compute the sum of all the elements and make the product by the area of small cell element.

◆ Normal()

Vector ScalarField::Normal ( const Vector p) const

Compute the normal.

Parameters
pPoint (should be on the surface).

◆ operator()()

double & ScalarField::operator() ( int  i,
int  j,
int  k 
)
inline

Return the field value at a given array vertex.

Parameters
i,j,kInteger coordinates of the vertex.

◆ operator*=()

ScalarField & ScalarField::operator*= ( const double &  s)

Scale the values of a scalar field.

Parameters
sScaling factor.

◆ operator+=()

ScalarField & ScalarField::operator+= ( const ScalarField s)

Sum two scalar fields.

Scalar fields should have the same size.

Parameters
sArgument scalar field.

◆ operator[]()

double & ScalarField::operator[] ( int  c)
inline

Return the data in the field.

Parameters
cIndex.

◆ Polygonize()

void ScalarField::Polygonize ( Mesh g) const

Polygonization.

Parameters
gReturned mesh.

◆ Read()

void ScalarField::Read ( const QString &  name)

Read data file.

Parameters
nameFilename.

◆ Save()

void ScalarField::Save ( const QString &  name) const

Save as data file.

Parameters
nameFilename.

◆ Scale()

void ScalarField::Scale ( const Vector s)

Scale the domain of the scalar field.

Parameters
sScaling factor.

◆ Translate()

void ScalarField::Translate ( const Vector t)

Translate the domain of the scalar field.

Parameters
tTranslation vector.

◆ Value() [1/2]

double ScalarField::Value ( const Vector p) const
virtual

Get the field value with world coordinate system.

This function computes a tri-linear interpolation of the values.

See also
Math::Trilinear
Parameters
pPoint position (should be strictly within bounding box of the domain).

◆ Value() [2/2]

double ScalarField::Value ( int  i,
int  j,
int  k 
) const
virtual

Access to array of data.

Parameters
i,j,kInteger coordinates.