[vtkusers] vtkProcrustesAlignmentFilter

Obada Mahdi omahdi at gmx.de
Fri Jan 18 12:38:45 EST 2008


[resending with Cc: to vtkusers, sorry for any dupes]

Hi Anders!

There are two different notions, one of which is an "input port" of an algorithm 
(which is usually fixed and defined by the way an algorithm works), and the 
other is an "input connection" on a particular input port (of which there can be 
many per given port).

 From what I've gathered reading the documentation, vtkProcrustesAlignmentFilter 
takes n inputs on the single port 0, where n has to be set using 
SetNumberOfInputs(), and produces n outputs on ports 0 to n-1.

Anders wrote:
> I've implemented a c++ solution of the Python example "procrustesAlignment.py"
> included in VTK 5.0.3. The  implementation seem to produce a correct result but
> the following errors are generated:
 >
> ERROR: In ~/VTK/Filtering/vtkAlgorithm.cxx, line 626
> vtkProcrustesAlignmentFilter (0x64c1ac0): Attempt to connect input port index 1
> for an algorithm with 1 input ports.
 >
> ERROR: In ~/VTK/Filtering/vtkAlgorithm.cxx, line 626
> vtkProcrustesAlignmentFilter (0x64c1ac0): Attempt to connect input port index 2
> for an algorithm with 1 input ports.


I guess you meant to do the right thing writing

|   procrustes2->SetInputConnection(0, sphere->GetOutputPort());
|   procrustes2->SetInputConnection(1, transformer1->GetOutputPort());
|   procrustes2->SetInputConnection(2, transformer2->GetOutputPort());

in your code, where in fact it should read

|   procrustes2->SetNthInputConnection(0, 0, sphere->GetOutputPort());
|   procrustes2->SetNthInputConnection(0, 1, transformer1->GetOutputPort());
|   procrustes2->SetNthInputConnection(0, 2, transformer2->GetOutputPort());

or maybe even just

|   procrustes2->AddInputConnection(0, sphere->GetOutputPort());
|   procrustes2->AddInputConnection(0, transformer1->GetOutputPort());
|   procrustes2->AddInputConnection(0, transformer2->GetOutputPort());


> I've used procrustes2->SetNumberOfInputs(3); to open up 3 inputs but it doesn't
> work since it's only possible to use the first port (0). Before the row:
> procrustes2->SetInputConnection(0, sphere->GetOutputPort());
> the procrustes2->GetTotalNumberOfInputConnections()  tells me that there are
> 3 inputs open but after that row the procrustes2->GetTotalNumberOfInputConnections()
> says that only 1 input is open.

The method SetNumberOfInputs() is a "convenience" method provided by 
vtkProcrustesAlignmentFilter and uses lower-level methods inherited from 
vtkAlgorithm in order to set up n input connections on port 0 as well as n 
output ports.  However, calling SetInputConnection() for a port implicitly 
removes all existing input connections and sets up a single one instead -- that 
is why the effect of setting up tree input connections through 
SetNumberOfInputs(3) is reversed by a call to SetInputConnection().


HTH,

Obada



More information about the vtkusers mailing list