Search Results for

    Show / Hide Table of Contents

    Class DMeshAABBTree3

    Hierarchical Axis-Aligned-Bounding-Box tree for a DMesh3 mesh. This class supports a variety of spatial queries, listed below.

    Various construction strategies are also available, the default is the fastest to build but if you are doing a lot of queries, you might experiment with the others (eg TopDownMedian)

    Available queries:

    • FindNearestTriangle(point, maxdist)
    • FindNearestHitTriangle(ray, maxdist)
    • FindAllHitTriangles(ray, maxdist)
    • TestIntersection(triangle)
    • TestIntersection(mesh)
    • TestIntersection(otherAABBTree)
    • FindAllIntersections(otherAABBTree)
    • FindNearestTriangles(otherAABBTree, maxdist)
    • IsInside(point)
    • WindingNumber(point)
    • FastWindingNumber(point)
    • DoTraversal(generic_traversal_object)
    Inheritance
    Object
    DMeshAABBTree3
    Implements
    ISpatial
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: g3
    Assembly: cs.temp.dll.dll
    Syntax
    public class DMeshAABBTree3 : ISpatial

    Constructors

    DMeshAABBTree3(DMesh3, Boolean)

    Declaration
    public DMeshAABBTree3(DMesh3 m, bool autoBuild = false)
    Parameters
    Type Name Description
    DMesh3 m
    Boolean autoBuild

    Fields

    BottomUpClusterLookahead

    Declaration
    public int BottomUpClusterLookahead
    Field Value
    Type Description
    Int32

    box_centers

    Declaration
    protected DVector<Vector3f> box_centers
    Field Value
    Type Description
    DVector<Vector3f>

    box_extents

    Declaration
    protected DVector<Vector3f> box_extents
    Field Value
    Type Description
    DVector<Vector3f>

    box_to_index

    Declaration
    protected DVector<int> box_to_index
    Field Value
    Type Description
    DVector<Int32>

    FWNApproxOrder

    FWN approximation order. can be 1 or 2. 2 is more accurate, obviously.

    Declaration
    public int FWNApproxOrder
    Field Value
    Type Description
    Int32

    FWNBeta

    FWN beta parameter - is 2.0 in paper

    Declaration
    public double FWNBeta
    Field Value
    Type Description
    Double

    index_list

    Declaration
    protected DVector<int> index_list
    Field Value
    Type Description
    DVector<Int32>

    mesh

    Declaration
    protected DMesh3 mesh
    Field Value
    Type Description
    DMesh3

    mesh_timestamp

    Declaration
    protected int mesh_timestamp
    Field Value
    Type Description
    Int32

    root_index

    Declaration
    protected int root_index
    Field Value
    Type Description
    Int32

    TopDownLeafMaxTriCount

    Declaration
    public int TopDownLeafMaxTriCount
    Field Value
    Type Description
    Int32

    TriangleFilterF

    If non-null, only triangle IDs that pass this filter (ie filter is true) are considered

    Declaration
    public Func<int, bool> TriangleFilterF
    Field Value
    Type Description
    Func<Int32, Boolean>

    triangles_end

    Declaration
    protected int triangles_end
    Field Value
    Type Description
    Int32

    Properties

    Bounds

    Root bounding box of tree (note: tree must be generated by calling a query function first!)

    Declaration
    public AxisAlignedBox3d Bounds { get; }
    Property Value
    Type Description
    AxisAlignedBox3d

    IsValid

    Declaration
    public bool IsValid { get; }
    Property Value
    Type Description
    Boolean

    Mesh

    Declaration
    public DMesh3 Mesh { get; }
    Property Value
    Type Description
    DMesh3

    SupportsNearestTriangle

    Does this ISpatial implementation support nearest-point query? (yes)

    Declaration
    public bool SupportsNearestTriangle { get; }
    Property Value
    Type Description
    Boolean

    SupportsPointContainment

    Does this ISpatial support IsInside() test (yes!)

    Declaration
    public bool SupportsPointContainment { get; }
    Property Value
    Type Description
    Boolean

    SupportsTriangleRayIntersection

    Does this ISpatial implementation support ray-triangle intersection? (yes)

    Declaration
    public bool SupportsTriangleRayIntersection { get; }
    Property Value
    Type Description
    Boolean

    Methods

    box_contains(Int32, Vector3d)

    Declaration
    protected bool box_contains(int iBox, Vector3d p)
    Parameters
    Type Name Description
    Int32 iBox
    Vector3d p
    Returns
    Type Description
    Boolean

    branch_fast_winding_num(Int32, Vector3d)

    Declaration
    protected double branch_fast_winding_num(int iBox, Vector3d p)
    Parameters
    Type Name Description
    Int32 iBox
    Vector3d p
    Returns
    Type Description
    Double

    branch_winding_num(Int32, Vector3d)

    Declaration
    protected double branch_winding_num(int iBox, Vector3d p)
    Parameters
    Type Name Description
    Int32 iBox
    Vector3d p
    Returns
    Type Description
    Double

    Build(DMeshAABBTree3.BuildStrategy, DMeshAABBTree3.ClusterPolicy)

    Declaration
    public void Build(DMeshAABBTree3.BuildStrategy eStrategy = DMeshAABBTree3.BuildStrategy.TopDownMidpoint, DMeshAABBTree3.ClusterPolicy ePolicy = DMeshAABBTree3.ClusterPolicy.Default)
    Parameters
    Type Name Description
    DMeshAABBTree3.BuildStrategy eStrategy
    DMeshAABBTree3.ClusterPolicy ePolicy

    build_fast_winding_cache()

    Declaration
    protected void build_fast_winding_cache()

    build_fast_winding_cache(Int32, Int32, Int32, out HashSet<Int32>, MeshTriInfoCache)

    Declaration
    protected int build_fast_winding_cache(int iBox, int depth, int tri_count_thresh, out HashSet<int> tri_hash, MeshTriInfoCache triCache)
    Parameters
    Type Name Description
    Int32 iBox
    Int32 depth
    Int32 tri_count_thresh
    HashSet<Int32> tri_hash
    MeshTriInfoCache triCache
    Returns
    Type Description
    Int32

    build_winding_cache()

    Declaration
    protected void build_winding_cache()

    build_winding_cache(Int32, Int32, Int32, out HashSet<Int32>)

    Declaration
    protected int build_winding_cache(int iBox, int depth, int tri_count_thresh, out HashSet<int> tri_hash)
    Parameters
    Type Name Description
    Int32 iBox
    Int32 depth
    Int32 tri_count_thresh
    HashSet<Int32> tri_hash
    Returns
    Type Description
    Int32

    can_use_fast_winding_cache(Int32, ref Vector3d)

    Declaration
    protected bool can_use_fast_winding_cache(int iBox, ref Vector3d q)
    Parameters
    Type Name Description
    Int32 iBox
    Vector3d q
    Returns
    Type Description
    Boolean

    collect_triangles(Int32, HashSet<Int32>)

    Declaration
    protected void collect_triangles(int iBox, HashSet<int> triangles)
    Parameters
    Type Name Description
    Int32 iBox
    HashSet<Int32> triangles

    DoTraversal(DMeshAABBTree3.TreeTraversal)

    Hierarchically descend through the tree nodes, calling the TreeTrversal functions at each level

    Declaration
    public virtual void DoTraversal(DMeshAABBTree3.TreeTraversal traversal)
    Parameters
    Type Name Description
    DMeshAABBTree3.TreeTraversal traversal

    evaluate_box_fast_winding_cache(Int32, ref Vector3d)

    Declaration
    protected double evaluate_box_fast_winding_cache(int iBox, ref Vector3d q)
    Parameters
    Type Name Description
    Int32 iBox
    Vector3d q
    Returns
    Type Description
    Double

    evaluate_box_winding_cache(Int32, Vector3d)

    Declaration
    protected double evaluate_box_winding_cache(int iBox, Vector3d p)
    Parameters
    Type Name Description
    Int32 iBox
    Vector3d p
    Returns
    Type Description
    Double

    FastWindingNumber(Vector3d)

    Fast approximation of winding number using far-field approximations

    Declaration
    public virtual double FastWindingNumber(Vector3d p)
    Parameters
    Type Name Description
    Vector3d p
    Returns
    Type Description
    Double

    find_all_hit_triangles(Int32, List<Int32>, ref Ray3d, Double)

    Declaration
    protected int find_all_hit_triangles(int iBox, List<int> hitTriangles, ref Ray3d ray, double fMaxDist)
    Parameters
    Type Name Description
    Int32 iBox
    List<Int32> hitTriangles
    Ray3d ray
    Double fMaxDist
    Returns
    Type Description
    Int32

    find_any_intersection(Int32, DMeshAABBTree3, Func<Vector3d, Vector3d>, Int32, Int32)

    Declaration
    protected bool find_any_intersection(int iBox, DMeshAABBTree3 otherTree, Func<Vector3d, Vector3d> TransformF, int oBox, int depth)
    Parameters
    Type Name Description
    Int32 iBox
    DMeshAABBTree3 otherTree
    Func<Vector3d, Vector3d> TransformF
    Int32 oBox
    Int32 depth
    Returns
    Type Description
    Boolean

    find_any_intersection(Int32, ref Triangle3d, ref AxisAlignedBox3d)

    Declaration
    protected int find_any_intersection(int iBox, ref Triangle3d triangle, ref AxisAlignedBox3d triBounds)
    Parameters
    Type Name Description
    Int32 iBox
    Triangle3d triangle
    AxisAlignedBox3d triBounds
    Returns
    Type Description
    Int32

    find_hit_triangle(Int32, ref Ray3d, ref Double, ref Int32)

    Declaration
    protected void find_hit_triangle(int iBox, ref Ray3d ray, ref double fNearestT, ref int tID)
    Parameters
    Type Name Description
    Int32 iBox
    Ray3d ray
    Double fNearestT
    Int32 tID

    find_intersections(Int32, DMeshAABBTree3, Func<Vector3d, Vector3d>, Int32, Int32, IntrTriangle3Triangle3, DMeshAABBTree3.IntersectionsQueryResult)

    Declaration
    protected void find_intersections(int iBox, DMeshAABBTree3 otherTree, Func<Vector3d, Vector3d> TransformF, int oBox, int depth, IntrTriangle3Triangle3 intr, DMeshAABBTree3.IntersectionsQueryResult result)
    Parameters
    Type Name Description
    Int32 iBox
    DMeshAABBTree3 otherTree
    Func<Vector3d, Vector3d> TransformF
    Int32 oBox
    Int32 depth
    IntrTriangle3Triangle3 intr
    DMeshAABBTree3.IntersectionsQueryResult result

    find_nearest_tri(Int32, Vector3d, ref Double, ref Int32)

    Declaration
    protected void find_nearest_tri(int iBox, Vector3d p, ref double fNearestSqr, ref int tID)
    Parameters
    Type Name Description
    Int32 iBox
    Vector3d p
    Double fNearestSqr
    Int32 tID

    find_nearest_triangles(Int32, DMeshAABBTree3, Func<Vector3d, Vector3d>, Int32, Int32, ref Double, ref Index2i)

    Declaration
    protected void find_nearest_triangles(int iBox, DMeshAABBTree3 otherTree, Func<Vector3d, Vector3d> TransformF, int oBox, int depth, ref double nearest_sqr, ref Index2i nearest_pair)
    Parameters
    Type Name Description
    Int32 iBox
    DMeshAABBTree3 otherTree
    Func<Vector3d, Vector3d> TransformF
    Int32 oBox
    Int32 depth
    Double nearest_sqr
    Index2i nearest_pair

    find_nearest_vtx(Int32, Vector3d, ref Double, ref Int32)

    Declaration
    protected void find_nearest_vtx(int iBox, Vector3d p, ref double fNearestSqr, ref int vid)
    Parameters
    Type Name Description
    Int32 iBox
    Vector3d p
    Double fNearestSqr
    Int32 vid

    FindAllHitTriangles(Ray3d, List<Int32>, Double)

    Find the ids of all the triangles that they ray intersects, within distance fMaxDist from ray origin Returns count of triangles.

    Declaration
    public virtual int FindAllHitTriangles(Ray3d ray, List<int> hitTriangles = null, double fMaxDist = 1.7976931348623157E+308)
    Parameters
    Type Name Description
    Ray3d ray
    List<Int32> hitTriangles
    Double fMaxDist
    Returns
    Type Description
    Int32

    FindAllIntersections(DMeshAABBTree3, Func<Vector3d, Vector3d>)

    Compute all intersections between two Meshes. TransformF argument transforms vertices of otherTree to our tree (can be null if in same coord space) Returns pairs of intersecting triangles, which could intersect in either point or segment Currently does not return coplanar intersections.

    Declaration
    public virtual DMeshAABBTree3.IntersectionsQueryResult FindAllIntersections(DMeshAABBTree3 otherTree, Func<Vector3d, Vector3d> TransformF = null)
    Parameters
    Type Name Description
    DMeshAABBTree3 otherTree
    Func<Vector3d, Vector3d> TransformF
    Returns
    Type Description
    DMeshAABBTree3.IntersectionsQueryResult

    FindNearestHitTriangle(Ray3d, Double)

    find id of first triangle that ray hits, within distance fMaxDist, or return DMesh3.InvalidID Use MeshQueries.TriangleIntersection() to get more information

    Declaration
    public virtual int FindNearestHitTriangle(Ray3d ray, double fMaxDist = 1.7976931348623157E+308)
    Parameters
    Type Name Description
    Ray3d ray
    Double fMaxDist
    Returns
    Type Description
    Int32

    FindNearestTriangle(Vector3d, Double)

    Find the triangle closest to p, within distance fMaxDist, or return InvalidID Use MeshQueries.TriangleDistance() to get more information

    Declaration
    public virtual int FindNearestTriangle(Vector3d p, double fMaxDist = 1.7976931348623157E+308)
    Parameters
    Type Name Description
    Vector3d p
    Double fMaxDist
    Returns
    Type Description
    Int32

    FindNearestTriangle(Vector3d, out Double, Double)

    Find the triangle closest to p, and distance to it, within distance fMaxDist, or return InvalidID Use MeshQueries.TriangleDistance() to get more information

    Declaration
    public virtual int FindNearestTriangle(Vector3d p, out double fNearestDistSqr, double fMaxDist = 1.7976931348623157E+308)
    Parameters
    Type Name Description
    Vector3d p
    Double fNearestDistSqr
    Double fMaxDist
    Returns
    Type Description
    Int32

    FindNearestTriangles(DMeshAABBTree3, Func<Vector3d, Vector3d>, out Double, Double)

    Find nearest pair of triangles on this tree with otherTree, within max_dist. TransformF transforms vertices of otherTree into our coordinates. can be null. returns triangle-id pair (my_tri,other_tri), or Index2i.Max if not found within max_dist Use MeshQueries.TrianglesDistance() to get more information

    Declaration
    public virtual Index2i FindNearestTriangles(DMeshAABBTree3 otherTree, Func<Vector3d, Vector3d> TransformF, out double distance, double max_dist = 1.7976931348623157E+308)
    Parameters
    Type Name Description
    DMeshAABBTree3 otherTree
    Func<Vector3d, Vector3d> TransformF
    Double distance
    Double max_dist
    Returns
    Type Description
    Index2i

    FindNearestVertex(Vector3d, Double)

    Find the vertex closest to p, within distance fMaxDist, or return InvalidID

    Declaration
    public virtual int FindNearestVertex(Vector3d p, double fMaxDist = 1.7976931348623157E+308)
    Parameters
    Type Name Description
    Vector3d p
    Double fMaxDist
    Returns
    Type Description
    Int32

    IsInside(Vector3d)

    Returns true if point p is inside this mesh.

    Declaration
    public virtual bool IsInside(Vector3d p)
    Parameters
    Type Name Description
    Vector3d p
    Returns
    Type Description
    Boolean

    make_box_fast_winding_cache(Int32, IEnumerable<Int32>, MeshTriInfoCache)

    Declaration
    protected void make_box_fast_winding_cache(int iBox, IEnumerable<int> triangles, MeshTriInfoCache triCache)
    Parameters
    Type Name Description
    Int32 iBox
    IEnumerable<Int32> triangles
    MeshTriInfoCache triCache

    make_box_winding_cache(Int32, HashSet<Int32>)

    Declaration
    protected void make_box_winding_cache(int iBox, HashSet<int> triangles)
    Parameters
    Type Name Description
    Int32 iBox
    HashSet<Int32> triangles

    TestCoverage()

    Declaration
    public void TestCoverage()

    TestIntersection(DMeshAABBTree3, Func<Vector3d, Vector3d>)

    Returns true if there is any intersection between our mesh and 'other' mesh. TransformF takes vertices of otherTree into our tree - can be null if in same coord space

    Declaration
    public virtual bool TestIntersection(DMeshAABBTree3 otherTree, Func<Vector3d, Vector3d> TransformF = null)
    Parameters
    Type Name Description
    DMeshAABBTree3 otherTree
    Func<Vector3d, Vector3d> TransformF
    Returns
    Type Description
    Boolean

    TestIntersection(IMesh, Func<Vector3d, Vector3d>, Boolean)

    return true if any triangle of testMesh intersects with our tree. Use TransformF to transform vertices of testMesh into space of this tree. if boundsCheck is false, we skip bbox/bbox early-out

    Declaration
    public virtual bool TestIntersection(IMesh testMesh, Func<Vector3d, Vector3d> TransformF = null, bool bBoundsCheck = true)
    Parameters
    Type Name Description
    IMesh testMesh
    Func<Vector3d, Vector3d> TransformF
    Boolean bBoundsCheck
    Returns
    Type Description
    Boolean

    TestIntersection(Triangle3d)

    Returns true if triangle intersects any triangle of our mesh

    Declaration
    public virtual bool TestIntersection(Triangle3d triangle)
    Parameters
    Type Name Description
    Triangle3d triangle
    Returns
    Type Description
    Boolean

    TotalExtentSum()

    Total sum-of-extents over all boxes in the tree. Mainly useful to evaluate tree quality.

    Declaration
    public double TotalExtentSum()
    Returns
    Type Description
    Double

    TotalVolume()

    Total sum of volumes of all boxes in the tree. Mainly useful to evaluate tree quality.

    Declaration
    public double TotalVolume()
    Returns
    Type Description
    Double

    tree_traversal(Int32, Int32, DMeshAABBTree3.TreeTraversal)

    Declaration
    protected virtual void tree_traversal(int iBox, int depth, DMeshAABBTree3.TreeTraversal traversal)
    Parameters
    Type Name Description
    Int32 iBox
    Int32 depth
    DMeshAABBTree3.TreeTraversal traversal

    WindingNumber(Vector3d)

    Evaluate the mesh winding number at point. To do this, we must construct additional information to short-circuit tree branches. This happens on the first evaluation. This does consume some additional memory, mainly temporary memory during construction. (eg on a 500k sphere, about 30mb to construct, but then only 2-5mb is stored at the end) If you don't want this, just use Mesh.WindingNumber() directly. Also note that if you are only evaluating a few times, it is not sensible - assume you need at least hundreds of evaluations to see speed improvements.

    Declaration
    public virtual double WindingNumber(Vector3d p)
    Parameters
    Type Name Description
    Vector3d p
    Returns
    Type Description
    Double

    Implements

    ISpatial
    In This Article
    Back to top ViRGIS VR GIS