Path Tracer
Classes | Public Member Functions | Protected Attributes | List of all members
Assimp::SpatialSort Class Reference

#include <SpatialSort.h>

Classes

struct  Entry
 

Public Member Functions

 SpatialSort (const aiVector3D *pPositions, unsigned int pNumPositions, unsigned int pElementOffset)
 
 ~SpatialSort ()
 
void Fill (const aiVector3D *pPositions, unsigned int pNumPositions, unsigned int pElementOffset, bool pFinalize=true)
 
void Append (const aiVector3D *pPositions, unsigned int pNumPositions, unsigned int pElementOffset, bool pFinalize=true)
 
void Finalize ()
 
void FindPositions (const aiVector3D &pPosition, ai_real pRadius, std::vector< unsigned int > &poResults) const
 
void FindIdenticalPositions (const aiVector3D &pPosition, std::vector< unsigned int > &poResults) const
 
unsigned int GenerateMappingTable (std::vector< unsigned int > &fill, ai_real pRadius) const
 

Protected Attributes

aiVector3D mPlaneNormal
 
std::vector< EntrymPositions
 

Detailed Description

A little helper class to quickly find all vertices in the epsilon environment of a given position. Construct an instance with an array of positions. The class stores the given positions by their indices and sorts them by their distance to an arbitrary chosen plane. You can then query the instance for all vertices close to a given position in an average O(log n) time, with O(n) worst case complexity when all vertices lay on the plane. The plane is chosen so that it avoids common planes in usual data sets.

Constructor & Destructor Documentation

◆ SpatialSort()

Assimp::SpatialSort::SpatialSort ( const aiVector3D pPositions,
unsigned int  pNumPositions,
unsigned int  pElementOffset 
)

Constructs a spatially sorted representation from the given position array. Supply the positions in its layout in memory, the class will only refer to them by index.

Parameters
pPositionsPointer to the first position vector of the array.
pNumPositionsNumber of vectors to expect in that array.
pElementOffsetOffset in bytes from the beginning of one vector in memory to the beginning of the next vector.

◆ ~SpatialSort()

Assimp::SpatialSort::~SpatialSort ( )

Destructor

Member Function Documentation

◆ Append()

void Assimp::SpatialSort::Append ( const aiVector3D pPositions,
unsigned int  pNumPositions,
unsigned int  pElementOffset,
bool  pFinalize = true 
)

Same as Fill(), except the method appends to existing data in the #SpatialSort.

◆ Fill()

void Assimp::SpatialSort::Fill ( const aiVector3D pPositions,
unsigned int  pNumPositions,
unsigned int  pElementOffset,
bool  pFinalize = true 
)

Sets the input data for the SpatialSort. This replaces existing data, if any. The new data receives new indices in ascending order.

Parameters
pPositionsPointer to the first position vector of the array.
pNumPositionsNumber of vectors to expect in that array.
pElementOffsetOffset in bytes from the beginning of one vector in memory to the beginning of the next vector.
pFinalizeSpecifies whether the SpatialSort's internal representation is finalized after the new data has been added. Finalization is required in order to use #FindPosition() or GenerateMappingTable(). If you don't finalize yet, you can use Append() to add data from other sources.

◆ Finalize()

void Assimp::SpatialSort::Finalize ( )

Finalize the spatial hash data structure. This can be useful after multiple calls to Append() with the pFinalize parameter set to false. This is finally required before one of FindPositions() and GenerateMappingTable() can be called to query the spatial sort.

◆ FindIdenticalPositions()

void Assimp::SpatialSort::FindIdenticalPositions ( const aiVector3D pPosition,
std::vector< unsigned int > &  poResults 
) const

Fills an array with indices of all positions identical to the given position. In opposite to FindPositions(), not an epsilon is used but a (very low) tolerance of four floating-point units.

Parameters
pPositionThe position to look for vertices.
poResultsThe container to store the indices of the found positions. Will be emptied by the call so it may contain anything.

◆ FindPositions()

void Assimp::SpatialSort::FindPositions ( const aiVector3D pPosition,
ai_real  pRadius,
std::vector< unsigned int > &  poResults 
) const

Returns an iterator for all positions close to the given position.

Parameters
pPositionThe position to look for vertices.
pRadiusMaximal distance from the position a vertex may have to be counted in.
poResultsThe container to store the indices of the found positions. Will be emptied by the call so it may contain anything.
Returns
An iterator to iterate over all vertices in the given area.

◆ GenerateMappingTable()

unsigned int Assimp::SpatialSort::GenerateMappingTable ( std::vector< unsigned int > &  fill,
ai_real  pRadius 
) const

Compute a table that maps each vertex ID referring to a spatially close enough position to the same output ID. Output IDs are assigned in ascending order from 0...n.

Parameters
fillWill be filled with numPositions entries.
pRadiusMaximal distance from the position a vertex may have to be counted in.
Returns
Number of unique vertices (n).

Member Data Documentation

◆ mPlaneNormal

aiVector3D Assimp::SpatialSort::mPlaneNormal
protected

Normal of the sorting plane, normalized. The center is always at (0, 0, 0)


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