NetDEM v1.0
Loading...
Searching...
No Matches
netdem::LevelSetFunction Class Reference

Class for representing a level set function on a regular grid. More...

#include <level_set_function.hpp>

Inheritance diagram for netdem::LevelSetFunction:
netdem::LevelSet netdem::LevelSetSplittor

Public Member Functions

 LevelSetFunction ()
 Default constructor.
 
Vec3d const & GetCorner () const
 
double GetSpacing () const
 
Vec3i const & GetDimensions () const
 
double GetSignedDistance (int id_x, int id_y, int id_z)
 Get the signed distance value of a certian cell of the grid.
 
VecXT< VecXT< VecXT< double > > > const & GetSignedDistanceTable () const
 
void SetCorner (double corner_x, double corner_y, double corner_z)
 Set the corner of the grid.
 
void SetSpacing (double sp)
 Set the spacing between grid points.
 
void SetDimension (double dim_x, double dim_y, double dim_z)
 Set the dimensions of the grid.
 
void SetSignedDistance (int id_x, int id_y, int id_z, double sdf)
 Set the signed distance value of a certian cell of the grid.
 
void InitFromSDFCalculator (const SDFCalculator &sdf_calculator)
 Initialize from a signed distance field.
 
double SignedDistance (Vec3d const &pos) const
 Compute the signed distance at a point in space.
 
Vec3d GradientInterpolate (Vec3d const &pos)
 Compute the gradient at a point in space using interpolation.
 
Vec3d GradientMinus (int i, int j, int k)
 Compute the gradient at the grid point (i, j, k) using backward differences.
 
Vec3d GradientPlus (int i, int j, int k)
 Compute the gradient at the grid point (i, j, k) using forward differences.
 
void Reinitialization (int iter, double dt)
 Perform reinitialization to maintain properties of the level set function.
 
void Reinitialization ()
 Perform reinitialization with default parameters.
 

Protected Attributes

Vec3d corner {-0.5, -0.5, -0.5}
 Coordinates of the corner of the grid.
 
double spacing {0.05}
 Spacing between grid points.
 
Vec3i dim {21, 21, 21}
 Dimensions of the grid.
 
VecXT< VecXT< VecXT< double > > > signed_distance_table
 Table containing the signed distance values.
 

Detailed Description

Class for representing a level set function on a regular grid.

This class represents a level set function on a regular grid with constant spacing in each dimension. It provides methods for initializing the function from a signed distance field, computing the signed distance and gradient at arbitrary points in space, and performing reinitialization to maintain the properties of the level set function.

Constructor & Destructor Documentation

◆ LevelSetFunction()

LevelSetFunction::LevelSetFunction ( )

Default constructor.

This creates an empty LevelSetFunction; it must be initialized before it can be used to compute signed distances or gradients.

Member Function Documentation

◆ GetCorner()

Vec3d const & LevelSetFunction::GetCorner ( ) const

◆ GetDimensions()

Vec3i const & LevelSetFunction::GetDimensions ( ) const

◆ GetSignedDistance()

double LevelSetFunction::GetSignedDistance ( int id_x,
int id_y,
int id_z )

Get the signed distance value of a certian cell of the grid.

Parameters
id_xThe index of grid cell in the x-dimension.
id_yThe index of grid cell in the y-dimension.
id_zThe index of grid cell in the z-dimension.
Returns
The new signed distance value of grid cell.

◆ GetSignedDistanceTable()

VecXT< VecXT< VecXT< double > > > const & LevelSetFunction::GetSignedDistanceTable ( ) const

◆ GetSpacing()

double LevelSetFunction::GetSpacing ( ) const

◆ GradientInterpolate()

Vec3d LevelSetFunction::GradientInterpolate ( Vec3d const & pos)

Compute the gradient at a point in space using interpolation.

This method computes the gradient at a given point in space by interpolating the gradients computed using GradientMinus and GradientPlus at the neighboring grid points.

Parameters
posThe point at which to compute the gradient.
Returns
The gradient at the specified point.

◆ GradientMinus()

Vec3d LevelSetFunction::GradientMinus ( int i,
int j,
int k )

