How to find connected triangles on a 3d mesh - algorithm

I have a file exported from a 3d application like Blender or Maya. I am able to read the files. I end up with indices describing each triangle and a vertex list.
The file can have more than one connected mesh, two spheres for example. I want to select individual meshes by finding connected triangles. What is the best way to do this? What geometric algorithms can I use? Any examples? Can it be multi threaded?

What you need is a graph solution.
Take all the data, the vertices become nodes in the graph, the edges linking vertices, link the nodes in the graph. Run a DSF/BFS on it marking all the nodes that you visit. All the nodes marked belong to the same object.
Run it again starting from an unmarked nodes to find additional objects.
You can construct a graph in parallel if you think it's easier, but you should be able to do it with the geometrical data as well.

A graph solution indeed, but with triangles as nodes and adjacent edges as connections between nodes. This can then be solved as a max clique problem.

Related

Constrained shortest distance in a graph

I came across this problem at a coding site and I have no idea on how to solve it. The editorial is not available nor was I able to find any related article online. So I am asking this here.
Problem:
You have a graph G that contains N vertices and M edges. The vertices are numbered from 1 through N. Also each node is colored either Black or White. You want to calculate the shortest path from 1 to N such that the difference of black and white nodes is at most 1.
As obvious as it is, applying straight forward Dijkstra's Algorithm will not work. Any help is appreciated. Thank you!
We can consider a modified graph and run Dijkstra on this one:
For each node in the original graph, the modified graph will have multiple meta vertices (theoretically, infinitely many) that each correspond to a different black-white difference. You only need to create the nodes as you explore the graph with Dijkstra. Thus, you won't need infinitely many nodes.
The edges are then pretty simple (you can also create them while exploring). If you are currently at a node with black-white difference d and the original graph has an edge to a white node, then you create an edge to the respective node with black-white difference d-1. If the original graph has an edge to a black node, you create an edge in the modified graph to the respective node with black-white difference d+1. You don't necessarily need to treat them as different nodes. You can also store the Dijkstra variables in the node grouped by black-white difference.
Running Dijkstra in this way will give you the shortest paths to any node with any black-white difference. As soon as you reach the target node with an acceptable black-white difference, you are done.

Polygons tree building by segments linking

Suppose a set of 2d polygons is given.
What I am trying to do is to link all the polygons together by segments in a such way that:
each of the segments does not intersect any polygons in between (i.e. it connects the "visible" points of the polygon)
the path along the segments from one polygon to another does not have any loops(if you consider polygons to be the nodes of the graph and the segments to be the edges then the graph has no cycles, i.e. there is a tree of polygons).
For example:
At the moment I am solving the problem by brute force search of the segments from each polygon to all the others checking if there is no intersections in between. And then I am using Kruskal algorithm to find a tree, so the path could be constructed. The solution is ok for "simple" polygons but quite time consuming for more complex ones when the number of vertices and polygons is big.
Are there similar problems or better solutions to this problem ?

Quickest way to determine if a rectangular graph would be partitioned if a node is removed

I am working on an atmospheric simulation for a video game, and a problem I have stumbled into is that I need a cheap (in processing time) way to determine if a graph of nodes in a rectangular grid (each node is connected to up to four neighbours, NSEW) would become partitioned if I removed a particular node.
I have tried searching for ways of detecting if a graph is partitioned but so far I have not found anything that suits my problem. I have not taken advanced math courses and only have basic knowledge of graph theory so it is possible that I just have not been searching with the right terms.
If possible, it would be very very desirable to avoid having to search through the whole graph.
You can find articulation points using a modified depth first search - see http://en.wikipedia.org/wiki/Biconnected_component. An articulation point of a graph is a node that, if removed, disconnects the graph. Every graph can be split up at the articulation points into biconnected components. If you are lucky, you just need to know whether a point is an articulation point. If not, perhaps splitting the graph up into a tree of biconnected components and analysing them will help.

Multiple source shortest path...Embeded plannar graph

The tree on which mssp(multiple source shortest path) can be executed, is stated in many papers that it must be an embeded plannar graph. Does this mean that there can be no edges that overlap each other? If so is possible to change such graph into a plannar graph?
The canonical input to MSSP is a doubly connected edge list or something like it that gives the combinatorial topology of the graph but not the geometry. If you have a straight-line graph that's not planar (i.e., it has edges that cross or overlap), then you need to change the graph somehow. One possibility is to introduce a new vertex everywhere there's an intersection; another is to delete problematic edges.

How to find pair edge while building half-edge datastructure

I wrote my half-edge datastructure based on this webpage.
The mesh is loaded from a .obj, contained info for each vertex and what 3 vertices compose a face.
The only problem is: how do I know what's the pair edge for a specific edge?
Right now I record not only end vertex but also start vertex info in edge struct,
compare O(N^2) to find out pair edge.
I think there is a better way but don't know how.

Resources