示例#1
0
int main () {
  Isis::Preference::Preferences(true);
  try {
  PvlGroup op("Operator");
  op += PvlKeyword("Name","Gradient");
  op += PvlKeyword("DeltaLine", 100);
  op += PvlKeyword("DeltaSamp", 100);
  op += PvlKeyword("Samples", 15);
  op += PvlKeyword("Lines", 15);
  op += PvlKeyword("MinimumInterest", 1);

  PvlObject o("InterestOperator");
  o.AddGroup(op);

  Pvl pvl;
  pvl.AddObject(o);
  std::cout << pvl << std::endl;

  InterestOperator *iop = InterestOperatorFactory::Create(pvl);

  Cube c;
  c.Open("$mgs/testData/ab102401.cub");

  iop->Operate(c, 100, 350);

  std::cout << "Sample: " << iop->CubeSample() << std::endl
            << "Line : " << iop->CubeLine() << std::endl
            << "Interest: " << iop->InterestAmount() << std::endl;
  }
  catch (iException &e) {
    e.Report();
  }

  return 0;
}
示例#2
0
文件: unitTest.cpp 项目: corburn/ISIS
int main() {
  try {
    Isis::Preference::Preferences(true);
    PvlGroup op("Operator");
    op += PvlKeyword("Name", "Forstner");
    op += PvlKeyword("DeltaLine", "100");
    op += PvlKeyword("DeltaSamp", "100");
    op += PvlKeyword("Samples", "15");
    op += PvlKeyword("Lines", "15");
    op += PvlKeyword("MinimumInterest", "0.0");

    PvlGroup opv("ValidMeasure"); 
    opv += PvlKeyword("MinDN", "0.0");
    opv += PvlKeyword("MaxDN", "1.0");
    opv += PvlKeyword("MinEmission", "15.0");
    opv += PvlKeyword("MaxEmission", "25.0");
    opv += PvlKeyword("MinIncidence", "0.0");
    opv += PvlKeyword("MaxIncidence", "135.0");

    PvlObject o("InterestOperator");
    o.addGroup(op);
    o.addGroup(opv);

    Pvl pvl;
    pvl.addObject(o);
    std::cout << pvl << std::endl;

    InterestOperator *iop = InterestOperatorFactory::Create(pvl);

    Cube c;
    c.open("$mgs/testData/ab102401.cub");

    //iop->Operate(c, 100, 350);
    UniversalGroundMap univGrndMap(c);
    iop->Operate(c,  univGrndMap, 100, 350);

    std::cout << "Sample: " << iop->CubeSample() << std::endl
              << "Line : " << iop->CubeLine() << std::endl
              << "Interest: " << iop->InterestAmount() << std::endl;
  }
  catch(IException &e) {
    e.print();
  }

  return 0;
}
示例#3
0
文件: cnetref.cpp 项目: corburn/ISIS
void IsisMain() {

  try {
    UserInterface &ui = Application::GetUserInterface();
    QString sSerialNumFile = ui.GetFileName("FROMLIST");

    // get the Criteria option
    QString sCriteria = ui.GetString("CRITERIA");

    // Check format of Pvl DefFile
    bool bDefFile = false;
    Pvl *pvlDefFile = 0;
    Pvl pvlTemplate, pvlResults;
    if (ui.WasEntered("DEFFILE")) {
      bDefFile = true;
      pvlDefFile = new Pvl(ui.GetFileName("DEFFILE"));

      // Log the DefFile
      Application::Log(pvlDefFile->group(0));

      if (pvlDefFile->group(0).hasKeyword("PixelsFromEdge") && pvlDefFile->group(0).hasKeyword("MetersFromEdge")) {
        QString message = "DefFile Error : Cannot have both \"PixelsFromEdge\" && \"MetersFromEdge\"" ;
        throw IException(IException::User, message, _FILEINFO_);
      }

      Pvl pvlTemplate, pvlResults;
      if (sCriteria == "INTEREST") {
        pvlTemplate = Pvl("$ISIS3DATA/base/templates/cnetref/cnetref_operator.def");
      }
      else {
        pvlTemplate = Pvl("$ISIS3DATA/base/templates/cnetref/cnetref_nooperator.def");
      }
      pvlTemplate.validatePvl(*pvlDefFile, pvlResults);
      if (pvlResults.groups() > 0 || pvlResults.keywords() > 0) {
        Application::Log(pvlResults.group(0));
        QString sErrMsg = "Invalid Deffile\n";
        throw IException(IException::User, sErrMsg, _FILEINFO_);
      }
    }

    // Get the original control net internalized
    Progress progress;
    ControlNet cNet(ui.GetFileName("CNET"), &progress);

    if (ui.WasEntered("NETWORKID")) {
      cNet.SetNetworkId(ui.GetString("NETWORKID"));
    }

    cNet.SetUserName(Isis::Application::UserName());

    if (ui.WasEntered("DESCRIPTION")) {
      cNet.SetDescription(ui.GetString("DESCRIPTION"));
    }

    // Get the output Log file
    bool bLogFile = false;
    QString sLogFile;
    if (ui.WasEntered("LOG")) {
      sLogFile = ui.GetFileName("LOG");
      bLogFile = true;
    }

    // get the Criteria option
    ControlNetValidMeasure *cnetValidMeas = NULL;

    // Process Reference by Emission Angle
    if (sCriteria == "EMISSION") {
      cnetValidMeas = new CnetRefByEmission(pvlDefFile, sSerialNumFile);
      cnetValidMeas->FindCnetRef(cNet);
    }

    // Process Reference by Incidence Angle
    else if (sCriteria == "INCIDENCE") {
      cnetValidMeas = new CnetRefByIncidence(pvlDefFile, sSerialNumFile);
      cnetValidMeas->FindCnetRef(cNet);
    }

    // Process Reference by Resolution
    else if (sCriteria == "RESOLUTION") {
      QString sType = ui.GetString("TYPE");
      double dResValue = 0;
      double dMinRes = 0, dMaxRes = 0;
      if (sType == "NEAREST") {
        dResValue = ui.GetDouble("RESVALUE");
        if (dResValue < 0) {
          QString message = "Invalid Nearest Resolution Value";
          throw IException(IException::User, message, _FILEINFO_);
        }
      }
      else if (sType == "RANGE") {
        dMinRes = ui.GetDouble("MINRES");
        dMaxRes = ui.GetDouble("MAXRES");
        if (dMinRes < 0 || dMaxRes < 0 || dMinRes > dMaxRes) {
          QString message = "Invalid Resolution Range";
          throw IException(IException::User, message, _FILEINFO_);
        }
      }
      cnetValidMeas = new CnetRefByResolution(pvlDefFile, sSerialNumFile, GetResolutionType(sType), dResValue, dMinRes, dMaxRes);
      cnetValidMeas->FindCnetRef(cNet);
    }

    // Process Reference by Interest
    else if (sCriteria == "INTEREST") {
      if (!bDefFile) {
        QString msg = "Interest Option must have a DefFile";
        throw IException(IException::User, msg, _FILEINFO_);
      }
      QString sOverlapListFile = "";
      if (ui.WasEntered("LIMIT")) {
        if (ui.GetBoolean("LIMIT")) {
          sOverlapListFile = FileName(ui.GetFileName("OVERLAPLIST")).expanded();
        }
      }

      // Get the InterestOperator set up
      InterestOperator *interestOp = InterestOperatorFactory::Create(*pvlDefFile);
      interestOp->Operate(cNet, sSerialNumFile, sOverlapListFile);

      // Write to print.prt and screen interest details
      // add operator to print.prt
      PvlGroup opGroup = interestOp->Operator();
      Application::Log(opGroup);
      if (bLogFile) {
        Pvl pvlLog = interestOp->GetLogPvl();
        pvlLog += opGroup;
        pvlLog.write(sLogFile);
      }
      Application::Log(interestOp->GetStdOptions());
      Application::Log(interestOp->GetStatistics());
    }

    // Write the new control network out
    cNet.Write(ui.GetFileName("ONET"));

    // Get Control Net Stats Summary
    PvlGroup statsGrp;
    ControlNetStatistics cnetStats(&cNet);
    cnetStats.GenerateControlNetStats(statsGrp);
    Application::Log(statsGrp);

    if (cnetValidMeas) {
      Pvl pvlLog = cnetValidMeas->GetLogPvl();
      if (bLogFile) {
        pvlLog.write(sLogFile);
      }
      Application::Log(cnetValidMeas->GetStdOptions());
      Application::Log(cnetValidMeas->GetStatistics());

      // clean up
      delete cnetValidMeas;
    }

  } // REFORMAT THESE ERRORS INTO ISIS TYPES AND RETHROW
  catch (IException &e) {
    throw;
  }
  catch (geos::util::GEOSException *exc) {
    QString message = "GEOS Exception: " + (QString)exc->what();
    delete exc;
    throw IException(IException::User, message, _FILEINFO_);
  }
  catch (std::exception const &se) {
    QString message = "std::exception: " + (QString)se.what();
    throw IException(IException::User, message, _FILEINFO_);
  }
  catch (...) {
    QString message = "Other Error";
    throw IException(IException::User, message, _FILEINFO_);
  }
}