[vtkusers] vtkPolyDataConnectivityFilter and world position of the vtkActors

Eric E. Monson emonson at cs.duke.edu
Thu Jun 24 09:32:54 EDT 2010


Hey Mark,

I've never used it myself, but looking at the test for vtkIterativeClosestPointTransform and the example:

http://www.vtk.org/Wiki/VTK/Examples/Filters/IterativeClosestPointsTransform

it looks like you need to feed it your polydata, and not the actors. You can then get the transform out with GetMatrix() and then use vtkTransformPolyDataFilter to apply the transform to your data (or to the UserMatrix of your actor).

I always think of the actor position as relative to the natural starting point -- wherever the coordinates of your polydata are located, that's the (0,0,0) starting point for the actor, and then you can change the position or orientation relative to that original position.

Talk to you later,
-Eric

------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group


On Jun 23, 2010, at 6:26 PM, Mark K. Batesole, DDS, MS wrote:

> Hi Everyone,
> 
> I'm having a heck of a time getting this little application to work correctly. Here's the problem I'm having: after splitting the polydata and assigning each part an actor. I'd like to get the world position of each actor so that I can then run an vtkIterativeClosestPointTransform and know what the transformation matrix is from one of the actors to another. So I've used vtkActor->GetPosition() which according to all the documentation I've found should return the actor's world coordinates. But each actor returns (0.0, 0.0, 0.0). Since they are not all on top of each other at the origin, I don't see how this could be correct. 
> 
> I know I must be missing something... any help would be sincerely appreciated. 
> 
> Thank you,
> Mark
> 
> <code snippet follows>
> 
> def splitParts(polydata):
>     conn = vtk.vtkPolyDataConnectivityFilter()
>     conn.SetInput(polydata)
>     conn.SetExtractionModeToAllRegions()
>     conn.Update()
> 
>     nregions = conn.GetNumberOfExtractedRegions()
> 
>     conn.SetExtractionModeToSpecifiedRegions()
>     conn.Update()
> 
>     polydata_collection = []
> 
>     for region in xrange(nregions):
>         conn.InitializeSpecifiedRegionList()
>         conn.AddSpecifiedRegion(region)
>         conn.Update()
> 
>         p = vtk.vtkPolyData()
>         p.DeepCopy(conn.GetOutput())
>         p.Update()
> 
>         polydata_collection.append(p)
> 
>     return polydata_collection
> 
> reader = vtk.vtkXMLPolyDataReader()
> reader.SetFileName('Model.vtp') 
> reader.Update();
> 
> polydataCollection = splitParts(reader.GetOutput())
> actorCollection = []    
> 
> for item in xrange(len(polydataCollection)):
>     mapper = vtk.vtkPolyDataMapper()
>     mapper.SetInput(polydataCollection[item])
>     
>     actor = vtk.vtkActor()
>     actor.SetMapper(mapper)
>     actorCollection.append(actor)
>     ren.AddActor(actor)
> 
>     print actor.GetPosition()
> 
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects athttp://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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100624/2338dd66/attachment.htm>


More information about the vtkusers mailing list