Assimp v5.2.2 (January 2022)
The Asset-Importer-Lib API documentation.
|
A little helper class to quickly find all vertices in the epsilon environment of a given position. More...
#include <SpatialSort.h>
Classes | |
struct | Entry |
An entry in a spatially sorted position array. More... | |
Public Member Functions | |
void | 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. More... | |
void | Fill (const aiVector3D *pPositions, unsigned int pNumPositions, unsigned int pElementOffset, bool pFinalize=true) |
Sets the input data for the SpatialSort. More... | |
void | Finalize () |
Finalize the spatial hash data structure. More... | |
void | FindIdenticalPositions (const aiVector3D &pPosition, std::vector< unsigned int > &poResults) const |
Fills an array with indices of all positions identical to the given position. More... | |
void | FindPositions (const aiVector3D &pPosition, ai_real pRadius, std::vector< unsigned int > &poResults) const |
Returns an iterator for all positions close to the given position. More... | |
unsigned int | 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. More... | |
SpatialSort () | |
SpatialSort (const aiVector3D *pPositions, unsigned int pNumPositions, unsigned int pElementOffset) | |
Constructs a spatially sorted representation from the given position array. More... | |
~SpatialSort () | |
Destructor. More... | |
Protected Member Functions | |
ai_real | CalculateDistance (const aiVector3D &pPosition) const |
Return the distance to the sorting plane. More... | |
Protected Attributes | |
aiVector3D | mCentroid |
The centroid of the positions, which is used as a point on the sorting plane when calculating distance. More... | |
bool | mFinalized |
false until the Finalize method is called. More... | |
aiVector3D | mPlaneNormal |
Normal of the sorting plane, normalized. More... | |
std::vector< Entry > | mPositions |
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.
Assimp::SpatialSort::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.
pPositions | Pointer to the first position vector of the array. |
pNumPositions | Number of vectors to expect in that array. |
pElementOffset | Offset in bytes from the beginning of one vector in memory to the beginning of the next vector. |
Assimp::SpatialSort::~SpatialSort | ( | ) |
Destructor.
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.
|
protected |
Return the distance to the sorting plane.
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.
pPositions | Pointer to the first position vector of the array. |
pNumPositions | Number of vectors to expect in that array. |
pElementOffset | Offset in bytes from the beginning of one vector in memory to the beginning of the next vector. |
pFinalize | Specifies 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. |
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.
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.
pPosition | The position to look for vertices. |
poResults | The container to store the indices of the found positions. Will be emptied by the call so it may contain anything. |
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.
pPosition | The position to look for vertices. |
pRadius | Maximal distance from the position a vertex may have to be counted in. |
poResults | The container to store the indices of the found positions. Will be emptied by the call so it may contain anything. |
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.
fill | Will be filled with numPositions entries. |
pRadius | Maximal distance from the position a vertex may have to be counted in. |
|
protected |
The centroid of the positions, which is used as a point on the sorting plane when calculating distance.
This value is calculated in Finalize.
|
protected |
false until the Finalize method is called.
|
protected |
Normal of the sorting plane, normalized.
|
protected |