// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QString InitializeSyntheticVolume::estimateNumFeatures(IntVec3_t dims, FloatVec3_t res) { float totalvol = 0.0f; int32_t phase = 0; totalvol = (dims.x * res.x) * (dims.y * res.y) * (dims.z * res.z); if (totalvol == 0.0) { return "-1"; } DataContainerArray::Pointer dca = getDataContainerArray(); // Get the PhaseTypes - Remember there is a Dummy PhaseType in the first slot of the array QVector<size_t> cDims(1, 1); // This states that we are looking for an array with a single component UInt32ArrayType::Pointer phaseType = dca->getPrereqArrayFromPath<UInt32ArrayType, AbstractFilter>(NULL, getInputPhaseTypesArrayPath(), cDims); if (phaseType.get() == NULL) { QString ss = QObject::tr("Phase types array could not be downcast using std::dynamic_pointer_cast<T> when estimating the number of grains. The path is %1").arg(getInputPhaseTypesArrayPath().serialize()); setErrorCondition(-11002); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return "0"; } QVector<size_t> statsDims(1, 1); StatsDataArray::Pointer statsPtr = dca->getPrereqArrayFromPath<StatsDataArray, AbstractFilter>(this, getInputStatsArrayPath(), statsDims); if (statsPtr.get() == NULL) { QString ss = QObject::tr("Statistics array could not be downcast using std::dynamic_pointer_cast<T> when estimating the number of grains. The path is %1").arg(getInputStatsArrayPath().serialize()); notifyErrorMessage(getHumanLabel(), ss, -11001); return "0"; } if (!phaseType->isAllocated()) { if (getInputStatsFile().isEmpty()) { QString ss = QObject::tr("Phase types array has not been allocated and the input statistics file is empty"); setErrorCondition(-1000); notifyWarningMessage(getHumanLabel(), ss, getErrorCondition()); return "-1"; } QFileInfo fi(getInputStatsFile()); if (fi.exists() == false) { QString ss = QObject::tr("Phase types array has not been allocated and the input statistics file does not exist at '%1'").arg(fi.absoluteFilePath()); setErrorCondition(-1001); notifyWarningMessage(getHumanLabel(), ss, getErrorCondition()); return "-1"; } hid_t fileId = -1; herr_t err = 0; // open the file fileId = H5Utilities::openFile(getInputStatsFile().toLatin1().constData(), true); // This will make sure if we return early from this method that the HDF5 File is properly closed. HDF5ScopedFileSentinel scopedFileSentinel(&fileId, true); DataArrayPath dap = getInputPhaseTypesArrayPath(); // Generate the path to the AttributeMatrix QString hPath = DREAM3D::StringConstants::DataContainerGroupName + "/" + dap.getDataContainerName() + "/" + dap.getAttributeMatrixName(); // Open the AttributeMatrix Group hid_t amGid = H5Gopen(fileId, hPath.toLatin1().data(), H5P_DEFAULT ); scopedFileSentinel.addGroupId(&amGid); err = phaseType->readH5Data(amGid); if (err < 0) { QString ss = QObject::tr("Error reading phase type data"); setErrorCondition(-1003); notifyWarningMessage(getHumanLabel(), ss, getErrorCondition()); return "-1"; } if (!phaseType->isAllocated()) { QString ss = QObject::tr("Phase types Array was not allocated due to an error reading the data from the statistics file %1").arg(fi.absoluteFilePath()); setErrorCondition(-1002); notifyWarningMessage(getHumanLabel(), ss, getErrorCondition()); return "-1"; } } // Create a Reference Variable so we can use the [] syntax StatsDataArray& statsDataArray = *(statsPtr.get()); std::vector<int32_t> primaryphases; std::vector<double> primaryphasefractions; double totalprimaryfractions = 0.0; // find which phases are primary phases for (size_t i = 1; i < phaseType->getNumberOfTuples(); ++i) { if (phaseType->getValue(i) == DREAM3D::PhaseType::PrimaryPhase) { PrimaryStatsData* pp = PrimaryStatsData::SafePointerDownCast(statsDataArray[i].get()); primaryphases.push_back(i); primaryphasefractions.push_back(pp->getPhaseFraction()); totalprimaryfractions = totalprimaryfractions + pp->getPhaseFraction(); } } // scale the primary phase fractions to total to 1 for (int32_t i = 0; i < primaryphasefractions.size(); i++) { primaryphasefractions[i] = primaryphasefractions[i] / totalprimaryfractions; } SIMPL_RANDOMNG_NEW() // generate the Features int32_t gid = 1; float currentvol = 0.0f; float vol = 0.0f; float diam = 0.0f; bool volgood = false; for (int32_t j = 0; j < primaryphases.size(); ++j) { float curphasetotalvol = totalvol * primaryphasefractions[j]; while (currentvol < curphasetotalvol) { volgood = false; phase = primaryphases[j]; PrimaryStatsData* pp = PrimaryStatsData::SafePointerDownCast(statsDataArray[phase].get()); if (NULL == pp) { QString ss = QObject::tr("Tried to cast a statsDataArray[%1].get() to a PrimaryStatsData* " "pointer but this resulted in a NULL pointer.\n") .arg(phase).arg(phase); setErrorCondition(-666); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return "-1"; } while (volgood == false) { volgood = true; if (pp->getFeatureSize_DistType() == DREAM3D::DistributionType::LogNormal) { float avgdiam = pp->getFeatureSizeDistribution().at(0)->getValue(0); float sddiam = pp->getFeatureSizeDistribution().at(1)->getValue(0); diam = rg.genrand_norm(avgdiam, sddiam); diam = expf(diam); if (diam >= pp->getMaxFeatureDiameter()) { volgood = false; } if (diam < pp->getMinFeatureDiameter()) { volgood = false; } vol = (4.0f / 3.0f) * (M_PI) * ((diam * 0.5f) * (diam * 0.5f) * (diam * 0.5f)); } } currentvol = currentvol + vol; gid++; } } return QString::number(gid); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AttributeMatrixCreationWidget::populateComboBoxes() { // std::cout << "void AttributeMatrixCreationWidget::populateComboBoxesWithSelection()" << std::endl; // Now get the DataContainerArray from the Filter instance // We are going to use this to get all the current DataContainers DataContainerArray::Pointer dca = getFilter()->getDataContainerArray(); if (NULL == dca.get()) { return; } // Check to see if we have any DataContainers to actually populate drop downs with. if (dca->getDataContainers().size() == 0) { return; } // Cache the DataContainerArray Structure for our use during all the selections m_DcaProxy = DataContainerArrayProxy(dca.get()); // Populate the DataContainer ComboBox FilterPararameterWidgetUtils::PopulateDataContainerComboBox<AttributeMatrixCreationFilterParameter>(getFilter(), getFilterParameter(), dataContainerCombo, m_DcaProxy); // Grab what is currently selected QString curDcName = dataContainerCombo->currentText(); QString curAmName = attributeMatrixName->text(); // Get what is in the filter DataArrayPath selectedPath = getFilter()->property(PROPERTY_NAME_AS_CHAR).value<DataArrayPath>(); // Split the path up to make sure we have a valid path separated by the "|" character QString filtDcName = selectedPath.getDataContainerName(); QString filtAmName = selectedPath.getAttributeMatrixName(); // Now to figure out which one of these to use. If this is the first time through then what we picked up from the // gui will be empty strings because nothing is there. If there is something in the filter then we should use that. // If there is something in both of them and they are NOT equal then we have a problem. Use the flag m_DidCausePreflight // to determine if the change from the GUI should over ride the filter or vice versa. there is a potential that in future // versions that something else is driving SIMPLView and pushing the changes to the filter and we need to reflect those // changes in the GUI, like a testing script? QString dcName = checkStringValues(curDcName, filtDcName); if (!dca->doesDataContainerExist(dcName)) { dcName = ""; } bool didBlock = false; if (!dataContainerCombo->signalsBlocked()) { didBlock = true; } dataContainerCombo->blockSignals(true); int dcIndex = dataContainerCombo->findText(dcName); dataContainerCombo->setCurrentIndex(dcIndex); if (didBlock) { dataContainerCombo->blockSignals(false); didBlock = false; } if (!attributeMatrixName->signalsBlocked()) { didBlock = true; } attributeMatrixName->blockSignals(true); QString amName = checkStringValues(curAmName, filtAmName); attributeMatrixName->setText(amName); if (didBlock) { attributeMatrixName->blockSignals(false); didBlock = false; } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void PhaseTypeSelectionWidget::populateComboBoxes() { // std::cout << "void PhaseTypeSelectionWidget::populateComboBoxesWithSelection()" << std::endl; // Now get the DataContainerArray from the Filter instance // We are going to use this to get all the current DataContainers DataContainerArray::Pointer dca = getFilter()->getDataContainerArray(); if(NULL == dca.get()) { return; } // Grab what is currently selected QString curDcName = dataContainerCombo->currentText(); QString curAmName = attributeMatrixCombo->currentText(); // Check to see if we have any DataContainers to actually populate drop downs with. if(dca->getDataContainers().size() == 0) { dataContainerCombo->clear(); attributeMatrixCombo->clear(); return; } // Cache the DataContainerArray Structure for our use during all the selections m_DcaProxy = DataContainerArrayProxy(dca.get()); // Populate the DataContainerArray Combo Box with all the DataContainers QList<DataContainerProxy> dcList = m_DcaProxy.dataContainers.values(); QListIterator<DataContainerProxy> iter(dcList); dataContainerCombo->clear(); while(iter.hasNext() ) { DataContainerProxy dc = iter.next(); dataContainerCombo->addItem(dc.name); } // Get what is in the filter PhaseTypeSelectionFilterParameter* p = dynamic_cast<PhaseTypeSelectionFilterParameter*>(getFilterParameter()); QVariant qvSelectedPath = getFilter()->property(p->getAttributeMatrixPathProperty().toLatin1().constData()); DataArrayPath selectedPath = qvSelectedPath.value<DataArrayPath>(); QString filtDcName = selectedPath.getDataContainerName(); QString filtAmName = selectedPath.getAttributeMatrixName(); QString dcName; QString amName; // If EVERYTHING is empty, then try the default value if(filtDcName.isEmpty() && filtAmName.isEmpty() && curDcName.isEmpty() && curAmName.isEmpty() ) { DataArrayPath daPath = getFilterParameter()->getDefaultValue().value<DataArrayPath>(); dcName = daPath.getDataContainerName(); amName = daPath.getAttributeMatrixName(); } else { // Now to figure out which one of these to use. If this is the first time through then what we picked up from the // gui will be empty strings because nothing is there. If there is something in the filter then we should use that. // If there is something in both of them and they are NOT equal then we have a problem. Use the flag m_DidCausePreflight // to determine if the change from the GUI should over ride the filter or vice versa. there is a potential that in future // versions that something else is driving DREAM3D and pushing the changes to the filter and we need to reflect those // changes in the GUI, like a testing script? dcName = checkStringValues(curDcName, filtDcName); if( !dca->doesDataContainerExist(dcName) ) { dcName = ""; } amName = checkStringValues(curAmName, filtAmName); if( !dca->doesAttributeMatrixExist(DataArrayPath(dcName, amName, "") ) ) { amName = ""; } } bool didBlock = false; if (!dataContainerCombo->signalsBlocked()) { didBlock = true; } dataContainerCombo->blockSignals(true); int dcIndex = dataContainerCombo->findText(dcName); dataContainerCombo->setCurrentIndex(dcIndex); populateAttributeMatrixList(); if(didBlock) { dataContainerCombo->blockSignals(false); didBlock = false; } if(!attributeMatrixCombo->signalsBlocked()) { didBlock = true; } attributeMatrixCombo->blockSignals(true); if (dcIndex < 0) { attributeMatrixCombo->setCurrentIndex(-1); } else { int amIndex = attributeMatrixCombo->findText(amName); attributeMatrixCombo->setCurrentIndex(amIndex); } if(didBlock) { attributeMatrixCombo->blockSignals(false); didBlock = false; } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void DataArraySelectionWidget::populateComboBoxes() { //qDebug() << "-----------------------------------------------"; //qDebug() << getFilter()->getHumanLabel() << " " << getFilterParameter()->getHumanLabel() << " DataArraySelectionWidget::populateComboBoxes()"; // Now get the DataContainerArray from the Filter instance // We are going to use this to get all the current DataContainers DataContainerArray::Pointer dca = getFilter()->getDataContainerArray(); if(NULL == dca.get()) { return; } //qDebug() << getFilter()->getHumanLabel() << " " << getFilterParameter()->getHumanLabel(); // Grab what is currently selected QString curDcName = dataContainerCombo->currentText(); QString curAmName = attributeMatrixCombo->currentText(); QString curDaName = attributeArrayCombo->currentText(); //qDebug() << "Current ComboBox Value: " << curDcName << "::" << curAmName << "::" << curDaName; // Check to see if we have any DataContainers to actually populate drop downs with. if(dca->getDataContainers().size() == 0) { dataContainerCombo->clear(); attributeMatrixCombo->clear(); attributeArrayCombo->clear(); return; } // Cache the DataContainerArray Structure for our use during all the selections m_DcaProxy = DataContainerArrayProxy(dca.get()); // Populate the DataContainerArray Combo Box with all the DataContainers QList<DataContainerProxy> dcList = m_DcaProxy.dataContainers.values(); QListIterator<DataContainerProxy> iter(dcList); dataContainerCombo->clear(); while(iter.hasNext() ) { DataContainerProxy dc = iter.next(); dataContainerCombo->addItem(dc.name); // if(dataContainerCombo->findText(dc.name) == -1 ) // { // int index = dataContainerCombo->currentIndex(); // dataContainerCombo->addItem(dc.name); // dataContainerCombo->setCurrentIndex(index); // } } // Get what is in the filter DataArrayPath selectedPath = getFilter()->property(PROPERTY_NAME_AS_CHAR).value<DataArrayPath>(); // Split the path up to make sure we have a valid path separated by the "|" character QString filtDcName = selectedPath.getDataContainerName(); QString filtAmName = selectedPath.getAttributeMatrixName(); QString filtDaName = selectedPath.getDataArrayName(); QString dcName; QString amName; QString daName; // If EVERYTHING is empty, then try the default value if(filtDcName.isEmpty() && filtAmName.isEmpty() && filtDaName.isEmpty() && curDcName.isEmpty() && curAmName.isEmpty() && curDaName.isEmpty() ) { DataArrayPath daPath = getFilterParameter()->getDefaultValue().value<DataArrayPath>(); dcName = daPath.getDataContainerName(); amName = daPath.getAttributeMatrixName(); daName = daPath.getDataArrayName(); } else { // Now to figure out which one of these to use. If this is the first time through then what we picked up from the // gui will be empty strings because nothing is there. If there is something in the filter then we should use that. // If there is something in both of them and they are NOT equal then we have a problem. Use the flag m_DidCausePreflight // to determine if the change from the GUI should over ride the filter or vice versa. there is a potential that in future // versions that something else is driving DREAM3D and pushing the changes to the filter and we need to reflect those // changes in the GUI, like a testing script? dcName = checkStringValues(curDcName, filtDcName); if( !dca->doesDataContainerExist(dcName) ) { dcName = ""; } amName = checkStringValues(curAmName, filtAmName); if ( !dca->doesAttributeMatrixExist(DataArrayPath(dcName, amName, "") ) ) { amName = ""; } daName = checkStringValues(curDaName, filtDaName); if ( !dca->doesAttributeArrayExist(DataArrayPath(dcName, amName, daName) )) { daName = ""; } } bool didBlock = false; if (!dataContainerCombo->signalsBlocked()) { didBlock = true; } dataContainerCombo->blockSignals(true); int dcIndex = dataContainerCombo->findText(dcName); dataContainerCombo->setCurrentIndex(dcIndex); populateAttributeMatrixList(); if(didBlock) { dataContainerCombo->blockSignals(false); didBlock = false; } if(!attributeMatrixCombo->signalsBlocked()) { didBlock = true; } attributeMatrixCombo->blockSignals(true); int amIndex = -1; if (dcIndex < 0) { attributeMatrixCombo->setCurrentIndex(-1); attributeArrayCombo->setCurrentIndex(-1); } else { amIndex = attributeMatrixCombo->findText(amName); attributeMatrixCombo->setCurrentIndex(amIndex); populateAttributeArrayList(); } if(didBlock) { attributeMatrixCombo->blockSignals(false); didBlock = false; } if(!attributeArrayCombo->signalsBlocked()) { didBlock = true; } attributeArrayCombo->blockSignals(true); if (amIndex < 0) { attributeArrayCombo->setCurrentIndex(-1); } else { int daIndex = attributeArrayCombo->findText(daName); // The DataArray Name was empty, lets instantiate the filter and get the default value and try that if (daIndex < 0) { QVariant var = getFilterParameter()->getDefaultValue(); DataArrayPath path = var.value<DataArrayPath>(); daName = path.getDataArrayName(); // Pick up the DataArray Name from a Default instantiation of the filter daIndex = attributeArrayCombo->findText(daName); } attributeArrayCombo->setCurrentIndex(daIndex); // we set the selection but we are NOT triggering anything so we should } if(didBlock) { attributeArrayCombo->blockSignals(false); didBlock = false; }// not be triggering an infinte recursion of preflights }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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 (daSrcAttributeMatrix->getName() == daDestAttributeMatrix->getName()) { 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; } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void DataContainerSelectionWidget::populateComboBoxes() { // std::cout << "void DataContainerSelectionWidget::populateComboBoxesWithSelection()" << std::endl; // Now get the DataContainerArray from the Filter instance // We are going to use this to get all the current DataContainers DataContainerArray::Pointer dca = getFilter()->getDataContainerArray(); if(NULL == dca.get()) { return; } // Check to see if we have any DataContainers to actually populate drop downs with. if(dca->getDataContainers().size() == 0) { return; } // Cache the DataContainerArray Structure for our use during all the selections m_DcaProxy = DataContainerArrayProxy(dca.get()); // Populate the DataContainerArray Combo Box with all the DataContainers QList<DataContainerProxy> dcList = m_DcaProxy.dataContainers.values(); QListIterator<DataContainerProxy> iter(dcList); dataContainerCombo->clear(); while(iter.hasNext() ) { DataContainerProxy dc = iter.next(); dataContainerCombo->addItem(dc.name); // if(dataContainerCombo->findText(dc.name) == -1 ) // { // int index = dataContainerCombo->currentIndex(); // dataContainerCombo->addItem(dc.name); // dataContainerCombo->setCurrentIndex(index); // } } //remove items in the combo that are NOT in the Data Container Array // int count = dataContainerCombo->count(); // for(int i = count - 1; i >= 0; i--) // { // QString str0 = dataContainerCombo->itemText(i); // iter.toFront(); // bool boo = false; // while(iter.hasNext() ) // { // DataContainerProxy dc = iter.next(); // if(dc.name.compare(str0) == 0) // { // boo = true; // found in the list // } // } // if(boo == false) // { // dataContainerCombo->removeItem(i); // } // } // Grab what is currently selected QString curDcName = dataContainerCombo->currentText(); // Get what is in the filter QString filtDcName; QString filtAmName; QVariant qvSelectedPath = getFilter()->property(PROPERTY_NAME_AS_CHAR); if( QString("QString").compare(qvSelectedPath.typeName()) == 0 ) { filtDcName = qvSelectedPath.toString(); } else if( QString("DataArrayPath").compare(qvSelectedPath.typeName()) == 0 ) { DataArrayPath selectedPath = qvSelectedPath.value<DataArrayPath>(); filtDcName = selectedPath.getDataContainerName(); filtAmName = selectedPath.getAttributeMatrixName(); } // Now to figure out which one of these to use. If this is the first time through then what we picked up from the // gui will be empty strings because nothing is there. If there is something in the filter then we should use that. // If there is something in both of them and they are NOT equal then we have a problem. Use the flag m_DidCausePreflight // to determine if the change from the GUI should over ride the filter or vice versa. there is a potential that in future // versions that something else is driving DREAM3D and pushing the changes to the filter and we need to reflect those // changes in the GUI, like a testing script? QString dcName = checkStringValues(curDcName, filtDcName); if( !dca->doesDataContainerExist(dcName) ) { dcName = ""; } bool didBlock = false; if (!dataContainerCombo->signalsBlocked()) { didBlock = true; } dataContainerCombo->blockSignals(true); int dcIndex = dataContainerCombo->findText(dcName); if(dcIndex < 0 && dcName.isEmpty() == false) { dataContainerCombo->addItem(dcName); } else { dataContainerCombo->setCurrentIndex(dcIndex); } if(didBlock) { dataContainerCombo->blockSignals(false); didBlock = false; } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QDebug operator<<(QDebug out, const DataArrayPath& v) { out << v.getDataContainerName() << "|" << v.getAttributeMatrixName() << "|" << v.getDataArrayName(); return out; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void MultiEmmpmFilter::dataCheck() { setErrorCondition(0); if (DataArrayPath::ValidateVector(getInputDataArrayVector()) == false) { setErrorCondition(-62000); QString ss = QObject::tr("All Attribute Arrays must belong to the same Data Container and Attribute Matrix"); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } QVector<size_t> cDims(1, 1); // We need a single component, gray scale image #if 0 m_InputImagePtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<uint8_t>, AbstractFilter>(this, getInputDataArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if (NULL != m_InputImagePtr.lock().get()) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_InputImage = m_InputImagePtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ if (getErrorCondition() < 0) { return; } ImageGeom::Pointer image = getDataContainerArray()->getDataContainer(getInputDataArrayPath().getDataContainerName())->getPrereqGeometry<ImageGeom, AbstractFilter>(this); if (getErrorCondition() < 0 || NULL == image.get()) { return; } m_OutputImagePtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<uint8_t>, AbstractFilter, uint8_t>(this, getOutputDataArrayPath(), 0, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if (NULL != m_OutputImagePtr.lock().get()) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_OutputImage = m_OutputImagePtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ #endif if (getOutputArrayPrefix().isEmpty()) { setErrorCondition(-62002); QString message = QObject::tr("Using a prefix (even a single alphanumeric value) is required so that the output Xdmf files can be written correctly"); notifyErrorMessage(getHumanLabel(), message, getErrorCondition()); } if (getInputDataArrayVector().isEmpty()) { setErrorCondition(-62003); QString message = QObject::tr("At least one Attribute Array must be selected"); notifyErrorMessage(getHumanLabel(), message, getErrorCondition()); return; } DataArrayPath inputAMPath = DataArrayPath::GetAttributeMatrixPath(getInputDataArrayVector()); AttributeMatrix::Pointer inAM = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, inputAMPath, -301); if(getErrorCondition() < 0 || NULL == inAM.get()) { return; } // Now create our output attributeMatrix which will contain all of our segmented images QVector<size_t> tDims = inAM->getTupleDimensions(); AttributeMatrix::Pointer outAM = getDataContainerArray()->getDataContainer(inputAMPath.getDataContainerName())->createNonPrereqAttributeMatrix<AbstractFilter>(this, getOutputAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::Cell); if(getErrorCondition() < 0 || NULL == outAM.get()) { return; } // Get the list of checked array names from the input data arrays list QList<QString> arrayNames = DataArrayPath::GetDataArrayNames(getInputDataArrayVector()); for (int32_t i = 0; i < arrayNames.size(); i++ ) { QString daName = arrayNames.at(i); QString newName = getOutputArrayPrefix() + arrayNames.at(i); inputAMPath.setDataArrayName(daName); getDataContainerArray()->getPrereqArrayFromPath<DataArray<uint8_t>, AbstractFilter>(this, inputAMPath, cDims); if (getErrorCondition() < 0) { return; } outAM->createAndAddAttributeArray<UInt8ArrayType, AbstractFilter, uint8_t>(this, newName, 0, cDims); } // The EM/MPM Library has a hard coded MAX Classes of 16 if (getNumClasses() > 15) { setErrorCondition(-62000); QString ss = QObject::tr("The maximum number of classes is 15"); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } // It does not make any sense if we want anything less than 2 classes if (getNumClasses() < 2) { setErrorCondition(-62001); QString ss = QObject::tr("The minimum number of classes is 2"); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } }