[vtk-developers] [VTK 0013819]: vtkHyperOctree->DeepCopy() provides shallow copy.
Mantis Bug Tracker
mantis at public.kitware.com
Wed Jan 23 23:58:19 EST 2013
The following issue has been SUBMITTED.
======================================================================
http://vtk.org/Bug/view.php?id=13819
======================================================================
Reported By: Trevor
Assigned To:
======================================================================
Project: VTK
Issue ID: 13819
Category: (No Category)
Reproducibility: have not tried
Severity: minor
Priority: normal
Status: backlog
Project: TBD
Type: incorrect functionality
Resolution: open
Fixed in Version:
======================================================================
Date Submitted: 2013-01-23 23:58 EST
Last Modified: 2013-01-23 23:58 EST
======================================================================
Summary: vtkHyperOctree->DeepCopy() provides shallow copy.
Description:
As reported on vtkUsers mailing list:
http://www.vtk.org/pipermail/vtkusers/2013-January/127166.html
The DeepCopy() method of vtkHyperOctree actually provides a shallow copy. This
can be seen in the following example:
/**
@file File exhibiting possible error in VTK
@author Trevor Irons
@date 01/15/2013
@version 0.0
**/
#include <iostream>
#include "vtkHyperOctree.h"
#include "vtkHyperOctreeCursor.h"
#include "vtkDoubleArray.h"
#include "vtkDataSetAttributes.h"
using namespace std;
int main() {
vtkHyperOctree* Octree1 = vtkHyperOctree::New();
Octree1->SetDimension(3);
Octree1->SetOrigin(0,0,0);
cout << "Octree1 GetNum Leaves "<< Octree1->GetNumberOfLeaves() <<
std::endl;
vtkHyperOctree* Octree2 = vtkHyperOctree::New();
Octree1->SetDimension(3);
Octree1->SetOrigin(0,0,0);
cout << "Octree2 Num Leaves " << Octree2->GetNumberOfLeaves() << std::endl;
// Now modify one of them
vtkHyperOctreeCursor* Cursor = Octree1->NewCellCursor();
Cursor->ToRoot();
Octree1->SubdivideLeaf(Cursor);
// set some leaf data
vtkDoubleArray *leafData = vtkDoubleArray::New();
for (int i=0; i<8; ++i) {
leafData->InsertNextTuple1(i);
}
leafData->SetName("da leaf data");
Octree1->GetLeafData()->SetScalars( leafData );
// copy
Octree2->DeepCopy(Octree1);
cout << "After Subdivide Octree1 GetNum Leaves = " <<
Octree1->GetNumberOfLeaves() << std::endl;
cout << "Octree2 Num Leaves (expect changed) = " <<
Octree2->GetNumberOfLeaves() << std::endl;
// Leaf Data
cout << Octree1->GetLeafData()->GetScalars() << std::endl;
cout << Octree2->GetLeafData()->GetScalars() << std::endl;
for (int i=0; i<8; ++i) {
cout << Octree1->GetLeafData()->GetScalars()->GetTuple1(i) << std::endl;
cout << Octree2->GetLeafData()->GetScalars()->GetTuple1(i) << std::endl;
}
// muck with Octree1
Cursor->ToRoot();
for (int i=0; i<8; ++i) {
Cursor->ToChild(i);
Octree1->SubdivideLeaf(Cursor);
Cursor->ToParent();
}
cout << "After Subdivide Octree1 GetNum Leaves = " <<
Octree1->GetNumberOfLeaves() << std::endl;
cout << "Octree2 Num Leaves (expect NOT changed) = " <<
Octree2->GetNumberOfLeaves() << std::endl;
Octree1->Delete();
Octree2->Delete();
Cursor->Delete();
leafData->Delete();
}
It is clear that DeepCopy is providing a shallow copy.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2013-01-23 23:58 Trevor New Issue
======================================================================
More information about the vtk-developers
mailing list