BVtkNodes
BVtkNodes copied to clipboard
Triangle elements in VTK Unstructured Grids convert incorrectly
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/)
Hi, I think you need to add vtkGeometryFilter in between, please check this example in the documentation.
Thanks for the response! Most of the meshes seem to be connected properly. Only one element type is still distorted.
Thanks for testing! Looks like vtkPolyLine (or vtkTriangle?) and vtkTriangleStrip are converted incorrectly.
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.
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.
FYI I've added all linear cells' conversion to VTK To Blender Mesh node, now it should work correctly in latest add-on version.