Compute the gradient at the grid point (i, j, k) using backward differences.

This method computes the gradient at the grid point (i, j, k) using backward differences.

Parameters
iThe x-coordinate of the grid point.
jThe y-coordinate of the grid point.
kThe z-coordinate of the grid point.
Returns
The gradient at the specified grid point.

◆ GradientPlus()

Vec3d LevelSetFunction::GradientPlus ( int i,
int j,
int k )

Compute the gradient at the grid point (i, j, k) using forward differences.

This method computes the gradient at the grid point (i, j, k) using forward differences.

Parameters
iThe x-coordinate of the grid point.
jThe y-coordinate of the grid point.
kThe z-coordinate of the grid point.
Returns
The gradient at the specified grid point.

◆ InitFromSDFCalculator()

void LevelSetFunction::InitFromSDFCalculator ( const SDFCalculator & sdf_calculator)

Initialize from a signed distance field.

This method initializes the LevelSetFunction from a signed distance field represented by an SDFCalculator object. It samples the signed distance at each point on the grid and stores it in the signed_distance_table.

Parameters
sdf_calculatorThe SDFCalculator containing the signed distance field.

◆ Reinitialization() [1/2]

void LevelSetFunction::Reinitialization ( )

Perform reinitialization with default parameters.

This method performs reinitialization on the signed distance values stored in the signed_distance_table. It uses default parameters for the number of iterations and time step.

◆ Reinitialization() [2/2]

void LevelSetFunction::Reinitialization ( int iter,
double dt )

Perform reinitialization to maintain properties of the level set function.

This method performs reinitialization on the signed distance values stored in the signed_distance_table. It iteratively updates the values using a finite difference scheme until the level set function becomes sufficiently smooth.

Parameters
iterThe number of iterations to perform.
dtThe time step used in the finite difference scheme.

◆ SetCorner()

void LevelSetFunction::SetCorner ( double corner_x,
double corner_y,
double corner_z )

Set the corner of the grid.

This method sets the coordinates of the corner of the grid, which is the point where the (0, 0, 0) grid cell is located.

Parameters
corner_xThe x-coordinate of the corner.
corner_yThe y-coordinate of the corner.
corner_zThe z-coordinate of the corner.

◆ SetDimension()

void LevelSetFunction::SetDimension ( double dim_x,
double dim_y,
double dim_z )

Set the dimensions of the grid.

This method sets the dimensions of the grid in each dimension.

Parameters
dim_xThe number of grid cells in the x-dimension.
dim_yThe number of grid cells in the y-dimension.
dim_zThe number of grid cells in the z-dimension.

◆ SetSignedDistance()

void LevelSetFunction::SetSignedDistance ( int id_x,
int id_y,
int id_z,
double sdf )

Set the signed distance value of a certian cell of the grid.

Parameters
id_xThe index of grid cell in the x-dimension.
id_yThe index of grid cell in the y-dimension.
id_zThe index of grid cell in the z-dimension.
sdfThe new signed distance value of grid cell.

◆ SetSpacing()

void LevelSetFunction::SetSpacing ( double sp)

Set the spacing between grid points.

This method sets the spacing between grid points in each dimension.

Parameters
spThe spacing between grid points.

◆ SignedDistance()

double LevelSetFunction::SignedDistance ( Vec3d const & pos) const

Compute the signed distance at a point in space.

This method computes the signed distance at a given point in space by interpolating the signed distances stored in the signed_distance_table.

Parameters
posThe point at which to compute the signed distance.
Returns
The signed distance at the specified point.

Member Data Documentation

◆ corner

Vec3d netdem::LevelSetFunction::corner {-0.5, -0.5, -0.5}
protected

Coordinates of the corner of the grid.

◆ dim

Vec3i netdem::LevelSetFunction::dim {21, 21, 21}
protected

Dimensions of the grid.

◆ signed_distance_table

VecXT<VecXT<VecXT<double> > > netdem::LevelSetFunction::signed_distance_table
protected

Table containing the signed distance values.

◆ spacing

double netdem::LevelSetFunction::spacing {0.05}
protected

Spacing between grid points.


The documentation for this class was generated from the following files: