本文整理汇总了C++中OBMol::ConnectTheDots方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::ConnectTheDots方法的具体用法?C++ OBMol::ConnectTheDots怎么用?C++ OBMol::ConnectTheDots使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBMol
的用法示例。
在下文中一共展示了OBMol::ConnectTheDots方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadMolecule
//------------------------------------------------------------------------------
bool OBMoldenFormat::ReadMolecule( OBBase* pOb, OBConversion* pConv )
{
OBMol* pmol = dynamic_cast< OBMol* >(pOb);
if( pmol == 0 ) return false;
istream& ifs = *pConv->GetInStream();
pmol->BeginModify();
pmol->SetDimension( 3 );
string lineBuffer;
getline( ifs, lineBuffer );
while( ifs && lineBuffer.find( "[Atoms]" ) == string::npos
&& lineBuffer.find( "[ATOMS]" ) == string::npos )
{
getline( ifs, lineBuffer );
}
if( !ifs ) return false;
//[Atoms] AU OR Angs
double factor = 1.; // Angstrom
if( lineBuffer.find( "AU" ) != string::npos ) factor = 0.529177249; // Bohr
while( ifs )
{
getline( ifs, lineBuffer );
if( lineBuffer.size() == 0 ) continue;
if( lineBuffer.find( '[' ) != string::npos ) break;
istringstream is( lineBuffer );
string atomName;
int atomId;
int atomicNumber;
double x, y, z;
is >> atomName >> atomId >> atomicNumber >> x >> y >> z;
OBAtom* atom = pmol->NewAtom();
if( !atom ) break;
atom->SetAtomicNum( atomicNumber );
atom->SetVector( x * factor, y * factor, z * factor );
}
if( !pConv->IsOption( "b", OBConversion::INOPTIONS ) ) pmol->ConnectTheDots();
if (!pConv->IsOption( "s", OBConversion::INOPTIONS )
&& !pConv->IsOption( "b", OBConversion::INOPTIONS ) )
{
pmol->PerceiveBondOrders();
}
pmol->EndModify();
return true;
}
示例2: ReadPQS_geom
int ReadPQS_geom(istream &ifs, OBMol &mol, const char *title,
int input_style, double bohr_to_angstrom)
{
int atom_count=0;
double x, y, z;
char buffer[BUFF_SIZE];
string str;
OBAtom *atom;
vector<string> vs;
mol.Clear();
mol.BeginModify();
while (ifs.getline(buffer,BUFF_SIZE) && !card_found(buffer))
{
if (buffer[0]!='$')
{
tokenize(vs, buffer);
if (vs.size() < 1) return false; // timvdm 18/06/2008
atom=mol.NewAtom();
str=vs[0];
if (input_style==0)
{
if (vs.size() < 4) return false; // timvdm 18/06/2008
atom->SetAtomicNum(OBElements::GetAtomicNum(str.c_str()));
x=atof((char*) vs[1].c_str())*bohr_to_angstrom;
y=atof((char*) vs[2].c_str())*bohr_to_angstrom;
z=atof((char*) vs[3].c_str())*bohr_to_angstrom;
}
else
{
if (vs.size() < 5) return false; // timvdm 18/06/2008
str.replace (0,2,"");
atom->SetAtomicNum(OBElements::GetAtomicNum(str.c_str()));
x=atof((char*) vs[2].c_str())*bohr_to_angstrom;
y=atof((char*) vs[3].c_str())*bohr_to_angstrom;
z=atof((char*) vs[4].c_str())*bohr_to_angstrom;
}
atom->SetVector(x, y, z);
atom_count++;
}
}
mol.ConnectTheDots();
mol.PerceiveBondOrders();
mol.EndModify();
mol.SetTitle(title);
return atom_count;
}
示例3: ReadBiosymCAR
bool ReadBiosymCAR(istream &ifs,OBMol &mol, const char *title)
{
char buffer[BUFF_SIZE];
string str;
double x,y,z;
OBAtom *atom;
vector<string> vs;
mol.BeginModify();
while (ifs.getline(buffer,BUFF_SIZE))
{
if(strstr(buffer,"PBC") != NULL)
{
if(strstr(buffer,"ON") != NULL)
{
ifs.getline(buffer,BUFF_SIZE);
ifs.getline(buffer,BUFF_SIZE);
ifs.getline(buffer,BUFF_SIZE);
}
else
{
ifs.getline(buffer,BUFF_SIZE);
ifs.getline(buffer,BUFF_SIZE);
}
break;
}
}
while (ifs.getline(buffer,BUFF_SIZE))
{
if(strstr(buffer,"end") != NULL)
break;
atom = mol.NewAtom();
tokenize(vs,buffer);
atom->SetAtomicNum(etab.GetAtomicNum(vs[7].c_str()));
x = atof((char*)vs[1].c_str());
y = atof((char*)vs[2].c_str());
z = atof((char*)vs[3].c_str());
atom->SetVector(x,y,z);
}
mol.EndModify();
mol.ConnectTheDots();
mol.PerceiveBondOrders();
mol.SetTitle(title);
return(true);
}
示例4: ReadViewMol
bool ReadViewMol(istream &ifs,OBMol &mol,const char *title)
{
char buffer[BUFF_SIZE];
OBAtom *atom;
double x,y,z, border;
double factor = 1.0;
int bgn, end, order;
vector<string> vs;
bool foundTitle = false;
bool foundBonds = false;
mol.BeginModify();
while (ifs.getline(buffer,BUFF_SIZE))
{
if (strstr(buffer,"$title") != NULL)
{
if (!ifs.getline(buffer,BUFF_SIZE)) return (false);
mol.SetTitle(buffer);
foundTitle = true;
}
else if (strstr(buffer,"$coord") != NULL)
{
tokenize(vs,buffer);
if (vs.size() == 2)
factor = atof((char*)vs[1].c_str()); // conversion to angstrom
while (ifs.getline(buffer,BUFF_SIZE))
{
if (buffer[0] == '$') break;
tokenize(vs,buffer);
if (vs.size() != 4) return(false);
atom = mol.NewAtom();
x = atof((char*)vs[0].c_str()) * factor;
y = atof((char*)vs[1].c_str()) * factor;
z = atof((char*)vs[2].c_str()) * factor;
atom->SetVector(x,y,z); //set coordinates
atom->SetAtomicNum(etab.GetAtomicNum(vs[3].c_str()));
}
}
else if (strstr(buffer,"$bonds") != NULL)
{
foundBonds = true;
while (ifs.getline(buffer,BUFF_SIZE))
{
if (buffer[0] == '$') break;
sscanf(buffer,"%d %d %lf",&bgn,&end, &border);
if (border > 1.0)
order = int(border);
else
order = 1;
mol.AddBond(bgn+1,end+1,order);
}
}
else if (strstr(buffer,"$end") != NULL)
break;
} // while
mol.EndModify();
if (!foundTitle)
mol.SetTitle(title);
if (!foundBonds)
{
mol.ConnectTheDots();
mol.PerceiveBondOrders();
}
return(true);
}
示例5: ReadXYZ
//.........这里部分代码省略.........
cerr << "WARNING: Problems reading an XYZ file, method 'bool ReadXYZ(istream &,OBMol &,const char *)'" << endl
<< " Problems reading the first line. The first line must contain the number of atoms." << endl
<< " OpenBabel found the line '" << buffer << "'" << endl
<< " which could not be interpreted as a number." << endl;
return(false);
}
if (!natoms) {
cerr << "WARNING: Problems reading an XYZ file, method 'bool ReadXYZ(istream &,OBMol &,const char *)'" << endl
<< " Problems reading the first line. The first line must contain the number of atoms." << endl
<< " OpenBabel found the number '0' which obviously does not work." << endl;
return(false);
}
mol.ReserveAtoms(natoms);
// The next line contains a title string for the molecule. Use this
// as the title for the molecule if the line is not
// empty. Otherwise, use the title given by the calling function.
if (!ifs.getline(buffer,BUFF_SIZE)) {
cerr << "WARNING: Problems reading an XYZ file, method 'bool ReadXYZ(istream &,OBMol &,const char *)'" << endl
<< " Could not read the second line, file error." << endl;
return(false);
}
if (strlen(buffer) == 0)
mol.SetTitle(buffer);
else
mol.SetTitle(title);
// The next lines contain four items each, separated by white
// spaces: the atom type, and the coordinates of the atom
vector<string> vs;
for (unsigned int i = 1; i <= natoms; i ++) {
if (!ifs.getline(buffer,BUFF_SIZE)) {
cerr << "WARNING: Problems reading an XYZ file, method 'bool ReadXYZ(istream &,OBMol &,const char *)'" << endl
<< " Could not read line #" << i+2 << ", file error." << endl
<< " According to line one, there should be " << natoms << " atoms, and therefore " << natoms+2 << " lines in the file" << endl;
return(false);
}
tokenize(vs,buffer);
if (vs.size() != 4) {
cerr << "WARNING: Problems reading an XYZ file, method 'bool ReadXYZ(istream &,OBMol &,const char *)'" << endl
<< " Could not read line #" << i+2 << "." << endl
<< " OpenBabel found the line '" << buffer << "'" << endl
<< " According to the specifications, this line should contain exactly 4 entries, separated by white space." << endl
<< " However, OpenBabel found " << vs.size() << " items." << endl;
return(false);
}
// Atom Type: get the atomic number from the element table, using
// the first entry in the currently read line. If the entry makes
// sense, set the atomic number and leave the atomic type open
// (the type is then later faulted in when atom->GetType() is
// called). If the entry does not make sense to use, set the atom
// type manually, assuming that the author of the xyz-file had
// something "special" in mind.
OBAtom *atom = mol.NewAtom();
int atomicNum = etab.GetAtomicNum(vs[0].c_str());
atom->SetAtomicNum(etab.GetAtomicNum(vs[0].c_str())); //set atomic number, or '0' if the atom type is not recognized
if (atomicNum == 0)
atom->SetType(vs[0]);
// Read the atom coordinates
char *endptr;
double x = strtod((char*)vs[1].c_str(),&endptr);
if (endptr == (char*)vs[1].c_str()) {
cerr << "WARNING: Problems reading an XYZ file, method 'bool ReadXYZ(istream &,OBMol &,const char *)'" << endl
<< " Could not read line #" << i+2 << "." << endl
<< " OpenBabel found the line '" << buffer << "'" << endl
<< " According to the specifications, this line should contain exactly 4 entries, separated by white space." << endl
<< " Item #0: Atom Type, Items #1-#3 cartesian coordinates in Angstrom." << endl
<< " OpenBabel could not interpret item #1 as a number." << endl;
return(false);
}
double y = strtod((char*)vs[2].c_str(),&endptr);
if (endptr == (char*)vs[2].c_str()) {
cerr << "WARNING: Problems reading an XYZ file, method 'bool ReadXYZ(istream &,OBMol &,const char *)'" << endl
<< " Could not read line #" << i+2 << "." << endl
<< " OpenBabel found the line '" << buffer << "'" << endl
<< " According to the specifications, this line should contain exactly 4 entries, separated by white space." << endl
<< " Item #0: Atom Type, Items #1-#3 cartesian coordinates in Angstrom." << endl
<< " OpenBabel could not interpret item #2 as a number." << endl;
return(false);
}
double z = strtod((char*)vs[3].c_str(),&endptr);
if (endptr == (char*)vs[3].c_str()) {
cerr << "WARNING: Problems reading an XYZ file, method 'bool ReadXYZ(istream &,OBMol &,const char *)'" << endl
<< " Could not read line #" << i+2 << "." << endl
<< " OpenBabel found the line '" << buffer << "'" << endl
<< " According to the specifications, this line should contain exactly 4 entries, separated by white space." << endl
<< " Item #0: Atom Type, Items #1-#3 cartesian coordinates in Angstrom." << endl
<< " OpenBabel could not interpret item #3 as a number." << endl;
return(false);
}
atom->SetVector(x,y,z); //set coordinates
}
mol.ConnectTheDots();
mol.PerceiveBondOrders();
return(true);
}