// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void RegularizeZSpacing::dataCheck()
{
    setErrorCondition(0);

    if (getNewZRes() <= 0)
    {
        QString ss = QObject::tr("The new Z resolution Y (%1) must be positive").arg(getNewZRes());
        setErrorCondition(-5555);
        notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
    }

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

    if (!inFile.good())
    {
        QString ss = QObject::tr("Unable to open input file with name '%1'").arg(getInputFile());
        setErrorCondition(-5556);
        notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
        return;
    }

    ImageGeom::Pointer image = getDataContainerArray()->getPrereqGeometryFromDataContainer<ImageGeom, AbstractFilter>(this, getCellAttributeMatrixPath().getDataContainerName());
    AttributeMatrix::Pointer cellAttrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, getCellAttributeMatrixPath(), -301);
    if(getErrorCondition() < 0) {
        return;
    }

    float zval = 0.0f;
    for (size_t iter = 0; iter < image->getZPoints() + 1; iter++)
    {
        inFile >> zval;
    }
    size_t zP = static_cast<size_t>(zval / getNewZRes());
    if(zP == 0) {
        zP = 1;
    }

    if (getInPreflight())
    {
        image->setDimensions(image->getXPoints(), image->getYPoints(), zP);
        QVector<size_t> tDims(3, 0);
        tDims[0] = image->getXPoints();
        tDims[1] = image->getYPoints();
        tDims[2] = zP;
        cellAttrMat->resizeAttributeArrays(tDims);
    }

    inFile.close();
}
Example #2
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void InsertAtoms::assign_points(QVector<VertexGeom::Pointer> points, QVector<BoolArrayType::Pointer> inFeature)
{
  size_t count = 0;
  int32_t numFeatures = points.size();
  for (int32_t i = 0; i < numFeatures; i++)
  {
    int64_t numPoints = points[i]->getNumberOfVertices();
    bool* inside = inFeature[i]->getPointer(0);
    for (int64_t j = 0; j < numPoints; j++)
    {
      if (inside[j] == true) { count++; }
    }
  }

  DataContainer::Pointer v = getDataContainerArray()->getDataContainer(getVertexDataContainerName());
  VertexGeom::Pointer vertices = VertexGeom::CreateGeometry(count, DREAM3D::VertexData::SurfaceMeshNodes);

  AttributeMatrix::Pointer vertexAttrMat = v->getAttributeMatrix(getVertexAttributeMatrixName());
  QVector<size_t> tDims(1, count);
  vertexAttrMat->resizeAttributeArrays(tDims);
  updateVertexInstancePointers();

  count = 0;
  float coords[3] = { 0.0f, 0.0f, 0.0f };
  for (int32_t i = 0; i < numFeatures; i++)
  {
    int64_t numPoints = points[i]->getNumberOfVertices();
    bool* inside = inFeature[i]->getPointer(0);
    for (int64_t j = 0; j < numPoints; j++)
    {
      if (inside[j] == true)
      {
        coords[0] = points[i]->getVertexPointer(j)[0];
        coords[1] = points[i]->getVertexPointer(j)[1];
        coords[2] = points[i]->getVertexPointer(j)[2];
        vertices->setCoords(count, coords);
        m_AtomFeatureLabels[count] = i;
        count++;
      }
    }
  }
  v->setGeometry(vertices);
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void InitializeSyntheticVolume::execute()
{
  setErrorCondition(0);
  dataCheck();
  if(getErrorCondition() < 0) { return; }

  DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getDataContainerName());
  AttributeMatrix::Pointer cellAttrMat = m->getAttributeMatrix(getCellAttributeMatrixName());

  // Resize the Cell AttributeMatrix to have the correct Tuple Dimensions.
  QVector<size_t> tDims(3, 0);
  tDims[0] = m->getGeometryAs<ImageGeom>()->getXPoints();
  tDims[1] = m->getGeometryAs<ImageGeom>()->getYPoints();
  tDims[2] = m->getGeometryAs<ImageGeom>()->getZPoints();
  cellAttrMat->resizeAttributeArrays(tDims);

  // If there is an error set this to something negative and also set a message
  notifyStatusMessage(getHumanLabel(), "Complete");
}
Example #4
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int32_t EnsembleInfoReader::readFile()
{
  setErrorCondition(0);
  dataCheck();
  if(getErrorCondition() < 0) { return getErrorCondition(); }

  DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getDataContainerName());
  AttributeMatrix::Pointer cellensembleAttrMat = m->getAttributeMatrix(getCellEnsembleAttributeMatrixName());

  int32_t numphases = 0;

  QSettings settings(getInputFile(), QSettings::IniFormat); // The .ini or .txt input file
  settings.beginGroup("EnsembleInfo");
  numphases = settings.value("Number_Phases").toInt(); // read number of phases from input file
  settings.endGroup();

  if (0 == numphases) // Either the group name "EnsembleInfo" is incorrect or 0 was entered as the Number_Phases
  {
    QString ss = QObject::tr("Check the group name EnsembleInfo and that Number_Phases > 0");
    setErrorCondition(-10003);
    notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
    return -1;
  }

  // Figure out if we are reading contiguous groups
  std::vector<bool> visited(numphases + 1, false);
  visited[0] = true; //this is DREAM3D's internal, which is always visited.

  QVector<size_t> tDims(1, numphases + 1);
  cellensembleAttrMat->resizeAttributeArrays(tDims);
  updateEnsembleInstancePointers();
  for (int32_t index = 1; index < numphases + 1; index++)
  {
    QString group = QString::number(index);
    settings.beginGroup(group);

    QString xtalString = settings.value(DREAM3D::StringConstants::CrystalStructure, "MissingCrystalStructure").toString();
    QString phaseTypeString = settings.value(DREAM3D::StringConstants::PhaseType, "MissingPhaseType").toString();
    // Check to make sure the user has something for each of the Crystal Structure and Phase Type
    if (xtalString.compare("MissingCrystalStructure") == 0)
    {
      QString ss = QObject::tr("Missing crystal structure for phase '%1'").arg(group);
      setErrorCondition(-10008);
      notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
      return -1;
    }

    if (phaseTypeString.compare("MissingPhaseType") == 0)
    {
      QString ss = QObject::tr("Missing phase type for phase '%1'").arg(group);
      setErrorCondition(-10009);
      notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
      return -1;
    }

    // Past that sanity check, so we have values, lets parse them
    QStringList values;
    values << xtalString << phaseTypeString;

    ensembleLookup(values); // Lookup number for the crystal number string and the phase type string read from the file

    // Check to see if the Crystal Structure string was valid
    if (m_crystruct == Ebsd::CrystalStructure::UnknownCrystalStructure) // The crystal structure name read from the file was not found in the lookup table
    {
      QString ss = QObject::tr("Incorrect crystal structure name '%1'").arg(xtalString);
      setErrorCondition(-10006);
      notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
      return -1;
    }
    else
    {
      m_CrystalStructures[index] = m_crystruct;
    }

    // now check to see if the Phase type string was valid.
    if (m_ptype == DREAM3D::PhaseType::UnknownPhaseType)
    {
      QString ss = QObject::tr("Incorrect phase type name '%1'").arg(phaseTypeString); // The phase type name read from the file was not found in the lookup table
      setErrorCondition(-10007);
      notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
      return -1;
    }
    else
    {
      m_PhaseTypes[index] = m_ptype;
    }

    visited[index] = true;
    // Close up this group
    settings.endGroup();
  }

  //Make sure we visited all the groups.
  for(std::vector<bool>::size_type i = 0; i < visited.size(); i++)
  {
    if(visited[i] == false)
    {
      QString ss = QObject::tr("Phase '%1' did not have entries in the file. Phase numbering must start at 1 and no phases may be skipped").arg(i); // The phase type name read from the file was not found in the lookup table
      setErrorCondition(-10005);
      notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
      return -1;
    }
  }

  notifyStatusMessage(getHumanLabel(), "Complete");
  return 0;
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void SharedFeatureFaceFilter::execute()
{
  setErrorCondition(0);
  dataCheck();
  if(getErrorCondition() < 0) { return; }

  DataContainer::Pointer sm = getDataContainerArray()->getDataContainer(m_SurfaceMeshFaceLabelsArrayPath.getDataContainerName());
  AttributeMatrix::Pointer faceFeatureAttrMat = sm->getAttributeMatrix(getFaceFeatureAttributeMatrixName());

  TriangleGeom::Pointer triangleGeom = sm->getGeometryAs<TriangleGeom>();
  int64_t totalPoints = triangleGeom->getNumberOfTris();

  QMap<uint64_t, int32_t> faceSizeMap;
  QMap<uint64_t, int32_t> faceIdMap; // This maps a unique 64 bit integer to an increasing 32 bit integer
  int32_t index = 1;
  struct { int g; int r; } faceId;
  uint64_t* faceId_64 = reinterpret_cast<uint64_t*>(&faceId);
  int32_t fl0 = -1;
  int32_t fl1 = -1;

  std::vector< std::pair<int32_t, int32_t> > faceLabelMap;
  faceLabelMap.push_back( std::pair<int32_t, int32_t>(0, 0) );

  // Loop through all the Triangles and figure out how many triangles we have in each one.
  for (int64_t t = 0; t < totalPoints; ++t)
  {
    fl0 = m_SurfaceMeshFaceLabels[t * 2];
    fl1 = m_SurfaceMeshFaceLabels[t * 2 + 1];
    if (fl0 < fl1)
    {
      faceId.g = fl0;
      faceId.r = fl1;
    }
    else
    {
      faceId.g = fl1;
      faceId.r = fl0;
    }

    QMap<uint64_t, int32_t>::iterator iter = faceSizeMap.find(*faceId_64);
    if (iter == faceSizeMap.end())
    {
      faceSizeMap[*faceId_64] = 1;
      faceIdMap[*faceId_64] = index;
      m_SurfaceMeshFeatureFaceIds[t] = index;
      faceLabelMap.push_back( std::pair<int32_t, int32_t>(faceId.g, faceId.r) );
      ++index;
    }
    else
    {
      iter.value()++;
      m_SurfaceMeshFeatureFaceIds[t] = faceIdMap[*faceId_64];
    }
  }

  // resize + update pointers
  QVector<size_t> tDims(1, index);
  faceFeatureAttrMat->resizeAttributeArrays(tDims);
  m_SurfaceMeshFeatureFaceLabels = m_SurfaceMeshFeatureFaceLabelsPtr.lock()->getPointer(0);
  m_SurfaceMeshFeatureFaceNumTriangles = m_SurfaceMeshFeatureFaceNumTrianglesPtr.lock()->getPointer(0);

  for (int32_t i = 0; i < index; i++)
  {
    // get feature face labels
    m_SurfaceMeshFeatureFaceLabels[2 * i + 0] = faceLabelMap[i].first;
    m_SurfaceMeshFeatureFaceLabels[2 * i + 1] = faceLabelMap[i].second;

    // get feature triangle count
    faceId.g = faceLabelMap[i].first;
    faceId.r = faceLabelMap[i].second;
    m_SurfaceMeshFeatureFaceNumTriangles[i] = faceSizeMap[*faceId_64];
  }

  /* Let the GUI know we are done with this filter */
  notifyStatusMessage(getHumanLabel(), "Complete");
}