1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
/**********************************************************************
Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
#include "mol.h"
using namespace std;
namespace OpenBabel
{
bool WriteFenskeZmat(ostream &ofs,OBMol &mol)
{
OBAtom *atom,*a,*b,*c;
char type[10],buffer[BUFF_SIZE];
vector<OBNodeBase*>::iterator i;
vector<OBInternalCoord*> vic;
vic.push_back((OBInternalCoord*)NULL);
for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
vic.push_back(new OBInternalCoord);
CartesianToInternal(vic,mol);
ofs << endl << mol.NumAtoms() << endl;
float r,w,t;
for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
{
a = vic[atom->GetIdx()]->_a;
b = vic[atom->GetIdx()]->_b;
c = vic[atom->GetIdx()]->_c;
r = vic[atom->GetIdx()]->_dst;
w = vic[atom->GetIdx()]->_ang;
t = vic[atom->GetIdx()]->_tor;
strcpy(type,etab.GetSymbol(atom->GetAtomicNum()));
if (atom->GetIdx() == 1)
{
sprintf(buffer,"%-2s 1",type);
ofs << buffer << endl;
continue;
}
if (atom->GetIdx() == 2)
{
sprintf(buffer,"%-2s%3d%6.3f",
type,
a->GetIdx(),r);
ofs << buffer << endl;
continue;
}
if (atom->GetIdx() == 3)
{
sprintf(buffer,"%-2s%3d%6.3f%3d%8.3f",
type,
a->GetIdx(),r, b->GetIdx(),w);
ofs << buffer << endl;
continue;
}
if (t < 0) t += 360;
sprintf(buffer,"%-2s%3d%6.3f%3d%8.3f%3d%6.1f",
type,
a->GetIdx(),r,b->GetIdx(),w,c->GetIdx(),t);
ofs << buffer << endl;
}
return(true);
}
}
|