Example #1
0
PyObject* OOFImage3D::getVolumeActor() {
  vtkFixedPointVolumeRayCastMapper *mapper;
  mapper = vtkFixedPointVolumeRayCastMapper::New();
  mapper->IntermixIntersectingGeometryOn();
  vtkIndent indent;
  image->Update();
  mapper->SetInputConnection(image->GetProducerPort());

  vtkVolumeProperty *volproperty;
  volproperty = vtkVolumeProperty::New();

  vtkColorTransferFunction *red;
  red = vtkColorTransferFunction::New();
  red->AddRGBSegment(0,0,0,0,255,1,0,0);
  volproperty->SetColor(0,red);
  vtkColorTransferFunction *green;
  green = vtkColorTransferFunction::New();
  green->AddRGBSegment(0,0,0,0,255,0,1,0);
  volproperty->SetColor(1,green);
  vtkColorTransferFunction *blue;
  blue = vtkColorTransferFunction::New();
  blue->AddRGBSegment(0,0,0,0,255,0,0,1);
  volproperty->SetColor(2,blue);
  vtkPiecewiseFunction *opacity;
  opacity = vtkPiecewiseFunction::New();
  opacity->AddSegment(0,1,255,0);
  volproperty->SetScalarOpacity(3,opacity);

  vtkVolume *volume;
  volume = vtkVolume::New();
  volume->SetMapper(mapper);
  volume->SetProperty(volproperty);

  return vtkPythonGetObjectFromPointer(volume);
}
//-----------------------------------------------------------------------------
PyObject* ctkVTKPythonQtWrapperFactory::wrap(const QByteArray& classname, void *ptr)
{
  if (classname.startsWith("vtk"))
    {
#if (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION <= 6) || VTK_MAJOR_VERSION < 5
    return vtkPythonGetObjectFromPointer(reinterpret_cast<vtkObjectBase*>(ptr));
#else
    return vtkPythonUtil::GetObjectFromPointer(reinterpret_cast<vtkObjectBase*>(ptr));
#endif
    }
  return NULL;
}