Beispiel #1
0
bool ShapefileReader::incompleteSrcFiles(){

  //constructing files names ending with three extensions
  std::string shxName = this->FileName;
  std::string dbfName = this->FileName;
  int extOffset = shxName.find_last_of(".");

  shxName.replace(extOffset, 4, ".shx");
  dbfName.replace(extOffset, 4, ".dbf");

  //check for readability of required .shx/SHX .shp/SHP .dbf/DBF files

  if ( isFileBad(this->FileName, extOffset, ".SHX") ) {
    vtkErrorMacro("Could not find/read the .shx/SHX file.");
    return true;
  }

  if ( isFileBad(shxName.c_str(), extOffset, ".SHP") ) {
    vtkErrorMacro("Could not find/read the .shp/SHP file.");
    return true;
  }

  if ( isFileBad(dbfName.c_str(), extOffset, ".DBF") ) {
    vtkErrorMacro("Could not find/read the .dbf/DBF file.");
    return true;
  }

  return false;
}
//----------------------------------------------------------------------------
// This method contains a switch statement that calls the correct
// templated function for the input data type.  This method does handle
// boundary conditions.
void vtkMitkThickSlicesFilter::ThreadedRequestData(vtkInformation*,
                                           vtkInformationVector** inputVector,
                                           vtkInformationVector*,
                                           vtkImageData*** inData,
                                           vtkImageData** outData,
                                           int outExt[6],
                                           int threadId)
{
  // Get the input and output data objects.
  vtkImageData* input = inData[0][0];
  vtkImageData* output = outData[0];

  // The ouptut scalar type must be double to store proper gradients.
/*
  if(output->GetScalarType() != VTK_DOUBLE)
    {
    vtkErrorMacro("Execute: output ScalarType is "
                  << output->GetScalarType() << "but must be double.");
    return;
    }
  */
  vtkDataArray* inputArray = this->GetInputArrayToProcess(0, inputVector);
  if (!inputArray)
    {
    vtkErrorMacro("No input array was found. Cannot execute");
    return;
    }

  // Gradient makes sense only with one input component.  This is not
  // a Jacobian filter.
  if(inputArray->GetNumberOfComponents() != 1)
    {
    vtkErrorMacro(
      "Execute: input has more than one component. "
      "The input to gradient should be a single component image. "
      "Think about it. If you insist on using a color image then "
      "run it though RGBToHSV then ExtractComponents to get the V "
      "components. That's probably what you want anyhow.");
    return;
    }

  void* inPtr = inputArray->GetVoidPointer(0);
  void* outPtr = output->GetScalarPointerForExtent(outExt);

  switch(inputArray->GetDataType())
    {
    vtkTemplateMacro(
      vtkMitkThickSlicesFilterExecute(this, input, static_cast<VTK_TT*>(inPtr), output, static_cast<VTK_TT*>(outPtr), outExt, threadId)
      );
    default:
      vtkErrorMacro("Execute: Unknown ScalarType " << input->GetScalarType());
      return;
    }
}
//----------------------------------------------------------------------------
void vtkExodusReader::CheckForProblems()
{
  vtkUnstructuredGrid *output = this->GetOutput();
  int numPts = output->GetNumberOfPoints();
  int numCells = output->GetNumberOfCells();
  int i, num;
  vtkDataArray *array;
  int id, ptId;
  vtkCell *cell;
  vtkIdList *ptIds;
  
  // Check cell arrays to see if they have the right number of values.
  num = output->GetCellData()->GetNumberOfArrays();
  for (i = 0; i < num; ++i)
    {
    array = output->GetCellData()->GetArray(i);
    if (array->GetNumberOfTuples() != numCells)
      {
      vtkErrorMacro("CellArray " << array->GetName() << " has "
                    << array->GetNumberOfTuples() 
                    << " tuples, but should have " << numCells);
      }
    }
  
  // Check point arrays to see if they have the right number of values.
  num = output->GetPointData()->GetNumberOfArrays();
  for (i = 0; i < num; ++i)
    {
    array = output->GetPointData()->GetArray(i);
    if (array->GetNumberOfTuples() != numPts)
      {
      vtkErrorMacro("PointArray " << array->GetName() << " has " 
                    << array->GetNumberOfTuples() 
                    << " tuples, but should have " << numPts);
      }
    }
  
  // Check all o fthe cells point ids to see if they are valid.
  for (id = 0; id < numCells; ++id)
    {
    cell = output->GetCell(id);
    ptIds = cell->GetPointIds();
    num = ptIds->GetNumberOfIds();
    for (i = 0; i < num; ++i)
      {
      ptId = ptIds->GetId(i);
      if (ptId < 0 || ptId >= numPts)
        {
        vtkErrorMacro("Bad pt id " << ptId << " in cell "
                      << id);
        }
      }
    }
}
//------------------------------------------------------------------------------
void vtkAMRSimPlaParticlesReader::ReadMetaData()
{
    if (this->Initialized)
    {
        return;
    }

    if (!this->FileName)
    {
        vtkErrorMacro("No FileName set!");
        return;
    }

   this->m_pimpl_->SetFileName(this->FileName);
    std::string tempName(this->FileName);
    std::string bExtName(".boundary");
    std::string hExtName(".hierarchy");

    if (tempName.length() > hExtName.length() &&
        tempName.substr(tempName.length() - hExtName.length()) == hExtName)
    {
       this->m_pimpl_->MajorFileName =
                tempName.substr(0, tempName.length() - hExtName.length());
       this->m_pimpl_->HierarchyFileName = tempName;
       this->m_pimpl_->BoundaryFileName =
               this->m_pimpl_->MajorFileName + bExtName;
    }
    else if (tempName.length() > bExtName.length() &&
             tempName.substr(tempName.length() - bExtName.length()) == bExtName)
    {
       this->m_pimpl_->MajorFileName =
                tempName.substr(0, tempName.length() - bExtName.length());
       this->m_pimpl_->BoundaryFileName = tempName;
       this->m_pimpl_->HierarchyFileName =
               this->m_pimpl_->MajorFileName + hExtName;
    }
    else
    {
        vtkErrorMacro("SimPla file has invalid extension!");
        return;
    }

   this->m_pimpl_->DirectoryName =
            GetSimPlaDirectory(this->m_pimpl_->MajorFileName.c_str());

   this->m_pimpl_->ReadMetaData();
   this->m_pimpl_->CheckAttributeNames();

    this->NumberOfBlocks =this->m_pimpl_->NumberOfBlocks;
    this->Initialized = true;

    this->SetupParticleDataSelections();
}
Beispiel #5
0
int AssignPointAttributeToCoordinatesFilter::RequestData(
    vtkInformation * /*request*/,
    vtkInformationVector ** inputVector,
    vtkInformationVector * outputVector)
{
    auto inData = vtkPointSet::SafeDownCast(inputVector[0]->GetInformationObject(0)->Get(vtkDataObject::DATA_OBJECT()));
    auto outData = vtkPointSet::SafeDownCast(outputVector->GetInformationObject(0)->Get(vtkDataObject::DATA_OBJECT()));

    auto previousPointCoords = inData->GetPoints()->GetData();
    vtkDataArray * pointsToAssign = nullptr;

    if (!this->AttributeArrayToAssign.empty())
    {
        auto newPoints = inData->GetPointData()->GetArray(this->AttributeArrayToAssign.c_str());
        if (!newPoints)
        {
            vtkErrorMacro("Array to assign not found in input data: " + this->AttributeArrayToAssign);
            return 0;
        }

        if (newPoints->GetNumberOfComponents() != 3
            || newPoints->GetNumberOfTuples() != inData->GetNumberOfPoints())
        {
            vtkErrorMacro("Component/Tuple count mismatching in selected data array: " + this->AttributeArrayToAssign);
            return 0;
        }
        pointsToAssign = newPoints;
    }

    outData->ShallowCopy(inData);

    if (pointsToAssign)
    {
        vtkNew<vtkPoints> newPoints;
        newPoints->SetData(pointsToAssign);
        outData->SetPoints(newPoints.Get());
    }

    // pass current point coordinates as point attribute
    if (previousPointCoords)
    {
        outData->GetPointData()->AddArray(previousPointCoords);
    }

    if (auto currentCoords = pointsToAssign ? pointsToAssign : previousPointCoords)
    {
        outData->GetPointData()->SetActiveScalars(currentCoords->GetName());
    }

    return 1;
}
int vtkErVolume::RequestData(vtkInformation* Request, vtkInformationVector** InputVector, vtkInformationVector* OutputVector)
{
	vtkInformation* InInfo = InputVector[0]->GetInformationObject(0);
	vtkInformation* OutInfo	= OutputVector->GetInformationObject(0);

	if (!InInfo || !OutInfo)
		return 0;

	vtkImageData* ImageDataIn = vtkImageData::SafeDownCast(InInfo->Get(vtkDataObject::DATA_OBJECT()));

	if (!ImageDataIn)
		return 0;

	if (ImageDataIn->GetDataDimension() != 3)
	{
		vtkErrorMacro("vtkErVolume onlys works with 3 dimensional image data!");
		return 0;
	}

	if (ImageDataIn->GetNumberOfScalarComponents() != 1)
	{
		vtkErrorMacro("vtkErVolume onlys works with 1 scalar component per voxel!");
		return 0;
	}

	if (ImageDataIn->GetScalarType() != VTK_UNSIGNED_SHORT)
	{
		vtkErrorMacro("vtkErVolume onlys works with unsigned short image data!");
		return 0;
	}

	vtkErVolumeData* VolumeDataOut = vtkErVolumeData::SafeDownCast(OutInfo->Get(vtkDataObject::DATA_OBJECT()));

	if (!VolumeDataOut)
		return 0;

	const Vec3i Resolution(ImageDataIn->GetExtent()[1] + 1, ImageDataIn->GetExtent()[3] + 1, ImageDataIn->GetExtent()[5] + 1);
	const Vec3f Spacing(ImageDataIn->GetSpacing()[0], ImageDataIn->GetSpacing()[1], ImageDataIn->GetSpacing()[2]);

	VolumeDataOut->Bindable.BindVoxels(Resolution, Spacing, (unsigned short*)ImageDataIn->GetScalarPointer(), true);
	VolumeDataOut->Bindable.GetVoxels().SetFilterMode(this->GetFilterMode());
	VolumeDataOut->Bindable.SetAcceleratorType(this->GetAcceleratorType());
	
	vtkErAlignment::RequestData(VolumeDataOut->Bindable.GetAlignment());

	VolumeDataOut->Bind();

	return 1;
}
//----------------------------------------------------------------------------
// This method contains a switch statement that calls the correct
// templated function for the input data type.  This method does handle
// boundary conditions.
void LofarIntegrateFrequencies::ThreadedRequestData(vtkInformation*,
                vtkInformationVector** inputVector,
                vtkInformationVector*,
                vtkImageData*** inData,
                vtkImageData** outData,
                int outExt[6],
                int threadId)
{
    // Get the input and output data objects.
    vtkImageData* input = inData[0][0];
    vtkImageData* output = outData[0];

    // The ouptut scalar type must be double to store proper gradients.
    if(output->GetScalarType() != VTK_DOUBLE)
    {
        vtkErrorMacro("Execute: output ScalarType is "
                        << output->GetScalarType() << "but must be double.");
        return;
    }

    vtkDataArray* inputArray = this->GetInputArrayToProcess(0, inputVector);
    if (!inputArray)
    {
        vtkErrorMacro("No input array was found. Cannot execute");
        return;
    }

    // Integration only works on scalars.
    if(inputArray->GetNumberOfComponents() != 1)
    {
        vtkErrorMacro("Execute: input has more than one component. ");
        return;
    }

    void* inPtr = inputArray->GetVoidPointer(0);
    double* outPtr = static_cast<double *>(
                    output->GetScalarPointerForExtent(outExt));
    switch(inputArray->GetDataType())
    {
    vtkTemplateMacro(
                    LofarIntegrateFrequenciesExecute(this, input, static_cast<VTK_TT*>(inPtr),
                                    output, outPtr, outExt, threadId)
    );
    default:
        vtkErrorMacro("Execute: Unknown ScalarType " << input->GetScalarType());
        return;
    }
}
// ****************************************************************************
//  Method:  vtkVisItStructuredGridNormals::Execute
//
//  Purpose:
//    main update function; decide which type of algorithm to perform
//
//  Arguments:
//    none
//
//  Programmer:  Hank Childs
//  Creation:    December 28, 2006
//
//  Modifications:
//
//    Hank Childs, Fri Feb 15 11:53:21 PST 2008
//    Take out some VTK uckiness.
//
// ****************************************************************************
int
vtkVisItStructuredGridNormals::RequestData(vtkInformation *vtkNotUsed(request),
    vtkInformationVector **vtkNotUsed(inputVector), 
    vtkInformationVector *vtkNotUsed(outputVector))
{
    // get the input and output
    vtkStructuredGrid *input = GetStructuredGridInput(0);
    vtkStructuredGrid *output = GetOutput();

    int dims[3];
    input->GetDimensions(dims);
    if (dims[0] > 1 && dims[1] > 1 && dims[2] > 1)
    {
        vtkErrorMacro("This filter only operates on topologically "
                      "two-dimensional structured grids");
        output->ShallowCopy(input);
        return 0;
    }

    if (ComputePointNormals)
    {
        ExecutePoint(input, output);
    }
    else
    {
        // Cell normals
        ExecuteCell(input, output);
    }
    return 1;
}
Beispiel #9
0
bool ShapefileReader::illegalFileName(){

  //check for null pointer
  if(!this->FileName)  {
    vtkErrorMacro("No FileName specified.");
    return true;
  }

  //check for zero length string
  if(strlen(this->FileName)==0)  {
    vtkErrorMacro("A zero length FileName.");
    return true;
  }

  return false;
}
Beispiel #10
0
void cv::viz::vtkXYZWriter::WriteData()
{
    vtkPolyData *input = this->GetInput();
    if (!input)
        return;

    // OpenVTKFile() will report any errors that happen
    ostream *outfilep = this->OpenVTKFile();
    if (!outfilep)
        return;

    ostream &outfile = *outfilep;

    for(vtkIdType i = 0; i < input->GetNumberOfPoints(); ++i)
    {
        Vec3d p;
        input->GetPoint(i, p.val);
        outfile << std::setprecision(this->DecimalPrecision) << p[0] << " " << p[1] << " " << p[2] << std::endl;
    }

    // Close the file
    this->CloseVTKFile(outfilep);

    // Delete the file if an error occurred
    if (this->ErrorCode == vtkErrorCode::OutOfDiskSpaceError)
    {
        vtkErrorMacro("Ran out of disk space; deleting file: " << this->FileName);
        unlink(this->FileName);
    }
}
 /**
  * Sets color's index of the segment with index @a id.
  */
 void VTKSegmentsFramesSource::SetSegmentColorIndex(vtkIdType id, vtkIdType color)
 {
   if (id >= this->mp_SegmentsColorIndex->GetNumberOfTuples())
   {
     vtkErrorMacro("Out of range.");
     return;
   }
   this->mp_SegmentsColorIndex->SetValue(id, color);
 };
 /**
  * Return color's index of the segment with index @a id.
  */
 vtkIdType VTKSegmentsFramesSource::GetSegmentColorIndex(vtkIdType id)
 {
   if (id >= this->mp_SegmentsColorIndex->GetNumberOfTuples())
   {
     vtkErrorMacro("Out of range.");
     return 0;
   }
   return this->mp_SegmentsColorIndex->GetValue(id);
 };
 /**
  * Returns the visibility of the segment with index @a id.
  */
 bool VTKSegmentsFramesSource::GetSegmentVisibility(vtkIdType id)
 {
   if (id >= this->mp_VisibleSegments->GetNumberOfTuples())
   {
     vtkErrorMacro("Out of range.");
     return false;
   }
   return this->mp_VisibleSegments->GetValue(id) ? true : false;
 };
