// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
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();
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
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;
}
Example #3
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;
}