| 1 |
tim |
1118 |
#include "RigidBodyVisitor.hpp" |
| 2 |
|
|
#include "RigidBody.hpp" |
| 3 |
|
|
#include "MatVec3.h" |
| 4 |
|
|
|
| 5 |
|
|
void LipidHeadVisitor::visit(RigidBody* rb){ |
| 6 |
|
|
double pos[3]; |
| 7 |
|
|
double u[3] = {0, 0, 1}; |
| 8 |
|
|
double newVec[3]; |
| 9 |
|
|
GenericData* data; |
| 10 |
|
|
AtomData* atomData; |
| 11 |
|
|
AtomInfo* atomInfo; |
| 12 |
|
|
bool haveAtomData; |
| 13 |
|
|
double rotMatrix[3][3]; |
| 14 |
|
|
|
| 15 |
|
|
if(!canVisit(rb->getType())) |
| 16 |
|
|
return; |
| 17 |
|
|
|
| 18 |
|
|
rb->getPos(pos); |
| 19 |
|
|
rb->getA(rotMatrix); |
| 20 |
|
|
matVecMul3(rotMatrix, u, newVec); |
| 21 |
|
|
|
| 22 |
|
|
data = rb->getProperty("ATOMDATA"); |
| 23 |
|
|
if(data != NULL){ |
| 24 |
|
|
|
| 25 |
|
|
atomData = dynamic_cast<AtomData*>(data); |
| 26 |
|
|
if(atomData == NULL){ |
| 27 |
|
|
cerr << "can not get Atom Data from " << rb->getType() << endl; |
| 28 |
|
|
atomData = new AtomData; |
| 29 |
|
|
haveAtomData = false; |
| 30 |
|
|
} |
| 31 |
|
|
else |
| 32 |
|
|
haveAtomData = true; |
| 33 |
|
|
} |
| 34 |
|
|
else{ |
| 35 |
|
|
atomData = new AtomData; |
| 36 |
|
|
haveAtomData = false; |
| 37 |
|
|
} |
| 38 |
|
|
|
| 39 |
|
|
atomInfo = new AtomInfo; |
| 40 |
|
|
atomInfo->AtomType = "X"; |
| 41 |
|
|
atomInfo->pos[0] = pos[0]; |
| 42 |
|
|
atomInfo->pos[1] = pos[1]; |
| 43 |
|
|
atomInfo->pos[2] = pos[2]; |
| 44 |
|
|
atomInfo->dipole[0] = newVec[0]; |
| 45 |
|
|
atomInfo->dipole[1] = newVec[1]; |
| 46 |
|
|
atomInfo->dipole[2] = newVec[2]; |
| 47 |
|
|
|
| 48 |
|
|
atomData->addAtomInfo(atomInfo); |
| 49 |
|
|
|
| 50 |
|
|
if(!haveAtomData){ |
| 51 |
|
|
atomData->setID("ATOMDATA"); |
| 52 |
|
|
rb->addProperty(atomData); |
| 53 |
|
|
} |
| 54 |
|
|
|
| 55 |
|
|
} |
| 56 |
|
|
|
| 57 |
|
|
void LipidHeadVisitor::addLipidHeadName(const string& name){ |
| 58 |
|
|
lipidHeadName.insert(name); |
| 59 |
|
|
|
| 60 |
|
|
} |
| 61 |
|
|
|
| 62 |
|
|
bool LipidHeadVisitor::canVisit(const string& name){ |
| 63 |
|
|
return lipidHeadName.find(name) != lipidHeadName.end() ? true : false; |
| 64 |
|
|
|
| 65 |
|
|
} |
| 66 |
|
|
|
| 67 |
|
|
const string LipidHeadVisitor::toString(){ |
| 68 |
|
|
char buffer[65535]; |
| 69 |
tim |
1119 |
string result; |
| 70 |
tim |
1118 |
set<string>::iterator i; |
| 71 |
|
|
|
| 72 |
tim |
1119 |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
| 73 |
|
|
result += buffer; |
| 74 |
|
|
|
| 75 |
|
|
sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str()); |
| 76 |
|
|
result += buffer; |
| 77 |
tim |
1118 |
|
| 78 |
|
|
//print the ignore type list |
| 79 |
tim |
1119 |
sprintf(buffer , "lipidHeadName list contains below types:\n"); |
| 80 |
|
|
result += buffer; |
| 81 |
tim |
1118 |
|
| 82 |
tim |
1119 |
for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){ |
| 83 |
|
|
sprintf(buffer ,"%s\t", i->c_str()); |
| 84 |
|
|
result += buffer; |
| 85 |
|
|
} |
| 86 |
tim |
1118 |
|
| 87 |
tim |
1119 |
sprintf(buffer ,"\n"); |
| 88 |
|
|
result += buffer; |
| 89 |
tim |
1118 |
|
| 90 |
tim |
1119 |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
| 91 |
|
|
result += buffer; |
| 92 |
|
|
|
| 93 |
|
|
return result; |
| 94 |
|
|
|
| 95 |
|
|
} |