mesh – Find neighboring nodes of an STL file

I have an STL file (4000+ points in 3D, degenerated to 2D), listing all nodes of a mesh. I need to find the connectivity between these nodes based on their index as they appear on the STL file. For example:

Nodes:
X  Y  Z  ID | Connectivity
0  0  0  1  | 2 3
0  1  0  2  | 1 4
1  0  0  3  | 1 4
1  1  0  4  | 2 3

2--4
|  |
1--3

In this specific case, I know how many nodes a node is connected to. But in general, I wouldn’t. So, is there a general way of calculating this without looping through the entire mesh n times?

Read more here: Source link