ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/visitors/RigidBodyVisitor.cpp
(Generate patch)

Comparing trunk/src/visitors/RigidBodyVisitor.cpp (file contents):
Revision 507 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
Revision 1008 by chrisfen, Wed Jul 19 12:35:31 2006 UTC

# Line 40 | Line 40
40   */
41  
42   #include "visitors/RigidBodyVisitor.hpp"
43
43   #include "primitives/RigidBody.hpp"
44  
45  
46   namespace oopse {
47  
49
50
48    void LipidHeadVisitor::visit(RigidBody* rb){
52
49      Vector3d pos;
54
50      Vector3d u(0, 0, 1);
56
51      Vector3d newVec;
58
52      GenericData* data;
60
53      AtomData* atomData;
62
54      AtomInfo* atomInfo;
64
55      bool haveAtomData;
66
56      RotMat3x3d rotMatrix;
57  
69
70
58      if(!canVisit(rb->getType()))
72
59        return;
60  
75
76
61      pos = rb->getPos();
78
62      rotMatrix = rb->getA();
80
63      //matVecMul3(rotMatrix, u, newVec);
82
64      newVec = rotMatrix * u;
65  
85  
86
66      data = rb->getPropertyByName("ATOMDATA");
67  
68      if(data != NULL){
90
91
92
69        atomData = dynamic_cast<AtomData*>(data);  
70 <
70 >      
71        if(atomData == NULL){
96
72          std::cerr << "can not get Atom Data from " << rb->getType() << std::endl;
73 <
73 >        
74          atomData = new AtomData;
100
75          haveAtomData = false;      
76 <
77 <      }
104 <
105 <      else
106 <
76 >        
77 >      } else
78          haveAtomData = true;
79 <
80 <    }
110 <
111 <    else{
112 <
79 >      
80 >    } else {
81        atomData = new AtomData;
114
82        haveAtomData = false;
83 <
83 >      
84      }
85  
119
120
86      atomInfo = new AtomInfo;
122
87      atomInfo->atomTypeName = "X";
124
88      atomInfo->pos[0] = pos[0];
126
89      atomInfo->pos[1] = pos[1];
128
90      atomInfo->pos[2] = pos[2];
130
91      atomInfo->dipole[0] = newVec[0];
132
92      atomInfo->dipole[1] = newVec[1];
134
93      atomInfo->dipole[2] = newVec[2];
94  
137
138
95      atomData->addAtomInfo(atomInfo);
96  
141
142
97      if(!haveAtomData){
144
98        atomData->setID("ATOMDATA");
146
99        rb->addProperty(atomData);
148
100      }
101  
151    
152
102    }
103  
104  
156
105    void LipidHeadVisitor::addLipidHeadName(const std::string& name){
158
106      lipidHeadName.insert(name);
107  
161
162
108    }
109  
165
166
110    bool LipidHeadVisitor::canVisit(const std::string& name){
168
111      return lipidHeadName.find(name) != lipidHeadName.end() ? true : false;
112  
171
172
113    }
114  
115  
176
116    const  std::string LipidHeadVisitor::toString(){
178
117      char buffer[65535];
180
118      std::string result;
182
119      std::set<std::string>::iterator i;
120  
185  
186
121      sprintf(buffer ,"------------------------------------------------------------------\n");
188
122      result += buffer;
123  
191  
192
124      sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
194
125      result += buffer;
126  
197
198
127      //print the ignore type list
200
128      sprintf(buffer , "lipidHeadName list contains below types:\n");
202
129      result += buffer;
130  
205
206
131      for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){
208
132        sprintf(buffer ,"%s\t", i->c_str());
210
133        result += buffer;
212
134      }
135  
215
216
136      sprintf(buffer ,"\n");
218
137      result += buffer;
138  
221
222
139      sprintf(buffer ,"------------------------------------------------------------------\n");
224
140      result += buffer;
141  
227
228
142      return result;
143  
231
232
144    }
145  
146  
236
147    void RBCOMVisitor::visit(RigidBody* rb){
238
148      AtomData* atomData;
240
149      AtomInfo* atomInfo;
242
150      Vector3d pos;
151  
245  
246
152      pos = rb->getPos();
248
153      atomInfo = new AtomInfo;
250
154      atomInfo->atomTypeName = "X";
252
155      atomInfo->pos[0] = pos[0];
254
156      atomInfo->pos[1] = pos[1];
256
157      atomInfo->pos[2] = pos[2];
258
158      atomInfo->dipole[0] = 0;
260
159      atomInfo->dipole[1] = 0;
262
160      atomInfo->dipole[2] = 0;
161  
265
266
162      atomData = new AtomData;
268
163      atomData->setID("ATOMDATA");
270
164      atomData->addAtomInfo(atomInfo);
165  
273
274
166      rb->addProperty(atomData);
167  
168    }
169  
170  
280
171    const  std::string RBCOMVisitor::toString(){
282
172      char buffer[65535];
284
173      std::string result;
174  
287  
288
175      sprintf(buffer ,"------------------------------------------------------------------\n");
290
176      result += buffer;
177  
293  
294
178      sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
296
179      result += buffer;
180  
299
300
181      //print the ignore type list
302
182      sprintf(buffer , "Visitor Description: add a pseudo atom at the center of the mass of the rigidbody\n");
304
183      result += buffer;
184  
307
308
185      sprintf(buffer ,"------------------------------------------------------------------\n");
310
186      result += buffer;
187  
313
314
188      return result;
189  
317
318
190    }
191  
321
322
323
324
192   }//namespace oopse
193  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines