本文整理汇总了C++中OBAtom::IsConnected方法的典型用法代码示例。如果您正苦于以下问题:C++ OBAtom::IsConnected方法的具体用法?C++ OBAtom::IsConnected怎么用?C++ OBAtom::IsConnected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBAtom
的用法示例。
在下文中一共展示了OBAtom::IsConnected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
OBMolPairIter::OBMolPairIter(OBMol &mol)
{
_parent = &mol;
bool foundPair = false;
OBAtom *a = _parent->BeginAtom(_i);
if (!a)
return;
OBAtom *b = _parent->BeginAtom(_j);
while (!foundPair) {
b = _parent->NextAtom(_j);
if (!b) {
a = _parent->NextAtom(_i);
if (!a)
return;
b = _parent->BeginAtom(_j);
}
if (a->GetIdx() >= b->GetIdx()) continue;
if (a->IsConnected(b)) continue;
if (a->IsOneThree(b)) continue;
foundPair = true;
}
_pair.clear();
_pair.push_back(a->GetIdx());
_pair.push_back(b->GetIdx());
}
示例2: IsOnSameAtom
bool OBCisTransStereo::IsOnSameAtom(unsigned long id1, unsigned long id2) const
{
const OBMol *mol = GetMolecule();
if (!mol) {
obErrorLog.ThrowError(__FUNCTION__, "OBCisTransStereo::IsOnSameAtom : No valid molecule set", obError);
return false;
}
OBAtom *begin = mol->GetAtomById(m_cfg.begin);
if (!begin) {
obErrorLog.ThrowError(__FUNCTION__, "OBCisTransStereo::IsOnSameAtom : Begin reference id is not valid.", obError);
return false;
}
OBAtom *end = mol->GetAtomById(m_cfg.end);
if (!end) {
obErrorLog.ThrowError(__FUNCTION__, "OBCisTransStereo::IsOnSameAtom : End reference id is not valid.", obError);
return false;
}
OBAtom *a = mol->GetAtomById(id1);
OBAtom *b = mol->GetAtomById(id2);
if (a && b) {
// both on begin atom?
if (a->IsConnected(begin) && b->IsConnected(begin))
return true;
// both on end atom?
if (a->IsConnected(end) && b->IsConnected(end))
return true;
return false;
} else {
if (a) {
// b atom not found, could be a deleted hydrogen...
if (a->IsConnected(begin)) {
// a is connected to begin. if this is the atom missing a hydrogen, return false
if (begin->GetValence() == 2)
return true;
// check if the end atom really is missing an atom
if (end->GetValence() != 2) {
obErrorLog.ThrowError(__FUNCTION__,
"OBCisTransStereo::IsOnSameAtom : id2 is not valid and is not a missing hydrogen.", obError);
return false;
}
// inform user we are treating id2 as deleted hydrogen
obErrorLog.ThrowError(__FUNCTION__,
"OBCisTransStereo::IsOnSameAtom : Atom with id2 doesn't exist anymore, must be a (deleted) hydrogen.", obInfo);
} else if (a->IsConnected(end)) {
// a is connected to end. again, if this is the atom missing a hydrogen, return false
if (end->GetValence() == 2)
return true;
// check if the begin atom really is missing an atom
if (begin->GetValence() != 2) {
obErrorLog.ThrowError(__FUNCTION__,
"OBCisTransStereo::IsOnSameAtom : id2 is not valid and is not a missing hydrogen.", obError);
return true;
}
// inform user we are treating id2 as deleted hydrogen
obErrorLog.ThrowError(__FUNCTION__,
"OBCisTransStereo::IsOnSameAtom : Atom with id2 doesn't exist, must be a (deleted) hydrogen.", obInfo);
} else {
obErrorLog.ThrowError(__FUNCTION__,
"OBCisTransStereo::IsOnSameAtom : Atom with id1 isn't connected to the begin or end atom.", obError);
return true;
}
} else if (b) {
// a atom not found, could be a deleted hydrogen...
if (b->IsConnected(begin)) {
// b is connected to begin. if this is the atom missing a hydrogen, return false
if (begin->GetValence() == 2)
return true;
// check if the end atom really is missing an atom
if (end->GetValence() != 2) {
obErrorLog.ThrowError(__FUNCTION__,
"OBCisTransStereo::IsOnSameAtom : id1 is not valid and is not a missing hydrogen.", obError);
return true;
}
// inform user we are treating id1 as deleted hydrogen
obErrorLog.ThrowError(__FUNCTION__,
"OBCisTransStereo::IsOnSameAtom : Atom with id1 doesn't exist, must be a (deleted) hydrogen.", obInfo);
} else if (b->IsConnected(end)) {
// a is connected to end. again, if this is the atom missing a hydrogen, return false
if (end->GetValence() == 2)
return true;
// check if the begin atom really is missing an atom
if (begin->GetValence() != 2) {
obErrorLog.ThrowError(__FUNCTION__,
"OBCisTransStereo::IsOnSameAtom : id1 is not valid and is not a missing hydrogen.", obError);
return true;
}
// inform user we are treating id2 as deleted hydrogen
obErrorLog.ThrowError(__FUNCTION__,
"OBCisTransStereo::IsOnSameAtom : Atom with id1 doesn't exist, must be a (deleted) hydrogen.", obInfo);
} else {
obErrorLog.ThrowError(__FUNCTION__,
"OBCisTransStereo::IsOnSameAtom : Atom with id1 isn't connected to the begin or end atom.", obError);
return true;
}
} else {
OBAtom *c = 0, *d = 0;
//.........这里部分代码省略.........