Search Results for

    Show / Hide Table of Contents

    Class SpatialSort

    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.

    Inheritance
    SpatialSort
    Namespace: Assimp
    Assembly: FlaxEngine.dll
    File: Engine/Tools/ModelTool/SpatialSort.h
    Syntax
    public class SpatialSort

    Constructors

    ~SpatialSort()

    Destructor

    Declaration
    public ~SpatialSort()

    SpatialSort()

    Declaration
    public 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.

    Declaration
    public SpatialSort(const aiVector3D* pPositions, unsigned int pNumPositions, unsigned int pElementOffset)
    Parameters
    aiVector3D pPositions

    Pointer to the first position vector of the array.

    unsigned int pNumPositions

    Number of vectors to expect in that array.

    unsigned int pElementOffset

    Offset in bytes from the beginning of one vector in memory to the beginning of the next vector.

    Fields

    mPlaneNormal

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

    Declaration
    protected aiVector3D mPlaneNormal
    Field Value
    aiVector3D

    mPositions

    Declaration
    protected std::vector<Entry> mPositions
    Field Value
    std::vector<Entry>

    Methods

    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.

    Declaration
    public void Append(const aiVector3D* pPositions, unsigned int pNumPositions, unsigned int pElementOffset, bool pFinalize=true)
    Parameters
    aiVector3D pPositions

    unsigned int pNumPositions

    unsigned int pElementOffset

    bool pFinalize

    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.

    Declaration
    public void Fill(const aiVector3D* pPositions, unsigned int pNumPositions, unsigned int pElementOffset, bool pFinalize=true)
    Parameters
    aiVector3D pPositions

    Pointer to the first position vector of the array.

    unsigned int pNumPositions

    Number of vectors to expect in that array.

    unsigned int pElementOffset

    Offset in bytes from the beginning of one vector in memory to the beginning of the next vector.

    bool 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.

    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.

    Declaration
    public void Finalize()

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

    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.

    Declaration
    public void FindIdenticalPositions(const aiVector3D& pPosition, std::vector<unsigned int>& poResults) const
    Parameters
    aiVector3D pPosition

    The position to look for vertices.

    std::vector<unsigned int> poResults

    The container to store the indices of the found positions. Will be emptied by the call so it may contain anything.

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

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

    Declaration
    public void FindPositions(const aiVector3D& pPosition, ai_real pRadius, std::vector<unsigned int>& poResults) const
    Parameters
    aiVector3D pPosition

    The position to look for vertices.

    ai_real pRadius

    Maximal distance from the position a vertex may have to be counted in.

    std::vector<unsigned int> poResults

    The container to store the indices of the found positions. Will be emptied by the call so it may contain anything.

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

    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.

    Declaration
    public unsigned int GenerateMappingTable(std::vector<unsigned int>& fill, ai_real pRadius) const
    Parameters
    std::vector<unsigned int> fill

    Will be filled with numPositions entries.

    ai_real pRadius

    Maximal distance from the position a vertex may have to be counted in.

    Returns
    unsigned int

    Number of unique vertices (n).

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat