当前位置: 首页>>代码示例>>C++>>正文


C++ Molecule::atoms方法代码示例

本文整理汇总了C++中Molecule::atoms方法的典型用法代码示例。如果您正苦于以下问题:C++ Molecule::atoms方法的具体用法?C++ Molecule::atoms怎么用?C++ Molecule::atoms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Molecule的用法示例。


在下文中一共展示了Molecule::atoms方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: paint

  void StereoCenterItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
  {
    Molecule *mol = molecule();
    
    painter->save();
    painter->setPen(Qt::green);

    if (!mol) {
      // not connected: default behaviour (draw connectable box)
      MolInputItem::paint(painter, option, widget);
      painter->restore();
      return;
    }

    const QList<Atom*> &atoms = mol->atoms();
    OpenBabel::OBMol *obmol = mol->OBMol();
    QPointF offset(-5.0, 5.0);

#ifdef OPENBABEL2_TRUNK
    // need to calculate symmetry first
    std::vector<unsigned int> symmetry_classes;
    OpenBabel::OBGraphSym graphsym(obmol);
    graphsym.GetSymmetry(symmetry_classes);

    //std::vector<unsigned long> atomIds = FindTetrahedralAtoms(obmol, symmetry_classes);
    std::vector<OpenBabel::StereogenicUnit> units = FindStereogenicUnits(obmol, symmetry_classes);
    
    for (unsigned int i = 0; i < units.size(); ++i) {
      if (units.at(i).type == OpenBabel::OBStereo::Tetrahedral) {
        OpenBabel::OBAtom *obatom = obmol->GetAtomById(units.at(i).id);
        painter->drawEllipse(mapFromItem(mol, atoms[obatom->GetIndex()]->pos()), 10, 10);
      } else 
      if (units.at(i).type == OpenBabel::OBStereo::CisTrans) {
        OpenBabel::OBBond *obbond = obmol->GetBondById(units.at(i).id);
        OpenBabel::OBAtom *obatom1 = obbond->GetBeginAtom();
        OpenBabel::OBAtom *obatom2 = obbond->GetEndAtom();
        painter->drawEllipse(mapFromItem(mol, atoms[obatom1->GetIndex()]->pos()), 10, 10);
        painter->drawEllipse(mapFromItem(mol, atoms[obatom2->GetIndex()]->pos()), 10, 10);
      } 
 
    }
#else
    using OpenBabel::OBMolAtomIter;
    FOR_ATOMS_OF_MOL(atom, obmol)
      if (atom->IsChiral())
        painter->drawEllipse(mapFromItem(mol, atoms[atom->GetIdx()-1]->pos()), 10, 10);
#endif

    // default behavious (draw the label())
    MolInputItem::paint(painter, option, widget);
    painter->restore();
  }
开发者ID:timvdm,项目名称:Molsketch,代码行数:52,代码来源:stereocenteritem.cpp

示例2: main

int main (int argc, char *argv[])
{
  if (argc < 2) {
    cout << "Usage: " << argv[0] << " {filename}" << endl;
    return 1;
  }

  Molecule mol;
  // loop through the filenames
  for (unsigned int a = 1; a < argc; ++a) {
    if (!readXYZ(mol, argv[a]))
      cout << "Cannot read the XYZ file" << endl;

    mol.perceiveBonds();

    cout << "Molecule has " << mol.numberOfAtoms() << " atoms and " << mol.numberOfBonds() << " bonds." << endl;
    
    mol.doMatching();

    std::vector<Atom*> atoms = mol.atoms();
    unsigned int j = 0;
    for (std::vector<Atom*>::iterator i = atoms.begin(); i < atoms.end(); ++i, ++j) {
      if ((*i)->atomicNum() == 6 && (*i)->numberOfDoubleBonds() != 1) {
        // cout << " failed matching on atom " << j << endl;
        cout << " failed matching on atom " << *i << endl;
        cout << " has " << (*i)->numberOfDoubleBonds() << " double bonds" << endl;
        break;
      }
    } // end check loop

    // write an SD output
    char *filename = argv[a];
    // change extension
    char *pExt = strrchr(filename, '.');
    if (pExt != NULL)
      strcpy(pExt, ".sdf");
    else
      strcat(filename, ".sdf");

    if (!writeSDF(mol, filename))
      cout << "Cannot write the SDF file" << endl;

  } // end (loop through command-line args)

  return 0;
}
开发者ID:kevishi,项目名称:parallelbondorder,代码行数:46,代码来源:main.cpp


注:本文中的Molecule::atoms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。