1 |
tim |
1695 |
#include "visitors/RigidBodyVisitor.hpp"
|
2 |
|
|
#include "primitives/RigidBody.hpp"
|
3 |
|
|
#include "math/MatVec3.h"
|
4 |
|
|
|
5 |
|
|
namespace oopse {
|
6 |
|
|
|
7 |
|
|
void LipidHeadVisitor::visit(RigidBody* rb){
|
8 |
tim |
1701 |
Vector3d pos;
|
9 |
|
|
Vector3d u(0, 0, 1);
|
10 |
|
|
Vector3d newVec;
|
11 |
tim |
1695 |
GenericData* data;
|
12 |
|
|
AtomData* atomData;
|
13 |
|
|
AtomInfo* atomInfo;
|
14 |
|
|
bool haveAtomData;
|
15 |
tim |
1701 |
RotMat3x3d rotMatrix;
|
16 |
tim |
1695 |
|
17 |
|
|
if(!canVisit(rb->getType()))
|
18 |
|
|
return;
|
19 |
|
|
|
20 |
|
|
pos = rb->getPos();
|
21 |
tim |
1701 |
rotMatrix = rb->getA();
|
22 |
|
|
//matVecMul3(rotMatrix, u, newVec);
|
23 |
|
|
newVec = rotMatrix * u;
|
24 |
|
|
|
25 |
|
|
data = rb->getPropertyByName("ATOMDATA");
|
26 |
tim |
1695 |
if(data != NULL){
|
27 |
|
|
|
28 |
|
|
atomData = dynamic_cast<AtomData*>(data);
|
29 |
|
|
if(atomData == NULL){
|
30 |
|
|
cerr << "can not get Atom Data from " << rb->getType() << endl;
|
31 |
|
|
atomData = new AtomData;
|
32 |
|
|
haveAtomData = false;
|
33 |
|
|
}
|
34 |
|
|
else
|
35 |
|
|
haveAtomData = true;
|
36 |
|
|
}
|
37 |
|
|
else{
|
38 |
|
|
atomData = new AtomData;
|
39 |
|
|
haveAtomData = false;
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
atomInfo = new AtomInfo;
|
43 |
|
|
atomInfo->AtomType = "X";
|
44 |
|
|
atomInfo->pos[0] = pos[0];
|
45 |
|
|
atomInfo->pos[1] = pos[1];
|
46 |
|
|
atomInfo->pos[2] = pos[2];
|
47 |
|
|
atomInfo->dipole[0] = newVec[0];
|
48 |
|
|
atomInfo->dipole[1] = newVec[1];
|
49 |
|
|
atomInfo->dipole[2] = newVec[2];
|
50 |
|
|
|
51 |
|
|
atomData->addAtomInfo(atomInfo);
|
52 |
|
|
|
53 |
|
|
if(!haveAtomData){
|
54 |
|
|
atomData->setID("ATOMDATA");
|
55 |
|
|
rb->addProperty(atomData);
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
void LipidHeadVisitor::addLipidHeadName(const string& name){
|
61 |
|
|
lipidHeadName.insert(name);
|
62 |
|
|
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
bool LipidHeadVisitor::canVisit(const string& name){
|
66 |
|
|
return lipidHeadName.find(name) != lipidHeadName.end() ? true : false;
|
67 |
|
|
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
const string LipidHeadVisitor::toString(){
|
71 |
|
|
char buffer[65535];
|
72 |
|
|
string result;
|
73 |
|
|
set<string>::iterator i;
|
74 |
|
|
|
75 |
|
|
sprintf(buffer ,"------------------------------------------------------------------\n");
|
76 |
|
|
result += buffer;
|
77 |
|
|
|
78 |
|
|
sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
|
79 |
|
|
result += buffer;
|
80 |
|
|
|
81 |
|
|
//print the ignore type list
|
82 |
|
|
sprintf(buffer , "lipidHeadName list contains below types:\n");
|
83 |
|
|
result += buffer;
|
84 |
|
|
|
85 |
|
|
for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){
|
86 |
|
|
sprintf(buffer ,"%s\t", i->c_str());
|
87 |
|
|
result += buffer;
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
sprintf(buffer ,"\n");
|
91 |
|
|
result += buffer;
|
92 |
|
|
|
93 |
|
|
sprintf(buffer ,"------------------------------------------------------------------\n");
|
94 |
|
|
result += buffer;
|
95 |
|
|
|
96 |
|
|
return result;
|
97 |
|
|
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
void RBCOMVisitor::visit(RigidBody* rb){
|
101 |
|
|
AtomData* atomData;
|
102 |
|
|
AtomInfo* atomInfo;
|
103 |
tim |
1701 |
Vector3d pos;
|
104 |
tim |
1695 |
|
105 |
|
|
pos = rb->getPos();
|
106 |
|
|
atomInfo = new AtomInfo;
|
107 |
|
|
atomInfo->AtomType = "X";
|
108 |
|
|
atomInfo->pos[0] = pos[0];
|
109 |
|
|
atomInfo->pos[1] = pos[1];
|
110 |
|
|
atomInfo->pos[2] = pos[2];
|
111 |
|
|
atomInfo->dipole[0] = 0;
|
112 |
|
|
atomInfo->dipole[1] = 0;
|
113 |
|
|
atomInfo->dipole[2] = 0;
|
114 |
|
|
|
115 |
|
|
atomData = new AtomData;
|
116 |
|
|
atomData->setID("ATOMDATA");
|
117 |
|
|
atomData->addAtomInfo(atomInfo);
|
118 |
|
|
|
119 |
|
|
rb->addProperty(atomData);
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
const string RBCOMVisitor::toString(){
|
123 |
|
|
char buffer[65535];
|
124 |
|
|
string result;
|
125 |
|
|
|
126 |
|
|
sprintf(buffer ,"------------------------------------------------------------------\n");
|
127 |
|
|
result += buffer;
|
128 |
|
|
|
129 |
|
|
sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
|
130 |
|
|
result += buffer;
|
131 |
|
|
|
132 |
|
|
//print the ignore type list
|
133 |
|
|
sprintf(buffer , "Visitor Description: add a pseudo atom at the center of the mass of the rigidbody\n");
|
134 |
|
|
result += buffer;
|
135 |
|
|
|
136 |
|
|
sprintf(buffer ,"------------------------------------------------------------------\n");
|
137 |
|
|
result += buffer;
|
138 |
|
|
|
139 |
|
|
return result;
|
140 |
|
|
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
}//namespace oopse
|