Example #1
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int EstablishShapeTypes::getPhaseCount()
{
  DataContainerArray::Pointer dca = getDataContainerArray();

  AttributeMatrix::Pointer inputAttrMat = dca->getAttributeMatrix(getInputPhaseTypesArrayPath());

  if (NULL == inputAttrMat.get() ) { return 0; }

  if (__SHOW_DEBUG_MSG__)
  {
    qDebug() << "  data->getNumberOfTuples(): " << inputAttrMat->getTupleDimensions();
    qDebug() << "Name" << inputAttrMat->getName();
  }

  if (inputAttrMat->getType() < DREAM3D::AttributeMatrixType::VertexEnsemble
      || inputAttrMat->getType() > DREAM3D::AttributeMatrixType::CellEnsemble )
  {
    return 0;
  }

  QVector<size_t> tupleDims = inputAttrMat->getTupleDimensions();
  size_t phaseCount = 1;
  for (int32_t i = 0; i < tupleDims.size(); i++)
  {
    phaseCount = phaseCount * tupleDims[i];
  }
  return phaseCount;
}
    static void PopulateAttributeMatrixComboBox(AbstractFilter* filter, FilterParameter* filterParameter,
                                            QComboBox* dcCombo, QComboBox* amCombo,
                                            DataContainerArrayProxy& dcaProxy)
    {
      FilterParameterType* fp = dynamic_cast<FilterParameterType*>(filterParameter);
      assert(fp != NULL);
      DataContainerArray::Pointer dca = filter->getDataContainerArray();
      if (NULL == dca.get()) { return; }

      QString dcName = dcCombo->currentText();

      // Clear the AttributeMatrix List
      bool alreadyBlocked = false;
      if(amCombo->signalsBlocked()) { alreadyBlocked = true; }
      amCombo->blockSignals(true);
      amCombo->clear();

      // Loop over the data containers until we find the proper data container
      QList<DataContainerProxy> containers = dcaProxy.dataContainers.values();
      QListIterator<DataContainerProxy> containerIter(containers);
      QVector<unsigned int> defVec = fp->getDefaultAttributeMatrixTypes();
      while(containerIter.hasNext())
      {
        DataContainerProxy dc = containerIter.next();

        if(dc.name.compare(dcName) == 0 )
        {
          // We found the proper Data Container, now populate the AttributeMatrix List
          QMap<QString, AttributeMatrixProxy> attrMats = dc.attributeMatricies;
          QMapIterator<QString, AttributeMatrixProxy> attrMatsIter(attrMats);
          while(attrMatsIter.hasNext() )
          {
            attrMatsIter.next();
            QString amName = attrMatsIter.key();
            AttributeMatrix::Pointer am = dca->getAttributeMatrix(DataArrayPath(dc.name, amName, ""));
            amCombo->addItem(amName);

            if (NULL != am.get() && defVec.isEmpty() == false && defVec.contains(am->getType()) == false)
            {
              QStandardItemModel* model = qobject_cast<QStandardItemModel*>(amCombo->model());
              if (NULL != model)
              {
                QStandardItem* item = model->item(amCombo->findText(amName));
                if (NULL != item)
                {
                  item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
                }
              }
            }
          }
        }
      }

      if(!alreadyBlocked) { // Only unblock if this function blocked the signals.
        amCombo->blockSignals(false);
      }
    }