//----------------------------------------------------------------------------
void fwVtkWindowLevelLookupTable::MapScalarsThroughTable2(void *input,
        unsigned char *output,
        int inputDataType,
        int numberOfValues,
        int inputIncrement,
        int outputFormat)
{
    if (this->UseMagnitude && inputIncrement > 1)
    {
        switch (inputDataType)
        {
            vtkTemplateMacro(
                    fwVtkWindowLevelLookupTableMapMag(this,static_cast<VTK_TT*>(input),output,
                        numberOfValues,inputIncrement,outputFormat);
                    return
                    );
            case VTK_BIT:
            vtkErrorMacro("Cannot comput magnitude of bit array.");
            break;
            default:
            vtkErrorMacro(<< "MapImageThroughTable: Unknown input ScalarType");
        }
    }

    switch (inputDataType)
    {
        case VTK_BIT:
            {
                vtkIdType i, id;
                vtkBitArray *bitArray = vtkBitArray::New();
                bitArray->SetVoidArray(input,numberOfValues,1);
                vtkUnsignedCharArray *newInput = vtkUnsignedCharArray::New();
                newInput->SetNumberOfValues(numberOfValues);
                for (id=i=0; i<numberOfValues; i++, id+=inputIncrement)
                {
                    newInput->SetValue(i, bitArray->GetValue(id));
                }
                fwVtkWindowLevelLookupTableMapData(this,
                        static_cast<unsigned char*>(newInput->GetPointer(0)),
                        output,numberOfValues,
                        inputIncrement,outputFormat);
                newInput->Delete();
                bitArray->Delete();
            }
            break;

            vtkTemplateMacro(
                    fwVtkWindowLevelLookupTableMapData(this,static_cast<VTK_TT*>(input),output,
                        numberOfValues,inputIncrement,outputFormat)
                    );
        default:
            vtkErrorMacro(<< "MapImageThroughTable: Unknown input ScalarType");
            return;
    }
}
//----------------------------------------------------------------------------
int vtkExodusReader::GetCellDataArrayLoadFlag(int arrayIdx)
{
  if (arrayIdx < 0 || arrayIdx >= this->NumberOfCellDataArrays)
    {
    vtkErrorMacro("CellData array  index " << arrayIdx 
                  << " is out of range.  The Current number of cell data arrays is : " 
                  << this->NumberOfCellDataArrays);
    return 0;
    }
  return this->CellDataArrayFlags[arrayIdx];
}    
 /**
  * Returns the mesh defining the segment corresponding to the index @a id.
  */
 TriangleMesh::Pointer VTKSegmentsFramesSource::GetDefinition(vtkIdType id)
 {
   if (id >= this->mp_VisibleSegments->GetNumberOfTuples())
   {
     vtkErrorMacro("Out of range.");
     return TriangleMesh::Pointer();
   }
   std::list<SegmentDefinition>::const_iterator it = this->m_Definitions.begin();
   std::advance(it, id);
   return it->mesh;
 };
 /**
  * Sets the definition (markers + links) for the segment with the index @a id. The segment must already exists.
  */
 void VTKSegmentsFramesSource::SetDefinition(vtkIdType id, const std::vector<int>& markerIds, const std::vector<Link>& links)
 {
   if (id >= this->mp_VisibleSegments->GetNumberOfTuples())
   {
     vtkErrorMacro("Out of range.");
     return;
   }
   std::list<SegmentDefinition>::iterator it = this->m_Definitions.begin();
   std::advance(it, id);
   it->mesh->SetDefinition(markerIds, links);
 };
 /**
  * Sets the visibility of the surface created for segment with index @a id.
  */
 void VTKSegmentsFramesSource::SetSegmentSurfaceVisibility(vtkIdType id, bool visible)
 {
   if (id >= this->mp_VisibleSegments->GetNumberOfTuples())
   {
     vtkErrorMacro("Out of range.");
     return;
   }
   std::list<SegmentDefinition>::iterator it = this->m_Definitions.begin();
   std::advance(it, id);
   it->surfaceEnabled = visible;
 };
//----------------------------------------------------------------------------
int vtkExodusReader::GetPointDataArrayNumberOfComponents(int arrayIdx)
{
  if (arrayIdx < 0 || arrayIdx >= this->NumberOfPointDataArrays)
    {
    vtkErrorMacro("PointData array  index " << arrayIdx 
                  << " is out of range.  The Current number of point data arrays is : " 
                  << this->NumberOfPointDataArrays);
    return 0;
    }
  return this->PointDataArrayNumberOfComponents[arrayIdx];
}
//----------------------------------------------------------------------------
const char *vtkExodusReader::GetCellDataArrayName(int arrayIdx)
{
  if (arrayIdx < 0 || arrayIdx >= this->NumberOfCellDataArrays)
    {
    vtkErrorMacro("CellData array  index " << arrayIdx 
                  << " is out of range.  The Current number of cell data arrays is : " 
                  << this->NumberOfCellDataArrays);
    return NULL;
    }
  return this->CellDataArrayNames[arrayIdx];
}
 /**
  * Sets the visibility of the segment with index @a id.
  */
 void VTKSegmentsFramesSource::SetSegmentVisibility(vtkIdType id, bool visible)
 {
   if (id >= this->mp_VisibleSegments->GetNumberOfTuples())
   {
     vtkErrorMacro("Out of range.");
     return;
   }
   if (visible)
     this->mp_VisibleSegments->SetValue(id, 1);
   else
     this->mp_VisibleSegments->SetValue(id, 0);
 };
