本文整理汇总了C++中Molecule::edgeCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Molecule::edgeCount方法的具体用法?C++ Molecule::edgeCount怎么用?C++ Molecule::edgeCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Molecule
的用法示例。
在下文中一共展示了Molecule::edgeCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertMolfile
void convertMolfile (char *path, char *filename, FileOutput &cpp_file)
{
FileScanner molfile("%s\\%s", path, filename);
MolfileLoader mf_loader(molfile);
Molecule mol;
QS_DEF(Array<int>, edges);
printf("%s\n", filename);
mf_loader.loadMolecule(mol, true);
BiconnectedDecomposer bd(mol);
if (bd.decompose() != 1)
{
printf("Error: %s is not biconnected\n", filename);
return;
}
int i, j;
edges.clear_reserve(mol.edgeCount());
for (i = mol.edgeBegin() ; i < mol.edgeEnd(); i = mol.edgeNext(i))
edges.push(i);
edges.qsort(edge_cmp, &mol);
const Edge &edge = mol.getEdge(edges[edges.size() / 2]);
Vec3f v1 = mol.getAtomPos(edge.beg);
Vec3f v2 = mol.getAtomPos(edge.end);
v1.z = 0.f;
v2.z = 0.f;
float scale = Vec3f::dist(v1, v2);
if (scale < 0.0001f)
{
printf("Error: %s has zero bond\n", filename);
return;
}
scale = 1.f / scale;
int first_idx = mol.vertexBegin();
Vec3f pos = mol.getAtomPos(first_idx);
for (i = mol.vertexNext(first_idx); i < mol.vertexEnd(); i = mol.vertexNext(i))
{
if (mol.getAtomPos(i).y < pos.y)
{
pos = mol.getAtomPos(i);
first_idx = i;
}
}
for (i = mol.vertexBegin() ; i < mol.vertexEnd(); i = mol.vertexNext(i))
{
mol.getAtom2(i).pos.sub(pos);
mol.getAtom2(i).pos.scale(scale);
}
char buf[1024];
sprintf_s(buf, "BEGIN_PATTERN(\"%s\")", filename);
cpp_file.writeStringCR(buf);
for (i = mol.vertexBegin(); i < mol.vertexEnd(); i = mol.vertexNext(i))
{
sprintf_s(buf, " ADD_ATOM(%d, %ff, %ff)", i, mol.getAtomPos(i).x, mol.getAtomPos(i).y);
cpp_file.writeStringCR(buf);
}
for (i = mol.edgeBegin(); i < mol.edgeEnd(); i = mol.edgeNext(i))
{
const Edge &edge = mol.getEdge(i);
int type = mol.getBond(i).type;
int qtype = mol.getQueryBond(i).type;
sprintf_s(buf, " ADD_BOND(%d, %d, %d)", edge.beg, edge.end, qtype != 0 ? qtype : type);
cpp_file.writeStringCR(buf);
}
Vec2f v, inter;
Vec2f pos_i;
int idx = mol.vertexCount();
i = first_idx;
float max_angle, cur_angle;
float i_angle = 0;
int next_nei = 0;
int point_idx = 0;
pos_i.set(mol.getAtomPos(i).x, mol.getAtomPos(i).y);
while (true)
//.........这里部分代码省略.........
示例2: _loadMolecule
void CrfLoader::_loadMolecule (Molecule &molecule)
{
Obj<CmfLoader> loader;
int i;
if (_decoder.get() != 0)
loader.create(_decoder.ref());
else
loader.create(_scanner);
QS_DEF(Array<int>, atom_flags);
QS_DEF(Array<int>, bond_flags);
loader->atom_flags = &atom_flags;
loader->bond_flags = &bond_flags;
loader->version = version;
loader->loadMolecule(molecule);
bool has_mapping = loader->has_mapping;
if (_atom_stereo_flags != 0)
{
_atom_stereo_flags->clear_resize(molecule.vertexCount());
_atom_stereo_flags->zerofill();
for (i = 0; i < molecule.vertexCount(); i++)
{
int idx = i;
if (has_mapping)
idx = loader->inv_atom_mapping_to_restore[i];
if (atom_flags[i] & 1)
_atom_stereo_flags->at(idx) |= STEREO_RETAINS;
if (atom_flags[i] & 2)
_atom_stereo_flags->at(idx) |= STEREO_INVERTS;
}
}
if (_bond_rc_flags != 0)
{
_bond_rc_flags->clear_resize(molecule.edgeCount());
_bond_rc_flags->zerofill();
for (i = 0; i < molecule.edgeCount(); i++)
{
int idx = i;
if (has_mapping)
idx = loader->inv_bond_mapping_to_restore[i];
if (bond_flags[i] & 1)
_bond_rc_flags->at(idx) |= RC_UNCHANGED;
if (bond_flags[i] & 2)
_bond_rc_flags->at(idx) |= RC_MADE_OR_BROKEN;
if (bond_flags[i] & 4)
_bond_rc_flags->at(idx) |= RC_ORDER_CHANGED;
}
}
if (_aam != 0)
{
_aam->clear_resize(molecule.vertexCount());
_aam->zerofill();
for (i = 0; i < molecule.vertexCount(); i++)
{
int value;
if (_decoder.get() != 0)
value = _decoder->get();
else
value = _scanner.readByte();
int idx = i;
if (has_mapping)
idx = loader->inv_atom_mapping_to_restore[i];
_aam->at(idx) = value - 1;
}
}
if (xyz_scanner != 0)
loader->loadXyz(*xyz_scanner);
}