Example #3
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void EdgeGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data)
{
  if (data->getType() != 0 || data->getType() != 1)
  {
    // EdgeGeom can only accept vertex or edge Attribute Matrices
    return;
  }
  if (data->getType() == 0 && static_cast<int64_t>(data->getNumTuples()) != getNumberOfVertices())
  {
    return;
  }
  if (data->getType() == 1 && data->getNumTuples() != getNumberOfElements())
  {
    return;
  }
  if (data->getName().compare(name) != 0)
  {
    data->setName(name);
  }
  m_AttributeMatrices[name] = data;
}
Example #4
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void VertexGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data)
{
  if (data->getType() != 0)
  {
    // VertexGeom can only accept vertex Attribute Matrices
    return;
  }
  if (data->getNumTuples() != getNumberOfElements())
  {
    return;
  }
  if (data->getName().compare(name) != 0)
  {
    data->setName(name);
  }
  m_AttributeMatrices[name] = data;
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
DataContainerArrayProxy::DataContainerArrayProxy(DataContainerArray* dca)
{

  if(NULL == dca)
  {
    return;
  }

  QList<DataContainer::Pointer> containers = dca->getDataContainers();
  for(int i = 0; i < containers.size(); i++) // Loop on each Data Container
  {
    DataContainer::Pointer container = containers.at(i);
    DataContainerProxy dcProxy(container->getName(), Qt::Checked); // Create a new DataContainerProxy

    // Now loop over each AttributeMatrix in the data container that was selected
    DataContainer::AttributeMatrixMap_t attrMats = container->getAttributeMatrices();
    QMapIterator<QString, AttributeMatrix::Pointer> iter(attrMats);
    while(iter.hasNext())
    {
      iter.next();
      QString amName = iter.key();
      AttributeMatrix::Pointer attrMat = iter.value();
      AttributeMatrixProxy amProxy(amName, Qt::Checked, attrMat->getType());

      QList<QString> attrArrayNames = attrMat->getAttributeArrayNames();
      QListIterator<QString> attrArrayNamesIter(attrArrayNames);
      while(attrArrayNamesIter.hasNext())
      {
        QString aaName = attrArrayNamesIter.next();
        QString daPath = container->getName() + "/" + amName + "/";
        IDataArray::Pointer attrArray = attrMat->getAttributeArray(aaName);
        DataArrayProxy daProxy(daPath, aaName, Qt::Checked, attrArray->getTypeAsString(), attrArray->getClassVersion() );
        amProxy.dataArrays.insert(aaName, daProxy);
      }
      dcProxy.attributeMatricies.insert(amName, amProxy); // Add the new AttributeMatrix to the DataContainerProxy
    }
    dataContainers.insert(dcProxy.name, dcProxy);
  }
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void ChangeResolution::execute()
{
  setErrorCondition(0);
  dataCheck();
  if(getErrorCondition() < 0) { return; }

  DataContainer::Pointer m;
  if(m_SaveAsNewDataContainer == false)
  {
    m = getDataContainerArray()->getDataContainer(getCellAttributeMatrixPath().getDataContainerName());
  }
  else
  {
    m = getDataContainerArray()->getDataContainer(getNewDataContainerName());
  }

  if(m->getGeometryAs<ImageGeom>()->getXRes() == m_Resolution.x
      && m->getGeometryAs<ImageGeom>()->getYRes() == m_Resolution.y
      && m->getGeometryAs<ImageGeom>()->getZRes() == m_Resolution.z)
  {
    return;
  }

  AttributeMatrix::Pointer cellAttrMat = m->getAttributeMatrix(getCellAttributeMatrixPath().getAttributeMatrixName());

  size_t dims[3] = { 0, 0, 0 };
  m->getGeometryAs<ImageGeom>()->getDimensions(dims);

  float sizex = (dims[0]) * m->getGeometryAs<ImageGeom>()->getXRes();
  float sizey = (dims[1]) * m->getGeometryAs<ImageGeom>()->getYRes();
  float sizez = (dims[2]) * m->getGeometryAs<ImageGeom>()->getZRes();
  size_t m_XP = size_t(sizex / m_Resolution.x);
  size_t m_YP = size_t(sizey / m_Resolution.y);
  size_t m_ZP = size_t(sizez / m_Resolution.z);
  if (m_XP == 0) { m_XP = 1; }
  if (m_YP == 0) { m_YP = 1; }
  if (m_ZP == 0) { m_ZP = 1; }
  size_t totalPoints = m_XP * m_YP * m_ZP;

  float x = 0.0f, y = 0.0f, z = 0.0f;
  size_t col = 0, row = 0, plane = 0;
  size_t index;
  size_t index_old;
  std::vector<size_t> newindicies(totalPoints);

  for (size_t i = 0; i < m_ZP; i++)
  {
    QString ss = QObject::tr("Changing Resolution - %1 Percent Complete").arg(((float)i / m->getGeometryAs<ImageGeom>()->getZPoints()) * 100);
    notifyStatusMessage(getMessagePrefix(), getHumanLabel(), ss);
    for (size_t j = 0; j < m_YP; j++)
    {
      for (size_t k = 0; k < m_XP; k++)
      {
        x = (k * m_Resolution.x);
        y = (j * m_Resolution.y);
        z = (i * m_Resolution.z);
        col = size_t(x / m->getGeometryAs<ImageGeom>()->getXRes());
        row = size_t(y / m->getGeometryAs<ImageGeom>()->getYRes());
        plane = size_t(z / m->getGeometryAs<ImageGeom>()->getZRes());
        index_old = (plane * m->getGeometryAs<ImageGeom>()->getXPoints() * m->getGeometryAs<ImageGeom>()->getYPoints()) + (row * m->getGeometryAs<ImageGeom>()->getXPoints()) + col;
        index = (i * m_XP * m_YP) + (j * m_XP) + k;
        newindicies[index] = index_old;
      }
    }
  }

  QVector<size_t> tDims(3, 0);
  tDims[0] = m_XP;
  tDims[1] = m_YP;
  tDims[2] = m_ZP;
  AttributeMatrix::Pointer newCellAttrMat = AttributeMatrix::New(tDims, cellAttrMat->getName(), cellAttrMat->getType());

  QList<QString> voxelArrayNames = cellAttrMat->getAttributeArrayNames();
  for (QList<QString>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter)
  {
    IDataArray::Pointer p = cellAttrMat->getAttributeArray(*iter);
    // Make a copy of the 'p' array that has the same name. When placed into
    // the data container this will over write the current array with
    // the same name. At least in theory.
    IDataArray::Pointer data = p->createNewArray(p->getNumberOfTuples(), p->getComponentDimensions(), p->getName());
    data->resize(totalPoints);
    void* source = NULL;
    void* destination = NULL;
    size_t newIndicies_I = 0;
    int nComp = data->getNumberOfComponents();
    for (size_t i = 0; i < static_cast<size_t>(totalPoints); i++)
    {
      newIndicies_I = newindicies[i];
      source = p->getVoidPointer((nComp * newIndicies_I));
      destination = data->getVoidPointer((data->getNumberOfComponents() * i));
      ::memcpy(destination, source, p->getTypeSize() * data->getNumberOfComponents());
    }
    cellAttrMat->removeAttributeArray(*iter);
    newCellAttrMat->addAttributeArray(*iter, data);
  }
  m->getGeometryAs<ImageGeom>()->setResolution(m_Resolution.x, m_Resolution.y, m_Resolution.z);
  m->getGeometryAs<ImageGeom>()->setDimensions(m_XP, m_YP, m_ZP);
  m->removeAttributeMatrix(getCellAttributeMatrixPath().getAttributeMatrixName());
  m->addAttributeMatrix(getCellAttributeMatrixPath().getAttributeMatrixName(), newCellAttrMat);

  // Feature Ids MUST already be renumbered.
  if (m_RenumberFeatures == true)
  {
    totalPoints = m->getGeometryAs<ImageGeom>()->getNumberOfElements();
    AttributeMatrix::Pointer cellFeatureAttrMat = m->getAttributeMatrix(getCellFeatureAttributeMatrixPath().getAttributeMatrixName());
    size_t totalFeatures = cellFeatureAttrMat->getNumTuples();
    QVector<bool> activeObjects(totalFeatures, false);
    if (0 == totalFeatures)
    {
      notifyErrorMessage(getHumanLabel(), "The number of Features is 0 and should be greater than 0", -600);
      return;
    }

    updateCellInstancePointers();

    // Find the unique set of feature ids
    for (size_t i = 0; i < totalPoints; ++i)
    {
      activeObjects[m_FeatureIds[i]] = true;
    }
    cellFeatureAttrMat->removeInactiveObjects(activeObjects, m_FeatureIdsPtr.lock());
  }

  notifyStatusMessage(getHumanLabel(), "Complete");
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void CombineAttributeMatrices::dataCheck()
{
  setErrorCondition(0);
  DataArrayPath tempPath;

  DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getFirstAttributeMatrixPath().getDataContainerName(), false);
  if (getErrorCondition() < 0 || NULL == m.get()) { return; }

  if (getFirstAttributeMatrixPath().getDataContainerName().compare(getSecondAttributeMatrixPath().getDataContainerName()) != 0)
  {
    QString ss = QObject::tr("The selected attribute matrices must be in the same data container and currently are not");
    setErrorCondition(-5557);
    notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
  }

  if (getFirstAttributeMatrixPath().getAttributeMatrixName().compare(getSecondAttributeMatrixPath().getAttributeMatrixName()) == 0)
  {
    QString ss = QObject::tr("The selected attribute matrices must be different and currently are the same");
    setErrorCondition(-5558);
    notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
  }

  AttributeMatrix::Pointer firstAttrMat = m->getPrereqAttributeMatrix(this, getFirstAttributeMatrixPath().getAttributeMatrixName(), -301);
  AttributeMatrix::Pointer secondAttrMat = m->getPrereqAttributeMatrix(this, getSecondAttributeMatrixPath().getAttributeMatrixName(), -301);
  if (getErrorCondition() < 0) { return; }

  if (firstAttrMat->getType() != secondAttrMat->getType())
  {
    QString ss = QObject::tr("The selected attribute matrices must be of the same type (ie Feature) and currently are not");
    setErrorCondition(-5559);
    notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
  }

  if (getErrorCondition() < 0) { return; }

  //Note that the minus 1 in the totalTuples calculation is to account for the fact that the zeroth tuple in the two attribute matrices should only be counted once, not twice.
  //All Feature or Ensemble AMs should start from 1 and the zeroth tuple can be combined in the two AMs
  size_t totalTuples = firstAttrMat->getNumTuples() + secondAttrMat->getNumTuples() - 1;
  QVector<size_t> tDims(1, totalTuples);
  m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCombinedAttributeMatrixName(), tDims, firstAttrMat->getType());
  if (getErrorCondition() < 0) { return; }
  AttributeMatrix::Pointer combinedAttrMat = m->getAttributeMatrix(getCombinedAttributeMatrixName());

  QVector<size_t> cDims(1, 1);
  m_FirstIndexPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getFirstIndexArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */
  if (NULL != m_FirstIndexPtr.lock().get()) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */
  {
    m_FirstIndex = m_FirstIndexPtr.lock()->getPointer(0);
  } /* Now assign the raw pointer to data from the DataArray<T> object */
  if (getErrorCondition() < 0) { return; }

  m_SecondIndexPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getSecondIndexArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */
  if (NULL != m_SecondIndexPtr.lock().get()) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */
  {
    m_SecondIndex = m_SecondIndexPtr.lock()->getPointer(0);
  } /* Now assign the raw pointer to data from the DataArray<T> object */
  if (getErrorCondition() < 0) { return; }

  // Create arrays on the reference grid to hold data present on the sampling grid
  QList<QString> fArrayNames = firstAttrMat->getAttributeArrayNames();
  for (QList<QString>::iterator iter = fArrayNames.begin(); iter != fArrayNames.end(); ++iter)
  {
    tempPath.update(getFirstAttributeMatrixPath().getDataContainerName(), getCombinedAttributeMatrixName(), *iter);
    IDataArray::Pointer tmpDataArray = firstAttrMat->getPrereqIDataArray<IDataArray, AbstractFilter>(this, *iter, -90001);
    if (getErrorCondition() >= 0)
    {
      QVector<size_t> cDims = tmpDataArray->getComponentDimensions();
      TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, tmpDataArray);
    }
  }
  QList<QString> sArrayNames = secondAttrMat->getAttributeArrayNames();
  for (QList<QString>::iterator iter = sArrayNames.begin(); iter != sArrayNames.end(); ++iter)
  {
    tempPath.update(getSecondAttributeMatrixPath().getDataContainerName(), getCombinedAttributeMatrixName(), *iter);
    IDataArray::Pointer tmpDataArray = secondAttrMat->getPrereqIDataArray<IDataArray, AbstractFilter>(this, *iter, -90001);
    if (getErrorCondition() >= 0)
    {
      if (fArrayNames.contains(*iter) == false)
      {
        QVector<size_t> cDims = tmpDataArray->getComponentDimensions();
        TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, tmpDataArray);
      }
    }
  }

  tempPath.update(getFirstIndexArrayPath().getDataContainerName(), getFirstIndexArrayPath().getAttributeMatrixName(), getNewIndexArrayName());
  m_NewIndexPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter, int32_t>(this, tempPath, 0, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */
  if (NULL != m_NewIndexPtr.lock().get()) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */
  {
    m_NewIndex = m_NewIndexPtr.lock()->getPointer(0);
  }    /* Now assign the raw pointer to data from the DataArray<T> object */
  if (getErrorCondition() < 0) { return; }
}
Example #8
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int DataContainer::writeXdmf(QTextStream& out, QString hdfFileName)
{
  if (NULL == m_Geometry.get())
  {
    return -1;
  }

  m_Geometry->writeXdmf(out, getName(), hdfFileName);
  unsigned int geomType = m_Geometry->getGeometryType();

  // Get all of our AttributeMatrices
  AttributeMatrixMap_t amMap = getAttributeMatrices();
  // Loop over each AttributeMatrix and write the meta data to the Xdmf file
  QString xdmfCenter = "";
  for(QMap<QString, AttributeMatrix::Pointer>::iterator iter = amMap.begin(); iter != amMap.end(); ++iter)
  {
    xdmfCenter = "";
    AttributeMatrix::Pointer attrMat = iter.value();
    uint32_t amType = attrMat->getType();
    switch(geomType)
    {
      case DREAM3D::GeometryType::VertexGeometry:
        switch(amType)
        {
          //FIXME: There are more AttributeMatrix Types that should be implemented
          case DREAM3D::AttributeMatrixType::Vertex:
            xdmfCenter = DREAM3D::XdmfCenterType::Node;
            break;
          default:
            break;
        }
      case DREAM3D::GeometryType::EdgeGeometry:
        switch(amType)
        {
          //FIXME: There are more AttributeMatrix Types that should be implemented
          case DREAM3D::AttributeMatrixType::Vertex:
            xdmfCenter = DREAM3D::XdmfCenterType::Node;
            break;
          case DREAM3D::AttributeMatrixType::Edge:
            xdmfCenter = DREAM3D::XdmfCenterType::Cell;
            break;
          default:
            break;
        }
      case DREAM3D::GeometryType::TriangleGeometry:
        switch(amType)
        {
          //FIXME: There are more AttributeMatrix Types that should be implemented
          case DREAM3D::AttributeMatrixType::Vertex:
            xdmfCenter = DREAM3D::XdmfCenterType::Node;
            break;
          case DREAM3D::AttributeMatrixType::Edge:
            xdmfCenter = DREAM3D::XdmfCenterType::Cell;
            break;
          case DREAM3D::AttributeMatrixType::Face:
            xdmfCenter = DREAM3D::XdmfCenterType::Cell;
            break;
          case DREAM3D::AttributeMatrixType::Cell:
            xdmfCenter = DREAM3D::XdmfCenterType::Cell;
            break;
          default:
            break;
        }
      case DREAM3D::GeometryType::QuadGeometry:
        switch(amType)
        {
          //FIXME: There are more AttributeMatrix Types that should be implemented
          case DREAM3D::AttributeMatrixType::Vertex:
            xdmfCenter = DREAM3D::XdmfCenterType::Node;
            break;
          case DREAM3D::AttributeMatrixType::Edge:
            xdmfCenter = DREAM3D::XdmfCenterType::Cell;
            break;
          case DREAM3D::AttributeMatrixType::Face:
            xdmfCenter = DREAM3D::XdmfCenterType::Cell;
            break;
          case DREAM3D::AttributeMatrixType::Cell:
            xdmfCenter = DREAM3D::XdmfCenterType::Cell;
            break;
          default:
            break;
        }
      case DREAM3D::GeometryType::ImageGeometry:
        switch(amType)
        {
          //FIXME: There are more AttributeMatrix Types that should be implemented
          case DREAM3D::AttributeMatrixType::Vertex:
            xdmfCenter = DREAM3D::XdmfCenterType::Node;
            break;
          case DREAM3D::AttributeMatrixType::Edge:
            xdmfCenter = DREAM3D::XdmfCenterType::Cell;
            break;
          case DREAM3D::AttributeMatrixType::Face:
            xdmfCenter = DREAM3D::XdmfCenterType::Cell;
            break;
          case DREAM3D::AttributeMatrixType::Cell:
            xdmfCenter = DREAM3D::XdmfCenterType::Cell;
            break;
          default:
            break;
        }
    }

    if(xdmfCenter.isEmpty() == false)
    {
      QString xdmfText = attrMat->generateXdmfText(xdmfCenter, getName(), hdfFileName, m_Geometry->getXdmfGridType());
      out << xdmfText;
    }
  }

  writeXdmfFooter(out);

  return 0;
}
Example #9
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void CropImageGeometry::dataCheck()
{
  if(getErrorCondition() < 0) { return; }
  setErrorCondition(0);

  // Validate the incoming DataContainer, Geometry, and AttributeMatrix ; bail if any do not exist since we plan on using them later on in the dataCheck
  // Error messages are handled by the getPrereq functions
  DataContainer::Pointer srcCellDataContainer = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getCellAttributeMatrixPath().getDataContainerName());
  ImageGeom::Pointer image = getDataContainerArray()->getPrereqGeometryFromDataContainer<ImageGeom, AbstractFilter>(this, getCellAttributeMatrixPath().getDataContainerName());
  AttributeMatrix::Pointer srcCellAttrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, getCellAttributeMatrixPath(), -301);
  if(getErrorCondition() < 0) { return; }

  DataContainer::Pointer destCellDataContainer = srcCellDataContainer;
  AttributeMatrix::Pointer destCellAttrMat;

  if (m_SaveAsNewDataContainer == true)
  {
    float ox = 0.0f, oy = 0.0f, oz = 0.0f, rx = 0.0f, ry = 0.0f, rz = 0.0f;
    size_t dx = 0, dy = 0, dz = 0;
    image->getOrigin(ox, oy, oz);
    image->getResolution(rx, ry, rz);
    image->getDimensions(dx, dy, dz);

    destCellDataContainer = getDataContainerArray()->createNonPrereqDataContainer<AbstractFilter>(this, getNewDataContainerName());
    if(NULL == destCellDataContainer.get() || getErrorCondition() < 0)
    {
      return;
    }
    IGeometry::Pointer imageCopy = image->deepCopy();
    destCellDataContainer->setGeometry(imageCopy);

    destCellAttrMat = srcCellAttrMat->deepCopy();
    destCellDataContainer->addAttributeMatrix(destCellAttrMat->getName(), destCellAttrMat);
  }
  else
  {
    destCellAttrMat = srcCellAttrMat;
  }

  if(NULL == destCellDataContainer.get() || NULL == destCellAttrMat.get() || getErrorCondition() < 0)
  {
    return;
  }

  if (getXMax() < getXMin())
  {
    QString ss = QObject::tr("X Max (%1) less than X Min (%2)").arg(getXMax()).arg(getXMin());
    notifyErrorMessage(getHumanLabel(), ss, -5550);
    setErrorCondition(-5550);
  }
  if (getYMax() < getYMin())
  {
    QString ss = QObject::tr("Y Max (%1) less than Y Min (%2)").arg(getYMax()).arg(getYMin());
    notifyErrorMessage(getHumanLabel(), ss, -5550);
    setErrorCondition(-5550);
  }
  if (getZMax() < getZMin())
  {
    QString ss = QObject::tr("Z Max (%1) less than Z Min (%2)").arg(getZMax()).arg(getZMin());
    notifyErrorMessage(getHumanLabel(), ss, -5550);
    setErrorCondition(-5550);
  }
  if (getXMin() < 0)
  {
    QString ss = QObject::tr("X Min (%1) less than 0").arg(getXMin());
    notifyErrorMessage(getHumanLabel(), ss, -5550);
    setErrorCondition(-5550);
  }
  if (getYMin() < 0)
  {
    QString ss = QObject::tr("Y Min (%1) less than 0").arg(getYMin());
    notifyErrorMessage(getHumanLabel(), ss, -5550);
    setErrorCondition(-5550);
  }
  if (getZMin() < 0)
  {
    QString ss = QObject::tr("Z Min (%1) less than 0").arg(getZMin());
    notifyErrorMessage(getHumanLabel(), ss, -5550);
    setErrorCondition(-5550);
  }

  if (getXMax() > (static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getXPoints()) - 1))
  {
    QString ss = QObject::tr("The X Max (%1) is greater than the Image Geometry X extent (%2)").arg(getXMax()).arg(static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getXPoints()) - 1);
    notifyErrorMessage(getHumanLabel(), ss, -5550);
    setErrorCondition(-5550);
  }

  if (getYMax() > (static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getYPoints()) - 1))
  {
    QString ss = QObject::tr("The Y Max (%1) is greater than the Image Geometry Y extent (%2)").arg(getYMax()).arg(static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getYPoints()) - 1);
    notifyErrorMessage(getHumanLabel(), ss, -5550);
    setErrorCondition(-5550);
  }

  if (getZMax() > (static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getZPoints()) - 1))
  {
    QString ss = QObject::tr("The Z Max (%1) is greater than the Image Geometry Z extent (%2)").arg(getZMax()).arg(static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getZPoints()) - 1);
    notifyErrorMessage(getHumanLabel(), ss, -5550);
    setErrorCondition(-5550);
  }

  QVector<size_t> tDims(3, 0);
  if (getXMax() - getXMin() < 0) { setXMax(getXMin() + 1); }
  if (getYMax() - getYMin() < 0) { setYMax(getYMin() + 1); }
  if (getZMax() - getZMin() < 0) { setZMax(getZMin() + 1); }
  tDims[0] = (getXMax() - getXMin()) + 1;
  tDims[1] = (getYMax() - getYMin()) + 1;
  tDims[2] = (getZMax() - getZMin()) + 1;

  destCellDataContainer->getGeometryAs<ImageGeom>()->setDimensions(tDims[0], tDims[1], tDims[2]);

  // If any of the sanity checks fail above then we should NOT attempt to go any further.
  if (getErrorCondition() < 0) { return; }

  size_t totalPoints = 1;
  for(int i = 0; i < 3; i++) {
    if(tDims[i] != 0) { totalPoints *= tDims[i]; }
  }
  AttributeMatrix::Pointer newCellAttrMat = AttributeMatrix::New(tDims, destCellAttrMat->getName(), destCellAttrMat->getType());

  QList<QString> voxelArrayNames = destCellAttrMat->getAttributeArrayNames();
  for (QList<QString>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter)
  {
    IDataArray::Pointer p = destCellAttrMat->getAttributeArray(*iter);
    //
    IDataArray::Pointer data = p->createNewArray(totalPoints, p->getComponentDimensions(), p->getName(), false);

    destCellAttrMat->removeAttributeArray(*iter);
    newCellAttrMat->addAttributeArray(*iter, data);
  }
  destCellDataContainer->removeAttributeMatrix(destCellAttrMat->getName());
  destCellDataContainer->addAttributeMatrix(newCellAttrMat->getName(), newCellAttrMat);


  if(m_RenumberFeatures == true)
  {
    QVector<size_t> cDims(1, 1);
    m_FeatureIdsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getFeatureIdsArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */
    if( NULL != m_FeatureIdsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */
    {
      m_FeatureIds = m_FeatureIdsPtr.lock()->getPointer(0);
    } /* Now assign the raw pointer to data from the DataArray<T> object */

    AttributeMatrix::Pointer cellFeatureAttrMat = srcCellDataContainer->getAttributeMatrix(getCellFeatureAttributeMatrixPath().getAttributeMatrixName());
    if(NULL == cellFeatureAttrMat.get()) { return; }
    QVector<bool> activeObjects(cellFeatureAttrMat->getNumTuples(), true);
    cellFeatureAttrMat->removeInactiveObjects(activeObjects, m_FeatureIdsPtr.lock());
  }
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void RegularizeZSpacing::execute()
{
    setErrorCondition(0);
    dataCheck();
    if(getErrorCondition() < 0) {
        return;
    }

    DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getCellAttributeMatrixPath().getDataContainerName());

    size_t dims[3];
    m->getGeometryAs<ImageGeom>()->getDimensions(dims);

    std::ifstream inFile;
    inFile.open(m_InputFile.toLatin1().data());

    float zval = 0.0f;
    std::vector<float> zboundvalues(dims[2] + 1, 0.0);
    for (size_t iter = 0; iter < dims[2] + 1; iter++)
    {
        inFile >> zval;
        zboundvalues[iter] = zval;
    }
    inFile.close();

    float xRes = m->getGeometryAs<ImageGeom>()->getXRes();
    float yRes = m->getGeometryAs<ImageGeom>()->getYRes();

    float sizez = zboundvalues[dims[2]];
    size_t m_XP = dims[0];
    size_t m_YP = dims[1];
    size_t m_ZP = static_cast<size_t>(sizez / m_NewZRes);
    if (m_ZP == 0) {
        m_ZP = 1;
    }
    size_t totalPoints = m_XP * m_YP * m_ZP;

    size_t index = 0, oldindex = 0;
    size_t plane = 0;
    std::vector<size_t> newindicies(totalPoints, 0);
    for (size_t i = 0; i < m_ZP; i++)
    {
        plane = 0;
        for (size_t iter = 1; iter < dims[2]; iter++)
        {
            if ((i * m_NewZRes) > zboundvalues[iter]) {
                plane = iter;
            }
        }
        for (size_t j = 0; j < m_YP; j++)
        {
            for (size_t k = 0; k < m_XP; k++)
            {
                oldindex = (plane * dims[0] * dims[1]) + (j * dims[0]) + k;
                index = (i * dims[0] * dims[1]) + (j * dims[0]) + k;
                newindicies[index] = oldindex;
            }
        }
    }

    AttributeMatrix::Pointer cellAttrMat = m->getAttributeMatrix(getCellAttributeMatrixPath().getAttributeMatrixName());
    QVector<size_t> tDims(3, 0);
    tDims[0] = m_XP;
    tDims[1] = m_YP;
    tDims[2] = m_ZP;
    AttributeMatrix::Pointer newCellAttrMat = AttributeMatrix::New(tDims, cellAttrMat->getName(), cellAttrMat->getType());

    QList<QString> voxelArrayNames = cellAttrMat->getAttributeArrayNames();
    for (QList<QString>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter)
    {
        IDataArray::Pointer p = cellAttrMat->getAttributeArray(*iter);
        // Make a copy of the 'p' array that has the same name. When placed into
        // the data container this will over write the current array with
        // the same name. At least in theory
        IDataArray::Pointer data = p->createNewArray(p->getNumberOfTuples(), p->getComponentDimensions(), p->getName());
        data->resize(totalPoints);
        void* source = NULL;
        void* destination = NULL;
        size_t newIndicies_I = 0;
        int nComp = data->getNumberOfComponents();
        for (size_t i = 0; i < static_cast<size_t>(totalPoints); i++)
        {
            newIndicies_I = newindicies[i];

            source = p->getVoidPointer((nComp * newIndicies_I));
            destination = data->getVoidPointer((data->getNumberOfComponents() * i));
            ::memcpy(destination, source, p->getTypeSize() * data->getNumberOfComponents());
        }
        cellAttrMat->removeAttributeArray(*iter);
        newCellAttrMat->addAttributeArray(*iter, data);
    }
    m->getGeometryAs<ImageGeom>()->setResolution(xRes, yRes, m_NewZRes);
    m->getGeometryAs<ImageGeom>()->setDimensions(m_XP, m_YP, m_ZP);
    m->removeAttributeMatrix(getCellAttributeMatrixPath().getAttributeMatrixName());
    m->addAttributeMatrix(getCellAttributeMatrixPath().getAttributeMatrixName(), newCellAttrMat);

    notifyStatusMessage(getHumanLabel(), "Complete");
}