Commit 28006e86 authored by Michael Migliore's avatar Michael Migliore Committed by Mathieu Westphal

Improve importer description to include field data

parent 326814fb
......@@ -13,8 +13,8 @@
=========================================================================*/
#include "vtkImporter.h"
#include "vtkAbstractArray.h"
#include "vtkCellData.h"
#include "vtkDataArray.h"
#include "vtkDataSet.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
......@@ -114,7 +114,7 @@ void vtkImporter::PrintSelf(ostream& os, vtkIndent indent)
}
//----------------------------------------------------------------------------
std::string vtkImporter::GetArrayDescription(vtkDataArray* array, vtkIndent indent)
std::string vtkImporter::GetArrayDescription(vtkAbstractArray* array, vtkIndent indent)
{
std::stringstream ss;
ss << indent;
......@@ -124,12 +124,29 @@ std::string vtkImporter::GetArrayDescription(vtkDataArray* array, vtkIndent inde
}
ss << array->GetDataTypeAsString() << " : ";
int nComp = array->GetNumberOfComponents();
double range[2];
for (int j = 0; j < nComp; j++)
vtkIdType nbTuples = array->GetNumberOfTuples();
if (nbTuples == 1)
{
ss << array->GetVariantValue(0).ToString();
}
else
{
array->GetRange(range, j);
ss << "[" << range[0] << ", " << range[1] << "] ";
int nComp = array->GetNumberOfComponents();
double range[2];
for (int j = 0; j < nComp; j++)
{
vtkDataArray* dataArray = vtkDataArray::SafeDownCast(array);
if (dataArray)
{
dataArray->GetRange(range, j);
ss << "[" << range[0] << ", " << range[1] << "] ";
}
else
{
ss << "[range unavailable] ";
}
}
}
ss << "\n";
return ss.str();
......@@ -155,22 +172,35 @@ std::string vtkImporter::GetDataSetDescription(vtkDataSet* ds, vtkIndent indent)
vtkPointData* pointData = ds->GetPointData();
vtkCellData* cellData = ds->GetCellData();
vtkFieldData* fieldData = ds->GetFieldData();
int nbPointData = pointData->GetNumberOfArrays();
int nbCellData = cellData->GetNumberOfArrays();
int nbFieldData = fieldData->GetNumberOfArrays();
ss << indent << nbPointData << " point data array(s):\n";
for (vtkIdType i = 0; i < nbPointData; i++)
{
vtkDataArray* array = pointData->GetArray(i);
vtkAbstractArray* array = pointData->GetAbstractArray(i);
ss << vtkImporter::GetArrayDescription(array, indent.GetNextIndent());
}
ss << indent << nbCellData << " cell data array(s):\n";
for (vtkIdType i = 0; i < nbCellData; i++)
{
vtkDataArray* array = cellData->GetArray(i);
vtkAbstractArray* array = cellData->GetAbstractArray(i);
ss << vtkImporter::GetArrayDescription(array, indent.GetNextIndent());
}
ss << indent << nbFieldData << " field data array(s):\n";
for (vtkIdType i = 0; i < nbFieldData; i++)
{
vtkAbstractArray* array = fieldData->GetAbstractArray(i);
if (array)
{
ss << vtkImporter::GetArrayDescription(array, indent.GetNextIndent());
}
}
return ss.str();
}
......
......@@ -50,7 +50,7 @@
#include <string>
class vtkDataArray;
class vtkAbstractArray;
class vtkDataSet;
class vtkDoubleArray;
class vtkRenderWindow;
......@@ -144,7 +144,7 @@ protected:
virtual void ImportProperties(vtkRenderer*) {}
static std::string GetDataSetDescription(vtkDataSet* ds, vtkIndent indent);
static std::string GetArrayDescription(vtkDataArray* array, vtkIndent indent);
static std::string GetArrayDescription(vtkAbstractArray* array, vtkIndent indent);
vtkRenderer* Renderer;
vtkRenderWindow* RenderWindow;
......
......@@ -31,6 +31,7 @@
=======================================================================*/
#include "vtkVRMLImporter.h"
#include "vtkAbstractArray.h"
#include "vtkActor.h"
#include "vtkCellArray.h"
#include "vtkConeSource.h"
......@@ -1400,7 +1401,7 @@ std::string vtkVRMLImporter::GetOutputsDescription()
{
vtkObject* obj = this->Internal->Heap.Get(i);
vtkPoints* points = vtkPoints::SafeDownCast(obj);
vtkDataArray* array = vtkDataArray::SafeDownCast(obj);
vtkAbstractArray* array = vtkAbstractArray::SafeDownCast(obj);
if (points)
{
ss << "Points with " << points->GetNumberOfPoints() << " points\n";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment