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
DMeshAABBTree3
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
Fields
BottomUpClusterLookahead
Declaration
public int BottomUpClusterLookahead
Field Value
box_centers
Declaration
protected DVector<Vector3f> box_centers
Field Value
box_extents
Declaration
protected DVector<Vector3f> box_extents
Field Value
box_to_index
Declaration
protected DVector<int> box_to_index
Field Value
FWNApproxOrder
FWN approximation order. can be 1 or 2. 2 is more accurate, obviously.
Declaration
public int FWNApproxOrder
Field Value
FWNBeta
FWN beta parameter - is 2.0 in paper
Declaration
Field Value
index_list
Declaration
protected DVector<int> index_list
Field Value
mesh
Declaration
Field Value
mesh_timestamp
Declaration
protected int mesh_timestamp
Field Value
root_index
Declaration
Field Value
TopDownLeafMaxTriCount
Declaration
public int TopDownLeafMaxTriCount
Field Value
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
triangles_end
Declaration
protected int triangles_end
Field Value
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
IsValid
Declaration
public bool IsValid { get; }
Property Value
Mesh
Declaration
public DMesh3 Mesh { get; }
Property Value
SupportsNearestTriangle
Does this ISpatial implementation support nearest-point query? (yes)
Declaration
public bool SupportsNearestTriangle { get; }
Property Value
SupportsPointContainment
Does this ISpatial support IsInside() test (yes!)
Declaration
public bool SupportsPointContainment { get; }
Property Value
SupportsTriangleRayIntersection
Does this ISpatial implementation support ray-triangle intersection? (yes)
Declaration
public bool SupportsTriangleRayIntersection { get; }
Property Value
Methods
box_contains(Int32, Vector3d)
Declaration
protected bool box_contains(int iBox, Vector3d p)
Parameters
Returns
branch_fast_winding_num(Int32, Vector3d)
Declaration
protected double branch_fast_winding_num(int iBox, Vector3d p)
Parameters
Returns
branch_winding_num(Int32, Vector3d)
Declaration
protected double branch_winding_num(int iBox, Vector3d p)
Parameters
Returns
Build(DMeshAABBTree3.BuildStrategy, DMeshAABBTree3.ClusterPolicy)
Declaration
public void Build(DMeshAABBTree3.BuildStrategy eStrategy = DMeshAABBTree3.BuildStrategy.TopDownMidpoint, DMeshAABBTree3.ClusterPolicy ePolicy = DMeshAABBTree3.ClusterPolicy.Default)
Parameters
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
Returns
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
Returns
can_use_fast_winding_cache(Int32, ref Vector3d)
Declaration
protected bool can_use_fast_winding_cache(int iBox, ref Vector3d q)
Parameters
Returns
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
evaluate_box_fast_winding_cache(Int32, ref Vector3d)
Declaration
protected double evaluate_box_fast_winding_cache(int iBox, ref Vector3d q)
Parameters
Returns
evaluate_box_winding_cache(Int32, Vector3d)
Declaration
protected double evaluate_box_winding_cache(int iBox, Vector3d p)
Parameters
Returns
FastWindingNumber(Vector3d)
Fast approximation of winding number using far-field approximations
Declaration
public virtual double FastWindingNumber(Vector3d p)
Parameters
Returns
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
Returns
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
Returns
find_any_intersection(Int32, ref Triangle3d, ref AxisAlignedBox3d)
Declaration
protected int find_any_intersection(int iBox, ref Triangle3d triangle, ref AxisAlignedBox3d triBounds)
Parameters
Returns
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
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
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
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
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
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
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
Returns
IsInside(Vector3d)
Returns true if point p is inside this mesh.
Declaration
public virtual bool IsInside(Vector3d p)
Parameters
Returns
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
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
Returns
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
Returns
TestIntersection(Triangle3d)
Returns true if triangle intersects any triangle of our mesh
Declaration
public virtual bool TestIntersection(Triangle3d triangle)
Parameters
Returns
TotalExtentSum()
Total sum-of-extents over all boxes in the tree. Mainly useful to evaluate tree quality.
Declaration
public double TotalExtentSum()
Returns
TotalVolume()
Total sum of volumes of all boxes in the tree. Mainly useful to evaluate tree quality.
Declaration
public double TotalVolume()
Returns
tree_traversal(Int32, Int32, DMeshAABBTree3.TreeTraversal)
Declaration
protected virtual void tree_traversal(int iBox, int depth, DMeshAABBTree3.TreeTraversal traversal)
Parameters
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
Returns
Implements