This project is read-only.

Connectivity diagram

Dec 6, 2013 at 7:22 PM
Edited Dec 6, 2013 at 7:24 PM
Hi,
congratualtion to the library really fast and accesible.
But i am woundering is there a way using 3D DelaunayTriangulation toget a connecivity diagram of the connected points? Any idea?
e.g vertex 0 => is connected to vertex 1,3,4,5
Dec 7, 2013 at 7:12 PM
The best way would be to post-process this information from the faces.
Make a dictionary with keys of type vertex and values of type List<vertex>
seed the entire with dictionary with all entries and new but empty List<vertex> for the values.
foreach face, f:
foreach vertex in face, v:
   Get the dictionary value for v and add the other 2 v's if they are not already present in the List
Dec 7, 2013 at 9:17 PM
I am clear that i have to postprocess, but i do not really understand how to get the diagram of connections every vertex has in the pointcloud with this approach?
Dec 9, 2013 at 10:10 AM
Edited Dec 9, 2013 at 10:10 AM
thanks for your reply and help.
can you mayhelp me out how can i access Adjacency of the cell.
regarding the wpfdelaunay example i can acces them threw tetrahedrons.ElementAt(0).Adjacency[0]
The output is than a TFace[] ....can you help me to access the data?
And how do i get the faces for the example above?
Dec 9, 2013 at 11:46 PM
Edited Dec 10, 2013 at 5:27 AM
Hi, this should work:
public static Dictionary<TVertex, TVertex[]> CreateTriangulationMap(ITriangulation<TVertex, TTetrahedron> tri)
{
    Dictionary<TVertex, HashSet<TVertex>> mapSet = new Dictionary<TVertex, HashSet<TVertex>>(); 
    foreach (var cell in tri.Cells)
    {
        for (int i = 0; i < 4; i++)
        {
            HashSet<TVertex> set;
            if (!mapSet.TryGetValue(cell.Vertices[i], out set))
            {
                set = new HashSet<TVertex>();
                mapSet[cell.Vertices[i]] = set;
            }
            for (int j = 0; j < 4; j++)
            {
                if (i != j)
                {
                    set.Add(cell.Vertices[j]);
                }
            }
        }
    }
    return mapSet.ToDictionary(a => a.Key, a => a.Value.ToArray());
}
Edit: realized there is no ITriangulation3D in the MIConvexHull code, I just copy pasted this from one of my projects and forgot to change it.
Dec 10, 2013 at 12:29 PM
Hi,
Yeah I realized that, that it is ITriangulation, thanks a lot, works well for the Vertices of the DelaunayTriangulation,
The only thing which I would recommend is that there is a dependencies missing between the input points and the output of the Delaunay.
I post-processed that to have the dependency graph in the same order as the input points.
Do you have an idea to advance your example to implement this?
Dec 10, 2013 at 1:01 PM
The only thing which I would recommend is that there is a dependencies missing between the input points and the output of the Delaunay.
I am not quite sure what you mean by this.
I post-processed that to have the dependency graph in the same order as the input points.
Maybe it would be a better idea to just add an Index property to you Vertex representation:
class MyVertex : IVertex
{
  public int Index { get; private set; }
  ...
  public MyVertex(int index, ...) { ... }
}
Do you have an idea to advance your example to implement this?
I don't really see much point in doing this.
Dec 10, 2013 at 1:25 PM
Dear Davecz,
with the dependencies i ment that the Vertertices/Cells of the
Triangulation.CreateDelaunay<Vertex, Tetrahedron>(vertices);
are no longer in any relationship to the input of the vertices.
But i think the idea of the Index property will solve that quite easy.
Again really fast lib and easy to adapt to certain ideas or computatonal needs.