//----------------------------------------------------------------------------
int vtkExodusReader::GetBlockId(int blockIdx)
{
  if (blockIdx < 0 || blockIdx >= this->NumberOfBlocks)
    {
    vtkErrorMacro("Block index " << blockIdx 
                  << " is out of range.  The Current number of blocks is : " 
                  << this->NumberOfBlocks);
    return 0;
    }
  
  return this->BlockIds->GetValue(blockIdx);
}
int cv::viz::vtkXYZReader::RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector)
{
    // Make sure we have a file to read.
    if(!this->FileName)
    {
        vtkErrorMacro("A FileName must be specified.");
        return 0;
    }

    // Open the input file.
    ifstream fin(this->FileName);
    if(!fin)
    {
        vtkErrorMacro("Error opening file " << this->FileName);
        return 0;
    }

    // Allocate objects to hold points and vertex cells.
    vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
    vtkSmartPointer<vtkCellArray> verts = vtkSmartPointer<vtkCellArray>::New();

    // Read points from the file.
    vtkDebugMacro("Reading points from file " << this->FileName);
    double x[3];
    while(fin >> x[0] >> x[1] >> x[2])
    {
        vtkIdType id = points->InsertNextPoint(x);
        verts->InsertNextCell(1, &id);
    }
    vtkDebugMacro("Read " << points->GetNumberOfPoints() << " points.");

    // Store the points and cells in the output data object.
    vtkPolyData* output = vtkPolyData::GetData(outputVector);
    output->SetPoints(points);
    output->SetVerts(verts);

    return 1;
}
void VolumeRayCastMapper::SetInput(int port, vtkDataSet *genericInput)
{
	vtkImageData *input =
		vtkImageData::SafeDownCast(genericInput);

	if (input)
	{
		SetInput(port, input);
	}
	else
	{
		vtkErrorMacro("The SetInput method of this mapper requires vtkImageData as input");
	}
}
void VtkColorLookupTable::SetTableValue(vtkIdType indx, unsigned char rgba[4])
{
	// Check the index to make sure it is valid
	if (indx < 0)
	{
		vtkErrorMacro("Can't set the table value for negative index " << indx);
		return;
	}
	if (indx >= this->NumberOfColors)
	{
		vtkErrorMacro(
		        "Index " << indx << " is greater than the number of colors " <<
		        this->NumberOfColors);
		return;
	}

	unsigned char* _rgba = this->Table->WritePointer(4 * indx,4);
	for (size_t i = 0; i < 4; i++)
		_rgba[i] = rgba[i];

	this->InsertTime.Modified();
	this->Modified();
}
//----------------------------------------------------------------------------
int vtkVisItXMLPDataReader::ReadPiece(vtkXMLDataElement* ePiece, int index)
{
  const char* fileName = ePiece->GetAttribute("Source");
  if(!fileName)
    {
    vtkErrorMacro("Piece " << index << " has no Source attribute.");
    return 0;
    }

  // The file name is relative to the summary file.  Convert it to
  // something we can use.
  this->PieceFileNames[index] = this->CreatePieceFileName(fileName);
  
  return 1;
}
//----------------------------------------------------------------------------
void vtkExodusReader::SetCellDataArrayLoadFlag(int arrayIdx, int flag)
{
  if (arrayIdx < 0 || arrayIdx >= this->NumberOfCellDataArrays)
    {
    vtkErrorMacro("CellData array  index " << arrayIdx 
                  << " is out of range.  The Current number of cell data arrays is : " 
                  << this->NumberOfCellDataArrays);
    return;
    }
  if (this->CellDataArrayFlags[arrayIdx] == flag)
    {
    return;
    }
  this->Modified();
  this->CellDataArrayFlags[arrayIdx] = flag;
}
int StreamTracer::SetupOutput(vtkInformation* inInfo,
                              vtkInformation* outInfo)
{
    int piece=outInfo->Get(
                  vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER());
    int numPieces =
        outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES());

    vtkDataObject* input = inInfo->Get(vtkDataObject::DATA_OBJECT());

    vtkCompositeDataSet *hdInput = vtkCompositeDataSet::SafeDownCast(input);
    vtkDataSet* dsInput = vtkDataSet::SafeDownCast(input);
    if (hdInput)
    {
        this->InputData = hdInput;
        hdInput->Register(this);
        return 1;
    }
    else if (dsInput)
    {
        vtkDataSet* copy = dsInput->NewInstance();
        copy->ShallowCopy(dsInput);
        vtkMultiBlockDataSet* mb = vtkMultiBlockDataSet::New();
        mb->SetNumberOfBlocks(numPieces);
        mb->SetBlock(piece, copy);
        copy->Delete();
        this->InputData = mb;
        mb->Register(this);
        mb->Delete();
        return 1;
    }
    else
    {
        vtkErrorMacro("This filter cannot handle input of type: "
                      << (input?input->GetClassName():"(none)"));
        return 0;
    }

}
//----------------------------------------------------------------------------
// Read the first three vectors and put in vectors as displacement.
//
// Modifications:
//   Kathleen Bonnell, Mon Oct 29 15:27:41 PST 2001
//   Use vtkIdType for outPtCount, pointMapOutInArray, to match VTK 4.0 API. 
//
//----------------------------------------------------------------------------
vtkDataArray *vtkExodusReader::ReadPointDataArray(int exoid, int varIndex)
{
  int error;
  float *x;
  float *pv;
  vtkFloatArray *array;
  int inId, outId;
  vtkIdType outPtCount;
  vtkIdType *pointMapOutInArray;
  
  x = new float[this->NumberOfNodes];
  
  error = ex_get_nodal_var (exoid, this->TimeStep, varIndex, this->NumberOfNodes, x);
  if (error < 0)
    {
    vtkErrorMacro("Error: " << error << " while reading array  from " 
                  << this->FileName);
    delete [] x;
    return NULL;
    }
  
  // Since we are only keeping a portion of the points/values, use a mapping.
  outPtCount = this->PointMapOutIn->GetNumberOfIds();
  pointMapOutInArray = this->PointMapOutIn->GetPointer(0);
  
  array = vtkFloatArray::New();
  array->SetNumberOfValues(outPtCount);
  // Fill in the array.
  pv = (float*)(array->GetVoidPointer(0));
  for (outId = 0; outId < outPtCount; ++outId)
    {
    inId = pointMapOutInArray[outId];
    *pv++= x[inId];
    }
  delete [] x;
  
  return array;
}
//------------------------------------------------------------------------------
vtkPolyData *vtkAMRSimPlaParticlesReader::ReadParticles(const int blkidx)
{
    //this->m_pimpl_->Blocks includes a pseudo block -- the roo as block #0
    int iBlockIdx = blkidx + 1;
    int NumParticles =this->m_pimpl_->Blocks[iBlockIdx].NumberOfParticles;

    if (NumParticles <= 0)
    {
        vtkPolyData *emptyParticles = vtkPolyData::New();
        assert("Cannot create particles DataModel" && (emptyParticles != NULL));
        return (emptyParticles);
    }

    std::string pfile =this->m_pimpl_->Blocks[iBlockIdx].ParticleFileName;
    if (pfile == "")
    {
        vtkErrorMacro("No particles file found, string is empty!");
        return NULL;
    }

    vtkPolyData *particles = this->GetParticles(pfile.c_str(), blkidx);
    return (particles);
}