[vtkusers] How to set data programmatically...

Michael Jackson mike.jackson at bluequartz.net
Tue May 5 16:48:13 EDT 2009


I am not familiar with the .Net stuff but if you can get to the  
vtkActor that is doing the rendering for the image data then you  
should be able to set it's opacity using the actor->GetProperty()- 
 >SetOpacity(1.0f);

_______________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio



On May 5, 2009, at 4:28 PM, Theodore Holden wrote:

> Hi, and thanks for the response.
>
> I'm guessing there must be several versions of vtk in use and large  
> differences between them.  I'm using (or trying to use) version 5.4  
> on windows and the wrapper class for .net and C# (company orders,  
> not my choice).....
>
> I don't see vtkStructuredPointsAlgorithm on this system or anything  
> else obvious which has requestdata or requestinformation methods.   
> Google searches on the two methods turn up mostly suggestions to  
> look at a description of the new vtk pipeline architecture (http://www.cmake.org/cgi-bin/viewcvs.cgi/*checkout*/Utilities/Upgrading/TheNewVTKPipeline.pdf?revision=1.5 
>  ).
>
> It would solve most of my basic problem if I knew a way to adjust  
> opacity of an image on the fly without having to re-read any data.   
> It might also solve my problem if I could figure out what the  
> "coordinate" array is in the GetArrayPointer function for  
> vtkStructuredPoints objects.
>
> Again thanks, and any/all information is appreciated.
>
>
> Ted
>
> From: Mike Jackson <mike.jackson at bluequartz.net>
> To: Theodore Holden <theodoreholden at yahoo.com>
> Cc: vtkusers at vtk.org
> Sent: Tuesday, May 5, 2009 1:51:36 PM
> Subject: Re: [vtkusers] How to set data programmatically...
>
> You probably want to write your own custom reader object. There are
> lots of examples floating around the internet on that. The basics are:
>
> Select a vtk class in which to inherit from. In your case probably
> vtkStructuredPointsAlgorithm?
> programatically set the "numberOfInputs=0".
> Implement the RequestInformation and RequestData methods.
>
> In the RequestInformation method you should read just enough
> information from your file to be able to setup the output type with
> its extents  and all that.
>
> In the RequestData method do the actual reading of data from your file
> and convert it into a vtk object as appropriate.
>
> HTH
> Mike
>
> On Tue, May 5, 2009 at 11:26 AM, Theodore Holden
> <theodoreholden at yahoo.com> wrote:
> > Hi,
> >
> > I have an 3d visualization application which reads data from a  
> file which
> > isn't related to vtk and at present I'm having to write the data  
> out in vtk
> > format to disk and then let a vtk reader read it a second time.
> >
> > It would help considerably if I was able to simply pass the data  
> to vtk
> > internally but thus far I've not been able to figure out how to do  
> it and
> > nothing I see on the web helps.  The data is unsigned char and the  
> piece of
> > code which presents it looks like this:
> >
> >        void AddBagVolumeToWindow4(vtk.vtkRenderWindow renWin)
> >         {
> >             // 3d texture map
> >             vtkStructuredPointsReader reader = new
> > vtkStructuredPointsReader();
> >
> >             vtkVolume volume = new vtkVolume();
> >             vtkVolumeProperty volumeProperty = new  
> vtkVolumeProperty();
> >
> >             vtkRenderer renderer = new vtkRenderer();
> >             vtkRenderWindowInteractor interactor = new
> > vtkRenderWindowInteractor();
> >             vtkVolumeTextureMapper3D volumeMapper = new
> > vtkVolumeTextureMapper3D();
> >             //vtkVolumeRayCastCompositeFunction compositeFunction  
> = new
> > vtkVolumeRayCastCompositeFunction();
> >
> >             vtkPiecewiseFunction opacity = new  
> vtkPiecewiseFunction();
> >             vtkColorTransferFunction color = new  
> vtkColorTransferFunction();
> >
> >             reader.SetFileName("c:\\zz.vtk");
> >             reader.Update();
> >
> >             opacity.AddPoint(0, 0);
> >             opacity.AddPoint(64, .005);
> >             opacity.AddPoint(128, .01);
> >             opacity.AddPoint(200, .05);
> >             opacity.AddPoint(220, .4);
> >
> >             color.AddRGBPoint(64, .665, .84, .88);
> >             color.AddRGBPoint(128, 0, .746, .95);
> >             color.AddRGBPoint(220, 0, 1, 0);
> >             color.AddRGBPoint(230, 1, 0, 0);
> >
> >             volumeProperty.SetColor(color);
> >             volumeProperty.SetScalarOpacity(opacity);
> >             volumeProperty.SetInterpolationTypeToLinear();
> >             volumeProperty.ShadeOn();
> >
> >             volumeMapper.SetInput(reader.GetOutput());
> >
> >             //int[] iiex = reader.GetOutput().GetExtent();
> >
> >             volume.SetMapper(volumeMapper);
> >             volume.SetProperty(volumeProperty);
> >
> >             renderer.SetBackground(1, 1, 1);
> >             renderer.AddVolume(volume);
> >
> >             interactor.SetRenderWindow(renWin);
> >             renWin.AddRenderer(renderer);
> >
> >             renx = renderer;
> >             volx = volume;
> >
> >             renWin.Render();
> >             interactor.Start();
> >
> >             vtk.vtkWin32OpenGLRenderWindow win32win =
> >                 vtk.vtkWin32OpenGLRenderWindow.SafeDownCast(renWin);
> >             win32win.Clean();
> >
> >         }
> >
> > That's after the data has been written out to "c:\\zz.vtk" of  
> course.  What
> > it looks like I'd want to do, rather than use the  
> vtkStructuredPointsReader,
> > is to set up my own vtkStructuredPoints object something like:
> >
> >             vtkStructuredPoints bsp = new vtkStructuredPoints();
> >             bsp.SetScalarTypeToUnsignedChar();
> >             bsp.SetDimensions(Width, Height, NumSlices);
> >             bsp.SetOrigin(0, 0, 0);
> >             bsp.SetExtent(0, Width - 1, 0, Height - 1, 0,  
> NumSlices - 1);
> >
> >  and then set the data array but, again, I've no clue as to how to  
> do that.
> > Any help would be apreciated.
> >
> >
> > Ted
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://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
> >
> >
>
>



---
Mike Jackson                 www.bluequartz.net






More information about the vtkusers mailing list