本文整理汇总了C++中OBAtom::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ OBAtom::Clear方法的具体用法?C++ OBAtom::Clear怎么用?C++ OBAtom::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBAtom
的用法示例。
在下文中一共展示了OBAtom::Clear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EndElement
bool ChemDrawXMLFormat::EndElement(const string& name)
{
//unsigned int i;
if(name=="n")
{
_pmol->AddAtom(_tempAtom);
atoms[_tempAtom.GetIdx()] = _pmol->NumAtoms();
_tempAtom.Clear();
}
else if(name=="b")
{
_pmol->AddBond(Begin, End, Order, Flag);
Order = -1;
}
else if(name=="fragment") //this is the end of the molecule we are extracting
{
EnsureEndElement();
_pmol->EndModify();
// This alone will already store the "Formula" property in the molecule property block
// The "Formula" is required for older ChemDraw generations allowing to match molecules to reaction properties
string MolFormula=_pmol->GetFormula();
// additional adding of "Formula" property is not required, as described above
//OBPairData *dp = new OBPairData;
//dp->SetAttribute("MolecularFormula");
//dp->SetValue(MolFormula);
//dp->SetOrigin(fileformatInput);
//_pmol->SetData(dp);
// alternative is using the molecular title, but a test is needed for preventing overwriting given titles, aka molecule ID
//_pmol->SetTitle(MolFormula);
atoms.clear();
return false;//means stop parsing
}
/*
// 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")
{
}
else if(name=="tableCell")
{
//OBPairData *dp = new OBPairData;
//dp->SetAttribute(attr);
//dp->SetValue(buff);
//dp->SetOrigin(fileformatInput);
//mol.SetData(dp);
}*/
return true;
}
示例2: EnsureEndElement
void ChemDrawXMLFormat::EnsureEndElement(void)
{
if (_tempAtom.GetAtomicNum() != 0)
{
_pmol->AddAtom(_tempAtom);
atoms[_tempAtom.GetIdx()] = _pmol->NumAtoms();
_tempAtom.Clear();
}
else if (Order >= 0)
{
_pmol->AddBond(Begin, End, Order, Flag);
Order = -1;
}
}
示例3: 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())];
}
//.........这里部分代码省略.........
示例4: ReadMolecule
bool CCCFormat::ReadMolecule(OBBase* pOb, OBConversion* pConv)
{
OBMol* pmol = pOb->CastAndClear<OBMol>();
if(pmol==NULL)
return false;
//Define some references so we can use the old parameter names
istream &ifs = *pConv->GetInStream();
OBMol &mol = *pmol;
mol.SetTitle( pConv->GetTitle()); //default title is the filename
char buffer[BUFF_SIZE];
ifs.getline(buffer,BUFF_SIZE);
if (strlen(buffer) > 5)
mol.SetTitle(&buffer[5]);
mol.SetEnergy(0.0);
int natoms;
ifs.getline(buffer,BUFF_SIZE);
sscanf(buffer,"%*s%d",&natoms);
mol.ReserveAtoms(natoms);
mol.BeginModify();
int end,order;
double x,y,z;
OBAtom atom;
vector3 v;
vector<string> vs;
char element[3];
element[2] = '\0';
for (int i = 1;i <= natoms;i++)
{
if (!ifs.getline(buffer,BUFF_SIZE))
return(false);
atom.Clear();
element[0] = buffer[0];
element[1] = (buffer[1] != ' ') ? buffer[1]:'\0';
atom.SetAtomicNum(etab.GetAtomicNum(element));
sscanf(&buffer[15],"%lf%lf%lf",&x,&y,&z);
v.Set(x,y,z);
atom.SetVector(v);
if (!mol.AddAtom(atom))
return(false);
tokenize(vs,&buffer[60]);
vector<string>::iterator j;
for (j = vs.begin();j != vs.end();j++)
if (!j->empty())
{
//get the bond order
switch((char)(*j)[j->size()-1])
{
case 'S':
order = 1;
break;
case 'D':
order = 2;
break;
case 'T':
order = 3;
break;
default:
order = 1;
}
(*j)[j->size()-1] = ' ';
end = atoi(j->c_str());
if (i>end)
mol.AddBond(i,end,order);
}
}
mol.EndModify();
return(true);
}
示例5: ReadMolecule
bool TurbomoleFormat::ReadMolecule(OBBase* pOb, OBConversion* pConv)
{
OBMol* pmol = pOb->CastAndClear<OBMol>();
if(pmol==NULL)
return false;
//Define some references so we can use the old parameter names
istream &ifs = *pConv->GetInStream();
OBMol &mol = *pmol;
double UnitConv=AAU;
if(pConv->IsOption("a", OBConversion::INOPTIONS))
UnitConv=1;
char buffer[BUFF_SIZE];
do
{
ifs.getline(buffer,BUFF_SIZE);
if (ifs.peek() == EOF || !ifs.good())
return false;
}
while(strncmp(buffer,"$coord",6));
mol.BeginModify();
OBAtom atom;
while(!(!ifs))
{
ifs.getline(buffer,BUFF_SIZE);
if(*buffer=='$')
break;
if(*buffer=='#')
continue;
float x,y,z;
char atomtype[8];
if(sscanf(buffer,"%f %f %f %7s",&x,&y,&z,atomtype)!=4)
return false;
atom.SetVector(x*UnitConv, y*UnitConv, z*UnitConv);
atom.SetAtomicNum(OBElements::GetAtomicNum(atomtype));
atom.SetType(atomtype);
if(!mol.AddAtom(atom))
return false;
atom.Clear();
}
while(!(!ifs) && strncmp(buffer,"$end",4))
ifs.getline(buffer,BUFF_SIZE);
if (!pConv->IsOption("b",OBConversion::INOPTIONS))
mol.ConnectTheDots();
if (!pConv->IsOption("s",OBConversion::INOPTIONS) && !pConv->IsOption("b",OBConversion::INOPTIONS))
mol.PerceiveBondOrders();
// clean out remaining blank lines
std::streampos ipos;
do
{
ipos = ifs.tellg();
ifs.getline(buffer,BUFF_SIZE);
}
while(strlen(buffer) == 0 && !ifs.eof() );
ifs.seekg(ipos);
mol.EndModify();
return true;
}