Search Results for

    Show / Hide Table of Contents

    Class MeshSignedDistanceGrid

    Compute discretely-sampled (ie gridded) signed distance field for a mesh The basic approach is, first compute exact distances in a narrow band, and then extend out to rest of grid using fast "sweeping" (ie like a distance transform). The resulting unsigned grid is then signed using ray-intersection counting, which is also computed on the grid, so no BVH is necessary

    If you set ComputeMode to NarrowBandOnly, result is a narrow-band signed distance field. This is quite a bit faster as the sweeping is the most computationally-intensive step.

    Caveats:

    • the "narrow band" is based on triangle bounding boxes, so it is not necessarily that "narrow" if you have large triangles on a diagonal to grid axes

    Potential optimizations:

    • Often we have a spatial data structure that would allow faster computation of the narrow-band distances (which become quite expensive if we want a wider band!) Not clear how to take advantage of this though. Perhaps we could have a binary grid that, in first pass, we set bits inside triangle bboxes to 1? Or perhaps same as current code, but we use spatial-dist, and so for each ijk we only compute once? (then have to test for computed value at each cell of each triangle...)

    This code is based on the C++ implementation found at https://github.com/christopherbatty/SDFGen Original license was public domain. Permission granted by Christopher Batty to include C# port under Boost license.

    Inheritance
    Object
    MeshSignedDistanceGrid
    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 MeshSignedDistanceGrid

    Constructors

    MeshSignedDistanceGrid(DMesh3, Double, DMeshAABBTree3)

    Declaration
    public MeshSignedDistanceGrid(DMesh3 mesh, double cellSize, DMeshAABBTree3 spatial = null)
    Parameters
    Type Name Description
    DMesh3 mesh
    Double cellSize
    DMeshAABBTree3 spatial

    Fields

    CancelF

    if this function returns true, we should abort calculation

    Declaration
    public Func<bool> CancelF
    Field Value
    Type Description
    Func<Boolean>

    CellSize

    Declaration
    public float CellSize
    Field Value
    Type Description
    Single

    ComputeMode

    Declaration
    public MeshSignedDistanceGrid.ComputeModes ComputeMode
    Field Value
    Type Description
    MeshSignedDistanceGrid.ComputeModes

    ComputeSigns

    Declaration
    public bool ComputeSigns
    Field Value
    Type Description
    Boolean

    DebugPrint

    Declaration
    public bool DebugPrint
    Field Value
    Type Description
    Boolean

    ExactBandWidth

    Declaration
    public int ExactBandWidth
    Field Value
    Type Description
    Int32

    ExpandBounds

    Declaration
    public Vector3d ExpandBounds
    Field Value
    Type Description
    Vector3d

    InsideMode

    Declaration
    public MeshSignedDistanceGrid.InsideModes InsideMode
    Field Value
    Type Description
    MeshSignedDistanceGrid.InsideModes

    Mesh

    Declaration
    public DMesh3 Mesh
    Field Value
    Type Description
    DMesh3

    NarrowBandMaxDistance

    Declaration
    public double NarrowBandMaxDistance
    Field Value
    Type Description
    Double

    Spatial

    Declaration
    public DMeshAABBTree3 Spatial
    Field Value
    Type Description
    DMeshAABBTree3

    UseParallel

    Declaration
    public bool UseParallel
    Field Value
    Type Description
    Boolean

    WantClosestTriGrid

    Declaration
    public bool WantClosestTriGrid
    Field Value
    Type Description
    Boolean

    WantIntersectionsGrid

    Declaration
    public bool WantIntersectionsGrid
    Field Value
    Type Description
    Boolean

    Properties

    ClosestTriGrid

    Declaration
    public DenseGrid3i ClosestTriGrid { get; }
    Property Value
    Type Description
    DenseGrid3i

    Dimensions

    Declaration
    public Vector3i Dimensions { get; }
    Property Value
    Type Description
    Vector3i

    Grid

    SDF grid available after calling Compute()

    Declaration
    public DenseGrid3f Grid { get; }
    Property Value
    Type Description
    DenseGrid3f

    GridOrigin

    Origin of the SDF grid, in same coordinates as mesh

    Declaration
    public Vector3f GridOrigin { get; }
    Property Value
    Type Description
    Vector3f

    IntersectionsGrid

    Declaration
    public DenseGrid3i IntersectionsGrid { get; }
    Property Value
    Type Description
    DenseGrid3i

    Item[Vector3i]

    Declaration
    public float this[Vector3i idx] { get; }
    Parameters
    Type Name Description
    Vector3i idx
    Property Value
    Type Description
    Single

    Item[Int32, Int32, Int32]

    Declaration
    public float this[int i, int j, int k] { get; }
    Parameters
    Type Name Description
    Int32 i
    Int32 j
    Int32 k
    Property Value
    Type Description
    Single

    Methods

    CellCenter(Int32, Int32, Int32)

    Declaration
    public Vector3f CellCenter(int i, int j, int k)
    Parameters
    Type Name Description
    Int32 i
    Int32 j
    Int32 k
    Returns
    Type Description
    Vector3f

    Compute()

    Declaration
    public void Compute()

    orientation(Double, Double, Double, Double, out Double)

    Declaration
    public static int orientation(double x1, double y1, double x2, double y2, out double twice_signed_area)
    Parameters
    Type Name Description
    Double x1
    Double y1
    Double x2
    Double y2
    Double twice_signed_area
    Returns
    Type Description
    Int32

    point_in_triangle_2d(Double, Double, Double, Double, Double, Double, Double, Double, out Double, out Double, out Double)

    Declaration
    public static bool point_in_triangle_2d(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, out double a, out double b, out double c)
    Parameters
    Type Name Description
    Double x0
    Double y0
    Double x1
    Double y1
    Double x2
    Double y2
    Double x3
    Double y3
    Double a
    Double b
    Double c
    Returns
    Type Description
    Boolean

    point_segment_distance(ref Vector3d, ref Vector3d, ref Vector3d)

    Declaration
    public static double point_segment_distance(ref Vector3d x0, ref Vector3d x1, ref Vector3d x2)
    Parameters
    Type Name Description
    Vector3d x0
    Vector3d x1
    Vector3d x2
    Returns
    Type Description
    Double

    point_segment_distance(ref Vector3f, ref Vector3f, ref Vector3f)

    Declaration
    public static float point_segment_distance(ref Vector3f x0, ref Vector3f x1, ref Vector3f x2)
    Parameters
    Type Name Description
    Vector3f x0
    Vector3f x1
    Vector3f x2
    Returns
    Type Description
    Single

    point_triangle_distance(ref Vector3d, ref Vector3d, ref Vector3d, ref Vector3d)

    Declaration
    public static double point_triangle_distance(ref Vector3d x0, ref Vector3d x1, ref Vector3d x2, ref Vector3d x3)
    Parameters
    Type Name Description
    Vector3d x0
    Vector3d x1
    Vector3d x2
    Vector3d x3
    Returns
    Type Description
    Double

    point_triangle_distance(ref Vector3f, ref Vector3f, ref Vector3f, ref Vector3f)

    Declaration
    public static float point_triangle_distance(ref Vector3f x0, ref Vector3f x1, ref Vector3f x2, ref Vector3f x3)
    Parameters
    Type Name Description
    Vector3f x0
    Vector3f x1
    Vector3f x2
    Vector3f x3
    Returns
    Type Description
    Single
    In This Article
    Back to top ViRGIS VR GIS