Coder Social home page Coder Social logo

tkeskita / bvtknodes Goto Github PK

View Code? Open in Web Editor NEW

This project forked from simboden/bvtknodes

108.0 108.0 19.0 16.37 MB

Create and execute VTK pipelines in Blender Node Editor

License: GNU General Public License v3.0

Python 95.55% C++ 4.41% Shell 0.04%

bvtknodes's People

Contributors

asky88 avatar joeadamay avatar simboden avatar staars avatar thomgrand avatar tkeskita avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bvtknodes's Issues

i need a vti to openvdb/json example

hi,I I read a few issues,But I still don't know how to do it,i want to convert vti to vdb ,use you
python3 convert_to_vdb.py volume_00001.json this command ,but the json file is null,
image

you doc is
image

I still don't know what U is

Add a contributors file

Create list of persons names who contributed commits to source code into a separate contributors text file. Remove author list from docs.

Stack 2D Tiff Images to 3D Model for Volumetric Rendering

Hey there, I am new to Vtk and looking for some guidance.

I am trying to use BVtk to create a 3D model of a microscope image stack of a cell. I tried paraview at first, but ran into some issues

Preview of my images
Original:
image

With convert -alpha copy:
image

I am able to load all images, with vtkTIFFReader, and just plugged it into the skull tutorial, but it loads it in in 2D, how can I make it a 3D model? I googled for general vtk pipelines for this, but was not able to recreate it so far.

My end goal is to keep the color of the original images, and create a photorealistic 3D model of the cell.

You can view my full data set here

Any help would be greatly appreciated!

Unable to change another .foam

Hi, i saw the tree for the openfoam motorbike that you uploaded on the blender artist website, amazing work! But i found that even though i used different .foam files, blender still show the motorbike streamlines. May i have some help and hints, please? Thank you!

4C594E90-D892-48A1-9E05-6C10E4433A9C

advice on converting polydata points to spheres?

Hi there,

I'm trying to convert a vtk file containing a POLYDATA dataset, which contains only points and point data.

I've attached an example vtk file (please change .txt to .vtk)
out_lptm.txt

What I want to do is read this vtk file, and use the x/y/z coordinates of the vertices to create spheres.

I already tried using glyphs, but because (I think) the data is only points, the glyphs end up being points as well.

See below node tree and example output:

image

What I'm trying to do is get spheres from these points, and ideally eventually color them by a scalar.

See below example from paraview:

image

I realize that there is functionality to convert to blender particles, but I was having some initial issues and know it's experimental, figure there has to be a sphere/glyph approach that works like it does in paraview.

I imagine that using the vtkSpheres node could help?

image

which by the looks of it would let me instantiate multiple spheres based on xyz coords and a scalar for radius.. but I can't figure it out.

Any suggestions greatly appreciated...

Unable to import medical images

Hi again!

With the update I have managed to install the add-on with the version of VTK that comes from pip and the node editor works just fine. Thanks for solving the #1 (comment) issue

But now I am having difficulties importing medical image data and setting up workflows in blender.
I have tried opening DICOM and NIFTI files and recreating the pipeline I previously coded in vtk-python.

So in python to end up with a mesh from a dicom stack I would normally do something like this:

PathDicom = "files/dicom/sample/" 
reader = vtk.vtkDICOMImageReader()
reader.SetDirectoryName(PathDicom)
reader.Update()

threshold = vtk.vtkImageThreshold ()
threshold.SetInputConnection(reader.GetOutputPort())
threshold.ThresholdByLower(float(300))  # threshold by 300 Hounsfield units
threshold.ReplaceInOn()
threshold.SetInValue(0)  # set all values below 300 to 0
threshold.ReplaceOutOn()
threshold.SetOutValue(1)  # set all values above 300 to 1
threshold.Update()

dmc = vtk.vtkDiscreteMarchingCubes()
dmc.SetInputConnection(threshold.GetOutputPort())
dmc.GenerateValues(1, 1, 1)
dmc.Update()

The output port of the marching cubes gives me a mesh.

I have tried to recreate this workflow with BVtkNodes and ran into several bumps right from the beginning.

  1. Each time I try to run the node graph the first error says there is no filename or dicom file provided
    image
    The NIFTI image reader generates the same error.
    Here I attach 2 samples (a dicom and a nifti image of a vertebra) that I am using for this test.

