[vtkusers] Unstructured grid renderer artefacts ?

Zsolt kanyi at seznam.cz
Fri Sep 23 07:53:03 EDT 2005


Dear VTK users,

I`m using VTK 4.4 under Visual C++ 7.1 for unstructured grid rendering and I`m getting strange artefacts, 
like small dots in the results:
   see link      http://www.sccg.sk/~toth/vtk/06.tiff
or if it is viewed axis alligned:
    see link     http://www.sccg.sk/~toth/vtk/18.tiff

the dataset can be found at:   link: http://www.sccg.sk/~toth/vtk/input.vtk

The code of the application:

#include "vtkConeSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkCamera.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRendererSource.h"
#include "vtkTIFFWriter.h"

#include "vtkVolumeRayCastMapper.h"
#include "vtkVolumeRayCastCompositeFunction.h"
#include "vtkUnstructuredGridVolumeRayCastMapper.h"
#include "vtkStructuredPoints.h"
#include "vtkUnstructuredGridReader.h"
#include "vtkDataReader.h"
#include <stdio.h>

#include "vtkPiecewiseFunction.h"
#include "vtkColorTransferFunction.h"
#include "vtkVolumeProperty.h"

#include "vtkDataArray.h"
#include "vtkErrorCode.h"
#include "vtkFieldData.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkStructuredPoints.h"
#include <vtkUnsignedShortArray.h> 
#include "vtkCellData.h"

#include <iostream>
using namespace std;


#include "vtkDataReader.h"


int main( int argc, char *argv[] )
{
  // volume property
  int shade = 0, 
	  compos = 0,  //Classify First or Interpolate First 
	  interp = 0;

  // renderer
  vtkRenderer *ren1= vtkRenderer::New();
  ren1->SetBackground( 1.0, 1.0, 1.0 );
  
  // render window
  vtkRenderWindow *renWin = vtkRenderWindow::New();
  renWin->AddRenderer( ren1 );
  renWin->SetSize( 800, 600 );

  // interactor
  vtkRenderWindowInteractor *iren1 = vtkRenderWindowInteractor::New();
  iren1->SetRenderWindow(renWin);

  // set up the input file for unstructured grid reader
  vtkUnstructuredGridReader *unstructuredReader =vtkUnstructuredGridReader::New();
  unstructuredReader->SetFileName("input.vtk");

  // set up opacity transfer function
  vtkPiecewiseFunction *opacityTransferFunction = vtkPiecewiseFunction::New();
  opacityTransferFunction->AddPoint(0,   0.02);
  opacityTransferFunction->AddPoint(4095.0, 1.0);

  // set up color transfer function
  vtkColorTransferFunction *colorTransferFunction = 
	  vtkColorTransferFunction::New();
  colorTransferFunction->AddRGBPoint( 0.0, 0.1, 0.1, 0.1);
  colorTransferFunction->AddRGBPoint( 4095.0, 1.0, 0.0, 1.0);	

  // set up volume property
  vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
  volumeProperty->SetColor(colorTransferFunction);
  volumeProperty->SetScalarOpacity(opacityTransferFunction);
  volumeProperty->SetInterpolationType(interp);
  volumeProperty->SetShade(shade);

  // composite function for strucured grid renderer
  vtkVolumeRayCastCompositeFunction *compositeFunction = 
	  vtkVolumeRayCastCompositeFunction::New();
  compositeFunction->SetCompositeMethod(compos);

  //unstructuredGridRendering
  vtkUnstructuredGridVolumeRayCastMapper *volumeUnstructedMapper = vtkUnstructuredGridVolumeRayCastMapper::New();
  volumeUnstructedMapper->SetInput(unstructuredReader->GetOutput());

  vtkVolume *volume = vtkVolume::New();

  volume->SetMapper(volumeUnstructedMapper);
  
  volume->SetProperty(volumeProperty);

  // add volume to renderer
  ren1->AddVolume(volume);

  renWin->Render();

  iren1->Start();
  
  ren1->Delete();
  renWin->Delete();
  iren1->Delete();
  opacityTransferFunction->Delete();
  colorTransferFunction->Delete();
  volumeProperty->Delete();
  compositeFunction->Delete();
   // unstructured grid case
  volumeUnstructedMapper->Delete();
  unstructuredReader->Delete();
  volume->Delete();

  return 0;
}

Do You have any idea what can cause these problems?

Many thanks, best regards
                                           Zsolt




More information about the vtkusers mailing list