Search Results for

    Show / Hide Table of Contents

    Class CachingMeshSDF

    [RMS] this is variant of MeshSignedDistanceGrid that does lazy evaluation of actual distances, using mesh spatial data structure. This is much faster if we are doing continuation-method marching cubes as only values on surface will be computed!

    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
    CachingMeshSDF
    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 CachingMeshSDF

    Constructors

    CachingMeshSDF(DMesh3, Double, DMeshAABBTree3)

    Declaration
    public CachingMeshSDF(DMesh3 mesh, double cellSize, DMeshAABBTree3 spatial)
    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

    ComputeSigns

    Declaration
    public bool ComputeSigns
    Field Value
    Type Description
    Boolean

    DebugPrint

    Declaration
    public bool DebugPrint
    Field Value
    Type Description
    Boolean

    ExpandBounds

    Declaration
    public Vector3d ExpandBounds
    Field Value
    Type Description
    Vector3d

    InsideMode

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

    MaxOffsetDistance

    Declaration
    public float MaxOffsetDistance
    Field Value
    Type Description
    Single

    Mesh

    Declaration
    public DMesh3 Mesh
    Field Value
    Type Description
    DMesh3

    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

    GetValue(Vector3i)

    Declaration
    public float GetValue(Vector3i idx)
    Parameters
    Type Name Description
    Vector3i idx
    Returns
    Type Description
    Single

    Initialize()

    Declaration
    public void Initialize()

    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
    In This Article
    Back to top ViRGIS VR GIS