[vtkusers] Draw points with gaussian fade out

Michka Popoff michkapopoff at gmail.com
Tue Jun 25 01:59:55 EDT 2013


Okay I got it working, it's me not knowing how to work with Cmake .... I read the manual and some examples from VTK 5.10.1, made some cleanup, and was able to build the project. I am now working on the python wrappings.

I'll let you know in a few days if it works, I need more time to continue on this project.

Michka Popoff

On 23 juin 2013, at 23:47, Michka Popoff <michkapopoff at gmail.com> wrote:

> Thank you for the code. I looked at the pictures, it seems to do what I want.
> 
> I am trying to install it but my knowledge is quite limited. As I understand I can build it without recompiling the whole VTK ? Hope I can get python bindings for it.
> 
> I launched cmake on the folder, I got the two following errors :
> 
> 1)
> 
>  CMake Error at CMakeLists.txt:8 (INCLUDE):
>    include could not find load file:
>      CMakeMacros_CSCS.cmake
> 
> I was not able to find this file. I looked on the internet, and downloaded some old Paraview and VTK's from 2006/2007, but was not able to find the file.
> So I removed the call to this file.
> 
> 2)
> 
>  CMake Error at CMakeLists.txt:93 (VTK_MAKE_INSTANTIATOR3):
>    Unknown CMake command "VTK_MAKE_INSTANTIATOR3".
> 
> Apparently this is due because VTK_MAKE_INSTANTIATOR3 is no more needed, so I also removed the line calling it.
> 
> Now the cmake is able to finish it's configuration.
> 
> 
> Then I did a "make" and got the following error :
> 
> In file included from /Users/michkapopoff/Desktop/vtkCSCSPointSprites/vtkPointSpriteMapper.h:51:
> /Users/michkapopoff/Desktop/build/vtkCSCSPointSpritesConfigure.h:7:5: error: expected value in expression
> #if 
>     ^
> In file included from /Users/michkapopoff/Desktop/vtkCSCSPointSprites/vtkPointSpriteMapper.cpp:33:
> /Users/michkapopoff/Desktop/vtkCSCSPointSprites/vtkPointSpriteMapper.h:52:10: fatal error: 'vtkPainterPolyDataMapper.h' file not found
> #include "vtkPainterPolyDataMapper.h"
>          ^
> 2 errors generated.
> make[2]: *** [CMakeFiles/vtkCSCSPointSprites.dir/vtkPointSpriteMapper.o] Error 1
> make[1]: *** [CMakeFiles/vtkCSCSPointSprites.dir/all] Error 2
> make: *** [all] Error 2
> 
> So it doesn't' find my include did, so I need to add the path to the INCLUDE_DIRECTORIES.
> I added the path directly with SET(). Perhaps not the cleanest solution but it worked :
> 
> SET( CSCS_POINTSPRITES_INCLUDE_DIRS
>   ${PROJECT_SOURCE_DIR}
>   ${PROJECT_BINARY_DIR}
>   /usr/local/Cellar/vtk/5.10.1/include/vtk-5.10
> )
> 
> So, next I got this error :
> 
> /Users/michkapopoff/Desktop/build/vtkCSCSPointSpritesConfigure.h:7:5: error: expected value in expression
> #if 
>     ^
> In file included from /Users/michkapopoff/Desktop/vtkCSCSPointSprites/vtkPointSpriteMapper.cpp:33:
> In file included from /Users/michkapopoff/Desktop/vtkCSCSPointSprites/vtkPointSpriteMapper.h:52:
> In file included from /usr/local/Cellar/vtk/5.10.1/include/vtk-5.10/vtkPainterPolyDataMapper.h:25:
> In file included from /usr/local/Cellar/vtk/5.10.1/include/vtk-5.10/vtkPolyDataMapper.h:25:
> In file included from /usr/local/Cellar/vtk/5.10.1/include/vtk-5.10/vtkMapper.h:55:
> In file included from /usr/local/Cellar/vtk/5.10.1/include/vtk-5.10/vtkAbstractMapper3D.h:32:
> In file included from /usr/local/Cellar/vtk/5.10.1/include/vtk-5.10/vtkAbstractMapper.h:28:
> In file included from /usr/local/Cellar/vtk/5.10.1/include/vtk-5.10/vtkAlgorithm.h:32:
> In file included from /usr/local/Cellar/vtk/5.10.1/include/vtk-5.10/vtkObject.h:41:
> In file included from /usr/local/Cellar/vtk/5.10.1/include/vtk-5.10/vtkObjectBase.h:43:
> In file included from /usr/local/Cellar/vtk/5.10.1/include/vtk-5.10/vtkIndent.h:24:
> In file included from /usr/local/Cellar/vtk/5.10.1/include/vtk-5.10/vtkSystemIncludes.h:40:
> In file included from /usr/local/Cellar/vtk/5.10.1/include/vtk-5.10/vtkIOStream.h:108:
> In file included from /usr/include/c++/4.2.1/backward/strstream:51:
> /usr/include/c++/4.2.1/backward/backward_warning.h:32:2: warning: This file includes at least one deprecated or antiquated header. Please consider
>       using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for
>       C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. [-W#warnings]
> #warning This file includes at least one deprecated or antiquated header. \
>  ^
> 1 warning and 1 error generated.
> make[2]: *** [CMakeFiles/vtkCSCSPointSprites.dir/vtkPointSpriteMapper.o] Error 1
> make[1]: *** [CMakeFiles/vtkCSCSPointSprites.dir/all] Error 2
> make: *** [all] Error 2
> 
> Perhaps you have an idea for this one ?
> 
> Thanks in advance
> 
> Michka Popoff
> 
> 
> On 21 juin 2013, at 14:39, "Biddiscombe, John A." <biddisco at cscs.ch> wrote:
> 
>> I’m attaching a very set of code from the original cvs repo that had the point sprite mapper. You should be able to compiled this against vtk, but not that the dates on the files go back to 2006, so you may need to update stuff
>>  
>> JB
>>  
>> From: Michka Popoff [mailto:michkapopoff at gmail.com] 
>> Sent: 20 June 2013 15:36
>> To: vtkusers
>> Cc: Biddiscombe, John A.; Markus Neuner
>> Subject: Re: [vtkusers] Draw points with gaussian fade out
>>  
>> Thanks for your answers,
>>  
>> I try to fight my way through vtkFastSplatter, but there is only one example and I do not understand everything. (The documentation is a little sparse)
>> The example in the docs use a vtkImageViewer2,and I want to have a vtkactor to put it in my 3d scenery.
>> So I mapped the splatter on a vtkplane through a vtktexture (to be able to have a vtkactor). Hope this will not lead to performance problems once I try to display millions of vtkactors ...
>> It's also not really working, the colors are messed up, and I don't understand the vtkpoints usage for the vtkFastSplatter.
>>  
>> 5 points are used in the example, which display 5 splats, but I was not able to have only one splat centered in the middle (even using only 1 point, at 0,0,0).
>>  
>>  
>> For vtkPointSpriteMapper, is not in vtk, so I have to find the way to take it from paraview, add it to vtk, and make the python bindings for it. Any idea how to achieve this ?
>>  
>>  
>> Regards
>>  
>> Michka
>>  
>>  
>> Le 19 juin 2013 à 23:29, Biddiscombe, John A. a écrit :
>>  
>> Try googling vtkPointSpriteMapper
>> A modified version using painters is in paraview, but the original was designed for straight vtk use.
>> 
>> JB 
>> (apologies if you get multiple copies of this, email misfired)
>>  
>>  
>> Le 19 juin 2013 à 19:57, Markus Neuner a écrit :
>> 
>> 
>> Hi,
>> 
>> oh vtkGaussianSplatter is the wrong class. It generates a volume, but you could visualize it with volume rendering.
>> 
>> The first version is basically what FastSplatter does (http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/FastSplatter).
>> 
>> For the second version i can't find a class in vtk that can actually does this (compute the Gaussian directly in the fragment shader).
>> 
>> You can derive from vtkGLSLShaderProgram and implement the procedures described in this examplehttp://prideout.net/blog/p60/Splat.zip written by Philip Rideout.
>> 
>> Regards,
>> Markus
>> 
>> 
>> On 06/16/2013 06:31 PM, Michka Popoff wrote:
>> 
>> Hi
>>  
>> thank you for your help.
>>  
>> 1) For the first solution, what would be the class to use to create the texture from the gaussian equation ? Once I have the textures, I could map them to planes. I did wrote some OpenGL code a while ago where I did this with a shader, billboarding the textures so that the gaussians would always face the camera. This was very fast.
>>  
>> 2) I saw vtkGaussianSplatter, but I don't know if I can set a different radius and exponent factor for each point ? In the class these values can only be set globally. I wrote some code (in python), inspired from the FinancialField example from vtkGaussianSplatter, but the splats are passed through vtkContourFilter to make a surface. I think this is messing with my gaussians, and I don't know how to do this without vtkContourFilter. I found no other example for vtkGaussianSplatter. Here is the code I wrote, displaying 10x10 points :
>>  
>> #!/usr/bin/env python
>>  
>> import vtk
>> from numpy import random
>>  
>> # Create points
>> points = vtk.vtkPoints()
>> for i in range(10):
>>     for j in range(10):
>>         points.InsertNextPoint(i, j, 0.0)
>>  
>> polydata = vtk.vtkPolyData()
>> polydata.SetPoints(points)
>>  
>> popSplatter = vtk.vtkGaussianSplatter()
>> popSplatter.SetInput(polydata)
>> popSplatter.SetSampleDimensions(50, 50, 50)
>> popSplatter.SetRadius(0.05)
>> popSplatter.ScalarWarpingOff()
>> popSplatter.Update()
>>  
>> popSurface = vtk.vtkContourFilter()
>> popSurface.SetInputConnection(popSplatter.GetOutputPort())
>> popSurface.SetValue(0, 0.01)
>>  
>> popMapper = vtk.vtkPolyDataMapper()
>> popMapper.SetInputConnection(popSurface.GetOutputPort())
>> popMapper.ImmediateModeRenderingOn()
>>  
>> popActor = vtk.vtkActor()
>> popActor.SetMapper(popMapper)
>>  
>> # Renderer
>> renderer = vtk.vtkRenderer()
>> renderer.AddActor(popActor)
>> renderer.ResetCamera()
>>  
>> # Render Window
>> renderWindow = vtk.vtkRenderWindow()
>> renderWindow.AddRenderer(renderer)
>>  
>> # Interactor
>> renderWindowInteractor = vtk.vtkRenderWindowInteractor()
>> renderWindowInteractor.SetRenderWindow(renderWindow)
>>  
>> # Begin Interaction
>> renderWindow.Render()
>> renderWindowInteractor.Start()
>>  
>>  
>>  
>>  
>> On 16 juin 2013, at 11:14, Markus Neuner <neuner.markus at gmx.net> wrote:
>>  
>> Hi Michka,
>>  
>> You could try to generate volumetric data using Gaussian splats.
>>  
>> There are two solutions to this problem:
>> - Create the 3D Gaussian function on the CPU during application initialization, and create a 3D texture from that.
>>  
>> - But better and much faster is to compute the Gaussian directly in the fragment shader.
>>  
>> Have a look at vtkGaussianSplatter it may do what you want.
>>  
>> Regards,
>> Markus
>>  
>>  
>> On 06/15/2013 05:18 PM, Michka Popoff wrote:
>> Hi
>>  
>> I want to draw a lot of points in VTK (~1.000.000), with each point's color fading out to a transparent value, following a gaussian function.
>> So the center will be bright (maximum intensity), and the border will have no color.
>>  
>> I am able to draw a lot of points using vtkPoints, I can also change their color, but I am looking for a way to apply the fade out to every point. Of course the parameters of the gaussian function will be different for each point (intensity value in the middle, diameter).
>>  
>> The result for 1 point would look like this :http://www.princeton.edu/~rvdb/images/deconv/Gauss2Psf.jpg
>>  
>> Are there some filters/mappers I could use directly ? Or can I perhaps try to "hijack" vtkgaussiansplatter to achieve this ?
>>  
>> Thanks in advance
>>  
>> Michka Popoff
>> _______________________________________________
>> Powered by www.kitware.com
>>  
>> Visit other Kitware open-source projects athttp://www.kitware.com/opensource/opensource.html
>>  
>> Please keep messages on-topic and check the VTK FAQ at:http://www.vtk.org/Wiki/VTK_FAQ
>>  
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>  
>>  
>>  
>>  
>> <vtkCSCSPointSprites.zip>
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130625/47c2e77d/attachment.htm>


More information about the vtkusers mailing list