[vtkusers] vtkPolyDataConnectivityFilter and world position of the vtkActors

Mark K. Batesole, DDS, MS mbatesole at yahoo.com
Thu Jun 24 22:19:43 EDT 2010


Hey Eric,

I'll post it to the group... my code is just so ugly, I was embarrassed. I'm a much better orthodontist than computer programmer ;)

Thanks again,
-Mark





________________________________
From: Eric E. Monson <emonson at cs.duke.edu>
To: "Mark K. Batesole, DDS, MS" <mbatesole at yahoo.com>
Cc: Mailing List VTK <vtkusers at vtk.org>
Sent: Thu, June 24, 2010 7:10:38 PM
Subject: Re: [vtkusers] vtkPolyDataConnectivityFilter and world position of the vtkActors

Hey Mark,

(Please respond to the whole list so everyone can contribute.)

What do you mean, "the transform still isn't responding in a way that I expect"? You have some idea of the transform that should come out of vtkIterativeClosestPointTransform, and what it's generating doesn't seem right? Or, after applying the transform the data set's don't align?

Feel free to post your code (or better, a minimal example that demonstrates the problem) and hopefully someone can spot what's wrong.

Talk to you later,
-Eric



On Jun 24, 2010, at 9:19 PM, Mark K. Batesole, DDS, MS wrote:

Hey Eric,
>
>
>Thanks so much for responding. You are totally right the vtkIterativeClosestPointTransform uses polydata. When I did the transform, and applied it to the data, the actor didn't seem to be moving, and I assumed the GetPosition() method was the root of the problem. Turns out I wasn't inputting the transformed data to the new actor. Sheesh. But, regardless, the transform still isn't responding in a way that I expect. Would you mind if I sent you my code so you can take a peek and tell me where I'm messing up?
>
>
>Thanks again, 
>Mark 
>
>
>
________________________________
From: Eric E. Monson <emonson at cs.duke.edu>
>To: "Mark K. Batesole, DDS, MS" <mbatesole at yahoo.com>
>Cc: vtkusers at vtk.org
>Sent: Thu, June 24, 2010 6:32:54 AM
>Subject: Re: [vtkusers] vtkPolyDataConnectivityFilter and world position of the vtkActors
>
>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/cbdf8d52/attachment.htm>


More information about the vtkusers mailing list