[vtkusers] Translating and rotating PolyData

Dominik Szczerba dominik at itis.ethz.ch
Tue Aug 4 11:14:35 EDT 2009


take a look at vtkTransformFilter.

Dmitri Danewitz wrote:
> 
> Hello David,
>  
> thanks a lot for the example, but there it looks like a new polyData is 
> created. I read mine from a VTK file.
>  
> Here is an example of the VTK file. The values are already there, I just 
> want to change the point coordinates and I managed to extract the point 
> coordinates from the VTK and changed them. Then I put them into the 
> polyData again but then I'm stuck, putting the polyData back into the 
> object where I took it from. Here is an example of my code:
>  
>  
> Reader[0]->SetFileName("D:/VTKzeug/room3D/temperature.vtk");
> Reader[0]->Update();
> 
> //Now making a 2D plane, to make a cut through the room
> plane = vtkPlaneSource::New();
> plane->SetResolution(((int)sqrt(tempForRes))*resolutionFactorX,((int)sqrt(tempForRes))*resolutionFactorY);
> plane->SetOrigin(linex1, liney1, linez1);
> plane->SetPoint1(linex2, liney2 , linez1);
> plane->SetPoint2(linex1, liney1, linez2);
> probe = vtkProbeFilter::New();
> probe->SetInput(plane->GetOutput());
> probe->SetSource(Reader->GetOutput());
> probe->Update();
> //Now changing the point-coordinates with own calculation
> //(I rotate the points and translate them) The values remain the same
> PolyDat = vtkPolyData::New();
> PolyDat = probe->GetPolyDataOutput();
> numberOfCells=PolyDat->GetNumberOfPoints();
> data = vtkPolyData::New();
> scalars = vtkFloatArray::New();
> points = vtkPoints::New();
> for (int i = 0; i < numberOfCells; i++)
> {
>  scalars->InsertTuple1(i, 
> PolyDat->GetPointData()->GetScalars()->GetTuple(j));
> //deleted the stuff here to calculate the new coordinate values
>  points->InsertPoint(i, newX, nexY, newZ);
> }
> //I take the new point-coordinates, as well as the unchanges scalars to 
> the vtkPolyData
> //and now don't know how to take them into the vtkPlaneSource probe again
> PolyDat->SetPoints(points);
> PolyDat->GetPointData()->SetScalars(scalars);
>  
>  
> ... I don't know if there is a class that provides simple translating 
> and rotating the points of the polyData, so I did it manually. But now I 
> can not bring the polyData back to the vtkPlaneSource plane for 
> visualising it.
>  
> Greets
> Dmitri
> 
> --- David Doria /<daviddoria+vtk at gmail.com>/ schrieb am *Di, 4.8.2009:
> *
> 
>     *
>     Von: David Doria <daviddoria+vtk at gmail.com>
>     Betreff: Re: [vtkusers] Translating and rotating PolyData
>     An: vtkusers at vtk.org
>     Datum: Dienstag, 4. August 2009, 14:00
> 
>     *
> 
>         *
> 
> 
>             Hello David,
>              
>             I'm not sure if i explained it right. First I read a VTK
>             file, in which is a rectilinear grid in 3D. And every point
>             of the grid has its value (scalar) (for example, in a 3D
>             room each value is a temperature at its coordinates)
>              
>             I now want to move the values in the grid, so that for example
>              
>             x = 0, y = 0, z = 0
>             with the temperature value 30°C in that location and I move
>             it to:
>              x = x +100
>             so that the new coordinates are :
>             x = 100, y = 0, z = 0
>             and the value has still to be 30°C
>             this is what I want to reach.
>             Hope I managed to explain that somehow.
>              
>             Greets
>             Dmitri
> 
>         *
> 
>         *
>         *
> 
>     *
>     Dmitri,
> 
>     Please reply to the list rather than an individual so everyone can
>     benefit from the conversation.
> 
>     Yes, that explanation is exactly what I thought you were talking
>     about. See this example for how to attach that temperature value to
>     your grid points:
> 
>     http://www.vtk.org/Wiki/Add_Miscellaneous_Data_to_Points_in_a_Polydata
>     http://www.vtk.org/Wiki/Add_Miscellaneous_Data_to_Cells_in_a_Polydata
> 
>     I'm assuming the values are already in that type of array in your
>     vtk file? If you can't get it from here please provide the vtk file
>     and we'll take a look.
> 
>     Thanks,
> 
>     David
>     *
>     *
>     -----Integrierter Anhang folgt-----
> 
>     *
>     *_______________________________________________
>     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
>     *
> 
> **
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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


-- 
d o m i n i k   s z c z e r b a ,   p h d . . . . . . . . . . .
c o m p u t a t i o n a l   l i f e   s c i e n c e   g r o u p
. . . . . . . i t ' i s   r e s e a r c h   f o u n d a t i o n
. . . . . . . . . . . . . . . . . . . . http://www.itis.ethz.ch




More information about the vtkusers mailing list