2

I'm using VTK+Paraview to produce some nice images for a presentation. My problem is the following: I have a sequence of camera poses with the corresponding grayscale images and I'd like to visualize them in 3D space. For the camera I use a cone and to put it in the right position I apply a transform filter to it:

vtkSmartPointer<vtkConeSource> coneSource = vtkSmartPointer<vtkConeSource>::New();
coneSource->SetHeight(0.02);
coneSource->SetRadius(0.01);
coneSource->SetResolution(4);
double direction[3] = {-1,0,0};
coneSource->SetDirection(direction);
coneSource->Update();

vtkSmartPointer<vtkTransform> cone_transform = vtkSmartPointer<vtkTransform>::New();
cone_transform->Translate(translation.x()+0.16,translation.y()+0.12,translation.z()-0.2);
cone_transform->RotateWXYZ(rotation.angle(),rotation.axis().x(),rotation.axis().y(),rotation.axis().z());
vtkSmartPointer<vtkTransformPolyDataFilter> cone_transformFilter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
cone_transformFilter->SetInputConnection(coneSource->GetOutputPort());
cone_transformFilter->SetTransform(cone_transform);
cone_transformFilter->Update();

and then I save it to a .vtp file.

For the image I thought it was a good idea to store it in a vtkImageData object, but then I don't know how to apply a transform to it.

Searching on the web didn't help.

Please, can someone show me how to do it correctly?

Thanks!


EDIT:

I tried using vtkImageReslice as explained here:

http://www.vtk.org/pipermail/vtkusers/2010-July/061266.html

but with no results :(


EDIT 2:

@Kenneth

I tried this way:

vtkSmartPointer<vtkImageData> imageData = vtkSmartPointer<vtkImageData>::New();
...
vtkSmartPointer<vtkTransformFilter> transformFilter = vtkSmartPointer<vtkTransformFilter>::New();
//transformFilter->SetInput(imageData);
transformFilter->SetInputConnection(imageData->GetProducerPort());
transformFilter->SetInformation(imageData->GetInformation());
transformFilter->SetTransform(vTransform);
transformFilter->Update();

but I get this error:

ERROR: In /build/buildd/vtk-5.8.0/Filtering/vtkExecutive.cxx, line 756 vtkStreamingDemandDrivenPipeline (0x13106e0): Algorithm vtkTransformFilter(0x130fc80) returned failure for request: vtkInformation (0x1310220)

Debug: Off

Modified Time: 1961

Reference Count: 1

Registered Events: (none)

Request: REQUEST_DATA_OBJECT

ALGORITHM_AFTER_FORWARD: 1

FROM_OUTPUT_PORT: 0

FORWARD_DIRECTION: 0

Any idea on how to solve it?

Federico Nardi
  • 510
  • 7
  • 19

2 Answers2

3

Here I found the answer:

http://public.kitware.com/pipermail/vtkusers/2009-January/050239.html

Basically, a vtkImageData must always be axis-aligned. If you want to apply a transform to a grid it's better to use vtkStructuredGrid.

Federico Nardi
  • 510
  • 7
  • 19
0

Another possibility is to set a user transform on the actor/prop instead of actually transforming the object. Instead of changing the object, you just modify the scene.

You may find the TransformActor example useful.

normanius
  • 8,629
  • 7
  • 53
  • 83