[vtk-developers] Bugfix for vtkPointSet::DeepCopy
pat marion
pat.marion at kitware.com
Fri Mar 19 13:55:21 EDT 2010
Hi,
Sorry to bring this up right before the branch, but I have a bugfix for
vtkPointSet I'd like to squeeze in. If I don't hear any objections I'll
commit it, 100% tests pass after the patch. Here is the bug demonstrated in
python:
from vtk import *
p1 = vtkPolyData()
p2 = vtkPolyData()
s = vtkSphereSource()
s.Update()
p1.DeepCopy(s.GetOutput())
print p1.GetNumberOfPoints()
p1.DeepCopy(p2)
print p1.GetNumberOfPoints()
this prints:
50
50
but I claim it should print:
50
0
Attached is my patch. Below is the current implementation of
vtkPointSet::DeepCopy and after that my new version. The bug is that
'this->Points->DeepCopy' becomes a no-op when the pointset-to-copy has null
vtkPoints.
//----------------------------------------------------------------------------
void vtkPointSet::DeepCopy(vtkDataObject *dataObject)
{
vtkPointSet *pointSet = vtkPointSet::SafeDownCast(dataObject);
if ( pointSet != NULL )
{
if (this->Points == NULL)
{
if ( pointSet->GetPoints() != NULL )
{
this->Points = pointSet->GetPoints()->NewInstance();
this->Points->SetDataType(pointSet->GetPoints()->GetDataType());
this->Points->Register(this);
this->Points->Delete();
}
else
{
this->Points = vtkPoints::New();
this->Points->Register(this);
this->Points->Delete();
}
}
this->Points->DeepCopy(pointSet->GetPoints());
}
// Do superclass
this->vtkDataSet::DeepCopy(dataObject);
}
//----------------------------------------------------------------------------
void vtkPointSet::DeepCopy(vtkDataObject *dataObject)
{
vtkPointSet *pointSet = vtkPointSet::SafeDownCast(dataObject);
if ( pointSet != NULL )
{
vtkPoints* newPoints;
vtkPoints* pointsToCopy = pointSet->GetPoints();
if (pointsToCopy)
{
newPoints = pointsToCopy->NewInstance();
newPoints->SetDataType(pointsToCopy->GetDataType());
newPoints->DeepCopy(pointsToCopy);
}
else
{
newPoints = vtkPoints::New();
}
this->SetPoints(newPoints);
newPoints->Delete();
}
// Do superclass
this->vtkDataSet::DeepCopy(dataObject);
}
Pat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100319/320ddc73/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pointset_deepcopy_fix.diff
Type: text/x-diff
Size: 1203 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100319/320ddc73/attachment-0001.diff>
More information about the vtk-developers
mailing list