Hold the state for a closest point transform. More...
#include <StateBase.h>
Public Member Functions | |
Constructors, etc. | |
StateBase () | |
Default constructor. | |
~StateBase () | |
Destructor. | |
Accessors. | |
int | getNumberOfGrids () const |
Return the number of grids. | |
bool | hasBRepBeenSet () const |
Return true if the b-rep has been set. | |
const BBox & | getDomain () const |
Return the domain that contains all grids. | |
Number | getMaximumDistance () const |
Return how far the distance is being computed. | |
Manipulators. | |
void | setParameters (const BBox &domain, Number maximumDistance) |
Set the parameters for the Closest Point Transform. | |
void | setParameters (const Number *domain, const Number maximumDistance) |
Set parameters for the closest point transform. | |
void | setParameters (const Number maximumDistance) |
Set the parameters for the Closest Point Transform. | |
void | setLattice (const Index &extents, const BBox &domain) |
Set the grid geometry. | |
void | setLattice (const int *extents, const Number *domain) |
Set the lattice geometry. | |
template<bool A1, bool A2, bool A3, bool A4> | |
void | insertGrid (ads::Array< N, Number, A1 > *distance, ads::Array< N, Point, A2 > *gradientOfDistance, ads::Array< N, Point, A3 > *closestPoint, ads::Array< N, int, A4 > *closestFace) |
Add a grid for the Closest Point Transform. | |
void | insertGrid (const int *indexLowerBounds, const int *indexUpperBounds, Number *distance, Number *gradientOfDistance, Number *closestPoint, int *closestFace) |
Add a grid for the Closest Point Transform. | |
void | clearGrids () |
Clear the grids. | |
std::pair< int, int > | computeClosestPointTransformUsingBBox () |
Compute the closest point transform for signed distance. | |
std::pair< int, int > | computeClosestPointTransformUsingBruteForce () |
Compute the closest point transform for signed distance. | |
std::pair< int, int > | computeClosestPointTransformUsingTree () |
Compute the closest point transform for signed distance. | |
std::pair< int, int > | computeClosestPointTransformUnsignedUsingBBox () |
Compute the closest point transform for unsigned distance. | |
std::pair< int, int > | computeClosestPointTransformUnsignedUsingBruteForce () |
Compute the closest point transform for unsigned distance. | |
void | floodFillAtBoundary (Number farAway) |
Flood fill the distance. | |
void | floodFillDetermineSign (Number farAway) |
Flood fill the distance. | |
void | floodFillUnsigned (Number farAway) |
Flood fill the unsigned distance. | |
bool | areGridsValid () |
Check the grids. | |
bool | areGridsValidUnsigned () |
Check the grids. | |
void | setBRepWithNoClipping (int verticesSize, const void *vertices, int facesSize, const void *faces) |
Set the b-rep. | |
void | setBRep (int verticesSize, const void *vertices, int facesSize, const void *faces) |
Set the b-rep. | |
I/O. | |
void | displayInformation (std::ostream &out) const |
Display information about the state of the closest point transform. | |
Protected Types | |
typedef T | Number |
The number type. | |
typedef ads::FixedArray< N, Number > | Point |
A point in N-D. | |
typedef ads::FixedArray< N, int > | IndexedFace |
The indices of a face. | |
typedef ads::FixedArray< N, int > | Index |
An index in N-D. | |
typedef ads::IndexRange< N, int > | Range |
An index range in N-D. | |
typedef geom::BBox< N, Number > | BBox |
A bounding box. | |
typedef geom::RegularGrid< N, T > | Lattice |
The lattice defines a domain and index extents. | |
typedef cpt::Grid< N, T > | Grid |
The grid. | |
typedef cpt::BRep< N, T > | BRep |
The b-rep. | |
Protected Member Functions | |
Grid operations. | |
void | initializeGrids () |
Initialize the grids. | |
Protected Attributes | |
bool | _hasBRepBeenSet |
Has the b-rep been set. | |
bool | _hasCptBeenComputed |
Has the CPT been computed. | |
BBox | _domain |
The domain containing all grids for which the CPT will be computed. | |
Number | _maximumDistance |
How far (in Cartesian space) to compute the distance. | |
Lattice | _lattice |
The lattice. | |
std::vector< Grid > | _grids |
The grids. | |
BRep | _brep |
The b-rep. |
Hold the state for a closest point transform.
Implements the dimension-independent functionality.
bool StateBase< N, T >::areGridsValid | ( | ) |
Check the grids.
Verify that the distance grids are valid. The known distances should be between +-maximumDistance. The difference between adjacent grid points should not be more than the grid spacing. Verify that the closest point and closest face grids are valid. Return true if the grids are valid. Return false and print a message to stderr otherwise.
bool StateBase< N, T >::areGridsValidUnsigned | ( | ) |
Check the grids.
Verify that the distance grids are valid. The known distances should be between 0 and maximumDistance. The difference between adjacent grid points should not be more than the grid spacing. Verify that the closest point and closest face grids are valid. Return true if the grids are valid. Return false and print a message to stderr otherwise.
void StateBase< N, T >::clearGrids | ( | ) | [inline] |
Clear the grids.
If the grids change, call this function and then add all the new grids with insertGrid().
Referenced by State< 3, T >::determinePointsInside(), and State< 2, T >::determinePointsInside().
std::pair<int,int> StateBase< N, T >::computeClosestPointTransformUnsignedUsingBBox | ( | ) |
Compute the closest point transform for unsigned distance.
Compute the unsigned distance. Compute the gradient of the distance, the closest face and closest point if their arrays specified in insertGrid() are nonzero.
This algorithm does not use polyhedron scan conversion. Instead, it builds bounding boxes around the characteristic polyhedra.
The unknown distances, gradients, and closest points are set to std::numeric_limits<Number>::max()
. The unknown closest faces are set to -1.
std::pair<int,int> StateBase< N, T >::computeClosestPointTransformUnsignedUsingBruteForce | ( | ) |
Compute the closest point transform for unsigned distance.
Compute the unsigned distance. Compute the gradient of the distance, the closest face and closest point if their arrays specified in insertGrid() are nonzero.
This algorithm does not use polyhedron scan conversion or the characteristic polyhedra. Instead, it builds bounding boxes around the faces, edges and vertices.
The unknown distances, gradients, and closest points are set to std::numeric_limits<Number>::max()
. The unknown closest faces are set to -1.
std::pair<int,int> StateBase< N, T >::computeClosestPointTransformUsingBBox | ( | ) |
Compute the closest point transform for signed distance.
Compute the signed distance. Compute the gradient of the distance, the closest face and closest point if their arrays specified in insertGrid() are nonzero.
This algorithm does not use polyhedron scan conversion. Instead, it builds bounding boxes around the characteristic polyhedra.
The unknown distances, gradients, and closest points are set to std::numeric_limits<Number>::max()
. The unknown closest faces are set to -1.
std::pair<int,int> StateBase< N, T >::computeClosestPointTransformUsingBruteForce | ( | ) |
Compute the closest point transform for signed distance.
Compute the signed distance. Compute the gradient of the distance, the closest face and closest point if their arrays specified in insertGrid() are nonzero.
This algorithm does not use polyhedron scan conversion or the characteristic polyhedra. Instead, it builds bounding boxes around the faces, edges and vertices.
The unknown distances, gradients, and closest points are set to std::numeric_limits<Number>::max()
. The unknown closest faces are set to -1.
std::pair<int,int> StateBase< N, T >::computeClosestPointTransformUsingTree | ( | ) |
Compute the closest point transform for signed distance.
Compute the signed distance. Compute the gradient of the distance, the closest face and closest point if their arrays specified in insertGrid() are nonzero.
This algorithm uses a bounding box tree to store the mesh and a lower-upper-bound queries to determine the distance.
The unknown distances, gradients, and closest points are set to std::numeric_limits<Number>::max()
. The unknown closest faces are set to -1.
Flood fill the distance.
This function is used to prepare the distance for visualization. The signed distance is flood filled. If any of the distances are known in a particular grid, set the unknown distances to +-farAway. If no distances are known, set all distances to +farAway. Thus note that if no points in a particular grid have known distance, then the sign of the distance is not determined.
Referenced by State< 3, T >::determinePointsInside(), and State< 2, T >::determinePointsInside().
void StateBase< N, T >::floodFillDetermineSign | ( | Number | farAway | ) |
Flood fill the distance.
This function is used to prepare the distance for visualization. The signed distance is flood filled. If any of the distances are known in a particular grid, set the unknown distances to +-farAway. If no distances are known, determine the correct sign by computing the signed distance to the boundary for a single point in the grid.
Flood fill the unsigned distance.
The unsigned distance is flood filled. Unknown distances are set to farAway
.
void StateBase< N, T >::insertGrid | ( | const int * | indexLowerBounds, | |
const int * | indexUpperBounds, | |||
Number * | distance, | |||
Number * | gradientOfDistance, | |||
Number * | closestPoint, | |||
int * | closestFace | |||
) |
Add a grid for the Closest Point Transform.
This is a wrapper for the above insertGrid() function.
The first two parameters describe the index range of the grid. The lower bounds are closed; the upper bounds are open. For each of the gradientOfDistance
, closestPoint
and closestFace
arrays: if the pointer is non-zero, that quantity will be computed.
void StateBase< N, T >::insertGrid | ( | ads::Array< N, Number, A1 > * | distance, | |
ads::Array< N, Point, A2 > * | gradientOfDistance, | |||
ads::Array< N, Point, A3 > * | closestPoint, | |||
ads::Array< N, int, A4 > * | closestFace | |||
) | [inline] |
Add a grid for the Closest Point Transform.
This function must be called at least once before calls to computeClosestPointTransform().
distance | is the Array that will be assigned the distance from the grid points to the surface by the computeClosestPointTransform() function. | |
gradientOfDistance | is a Array that holds the gradient of the distance It is computed from the geometric primitives and not by differencing the distance array. Thus it is accurate to machine precision. If this array has zero size, the gradient of the distance will not be computed. | |
closestPoint | is a Array that holds the closest point on the triangle surface. If this array has zero size, the closest point will not be computed. | |
closestFace | is a Array that holds the index of the closest face on the triangle surface. If this array has zero size, the closest face will not be computed. |
Referenced by State< 3, T >::determinePointsInside(), and State< 2, T >::determinePointsInside().
void StateBase< N, T >::setBRep | ( | int | verticesSize, | |
const void * | vertices, | |||
int | facesSize, | |||
const void * | faces | |||
) |
Set the b-rep.
Clip the mesh to use only points that affect the cartesian domain.
Either this function or setBRepWithNoClipping() must be called at least once before calls to computeClosestPointTransform(). This version is more efficient if the b-rep extends beyond the domain spanned by the grid.
verticesSize | is the number of vertices. | |
vertices | is a const pointer to the beginning of the vertices. | |
facesSize | is the number of faces. | |
faces | is a const pointer to the beginning of the faces. |
void StateBase< N, T >::setBRepWithNoClipping | ( | int | verticesSize, | |
const void * | vertices, | |||
int | facesSize, | |||
const void * | faces | |||
) |
Set the b-rep.
Do not use the Cartesian domain to clip the mesh.
Either this function or setBRep() must be called at least once before calls to computeClosestPointTransform().
verticesSize | is the number of vertices. | |
vertices | is a const pointer to the beginning of the vertices. | |
facesSize | is the number of faces. | |
faces | is a const pointer to the beginning of the faces. |
void StateBase< N, T >::setLattice | ( | const int * | extents, | |
const Number * | domain | |||
) | [inline] |
Set the lattice geometry.
This is a wrapper for the above setLattice function().
void StateBase< N, T >::setLattice | ( | const Index & | extents, | |
const BBox & | domain | |||
) |
Set the grid geometry.
extents | are the grid geometry extents. | |
domain | is the grid geometry domain. |
Referenced by State< 3, T >::determinePointsInside(), State< 2, T >::determinePointsInside(), and StateBase< 2, T >::setLattice().
void StateBase< N, T >::setParameters | ( | const Number | maximumDistance | ) | [inline] |
Set the parameters for the Closest Point Transform.
This calls the first setParameters() function. The domain containing all grids is set to all space. This means that clipping the mesh will have no effect.
void StateBase< N, T >::setParameters | ( | const Number * | domain, | |
const Number | maximumDistance | |||
) | [inline] |
Set parameters for the closest point transform.
This is a wrapper for the above setParameters function.
void StateBase< N, T >::setParameters | ( | const BBox & | domain, | |
Number | maximumDistance | |||
) |
Set the parameters for the Closest Point Transform.
This function must be called at least once before calls to computeClosestPointTransform().
domain | is the Cartesian domain that contains all grids. | |
maximumDistance | The distance will be computed up to maximumDistance away from the surface. |
The distance for grid points whose distance is larger than maximumDistance will be set to std::numeric_limits<Number>::max()
. Each component of the closest point of these far away points will be set to std::numeric_limits<Number>::max()
. The closest face of far away points will be set to -1.
Referenced by State< 3, T >::determinePointsInside(), State< 2, T >::determinePointsInside(), StateBase< 2, T >::setParameters(), and State< 2, T >::setParameters().
The domain containing all grids for which the CPT will be computed.
This may be used in clipping the mesh.
Referenced by StateBase< 2, T >::getDomain().