本文整理汇总了C++中Topology::SetupCharMask方法的典型用法代码示例。如果您正苦于以下问题:C++ Topology::SetupCharMask方法的具体用法?C++ Topology::SetupCharMask怎么用?C++ Topology::SetupCharMask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topology
的用法示例。
在下文中一共展示了Topology::SetupCharMask方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mprintf
/** Based on the given atom mask expression determine what molecules are
* selected by the mask.
* \return A list of atom pairs that mark the beginning and end of each
* selected molecule.
*/
Action_AutoImage::pairList
Action_AutoImage::SetupAtomRanges( Topology const& currentParm, std::string const& maskexpr )
{
pairList imageList;
CharMask Mask1( maskexpr.c_str() );
if (currentParm.SetupCharMask( Mask1 )) return imageList;
if (Mask1.None()) return imageList;
for (Topology::mol_iterator mol = currentParm.MolStart(); mol != currentParm.MolEnd(); mol++)
{
int firstAtom = mol->BeginAtom();
int lastAtom = mol->EndAtom();
// Check that each atom in the range is in Mask1
bool rangeIsValid = true;
for (int atom = firstAtom; atom < lastAtom; ++atom) {
if (!Mask1.AtomInCharMask(atom)) {
rangeIsValid = false;
break;
}
}
if (rangeIsValid) {
imageList.push_back( firstAtom );
imageList.push_back( lastAtom );
}
}
mprintf("\tMask [%s] corresponds to %zu molecules\n", Mask1.MaskString(), imageList.size()/2);
return imageList;
}
示例2: CreatePairList
/** An atom pair list consists of 2 values for each entry, a beginning
* index and ending index. For molecules and residues this is the first
* and just beyond the last atom; for atoms it is just the atom itself
* twice.
*/
Image::PairType Image::CreatePairList(Topology const& Parm, Mode modeIn,
std::string const& maskExpression)
{
PairType atomPairs;
// Set up mask based on desired imaging mode.
if ( modeIn == BYMOL || modeIn == BYRES ) {
CharMask cmask( maskExpression );
if ( Parm.SetupCharMask( cmask ) ) return atomPairs;
cmask.MaskInfo();
if (cmask.None()) return atomPairs;
// Set up atom range for each entity to be imaged.
if (modeIn == BYMOL) {
atomPairs.reserve( Parm.Nmol()*2 );
for (Topology::mol_iterator mol = Parm.MolStart();
mol != Parm.MolEnd(); ++mol)
CheckRange( atomPairs, cmask, mol->BeginAtom(), mol->EndAtom());
} else { // BYRES
atomPairs.reserve( Parm.Nres()*2 );
for (Topology::res_iterator residue = Parm.ResStart();
residue != Parm.ResEnd(); ++residue)
CheckRange( atomPairs, cmask, residue->FirstAtom(), residue->LastAtom() );
}
} else { // BYATOM
AtomMask imask( maskExpression );
if ( Parm.SetupIntegerMask( imask ) ) return atomPairs;
imask.MaskInfo();
if (imask.None()) return atomPairs;
atomPairs.reserve( Parm.Natom()*2 );
for (AtomMask::const_iterator atom = imask.begin(); atom != imask.end(); ++atom) {
atomPairs.push_back( *atom );
atomPairs.push_back( (*atom)+1 );
}
}
// mprintf("\tNumber of %ss to be imaged is %zu based on mask '%s'\n",
// ModeString[modeIn], atomPairs.size()/2, maskIn.MaskString());
return atomPairs;
}