holoviz-topics / EarthSim

Tools for working with and visualizing environmental simulations.
https://earthsim.holoviz.org
BSD 3-Clause "New" or "Revised" License
65 stars 21 forks source link

TriMesh vs Network Graph #238

Closed kcpevey closed 3 years ago

kcpevey commented 5 years ago

Long term, I'd like the ability to interact with the mesh in a more dynamic way.
1) Ability to view node index
2) ability to view element index
3) Ability to move nodes in drawing
4) ability to select a group of elements based on material type/kdims

I started using networkx in one of my workflows to hold my 3dm mesh vertices and edges. An issue that just came up in holoviews made me start looking into Network Graph so I started poking around at this http://holoviews.org/user_guide/Network_Graphs.html . I like some of the functionality provided with Graph as part of the TriMesh objects, namely the ability to select a node and get the node index.

I also briefly looked at TriMesh and it seems like its inheriting from Graph so I'm wondering what is their connection? By the time its a TriMesh, is it no longer a networkx graph? I see that TriMesh holds the vertices of each element, which is critical, but maybe we could expose more of the Graph functionality to TriMesh?

kcpevey commented 5 years ago

@philippjfr Can I get your opinion on this?

philippjfr commented 5 years ago

Okay, I'll start by summarizing what the relationship between Graph and TriMesh is. Fundamentally they are fairly similar, particularly in terms of the datastructures they share, which consist of:

That's why I chose to implement TriMesh as a subclass of Graph. However there is also one significant different which is that the "edges" in a TriMesh aren't really edges, they are better described as faces or simplexes. This means that unless we extend TriMesh significantly a lot of the features will not work quite right, specifically selecting on vertices or simplexes will not work quite correctly since it does not take into account the third node index of each simplex. However some of the features you asked for should be possible:

  1. Ability to view node index: This should be possible right now simply by enabling hover on a Trimesh
  2. Ability to view element index: If by element index you mean the index of the simplices that should also be possible either by adding a custom hover tool which displays the index or by adding an index column as a value dimension.
  3. Ability to move nodes in drawing: This should be reasonably straightforward to implement by drawing the nodes as a separate set of points and linking them to the node positions.
  4. Ability to select a group of elements based on material type/kdims: This would require improving TriMesh.select to take into account the third node id of each simplex and may be a bit of work.
kcpevey commented 3 years ago

This has been superseded. The available tools have changed since this was opened.