本文整理汇总了C++中AtomMask::SetMaskString方法的典型用法代码示例。如果您正苦于以下问题:C++ AtomMask::SetMaskString方法的具体用法?C++ AtomMask::SetMaskString怎么用?C++ AtomMask::SetMaskString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AtomMask
的用法示例。
在下文中一共展示了AtomMask::SetMaskString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
// Action_Center::Init()
Action::RetType Action_Center::Init(ArgList& actionArgs, ActionInit& init, int debugIn)
{
// Get keywords
useMass_ = actionArgs.hasKey("mass");
ReferenceFrame refFrm = init.DSL().GetReferenceFrame( actionArgs );
if (refFrm.error()) return Action::ERR;
// Determine center mode.
if (!refFrm.empty())
centerMode_ = REF;
else if (actionArgs.hasKey("origin"))
centerMode_ = ORIGIN;
else if (actionArgs.hasKey("point")) {
centerMode_ = POINT;
refCenter_[0] = actionArgs.getNextDouble(0.0);
refCenter_[1] = actionArgs.getNextDouble(0.0);
refCenter_[2] = actionArgs.getNextDouble(0.0);
} else
centerMode_ = BOXCTR;
// Get Masks
Mask_.SetMaskString( actionArgs.GetMaskNext() );
// Get reference mask if reference specified.
AtomMask refMask;
if (centerMode_ == REF) {
std::string rMaskExpr = actionArgs.GetMaskNext();
if (rMaskExpr.empty())
rMaskExpr = Mask_.MaskExpression();
refMask.SetMaskString( rMaskExpr );
if (refFrm.Parm().SetupIntegerMask( refMask, refFrm.Coord() ))
return Action::ERR;
// Get center of mask in reference
if (useMass_)
refCenter_ = refFrm.Coord().VCenterOfMass( refMask );
else
refCenter_ = refFrm.Coord().VGeometricCenter( refMask );
}
mprintf(" CENTER: Centering coordinates using");
if (useMass_)
mprintf(" center of mass");
else
mprintf(" geometric center");
mprintf(" of atoms in mask (%s) to\n", Mask_.MaskString());
switch (centerMode_) {
case ORIGIN: mprintf("\tcoordinate origin.\n"); break;
case BOXCTR: mprintf("\tbox center.\n"); break;
case REF:
mprintf("\tcenter of mask (%s) in reference '%s'.\n", refMask.MaskString(),
refFrm.refName());
break;
case POINT: mprintf("\tpoint (%g, %g, %g).\n",
refCenter_[0], refCenter_[1], refCenter_[2]);
break;
}
return Action::OK;
}
示例2: Init
// Action_Center::Init()
Action::RetType Action_Center::Init(ArgList& actionArgs, TopologyList* PFL, DataSetList* DSL, DataFileList* DFL, int debugIn)
{
// Get keywords
if (actionArgs.hasKey("origin"))
centerMode_ = ORIGIN;
else
centerMode_ = BOXCTR;
useMass_ = actionArgs.hasKey("mass");
ReferenceFrame refFrm = DSL->GetReferenceFrame( actionArgs );
if (refFrm.error()) return Action::ERR;
// Get Masks
Mask_.SetMaskString( actionArgs.GetMaskNext() );
// Get reference mask if reference specified.
AtomMask refMask;
if (!refFrm.empty()) {
std::string rMaskExpr = actionArgs.GetMaskNext();
if (rMaskExpr.empty())
rMaskExpr = Mask_.MaskExpression();
refMask.SetMaskString( rMaskExpr );
if (refFrm.Parm().SetupIntegerMask( refMask, refFrm.Coord() ))
return Action::ERR;
// Get center of mask in reference
if (useMass_)
refCenter_ = refFrm.Coord().VCenterOfMass( refMask );
else
refCenter_ = refFrm.Coord().VGeometricCenter( refMask );
centerMode_ = POINT;
}
mprintf(" CENTER: Centering coordinates using");
if (useMass_)
mprintf(" center of mass");
else
mprintf(" geometric center");
mprintf(" of atoms in mask (%s) to\n", Mask_.MaskString());
if (centerMode_ == POINT)
mprintf("\tcenter of mask (%s) in reference '%s'.\n", refMask.MaskString(),
refFrm.refName());
else if (centerMode_ == ORIGIN)
mprintf("\tcoordinate origin.\n");
else
mprintf("\tbox center.\n");
return Action::OK;
}
示例3: SetupBlock
/** Set up each mask/integer loop. */
int ControlBlock_For::SetupBlock(CpptrajState& State, ArgList& argIn) {
mprintf(" Setting up 'for' loop.\n");
Vars_.clear();
Topology* currentTop = 0;
static const char* TypeStr[] = { "ATOMS ", "RESIDUES ", "MOLECULES ",
"MOL_FIRST_RES ", "MOL_LAST_RES " };
static const char* OpStr[] = {"+=", "-=", "<", ">"};
description_.assign("for (");
int MaxIterations = -1;
int iarg = 0;
while (iarg < argIn.Nargs())
{
// Advance to next unmarked argument.
while (iarg < argIn.Nargs() && argIn.Marked(iarg)) iarg++;
if (iarg == argIn.Nargs()) break;
// Determine 'for' type
ForType ftype = UNKNOWN;
bool isMaskFor = true;
int argToMark = iarg;
if ( argIn[iarg] == "atoms" ) ftype = ATOMS;
else if ( argIn[iarg] == "residues" ) ftype = RESIDUES;
else if ( argIn[iarg] == "molecules" ) ftype = MOLECULES;
else if ( argIn[iarg] == "molfirstres" ) ftype = MOLFIRSTRES;
else if ( argIn[iarg] == "mollastres" ) ftype = MOLLASTRES;
else if ( argIn[iarg].find(";") != std::string::npos ) {
isMaskFor = false;
ftype = INTEGER;
}
// If type is still unknown, check for list.
if (ftype == UNKNOWN) {
if (iarg+1 < argIn.Nargs() && argIn[iarg+1] == "in") {
ftype = LIST;
isMaskFor = false;
argToMark = iarg+1;
}
}
// Exit if type could not be determined.
if (ftype == UNKNOWN) {
mprinterr("Error: for loop type not specfied.\n");
return 1;
}
argIn.MarkArg(argToMark);
Vars_.push_back( LoopVar() );
LoopVar& MH = Vars_.back();
int Niterations = -1;
// Set up for specific type
if (description_ != "for (") description_.append(", ");
// -------------------------------------------
if (isMaskFor)
{
// {atoms|residues|molecules} <var> inmask <mask> [TOP KEYWORDS]
if (argIn[iarg+2] != "inmask") {
mprinterr("Error: Expected 'inmask', got %s\n", argIn[iarg+2].c_str());
return 1;
}
AtomMask currentMask;
if (currentMask.SetMaskString( argIn.GetStringKey("inmask") )) return 1;
MH.varType_ = ftype;
Topology* top = State.DSL().GetTopByIndex( argIn );
if (top != 0) currentTop = top;
if (currentTop == 0) return 1;
MH.varname_ = argIn.GetStringNext();
if (MH.varname_.empty()) {
mprinterr("Error: 'for inmask': missing variable name.\n");
return 1;
}
MH.varname_ = "$" + MH.varname_;
// Set up mask
if (currentTop->SetupIntegerMask( currentMask )) return 1;
currentMask.MaskInfo();
if (currentMask.None()) return 1;
// Set up indices
if (MH.varType_ == ATOMS)
MH.Idxs_ = currentMask.Selected();
else if (MH.varType_ == RESIDUES) {
int curRes = -1;
for (AtomMask::const_iterator at = currentMask.begin(); at != currentMask.end(); ++at) {
int res = (*currentTop)[*at].ResNum();
if (res != curRes) {
MH.Idxs_.push_back( res );
curRes = res;
}
}
} else if (MH.varType_ == MOLECULES ||
MH.varType_ == MOLFIRSTRES ||
MH.varType_ == MOLLASTRES)
{
int curMol = -1;
for (AtomMask::const_iterator at = currentMask.begin(); at != currentMask.end(); ++at) {
int mol = (*currentTop)[*at].MolNum();
if (mol != curMol) {
if (MH.varType_ == MOLECULES)
MH.Idxs_.push_back( mol );
else {
int res;
if (MH.varType_ == MOLFIRSTRES)
res = (*currentTop)[ currentTop->Mol( mol ).BeginAtom() ].ResNum();
else // MOLLASTRES
res = (*currentTop)[ currentTop->Mol( mol ).EndAtom()-1 ].ResNum();
//.........这里部分代码省略.........