SampleDICOM.zip
SampleNII.nii.gz

  1. In the nodes themselves I am missing some functions that are a part of the filter. For example the vtkImageTheshold is missing ThresholdByLower() setting and ReplaceInOn and ReplaceOutOn settings. I assume I can access them via node custom code, is that correct? If yes, can you provide a little bit of guidance on how to do that?

Thank you for developing this add-on.

Extracting multiple meshes from a single vtk file

Hi,

I have a big vtk file (6.3 GB) which takes ages to parse and I would like to automate the extraction of multiple meshes from it.

The file is containing voxels with ids of different cellular bodies. In total I have 53 items to extracts from this file.
Some of them have neighbouring voxels, so when extracting everything in one row, they are glued together in the same mesh, and I have to manually seperate them and fill the gaps, which is quite tedious.

I've found a way to extract each mesh one by one, using this setup :

image

In the vtkThreshold node I use the int id - 0.5 and id + 0.5 values to isolate the item I want to extract (so here, 12.5 and 13.5 to get the item with id 13)

This gives the expected result for this item... But it takes several minutes.
So, unless a better (and faster) solution is available, I would like to automate this process to extract all the 53 meshes.

I've tried to write this little script :


import bpy
import time

for value in range(1,53):
    print(value)
    bpy.data.node_groups["NodeTree"].nodes["vtkThreshold"].m_Value1 = value - 0.5
    bpy.data.node_groups["NodeTree"].nodes["vtkThreshold"].m_Value2 = value + 0.5

    bpy.data.node_groups["NodeTree"].nodes["VTK To Blender Mesh"].m_Name = "mesh"+str(value)

    bpy.ops.node.bvtk_node_update(node_path="bpy.data.node_groups['NodeTree'].nodes['VTK To Blender Mesh']")

But it is not working as expected : the bvtk_node_update() function seems to be asynchronous, and so the "for" loop is continuing to run while the first mesh is still not generated.

What should be done here ?
Thanks for your help !

Installation for Apple M1

This is not a complete guide, but it may contain some useful tips.

  1. Compile blender as described here:
    https://wiki.blender.org/wiki/Building_Blender/Mac
    This is possible since master is on 2.93. for the M1. At the moment the included python version is 3.9.2

  2. Compile VTK for the M1
    There is no wheel yet on PyPi for the M1.
    I use ~/Developer as the working folder for the following steps.

git clone https://github.com/Kitware/VTK
mkdir vtk_build
cd vtk_build

You may need to install pyenv with brew install pyenv

env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install -v 3.9.2
pyenv local 3.9.2
pip install wheel

Now configure the things with ccmake, it may be needed to press 'c' several times, some warnings are expected

ccmake -DVTK_WHEEL_BUILD=ON -DVTK_WRAP_PYTHON=ON ../VTK/ -DPython3_EXECUTABLE=~/.pyenv/versions/3.9.2/bin/python3 -DPython3_INCLUDE_DIR=~/.pyenv/versions/3.9.2/include/python3.9 -DPython3_LIBRARY=~/.pyenv/versions/3.9.2/Python.framework/Versions/3.9/lib/libpython3.9.dylib

Now build, -j 8 is optional for faster build.

make -j 8

Now comes the glitchy part, which may be fixed for arm64 on macOs sooner or later.

python setup.py bdist_wheel will create a faulty wheel, because some wrongly named subfolders will be created in ./build

