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

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines