[vtkusers] vtkHyperOctree DeepCopy seems to actually be shallow

Trevor Irons trevorirons at gmail.com
Tue Jan 15 17:44:52 EST 2013


Hello. I am having a problem with the vtkHyperOctree->DeepCopy method. The
underlying CellTree is being shallow copied.

I made the following modification to vtkHyperOctree.cxx:112

//-----------------------------------------------------------------------------
// because the PrintSelf test is not smart, PrintSelf has to be here.
void vtkHyperOctree::PrintSelf(ostream& os, vtkIndent indent)
{
  this->Superclass::PrintSelf(os,indent);

  os << indent << "Dimension: "<<this->Dimension<<endl;
  os << indent << "Size: "<<this->Size[0]<<","<<this->Size[1]<<",";
  os <<this->Size[2]<<endl;
  os << indent << "origin: "<<this->Origin[0]<<","<<this->Origin[1]<<",";
  os <<this->Origin[2]<<endl;

  os << indent << "DualGridFlag: " << this->DualGridFlag << endl;
  os << indent << "CellTree Ptr " << this->CellTree << endl;  // stream
pointer address
  //this->CellTree->PrintSelf(os,indent);
}

Just to check the address of the underlying tree. Then in a piece of (c++)
code

vtkHyperOctreeSampleFunction* OctSamp2 =
vtkHyperOctreeSampleFunction::New();
vtkHyperOctree* Octree = vtkHyperOctree::New();
// Do the sampling
this->Octree->DeepCopy(OctSamp2->GetOutput())
std::cout << *OctSamp2->GetOutput() << std::endl;
std::cout << *Octree << std::endl;

And the two pointer addresses were the same.

OctSamp2-> GetOutput()  ->>>>>   CellTree Ptr 0x237fcf0
Octree -                           ->>>>>   CellTree Ptr 0x237fcf0

Which I did not expect, and is causing errors in  my application. Is there
a way to get a true deep copy?

If this is indeed an error I can generate a test file exhibiting the
problem. But my method of checking involved mucking with the vtk source
file.

Thanks for any help or input.

-- Trevor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130115/3ef61fda/attachment.htm>


More information about the vtkusers mailing list