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())]; } } /* // Forget that, the fragment, aka molecule, is in another XML hierachy tree than the data. // Parsing has already stopped before ever getting to this point else if(name=="tags") { buf = _pxmlConv->GetAttribute("ID"); if (buf.length()) { } } else if(name=="tableCell") { buf = _pxmlConv->GetAttribute("value"); if (buf.length()) { } } */ return true; }