本文整理汇总了C++中OBBond::SetData方法的典型用法代码示例。如果您正苦于以下问题:C++ OBBond::SetData方法的具体用法?C++ OBBond::SetData怎么用?C++ OBBond::SetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBBond
的用法示例。
在下文中一共展示了OBBond::SetData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddDataToSubstruct
/**
@since version 2.3
Adds an OBPairData object to each atom and bond in a substructure.
The substructure's atoms are specified in an input parameter, a
vector of atom indx; the bonds are those in the molecule that join
these atoms. The attribute and value of the OBPairObject (the same
for all the added objects) are specified as parameters.
**/
bool AddDataToSubstruct(OBMol* pmol,
const std::vector<int>& atomIdxs,
const std::string& attribute,
const std::string& value)
{
//Add data to atoms
for(unsigned int j=0; j<atomIdxs.size(); ++j)
{
OBAtom* pAtom = pmol->GetAtom(atomIdxs[j]);
if(!pAtom)
continue;
OBPairData* dp = new OBPairData;
dp->SetAttribute(attribute);
dp->SetValue(value);
pAtom->SetData(dp);
}
OBBond* pBond;
vector<OBBond*>::iterator i;
for(pBond = pmol->BeginBond(i); pBond; pBond = pmol->NextBond(i))
{
//Add data to bond if it joins two atoms in list
if(count(atomIdxs.begin(), atomIdxs.end(), pBond->GetBeginAtomIdx())
&& count(atomIdxs.begin(), atomIdxs.end(), pBond->GetEndAtomIdx()))
{
OBPairData* dp = new OBPairData;
dp->SetAttribute(attribute);
dp->SetValue(value);
pBond->SetData(dp);
}
}
return true;
}