cpt::StateBase< N, T > Class Template Reference

Hold the state for a closest point transform. More...

#include <StateBase.h>

Inheritance diagram for cpt::StateBase< N, T >:
Inheritance graph
[legend]
Collaboration diagram for cpt::StateBase< N, T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

Constructors, etc.



 StateBase ()
 Default constructor.
 ~StateBase ()
 Destructor.
Accessors.



std::size_t getNumberOfGrids () const
 Return the number of grids.
const GridgetGrid (const std::size_t n) const
 Get the specified grid.
bool hasBRepBeenSet () const
 Return true if the b-rep has been set.
const BBoxgetDomain () 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 *domainLowerData, const Number *domainUpperData, 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 SizeList &extents, const BBox &domain)
 Set the grid geometry.
void setLattice (const int *extentsData, const Number *lowerData, const Number *upperData)
 Set the lattice geometry.
void insertGrid (const SizeList &extents, const IndexList &bases, bool useGradientOfDistance, bool useClosestPoint, bool useClosestFace)
 Add a grid for the Closest Point Transform.
void insertGrid (const SizeList &extents, const IndexList &bases, Number *distance, Number *gradientOfDistance, Number *closestPoint, int *closestFace)
 Add a grid for the Closest Point Transform.
void insertGrid (const int *lowerBounds, const int *upperBounds, Number *distance, Number *gradientOfDistance, Number *closestPoint, int *closestFace)
 Add a grid for the Closest Point Transform.
void clearGrids ()
 Clear the grids.
std::pair< std::size_t,
std::size_t > 
computeClosestPointTransformUsingBBox ()
 Compute the closest point transform for signed distance.
std::pair< std::size_t,
std::size_t > 
computeClosestPointTransformUsingBruteForce ()
 Compute the closest point transform for signed distance.
std::pair< std::size_t,
std::size_t > 
computeClosestPointTransformUsingTree ()
 Compute the closest point transform for signed distance.
std::pair< std::size_t,
std::size_t > 
computeClosestPointTransformUnsignedUsingBBox ()
 Compute the closest point transform for unsigned distance.
std::pair< std::size_t,
std::size_t > 
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 (const std::vector< std::tr1::array< Number, N > > &vertices, const std::vector< std::tr1::array< std::size_t, N > > &faces)
 Set the b-rep.
void setBRepWithNoClipping (std::size_t numVertices, const Number *vertices, std::size_t numFaces, const int *faces)
 Wrapper for the above function.
void setBRep (const std::vector< std::tr1::array< Number, N > > &vertices, const std::vector< std::tr1::array< std::size_t, N > > &faces)
 Set the b-rep.
void setBRep (std::size_t numVertices, const Number *vertices, std::size_t numFaces, const int *faces)
 Wrapper for the above function.
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 geom::BBox< N, NumberBBox
 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.
typedef Grid::Point Point
 A point in N-D.
typedef Grid::SizeList SizeList
 An extent in N-D.
typedef Grid::IndexList IndexList
 A multi-index in N-D.
typedef Grid::IndexList IndexedFace
 The indices of a face.
typedef Grid::Index Index
 A single index.
typedef Grid::Range Range
 A multi-index range in N-D.

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.

Detailed Description

template<std::size_t N, typename T = double>
class cpt::StateBase< N, T >

Hold the state for a closest point transform.

Implements the dimension-independent functionality.


Member Function Documentation

template<std::size_t N, typename T = double>
bool cpt::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.

template<std::size_t N, typename T = double>
bool cpt::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.

template<std::size_t N, typename T = double>
void cpt::StateBase< N, T >::clearGrids (  )  [inline]

Clear the grids.

If the grids change, call this function and then add all the new grids with insertGrid().

template<std::size_t N, typename T = double>
std::pair<std::size_t, std::size_t> cpt::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 std::numeric_limits<std::size_t>::max().

Returns:
Return the number of points for which the distance was computed and the number of points for which the distance was set.
template<std::size_t N, typename T = double>
std::pair<std::size_t, std::size_t> cpt::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 std::numeric_limits<std::size_t>::max().

Returns:
Return the number of points for which the distance was computed and the number of points for which the distance was set.
template<std::size_t N, typename T = double>
std::pair<std::size_t, std::size_t> cpt::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 std::numeric_limits<std::size_t>::max().

Returns:
Return the number of points for which the distance was computed and the number of points for which the distance was set.
template<std::size_t N, typename T = double>
std::pair<std::size_t, std::size_t> cpt::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 std::numeric_limits<std::size_t>::max().

Returns:
Return the number of points for which the distance was computed and the number of points for which the distance was set.
template<std::size_t N, typename T = double>
std::pair<std::size_t, std::size_t> cpt::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 std::numeric_limits<std::size_t>::max().

