[vtkusers] vtkProcrustesAlignmentFilter

Anders anders.forsberg at radiol.uu.se
Fri Jan 18 08:08:02 EST 2008


Hi,

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'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.


This is the code (running on mac os x 10.4.11). I've only converted the part of
the python example that uses the similarity mode and skipped the affine and
rigid body part. This will not affect the function of the code.

I can't find any solution to this problem. Would be very happy if someone could
help out.

Thanks in advance!

/Anders


code:

		vtkSphereSource * sphere = vtkSphereSource::New();

		// make two copies of the shape and distort them a little
		vtkTransform * transform1 = vtkTransform::New();
		transform1->Translate(0.2, 0.1, 0.3);
		transform1->Scale(1.3, 1.1, 0.8);

		vtkTransform * transform2 = vtkTransform::New();
		transform2->Translate(0.3, 0.7, 0.1);
		transform2->Scale(1.0, 0.1, 1.8);
		
		vtkTransformPolyDataFilter * transformer1 =
			vtkTransformPolyDataFilter::New();
		transformer1->SetInputConnection(sphere->GetOutputPort());
		transformer1->SetTransform(transform1);
		
		vtkTransformPolyDataFilter * transformer2 =
			vtkTransformPolyDataFilter::New();
		transformer2->SetInputConnection(sphere->GetOutputPort());
		transformer2->SetTransform(transform2);
		
		// map these three shapes into the first renderer
		vtkPolyDataMapper * map1a = vtkPolyDataMapper::New();
		map1a->SetInputConnection(sphere->GetOutputPort());
		vtkActor * Actor1a = vtkActor::New();
		Actor1a->SetMapper(map1a);
		Actor1a->GetProperty()->SetDiffuseColor(1.0000, 0.3882, 0.2784);

		vtkPolyDataMapper * map1b = vtkPolyDataMapper::New();
		map1b->SetInputConnection(transformer1->GetOutputPort());
		vtkActor * Actor1b = vtkActor::New();
		Actor1b->SetMapper(map1b);
		Actor1b->GetProperty()->SetDiffuseColor(0.3882, 1.0000, 0.2784);

		vtkPolyDataMapper * map1c = vtkPolyDataMapper::New();
		map1c->SetInputConnection(transformer2->GetOutputPort());
		vtkActor * Actor1c = vtkActor::New();
		Actor1c->SetMapper(map1c);
		Actor1c->GetProperty()->SetDiffuseColor(0.3882, 0.2784, 1.0000);

		// -- align the shapes using Procrustes
		// (using SetModeToSimilarity (default)) --
		vtkProcrustesAlignmentFilter * procrustes2 =
			vtkProcrustesAlignmentFilter::New();
		procrustes2->SetNumberOfInputs(3);
//		std::cout << procrustes2->GetTotalNumberOfInputConnections()
			<< std::endl;
		procrustes2->SetInputConnection(0, sphere->GetOutputPort());
//		std::cout << procrustes2->GetTotalNumberOfInputConnections()
			<< std::endl;	
	      procrustes2->SetInputConnection(1, transformer1->GetOutputPort());
	      procrustes2->SetInputConnection(2, transformer2->GetOutputPort());


// the code continues here but I don't think that is of interest











More information about the vtkusers mailing list