Copy manually all *.dylib from „wrong“ subfolder to build/lib.macosx-11.2-arm64-3.9/vtkmodules. You can use the Finder (i.e. with open .. The right folder already contains all *39-darwin.so-files (and more).

Now repeat:
python setup.py bdist_wheel

install this wheel:
~/Developer/blender-git/build_darwin/bin/Blender.app/Contents/Resources/2.93/python/bin/python3.9 -m pip install dist/vtk-9.0.20210319-cp39-cp39-macosx_11_0_arm64.whl
the filename will change

install BVtkNodes the usual way in blender.

I did only a few tests so far, but for me it works quite okay. Reading dicom files from iCloud Drive did not work, but I still did not see a single crash and performance is pretty good on the (completely silent) MacBook Air M1.

This little guide may be obsolete after some of the next VTK updates and I will eventually update it.

Color Ramp texture name is hard coded to node name, causes clash when using several node trees

Hello,

I'm running into an issue when I make color ramp nodes in different node trees.

It seems that if I create multiple node trees, and have a color ramp node in each of those node trees, they are somehow linked together and always mirror eachother even if I have different settings for each color ramp node.

To reproduce, open an empty blend file and create two node trees. In each node tree, create a color ramp node. Now, edit the settings of one of them and go to the other node tree and you will see the settings have also been modified there.

See below images, note that the second color ramp does not match the preset value that was chosen, but instead is the same as the first color ramp:

image
image

I cannot figure out how to have two different color ramp nodes in two different node trees.

Is this a bug or is there some way around this?

The only thing I can think of is having multiple color ramp nodes in each tree, where some don't get used.

Thanks! And once again, this add-on is amazing. Thank you.

Hexahedral box in BoxClipDataSet filter

Hi @tkeskita,

I'm once again back to the vtkBoxClipDataSet filter.
This time I'm struggling to get my clipping box to have an arbitrary orientation rather than having it parallel with the coordinate axis. I tried to modify the custom class definition, but somehow can't get it to work.

Is there a way to implement it in the BoxClipDataSet filter?

The VTK documentation says:

To use this filter, you can decide if you will be clipping with a box or a hexahedral box.

  1. Set orientation
    if(SetOrientation(0)): box (parallel with coordinate axis) SetBoxClip(xmin,xmax,ymin,ymax,zmin,zmax)
    if(SetOrientation(1)): hexahedral box (Default) SetBoxClip(n[0],o[0],n[1],o[1],n[2],o[2],n[3],o[3],n[4],o[4],n[5],o[5]) PlaneNormal[] normal of each plane PlanePoint[] point on the plane
  2. Apply the GenerateClipScalarsOn()
  3. Execute clipping Update();

In Paraview, I can do it by setting the Position, Rotation, Length.

Using BVTKNodes with pip version of the VTK

👋 hi
First of all thank you very much for bringing this valuable addon to 2.8. It has potential to provide big opportunities for scientific 3d processing.

I am trying to setup BVTKNodes in Blender 2.8 on OSX. I didn’t compile vtk, but I have installed vtk 8.2 from pip, using the python that comes with blender.

Now I can import vtk in blender python console, access classes and do computations.

The addon does not raise any errors during installation, but I don’t see the node editor.

Am I missing something in the installation process? Or is there anything special about the python bindings that vtk needs to interact with blender, that makes building from source mandatory?

Foam reader

Hello.
I've opened a case.foam with BVtkNodes but only the internal mesh seems to be available in the drop-downs. The boundary regions, which I can extract in Paraview, are not showing up. Am I missing something obvious. My node set-up is below.
Cheers
Ryan

image

Xubuntu 18.04LTS

I found the following error during adding VTK to blender

Traceback (most recent call last):
File "/home/mohammed/Post-Processing/Blender/blender-2.83.0-linux64/2.83/scripts/modules/addon_utils.py", line 351, in enable
mod = import(module_name)
File "/home/mohammed/.config/blender/2.83/scripts/addons/BVtkNodes-master/init.py", line 114, in
from . import core
File "/home/mohammed/.config/blender/2.83/scripts/addons/BVtkNodes-master/core.py", line 26, in
from .update import *
File "/home/mohammed/.config/blender/2.83/scripts/addons/BVtkNodes-master/update.py", line 193, in
open(logfile, 'w').write('')
PermissionError: [Errno 13] Permission denied: '/home/mohammed/.config/blender/2.83/scripts/addons/BVtkNodes-master/vtklog.txt'

Color Mapper node color by vector field magnitude

I do not know if the following problem has already been discussed: When using vtkStreamTracer, the velocity magnitude is not correctly mapped to the streamlines, as can be seen from the screenshot (right image). A coloring with the components u, v, or w works without problems (left image). I tried it with completely different datasets, always with the same result. Also changing the node settings does not solve the problem. What can be the reason?

I can share the VTU file, but it is about 50MB.

streamlines_U

Colouring particles?

Hello!

Now that time selector is working (thanks btw) I am trying to a render of my simulation inside of Blender. For me, my simulation data is particles (which using this package is imported as mesh vertices), which looks like;

image

My problem is now that, I want to animate these particles by using spheres etc. I am able to do this by the following approach;

  1. Select my object
  2. Add particle filter
  3. Use hair
  4. Insert number of hairs to be exactly equal to number of vertices
  5. Under "Source" emit from "Verts"
  6. Under "Source" disable random order
  7. Under "Render" select object and choose any mesh (for example a Sphere)

Then I can get something like this;

image

Where the "orange spheres" are a moving piston, and the "black vertices" is the fluid. My problem now arises;

I can do the exact same thing for the Fluid particles, but I have no clue of how to color the spheres based on their data. What I have been trying is;

image

But this would only be able to color the "black vertices" and I am not sure if it possible to color / scale up vertices in Blender.

So basically my question is, is there a hack / workflow to parse this velocity data to the particle info in the Shading settings?

What I seek is something like this;

image

Where the fluid particles are coloured by velocity. This was done in Paraview.

Kind regards

Ensight to BVtkNodes

Hello everyone,
I’m currently using CFX from Ansys where is the option to export results to Ensight Gold. I already use this method before through Paraview and it works OK, but when I tried to import the same results directly to Blender via BVTKNodes, everythings seemed fine until I took a look at velocity. It seem that the algorythm used in BVTKNodes doesn’t sort the cell or node data correctly (attached pic.). I don’t know what I’m doing wrong. Anyone who did experience something similar?
Also, I'm new to BVtkNodes, so maybe I forgot to do something.

Thank you for you help.
PS: Other variables (like Total Pressure) seems fine to me which is even more odd.

screen

Using Bvtk nodes for volume rendering node template

Hi,

I recently got into using Blender for post-processing my ParaView Data and saw the efforts you all made! Being said, I can currently export my data to .vtk,. vti formats. I can post process my surface data, but not my volume rendering data despite correctly having access to the Bvtk nodes addon and successfully installing it. I am using Blender 2.90, with VTK 8.1.2 (on Win10) and installed your add-on. Everything works fine, but I am confused on a few things:

  1. how do I install the build version of Blender with access to pyopenvdb? I am new to this so I am not familiar with some things despite reading the docs.

  2. I saw the sample node setup for "volume rendering" but for any general .vtk, vti file, what is the preferred node reader to input the data? I saw many options and was not sure how to make a simple import procedure.

  3. I tried to first follow the example used in the first image (https://bvtknodes.readthedocs.io/en/latest/BVTKNodes.html#vtktoblendervolume) for import of the data as a surface mesh instead of a volume, but even though there is no error, it does not load/generate the object. Is there something else to be done aside from this?

I don't need to use pyopenvdb but it would be better in the long run; but namely please see if you can get this file to load using either of the methods. I am struggling to use the nodes despite having the same setup and following the docs. If you have time please let me know if you are able to get this into blender either way.

I apologize if these concerns sound trivial or are in the wrong place, but seeing how I got the add-on working, I may not be understanding how to use the nodes themselves and would like your help if you have a chance. Thank you for you patience and support. The file is below:

https://drive.google.com/file/d/1BHomTpoSYWMyafilJPhTUEMOz_cSYwtq/view?usp=sharing

Time Selector for PartFluid.vtk Data

Hello,

When I select the first file of my partfluid in the vtkPolyDataReader node, the time selector node is not reading the time steps. The file names are in the form PartFluid_0100.vtk, PartFluid_0101.vtk etc.

Does anyone know how I can get the node to properly read the file names? Either by changing the names of the files or editing the code for the time selector node?

Thank you

Rerouting not working

Blender allows for an useful mechanism called Rerouting in node trees. When shift+right-click dragging across multiple links, a re-route node will be created.

figure figure

This allows you to easily replace the root node, but crashes in BVTK when updating with the error:

Error: Python: Traceback (most recent call last):
  File "[...]\Blender Foundation\Blender\2.92\scripts\addons\BVTK\converters.py", line 1986, in execute
    BVTKCache.check_cache()
  File "[...]\Blender Foundation\Blender\2.92\scripts\addons\BVTK\cache.py", line 71, in check_cache
    if n.node_id == 0:
AttributeError: 'NodeReroute' object has no attribute 'node_id'

No custom Code available for

Hi,

many thanks for this Blender Addon.
While trying to plot a glyph vector following the tutorial, I tried to select the correct vector by removing all unused fields. However, the nodes vtkPassArrays and vtkAssignAttribute did not have a properties field "Custom Code" to allow this, as mentioned in the tutorial (see screenshot).
bvtk_no_custom_code

OS: Windows & Linux
Blender version: 2.83/2.9
VTK version: 8.1.2

Importing nodes in a script

When I try to import nodes within my script, like,
ops.node.bvtk_node_tree_import(filepath='example.json')
I get a Runtime Error:
RuntimeError: Operator bpy.ops.node.select_all.poll() failed, context is incorrect.

I tried changing to EDIT mode from OBJECT mode and I still get the same error.

How can I properly import nodes in my script?

No particle colors in the final render with Cycles

Hi @tkeskita, I've been trying out the VTK To Blender Particles node.
The colors work fine in the Rendered Viewport Shading mode with the Cycles engine.
But the final rendered image (with Cycles) does not show any color.
Is this a known issue? or am I missing something?

vdbreader?

Does bvtknode have a vdbreeder?
I have vdb format data but there is no vdbreader in Bvtknode.

cannot create new node group in headless mode

Hello,

I'm having an issue when trying to create a node tree from headless python console

the way I do this is by running blender in the background and opening up the python console.

If I start blender from scratch and try to make the node group it does not work:

launch using: blender -b --python-console

##does not work
import bpy
bpy.ops.mesh.primitive_cube_add()
group = bpy.data.node_groups.new('test', type='BVTK_NodeTreeType')
group.nodes.new(type='VTKPolyDataReaderType')
print(bpy.data.node_groups[0]) #<bpy_struct, BVTK_NodeTreeType("test") at 0x000001BEE0E9EC08>
print(list(bpy.data.node_groups[0].nodes)) #[bpy.data.node_groups['test'].nodes["vtkPolyDataReader"]]
bpy.ops.wm.save_mainfile(filepath='testout.blend')
bpy.ops.wm.quit_blender()

for some reason, after I've saved the file and opened in Blender GUI there are no node groups present.
I have tested that I was able to do non-BVTKNodes operations (i.e. creating a cube works)

so then I tried creating the blend file manually first, and creating an empty node group in the file:

launch using: blender 'testout.blend' -b --python-console

##works -- assuming file created before hand with node group
import bpy
print(bpy.data.node_groups[0]) #<bpy_struct, BVTK_NodeTreeType("test") at 0x000002AB5ADDF008>
group = bpy.data.node_groups[0]
group.nodes.new(type='VTKPolyDataReaderType')
print(list(bpy.data.node_groups[0].nodes)) #[bpy.data.node_groups['test'].nodes["vtkPolyDataReader"]]
bpy.ops.wm.save_mainfile()
bpy.ops.wm.quit_blender()

this time, when I open the blend file in the Blender GUI, the node tree has been updated.

Can you please explain why the first is not working or how I could achieve this?

I want to be able to develop a file and node groups from scratch, without having to manually instantiate each node group in the GUI.

I would also note that when I create node groups using python from within the Blender scripting environment, it works fine. For some reason just creating node groups from a headless python session does not work.

Much appreciated!


EDIT - I also tried running a python expression through the command line:

blender -b --python-expr "import bpy; bpy.data.node_groups.new('test', type='BVTK_NodeTreeType'); print(bpy.data.node_groups[0]); bpy.ops.wm.save_as_mainfile(filepath='testout.blend')"

putting it into a script doesnt work either:

blender -b --python try.py

it seems I can only create a node group when the GUI is open??

also, if I take away the -b flag in these last 2 approaches, it works fine.. but i have to kill blender manually


EDIT - after digging more into it, I've found that it's related to the "users" each node group has:

image

this can be accessed through:

bpy.data.node_groups[0].users

I guess they all start as 0, but if you open them in the GUI they change to 1.

image

I tried all of the methods here to try to set it to 1 for the newly instatiated node groups:

image

but could not do it,

doing bpy.data.node_groups[0].user_fake_user=True did work, but adds an 'F' next to each group.

image

it seems that if I use the fake user approach, all my problems go away but I'm not sure what this even means or if there will be downstream consequences.

Caching bug with common root nodes

I tried using the vtkAppendFilter with a common root node, but ran into problems that turned out to be a bug in the caching: Update is called on the common root node for both descendant nodes, creating two instances of the root object and the input/properties are only applied to one of the copies of the common root node, resulting in a missing vtkobj (None) down the line.

The attached images show the error and how to reproduce it (Calling update on mixed will fail). I will upload my suggested hotfix for this issue.

append_bug
append_bug3

Scripting with BVtkNodes

First of all,
@simboden - thanks for bringing this Addon to Blender, and
@tkeskita - thanks for getting it on 2.80
Everything works fine with the BVTK Node Tree Editor and I get what I want.
Recently, I started scripting with it and I'm having some issues. I thought you might be able to help me out.

With python, everything seems to work as expected, but the scene is not getting updated until the script has finished running.

For instance, here is a minimal reprex:

import bpy

#Add the BVtkNodes
bvtkn = bpy.data.node_groups.new('NodeTree',type='BVTK_NodeTreeType')

# Cache the Nodes and Links
nodes = bpy.data.node_groups["NodeTree"].nodes 
links = bpy.data.node_groups["NodeTree"].links

# Create the Reader
reader = bvtkn.nodes.new(type="VTKXMLImageDataReaderType")
reader.m_FileName = "examples_data/head.vti"

# Create the Contour Filter
contr_filter = nodes.new(type="VTKContourFilterType")

# Add a contour value
item = contr_filter.m_ContourValues.add()
item.value = 66.

# VTK To Blender
vtk_to_blend = nodes.new(type="BVTK_Node_VTKToBlenderType")

# Create the links
links.new(reader.outputs["output"], contr_filter.inputs['input'])
links.new(contr_filter.outputs['output'], vtk_to_blend.inputs['input'])

# Update the BVtkNode
bpy.ops.node.bvtk_auto_update_scan(
    node_name="VTK To Blender",
    tree_name="NodeTree")

# Print the list of objects in the scene
print(bpy.data.objects[:])

When I run the above script, the output is,

[bpy.data.objects['Camera'], bpy.data.objects['Cube'], bpy.data.objects['Light']]

The scene gets updated with the new object only after this.

The problem is that the object does not exist until the script has completed executing. So, I am unable to call the object within the script. I even tried to add in a time delay to wait for the BVtkNodes.

What am I doing wrong here?

External Workaround for Converting 3D VTK Image Data to OpenVDB for Volumetric Rendering

Background
Since pyopenvdb is not part of Blender libs, currently it's not possible to use the new VTK To Blender Volume node without building custom Blender. It is currently unknown when pyopenvdb will be part of out-of-box Blender.

Meanwhile, there seems to be some interest in volumetric rendering of 3D image data in Blender, at least many people have opened issues about it. Currently alternatives to building custom Blender is to edit, compile and use external C++ programs (see e.g. this, or this) to convert data to openvdb, or to use tile mapping with a complex UV mapping scheme (see #19).

Proposal
Provide an exporter node similar to current VTK To Blender Volume node (with color, density, flame and temperature fields), which exports VTK image data into text files. Another external Python script using externally provided pyopenvdb (e.g. python3-openvdb package in Ubuntu) could then be used outside of Blender to convert those text files into openvdb files, which could be imported back to Blender for visualization.

Please like this post if you would benefit from this kind of a workaround. Comments are also welcome!

Set transparency for VTK meshes?

Is it possible to add transparency to a VTK To Blender mesh generated object? I can't find anything in the documentation and the known places on the web (e.g. blenderartists, vtk.org).

Under Material Properties one can set the Blend Mode and Alpha value, but it is turned off or set to 1 (no transparency) during rendering. In viewport rendering this doesn't happen, but the render result is of course not that good (with my knowledge).

Is there a solution with the help of the BVTK nodes or is there even a connection to the material nodes possible?

Time Selector not working?

Thanks for making this package available for 2.80 first and foremost.

Secondly, I have about 200 vtk files, which I want to load in at current time step, in the blender time line. I load the data file correctly and it works;

image

Is it possible to do what I want to do, to read files depending on time step?

Kind regards

vtkTIFFReader file size limitation and slices loading

Hi,

Stacks in Tiff format bigger than 4GB are not properly imported (only the first slice is loaded)
It seems to be a limitation of some tiff loaders. I assume this is a limitation in the VTK api.

I've tried to find a workaround by extracting all the slices in individual tiff files, but then I can't find how to import them as a stack.
My current setup is like this :

image

The file pattern is ok :
%s%04d.tif

"%s" for the string prefix and "%04d" for the numerical part with 4 digits.

As seen in the information node, the first slice only is loaded (Z range=0).
What should I change to get all the slices loaded ?

Creating streamlines/vectors from polydata

Hello,

Does anyone know a solution to creating a vector field or streamlines from vtk polydata? I've followed the node trees as shown on the BVTKnodes website, but the start of the node tree isn't available for either of them. Blender generates an output, but I cannot see the streamlines. As for the vectors, the vectors are all pointing towards +x, with orient on, and the custom code entered into the vtkAssignAttribute and vtkArrayCalculator nodes. Attached are images of my node tree setups.

Thank you

Streamlines

Vector field

VTK To Blender Particles rendering is unreliable

When rendering large number of particle instances produced with the new VTK To Blender Particles node, there can occur an error which is shown as debug message like

AttributeError: Writing to ID classes in this context is not allowed: NodeTree, NodeTree datablock, error setting BVTK_Node_VTKToBlenderParticlesType.quats

When the error occurs, the render shows no particles, and rendering hangs.

This seems to be an issue in Blender. It comes up less often when rendering is done in new window compared to rendering in Image Editor. Need more bisecting to pinpoint the problem, please let me know if you get more information when this occurs and when not.

vtkAlembicReader status

In the code there is mentions of a potential vtkAlembicReader:
https://github.com/tkeskita/BVtkNodes/blob/master/__init__.py

 - Blender To VTK Node: A BVTK node which converts Blender mesh into
   vtkPolyData. Alternatively add vtkBlendReader to VTK?
   Or maybe vtkAlembicReader to VTK? https://www.alembic.io/

Was there any ongoing work on this ?

BTW F3D has a first version of a vtkAssimpImporter that would theoritcally allow to reader .blend in VTK:
https://github.com/f3d-app/f3d/blob/master/src/vtkF3DAssimpImporter.cxx

Preprocessing and cutting planes in 3D data block

Hello. I was in the Blender artists post and they say to ask questions here so, here it goes:

I managed to make the example in the introduction of the documentation and now I am excited to start with my own data. I know my way around Blender, even in Paraview. I learned to use VTK and ITK long ago but not a lot, only for some specific tasks.

So my question is, can you recommend a good tutorial for converting the data to VTK so I can import it in Blender in BVTK? I have simply a block of 3D data, XYZ coordinates with 2 values associated to them. I was using a vtkPolyData is that a good one? and also, how would I go about taking several cuts of this block? I basically want to observe a few planes within my data along a specific path.

If I manage to create a vtk file with my data, which BVTK reader node should I add to read it?

I found this cutting-field-data, so maybe that answers part of my question but in this case I have to use a vtkPlane to cut the data but I was wondering if there is a way to connect a Blender plane instead, so I could almost dynamically move the plane in Blender but get the cut computed by VTK.

color_by option in ColorMapper

Hi @tkeskita

I'm trying to assign a named array to the color_by option in the ColorMapper node within a script.

I can only do it via array numbers like 'P0', 'P1', etc. and not by the array name.

>>> colormapper.color_by="P0"
>>> colormapper.color_by="Temperature"
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
TypeError: bpy_struct: item.attr = val: enum "Temperature" not found in ('P0', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9')

Is there a way to assign color by the name of the array (like in the Node editor)?
Or, how do I find out the array number (e.g P4 - "Point data [4]: 'Temperature': 5000 - 6000") that correspond to the data I want?

Thank you,
Vigeesh

MultiBlockDataReader

Hi @tkeskita,

I have difficulties to use your addon for my OpenLB .vtm output files.
I have looked at your nice sample node setups, but could not deduce a working setup for my files
cavity3d_iT0003600.zip
.
What I tried is: (in Blender 2.8)
nodes
but when I update the CompositeCutter, no suitable input seems to be recognized.

I'd really appreciate if you could tell me what I've done wrong in this basic setup.
At this point I'm just trying to get any visual representation of this data in blender as a starting point for exploring the addon.
I guess this has more to do with VTK in general rather than your addon fork.

Upgrade to VTK 9?

VTK 9.0.1 seems to be available via pip install vtk. Is there someone who would like BVTKNodes to be upgraded to VTK 9? What is the reason? I usually hesitate to jump to any new major version at least before x.1 version, and so far 8.1.2 seems to have been working nicely for me at least..

vtkPassArray producing vtkCompositeDataPipeline error

Howdy,

I am just starting to get a feel for this add-on (new to blender) and I am having some trouble replicating some of your lovely examples on the blender forum.

I am reading in a particle file from DualSPhysics simulator on a different machine (which I believe was also used in the example based on file names) and I am able to import the file fine. However I am running into some issues where my custom code in nodes such as vtkPassArray or vtkArrayCalculator which does not seem to run and produces an error. See example below.

Without the vtkPassArray node I can continue to create 3D glyphs, colormap, etc. just fine. I tried other vtkDataObject formats without luck.

Any thoughts? Am I just missing something silly? Many thanks!

A minimal working example of this follows:
image

image

OS: Windows
Blender Version: 2.92 (installed via steam)
VTK version: 8.1.2

Current installed python modules:
image

===Update===
Seems I can force the nodes to execute correctly by putting in the VTK to Blender node. I still get a bunch of those Datapipeline errors related to the vtkPassArrays node but the output of the info nodes seems correct. Also it does add the object to the scene. Still seeing if I can get the calculator working despite these errors. Maybe has to do with the vtk file (inconsistent version maybe)...

image

Unstructured VTK data

Dear BVTKNodes,
I am new to this feature , I have a particles confined between two planes ( normal to z axis) the particles and the planes are in vtu format and named (particle_0.vtu and particle_1.vtu) and the same for the planes (wall_0.vtu…etc) where each *_n.vtu is for time step.
particles have the following attributes :- radius, a velocity vector and species. I managed to create the tree as shown in the attached image . I am still struggle how to color the particle using the velocity ? how to scale particles to their real diameter size (eg. particles with different radius )?
secondly, I would like to show the walls as well how can I do that (Knowing that the wall is moving)?
thirdly, how can i create a video animation could you share a setup or a tutorial ?
Kind Regards,

screnshot
particles
para
data_sample.zip

tutorial?
Looking really to your respond and recommendations.

Exporting Blender object to vtk?

Hello!

I cannot see why this should not be possible, so that is why I am making this issue. Using a vtk sphere source, I have drawn on the left this bowl shape and I am able to export it to vtk, if I remove the option of "tooutputstring" (I don't know what it does). On the right hand side I have now applied a solidify modifer in Blender and I wish to export this object to vtk - how do I go about doing that? I cannot see any reason why it should not be possible - specifically I am trying to use the "polydata" vtk writer.

image

Kind regards

Custom vtkFileSeriesReader Node

After having some issues with getting the animation to work in BVTK due to my data starting at time-step 100 instead of 0 I thought it may be useful to add some sort of node that would allow increased control over time-step to animation frame process. (Also noted this seems to be a particular area in need of improvements based on some of the issues).

Something I stumbled on was this vtkFileSeriesReader in Paraview which allows the user to set up a JSON file with time-step meta-data if you have a series of data coming from multiple files:

{
  "file-series-version" : "1.0",
  "files" : [
    { "name" : "foo1.vtk", "time" : 0 },
    { "name" : "foo2.vtk", "time" : 5.5 },
    { "name" : "foo3.vtk", "time" : 11.2 }
  ]
}

This type of support for custom JSON files labels as filename.series may be a good fall back to add in BVTK if the use currently needs more control over the time-series than the default time-selector offers.

Is there something like this present or being developed in BVTK? Because if not, I'll work on making a custom node with this functionality.

Need some clarifications I can't find in documentation/example

Hi,

First I just wanted to say thank you SO much for maintaining this repo. As someone who's been dabbling with Blender for a couple years, but am used to doing model renderings in Paraview, Python and various other software, this is absolutely amazing.

I was hoping you could clarify a couple things so I can understand how to use a couple of the VTK functions in Blender. Specfically, I am trying to figure out :

vtkClipDataSet and vtkWarpScalar


For clipping, I'm just trying to figure out what I actually need to pass in here. What is ClipFunction supposed to be or are you able to give me an example?

This is what my nodes look like now:

image

I get an error that it can't do the clip without a clipping function.

My aim is to do a clip by scalar, using a function like:

Variable_Data >= -999

like in paraview:

image

Can you give me an idea how to do this?

For warp scalar, I am trying to warp the z axis of the surface by the scalar value. Like this in paraview:

image

I've tried a couple different things with the BVTK node and couldnt get it to work..

image

Are you able to give me an example how I can warp the surface by a scalar?

I tried using Custom Code by adding:

AddArray(vtk.vtkDataObject.POINT, "Surface_elevation")

and in vtkPassArrays.. also tried using a vtkArrayCalculator..

I'm honestly not that familiar with VTK itself and really don't know what I'm supposed to be giving it.

Can you point me in the right direction?

FYI I know I need to connect these to a to Blender node to create the blender mesh.. I've just screenshotted the minimum to show you what I'm trying to do.

Code for VTK to Blender

I am developing a plugin for Blender, which will allow to make ParaView pipelines in Blender. Paraview is a software for scientific visualization that uses VTK under the hood. I would like to copy some of the code from this plugin related to "VTK to Blender" conversion (VTK->BMesh). @tkeskita, I know that this plugin is under the GPL license, and my plugin also will be opensource, nevertheless I think it's good to say that I'll borrowing some of your code. I will appropriately annotate the code.

(I would gladly combine my plugin with yours, as ParaView objects wrap around VTK objects, but I think the underlying design of the plugins is for now too far off)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.