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


C++ OBAtom::SetIdx方法代码示例

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


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

示例1: DoElement

bool ChemDrawXMLFormat::DoElement(const string& name)
{
    string buf;
    if(name=="fragment")
    {
        //This is the start of the molecule we are extracting and it will
        //be put into the OBMol* _pmol declared in the parent class.
        //initialise everything
        _tempAtom.Clear();
        atoms.clear();

        _pmol->SetDimension(2);
        _pmol->BeginModify();

        buf = _pxmlConv->GetAttribute("id");
        if (buf.length())
        {
            _pmol->SetTitle(buf);
        }
    }
    else if(name=="n")
    {
        EnsureEndElement();
        buf = _pxmlConv->GetAttribute("Type");
        if (buf.length())
        {
            if (buf != "Unspecified" && buf != "Element")
            {
                cerr << "CDXML Format: Node type \"" << buf <<
                     "\" is not currently supported." << endl;
                return false; // FIXME: use as many types as possible
            }
        }
        _tempAtom.SetAtomicNum(6); // default is carbon
        buf = _pxmlConv->GetAttribute("id");
        if (buf.length())
            _tempAtom.SetIdx(atoi(buf.c_str()));
        buf = _pxmlConv->GetAttribute("Element");
        if (buf.length())
            _tempAtom.SetAtomicNum(atoi(buf.c_str()));

        buf = _pxmlConv->GetAttribute("p"); // coords
        if (buf.length())
        {
            double x = 0., y = 0.;
            sscanf(buf.c_str(), "%lf %lf", &x, &y);
            _tempAtom.SetVector(x, y, 0.);
        }
        buf = _pxmlConv->GetAttribute("Charge");
        if (buf.length())
            _tempAtom.SetFormalCharge(atoi(buf.c_str()));
    }
    else if(name=="b")
    {
        EnsureEndElement();
        bool invert_ends = false;
        Begin = End = Flag = 0;
        buf = _pxmlConv->GetAttribute("Order");
        if (buf.length())
            Order = atoi(buf.c_str());
        else
            Order = 1; //default value
        buf = _pxmlConv->GetAttribute("Display");
        if (buf.length())
        {
            if (buf == "WedgeEnd")
            {
                invert_ends = true;
                Flag = OB_HASH_BOND;
            }
            else if (buf == "WedgeBegin")
            {
                Flag = OB_HASH_BOND;
            }
            else if (buf == "Hash" ||buf == "WedgedHashBegin")
            {
                Flag = OB_WEDGE_BOND;
            }
            else if (buf == "WedgedHashEnd")
            {
                invert_ends = true;
                Flag = OB_WEDGE_BOND;
            }
        }
        buf = _pxmlConv->GetAttribute("B");
        if (buf.length())
        {
            if (invert_ends)
                End = atoms[atoi(buf.c_str())];
            else
                Begin = atoms[atoi(buf.c_str())];
        }
        buf = _pxmlConv->GetAttribute("E");
        if (buf.length())
        {
            if (invert_ends)
                Begin = atoms[atoi(buf.c_str())];
            else
                End = atoms[atoi(buf.c_str())];
        }
//.........这里部分代码省略.........
开发者ID:baoilleach,项目名称:openbabel-svn-mirror,代码行数:101,代码来源:cdxmlformat.cpp


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