tkeskita / BVtkNodes

Create and execute VTK pipelines in Blender Node Editor
GNU General Public License v3.0
111 stars 19 forks source link

VTK to blender mesh: faces.new(...): sequence incorrect size #73

Closed lzhshou closed 2 years ago

lzhshou commented 2 years ago

Hi Keskitalo,

Thank you for the efforts in maintaining this great and useful tool.

I encountered the error of sequence incorrect size prompted by the facets.new() function, when trying to import vtk data to blender mesh using the VTK to blender mesh node (the bottom figure). The file is prepared in polydata format with triangle strips, and it works well in paraview (the top figure).

Would you please help take a look at this issue? (The vtk file is attached as particle_000_000000000040000.zip)

Many thanks,

Zhengshou

vtk_paraview

blender_vtk_issue

particle_000_000000000040000.zip

tkeskita commented 2 years ago

Hi, thanks for providing data example for this issue! There is something strange in the triangle strip VTK data which causes troubles. I'll check it, but meanwhile you can add vtkTriangleFilter after reader as a workaround, if surface data is enough for you.

lzhshou commented 2 years ago

Hi Keskitalo,

Thanks for the quick reply. I have tried vtkTriangleFilter, but the issue is still there.

FYI, here is the snippet code to create the triangle strips. Please let me know if there is anything else I can help with this issue.

VecXT triangle_strips; for (auto &tmp_facet : facets) { triangle_strips.emplace_back(tmp_facet[0]); triangle_strips.emplace_back(tmp_facet[0]); triangle_strips.emplace_back(tmp_facet[1]); triangle_strips.emplace_back(tmp_facet[2]); triangle_strips.emplace_back(tmp_facet[2]); }

Again, thanks for your help.

tkeskita commented 2 years ago

Sorry my mistake. I just committed a "hot fix", with that it should not crash any more, although you still need vtkTriangleFilter.

lzhshou commented 2 years ago

I checked out the new commit and it works. Thanks.

tkeskita commented 2 years ago

FYI Your triangle strip data seems not to be aligned with formulation of VTK triangle strips, since not all sets of three points define a triangle. But it seems that by using vtkTriangleFilter the end product contains all the faces you need. I've slightly modified the hot fix from yesterday, should not affect the end result.

lzhshou commented 2 years ago

You are right that I did not implement an exact triangle strip algorithm, and just used that workaround in my code. Thanks for the follow-up.