View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0003941VTK(No Category)public2006-10-13 17:342013-04-05 20:18
ReporterSean McInerney 
Assigned ToBerk Geveci 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0003941: vtkImageData DeepCopy and ShallowCopy incomplete.
DescriptionvtkImageData::InternalImageDataCopy does not copy SPACING and ORIGIN pipeline information entries. These entries should be copied as other enties (e.g. WHOLE_EXTENT) are in the vtkDataObject subclass method.
TagsNo tags attached.
Project
Type
Attached Files

 Relationships

  Notes
(0010321)
Xenophon Papademetris (reporter)
2008-01-28 23:52

This is a critical bug for us at BioImage Suite (www.bioimagesuite.org) where ShallowCopy is used multiple times. The problem is naturally most acute within the Registration pipeline where image spacing and origin change frequently ....

A potential solution is below, it was also posted on vtk-developers

Feel free to contact me directly if you need more information, scripts to replicate this etc.






//--------------------------------------------------------------------------
--

// This copies all the local variables (but not objects).

void vtkImageData::InternalImageDataCopy(vtkImageData *src)

{
  int idx;

  this->DataDescription = src->DataDescription;
  this->SetScalarType(src->GetScalarType());
  this->SetNumberOfScalarComponents(src->GetNumberOfScalarComponents());

  for (idx = 0; idx < 3; ++idx)
    {
    this->Dimensions[idx] = src->Dimensions[idx];
    this->Increments[idx] = src->Increments[idx];
    this->Origin[idx] = src->Origin[idx];
    this->Spacing[idx] = src->Spacing[idx];
    }

  memcpy(this->Extent, src->GetExtent(), 6*sizeof(int));


  // Additions (XP)

  if (this->Information->Has(SPACING()))
this->Information->Set(SPACING(),this->Spacing[0],this->Spacing[1],this->Spa
cing[2]);

   if (this->PipelineInformation->Has(SPACING()))
    this->PipelineInformation->Set(SPACING(),this->Spacing[0],this->Spacing[1],t
his->Spacing[2]);

   if (this->Information->Has(ORIGIN()))
this->Information->Set(ORIGIN(),this->Origin[0],this->Origin[1],this->Origin
[2]);

  if (this->PipelineInformation->Has(ORIGIN()))
this->PipelineInformation->Set(ORIGIN(),this->Origin[0],this->Origin[1],this
->Origin[2]);

  // End of Additions
(0019985)
David Partyka (developer)
2010-03-23 11:10

An alternative patch from Dominique Belhachemi <domibel@cs.tu-berlin.de>.

Index: Filtering/vtkTrivialProducer.cxx
===================================================================
RCS file: /cvsroot/VTK/VTK/Filtering/vtkTrivialProducer.cxx,v
retrieving revision 1.13
diff -u -r1.13 vtkTrivialProducer.cxx
--- Filtering/vtkTrivialProducer.cxx 18 Dec 2008 16:55:39 -0000 1.13
+++ Filtering/vtkTrivialProducer.cxx 17 Mar 2010 15:36:21 -0000
@@ -20,6 +20,7 @@
 #include "vtkInformation.h"
 #include "vtkInformationVector.h"
 #include "vtkObjectFactory.h"
+#include "vtkDataObject.h"
 
 vtkCxxRevisionMacro(vtkTrivialProducer, "$Revision: 1.13 $");
 vtkStandardNewMacro(vtkTrivialProducer);
@@ -115,6 +116,27 @@
                                    vtkInformationVector** inputVector,
                                    vtkInformationVector* outputVector)
 {
+ if (this->Output->IsA("vtkImageData"))
+ {
+ vtkImageData* img=(vtkImageData*)(this->Output);
+
+ vtkInformation* info = img->GetInformation();
+ vtkInformation* pinfo = img->GetPipelineInformation();
+ double Spacing[3]; img->GetSpacing(Spacing);
+ double Origin[3]; img->GetOrigin(Origin);
+
+ if (info->Has(vtkDataObject::SPACING()))
+ info->Set(vtkDataObject::SPACING(),Spacing[0],Spacing[1],Spacing[2]);
+
+ if (pinfo->Has(vtkDataObject::SPACING()))
+ pinfo->Set(vtkDataObject::SPACING(),Spacing[0],Spacing[1],Spacing[2]);
+
+ if (info->Has(vtkDataObject::ORIGIN()))
+ info->Set(vtkDataObject::ORIGIN(),Origin[0],Origin[1],Origin[2]);
+
+ if (pinfo->Has(vtkDataObject::ORIGIN()))
+ pinfo->Set(vtkDataObject::ORIGIN(),Origin[0],Origin[1],Origin[2]);
+ }
   if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION()) &&
      this->Output)
     {
(0019987)
David Partyka (developer)
2010-03-23 15:55

Fix by the following patch from Berk:

diff --git a/VTK/Filtering/vtkTrivialProducer.cxx b/VTK/Filtering/vtkTrivialProducer.cxx
index 10c20bf..80881bb 100644
--- a/VTK/Filtering/vtkTrivialProducer.cxx
+++ b/VTK/Filtering/vtkTrivialProducer.cxx
@@ -20,6 +20,7 @@
 #include "vtkInformation.h"
 #include "vtkInformationVector.h"
 #include "vtkObjectFactory.h"
+#include "vtkDataObject.h"
 
 vtkCxxRevisionMacro(vtkTrivialProducer, "$Revision$");
 vtkStandardNewMacro(vtkTrivialProducer);
@@ -148,6 +149,20 @@ vtkTrivialProducer::ProcessRequest(vtkInformation* request,
       outputInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
                       timeRange, 2);
       }
+
+ if (this->Output->IsA("vtkImageData"))
+ {
+ vtkImageData* img = static_cast<vtkImageData*>(this->Output);
+ vtkInformation* pinfo = img->GetPipelineInformation();
+
+ double spacing[3];
+ img->GetSpacing(spacing);
+ pinfo->Set(vtkDataObject::SPACING(), spacing[0], spacing[1], spacing[2]);
+
+ double origin[3];
+ img->GetOrigin(origin);
+ pinfo->Set(vtkDataObject::ORIGIN(), origin[0], origin[1], origin[2]);
+ }
     }
 #if VTK_TRIVIAL_PRODUCER_CHECK_UPDATE_EXTENT
   if(request->Has(vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT()))

Committed:

Committer: Dave Partyka <dave.partyka@kitware.com>
/cvsroot/ParaView3/ParaView3/VTK/Filtering/vtkTrivialProducer.cxx,v <-- Filtering/vtkTrivialProducer.cxx
new revision: 1.14; previous revision: 1.13

 Issue History
Date Modified Username Field Change
2008-01-28 23:52 Xenophon Papademetris Note Added: 0010321
2008-02-06 09:32 Jeff Baumes Assigned To Will Schroeder => Berk Geveci
2010-03-23 11:10 David Partyka Note Added: 0019985
2010-03-23 15:55 David Partyka Note Added: 0019987
2010-03-23 15:55 David Partyka Status tabled => @80@
2010-03-23 15:55 David Partyka Resolution open => fixed
2011-01-13 17:00 Source_changeset_attached => VTK master a2bd8391
2011-01-13 17:00 Source_changeset_attached => VTK master 020ef709
2011-06-16 13:11 Zack Galbreath Category => (No Category)
2013-04-05 20:18 Berk Geveci Status customer review => closed


Copyright © 2000 - 2018 MantisBT Team