[vtkusers] vtkTextureMapper3DComputeScalars fails in visualizing a small volume data

Mathieu Malaterre mathieu.malaterre at kitware.com
Wed Apr 12 17:54:56 EDT 2006


Berry,

	Thanks for sending the dataset. Unfortunately I cannot reproduce the 
problem here. I even ran the code through valgrind, and nothing wrong 
happen. Can you try with the very latest VTK CVS, do you have an nvidia 
card ?

Mathieu


berry wrote:
> hi, everyone
>  
> Sorry to fill your mailbox and sorry to post same message again :(
>  
> I am  trying to visualize a float-point structured points data with size 
> 119*195*90 using vtk(version 5.0) 's 3D texture mapping functionality. 
> However, It always fails to exectute in vtkTextureMapper3DComputeScalars 
> function with a Unhandle Execption error:(I am using MS Visual Studio. 
> NET 2003 ,  vtk Compiled with static library)
>  
> Unhandled Execption at 0x004614c8  in **.exe , 0xC00005 access 
> violation reading location 0x04dca000
>  
> I have checked my simple source code a lot of  times and traced it line 
> by line every time , and compiled the VTK Source code a lot of l times 
> also —_—. The vtkTextureMapper3DComputeScalars always fails.  I am sure 
> my display card and it's driver
> support 3d texture. Because my previous code (written by myself, do not 
> using vtk) works very well using 3d texture and cg shader.
>  
> By the way, I have also compiled the vtk source code using share libs 
> several times ,  I am very sad to see that it also fails in 
> vtkTxtureMapper3DComputeScalars.  I am crazy now.
>  
> Can anyone help me ?
>  
> Best Regards,
> berry
>  
> below is my simple code :
>  
> 
> #include "vtkRenderer.h"
> #include "vtkRenderWindow.h"
> #include "vtkStructuredPointsReader.h"
> #include "vtkPiecewiseFunction.h"
> #include "vtkColorTransferFunction.h "
> #include "vtkVolumeProperty.h"
> #include "vtkStructuredPoints.h"
> #include "vtkImageData.h"
> #include "vtkVolumeTextureMapper3D.h"
> #include "vtkVolume.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkRenderWindow.h"
> #include "vtkLODProp3D.h"
> #include "vtkVolumeRayCastCompositeFunction.h"
> #include "vtkVolumeRayCastMapper.h "
> 
> 
> #pragma comment(lib, "vtkGraphics.lib")
> #pragma comment(lib, "vtkCommon.lib")
> #pragma comment(lib, "vtkRendering.lib")
> #pragma comment(lib, "vtkVolumeRendering.lib")
> #pragma comment(lib, "vtkImaging.lib")
> #pragma comment(lib, "vtkHybrid.lib")
> #pragma comment(lib, "vtkIO.lib")
> #pragma comment(lib, "vtkFiltering.lib")
> 
> #pragma comment(lib, "OpenGL32.lib")
> 
>  
> 
> int _tmain(int argc, _TCHAR* argv[])
> {
>  vtkStructuredPointsReader* reader = vtkStructuredPointsReader::New();
>  reader->SetFileName("test.vtk");
> 
>  vtkPiecewiseFunction* opacityTransferFunction = 
> vtkPiecewiseFunction::New();
>  opacityTransferFunction->AddPoint(20,0.0);
>  opacityTransferFunction->AddSegment(20,0.0, 340,0.0);
>  opacityTransferFunction->AddSegment(340, 0.0,395,0.2);
>  opacityTransferFunction->AddSegment(395,0.2,460,0.0);
>  opacityTransferFunction->AddSegment(460,0.0, 1430,0.0); 
>  opacityTransferFunction->AddSegment(1430,0.0,1464,0.2);
>  opacityTransferFunction->AddSegment(1464, 0.2,1511,0.0);
> 
> 
>  vtkColorTransferFunction* colorTransferFunction = 
> vtkColorTransferFunction::New();
>  colorTransferFunction->AddRGBPoint(20.0, 0.0,0.0,1.0);
>  colorTransferFunction->AddRGBPoint(300.0, 0.0,0.0,0.7);
>  colorTransferFunction->AddRGBPoint( 1200.0, 0.0,0.7,0.0);
>  colorTransferFunction->AddRGBPoint(1400.0, 0.6,0.0,0.0); 
>  colorTransferFunction->AddRGBPoint(1500.0, 0.8,0.0,0.0);
>  
> 
>  vtkVolumeProperty* volumeProperty = vtkVolumeProperty::New();
>  volumeProperty->SetColor(colorTransferFunction);
>  volumeProperty->SetScalarOpacity(opacityTransferFunction);
>  volumeProperty->SetInterpolationTypeToLinear();
> 
>  vtkVolumeTextureMapper3D* texMapper = vtkVolumeTextureMapper3D::New();
>  texMapper->SetInputConnection(reader->GetOutputPort());
>  texMapper->SetPreferredMethodToNVidia();
>  //texMapper->SetSampleDistance( 0.25);
> 
>  vtkVolumeRayCastCompositeFunction* composite = 
> vtkVolumeRayCastCompositeFunction::New();
>  vtkVolumeRayCastMapper* raycastMapper = vtkVolumeRayCastMapper::New();
>  raycastMapper->SetVolumeRayCastFunction(composite);
>  raycastMapper->SetInputConnection(reader->GetOutputPort());
>  raycastMapper->SetNumberOfThreads(2);
>  raycastMapper->SetImageSampleDistance(0.5);
>    
>  vtkVolume* volume = vtkVolume::New();
>  volume->SetMapper(texMapper);
>  //volume->SetMapper(raycastMapper);
>  volume->SetProperty(volumeProperty);
> 
>  vtkRenderer* ren = vtkRenderer::New();
>  ren->AddVolume(volume);
> 
> 
>  vtkRenderWindow* renWin = vtkRenderWindow::New();
>  renWin->AddRenderer(ren);
> 
> 
>  vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New(); 
>  iren->SetSize(800,600);
>  iren->SetRenderWindow(renWin);
> 
> 
>  iren->Initialize();
>  iren->Start();
> 
>  ren->Delete();
>  iren->Delete();
>  renWin->Delete();
>  reader->Delete();
>  opacityTransferFunction->Delete(); 
>  volumeProperty->Delete();
>  texMapper->Delete();
>  composite->Delete();
>  raycastMapper->Delete();
>  volume->Delete();
>  colorTransferFunction->Delete();
>  return 0;
> }
> 
>  
>  
>  
> 
> Pang Shengyong
> berry_hust at hotmail.com <mailto:berry_hust at hotmail.com>
> Solidification  Simulation Lab, Huazhong Univ. of Sci. & Tech.
> 
> (Tel)+86-27-87541922
> 
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list