// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void VisualizeGBCDPoleFigure::dataCheck() { setErrorCondition(0); getDataContainerArray()->getPrereqGeometryFromDataContainer<TriangleGeom, AbstractFilter>(this, getGBCDArrayPath().getDataContainerName()); if (getOutputFile().isEmpty() == true) { QString ss = QObject::tr( "The output file must be set"); setErrorCondition(-1000); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } QFileInfo fi(getOutputFile()); QDir parentPath = fi.path(); if (parentPath.exists() == false && getInPreflight()) { QString ss = QObject::tr( "The directory path for the output file does not exist. DREAM.3D will attempt to create this path during execution of the filter"); notifyWarningMessage(getHumanLabel(), ss, -1); } if (fi.suffix().compare("") == 0) { setOutputFile(getOutputFile().append(".vtk")); } QVector<size_t> cDims(1, 1); m_CrystalStructuresPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<unsigned int>, AbstractFilter>(this, getCrystalStructuresArrayPath(), cDims); /* 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 */ IDataArray::Pointer tmpGBCDPtr = getDataContainerArray()->getPrereqIDataArrayFromPath<IDataArray, AbstractFilter>(this, getGBCDArrayPath()); if(getErrorCondition() < 0) { return; } if (NULL != tmpGBCDPtr.get()) { QVector<size_t> cDims = tmpGBCDPtr->getComponentDimensions(); m_GBCDPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<double>, AbstractFilter>(this, getGBCDArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_GBCDPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_GBCD = m_GBCDPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ } if (NULL != m_GBCDPtr.lock().get() && getPhaseOfInterest() >= m_GBCDPtr.lock()->getNumberOfTuples()) { QString ss = QObject::tr("The phase index is larger than the number of Ensembles").arg(ClassName()); setErrorCondition(-1); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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 DataContainerReader::readData(bool preflight, DataContainerArrayProxy& proxy, DataContainerArray::Pointer dca) { setErrorCondition(0); QString ss; int32_t err = 0; QString m_FileVersion; float fVersion = 0.0f; bool check = false; // qDebug() << "DataContainerReader::readData() " << m_InputFile; // Read the Meta Data and Array names from the file hid_t fileId = QH5Utilities::openFile(m_InputFile, true); // Open the file Read Only if (fileId < 0) { ss = QObject::tr("Error opening input file '%1'").arg(m_InputFile); setErrorCondition(-150); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } // This will make sure if we return early from this method that the HDF5 File is properly closed. HDF5ScopedFileSentinel scopedFileSentinel(&fileId, true); // Check to see if version of .dream3d file is prior to new data container names err = QH5Lite::readStringAttribute(fileId, "/", DREAM3D::HDF5::FileVersionName, m_FileVersion); fVersion = m_FileVersion.toFloat(&check); if (fVersion < 5.0 || err < 0) { QH5Utilities::closeFile(fileId); fileId = QH5Utilities::openFile(m_InputFile, false); // Re-Open the file as Read/Write err = H5Lmove(fileId, "VoxelDataContainer", fileId, DREAM3D::Defaults::DataContainerName.toLatin1().data(), H5P_DEFAULT, H5P_DEFAULT); err = H5Lmove(fileId, "SurfaceMeshDataContainer", fileId, DREAM3D::Defaults::DataContainerName.toLatin1().data(), H5P_DEFAULT, H5P_DEFAULT); err = QH5Lite::writeStringAttribute(fileId, "/", DREAM3D::HDF5::FileVersionName, "5.0"); QH5Utilities::closeFile(fileId); fileId = QH5Utilities::openFile(m_InputFile, true); // Re-Open the file as Read Only } if (fVersion < 7.0) { ss = QObject::tr("File unable to be read - file structure older than 7.0"); setErrorCondition(-250); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } hid_t dcaGid = H5Gopen(fileId, DREAM3D::StringConstants::DataContainerGroupName.toLatin1().data(), 0); if (dcaGid < 0) { setErrorCondition(-1923123); QString ss = QObject::tr("Error attempting to open the HDF5 Group '%1'").arg(DREAM3D::StringConstants::DataContainerGroupName); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } scopedFileSentinel.addGroupId(&dcaGid); err = dca->readDataContainersFromHDF5(preflight, dcaGid, proxy, this); if (err < 0) { setErrorCondition(err); QString ss = QObject::tr("Error trying to read the DataContainers from the file '%1'").arg(getInputFile()); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } err = H5Gclose(dcaGid); dcaGid = -1; err = readDataContainerBundles(fileId, dca); if (err < 0) { setErrorCondition(err); QString ss = QObject::tr("Error trying to read the DataContainerBundles from the file '%1'").arg(getInputFile()); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (!getInPreflight()) { err = readExistingPipelineFromFile(fileId); if(err < 0) { setErrorCondition(err); QString ss = QObject::tr("Error trying to read the existing pipeline from the file '%1'").arg(getInputFile()); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void DataContainerReader::dataCheck() { // Sync the file proxy and cached proxy if the time stamps are different QFileInfo fi(getInputFile()); if (getInputFile() == getLastFileRead() && getLastRead() < fi.lastModified()) { syncProxies(); } QString ss; if (getInputFile().isEmpty() == true) { ss = QObject::tr("The input file must be set"); setErrorCondition(-387); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } else if (fi.exists() == false) { ss = QObject::tr("The input file does not exist"); setErrorCondition(-388); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if(getErrorCondition()) { // something has gone wrong and errors were logged alread so just return return; } DataContainerArray::Pointer dca = getDataContainerArray(); // Create a new DataContainerArray to read the file data into DataContainerArray::Pointer tempDCA = DataContainerArray::New(); // Read either the structure or all the data depending on the preflight status readData(getInPreflight(), m_InputFileDataContainerArrayProxy, tempDCA); QList<DataContainer::Pointer>& tempContainers = tempDCA->getDataContainers(); QListIterator<DataContainer::Pointer> iter(tempContainers); while (iter.hasNext()) { DataContainer::Pointer container = iter.next(); if (getOverwriteExistingDataContainers() == true ) { if (dca->doesDataContainerExist(container->getName()) == true) { dca->removeDataContainer(container->getName()); } dca->addDataContainer(container); } else { if (dca->doesDataContainerExist(container->getName()) == true) { ss = QObject::tr("The input file has a DataContainer with a name (%1) that already exists in the current DataContainerArray structure").arg(container->getName()); setErrorCondition(-390); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } else { dca->addDataContainer(container); } } } QMap<QString, IDataContainerBundle::Pointer> bundles = tempDCA->getDataContainerBundles(); dca->setDataContainerBundles(bundles); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ConvertData::dataCheck() { setErrorCondition(0); DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getSelectedCellArrayPath().getDataContainerName(), false); QString ss; if (m_OutputArrayName.isEmpty() == true) { ss = QObject::tr("The output array name must be set"); setErrorCondition(-398); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } if (getInPreflight()) { AttributeMatrix::Pointer cellAttrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, m_SelectedCellArrayPath, -301); if(getErrorCondition() < 0) { return; } IDataArray::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath<IDataArray, AbstractFilter>(this, getSelectedCellArrayPath()); if(getErrorCondition() < 0) { return; } QVector<size_t> dims = p->getComponentDimensions(); size_t voxels = cellAttrMat->getNumTuples(); if (m_ScalarType == Detail::Int8) { p = Int8ArrayType::CreateArray(voxels, dims, m_OutputArrayName); } else if (m_ScalarType == Detail::UInt8) { p = UInt8ArrayType::CreateArray(voxels, dims, m_OutputArrayName); } else if (m_ScalarType == Detail::Int16) { p = Int16ArrayType::CreateArray(voxels, dims, m_OutputArrayName); } else if (m_ScalarType == Detail::UInt16) { p = UInt16ArrayType::CreateArray(voxels, dims, m_OutputArrayName); } else if (m_ScalarType == Detail::Int32) { p = Int32ArrayType::CreateArray(voxels, dims, m_OutputArrayName); } else if (m_ScalarType == Detail::UInt32) { p = UInt32ArrayType::CreateArray(voxels, dims, m_OutputArrayName); } else if (m_ScalarType == Detail::Int64) { p = Int64ArrayType::CreateArray(voxels, dims, m_OutputArrayName); } else if (m_ScalarType == Detail::UInt64) { p = UInt64ArrayType::CreateArray(voxels, dims, m_OutputArrayName); } else if (m_ScalarType == Detail::Float) { p = FloatArrayType::CreateArray(voxels, dims, m_OutputArrayName); } else if (m_ScalarType == Detail::Double) { p = DoubleArrayType::CreateArray(voxels, dims, m_OutputArrayName); } cellAttrMat->addAttributeArray(p->getName(), p); } }