Exemple #1
0
/** Search for a COORDS DataSet. If no name specified, create a default
  * COORDS DataSet named _DEFAULTCRD_.
  */
DataSet* DataSetList::FindCoordsSet(std::string const& setname) {
  DataSet* outset = 0;
  if (setname.empty()) {
    // crdset not given, search for the default set
    outset = FindSetOfType("_DEFAULTCRD_", DataSet::COORDS);
    if (outset == 0) {
      // No default set; create one.
      outset = AddSet(DataSet::COORDS, "_DEFAULTCRD_", "CRD");
    }
  } else {
    DataSetList dslist = SelectGroupSets(setname, DataSet::COORDINATES);
    if (!dslist.empty()) outset = dslist[0];
  }
  return outset;
}
Exemple #2
0
// DataSetList::GetTopByKeyword()
DataSet* DataSetList::GetTopByKeyword(ArgList& argIn, int& err) const {
  DataSet* top = 0;
  err = 0;
  std::string topname = argIn.GetStringKey("parm");
  if (!topname.empty()) {
    top = FindSetOfType( topname, DataSet::TOPOLOGY );
    if ( top == 0 ) {
      mprinterr("Error: Topology '%s' not found.\n", topname.c_str());
      err = 1;
    }
  } else {
    int topindex = argIn.getKeyInt("parmindex", -1);
    if (topindex > -1 && topindex < (int)TopList_.size())
      top = TopList_[topindex];
    if (topindex != -1 && top == 0) {
      mprinterr("Error: Topology index %i not found.\n", topindex);
      err = 1;
    }
  }
  return top;
}
Exemple #3
0
/** Search for a REF_FRAME DataSet. Provided for backwards compatibility
  * with the FrameList::GetFrameFromArgs() routine.
  * The keywords in order of precedence are:
  *   - 'ref <name>'  : Get reference frame by full/base filename or tag.
  *   - 'reference'   : First reference frame in list.
  *   - 'refindex <#>': Reference frame at position.
  * \param err Set to 1 if keyword present but no reference found, 0 otherwise.
  */
DataSet* DataSetList::GetReferenceSet(ArgList& argIn, int& err) const {
  DataSet* ref = 0;
  err = 0;
  std::string refname = argIn.GetStringKey("ref");
  if (!refname.empty()) {
    ref = FindSetOfType( refname, DataSet::REF_FRAME );
    if (ref == 0) {
      mprinterr("Error: Reference '%s' not found.\n", refname.c_str());
      err = 1;
    }
  } else {
    int refindex = argIn.getKeyInt("refindex", -1);
    if (argIn.hasKey("reference")) refindex = 0;
    if (refindex > -1 && refindex < (int)RefList_.size())
      ref = RefList_[refindex];
    if (refindex != -1 && ref == 0) {
      mprinterr("Error: Reference index %i not found.\n", refindex);
      err = 1;
    }
  }
  return ref;
}
/** Search for a REF_FRAME DataSet. Provided for backwards compatibility
  * with the FrameList::GetFrameFromArgs() routine.
  * The keywords in order of precedence are:
  *   - 'ref <name>'  : Get reference frame by full/base filename or tag.
  *   - 'reference'   : First reference frame in list.
  *   - 'refindex <#>': Reference frame at position.
  */
ReferenceFrame DataSetList::GetReferenceFrame(ArgList& argIn) const {
    DataSet* ref = 0;
    // 'ref <name>'
    std::string refname = argIn.GetStringKey("ref");
    if (!refname.empty()) {
        ref = FindSetOfType( refname, DataSet::REF_FRAME );
        if (ref == 0) {
            mprinterr("Error: Reference '%s' not found.\n", refname.c_str());
            return ReferenceFrame(1);
        }
    } else {
        int refindex = argIn.getKeyInt("refindex", -1);
        if (argIn.hasKey("reference")) refindex = 0;
        if (refindex > -1 && refindex < (int)RefList_.size())
            ref = RefList_[refindex];
        if (refindex != -1 && ref == 0) {
            mprinterr("Error: Reference index %i not found.\n", refindex);
            return ReferenceFrame(1);
        }
    }
    return ReferenceFrame((DataSet_Coords_REF*)ref);
}
Exemple #5
0
// DataSetList::GetTopology()
Topology* DataSetList::GetTopology(ArgList& argIn) const {
  if (TopList_.empty()) {
    mprinterr("Error: No topologies loaded.\n");
    return 0;
  }
  DataSet* top = 0;
  std::string topname = argIn.GetStringKey("parm");
  if (!topname.empty()) {
    top = FindSetOfType( topname, DataSet::TOPOLOGY );
    if ( top == 0 )
      mprinterr("Error: Topology '%s' not found.\n", topname.c_str());
  } else {
    int topindex = argIn.getKeyInt("parmindex", -1);
    if (topindex > -1 && topindex < (int)TopList_.size())
      top = TopList_[topindex];
    if (topindex != -1 && top == 0)
      mprinterr("Error: Topology index %i not found.\n", topindex);
  }
  if (top == 0)
    // By default return first parm if nothing else specified.
    top = TopList_.front();
  if (top == 0) return 0; // Sanity check
  return ((DataSet_Topology*)top)->TopPtr();
}