| 219 |
|
strIter = linearAtomType.find(atomType); |
| 220 |
|
|
| 221 |
|
return strIter != linearAtomType.end() ? true : false; |
| 222 |
+ |
} |
| 223 |
+ |
|
| 224 |
+ |
void LinearAtomVisitor::addGayBerneAtomType(const std::string& atomType){ |
| 225 |
+ |
linearAtomType.insert(atomType); |
| 226 |
|
} |
| 227 |
|
|
| 228 |
|
void LinearAtomVisitor::visit(DirectionalAtom* datom){ |
| 341 |
|
result += buffer; |
| 342 |
|
|
| 343 |
|
return result; |
| 344 |
+ |
} |
| 345 |
+ |
|
| 346 |
+ |
bool GBLipidAtomVisitor::isGBLipidAtom(const std::string& atomType){ |
| 347 |
+ |
std::set<std::string>::iterator strIter; |
| 348 |
+ |
strIter = GBLipidAtomType.find(atomType); |
| 349 |
+ |
|
| 350 |
+ |
return strIter != GBLipidAtomType.end() ? true : false; |
| 351 |
|
} |
| 352 |
+ |
|
| 353 |
+ |
void GBLipidAtomVisitor::visit(DirectionalAtom* datom){ |
| 354 |
+ |
std::vector<AtomInfo*> atoms; |
| 355 |
+ |
//we need to convert linear into 4 different atoms |
| 356 |
+ |
Vector3d c1(0.0, 0.0, -6.25); |
| 357 |
+ |
Vector3d c2(0.0, 0.0, -2.1); |
| 358 |
+ |
Vector3d c3(0.0, 0.0, 2.1); |
| 359 |
+ |
Vector3d c4(0.0, 0.0, 6.25); |
| 360 |
+ |
RotMat3x3d rotMatrix; |
| 361 |
+ |
RotMat3x3d rotTrans; |
| 362 |
+ |
AtomInfo* atomInfo; |
| 363 |
+ |
Vector3d pos; |
| 364 |
+ |
Vector3d newVec; |
| 365 |
+ |
Quat4d q; |
| 366 |
+ |
AtomData* atomData; |
| 367 |
+ |
GenericData* data; |
| 368 |
+ |
bool haveAtomData; |
| 369 |
+ |
|
| 370 |
+ |
//if atom is not GBlipid atom, just skip it |
| 371 |
+ |
if(!isGBLipidAtom(datom->getType())) |
| 372 |
+ |
return; |
| 373 |
+ |
|
| 374 |
+ |
data = datom->getPropertyByName("ATOMDATA"); |
| 375 |
+ |
if(data != NULL){ |
| 376 |
+ |
atomData = dynamic_cast<AtomData*>(data); |
| 377 |
+ |
if(atomData == NULL){ |
| 378 |
+ |
std::cerr << "can not get Atom Data from " << datom->getType() << std::endl; |
| 379 |
+ |
atomData = new AtomData; |
| 380 |
+ |
haveAtomData = false; |
| 381 |
+ |
} else { |
| 382 |
+ |
haveAtomData = true; |
| 383 |
+ |
} |
| 384 |
+ |
} else { |
| 385 |
+ |
atomData = new AtomData; |
| 386 |
+ |
haveAtomData = false; |
| 387 |
+ |
} |
| 388 |
+ |
|
| 389 |
+ |
|
| 390 |
+ |
pos = datom->getPos(); |
| 391 |
+ |
q = datom->getQ(); |
| 392 |
+ |
rotMatrix = datom->getA(); |
| 393 |
|
|
| 394 |
+ |
// We need A^T to convert from body-fixed to space-fixed: |
| 395 |
+ |
rotTrans = rotMatrix.transpose(); |
| 396 |
+ |
|
| 397 |
+ |
newVec = rotTrans * c1; |
| 398 |
+ |
atomInfo = new AtomInfo; |
| 399 |
+ |
atomInfo->atomTypeName = "K"; |
| 400 |
+ |
atomInfo->pos[0] = pos[0] + newVec[0]; |
| 401 |
+ |
atomInfo->pos[1] = pos[1] + newVec[1]; |
| 402 |
+ |
atomInfo->pos[2] = pos[2] + newVec[2]; |
| 403 |
+ |
atomInfo->dipole[0] = 0.0; |
| 404 |
+ |
atomInfo->dipole[1] = 0.0; |
| 405 |
+ |
atomInfo->dipole[2] = 0.0; |
| 406 |
+ |
atomData->addAtomInfo(atomInfo); |
| 407 |
+ |
|
| 408 |
+ |
newVec = rotTrans * c2; |
| 409 |
+ |
atomInfo = new AtomInfo; |
| 410 |
+ |
atomInfo->atomTypeName = "K"; |
| 411 |
+ |
atomInfo->pos[0] = pos[0] + newVec[0]; |
| 412 |
+ |
atomInfo->pos[1] = pos[1] + newVec[1]; |
| 413 |
+ |
atomInfo->pos[2] = pos[2] + newVec[2]; |
| 414 |
+ |
atomInfo->dipole[0] = 0.0; |
| 415 |
+ |
atomInfo->dipole[1] = 0.0; |
| 416 |
+ |
atomInfo->dipole[2] = 0.0; |
| 417 |
+ |
atomData->addAtomInfo(atomInfo); |
| 418 |
+ |
|
| 419 |
+ |
newVec = rotTrans * c3; |
| 420 |
+ |
atomInfo = new AtomInfo; |
| 421 |
+ |
atomInfo->atomTypeName = "K"; |
| 422 |
+ |
atomInfo->pos[0] = pos[0] + newVec[0]; |
| 423 |
+ |
atomInfo->pos[1] = pos[1] + newVec[1]; |
| 424 |
+ |
atomInfo->pos[2] = pos[2] + newVec[2]; |
| 425 |
+ |
atomInfo->dipole[0] = 0.0; |
| 426 |
+ |
atomInfo->dipole[1] = 0.0; |
| 427 |
+ |
atomInfo->dipole[2] = 0.0; |
| 428 |
+ |
atomData->addAtomInfo(atomInfo); |
| 429 |
+ |
|
| 430 |
+ |
newVec = rotTrans * c4; |
| 431 |
+ |
atomInfo = new AtomInfo; |
| 432 |
+ |
atomInfo->atomTypeName = "K"; |
| 433 |
+ |
atomInfo->pos[0] = pos[0] + newVec[0]; |
| 434 |
+ |
atomInfo->pos[1] = pos[1] + newVec[1]; |
| 435 |
+ |
atomInfo->pos[2] = pos[2] + newVec[2]; |
| 436 |
+ |
atomInfo->dipole[0] = 0.0; |
| 437 |
+ |
atomInfo->dipole[1] = 0.0; |
| 438 |
+ |
atomInfo->dipole[2] = 0.0; |
| 439 |
+ |
atomData->addAtomInfo(atomInfo); |
| 440 |
+ |
|
| 441 |
+ |
//add atom data into atom's property |
| 442 |
+ |
|
| 443 |
+ |
if(!haveAtomData){ |
| 444 |
+ |
atomData->setID("ATOMDATA"); |
| 445 |
+ |
datom->addProperty(atomData); |
| 446 |
+ |
} |
| 447 |
+ |
|
| 448 |
+ |
setVisited(datom); |
| 449 |
+ |
|
| 450 |
+ |
} |
| 451 |
+ |
|
| 452 |
+ |
const std::string GBLipidAtomVisitor::toString(){ |
| 453 |
+ |
char buffer[65535]; |
| 454 |
+ |
std::string result; |
| 455 |
+ |
|
| 456 |
+ |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
| 457 |
+ |
result += buffer; |
| 458 |
+ |
|
| 459 |
+ |
sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str()); |
| 460 |
+ |
result += buffer; |
| 461 |
+ |
|
| 462 |
+ |
sprintf(buffer , "Visitor Description: Convert GBlipid into 4 different K atoms\n"); |
| 463 |
+ |
result += buffer; |
| 464 |
+ |
|
| 465 |
+ |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
| 466 |
+ |
result += buffer; |
| 467 |
+ |
|
| 468 |
+ |
return result; |
| 469 |
+ |
} |
| 470 |
+ |
|
| 471 |
|
//----------------------------------------------------------------------------// |
| 472 |
|
|
| 473 |
|
void DefaultAtomVisitor::visit(Atom *atom) { |