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

Comparing trunk/src/visitors/RigidBodyVisitor.cpp (file contents):
Revision 246 by gezelter, Wed Jan 12 22:41:40 2005 UTC vs.
Revision 1008 by chrisfen, Wed Jul 19 12:35:31 2006 UTC

# Line 1 | Line 1
1 < /*
1 > /*
2   * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3   *
4   * The University of Notre Dame grants you ("Licensee") a
# Line 40 | Line 40
40   */
41  
42   #include "visitors/RigidBodyVisitor.hpp"
43
43   #include "primitives/RigidBody.hpp"
44  
46 #include "math/MatVec3.h"
45  
48
49
46   namespace oopse {
47  
48 +  void LipidHeadVisitor::visit(RigidBody* rb){
49 +    Vector3d pos;
50 +    Vector3d u(0, 0, 1);
51 +    Vector3d newVec;
52 +    GenericData* data;
53 +    AtomData* atomData;
54 +    AtomInfo* atomInfo;
55 +    bool haveAtomData;
56 +    RotMat3x3d rotMatrix;
57  
58 +    if(!canVisit(rb->getType()))
59 +      return;
60  
61 < void LipidHeadVisitor::visit(RigidBody* rb){
61 >    pos = rb->getPos();
62 >    rotMatrix = rb->getA();
63 >    //matVecMul3(rotMatrix, u, newVec);
64 >    newVec = rotMatrix * u;
65  
66 <  Vector3d pos;
66 >    data = rb->getPropertyByName("ATOMDATA");
67  
68 <  Vector3d u(0, 0, 1);
68 >    if(data != NULL){
69 >      atomData = dynamic_cast<AtomData*>(data);  
70 >      
71 >      if(atomData == NULL){
72 >        std::cerr << "can not get Atom Data from " << rb->getType() << std::endl;
73 >        
74 >        atomData = new AtomData;
75 >        haveAtomData = false;      
76 >        
77 >      } else
78 >        haveAtomData = true;
79 >      
80 >    } else {
81 >      atomData = new AtomData;
82 >      haveAtomData = false;
83 >      
84 >    }
85  
86 <  Vector3d newVec;
86 >    atomInfo = new AtomInfo;
87 >    atomInfo->atomTypeName = "X";
88 >    atomInfo->pos[0] = pos[0];
89 >    atomInfo->pos[1] = pos[1];
90 >    atomInfo->pos[2] = pos[2];
91 >    atomInfo->dipole[0] = newVec[0];
92 >    atomInfo->dipole[1] = newVec[1];
93 >    atomInfo->dipole[2] = newVec[2];
94  
95 <  GenericData* data;
95 >    atomData->addAtomInfo(atomInfo);
96  
97 <  AtomData* atomData;
98 <
99 <  AtomInfo* atomInfo;
67 <
68 <  bool haveAtomData;
69 <
70 <  RotMat3x3d rotMatrix;
71 <
72 <
73 <
74 <  if(!canVisit(rb->getType()))
75 <
76 <    return;
77 <
78 <
79 <
80 <  pos = rb->getPos();
81 <
82 <  rotMatrix = rb->getA();
83 <
84 <  //matVecMul3(rotMatrix, u, newVec);
85 <
86 <  newVec = rotMatrix * u;
87 <
88 <  
89 <
90 <  data = rb->getPropertyByName("ATOMDATA");
91 <
92 <  if(data != NULL){
93 <
94 <
95 <
96 <    atomData = dynamic_cast<AtomData*>(data);  
97 <
98 <    if(atomData == NULL){
99 <
100 <      std::cerr << "can not get Atom Data from " << rb->getType() << std::endl;
101 <
102 <      atomData = new AtomData;
103 <
104 <      haveAtomData = false;      
105 <
97 >    if(!haveAtomData){
98 >      atomData->setID("ATOMDATA");
99 >      rb->addProperty(atomData);
100      }
101  
108    else
109
110      haveAtomData = true;
111
102    }
103  
114  else{
104  
105 <    atomData = new AtomData;
105 >  void LipidHeadVisitor::addLipidHeadName(const std::string& name){
106 >    lipidHeadName.insert(name);
107  
118    haveAtomData = false;
119
108    }
109  
110 +  bool LipidHeadVisitor::canVisit(const std::string& name){
111 +    return lipidHeadName.find(name) != lipidHeadName.end() ? true : false;
112  
113 +  }
114  
124  atomInfo = new AtomInfo;
115  
116 <  atomInfo->AtomType = "X";
116 >  const  std::string LipidHeadVisitor::toString(){
117 >    char buffer[65535];
118 >    std::string result;
119 >    std::set<std::string>::iterator i;
120  
121 <  atomInfo->pos[0] = pos[0];
121 >    sprintf(buffer ,"------------------------------------------------------------------\n");
122 >    result += buffer;
123  
124 <  atomInfo->pos[1] = pos[1];
124 >    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
125 >    result += buffer;
126  
127 <  atomInfo->pos[2] = pos[2];
127 >    //print the ignore type list
128 >    sprintf(buffer , "lipidHeadName list contains below types:\n");
129 >    result += buffer;
130  
131 <  atomInfo->dipole[0] = newVec[0];
131 >    for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){
132 >      sprintf(buffer ,"%s\t", i->c_str());
133 >      result += buffer;
134 >    }
135  
136 <  atomInfo->dipole[1] = newVec[1];
136 >    sprintf(buffer ,"\n");
137 >    result += buffer;
138  
139 <  atomInfo->dipole[2] = newVec[2];
139 >    sprintf(buffer ,"------------------------------------------------------------------\n");
140 >    result += buffer;
141  
142 +    return result;
143  
144 +  }
145  
142  atomData->addAtomInfo(atomInfo);
146  
147 +  void RBCOMVisitor::visit(RigidBody* rb){
148 +    AtomData* atomData;
149 +    AtomInfo* atomInfo;
150 +    Vector3d pos;
151  
152 +    pos = rb->getPos();
153 +    atomInfo = new AtomInfo;
154 +    atomInfo->atomTypeName = "X";
155 +    atomInfo->pos[0] = pos[0];
156 +    atomInfo->pos[1] = pos[1];
157 +    atomInfo->pos[2] = pos[2];
158 +    atomInfo->dipole[0] = 0;
159 +    atomInfo->dipole[1] = 0;
160 +    atomInfo->dipole[2] = 0;
161  
162 <  if(!haveAtomData){
147 <
162 >    atomData = new AtomData;
163      atomData->setID("ATOMDATA");
164 +    atomData->addAtomInfo(atomInfo);
165  
166      rb->addProperty(atomData);
167  
168    }
169  
154    
170  
171 < }
171 >  const  std::string RBCOMVisitor::toString(){
172 >    char buffer[65535];
173 >    std::string result;
174  
175 <
176 <
160 < void LipidHeadVisitor::addLipidHeadName(const std::string& name){
161 <
162 <  lipidHeadName.insert(name);
175 >    sprintf(buffer ,"------------------------------------------------------------------\n");
176 >    result += buffer;
177  
178 +    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
179 +    result += buffer;
180  
181 +    //print the ignore type list
182 +    sprintf(buffer , "Visitor Description: add a pseudo atom at the center of the mass of the rigidbody\n");
183 +    result += buffer;
184  
185 < }
167 <
168 <
169 <
170 < bool LipidHeadVisitor::canVisit(const std::string& name){
171 <
172 <  return lipidHeadName.find(name) != lipidHeadName.end() ? true : false;
173 <
174 <
175 <
176 < }
177 <
178 <
179 <
180 < const  std::string LipidHeadVisitor::toString(){
181 <
182 <  char buffer[65535];
183 <
184 <   std::string result;
185 <
186 <   std::set<std::string>::iterator i;
187 <
188 <  
189 <
190 <  sprintf(buffer ,"------------------------------------------------------------------\n");
191 <
192 <  result += buffer;
193 <
194 <  
195 <
196 <  sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
197 <
198 <  result += buffer;
199 <
200 <
201 <
202 <  //print the ignore type list
203 <
204 <  sprintf(buffer , "lipidHeadName list contains below types:\n");
205 <
206 <  result += buffer;
207 <
208 <
209 <
210 <  for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){
211 <
212 <    sprintf(buffer ,"%s\t", i->c_str());
213 <
185 >    sprintf(buffer ,"------------------------------------------------------------------\n");
186      result += buffer;
187  
188 +    return result;
189 +
190    }
191  
218
219
220  sprintf(buffer ,"\n");
221
222  result += buffer;
223
224
225
226  sprintf(buffer ,"------------------------------------------------------------------\n");
227
228  result += buffer;
229
230
231
232  return result;
233
234
235
236 }
237
238
239
240 void RBCOMVisitor::visit(RigidBody* rb){
241
242  AtomData* atomData;
243
244  AtomInfo* atomInfo;
245
246  Vector3d pos;
247
248  
249
250  pos = rb->getPos();
251
252  atomInfo = new AtomInfo;
253
254  atomInfo->AtomType = "X";
255
256  atomInfo->pos[0] = pos[0];
257
258  atomInfo->pos[1] = pos[1];
259
260  atomInfo->pos[2] = pos[2];
261
262  atomInfo->dipole[0] = 0;
263
264  atomInfo->dipole[1] = 0;
265
266  atomInfo->dipole[2] = 0;
267
268
269
270  atomData = new AtomData;
271
272  atomData->setID("ATOMDATA");
273
274  atomData->addAtomInfo(atomInfo);
275
276
277
278  rb->addProperty(atomData);
279
280 }
281
282
283
284 const  std::string RBCOMVisitor::toString(){
285
286  char buffer[65535];
287
288   std::string result;
289
290  
291
292  sprintf(buffer ,"------------------------------------------------------------------\n");
293
294  result += buffer;
295
296  
297
298  sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
299
300  result += buffer;
301
302
303
304  //print the ignore type list
305
306  sprintf(buffer , "Visitor Description: add a pseudo atom at the center of the mass of the rigidbody\n");
307
308  result += buffer;
309
310
311
312  sprintf(buffer ,"------------------------------------------------------------------\n");
313
314  result += buffer;
315
316
317
318  return result;
319
320
321
322 }
323
324
325
326
327
192   }//namespace oopse
193  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines