本文整理汇总了C++中BaseMolecule::getEdge方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseMolecule::getEdge方法的具体用法?C++ BaseMolecule::getEdge怎么用?C++ BaseMolecule::getEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseMolecule
的用法示例。
在下文中一共展示了BaseMolecule::getEdge方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _placeSGroupBracketsCrossBondSingle
void _placeSGroupBracketsCrossBondSingle (Array<Vec2f[2]>& brackets, BaseMolecule& mol, const Array<int>& atoms, int bid, bool out, float bondLength)
{
brackets.clear();
const Edge& edge = mol.getEdge(bid);
int aidIn = edge.beg, aidOut = edge.end;
if (!out) {
int t;
__swap(aidIn, aidOut, t);
}
Vec2f p2dIn, p2dOut, d, n, b1, b2;
Vec2f::projectZ(p2dIn, mol.getAtomXyz(aidIn));
Vec2f::projectZ(p2dOut, mol.getAtomXyz(aidOut));
d.diff(p2dOut, p2dIn);
d.normalize();
n.copy(d);
n.rotate(1, 0);
Vec2f min, max, a, b;
for (int i = 0; i < atoms.size(); ++i) {
int aid = atoms[i];
const Vec3f& pos = mol.getAtomXyz(aid);
Vec2f p2d;
Vec2f::projectZ(p2d, pos);
p2d.sub(p2dIn);
p2d.set(Vec2f::dot(p2d, d), Vec2f::dot(p2d, n));
if (i == 0) {
min.copy(p2d);
max.copy(p2d);
} else {
min.min(p2d);
max.max(p2d);
}
}
b1.lineCombin(p2dIn, d, max.x + 0.3f * bondLength);
b2.copy(b1);
float factor = 0.5;
b1.addScaled(n, factor * bondLength);
b2.addScaled(n, -factor * bondLength);
Vec2f* const & bracket1 = brackets.push();
bracket1[0].copy(b1);
bracket1[1].copy(b2);
b1.lineCombin(p2dIn, d, min.x - 0.3f * bondLength);
b2.copy(b1);
b1.addScaled(n, -factor * bondLength);
b2.addScaled(n, factor * bondLength);
Vec2f* const & bracket2 = brackets.push();
bracket2[0].copy(b1);
bracket2[1].copy(b2);
}
示例2: getTotalMoleculeBondLength
float Metalayout::getTotalMoleculeBondLength (BaseMolecule& mol)
{
Vec2f v1, v2;
float sum = 0;
for (int i = mol.edgeBegin(); i < mol.edgeEnd(); i = mol.edgeNext(i))
{
const Edge& edge = mol.getEdge(i);
Vec2f::projectZ(v1, mol.getAtomXyz(edge.beg));
Vec2f::projectZ(v2, mol.getAtomXyz(edge.end));
sum += Vec2f::dist(v1, v2);
}
return sum;
}
示例3: isAutomorphism
bool MoleculeCisTrans::isAutomorphism (BaseMolecule &mol, const Array<int> &mapping, const Filter *edge_filter)
{
for (int i = mol.edgeBegin(); i != mol.edgeEnd(); i = mol.edgeNext(i))
{
if (edge_filter && !edge_filter->valid(i))
continue;
const Edge &edge = mol.getEdge(i);
int parity = mol.cis_trans.getParity(i);
int parity2 = MoleculeCisTrans::applyMapping(parity, mol.cis_trans.getSubstituents(i),
mapping.ptr(), false);
int i2 = mol.findEdgeIndex(mapping[edge.beg], mapping[edge.end]);
if (mol.cis_trans.getParity(i2) != parity2)
return false;
}
return true;
}
示例4: _getBounds
void _getBounds (RenderParams& params, BaseMolecule &mol, Vec2f &min, Vec2f &max, float &scale)
{
// Compute average bond length
float avg_bond_length = 1;
if (mol.edgeCount() > 0)
{
float bond_length_sum = 0;
for (int i = mol.edgeBegin(); i != mol.edgeEnd(); i = mol.edgeNext(i))
{
const Edge& edge = mol.getEdge(i);
const Vec3f &p1 = mol.getAtomXyz(edge.beg);
const Vec3f &p2 = mol.getAtomXyz(edge.end);
bond_length_sum += Vec3f::dist(p1, p2);
}
avg_bond_length = bond_length_sum / mol.edgeCount();
}
float bond_length = 1;
if (params.cnvOpt.bondLength > 0)
bond_length = params.cnvOpt.bondLength / 100.0f;
scale = bond_length / avg_bond_length;
for (int i = mol.vertexBegin(); i != mol.vertexEnd(); i = mol.vertexNext(i))
{
Vec3f &p = mol.getAtomXyz(i);
Vec2f p2(p.x, p.y);
if (i == mol.vertexBegin())
min = max = p2;
else
{
min.min(p2);
max.max(p2);
}
}
min.scale(scale);
max.scale(scale);
}
示例5: _collectCrossBonds
void _collectCrossBonds (Array<int>& crossBonds, Array<bool>& crossBondOut, BaseMolecule& mol, const Array<int>& atoms)
{
QS_DEF(Array<bool>, atomMask);
atomMask.clear_resize(mol.vertexEnd());
atomMask.fill(false);
for (int i = 0; i < atoms.size(); ++i) {
int aid = atoms[i];
atomMask[aid] = true;
}
crossBonds.clear();
crossBondOut.clear();
for (int i = 0; i < atoms.size(); ++i) {
int aid = atoms[i];
const Vertex& v = mol.getVertex(aid);
for (int j = v.neiBegin(); j < v.neiEnd(); j = v.neiNext(j)) {
int naid = v.neiVertex(j);
if (!atomMask[naid]) {
int bid = v.neiEdge(j);
crossBonds.push(bid);
crossBondOut.push(mol.getEdge(bid).beg == aid);
}
}
}
}
示例6: _fillExplicitHydrogens
void MoleculeCisTrans::_fillExplicitHydrogens (BaseMolecule &mol, int bond_idx, int subst[4])
{
_fillAtomExplicitHydrogens(mol, mol.getEdge(bond_idx).beg, subst);
_fillAtomExplicitHydrogens(mol, mol.getEdge(bond_idx).end, subst + 2);
}
示例7: isGeomStereoBond
bool MoleculeCisTrans::isGeomStereoBond (BaseMolecule &mol, int bond_idx,
int *substituents, bool have_xyz)
{
int substituents_local[4];
if (substituents == 0)
substituents = substituents_local;
// it must be [C,N,Si,Ge]=[C,N,Si,Ge] bond
if (!mol.possibleBondOrder(bond_idx, BOND_DOUBLE))
return false;
const Edge &edge = mol.getEdge(bond_idx);
int beg_idx = edge.beg;
int end_idx = edge.end;
if (!mol.possibleAtomNumber(beg_idx, ELEM_C) &&
!mol.possibleAtomNumber(beg_idx, ELEM_N) &&
!mol.possibleAtomNumber(beg_idx, ELEM_Si) &&
!mol.possibleAtomNumber(beg_idx, ELEM_Ge))
return false;
if (!mol.possibleAtomNumber(end_idx, ELEM_C) &&
!mol.possibleAtomNumber(end_idx, ELEM_N) &&
!mol.possibleAtomNumber(end_idx, ELEM_Si) &&
!mol.possibleAtomNumber(end_idx, ELEM_Ge))
return false;
// Double bonds with R-sites are excluded because cis-trans configuration
// cannot be determined when R-site is substituted with R-group
if (mol.isRSite(beg_idx) || mol.isRSite(end_idx))
return false;
// the atoms should have 1 or 2 single bonds
// (apart from the double bond under consideration)
const Vertex &beg = mol.getVertex(beg_idx);
const Vertex &end = mol.getVertex(end_idx);
if (beg.degree() < 2 || beg.degree() > 3 ||
end.degree() < 2 || end.degree() > 3)
return false;
substituents[0] = -1;
substituents[1] = -1;
substituents[2] = -1;
substituents[3] = -1;
int i;
for (i = beg.neiBegin(); i != beg.neiEnd(); i = beg.neiNext(i))
{
int nei_edge_idx = beg.neiEdge(i);
if (nei_edge_idx == bond_idx)
continue;
if (!mol.possibleBondOrder(nei_edge_idx, BOND_SINGLE))
return false;
if (substituents[0] == -1)
substituents[0] = beg.neiVertex(i);
else // (substituents[1] == -1)
substituents[1] = beg.neiVertex(i);
}
for (i = end.neiBegin(); i != end.neiEnd(); i = end.neiNext(i))
{
int nei_edge_idx = end.neiEdge(i);
if (nei_edge_idx == bond_idx)
continue;
if (!mol.possibleBondOrder(nei_edge_idx, BOND_SINGLE))
return false;
if (substituents[2] == -1)
substituents[2] = end.neiVertex(i);
else // (substituents[3] == -1)
substituents[3] = end.neiVertex(i);
}
// Check trianges when substituents are the same: CC1=C(N)C1
if (substituents[0] >= 0)
if (substituents[0] == substituents[2] || substituents[0] == substituents[3])
return false;
if (substituents[1] >= 0)
if (substituents[1] == substituents[2] || substituents[1] == substituents[3])
return false;
if (have_xyz)
{
if (substituents[1] != -1 &&
_sameside(mol, beg_idx, end_idx, substituents[0], substituents[1]) != -1)
return false;
else if (_sameline(mol, beg_idx, end_idx, substituents[0]))
return false;
if (substituents[3] != -1 &&
_sameside(mol, beg_idx, end_idx, substituents[2], substituents[3]) != -1)
return false;
else if (_sameline(mol, beg_idx, end_idx, substituents[2]))
//.........这里部分代码省略.........
示例8: _placeSGroupBracketsCrossBonds
void _placeSGroupBracketsCrossBonds (Array<Vec2f[2]>& brackets, BaseMolecule& mol, const Array<int>& atoms, const Array<int>& crossBonds, const Array<bool>& crossBondOut, float bondLength)
{
brackets.clear();
if (crossBonds.size() == 2) {
int bid1 = crossBonds[0], bid2 = crossBonds[1];
const Edge& edge1 = mol.getEdge(bid1);
const Edge& edge2 = mol.getEdge(bid2);
Vec2f pb1, pe1, pb2, pe2;
Vec2f::projectZ(pb1, mol.getAtomXyz(edge1.beg));
Vec2f::projectZ(pe1, mol.getAtomXyz(edge1.end));
Vec2f::projectZ(pb2, mol.getAtomXyz(edge2.beg));
Vec2f::projectZ(pe2, mol.getAtomXyz(edge2.end));
Vec2f d1, d2;
d1.diff(pe1, pb1);
if (!crossBondOut[0])
d1.scale(-1);
d1.normalize();
d2.diff(pe2, pb2);
if (!crossBondOut[1])
d2.scale(-1);
d2.normalize();
if (Vec2f::dot(d1, d2) < -0.3) {
Vec2f d, n;
d.add(pb1);
d.add(pe1);
d.sub(pb2);
d.sub(pe2);
d.normalize();
n.copy(d);
n.rotate(1, 0);
Vec2f min, max, a, b, c;
c.add(pb1);
c.add(pe1);
c.add(pb2);
c.add(pe2);
c.scale(0.25f);
for (int i = 0; i < atoms.size(); ++i) {
int aid = atoms[i];
const Vec3f& pos = mol.getAtomXyz(aid);
Vec2f p2d;
Vec2f::projectZ(p2d, pos);
p2d.sub(c);
p2d.set(Vec2f::dot(p2d, d), Vec2f::dot(p2d, n));
if (i == 0) {
min.copy(p2d);
max.copy(p2d);
} else {
min.min(p2d);
max.max(p2d);
}
}
Vec2f b1(c), b2;
b1.addScaled(d, max.x + 0.3f * bondLength);
b2.copy(b1);
float factor = 0.5;
b1.addScaled(n, factor * bondLength);
b2.addScaled(n, -factor * bondLength);
Vec2f* const & bracket1 = brackets.push();
bracket1[0].copy(b1);
bracket1[1].copy(b2);
b1.copy(c);
b1.addScaled(d, min.x - 0.3f * bondLength);
b2.copy(b1);
b1.addScaled(n, -factor * bondLength);
b2.addScaled(n, factor * bondLength);
Vec2f* const & bracket2 = brackets.push();
bracket2[0].copy(b1);
bracket2[1].copy(b2);
return;
}
}
for (int i = 0; i < crossBonds.size(); ++i) {
int bid = crossBonds[i];
const Edge& edge = mol.getEdge(bid);
int aidIn = edge.beg, aidOut = edge.end;
if (!crossBondOut[i]) {
int t;
__swap(aidIn, aidOut, t);
}
Vec2f p2dIn, p2dOut, d, n, b1, b2;
Vec2f::projectZ(p2dIn, mol.getAtomXyz(aidIn));
Vec2f::projectZ(p2dOut, mol.getAtomXyz(aidOut));
d.diff(p2dOut, p2dIn);
d.normalize();
n.copy(d);
n.rotate(1, 0);
float offset = 1.0f / 3;
b1.lineCombin2(p2dIn, 1 - offset, p2dOut, offset);
b2.copy(b1);
float factor = 0.5;
b1.addScaled(n, factor * bondLength);
b2.addScaled(n, -factor * bondLength);
Vec2f* const & bracket = brackets.push();
bracket[0].copy(b1);
bracket[1].copy(b2);
}
}