75 |
|
} |
76 |
|
|
77 |
|
bool SSDAtomVisitor::isSSDAtom(const std::string&atomType) { |
78 |
< |
std::vector<std::string>::iterator strIter; |
79 |
< |
|
80 |
< |
for( strIter = ssdAtomType.begin(); strIter != ssdAtomType.end(); |
81 |
< |
++strIter ) |
82 |
< |
if (*strIter == atomType) |
83 |
< |
return true; |
84 |
< |
|
85 |
< |
return false; |
78 |
> |
std::set<std::string>::iterator strIter; |
79 |
> |
strIter = ssdAtomType.find(atomType); |
80 |
> |
return strIter != ssdAtomType.end() ? true : false; |
81 |
|
} |
82 |
|
|
83 |
|
void SSDAtomVisitor::visit(DirectionalAtom *datom) { |
84 |
< |
std::vector<AtomInfo *>atoms; |
84 |
> |
std::vector<AtomInfo*>atoms; |
85 |
|
|
86 |
|
//we need to convert SSD into 4 differnet atoms |
87 |
|
//one oxygen atom, two hydrogen atoms and one pseudo atom which is the center of the mass |
215 |
|
return result; |
216 |
|
} |
217 |
|
|
218 |
< |
bool LinearAtomVisitor::isLinearAtom(const string& atomType){ |
219 |
< |
vector<string>::iterator strIter; |
220 |
< |
|
221 |
< |
for(strIter = linearAtomType.begin(); strIter != linearAtomType.end(); |
222 |
< |
++strIter) |
228 |
< |
if(*strIter == atomType) |
229 |
< |
return true; |
230 |
< |
|
231 |
< |
return false; |
218 |
> |
bool LinearAtomVisitor::isLinearAtom(const std::string& atomType){ |
219 |
> |
std::set<std::string>::iterator strIter; |
220 |
> |
strIter = linearAtomType.find(atomType); |
221 |
> |
|
222 |
> |
return strIter != linearAtomType.end() ? true : false; |
223 |
|
} |
224 |
|
|
225 |
|
void LinearAtomVisitor::visit(DirectionalAtom* datom){ |
226 |
+ |
std::vector<AtomInfo*> atoms; |
227 |
+ |
//we need to convert linear into 4 different atoms |
228 |
+ |
Vector3d c1(0.0, 0.0, -1.8); |
229 |
+ |
Vector3d c2(0.0, 0.0, -0.6); |
230 |
+ |
Vector3d c3(0.0, 0.0, 0.6); |
231 |
+ |
Vector3d c4(0.0, 0.0, 1.8); |
232 |
+ |
RotMat3x3d rotMatrix; |
233 |
+ |
RotMat3x3d rotTrans; |
234 |
+ |
AtomInfo* atomInfo; |
235 |
+ |
Vector3d pos; |
236 |
+ |
Vector3d newVec; |
237 |
+ |
Quat4d q; |
238 |
+ |
AtomData* atomData; |
239 |
+ |
GenericData* data; |
240 |
+ |
bool haveAtomData; |
241 |
|
|
242 |
< |
vector<AtomInfo*> atoms; |
242 |
> |
//if atom is not SSD atom, just skip it |
243 |
> |
if(!isLinearAtom(datom->getType())) |
244 |
> |
return; |
245 |
|
|
246 |
< |
//we need to convert linear into 4 different atoms |
247 |
< |
double c1[3] = {0.0, 0.0, -1.8}; |
248 |
< |
double c2[3] = {0.0, 0.0, -0.6}; |
249 |
< |
double c3[3] = {0.0, 0.0, 0.6}; |
250 |
< |
double c4[3] = {0.0, 0.0, 1.8}; |
251 |
< |
double rotMatrix[3][3]; |
252 |
< |
double rotTrans[3][3]; |
253 |
< |
AtomInfo* atomInfo; |
254 |
< |
double pos[3]; |
255 |
< |
double newVec[3]; |
256 |
< |
double q[4]; |
257 |
< |
AtomData* atomData; |
258 |
< |
GenericData* data; |
251 |
< |
bool haveAtomData; |
252 |
< |
|
253 |
< |
//if atom is not SSD atom, just skip it |
254 |
< |
if(!isLinearAtom(datom->getType())) |
255 |
< |
return; |
256 |
< |
|
257 |
< |
data = datom->getProperty("ATOMDATA"); |
258 |
< |
if(data != NULL){ |
259 |
< |
|
260 |
< |
atomData = dynamic_cast<AtomData*>(data); |
261 |
< |
if(atomData == NULL){ |
262 |
< |
cerr << "can not get Atom Data from " << datom->getType() << endl; |
263 |
< |
atomData = new AtomData; |
264 |
< |
haveAtomData = false; |
246 |
> |
data = datom->getPropertyByName("ATOMDATA"); |
247 |
> |
if(data != NULL){ |
248 |
> |
atomData = dynamic_cast<AtomData*>(data); |
249 |
> |
if(atomData == NULL){ |
250 |
> |
std::cerr << "can not get Atom Data from " << datom->getType() << std::endl; |
251 |
> |
atomData = new AtomData; |
252 |
> |
haveAtomData = false; |
253 |
> |
} else { |
254 |
> |
haveAtomData = true; |
255 |
> |
} |
256 |
> |
} else { |
257 |
> |
atomData = new AtomData; |
258 |
> |
haveAtomData = false; |
259 |
|
} |
266 |
– |
else |
267 |
– |
haveAtomData = true; |
268 |
– |
} |
269 |
– |
else{ |
270 |
– |
atomData = new AtomData; |
271 |
– |
haveAtomData = false; |
272 |
– |
} |
260 |
|
|
261 |
|
|
262 |
< |
datom->getPos(pos); |
263 |
< |
datom->getQ(q); |
264 |
< |
datom->getA(rotMatrix); |
262 |
> |
pos = datom->getPos(); |
263 |
> |
q = datom->getQ(); |
264 |
> |
rotMatrix = datom->getA(); |
265 |
|
|
266 |
< |
// We need A^T to convert from body-fixed to space-fixed: |
267 |
< |
transposeMat3(rotMatrix, rotTrans); |
281 |
< |
|
282 |
< |
matVecMul3(rotTrans, c1, newVec); |
283 |
< |
atomInfo = new AtomInfo; |
284 |
< |
atomInfo->AtomType = "C"; |
285 |
< |
atomInfo->pos[0] = pos[0] + newVec[0]; |
286 |
< |
atomInfo->pos[1] = pos[1] + newVec[1]; |
287 |
< |
atomInfo->pos[2] = pos[2] + newVec[2]; |
288 |
< |
atomInfo->dipole[0] = 0.0; |
289 |
< |
atomInfo->dipole[1] = 0.0; |
290 |
< |
atomInfo->dipole[2] = 0.0; |
291 |
< |
atomData->addAtomInfo(atomInfo); |
266 |
> |
// We need A^T to convert from body-fixed to space-fixed: |
267 |
> |
rotTrans = rotMatrix.transpose(); |
268 |
|
|
269 |
< |
matVecMul3(rotTrans, c2, newVec); |
270 |
< |
atomInfo = new AtomInfo; |
271 |
< |
atomInfo->AtomType = "C"; |
272 |
< |
atomInfo->pos[0] = pos[0] + newVec[0]; |
273 |
< |
atomInfo->pos[1] = pos[1] + newVec[1]; |
274 |
< |
atomInfo->pos[2] = pos[2] + newVec[2]; |
275 |
< |
atomInfo->dipole[0] = 0.0; |
276 |
< |
atomInfo->dipole[1] = 0.0; |
277 |
< |
atomInfo->dipole[2] = 0.0; |
278 |
< |
atomData->addAtomInfo(atomInfo); |
269 |
> |
newVec = rotTrans * c1; |
270 |
> |
atomInfo = new AtomInfo; |
271 |
> |
atomInfo->AtomType = "C"; |
272 |
> |
atomInfo->pos[0] = pos[0] + newVec[0]; |
273 |
> |
atomInfo->pos[1] = pos[1] + newVec[1]; |
274 |
> |
atomInfo->pos[2] = pos[2] + newVec[2]; |
275 |
> |
atomInfo->dipole[0] = 0.0; |
276 |
> |
atomInfo->dipole[1] = 0.0; |
277 |
> |
atomInfo->dipole[2] = 0.0; |
278 |
> |
atomData->addAtomInfo(atomInfo); |
279 |
|
|
280 |
< |
matVecMul3(rotTrans, c3, newVec); |
281 |
< |
atomInfo = new AtomInfo; |
282 |
< |
atomInfo->AtomType = "C"; |
283 |
< |
atomInfo->pos[0] = pos[0] + newVec[0]; |
284 |
< |
atomInfo->pos[1] = pos[1] + newVec[1]; |
285 |
< |
atomInfo->pos[2] = pos[2] + newVec[2]; |
286 |
< |
atomInfo->dipole[0] = 0.0; |
287 |
< |
atomInfo->dipole[1] = 0.0; |
288 |
< |
atomInfo->dipole[2] = 0.0; |
289 |
< |
atomData->addAtomInfo(atomInfo); |
280 |
> |
newVec = rotTrans * c2; |
281 |
> |
atomInfo = new AtomInfo; |
282 |
> |
atomInfo->AtomType = "C"; |
283 |
> |
atomInfo->pos[0] = pos[0] + newVec[0]; |
284 |
> |
atomInfo->pos[1] = pos[1] + newVec[1]; |
285 |
> |
atomInfo->pos[2] = pos[2] + newVec[2]; |
286 |
> |
atomInfo->dipole[0] = 0.0; |
287 |
> |
atomInfo->dipole[1] = 0.0; |
288 |
> |
atomInfo->dipole[2] = 0.0; |
289 |
> |
atomData->addAtomInfo(atomInfo); |
290 |
|
|
291 |
< |
matVecMul3(rotTrans, c4, newVec); |
292 |
< |
atomInfo = new AtomInfo; |
293 |
< |
atomInfo->AtomType = "C"; |
294 |
< |
atomInfo->pos[0] = pos[0] + newVec[0]; |
295 |
< |
atomInfo->pos[1] = pos[1] + newVec[1]; |
296 |
< |
atomInfo->pos[2] = pos[2] + newVec[2]; |
297 |
< |
atomInfo->dipole[0] = 0.0; |
298 |
< |
atomInfo->dipole[1] = 0.0; |
299 |
< |
atomInfo->dipole[2] = 0.0; |
300 |
< |
atomData->addAtomInfo(atomInfo); |
291 |
> |
newVec = rotTrans * c3; |
292 |
> |
atomInfo = new AtomInfo; |
293 |
> |
atomInfo->AtomType = "C"; |
294 |
> |
atomInfo->pos[0] = pos[0] + newVec[0]; |
295 |
> |
atomInfo->pos[1] = pos[1] + newVec[1]; |
296 |
> |
atomInfo->pos[2] = pos[2] + newVec[2]; |
297 |
> |
atomInfo->dipole[0] = 0.0; |
298 |
> |
atomInfo->dipole[1] = 0.0; |
299 |
> |
atomInfo->dipole[2] = 0.0; |
300 |
> |
atomData->addAtomInfo(atomInfo); |
301 |
|
|
302 |
< |
//add atom data into atom's property |
302 |
> |
newVec = rotTrans * c4; |
303 |
> |
atomInfo = new AtomInfo; |
304 |
> |
atomInfo->AtomType = "C"; |
305 |
> |
atomInfo->pos[0] = pos[0] + newVec[0]; |
306 |
> |
atomInfo->pos[1] = pos[1] + newVec[1]; |
307 |
> |
atomInfo->pos[2] = pos[2] + newVec[2]; |
308 |
> |
atomInfo->dipole[0] = 0.0; |
309 |
> |
atomInfo->dipole[1] = 0.0; |
310 |
> |
atomInfo->dipole[2] = 0.0; |
311 |
> |
atomData->addAtomInfo(atomInfo); |
312 |
|
|
313 |
< |
if(!haveAtomData){ |
329 |
< |
atomData->setID("ATOMDATA"); |
330 |
< |
datom->addProperty(atomData); |
331 |
< |
} |
313 |
> |
//add atom data into atom's property |
314 |
|
|
315 |
< |
setVisited(datom); |
315 |
> |
if(!haveAtomData){ |
316 |
> |
atomData->setID("ATOMDATA"); |
317 |
> |
datom->addProperty(atomData); |
318 |
> |
} |
319 |
|
|
320 |
+ |
setVisited(datom); |
321 |
+ |
|
322 |
|
} |
323 |
|
|
324 |
< |
const string LinearAtomVisitor::toString(){ |
324 |
> |
const std::string LinearAtomVisitor::toString(){ |
325 |
|
char buffer[65535]; |
326 |
< |
string result; |
326 |
> |
std::string result; |
327 |
|
|
328 |
|
sprintf(buffer ,"------------------------------------------------------------------\n"); |
329 |
|
result += buffer; |