Returns:
Return the number of points for which the distance was computed and the number of points for which the distance was set.
template<std::size_t N, typename T = double>
void cpt::StateBase< N, T >::floodFillAtBoundary ( 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, 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.

template<std::size_t N, typename T = double>
void cpt::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.

Note:
In order to determine the sign of the distance for far away grids, this algorithm needs that portion of the boundary that is closest to those grids. Using setBRep() may clip away the needed portion (or for that matter all) of the boundary. You should use setBRepWithNoClipping() before calling this function. To be on the safe side, you should give the entire boundary to setBRepWithNoClipping() .
template<std::size_t N, typename T = double>
void cpt::StateBase< N, T >::floodFillUnsigned ( Number  farAway  ) 

Flood fill the unsigned distance.

The unsigned distance is flood filled. Unknown distances are set to farAway.

template<std::size_t N, typename T = double>
void cpt::StateBase< N, T >::insertGrid ( const int *  lowerBounds,
const int *  upperBounds,
Number distance,
Number gradientOfDistance,
Number closestPoint,
int *  closestFace 
) [inline]

Add a grid for the Closest Point Transform.

This is a wrapper for the above insertGrid function().

template<std::size_t N, typename T = double>
void cpt::StateBase< N, T >::insertGrid ( const SizeList extents,
const IndexList bases,
Number distance,
Number gradientOfDistance,
Number closestPoint,
int *  closestFace 
)

Add a grid for the Closest Point Transform.

Parameters:
extents The array extents.
bases The index bases for the arrays. For each of the gradientOfDistance, closestPoint and closestFace arrays: if the pointer is non-zero, that quantity will be computed.
distance Pointer to the distance array.
gradientOfDistance Pointer to the gradient of distance array.
closestPoint Pointer to the closest point array.
closestFace Pointer to the closest face array.
template<std::size_t N, typename T = double>
void cpt::StateBase< N, T >::insertGrid ( const SizeList extents,
const IndexList bases,
bool  useGradientOfDistance,
bool  useClosestPoint,
bool  useClosestFace 
)

Add a grid for the Closest Point Transform.

This function must be called at least once before calls to computeClosestPointTransform().

Parameters:
extents The array extents.
bases The index bases for the arrays.
useGradientOfDistance Whether to compute the gradient of the distance. The gradient of the distance is computed from the geometric primitives and not by differencing the distance array. Thus it is accurate to within machine precision.
useClosestPoint Whether to compute the closest points.
useClosestFace Whether to compute the closet face on the mesh.

Referenced by cpt::StateBase< 2, T >::insertGrid().

template<std::size_t N, typename T = double>
void cpt::StateBase< N, T >::setBRep ( const std::vector< std::tr1::array< Number, N > > &  vertices,
const std::vector< std::tr1::array< std::size_t, N > > &  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.

Parameters:
vertices are the locations of the vertices.
faces is a vector of tuples of vertex indices that describe the faces.
template<std::size_t N, typename T = double>
void cpt::StateBase< N, T >::setBRepWithNoClipping ( const std::vector< std::tr1::array< Number, N > > &  vertices,
const std::vector< std::tr1::array< std::size_t, N > > &  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().

Parameters:
vertices are the locations of the vertices.
faces is a vector of tuples of vertex indices that describe the faces.
template<std::size_t N, typename T = double>
void cpt::StateBase< N, T >::setLattice ( const int *  extentsData,
const Number lowerData,
const Number upperData 
) [inline]

Set the lattice geometry.

This is a wrapper for the above setLattice function().

template<std::size_t N, typename T = double>
void cpt::StateBase< N, T >::setLattice ( const SizeList extents,
const BBox domain 
)

Set the grid geometry.

Parameters:
extents are the grid geometry extents.
domain is the grid geometry domain.

Referenced by cpt::StateBase< 2, T >::setLattice().

template<std::size_t N, typename T = double>
void cpt::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.

template<std::size_t N, typename T = double>
void cpt::StateBase< N, T >::setParameters ( const Number domainLowerData,
const Number domainUpperData,
const Number  maximumDistance 
) [inline]

Set parameters for the closest point transform.

This is a wrapper for the above setParameters function.

template<std::size_t N, typename T = double>
void cpt::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().

Parameters:
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 std::numeric_limits<std::size_t>::max().

Referenced by cpt::StateBase< 2, T >::setParameters().


Member Data Documentation

template<std::size_t N, typename T = double>
BBox cpt::StateBase< N, T >::_domain [protected]

The domain containing all grids for which the CPT will be computed.

This may be used in clipping the mesh.

Referenced by cpt::StateBase< 2, T >::getDomain().


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

STLib Home / http://www.its.caltech.edu/~sean/ / at(sean, dot(caltech, edu))