本文整理汇总了C++中OBMol::Center方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::Center方法的具体用法?C++ OBMol::Center怎么用?C++ OBMol::Center使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBMol
的用法示例。
在下文中一共展示了OBMol::Center方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc,char **argv)
{
char *program_name= argv[0];
int c;
char *FileIn = NULL;
if (argc != 2) {
cerr << " Usage: " << program_name << " <input file>\n";
exit(-1);
}
else {
FileIn = argv[1];
}
// Find Input filetype
OBConversion conv;
OBFormat *inFormat = conv.FormatFromExt(FileIn);
if (!inFormat || !conv.SetInFormat(inFormat)) {
cerr << program_name << ": cannot read input format!" << endl;
exit (-1);
}
ifstream ifs;
// Read the file
ifs.open(FileIn);
if (!ifs) {
cerr << program_name << ": cannot read input file!" << endl;
exit (-1);
}
OBMol mol;
OBPointGroup pg;
for (c = 1;; ++c)
{
mol.Clear();
conv.Read(&mol, &ifs);
if (mol.Empty())
break;
// not needed by OBPointGroup, but useful for external programs
mol.Center();
mol.ToInertialFrame();
pg.Setup(&mol);
cout << "Point Group: " << pg.IdentifyPointGroup() << endl;
} // end for loop
return(1);
}
示例2: main
//.........这里部分代码省略.........
if (inFileArg == 0 || outFileArg == 0
|| (inFileArg < 0 && !gotInType)
|| (outFileArg < 0 && !gotOutType))
usage();
if (!gotInType)
{
if (extab.CanReadExtension(argv[inFileArg]))
inFileType = extab.FilenameToType(argv[inFileArg]);
else
{
cerr << program_name << ": cannot read input format!" << endl;
usage();
}
}
if (!gotOutType)
{
if (extab.CanWriteExtension(argv[outFileArg]))
outFileType = extab.FilenameToType(argv[outFileArg]);
else
{
cerr << program_name << ": cannot write output format!" << endl;
usage();
}
}
// Finally, we can do some work!
OBMolVector moleculeList;
ifstream inFileStream;
bool usingStdin = false;
bool canRead = true;
int currentMol = 1;
// read
if (inFileArg > 0)
{
inFileStream.open(argv[inFileArg]);
if (!inFileStream)
{
cerr << program_name << ": cannot read input file!" << endl;
exit (-1);
}
}
else
usingStdin = true;
while (canRead)
{
OBMol *mol = new OBMol(inFileType, outFileType);
if (!usingStdin)
fileFormat.ReadMolecule(inFileStream, *mol, argv[inFileArg]);
else
fileFormat.ReadMolecule(cin, *mol, "STDIN");
if (mol->NumAtoms() != 0)
{
// Perform any requested transformations
if (removeHydrogens)
mol->DeleteHydrogens();
if (addHydrogens)
mol->AddHydrogens(false, usePH);
if (centerCoords)
mol->Center();
if (currentMol >= firstMol && currentMol <= lastMol)
moleculeList.PushMol(mol);
if (!usingStdin &&
(inFileStream.peek() == EOF || !inFileStream.good()) )
canRead = false;
else if (usingStdin && (cin.peek() == EOF || !cin.good()) )
canRead = false;
else if (currentMol > lastMol)
canRead = false;
}
else // 0 atoms in this molecule!
{
// cerr << " error: has zero atoms! " << endl;
canRead = false;
}
currentMol++;
}
// write
if (outFileArg > 0)
{
ofstream outFileStream(argv[outFileArg]);
if (!outFileStream)
{
cerr << program_name << ": cannot write to output file!" << endl;
exit (-1);
}
moleculeList.Write(outFileStream, formatOptions);
}
else
moleculeList.Write(cout, formatOptions);
return(0);
}