Need help making a 3D mesh given co-ordinates of the vertices and vertex indices of each face for 3D Slicer - trimesh/vtkwrite/etc

Hi all,

Given the following data:

  1. The Cartesian co-ordinates of the vertices in the surface mesh: n vertices x 3
  2. The vertex indices of each face in the surface mesh: n faces x 3

I’m trying to make some 3D file that I can readily import to 3D Slicer for registration against a 2nd VTK file.

Faces: 339,263,314340,315,263340,293,315368,314,313368,339,314369,263,33936 - Pastebin.com
Vertices: 16.215,13.236,126.06516.149,14.237,125.70816.843,13.707,125.85115.178,14.2 - Pastebin.com

I have been trying various packages/libraries etc.

I’ve tried Trimesh in Python and am running into issues probably due to my poor Python ability. I’m opening a Stackoverflow question about that separately. I’ve used vtkwrite but the “Precision” option is broken in the package and it’s doing some odd-rounding that is changing the original data too much.

From the supporting data formats page, it seems like I want something other than VTK that will preserve orientation.

How are ya’ll overcoming this?

I’m no expert but I’ve seen this done with vtkPolydata - if anyone else weighs in I’d defer to them! You can see an example of it here:

In this example, a scalar value is assigned to each vertex but I don’t think that’s required for polydata. I’m not sure if you’ll face the same rounding issues you’re having with Trimesh.

1 Like

Ah back to SlicerEAMapReader, I have a ticket open on that Git due to some issues with the latest version (4.13) and Slicer 5.0.3. Nontheless, the script is helpful, thanks! Looking forward to more input.