/** * * @param FileName * @param data * @param nx X Dimension * @param ny Y Dimension * @param nz Z Dimension */ int ReadPHFile(QString FileName, QVector<int>& data, int& nx, int& ny, int& nz) { DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer m = DataContainer::New(); /* FIXME: What Geometry do we need? */ dca->pushBack(m); FilterManager::Pointer fm = FilterManager::Instance(); AbstractFilter::Pointer reader = fm->getFactoryForFilter("PhReader")->create(); reader->setDataContainerArray(dca); bool propWasSet = reader->setProperty("InputFile", FileName); if(propWasSet == false) { } reader->execute(); if (reader->getErrorCondition() < 0) { qDebug() << "Error Reading the Ph File '" << FileName << "' Error Code:" << reader->getErrorCondition(); return -1; } Int32ArrayType* featureIds = Int32ArrayType::SafePointerDownCast(m->getAttributeMatrix(DREAM3D::Defaults::CellAttributeMatrixName)->getAttributeArray(DREAM3D::CellData::FeatureIds).get()); size_t count = featureIds->getNumberOfTuples(); data.resize(count); for(size_t i = 0; i < count; ++i) { data[i] = featureIds->getValue(i); } return 0; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void LoopOnFilters() { FilterManager::Pointer fm = FilterManager::Instance(); FilterManager::Collection factories = fm->getFactories(); FilterManager::CollectionIterator i(factories); int count = 0; while (i.hasNext()) { i.next(); std::cout << ++count << ": " << i.key().toStdString() << ": " << std::endl; //std::cout << " public:" << std::endl; IFilterFactory::Pointer factory = i.value(); AbstractFilter::Pointer filter = factory->create(); //if (filter->getGroupName().compare(DREAM3D::FilterGroups::StatisticsFilters) == 0) // if(filter->getNameOfClass().compare("FindSchmids") == 0) { // std::cout << "" << filter->getGroupName().toStdString() << "Filters/" << filter->getNameOfClass().toStdString() << ".cpp" << std::endl; QString cpp = findPath(filter->getGroupName(), filter->getNameOfClass(), ".cpp"); std::cout << filter << " " << cpp.toStdString() << std::endl; } } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void PipelineViewEntry::instantiateFilter(const QString& filterClassName) { FilterManager::Pointer fm = FilterManager::Instance(); if(NULL == fm.get() ) { return; } IFilterFactory::Pointer ff = fm->getFactoryForFilter(filterClassName); if (NULL == ff.get()) { return; } // Create an instance of the filter. Since we are dealing with the AbstractFilter interface we can not // actually use the actual filter class. We are going to have to rely on QProperties or Signals/Slots // to communicate changes back to the filter. m_Filter = ff->create(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void GenerateFilterParametersCode() { FilterManager::Pointer fm = FilterManager::Instance(); FilterManager::Collection factories = fm->getFactories(); QMapIterator<QString, IFilterFactory::Pointer> iter(factories); // Loop on each filter while(iter.hasNext()) { iter.next(); IFilterFactory::Pointer factory = iter.value(); AbstractFilter::Pointer filter = factory->create(); QString cpp = findPath(filter->getGroupName(), filter->getNameOfClass(), ".cpp"); QString h = findPath(filter->getGroupName(), filter->getNameOfClass(), ".h"); fixFile(filter, h, cpp); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int main(int argc, char* argv[]) { Q_ASSERT(true); // We don't want anyone to run this program. // Instantiate the QCoreApplication that we need to get the current path and load plugins. QCoreApplication app(argc, argv); QCoreApplication::setOrganizationName("BlueQuartz Software"); QCoreApplication::setOrganizationDomain("bluequartz.net"); QCoreApplication::setApplicationName("FilterParameterTool"); std::cout << "FilterParameterTool Starting. Version " << DREAM3DLib::Version::PackageComplete().toStdString() << std::endl; // Register all the filters including trying to load those from Plugins FilterManager::Pointer fm = FilterManager::Instance(); DREAM3DPluginLoader::LoadPluginFilters(fm.get()); // Send progress messages from PipelineBuilder to this object for display qRegisterMetaType<PipelineMessage>(); GenerateFilterParametersCode(); return 0; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int main(int argc, char** argv) { qDebug() << "Starting Ph to HDF5 Merging..."; // Instantiate the QCoreApplication that we need to get the current path and load plugins. QCoreApplication app(argc, argv); QCoreApplication::setOrganizationName("BlueQuartz Software"); QCoreApplication::setOrganizationDomain("bluequartz.net"); QCoreApplication::setApplicationName("PhToHDF5"); std::cout << "PhToHDF5 Starting. Version " << SIMPLib::Version::PackageComplete().toStdString() << std::endl; // Register all the filters including trying to load those from Plugins FilterManager::Pointer fm = FilterManager::Instance(); SIMPLibPluginLoader::LoadPluginFilters(fm.get()); // Send progress messages from PipelineBuilder to this object for display QMetaObjectUtilities::RegisterMetaTypes(); try { // Handle program options passed on command line. TCLAP::CmdLine cmd("PhToHDF5", ' ', SIMPLib::Version::Complete().toStdString()); TCLAP::ValueArg<std::string> phFileArg( "p", "phfile", "Ph Input File", true, "", "Ph Input File"); cmd.add(phFileArg); TCLAP::ValueArg<std::string> angleFileArg( "e", "eulerfile", "Euler Angle File", false, "", "Euler Angle File"); cmd.add(angleFileArg); TCLAP::ValueArg<std::string> h5InputFileArg( "t", "h5file", "Target HDF5 File", true, "", "Target HDF5 File"); cmd.add(h5InputFileArg); // Parse the argv array. cmd.parse(argc, argv); if (argc == 1) { qDebug() << "PhToHDF5 program was not provided any arguments. Use the --help argument to show the help listing."; return EXIT_FAILURE; } QString phFile = QString::fromStdString(phFileArg.getValue()); QString h5File = QString::fromStdString(h5InputFileArg.getValue()); QVector<int> voxels; int nx = 0; int ny = 0; int nz = 0; qDebug() << "Merging the FeatureID data from " << phFile; qDebug() << " into"; qDebug() << "file: " << h5File; qDebug() << "Reading the Ph data file...."; int err = ReadPHFile(phFile, voxels, nx, ny, nz); if (err < 0) { return EXIT_FAILURE; } qDebug() << "Ph File has dimensions: " << nx << " x " << ny << " x " << nz; qDebug() << "Now Overwriting the FeatureID data set in the HDF5 file...."; err = writePhDataToHDF5File(h5File, voxels, nz, ny, nz); if (err < 0) { qDebug() << "There was an error writing the feature id data. Check other errors for possible clues."; return EXIT_FAILURE; } qDebug() << "+ Done Writing the Feature ID Data."; QMap<int, EulerSet> gidToEulerMap; if (angleFileArg.getValue().empty() == false) { qDebug() << "Reading the Euler Angle Data...."; err = ReadEulerFile(QString::fromStdString(angleFileArg.getValue()), gidToEulerMap); if (err < 0) { qDebug() << "Error Reading the Euler Angle File"; return EXIT_FAILURE; } // Over Write the Euler Angles if the Euler File was supplied qDebug() << "Now Over Writing the Euler Angles data in the HDF5 file....."; int totalPoints = nx * ny * nz; int numComp = 3; // Loop over each Voxel getting its Feature ID and then setting the Euler Angle QVector<float> dataf(totalPoints * 3); for (int i = 0; i < totalPoints; ++i) { EulerSet& angle = gidToEulerMap[voxels[i]]; dataf[i * 3] = angle.e0; dataf[i * 3 + 1] = angle.e1; dataf[i * 3 + 2] = angle.e2; } // This is going to be a 2 Dimension Table Data set. int32_t rank = 2; hsize_t dims[2] = {totalPoints, numComp}; err = writeEulerDataToHDF5File(h5File, dataf, numComp, rank, dims); if (err < 0) { qDebug() << "There was an error writing the Euler Angle data. Check other errors for possible clues."; return EXIT_FAILURE; } qDebug() << "+ Done Writing the Euler Angle Data."; } } catch (TCLAP::ArgException& e) // catch any exceptions { std::cerr << " error: " << e.error() << " for arg " << e.argId(); return EXIT_FAILURE; } qDebug() << "Successfully completed the merge."; return EXIT_SUCCESS; }