Skip to content
Snippets Groups Projects
Commit aaaf38ff authored by Eric Stanton's avatar Eric Stanton
Browse files

BUG: Fix failing DelimitedTextReader test. Make pedigree id assignment optional.

parent 7f4a4b52
No related branches found
No related tags found
No related merge requests found
......@@ -41,7 +41,7 @@
#include <ctype.h>
vtkCxxRevisionMacro(vtkDelimitedTextReader, "1.27");
vtkCxxRevisionMacro(vtkDelimitedTextReader, "1.28");
vtkStandardNewMacro(vtkDelimitedTextReader);
struct vtkDelimitedTextReaderInternals
......@@ -101,6 +101,7 @@ vtkDelimitedTextReader::vtkDelimitedTextReader()
this->PedigreeIdArrayName = NULL;
this->SetPedigreeIdArrayName("id");
this->GeneratePedigreeIds = true;
this->OutputPedigreeIds = false;
}
......@@ -357,32 +358,35 @@ int vtkDelimitedTextReader::RequestData(
dataArray->Delete();
}
if (this->GeneratePedigreeIds)
if(this->OutputPedigreeIds)
{
vtkSmartPointer<vtkIdTypeArray> pedigreeIds =
vtkSmartPointer<vtkIdTypeArray>::New();
vtkIdType numRows = table->GetNumberOfRows();
pedigreeIds->SetNumberOfTuples(numRows);
pedigreeIds->SetName(this->PedigreeIdArrayName);
for (vtkIdType i = 0; i < numRows; ++i)
if (this->GeneratePedigreeIds)
{
pedigreeIds->InsertValue(i, i);
}
table->GetRowData()->SetPedigreeIds(pedigreeIds);
}
else
{
vtkAbstractArray* arr =
table->GetColumnByName(this->PedigreeIdArrayName);
if (arr)
{
table->GetRowData()->SetPedigreeIds(arr);
vtkSmartPointer<vtkIdTypeArray> pedigreeIds =
vtkSmartPointer<vtkIdTypeArray>::New();
vtkIdType numRows = table->GetNumberOfRows();
pedigreeIds->SetNumberOfTuples(numRows);
pedigreeIds->SetName(this->PedigreeIdArrayName);
for (vtkIdType i = 0; i < numRows; ++i)
{
pedigreeIds->InsertValue(i, i);
}
table->GetRowData()->SetPedigreeIds(pedigreeIds);
}
else
{
vtkErrorMacro(<< "Could find pedigree id array: "
<< this->PedigreeIdArrayName);
return 0;
vtkAbstractArray* arr =
table->GetColumnByName(this->PedigreeIdArrayName);
if (arr)
{
table->GetRowData()->SetPedigreeIds(arr);
}
else
{
vtkErrorMacro(<< "Could find pedigree id array: "
<< this->PedigreeIdArrayName);
return 0;
}
}
}
......
......@@ -121,6 +121,12 @@ public:
vtkGetMacro(GeneratePedigreeIds, bool);
vtkBooleanMacro(GeneratePedigreeIds, bool);
// Description:
// If on, assigns pedigree ids to output. Defaults to off.
vtkSetMacro(OutputPedigreeIds, bool);
vtkGetMacro(OutputPedigreeIds, bool);
vtkBooleanMacro(OutputPedigreeIds, bool);
protected:
vtkDelimitedTextReader();
~vtkDelimitedTextReader();
......@@ -145,6 +151,7 @@ public:
bool DetectNumericColumns;
char* PedigreeIdArrayName;
bool GeneratePedigreeIds;
bool OutputPedigreeIds;
private:
vtkDelimitedTextReader(const vtkDelimitedTextReader&); // Not implemented
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment