[vtkusers] vtkProcrustesAlignmentFilter

Obada Mahdi omahdi at gmx.de
Sun Jan 20 10:14:55 EST 2008


Hi Anders!

I am sorry for any inconvenience, I shouldn't have rushed through writing that 
reply.  I took another look at the code -- as it turns out, the Python example 
is buggy already and produces the exact same error messages as your C++ version 
does.

Anders Forsberg wrote:
> The SetNthInputConnection() is a protected method which I can't access.

>> |   procrustes2->AddInputConnection(0, sphere->GetOutputPort());
>> |   procrustes2->AddInputConnection(0, transformer1->GetOutputPort());
>> |   procrustes2->AddInputConnection(0, transformer2->GetOutputPort());
>>
> 
> The AddInputConnection() will crash the application

I've made another mistake here.  The first input has to be set using 
SetInputConnection(), then other input connections can be added by calling 
AddInputConnection().  This seems to work just fine, see attached example.

There is another method to set up input connections, which is used in the 
corresponding Tcl example in "Examples/Modelling/Tcl/procrustesAlignment.tcl". 
It uses a different (obsolete) interface for establishing pipeline connections, 
where output data objects (like vtkPolyData instances) are passed around 
directly, as opposed to proxy objects that only hold information about the 
algorithm instance and output port index that is producing a certain output data 
object.  In C++, this method, as used in the Tcl example, would read

|   procrustes2->SetInput(0, sphere->GetOutput());
|   procrustes2->SetInput(1, transformer1->GetOutput());
|   procrustes2->SetInput(2, transformer2->GetOutput());


It should be noted, however, that the way SetInput() works in 
vtkProcrustesAlignmentFilter differs from the way it works in its superclass, 
vtkPointSetAlgorithm (and probably elsewhere).

vtkProcrustesAlignmentFilter::SetInput() interprets the index passed as first 
argument as the index of a connection on port 0, which is hard-wired into the 
code (in fact, it does use SetNthInputConnection(0, index, ...) internally). 
However, the superclass implementation of SetInput() treats the index argument 
as a port index, so it has the same effect as SetInputConnection(index, ...) (as 
it is written in the Python example, which causes those errors).

Having such inconsistencies means that one should probably be cautious with 
those "old-style" pipeline connection interfaces, and at least have a really 
good look at the documentation, maybe even the code ;-)


In the attached example code, I've just used the code snippet from your first 
email and added two renderers, one render window and one interactor in order to 
display both the input and output of the vtkProcrustesAlignmentFilter.  I've 
tried both methods, SetInput() and Set/AddInputConnection(), they both seem to 
work (I am using VTK CVS, though).


Regards and good luck :-)

Obada
-------------- next part --------------
A non-text attachment was scrubbed...
Name: procrustes.cc
Type: text/x-c++src
Size: 5367 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080120/3c9fac3a/attachment.cc>


More information about the vtkusers mailing list