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

Comparing trunk/OOPSE-2.0/src/visitors/AtomVisitor.cpp (file contents):
Revision 1625 by tim, Thu Oct 21 16:22:01 2004 UTC vs.
Revision 1718 by chrisfen, Fri Nov 5 21:45:14 2004 UTC

# Line 174 | Line 174 | const string SSDAtomVisitor::toString(){
174    return result;
175   }
176  
177 + bool LinearAtomVisitor::isLinearAtom(const string& atomType){
178 +  vector<string>::iterator strIter;
179 +  
180 +  for(strIter = linearAtomType.begin(); strIter != linearAtomType.end();
181 +      ++strIter)
182 +    if(*strIter == atomType)
183 +      return true;
184 +  
185 +  return false;  
186 + }
187 +
188 + void LinearAtomVisitor::visit(DirectionalAtom* datom){
189 +
190 +  vector<AtomInfo*> atoms;
191 +
192 +  //we need to convert linear into 4 different atoms
193 +  double c1[3] = {0.0, 0.0, -1.8};
194 +  double c2[3] = {0.0, 0.0, -0.6};
195 +  double c3[3] = {0.0, 0.0,  0.6};
196 +  double c4[3] = {0.0, 0.0,  1.8};
197 +  double rotMatrix[3][3];
198 +  double rotTrans[3][3];
199 +  AtomInfo* atomInfo;
200 +  double pos[3];
201 +  double newVec[3];
202 +  double q[4];
203 +  AtomData* atomData;
204 +  GenericData* data;
205 +  bool haveAtomData;
206 +  
207 +  //if atom is not SSD atom, just skip it
208 +  if(!isLinearAtom(datom->getType()))
209 +    return;
210 +  
211 +  data = datom->getProperty("ATOMDATA");
212 +  if(data != NULL){
213 +
214 +    atomData = dynamic_cast<AtomData*>(data);  
215 +    if(atomData == NULL){
216 +      cerr << "can not get Atom Data from " << datom->getType() << endl;
217 +      atomData = new AtomData;
218 +      haveAtomData = false;      
219 +    }
220 +    else
221 +      haveAtomData = true;
222 +  }
223 +  else{
224 +    atomData = new AtomData;
225 +    haveAtomData = false;
226 +  }
227 +  
228 +  
229 +  datom->getPos(pos);
230 +  datom->getQ(q);
231 +  datom->getA(rotMatrix);
232 +
233 +  // We need A^T to convert from body-fixed to space-fixed:
234 +  transposeMat3(rotMatrix, rotTrans);
235 +  
236 +  matVecMul3(rotTrans, c1, newVec);
237 +  atomInfo = new AtomInfo;
238 +  atomInfo->AtomType = "C";
239 +  atomInfo->pos[0] = pos[0] + newVec[0];
240 +  atomInfo->pos[1] = pos[1] + newVec[1];
241 +  atomInfo->pos[2] = pos[2] + newVec[2];
242 +  atomInfo->dipole[0] = 0.0;
243 +  atomInfo->dipole[1] = 0.0;
244 +  atomInfo->dipole[2] = 0.0;
245 +  atomData->addAtomInfo(atomInfo);
246 +
247 +  matVecMul3(rotTrans, c2, newVec);
248 +  atomInfo = new AtomInfo;
249 +  atomInfo->AtomType = "C";
250 +  atomInfo->pos[0] = pos[0] + newVec[0];
251 +  atomInfo->pos[1] = pos[1] + newVec[1];
252 +  atomInfo->pos[2] = pos[2] + newVec[2];
253 +  atomInfo->dipole[0] = 0.0;
254 +  atomInfo->dipole[1] = 0.0;
255 +  atomInfo->dipole[2] = 0.0;
256 +  atomData->addAtomInfo(atomInfo);
257 +
258 +  matVecMul3(rotTrans, c3, newVec);
259 +  atomInfo = new AtomInfo;
260 +  atomInfo->AtomType = "C";
261 +  atomInfo->pos[0] = pos[0] + newVec[0];
262 +  atomInfo->pos[1] = pos[1] + newVec[1];
263 +  atomInfo->pos[2] = pos[2] + newVec[2];
264 +  atomInfo->dipole[0] = 0.0;
265 +  atomInfo->dipole[1] = 0.0;
266 +  atomInfo->dipole[2] = 0.0;
267 +  atomData->addAtomInfo(atomInfo);
268 +
269 +  matVecMul3(rotTrans, c4, newVec);
270 +  atomInfo = new AtomInfo;
271 +  atomInfo->AtomType = "C";
272 +  atomInfo->pos[0] = pos[0] + newVec[0];
273 +  atomInfo->pos[1] = pos[1] + newVec[1];
274 +  atomInfo->pos[2] = pos[2] + newVec[2];
275 +  atomInfo->dipole[0] = 0.0;
276 +  atomInfo->dipole[1] = 0.0;
277 +  atomInfo->dipole[2] = 0.0;
278 +  atomData->addAtomInfo(atomInfo);
279 +
280 +  //add atom data into atom's property
281 +
282 +  if(!haveAtomData){
283 +    atomData->setID("ATOMDATA");
284 +    datom->addProperty(atomData);
285 +  }
286 +
287 +  setVisited(datom);
288 +
289 + }
290 +
291 + const string LinearAtomVisitor::toString(){
292 +  char buffer[65535];
293 +  string result;
294 +  
295 +  sprintf(buffer ,"------------------------------------------------------------------\n");
296 +  result += buffer;
297 +
298 +  sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
299 +  result += buffer;
300 +
301 +  sprintf(buffer , "Visitor Description: Convert linear into 4 different atoms\n");
302 +  result += buffer;
303 +
304 +  sprintf(buffer ,"------------------------------------------------------------------\n");
305 +  result += buffer;
306 +
307 +  return result;
308 + }
309 +
310   //----------------------------------------------------------------------------//
311  
312   void DefaultAtomVisitor::visit(Atom* atom){

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines