Page 1 of 1

How to activate coloring by normals using pyanatomist ?

Posted: Thu Mar 01, 2018 5:16 pm
by pron.a
Hello Anatomist experts,

I am trying to visualize streamlines color coded by their local orientation. To do so, I calculate tangent of these streamlines and incorporate this information
into the normal field of the resulting 2D mesh.
In graphical interface of anatomist, I then click on activate shaders and select color model: normals. However I do not manage to do this operation using pyanatomist. When I do the operation into GUI and then check informations stored into the mesh AObject using getInfos method there is a shader_color_normals field into the material field. Unfortunately I do not manage to modify it using setMaterial method .
Do you have any hint ?

Alex

Re: How to activate coloring by normals using pyanatomist ?

Posted: Fri Mar 02, 2018 1:42 am
by riviere
Hi,
Well, after checking it seems that we haven't done any python bindings for these set of functionalities... That's definitely something we could do...
Denis

Re: How to activate coloring by normals using pyanatomist ?

Posted: Sat Mar 03, 2018 5:20 pm
by pron.a
Thank you very much for the answer Denis :)
Have a good day
Alex

Re: How to activate coloring by normals using pyanatomist ?

Posted: Mon Mar 05, 2018 10:49 am
by riviere
Hi,
Well, actually there is a trick to setup normals colors, it's not very convenient but it should work until we do something better:

Code: Select all

# load/init anatomist
import anatomist.api as ana
a = ana.Anatomist()
# load a mesh
mesh = a.loadObject('soma_mesh.mesh')
# get low-level Material object (not the same as mesh.material)
mat = mesh.GetMaterial()
# set options on it
mat.set({'use_shader': True, 'shader_color_normals': True})
# this line might not be neededd
mesh.SetMaterial(mat)
# force setting material/shading options (this is not done by SetMaterial - for now)
mesh.setHeaderOptions()
# notify changes
mesh.setChanged()
mesh.notifyObservers()
Denis

Re: How to activate coloring by normals using pyanatomist ?

Posted: Mon Mar 05, 2018 12:32 pm
by riviere
OK in the next update (or if you are building anatomist from sources), it should be included in setMaterial():

Code: Select all

mesh.setMaterial(use_shader=1, shader_color_normals=1)
Denis

Re: How to activate coloring by normals using pyanatomist ?

Posted: Thu Mar 08, 2018 12:17 pm
by pron.a
Hello Denis,

Sorry for the delay. Thank you very much for your super answers :) I will try the first solution for now and will rebuild from source later :P
Have a good day
Alex