Attached Files | Partial.BUG.9252.patch [^] (15,219 bytes) 2009-09-28 09:24 [Show Content] [Hide Content]? VTK/Filtering/vtkFieldList.h
? VTK/Graphics/vtkTableToImage.cxx
? VTK/Graphics/vtkTableToImage.h
? VTK/Graphics/vtkTableToImageData.cxx
? VTK/Graphics/vtkTableToImageData.h
Index: VTK/Filtering/vtkDataSetAttributes.cxx
===================================================================
RCS file: /cvsroot/ParaView3/ParaView3/VTK/Filtering/vtkDataSetAttributes.cxx,v
retrieving revision 1.30
diff -u -3 -p -r1.30 vtkDataSetAttributes.cxx
--- VTK/Filtering/vtkDataSetAttributes.cxx 9 Oct 2008 16:27:50 -0000 1.30
+++ VTK/Filtering/vtkDataSetAttributes.cxx 28 Sep 2009 13:24:02 -0000
@@ -1504,6 +1504,7 @@ void vtkDataSetAttributes::InternalCopyA
newDA->SetLookupTable(list.LUT[i]);
}
+
// If attribute data, do something extra
if ( i < NUM_ATTRIBUTES )
{
@@ -1551,7 +1552,7 @@ void vtkDataSetAttributes::CopyData(vtkD
int i;
for (i=0; i < list.NumberOfFields; i++)
{
- if ( list.FieldIndices[i] >= 0 )
+ if ( list.FieldIndices[i] >= 0 && list.DSAIndices[idx][i] >= 0 )
{
toDA = this->GetAbstractArray(list.FieldIndices[i]);
fromDA = fromDSA->GetAbstractArray(list.DSAIndices[idx][i]);
@@ -1575,7 +1576,7 @@ void vtkDataSetAttributes::InterpolatePo
for (int i=0; i < list.NumberOfFields; i++)
{
- if ( list.FieldIndices[i] >= 0 )
+ if ( list.FieldIndices[i] >= 0 && list.DSAIndices[idx][i] >= 0 )
{
toArray = this->GetAbstractArray(list.FieldIndices[i]);
fromArray = fromPd->GetAbstractArray(list.DSAIndices[idx][i]);
@@ -1646,7 +1647,7 @@ vtkDataSetAttributes::FieldList::~FieldL
void vtkDataSetAttributes::FieldList::InitializeFieldList(
vtkDataSetAttributes* dsa)
{
- int i, idx;
+ int i;
this->ClearFields();
// Allocate space for the arrays plus five attributes
this->NumberOfFields = dsa->GetNumberOfArrays() + NUM_ATTRIBUTES;
@@ -1671,10 +1672,11 @@ void vtkDataSetAttributes::FieldList::In
//there may be no data hence dsa->Data
for(i=0; dsa->Data && i < dsa->GetNumberOfArrays(); i++)
{
- if ( (idx=dsa->IsArrayAnAttribute(i)) != -1 ) //it's an attribute
+ int attrType = dsa->IsArrayAnAttribute(i);
+ if ( attrType != -1 ) //it's an attribute
{
- this->FieldIndices[idx] = idx;
- this->SetField(idx, dsa->Data[i]);
+ this->FieldIndices[attrType] = i;
+ this->SetField(attrType, dsa->Data[i]);
}
else
{
@@ -1688,6 +1690,214 @@ void vtkDataSetAttributes::FieldList::In
}
//--------------------------------------------------------------------------
+void vtkDataSetAttributes::FieldList::UnionFieldList(vtkDataSetAttributes* dsa)
+{
+ vtkAbstractArray* aa;
+ vtkDataArray* da;
+ // Keep a running total of the number of tuples...might be useful
+ // for later allocation.
+ if ( (aa=dsa->GetAbstractArray(0)) )
+ {
+ this->NumberOfTuples += aa->GetNumberOfTuples();
+ }
+
+ // unlike Intersection, with Union the the total number of fields may change,
+ // so we have to be careful with that.
+ vtkstd::vector<int> dsaIndices;
+ dsaIndices.resize(this->NumberOfFields, -1);
+
+ // Intersect the active attributes. (Even though we are taking a union, we
+ // intersect the active attributes).
+ int attributeIndices[NUM_ATTRIBUTES];
+ dsa->GetAttributeIndices(attributeIndices);
+ for (int i=0; i < NUM_ATTRIBUTES; i++)
+ {
+ if (this->FieldIndices[i] >= 0)
+ {
+ da = dsa->GetAttribute(i);
+ if ((da) && (da->GetDataType() == this->FieldTypes[i]) &&
+ (da->GetNumberOfComponents() == this->FieldComponents[i]))
+ {
+ dsaIndices[i] = attributeIndices[i];
+ }
+ else
+ {
+ // doh! A attribute is not available in this new dsa. But it was
+ // available until now.
+
+ // In InitializeFieldList(), if an array is an active attribute, its
+ // information is noted only in the first "set". Now since we are
+ // marking it as not-an-attribute, we still don't want to loose the
+ // array. So we enable it in the second "set". But all DSAIndices until
+ // the CurrentInput referred to this array in it's location in the
+ // first "set" so we have to move those as well. That's what's
+ // happening here.
+ this->FieldIndices[NUM_ATTRIBUTES + this->FieldIndices[i]] =
+ this->FieldIndices[i];
+ this->Fields[i+NUM_ATTRIBUTES] = this->Fields[i];
+ this->FieldTypes[i+NUM_ATTRIBUTES] = this->FieldTypes[i];
+ this->FieldComponents[i+NUM_ATTRIBUTES] = this->FieldComponents[i];
+ this->LUT[i+NUM_ATTRIBUTES] = this->LUT[i];
+ this->FieldInformation[i+NUM_ATTRIBUTES] = this->FieldInformation[i];
+
+ this->FieldIndices[i] = -1; //Attribute not present
+ this->Fields[i] = NULL;
+ this->FieldTypes[i] = -1;
+ this->FieldComponents[i] = 0;
+ this->LUT[i] = NULL;
+ this->FieldInformation[i] = NULL;
+
+ for (int cc=0; cc < this->CurrentInput && cc < this->NumberOfDSAIndices;
+ cc++)
+ {
+ this->DSAIndices[cc][i+NUM_ATTRIBUTES] = this->DSAIndices[cc][i];
+ this->DSAIndices[cc][i] = -1;
+ }
+ }
+ }
+ }
+
+ vtkstd::vector<bool> dsaMarkedArrays;
+ dsaMarkedArrays.resize(dsa->GetNumberOfArrays(), false);
+
+ // * Try to match the existing fields with those in dsa.
+ for (int i = NUM_ATTRIBUTES; i < this->NumberOfFields; i++)
+ {
+ // FieldIndices should really be a bool.
+ if (this->FieldIndices[i] < 0)
+ {
+ continue;
+ }
+ int index;
+ aa = dsa->GetAbstractArray(this->Fields[i], index);
+ if ((aa) && (aa->GetDataType() == this->FieldTypes[i]) &&
+ (aa->GetNumberOfComponents() == this->FieldComponents[i]))
+ {
+ dsaIndices[i] = index;
+ dsaMarkedArrays[index] = true;
+ }
+ }
+
+ // * Now every array in dsaMarkedArrays that has a false, implies that it did not
+ // match with any of the existing fields. So those will be appended to the
+ // end of the field list.
+ vtkstd::vector<int> dsaPendingIndices;
+ for (size_t cc=0; cc < dsaMarkedArrays.size(); cc++)
+ {
+ if (dsaMarkedArrays[cc] == false)
+ {
+ dsaPendingIndices.push_back(static_cast<int>(cc));
+ }
+ }
+
+ if (dsaPendingIndices.size() != 0)
+ {
+ size_t old_size = dsaIndices.size();
+ size_t new_size = old_size + dsaPendingIndices.size();
+
+ // * If dsaPendingIndices != empty, then we need to grow the num of fields.
+ this->GrowBy(static_cast<unsigned int>(dsaPendingIndices.size()));
+
+ dsaIndices.resize(new_size, -1);
+ for (size_t cc=0; cc < dsaPendingIndices.size(); cc++)
+ {
+ this->FieldIndices[old_size+cc] = (old_size+cc) - NUM_ATTRIBUTES;
+ this->SetField(old_size+cc, dsa->GetAbstractArray(dsaPendingIndices[cc]));
+ dsaIndices[old_size + cc] = dsaPendingIndices[cc];
+ }
+ }
+
+ this->DSAIndices[this->CurrentInput] = new int [this->NumberOfFields];
+ memcpy(this->DSAIndices[this->CurrentInput], &dsaIndices[0],
+ sizeof(int)*this->NumberOfFields);
+
+ this->CurrentInput++;
+}
+
+//--------------------------------------------------------------------------
+void vtkDataSetAttributes::FieldList::GrowBy(unsigned int delta)
+{
+ if (delta == 0)
+ {
+ return;
+ }
+
+ int old_size = this->NumberOfFields;
+ int new_size = this->NumberOfFields + delta;
+
+ char** newFields = new char*[new_size];
+ int* newFieldTypes = new int[new_size];
+ int* newFieldComponents = new int [new_size];
+ int* newFieldIndices = new int [new_size];
+ vtkLookupTable** newLUT = new vtkLookupTable* [new_size];
+ vtkInformation** newFieldInformation = new vtkInformation* [new_size];
+
+ // copy the old fields.
+ for(int i=0; i < old_size; i++)
+ {
+ if (this->Fields[i])
+ {
+ newFields[i] = strdup(this->Fields[i]);
+ }
+ else
+ {
+ newFields[i] = NULL;
+ }
+ }
+ memcpy(newFieldTypes, this->FieldTypes, sizeof(int)*old_size);
+ memcpy(newFieldComponents, this->FieldComponents, sizeof(int)*old_size);
+ memcpy(newFieldIndices, this->FieldIndices, sizeof(int)*old_size);
+ memcpy(newLUT, this->LUT, sizeof(vtkLookupTable*)*old_size);
+ memcpy(newFieldInformation, this->FieldInformation,
+ sizeof(vtkInformation*)*old_size);
+
+ // initialize the rest.
+ for (int i=old_size; i < new_size; i++)
+ {
+ newFields[i] = NULL;
+ newFieldTypes[i] = -1;
+ newFieldComponents[i] = 0;
+ newFieldIndices[i] = -1;
+ newLUT[i] = NULL;
+ newFieldInformation[i] = NULL;
+ }
+
+ int **newDSAIndices = new int*[this->NumberOfDSAIndices];
+ for (int cc=0; cc < this->NumberOfDSAIndices; cc++)
+ {
+ if (this->DSAIndices[cc] != NULL)
+ {
+ newDSAIndices[cc] = new int[new_size];
+ memcpy(newDSAIndices[cc], this->DSAIndices[cc], sizeof(int)*old_size);
+ for (int kk=old_size; kk < new_size; kk++)
+ {
+ newDSAIndices[cc][kk] = -1;
+ }
+ }
+ else
+ {
+ newDSAIndices[cc] = NULL;
+ }
+ }
+
+ int currentInput = this->CurrentInput;
+ int numberOfDSAIndices = this->NumberOfDSAIndices;
+
+ this->ClearFields();
+
+ this->NumberOfFields = new_size;
+ this->NumberOfDSAIndices = numberOfDSAIndices;
+ this->CurrentInput = currentInput;
+ this->Fields = newFields;
+ this->FieldTypes = newFieldTypes;
+ this->FieldComponents = newFieldComponents;
+ this->FieldIndices = newFieldIndices;
+ this->LUT = newLUT;
+ this->FieldInformation = newFieldInformation;
+ this->DSAIndices = newDSAIndices;
+}
+
+//--------------------------------------------------------------------------
void vtkDataSetAttributes::FieldList::IntersectFieldList(vtkDataSetAttributes* dsa)
{
int i;
Index: VTK/Filtering/vtkDataSetAttributes.h
===================================================================
RCS file: /cvsroot/ParaView3/ParaView3/VTK/Filtering/vtkDataSetAttributes.h,v
retrieving revision 1.13
diff -u -3 -p -r1.13 vtkDataSetAttributes.h
--- VTK/Filtering/vtkDataSetAttributes.h 11 Jun 2009 19:16:48 -0000 1.13
+++ VTK/Filtering/vtkDataSetAttributes.h 28 Sep 2009 13:24:02 -0000
@@ -607,6 +607,7 @@ public:
void InitializeFieldList(vtkDataSetAttributes* dsa);
void IntersectFieldList(vtkDataSetAttributes* dsa);
+ void UnionFieldList(vtkDataSetAttributes* dsa);
//Determine whether data is available
int IsAttributePresent(int attrType); //true/false attributes specified
@@ -630,6 +631,7 @@ public:
void SetField(int index, vtkAbstractArray *da);
void RemoveField(const char *name);
void ClearFields();
+ void GrowBy(unsigned int delta);
int NumberOfFields; //the number of fields (including five named attributes)
// These keep track of what is common across datasets. The first
Index: VTK/Graphics/vtkCompositeDataProbeFilter.cxx
===================================================================
RCS file: /cvsroot/ParaView3/ParaView3/VTK/Graphics/vtkCompositeDataProbeFilter.cxx,v
retrieving revision 1.2
diff -u -3 -p -r1.2 vtkCompositeDataProbeFilter.cxx
--- VTK/Graphics/vtkCompositeDataProbeFilter.cxx 2 Sep 2008 13:13:11 -0000 1.2
+++ VTK/Graphics/vtkCompositeDataProbeFilter.cxx 28 Sep 2009 13:24:02 -0000
@@ -132,6 +132,11 @@ int vtkCompositeDataProbeFilter::Request
return 1;
}
+//----------------------------------------------------------------------------
+void vtkCompositeDataProbeFilter::InitializeForProbing(vtkDataSet *input, vtkDataSet *output)
+{
+ this->Superclass::InitializeForProbing(input, output);
+}
//----------------------------------------------------------------------------
int vtkCompositeDataProbeFilter::BuildFieldList(vtkCompositeDataSet* source)
@@ -182,7 +187,7 @@ int vtkCompositeDataProbeFilter::BuildFi
}
else
{
- this->PointList->IntersectFieldList(sourceDS->GetPointData());
+ this->PointList->UnionFieldList(sourceDS->GetPointData());
}
if (sourceDS->GetNumberOfCells() > 0)
@@ -194,10 +199,11 @@ int vtkCompositeDataProbeFilter::BuildFi
}
else
{
- this->CellList->IntersectFieldList(sourceDS->GetCellData());
+ this->CellList->UnionFieldList(sourceDS->GetCellData());
}
}
}
+ this->PointList->PrintSelf(cout, vtkIndent());
return 1;
}
Index: VTK/Graphics/vtkCompositeDataProbeFilter.h
===================================================================
RCS file: /cvsroot/ParaView3/ParaView3/VTK/Graphics/vtkCompositeDataProbeFilter.h,v
retrieving revision 1.2
diff -u -3 -p -r1.2 vtkCompositeDataProbeFilter.h
--- VTK/Graphics/vtkCompositeDataProbeFilter.h 2 Sep 2008 13:13:11 -0000 1.2
+++ VTK/Graphics/vtkCompositeDataProbeFilter.h 28 Sep 2009 13:24:02 -0000
@@ -48,6 +48,10 @@ protected:
int BuildFieldList(vtkCompositeDataSet* source);
// Description:
+ // Initializes output and various arrays which keep track for probing status.
+ virtual void InitializeForProbing(vtkDataSet *input, vtkDataSet *output);
+
+ // Description:
// Handle composite input.
virtual int RequestData(vtkInformation *,
vtkInformationVector **, vtkInformationVector *);
Index: VTK/Graphics/vtkProbeFilter.cxx
===================================================================
RCS file: /cvsroot/ParaView3/ParaView3/VTK/Graphics/vtkProbeFilter.cxx,v
retrieving revision 1.96
diff -u -3 -p -r1.96 vtkProbeFilter.cxx
--- VTK/Graphics/vtkProbeFilter.cxx 6 Oct 2008 17:50:53 -0000 1.96
+++ VTK/Graphics/vtkProbeFilter.cxx 28 Sep 2009 13:24:02 -0000
@@ -21,6 +21,7 @@
#include "vtkImageData.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
+#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkStreamingDemandDrivenPipeline.h"
@@ -180,6 +181,26 @@ void vtkProbeFilter::InitializeForProbin
}
tempCellData->Delete();
+ outPD->SetNumberOfTuples(numPts);
+
+ // Initialize the arrays.
+ for (int cc=0; cc < outPD->GetNumberOfArrays(); cc++)
+ {
+ vtkDataArray* da = outPD->GetArray(cc);
+ if (da)
+ {
+ double null_value = 0.0;
+ if (da->IsA("vtkDoubleArray") || da->IsA("vtkFloatArray"))
+ {
+ null_value = vtkMath::Nan();
+ }
+ for (int kk=0; kk < da->GetNumberOfComponents(); kk++)
+ {
+ da->FillComponent(kk, null_value);
+ }
+ }
+ }
+
outPD->AddArray(this->MaskPoints);
// BUG FIX: JB.
Index: VTK/Graphics/vtkProbeFilter.h
===================================================================
RCS file: /cvsroot/ParaView3/ParaView3/VTK/Graphics/vtkProbeFilter.h,v
retrieving revision 1.56
diff -u -3 -p -r1.56 vtkProbeFilter.h
--- VTK/Graphics/vtkProbeFilter.h 2 Sep 2008 13:13:11 -0000 1.56
+++ VTK/Graphics/vtkProbeFilter.h 28 Sep 2009 13:24:02 -0000
@@ -110,7 +110,7 @@ protected:
// Description:
// Initializes output and various arrays which keep track for probing status.
- void InitializeForProbing(vtkDataSet *input, vtkDataSet *output);
+ virtual void InitializeForProbing(vtkDataSet *input, vtkDataSet *output);
// Description:
// Probe only those points that are marked as not-probed by the MaskPoints
|