Commit e52cd893 authored by Mathieu Malaterre's avatar Mathieu Malaterre

ENH: Fix initialization of NumberOfCells + minor cells

parent 956e9fa9
......@@ -22,7 +22,7 @@
#include "vtkObjectFactory.h"
#include "vtkXMLDataElement.h"
vtkCxxRevisionMacro(vtkXMLDataParser, "1.25");
vtkCxxRevisionMacro(vtkXMLDataParser, "1.26");
vtkStandardNewMacro(vtkXMLDataParser);
vtkCxxSetObjectMacro(vtkXMLDataParser, Compressor, vtkDataCompressor);
......@@ -505,9 +505,14 @@ int vtkXMLDataParser::ReadBlock(unsigned int block, unsigned char* buffer)
unsigned int compressedSize = this->BlockCompressedSizes[block];
unsigned char* readBuffer = new unsigned char[compressedSize];
if(!this->DataStream->Seek(this->BlockStartOffsets[block])) { return 0; }
if(!this->DataStream->Seek(this->BlockStartOffsets[block]))
{
return 0;
}
if(this->DataStream->Read(readBuffer, compressedSize) < compressedSize)
{ return 0; }
{
return 0;
}
unsigned long result =
this->Compressor->Uncompress(readBuffer, compressedSize,
......@@ -553,9 +558,15 @@ unsigned long vtkXMLDataParser::ReadUncompressedData(unsigned char* data,
unsigned long length = numWords*wordSize;
// Make sure the begin/end offsets fall within total size.
if(offset > size) { return 0; }
if(offset > size)
{
return 0;
}
unsigned long end = offset+length;
if(end > size) { end = size; }
if(end > size)
{
end = size;
}
length = end-offset;
// Read the data.
......@@ -706,7 +717,10 @@ unsigned long vtkXMLDataParser::ReadCompressedData(unsigned char* data,
if(endBlockOffset > 0 && !this->Abort)
{
blockBuffer = this->ReadBlock(lastBlock);
if(!blockBuffer) { return 0; }
if(!blockBuffer)
{
return 0;
}
memcpy(outputPointer, blockBuffer, endBlockOffset);
delete [] blockBuffer;
......
......@@ -23,7 +23,7 @@
#include "vtkInformation.h"
#include "vtkStreamingDemandDrivenPipeline.h"
vtkCxxRevisionMacro(vtkXMLUnstructuredDataReader, "1.18");
vtkCxxRevisionMacro(vtkXMLUnstructuredDataReader, "1.19");
//----------------------------------------------------------------------------
vtkXMLUnstructuredDataReader::vtkXMLUnstructuredDataReader()
......@@ -37,7 +37,10 @@ vtkXMLUnstructuredDataReader::vtkXMLUnstructuredDataReader()
//----------------------------------------------------------------------------
vtkXMLUnstructuredDataReader::~vtkXMLUnstructuredDataReader()
{
if(this->NumberOfPieces) { this->DestroyPieces(); }
if(this->NumberOfPieces)
{
this->DestroyPieces();
}
}
//----------------------------------------------------------------------------
......
......@@ -23,7 +23,7 @@
#include "vtkInformation.h"
#include "vtkStreamingDemandDrivenPipeline.h"
vtkCxxRevisionMacro(vtkXMLUnstructuredGridReader, "1.8");
vtkCxxRevisionMacro(vtkXMLUnstructuredGridReader, "1.9");
vtkStandardNewMacro(vtkXMLUnstructuredGridReader);
//----------------------------------------------------------------------------
......@@ -38,13 +38,16 @@ vtkXMLUnstructuredGridReader::vtkXMLUnstructuredGridReader()
output->Delete();
this->CellElements = 0;
this->TotalNumberOfCells = 0;
this->NumberOfCells = 0;
}
//----------------------------------------------------------------------------
vtkXMLUnstructuredGridReader::~vtkXMLUnstructuredGridReader()
{
if(this->NumberOfPieces) { this->DestroyPieces(); }
if(this->NumberOfPieces)
{
this->DestroyPieces();
}
}
//----------------------------------------------------------------------------
......@@ -153,7 +156,10 @@ void vtkXMLUnstructuredGridReader::SetupOutputData()
//----------------------------------------------------------------------------
int vtkXMLUnstructuredGridReader::ReadPiece(vtkXMLDataElement* ePiece)
{
if(!this->Superclass::ReadPiece(ePiece)) { return 0; }
if(!this->Superclass::ReadPiece(ePiece))
{
return 0;
}
int i;
if(!ePiece->GetScalarAttribute("NumberOfCells",
......@@ -232,7 +238,10 @@ int vtkXMLUnstructuredGridReader::ReadPieceData()
this->SetProgressRange(progressRange, 0, fractions);
// Let the superclass read its data.
if(!this->Superclass::ReadPieceData()) { return 0; }
if(!this->Superclass::ReadPieceData())
{
return 0;
}
vtkUnstructuredGrid* output = this->GetOutput();
......@@ -271,7 +280,7 @@ int vtkXMLUnstructuredGridReader::ReadPieceData()
// Set the range of progress for the cell types.
this->SetProgressRange(progressRange, 2, fractions);
// Read the cooresponding cell types.
// Read the corresponding cell types.
vtkIdType numberOfCells = this->NumberOfCells[this->Piece];
vtkXMLDataElement* eCells = this->CellElements[this->Piece];
vtkXMLDataElement* eTypes = this->FindDataArrayWithName(eCells, "types");
......@@ -331,8 +340,9 @@ int vtkXMLUnstructuredGridReader::ReadArrayForCells(vtkXMLDataElement* da,
}
//----------------------------------------------------------------------------
int vtkXMLUnstructuredGridReader::FillOutputPortInformation(int, vtkInformation *info)
{
{
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkUnstructuredGrid");
return 1;
}
}
......@@ -37,7 +37,7 @@
# include <io.h> /* unlink */
#endif
vtkCxxRevisionMacro(vtkXMLWriter, "1.41");
vtkCxxRevisionMacro(vtkXMLWriter, "1.42");
vtkCxxSetObjectMacro(vtkXMLWriter, Compressor, vtkDataCompressor);
//----------------------------------------------------------------------------
......@@ -568,7 +568,7 @@ unsigned long vtkXMLWriter::ReserveAttributeSpace(const char* attr)
// Write enough space to go back and write the given attribute with
// an appended data offset value. Returns the stream position at
// which attribute should be later written with
// WriteAppendedDataOffset(). If attr is 0, writes space only for
// WriteAppendedDataOffset(). If attr is 0, writes space only for
// the double quotes and value.
ostream& os = *(this->Stream);
unsigned long startPosition = os.tellp();
......@@ -606,7 +606,10 @@ unsigned long vtkXMLWriter::WriteAppendedDataOffset(unsigned long streamPos,
unsigned long returnPos = os.tellp();
unsigned long offset = returnPos - this->AppendedDataPosition;
os.seekp(streamPos);
if(attr) { os << " " << attr << "="; }
if(attr)
{
os << " " << attr << "=";
}
os << "\"" << offset << "\"";
unsigned long endPos = os.tellp();
os.seekp(returnPos);
......@@ -1412,7 +1415,10 @@ unsigned long vtkXMLWriter::WriteDataArrayAppended(vtkDataArray* a,
else
{
const char* arrayName = a->GetName();
if(arrayName) { this->WriteStringAttribute("Name", arrayName); }
if(arrayName)
{
this->WriteStringAttribute("Name", arrayName);
}
}
if(a->GetNumberOfComponents() > 1)
{
......@@ -1458,7 +1464,10 @@ void vtkXMLWriter::WriteDataArrayInline(vtkDataArray* a, vtkIndent indent,
else
{
const char* arrayName = a->GetName();
if(arrayName) { this->WriteStringAttribute("Name", arrayName); }
if(arrayName)
{
this->WriteStringAttribute("Name", arrayName);
}
}
if(a->GetNumberOfComponents() > 1)
{
......@@ -2133,7 +2142,10 @@ void vtkXMLWriter::WritePDataArray(vtkDataArray* a, vtkIndent indent,
else
{
const char* arrayName = a->GetName();
if(arrayName) { this->WriteStringAttribute("Name", arrayName); }
if(arrayName)
{
this->WriteStringAttribute("Name", arrayName);
}
}
if(a->GetNumberOfComponents() > 1)
{
......
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