MantisBT - VTK
View Issue Details
0005499VTK(No Category)public2007-08-14 17:032008-07-26 13:14
Levap 
David Gobbi 
normalcrashalways
closedfixed 
 
 
0005499: Bug in vtkThinPlateSplineTransform::InternalUpdate()
The following code leads to crash: division by zero!

int nSize = 2;
vtkPoints* pScr = vtkPoints::New();
pScr->SetNumberOfPoints(nSize);

pScr->SetPoint(0, 0.0, 0.0, 0.0);
pScr->SetPoint(1, 5.0, 6.0, 0.0);

vtkPoints* pTrg = vtkPoints::New();
pTrg->SetNumberOfPoints(nSize);

pTrg->SetPoint(0, 0.0, 0.0, 0.0);
pTrg->SetPoint(1, 0.0, 0.0, 0.0);

vtkThinPlateSplineTransform* pT = vtkThinPlateSplineTransform::New();
pT->Modified();
pT->SetSourceLandmarks(pScr);
pT->SetTargetLandmarks(pTrg);
pT->Update();

pT->Delete();
The problem is in vtkThinPlateSplineTransform.cxx line 373:

// normalize the two vectors
rs = sqrt(rs);
ds[0] /= rs; ds[1] /= rs; ds[2] /= rs;
rt = sqrt(rt);
dt[0] /= rt; dt[1] /= rt; dt[2] /= rt;

The value of rs and rt are zero! What is the right strategy in this case?
No tags attached.
Issue History
2007-08-14 17:03LevapNew Issue
2008-02-06 09:28Jeff BaumesStatusbacklog => tabled
2008-02-06 09:28Jeff BaumesAssigned To => David Gobbi
2008-02-07 17:44David GobbiNote Added: 0010428
2008-02-19 11:03David GobbiNote Added: 0010585
2008-02-19 11:04David GobbiNote Edited: 0010585
2008-07-25 08:55David GobbiNote Added: 0012819
2008-07-25 08:55David GobbiResolutionopen => fixed
2008-07-25 08:56David GobbiNote Deleted: 0012819
2008-07-26 13:14David GobbiStatustabled => closed
2011-06-16 13:11Zack GalbreathCategory => (No Category)

Notes
(0010428)
David Gobbi   
2008-02-07 17:44   
If there are duplicate landmarks within either the SourceLandmarks or TargetLandmarks, that qualifies as a bad input and a VTK error should be raised. I will add a check for this.
(0010585)
David Gobbi   
2008-02-19 11:03   
(edited on: 2008-02-19 11:04)
Fix committed on Friday, February 15 2008. Code will generate an warning when there are two coincident source or target points, and will no longer crash.