// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- bool DataContainer::renameAttributeMatrix(const QString& oldname, const QString& newname, bool overwrite) { QMap<QString, AttributeMatrix::Pointer>::iterator it; it = m_AttributeMatrices.find(oldname); if ( it == m_AttributeMatrices.end() ) { return false; } AttributeMatrix::Pointer p = it.value(); p->setName(newname); removeAttributeMatrix(oldname); // Now check to make sure there isn't one with the same name it = m_AttributeMatrices.find(newname); if ( it == m_AttributeMatrices.end() ) // Didn't find another AttributeMatrix with the new name { addAttributeMatrix(newname, p); } else if(overwrite == true) // We are here because we found another attribute matrix with the new name { AttributeMatrix::Pointer removedAttributeMatrix = removeAttributeMatrix(newname); // Remove the existing one addAttributeMatrix(newname, p); } else { return false; } return true; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void EstablishShapeTypes::dataCheck() { setErrorCondition(0); DataArrayPath tempPath; DataContainerArray::Pointer dca = getDataContainerArray(); QVector<size_t> cDims(1, 1); m_PhaseTypesPtr = dca->getPrereqArrayFromPath<DataArray<uint32_t>, AbstractFilter>(this, getInputPhaseTypesArrayPath(), cDims); if( NULL != m_PhaseTypesPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_PhaseTypes = m_PhaseTypesPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ // Get the DataContainer first - same as phase types DataContainer::Pointer m = dca->getPrereqDataContainer<AbstractFilter>(this, getInputPhaseTypesArrayPath().getDataContainerName()); if(getErrorCondition() < 0) { return; } // Now get the AttributeMatrix that the user wants to use to store the ShapeTypes array - same as phase types AttributeMatrix::Pointer cellEnsembleAttrMat = m->getPrereqAttributeMatrix<AbstractFilter>(this, getInputPhaseTypesArrayPath().getAttributeMatrixName(), -990); if(getErrorCondition() < 0 || NULL == cellEnsembleAttrMat.get()) { return; } // Now create the output Shape Types Array tempPath.update(getInputPhaseTypesArrayPath().getDataContainerName(), getInputPhaseTypesArrayPath().getAttributeMatrixName(), getShapeTypesArrayName() ); m_ShapeTypesPtr = getDataContainerArray()->createNonPrereqArrayFromPath<UInt32ArrayType, AbstractFilter>(this, tempPath, true, cDims); /* Assigns the shared_ptr<>(this, tempPath, true, dims); Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_ShapeTypesPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_ShapeTypes = m_ShapeTypesPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int BoundaryPhaseWidget::gatherStatsData(AttributeMatrix::Pointer attrMat) { if (m_PhaseIndex < 1) { QMessageBox::critical(this, tr("StatsGenerator"), tr("The Phase Index is Less than 1. This is not allowed."), QMessageBox::Default); return -1; } int retErr = 0; float calcPhaseFraction = m_PhaseFraction / m_TotalPhaseFraction; //size_t ensembles = attrMat->getNumTuples(); // Get pointers IDataArray::Pointer iDataArray = attrMat->getAttributeArray(DREAM3D::EnsembleData::CrystalStructures); unsigned int* crystalStructures = boost::dynamic_pointer_cast< UInt32ArrayType >(iDataArray)->getPointer(0); iDataArray = attrMat->getAttributeArray(DREAM3D::EnsembleData::PhaseTypes); unsigned int* phaseTypes = boost::dynamic_pointer_cast< UInt32ArrayType >(iDataArray)->getPointer(0); crystalStructures[m_PhaseIndex] = m_CrystalStructure; phaseTypes[m_PhaseIndex] = m_PhaseType; StatsDataArray* statsDataArray = StatsDataArray::SafeObjectDownCast<IDataArray*, StatsDataArray*>(attrMat->getAttributeArray(DREAM3D::EnsembleData::Statistics).get()); if (NULL != statsDataArray) { StatsData::Pointer statsData = statsDataArray->getStatsData(m_PhaseIndex); BoundaryStatsData* boundaryStatsData = BoundaryStatsData::SafePointerDownCast(statsData.get()); boundaryStatsData->setPhaseFraction(calcPhaseFraction); } return retErr; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void BoundaryPhaseWidget::extractStatsData(AttributeMatrix::Pointer attrMat, int index) { setPhaseIndex(index); IDataArray::Pointer iDataArray = attrMat->getAttributeArray(DREAM3D::EnsembleData::CrystalStructures); unsigned int* attributeArray = boost::dynamic_pointer_cast< UInt32ArrayType >(iDataArray)->getPointer(0); m_CrystalStructure = attributeArray[index]; iDataArray = attrMat->getAttributeArray(DREAM3D::EnsembleData::PhaseTypes); attributeArray = boost::dynamic_pointer_cast< UInt32ArrayType >(iDataArray)->getPointer(0); m_PhaseType = attributeArray[index]; iDataArray = attrMat->getAttributeArray(DREAM3D::EnsembleData::Statistics); StatsDataArray* statsDataArray = StatsDataArray::SafeObjectDownCast<IDataArray*, StatsDataArray*>(iDataArray.get()); if (statsDataArray == NULL) { return; } StatsData::Pointer statsData = statsDataArray->getStatsData(index); BoundaryStatsData* boundaryStatsData = BoundaryStatsData::SafePointerDownCast(statsData.get()); m_PhaseFraction = boundaryStatsData->getPhaseFraction(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void RegularGridSampleSurfaceMesh::dataCheck() { setErrorCondition(0); DataArrayPath tempPath; DataContainer::Pointer m = getDataContainerArray()->createNonPrereqDataContainer<AbstractFilter>(this, getDataContainerName()); if (getErrorCondition() < 0) { return; } ImageGeom::Pointer image = ImageGeom::CreateGeometry(DREAM3D::Geometry::ImageGeometry); m->setGeometry(image); // Set the Dimensions, Resolution and Origin of the output data container m->getGeometryAs<ImageGeom>()->setDimensions(m_XPoints, m_YPoints, m_ZPoints); m->getGeometryAs<ImageGeom>()->setResolution(m_Resolution.x, m_Resolution.y, m_Resolution.z); m->getGeometryAs<ImageGeom>()->setOrigin(m_Origin.x, m_Origin.y, m_Origin.z); QVector<size_t> tDims(3, 0); tDims[0] = m_XPoints; tDims[1] = m_YPoints; tDims[2] = m_ZPoints; AttributeMatrix::Pointer cellAttrMat = m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCellAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::Cell); if (getErrorCondition() < 0 || NULL == cellAttrMat.get()) { return; } QVector<size_t> cDims(1, 1); tempPath.update(getDataContainerName(), getCellAttributeMatrixName(), getFeatureIdsArrayName() ); m_FeatureIdsPtr = 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_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 */ }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void CopyAttributeArray::dataCheck() { setErrorCondition(0); if(m_NewArrayName.isEmpty() == true) { setErrorCondition(-11009); QString ss = QObject::tr("The new Attribute Array name must be set"); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } QString daName = getSelectedArrayPath().getDataArrayName(); IDataArray::Pointer dataArray = getDataContainerArray()->getPrereqIDataArrayFromPath<IDataArray, AbstractFilter>(this, getSelectedArrayPath()); if(getErrorCondition() < 0) { return; } DataArrayPath path(getSelectedArrayPath().getDataContainerName(), getSelectedArrayPath().getAttributeMatrixName(), ""); AttributeMatrix::Pointer attrMat = getDataContainerArray()->getAttributeMatrix(path); IDataArray::Pointer pNew = dataArray->deepCopy(); pNew->setName(m_NewArrayName); // Set the name of the array int32_t err = attrMat->addAttributeArray(m_NewArrayName, pNew); if (0 != err) { setErrorCondition(err); QString ss = QObject::tr("Attempt to copy Attribute Array '%1' to '%2' failed").arg(daName).arg(m_NewArrayName); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } }
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); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ChangeResolution::preflight() { setInPreflight(true); emit preflightAboutToExecute(); emit updateFilterParameters(this); dataCheck(); if (getErrorCondition() < 0) { emit preflightExecuted(); setInPreflight(false); return; } DataContainer::Pointer m; if (m_SaveAsNewDataContainer == false) { m = getDataContainerArray()->getDataContainer(getCellAttributeMatrixPath().getDataContainerName()); } else { m = getDataContainerArray()->getDataContainer(getNewDataContainerName()); } 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; } m->getGeometryAs<ImageGeom>()->setDimensions(m_XP, m_YP, m_ZP); m->getGeometryAs<ImageGeom>()->setResolution(m_Resolution.x, m_Resolution.y, m_Resolution.z); QVector<size_t> tDims(3, 0); tDims[0] = m_XP; tDims[1] = m_YP; tDims[2] = m_ZP; m->getAttributeMatrix(getCellAttributeMatrixPath().getAttributeMatrixName())->setTupleDimensions(tDims); if (m_RenumberFeatures == true) { AttributeMatrix::Pointer cellFeatureAttrMat = m->getAttributeMatrix(getCellFeatureAttributeMatrixPath().getAttributeMatrixName()); QVector<bool> activeObjects(cellFeatureAttrMat->getNumTuples(), true); cellFeatureAttrMat->removeInactiveObjects(activeObjects, m_FeatureIdsPtr.lock()); } emit preflightExecuted(); setInPreflight(false); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void DataContainer::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) { if (data->getName().compare(name) != 0) { qDebug() << "Adding Attribute Matrix with different array name than key name"; qDebug() << "Key name: " << name; qDebug() << "Array Name: " << data->getName(); qDebug() << "This action is NOT typical of DREAM3D Usage. Are you sure you want to be doing this? We are forcing the name of the AttributeMatrix to be the same as the key"; data->setName(name); } m_AttributeMatrices[name] = data; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void CombineAttributeMatrices::execute() { setErrorCondition(0); dataCheck(); if (getErrorCondition() < 0) { return; } DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getFirstAttributeMatrixPath().getDataContainerName()); AttributeMatrix::Pointer firstAttrMat = m->getAttributeMatrix(getFirstAttributeMatrixPath().getAttributeMatrixName()); AttributeMatrix::Pointer secondAttrMat = m->getAttributeMatrix(getSecondAttributeMatrixPath().getAttributeMatrixName()); AttributeMatrix::Pointer combinedAttrMat = m->getAttributeMatrix(getCombinedAttributeMatrixName()); size_t firstAttrMatNumTuples = firstAttrMat->getNumTuples(); size_t totalTuples1 = m_SecondIndexPtr.lock()->getNumberOfTuples(); size_t totalTuples2 = m_SecondIndexPtr.lock()->getNumberOfTuples(); for (size_t i = 0; i < totalTuples1; i++) { if (m_FirstIndex > 0) { m_NewIndex[i] = m_FirstIndex[i]; } } for (size_t i = 0; i < totalTuples2; i++) { //subtract 1 from the index plus numTuples because the second index should be shifted to account for the zeroth tuple (all AMs above element start at tuple 1) if (m_SecondIndex[i] > 0 && m_NewIndex[i] == 0) m_NewIndex[i] = m_SecondIndex[i] + firstAttrMatNumTuples - 1; else if (m_SecondIndex[i] > 0 && m_NewIndex[i] != 0) { QString ss = QObject::tr("When copying the indices, the indices of the two attribute matrices overlapped. The index of the first attribute matrix was kept."); notifyWarningMessage(getHumanLabel(), ss, -111); } } QList<QString> arrayNames = firstAttrMat->getAttributeArrayNames(); size_t location = 0; for (QList<QString>::iterator iter = arrayNames.begin(); iter != arrayNames.end(); ++iter) { IDataArray::Pointer fromDataArray = firstAttrMat->getAttributeArray(*iter); IDataArray::Pointer toDataArray = combinedAttrMat->getAttributeArray(*iter); EXECUTE_FUNCTION_TEMPLATE(this, copyData, fromDataArray, fromDataArray, toDataArray, location); } arrayNames.clear(); arrayNames = secondAttrMat->getAttributeArrayNames(); location = firstAttrMatNumTuples; for (QList<QString>::iterator iter = arrayNames.begin(); iter != arrayNames.end(); ++iter) { IDataArray::Pointer fromDataArray = secondAttrMat->getAttributeArray(*iter); IDataArray::Pointer toDataArray = combinedAttrMat->getAttributeArray(*iter); EXECUTE_FUNCTION_TEMPLATE(this, copyData, fromDataArray, fromDataArray, toDataArray, location); } notifyStatusMessage(getHumanLabel(), "Complete"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void MoveData::dataCheck() { setErrorCondition(0); DataArrayPath amSrcPath = getAttributeMatrixSource(); DataArrayPath amDestPath = getAttributeMatrixDestination(); DataArrayPath daSrcPath = getDataArraySource(); if (getWhatToMove() == k_MoveAttributeMatrix) { DataContainer::Pointer amDestDataContainer = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getDataContainerDestination()); DataContainer::Pointer amSrcDataContainer = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, amSrcPath.getDataContainerName()); AttributeMatrix::Pointer amSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, amSrcPath, -301); if(getErrorCondition() < 0) { return; } if (amSrcDataContainer->getName() == amDestDataContainer->getName()) { QString ss = QObject::tr("The source and destination Data Container are the same. Is this what you meant to do?"); notifyWarningMessage(getHumanLabel(), ss, getErrorCondition()); return; } amDestDataContainer->addAttributeMatrix(amSrcAttributeMatrix->getName(), amSrcAttributeMatrix); amSrcDataContainer->removeAttributeMatrix(amSrcAttributeMatrix->getName()); } else if (getWhatToMove() == k_MoveDataArray ) { AttributeMatrix::Pointer daSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, daSrcPath, -301); AttributeMatrix::Pointer daDestAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, amDestPath, -301); IDataArray::Pointer daSrcDataArray = getDataContainerArray()->getPrereqIDataArrayFromPath<IDataArray, AbstractFilter>(this, daSrcPath); if(getErrorCondition() < 0) { return; } if (daDestAttributeMatrix->getNumTuples() != daSrcDataArray->getNumberOfTuples()) { setErrorCondition(-11019); QString ss = QObject::tr("The number of tuples of source Attribute Array (%1) and destination Attribute Matrix (%2) do not match").arg(daSrcDataArray->getNumberOfTuples()).arg(daDestAttributeMatrix->getNumTuples()); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } else if (amSrcPath == amDestPath) { QString ss = QObject::tr("The source and destination Attribute Matrix are the same. Is this what you meant to do?"); notifyWarningMessage(getHumanLabel(), ss, getErrorCondition()); return; } daDestAttributeMatrix->addAttributeArray(daSrcPath.getDataArrayName(), daSrcDataArray); daSrcAttributeMatrix->removeAttributeArray(daSrcPath.getDataArrayName()); } else { setErrorCondition(-11020); QString ss = QObject::tr("Neither an Attribute Matrix nor an Attribute Array was selected to be moved"); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QVector<DataArrayPath> DataContainer::getAllDataArrayPaths() { QVector<DataArrayPath> paths; for(QMap<QString, AttributeMatrix::Pointer>::iterator iter = m_AttributeMatrices.begin(); iter != m_AttributeMatrices.end(); ++iter) { AttributeMatrix::Pointer am = iter.value(); QString amName = am->getName(); QList<QString> aaNames = am->getAttributeArrayNames(); foreach(QString aaName, aaNames) { DataArrayPath dap(getName(), amName, aaName); paths.push_back(dap); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- AttributeMatrix::Pointer AttributeMatrix::deepCopy() { AttributeMatrix::Pointer newAttrMat = AttributeMatrix::New(getTupleDimensions(), getName(), getType()); for(QMap<QString, IDataArray::Pointer>::iterator iter = m_AttributeArrays.begin(); iter != m_AttributeArrays.end(); ++iter) { IDataArray::Pointer d = iter.value(); IDataArray::Pointer new_d = d->deepCopy(); if (new_d.get() == NULL) { return AttributeMatrix::NullPointer(); } newAttrMat->addAttributeArray(new_d->getName(), new_d); } return newAttrMat; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void InitializeSyntheticVolume::dataCheck() { setErrorCondition(0); // Create the output Data Container DataContainer::Pointer m = getDataContainerArray()->createNonPrereqDataContainer<AbstractFilter>(this, getDataContainerName()); if(getErrorCondition() < 0) { return; } ImageGeom::Pointer image = ImageGeom::CreateGeometry(DREAM3D::Geometry::ImageGeometry); m->setGeometry(image); // Sanity Check the Dimensions and Resolution INIT_SYNTH_VOLUME_CHECK(Dimensions.x, -5000); INIT_SYNTH_VOLUME_CHECK(Dimensions.y, -5001); INIT_SYNTH_VOLUME_CHECK(Dimensions.z, -5002); INIT_SYNTH_VOLUME_CHECK(Resolution.x, -5003); INIT_SYNTH_VOLUME_CHECK(Resolution.y, -5004); INIT_SYNTH_VOLUME_CHECK(Resolution.z, -5005); // Set the Dimensions, Resolution and Origin of the output data container m->getGeometryAs<ImageGeom>()->setDimensions(m_Dimensions.x, m_Dimensions.y, m_Dimensions.z); m->getGeometryAs<ImageGeom>()->setResolution(m_Resolution.x, m_Resolution.y, m_Resolution.z); m->getGeometryAs<ImageGeom>()->setOrigin(m_Origin.x, m_Origin.y, m_Origin.z); // Create our output Cell and Ensemble Attribute Matrix objects QVector<size_t> tDims(3, 0); tDims[0] = m_Dimensions.x; tDims[1] = m_Dimensions.y; tDims[2] = m_Dimensions.z; AttributeMatrix::Pointer cellAttrMat = m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCellAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::Cell); if(getErrorCondition() < 0 && cellAttrMat.get() == NULL) { return; } QVector<size_t> cDims(1, 1); // This states that we are looking for an array with a single component UInt32ArrayType::Pointer phaseType = getDataContainerArray()->getPrereqArrayFromPath<UInt32ArrayType, AbstractFilter>(this, getInputPhaseTypesArrayPath(), cDims); if(getErrorCondition() < 0 && phaseType.get() == NULL) { return; } QVector<size_t> statsDims(1, 1); StatsDataArray::Pointer statsPtr = getDataContainerArray()->getPrereqArrayFromPath<StatsDataArray, AbstractFilter>(this, getInputStatsArrayPath(), statsDims); if(getErrorCondition() < 0 && statsPtr.get() == NULL) { return; } if(m_EstimateNumberOfFeatures) { m_EstimatedPrimaryFeatures = estimateNumFeatures(m_Dimensions, m_Resolution); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void MinNeighbors::execute() { setErrorCondition(0); dataCheck(); if(getErrorCondition() < 0) { return; } // If running on a single phase, validate that the user has not entered a phase number // that is not in the system ; the filter would not crash otherwise, but the user should // be notified of unanticipated behavior ; this cannot be done in the dataCheck since // we don't have acces to the data yet if (m_ApplyToSinglePhase == true) { AttributeMatrix::Pointer featAttrMat = getDataContainerArray()->getDataContainer(getFeaturePhasesArrayPath().getDataContainerName())->getAttributeMatrix(getFeaturePhasesArrayPath().getAttributeMatrixName()); size_t numFeatures = featAttrMat->getNumTuples(); bool unavailablePhase = true; for (size_t i = 0; i < numFeatures; i++) { if (m_FeaturePhases[i] == m_PhaseNumber) { unavailablePhase = false; break; } } if (unavailablePhase == true) { QString ss = QObject::tr("The phase number (%1) is not available in the supplied Feature phases array with path (%2)").arg(m_PhaseNumber).arg(m_FeaturePhasesArrayPath.serialize()); setErrorCondition(-5555); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } } QVector<bool> activeObjects = merge_containedfeatures(); if(getErrorCondition() < 0) { return; } assign_badpoints(); DataContainer::Pointer m = getDataContainerArray()->getDataContainer(m_NumNeighborsArrayPath.getDataContainerName()); AttributeMatrix::Pointer cellFeatureAttrMat = m->getAttributeMatrix(m_NumNeighborsArrayPath.getAttributeMatrixName()); cellFeatureAttrMat->removeInactiveObjects(activeObjects, m_FeatureIdsPtr.lock()); // If there is an error set this to something negative and also set a message notifyStatusMessage(getHumanLabel(), "Complete"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- DataContainer::Pointer DataContainer::deepCopy() { DataContainer::Pointer dcCopy = DataContainer::New(getName()); dcCopy->setName(getName()); if (m_Geometry.get() != NULL) { IGeometry::Pointer geomCopy = m_Geometry->deepCopy(); dcCopy->setGeometry(geomCopy); } for (AttributeMatrixMap_t::iterator iter = getAttributeMatrices().begin(); iter != getAttributeMatrices().end(); ++iter) { AttributeMatrix::Pointer attrMat = (*iter)->deepCopy(); dcCopy->addAttributeMatrix(attrMat->getName(), attrMat); } return dcCopy; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void RemoveFlaggedFeatures::execute() { setErrorCondition(0); dataCheck(); if(getErrorCondition() < 0) { return; } QVector<bool> activeObjects = remove_flaggedfeatures(); if (m_FillRemovedFeatures == true) { assign_badpoints(); } AttributeMatrix::Pointer cellFeatureAttrMat = getDataContainerArray()->getAttributeMatrix(getFlaggedFeaturesArrayPath()); cellFeatureAttrMat->removeInactiveObjects(activeObjects, m_FeatureIdsPtr.lock()); // If there is an error set this to something negative and also set a message notifyStatusMessage(getHumanLabel(), "Remove Flagged Features Filter Complete"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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); }
int32_t readDataChunk(AttributeMatrix::Pointer attrMat, std::istream& in, bool inPreflight, bool binary, const QString& scalarName, int32_t scalarNumComp) { size_t numTuples = attrMat->getNumTuples(); QVector<size_t> tDims = attrMat->getTupleDimensions(); QVector<size_t> cDims(1, scalarNumComp); typename DataArray<T>::Pointer data = DataArray<T>::CreateArray(tDims, cDims, scalarName, !inPreflight); data->initializeWithZeros(); attrMat->addAttributeArray(data->getName(), data); if (inPreflight == true) { return skipVolume<T>(in, binary, numTuples * scalarNumComp); } else { if (binary) { int32_t err = vtkReadBinaryData<T>(in, data->getPointer(0), numTuples, scalarNumComp); if( err < 0 ) { std::cout << "Error Reading Binary Data '" << scalarName.toStdString() << "' " << attrMat->getName().toStdString() << " numTuples = " << numTuples << std::endl; return err; } if(BIGENDIAN == 0) {data->byteSwapElements(); } } else { T value = static_cast<T>(0.0); size_t totalSize = numTuples * scalarNumComp; for (size_t i = 0; i < totalSize; ++i) { in >> value; data->setValue(i, value); } } } return 0; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void SineParamsSegmentFeatures::dataCheck() { DataArrayPath tempPath; setErrorCondition(0); //Set the DataContainerName for the Parent Class (SegmentFeatures) to Use setDataContainerName(m_SineParamsArrayPath.getDataContainerName()); SegmentFeatures::dataCheck(); if(getErrorCondition() < 0) { return; } DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getDataContainerName(), false); if(getErrorCondition() < 0 || NULL == m) { return; } QVector<size_t> tDims(1, 0); AttributeMatrix::Pointer cellFeatureAttrMat = m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCellFeatureAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::CellFeature); if(getErrorCondition() < 0 || NULL == cellFeatureAttrMat.get()) { return; } ImageGeom::Pointer image = m->getPrereqGeometry<ImageGeom, AbstractFilter>(this); if(getErrorCondition() < 0 || NULL == image.get()) { return; } QVector<size_t> dims(1, 3); m_SineParamsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<float>, AbstractFilter>(this, getSineParamsArrayPath(), dims); if( NULL != m_SineParamsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SineParams = m_SineParamsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ dims[0] = 1; tempPath.update(getDataContainerName(), m_SineParamsArrayPath.getAttributeMatrixName(), getFeatureIdsArrayName() ); m_FeatureIdsPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter, int32_t>(this, tempPath, 0, dims); /* 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 */ if(m_UseGoodVoxels == true) { m_GoodVoxelsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<bool>, AbstractFilter>(this, getGoodVoxelsArrayPath(), dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_GoodVoxelsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_GoodVoxels = m_GoodVoxelsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ } tempPath.update(getDataContainerName(), getCellFeatureAttributeMatrixName(), getActiveArrayName() ); m_ActivePtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<bool>, AbstractFilter, bool>(this, tempPath, true, dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_ActivePtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_Active = m_ActivePtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void InsertAtoms::dataCheck() { setErrorCondition(0); DataArrayPath tempPath; TriangleGeom::Pointer triangles = getDataContainerArray()->getPrereqGeometryFromDataContainer<TriangleGeom, AbstractFilter>(this, getSurfaceMeshFaceLabelsArrayPath().getDataContainerName()); QVector<IDataArray::Pointer> dataArrays; if(getErrorCondition() >= 0) { dataArrays.push_back(triangles->getTriangles()); } DataContainer::Pointer v = getDataContainerArray()->createNonPrereqDataContainer<AbstractFilter>(this, getVertexDataContainerName()); if(getErrorCondition() < 0) { return; } VertexGeom::Pointer vertices = VertexGeom::CreateGeometry(0, DREAM3D::Geometry::VertexGeometry); v->setGeometry(vertices); QVector<size_t> tDims(1, 0); AttributeMatrix::Pointer vertexAttrMat = v->createNonPrereqAttributeMatrix<AbstractFilter>(this, getVertexAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::Vertex); if(getErrorCondition() < 0 || NULL == vertexAttrMat.get()) { return; } QVector<size_t> cDims(1, 2); m_SurfaceMeshFaceLabelsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getSurfaceMeshFaceLabelsArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_SurfaceMeshFaceLabelsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceMeshFaceLabels = m_SurfaceMeshFaceLabelsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ if(getErrorCondition() >= 0) { dataArrays.push_back(m_SurfaceMeshFaceLabelsPtr.lock()); } cDims[0] = 4; m_AvgQuatsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<float>, AbstractFilter>(this, getAvgQuatsArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_AvgQuatsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_AvgQuats = m_AvgQuatsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ cDims[0] = 1; tempPath.update(getVertexDataContainerName(), getVertexAttributeMatrixName(), getAtomFeatureLabelsArrayName() ); m_AtomFeatureLabelsPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter, int32_t>(this, tempPath, -301, cDims); /* Assigns the shared_ptr<>(this, tempPath, -301, dims); Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_AtomFeatureLabelsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_AtomFeatureLabels = m_AtomFeatureLabelsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ getDataContainerArray()->validateNumberOfTuples<AbstractFilter>(this, dataArrays); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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 SharedFeatureFaceFilter::dataCheck() { setErrorCondition(0); DataArrayPath tempPath; getDataContainerArray()->getPrereqGeometryFromDataContainer<TriangleGeom, AbstractFilter>(this, getSurfaceMeshFaceLabelsArrayPath().getDataContainerName()); DataContainer::Pointer sm = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, m_SurfaceMeshFaceLabelsArrayPath.getDataContainerName(), false); if(getErrorCondition() < 0) { return; } QVector<size_t> tDims(1, 0); AttributeMatrix::Pointer facefeatureAttrMat = sm->createNonPrereqAttributeMatrix<AbstractFilter>(this, getFaceFeatureAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::FaceFeature); if(getErrorCondition() < 0 || NULL == facefeatureAttrMat.get()) { return; } QVector<size_t> cDims(1, 2); m_SurfaceMeshFaceLabelsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getSurfaceMeshFaceLabelsArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_SurfaceMeshFaceLabelsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceMeshFaceLabels = m_SurfaceMeshFaceLabelsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ cDims[0] = 1; tempPath.update(m_SurfaceMeshFaceLabelsArrayPath.getDataContainerName(), m_SurfaceMeshFaceLabelsArrayPath.getAttributeMatrixName(), getSurfaceMeshFeatureFaceIdsArrayName() ); m_SurfaceMeshFeatureFaceIdsPtr = 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_SurfaceMeshFeatureFaceIdsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceMeshFeatureFaceIds = m_SurfaceMeshFeatureFaceIdsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ tempPath.update(m_SurfaceMeshFaceLabelsArrayPath.getDataContainerName(), getFaceFeatureAttributeMatrixName(), getSurfaceMeshFeatureFaceNumTrianglesArrayName() ); m_SurfaceMeshFeatureFaceNumTrianglesPtr = 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_SurfaceMeshFeatureFaceNumTrianglesPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceMeshFeatureFaceNumTriangles = m_SurfaceMeshFeatureFaceNumTrianglesPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ cDims[0] = 2; tempPath.update(m_SurfaceMeshFaceLabelsArrayPath.getDataContainerName(), getFaceFeatureAttributeMatrixName(), getSurfaceMeshFeatureFaceLabelsArrayName() ); m_SurfaceMeshFeatureFaceLabelsPtr = 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_SurfaceMeshFeatureFaceLabelsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceMeshFeatureFaceLabels = m_SurfaceMeshFeatureFaceLabelsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void NearestPointFuseRegularGrids::dataCheck() { setErrorCondition(0); getDataContainerArray()->getPrereqGeometryFromDataContainer<ImageGeom, AbstractFilter>(this, getReferenceCellAttributeMatrixPath().getDataContainerName()); getDataContainerArray()->getPrereqGeometryFromDataContainer<ImageGeom, AbstractFilter>(this, getSamplingCellAttributeMatrixPath().getDataContainerName()); AttributeMatrix::Pointer refAttrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, getReferenceCellAttributeMatrixPath(), -301); AttributeMatrix::Pointer sampleAttrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, getSamplingCellAttributeMatrixPath(), -301); if(getErrorCondition() < 0) { return; } // Create arrays on the reference grid to hold data present on the sampling grid QList<QString> voxelArrayNames = sampleAttrMat->getAttributeArrayNames(); for (QList<QString>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter) { IDataArray::Pointer p = sampleAttrMat->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(refAttrMat->getNumTuples(), p->getComponentDimensions(), p->getName()); refAttrMat->addAttributeArray(p->getName(), data); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void YSChoiAbaqusReader::dataCheck() { DataArrayPath tempPath; setErrorCondition(0); DataContainer::Pointer m = getDataContainerArray()->createNonPrereqDataContainer<AbstractFilter>(this, getDataContainerName()); if(getErrorCondition() < 0) { return; } ImageGeom::Pointer image = ImageGeom::CreateGeometry(DREAM3D::Geometry::ImageGeometry); m->setGeometry(image); QVector<size_t> tDims(3, 0); AttributeMatrix::Pointer cellAttrMat = m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCellAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::Cell); if(getErrorCondition() < 0 || NULL == cellAttrMat.get()) { return; } tDims.resize(1); tDims[0] = 0; AttributeMatrix::Pointer cellFeatureAttrMat = m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCellFeatureAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::CellFeature); if(getErrorCondition() < 0 || NULL == cellFeatureAttrMat.get()) { return; } AttributeMatrix::Pointer cellEnsembleAttrMat = m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCellEnsembleAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::CellEnsemble); if(getErrorCondition() < 0 || NULL == cellEnsembleAttrMat.get()) { return; } QFileInfo fi(getInputFile()); if (getInputFile().isEmpty() == true) { QString ss = QObject::tr("%1 needs the Input File Set and it was not.").arg(ClassName()); setErrorCondition(-387); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } else if (fi.exists() == false) { QString ss = QObject::tr("The input file does not exist"); setErrorCondition(-388); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } else { bool ok = false; //const unsigned int size(1024); // Read header from data file to figure out how many points there are QFile in(getInputFile()); if (!in.open(QIODevice::ReadOnly | QIODevice::Text)) { QString msg = QObject::tr("Abaqus file could not be opened: %1").arg(getInputFile()); setErrorCondition(-100); notifyErrorMessage(getHumanLabel(), "", getErrorCondition()); return; } QString word; bool headerdone = false; int xpoints, ypoints, zpoints; float resx, resy, resz; while (headerdone == false) { QByteArray buf = in.readLine(); if (buf.startsWith(DIMS)) { QList<QByteArray> tokens = buf.split(' '); xpoints = tokens[1].toInt(&ok, 10); ypoints = tokens[2].toInt(&ok, 10); zpoints = tokens[3].toInt(&ok, 10); size_t dims[3] = { static_cast<size_t>(xpoints), static_cast<size_t>(ypoints), static_cast<size_t>(zpoints) }; m->getGeometryAs<ImageGeom>()->setDimensions(dims); m->getGeometryAs<ImageGeom>()->setOrigin(0, 0, 0); } if (RES == word) { QList<QByteArray> tokens = buf.split(' '); resx = tokens[1].toInt(&ok, 10); resy = tokens[2].toInt(&ok, 10); resz = tokens[3].toInt(&ok, 10); float res[3] = {resx, resy, resz}; m->getGeometryAs<ImageGeom>()->setResolution(res); } } } QVector<size_t> dims(1, 3); tempPath.update(getDataContainerName(), getCellAttributeMatrixName(), getCellEulerAnglesArrayName() ); m_CellEulerAnglesPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<float>, AbstractFilter, float>(this, tempPath, 0, dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_CellEulerAnglesPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_CellEulerAngles = m_CellEulerAnglesPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ dims[0] = 4; tempPath.update(getDataContainerName(), getCellAttributeMatrixName(), getQuatsArrayName() ); m_QuatsPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<float>, AbstractFilter, float>(this, tempPath, 0, dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_QuatsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_Quats = m_QuatsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ tempPath.update(getDataContainerName(), getCellFeatureAttributeMatrixName(), getAvgQuatsArrayName() ); m_AvgQuatsPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<float>, AbstractFilter, float>(this, tempPath, 0, dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_AvgQuatsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_AvgQuats = m_AvgQuatsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ dims[0] = 1; tempPath.update(getDataContainerName(), getCellAttributeMatrixName(), getCellPhasesArrayName() ); m_CellPhasesPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter, int32_t>(this, tempPath, 1, dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_CellPhasesPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_CellPhases = m_CellPhasesPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ tempPath.update(getDataContainerName(), getCellFeatureAttributeMatrixName(), getSurfaceFeaturesArrayName() ); m_SurfaceFeaturesPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<bool>, AbstractFilter, bool>(this, tempPath, false, dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_SurfaceFeaturesPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceFeatures = m_SurfaceFeaturesPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ tempPath.update(getDataContainerName(), getCellAttributeMatrixName(), getFeatureIdsArrayName() ); m_FeatureIdsPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter, int32_t>(this, tempPath, 0, dims); /* 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 */ //typedef DataArray<unsigned int> XTalStructArrayType; tempPath.update(getDataContainerName(), getCellEnsembleAttributeMatrixName(), getCrystalStructuresArrayName() ); m_CrystalStructuresPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<uint32_t>, AbstractFilter, uint32_t>(this, tempPath, Ebsd::CrystalStructure::Cubic_High, dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_CrystalStructuresPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_CrystalStructures = m_CrystalStructuresPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ }