BVtkNodes icon indicating copy to clipboard operation
BVtkNodes copied to clipboard

Triangle elements in VTK Unstructured Grids convert incorrectly

Open topabs61 opened this issue 4 years ago • 6 comments

Hello. I'm doing Scientific Visualization with VTK and Paraview. I'm so glad to find your add-on that works with Blender. However, when I open VTK or VTU, the mesh connectivity is distorted as shown below.

I upload corresponding screenshot. This example comes from below URL. If there is something wrong or there is a solution, please let me know. [1] (https://lorensen.github.io/VTKExamples/site/Cxx/IO/ReadLegacyUnstructuredGrid/) image

image

topabs61 avatar Aug 30 '20 11:08 topabs61

Hi, I think you need to add vtkGeometryFilter in between, please check this example in the documentation.

tkeskita avatar Aug 30 '20 12:08 tkeskita

Thanks for the response! Most of the meshes seem to be connected properly. Only one element type is still distorted.

image

topabs61 avatar Aug 30 '20 13:08 topabs61

Thanks for testing! Looks like vtkPolyLine (or vtkTriangle?) and vtkTriangleStrip are converted incorrectly.

tkeskita avatar Aug 30 '20 14:08 tkeskita

Some of the incorrect conversion might be due to vtkGeometryFilter, according to docs it

assumes that the input dataset is composed of either: 0D cells OR 1D cells OR 2D and/or 3D cells. In other words, the input dataset cannot be a combination of different dimensional cells with the exception of 2D and 3D cells

The main cause is the current surface mesh conversion routine vtkdata_to_blender(), which does mesh conversion simply by connecting lists of vertices (as-is) to create faces, without considering VTK cell types and their vertex semantics. Therefore it produces wrong results if plugged in directly as in your first example.

I'm thinking about rewriting a new Blender surface mesh conversion routine which would convert all native linear + polyhedron VTK cell types directly to Blender mesh. Needs some thinking first.. maybe always exclude internal faces.. Also could optionally include internal vertices in conversion, sometimes I've wanted that.

tkeskita avatar Sep 01 '20 10:09 tkeskita

Here's my plan for a new VTK To Blender Mesh node, which would extract surface meshes directly from linear + polyhedron VTK cells, without need for vtkGeometryFilter in between.

Node would have boolean options:

  • extract only boundary vertices (or all vertices)
  • extract edges (or no edges nor faces)
  • extract boundary faces (or no faces)

Technical implementation: Process all VTK cells, and separate each face of 3D cells into a list of face vertices. Face verts would be added into an extraction list, unless same vertices are already in the list, which means face is internal. In that case face would be instead removed from list. This results in only boundary face verts remaining in the list, and it's possible to generate mesh from those. Implementation of this in Python will likely be much slower than current VTK To Blender, at least for typical unstructured grids containing many internal cells, so at least the first version couldn't replace VTK To Blender.

tkeskita avatar Sep 20 '20 06:09 tkeskita

FYI I've added all linear cells' conversion to VTK To Blender Mesh node, now it should work correctly in latest add-on version.

tkeskita avatar Sep 26 '20 13:09 tkeskita