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

Comparing trunk/OOPSE-4/src/visitors/OtherVisitor.cpp (file contents):
Revision 1930 by gezelter, Wed Jan 12 22:41:40 2005 UTC vs.
Revision 3446 by cli2, Wed Sep 10 19:51:45 2008 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
5   * non-exclusive, royalty free, license to use, modify and
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8 *
8   * 1. Acknowledgement of the program authors must be made in any
9   *    publication of scientific results based in part on use of the
10   *    program.  An acceptable form of acknowledgement is citation of
# Line 38 | Line 37
37   * University of Notre Dame has been advised of the possibility of
38   * such damages.
39   */
40 <
40 > #include "selection/SelectionManager.hpp"
41   #include "visitors/OtherVisitor.hpp"
42   #include "primitives/DirectionalAtom.hpp"
43   #include "primitives/RigidBody.hpp"
# Line 46 | Line 45 | namespace oopse {
45   #include "brains/SimInfo.hpp"
46   namespace oopse {
47  
48 < //----------------------------------------------------------------------------//
49 < void IgnoreVisitor::visit(Atom *atom) {
50 <    if (isIgnoreType(atom->getType()))
52 <        internalVisit(atom);
53 < }
48 >  void WrappingVisitor::visit(Atom *atom) {
49 >    internalVisit(atom);
50 >  }
51  
52 < void IgnoreVisitor::visit(DirectionalAtom *datom) {
53 <    if (isIgnoreType(datom->getType()))
54 <        internalVisit(datom);
58 < }
52 >  void WrappingVisitor::visit(DirectionalAtom *datom) {
53 >    internalVisit(datom);
54 >  }
55  
56 < void IgnoreVisitor::visit(RigidBody *rb) {
57 <    std::vector<Atom *>           myAtoms;
58 <    std::vector<Atom *>::iterator atomIter;
63 <    AtomInfo *                    atomInfo;
56 >  void WrappingVisitor::visit(RigidBody *rb) {
57 >    internalVisit(rb);
58 >  }
59  
60 <    if (isIgnoreType(rb->getType())) {
66 <        internalVisit(rb);
67 <
68 <        myAtoms = rb->getAtoms();
69 <
70 <        for( atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter )
71 <            internalVisit(*atomIter);
72 <    }
73 < }
74 <
75 < bool IgnoreVisitor::isIgnoreType(const std::string&name) {
76 < return itList.find(name) != itList.end() ? true : false;
77 < }
78 <
79 < void IgnoreVisitor::internalVisit(StuntDouble *sd) {
80 <    GenericData *data;
81 <    data = sd->getPropertyByName("IGNORE");
82 <
83 <    //if this stuntdoulbe is already marked as ignore just skip it
84 <    if (data == NULL) {
85 <        data = new GenericData;
86 <        data->setID("IGNORE");
87 <        sd->addProperty(data);
88 <    }
89 < }
90 <
91 < const std::string IgnoreVisitor::toString() {
92 <    char                            buffer[65535];
93 <    std::string                     result;
94 <    std::set<std::string>::iterator i;
95 <
96 <    sprintf(buffer,
97 <            "------------------------------------------------------------------\n");
98 <    result += buffer;
99 <
100 <    sprintf(buffer, "Visitor name: %s\n", visitorName.c_str());
101 <    result += buffer;
102 <
103 <    sprintf(buffer, "Visitor Description: ignore  stuntdoubles\n");
104 <    result += buffer;
105 <
106 <    //print the ignore type list
107 <    sprintf(buffer, "Ignore type list contains below types:\n");
108 <    result += buffer;
109 <
110 <    for( i = itList.begin(); i != itList.end(); ++i ) {
111 <        sprintf(buffer, "%s\t", i->c_str());
112 <        result += buffer;
113 <    }
114 <
115 <    sprintf(buffer, "\n");
116 <    result += buffer;
117 <
118 <    sprintf(buffer,
119 <            "------------------------------------------------------------------\n");
120 <    result += buffer;
121 <
122 <    return result;
123 < }
124 <
125 < //----------------------------------------------------------------------------//
126 <
127 < void WrappingVisitor::visit(Atom *atom) {
128 < internalVisit(atom);
129 < }
130 <
131 < void WrappingVisitor::visit(DirectionalAtom *datom) {
132 < internalVisit(datom);
133 < }
134 <
135 < void WrappingVisitor::visit(RigidBody *rb) {
136 < internalVisit(rb);
137 < }
138 <
139 < void WrappingVisitor::internalVisit(StuntDouble *sd) {
60 >  void WrappingVisitor::internalVisit(StuntDouble *sd) {
61      GenericData *                     data;
62      AtomData *                        atomData;
63      AtomInfo *                        atomInfo;
# Line 145 | Line 66 | void WrappingVisitor::internalVisit(StuntDouble *sd) {
66      data = sd->getPropertyByName("ATOMDATA");
67  
68      if (data != NULL) {
69 <        atomData = dynamic_cast<AtomData *>(data);
69 >      atomData = dynamic_cast<AtomData *>(data);
70  
71 <        if (atomData == NULL)
72 <            return;
71 >      if (atomData == NULL)
72 >        return;
73      } else
74 <        return;
74 >      return;
75  
76      Snapshot* currSnapshot = info->getSnapshotManager()->getCurrentSnapshot();
77      
78      for( atomInfo = atomData->beginAtomInfo(i); atomInfo; atomInfo = atomData->nextAtomInfo(i) ) {
79 <        currSnapshot->wrapVector(atomInfo->pos);
79 >      Vector3d newPos = atomInfo->pos - origin_;
80 >      currSnapshot->wrapVector(newPos);
81 >      atomInfo->pos = newPos;
82      }
83 < }
83 >  }
84  
85 < const std::string WrappingVisitor::toString() {
85 >  void WrappingVisitor::update() {
86 >    if (useCom_){
87 >      origin_ = info->getCom();
88 >    }
89 >  }
90 >  
91 >  const std::string WrappingVisitor::toString() {
92      char        buffer[65535];
93      std::string result;
94  
# Line 179 | Line 108 | const std::string WrappingVisitor::toString() {
108      result += buffer;
109  
110      return result;
111 < }
111 >  }
112  
113 < //----------------------------------------------------------------------------//
113 >  //----------------------------------------------------------------------------//
114  
115 < ReplicateVisitor::ReplicateVisitor(SimInfo *info, Vector3i opt) :
115 >  ReplicateVisitor::ReplicateVisitor(SimInfo *info, Vector3i opt) :
116      BaseVisitor() {
117 <    this->info = info;
118 <    visitorName = "ReplicateVisitor";
119 <    this->replicateOpt = opt;
117 >      this->info = info;
118 >      visitorName = "ReplicateVisitor";
119 >      this->replicateOpt = opt;
120  
121 <    //generate the replicate directions
122 <    for( int i = 0; i <= replicateOpt[0]; i++ ) {
121 >      //generate the replicate directions
122 >      for( int i = 0; i <= replicateOpt[0]; i++ ) {
123          for( int j = 0; j <= replicateOpt[1]; j++ ) {
124 <            for( int k = 0; k <= replicateOpt[2]; k++ ) {
125 <                //skip original frame
126 <                if (i == 0 && j == 0 && k == 0) {
127 <                    continue;
128 <                } else {
129 <                    dir.push_back(Vector3i(i, j, k));
130 <                }
131 <            }
124 >          for( int k = 0; k <= replicateOpt[2]; k++ ) {
125 >            //skip original frame
126 >            if (i == 0 && j == 0 && k == 0) {
127 >              continue;
128 >            } else {
129 >              dir.push_back(Vector3i(i, j, k));
130 >            }
131 >          }
132          }
133 <    }
133 >      }
134      
135 < }
135 >    }
136  
137 < void ReplicateVisitor::visit(Atom *atom) {
138 < internalVisit(atom);
139 < }
137 >  void ReplicateVisitor::visit(Atom *atom) {
138 >    internalVisit(atom);
139 >  }
140  
141 < void ReplicateVisitor::visit(DirectionalAtom *datom) {
142 < internalVisit(datom);
143 < }
141 >  void ReplicateVisitor::visit(DirectionalAtom *datom) {
142 >    internalVisit(datom);
143 >  }
144  
145 < void ReplicateVisitor::visit(RigidBody *rb) {
146 < internalVisit(rb);
147 < }
145 >  void ReplicateVisitor::visit(RigidBody *rb) {
146 >    internalVisit(rb);
147 >  }
148  
149 < void ReplicateVisitor::internalVisit(StuntDouble *sd) {
149 >  void ReplicateVisitor::internalVisit(StuntDouble *sd) {
150      GenericData *          data;
151      AtomData *             atomData;
152  
# Line 225 | Line 154 | void ReplicateVisitor::internalVisit(StuntDouble *sd)
154      data = sd->getPropertyByName("ATOMDATA");
155  
156      if (data != NULL) {
157 <        atomData = dynamic_cast<AtomData *>(data);
157 >      atomData = dynamic_cast<AtomData *>(data);
158  
159 <        if (atomData == NULL) {
160 <            return;
161 <        }
159 >      if (atomData == NULL) {
160 >        return;
161 >      }
162      } else {
163 <        return;
163 >      return;
164      }
165  
166      Snapshot* currSnapshot = info->getSnapshotManager()->getCurrentSnapshot();
# Line 240 | Line 169 | void ReplicateVisitor::internalVisit(StuntDouble *sd)
169      std::vector<AtomInfo *> atomInfoList = atomData->getData();
170  
171      replicate(atomInfoList, atomData, box);
172 < }
172 >  }
173  
174 < void ReplicateVisitor::replicate(std::vector<AtomInfo *>&infoList, AtomData *data, const Mat3x3d& box) {
174 >  void ReplicateVisitor::replicate(std::vector<AtomInfo *>&infoList, AtomData *data, const Mat3x3d& box) {
175      AtomInfo* newAtomInfo;
176      std::vector<Vector3i>::iterator dirIter;
177      std::vector<AtomInfo *>::iterator i;
178  
179      for( dirIter = dir.begin(); dirIter != dir.end(); ++dirIter ) {
180 <        for( i = infoList.begin(); i != infoList.end(); i++ ) {
181 <            newAtomInfo = new AtomInfo();
182 <            *newAtomInfo = *(*i);
180 >      for( i = infoList.begin(); i != infoList.end(); i++ ) {
181 >        newAtomInfo = new AtomInfo();
182 >        *newAtomInfo = *(*i);
183  
184 <            for( int j = 0; j < 3; j++ )
185 <                newAtomInfo->pos[j] += (*dirIter)[0]*box(j, 0) + (*dirIter)[1]*box(j, 1) + (*dirIter)[2]*box(j, 2);
184 >        for( int j = 0; j < 3; j++ )
185 >          newAtomInfo->pos[j] += (*dirIter)[0]*box(j, 0) + (*dirIter)[1]*box(j, 1) + (*dirIter)[2]*box(j, 2);
186  
187 <            data->addAtomInfo(newAtomInfo);
188 <        }
187 >        data->addAtomInfo(newAtomInfo);
188 >      }
189      } // end for(dirIter)  
190 < }
190 >  }
191  
192 < const std::string ReplicateVisitor::toString() {
192 >  const std::string ReplicateVisitor::toString() {
193      char                            buffer[65535];
194      std::string                     result;
195      std::set<std::string>::iterator i;
# Line 291 | Line 220 | const std::string ReplicateVisitor::toString() {
220      result += buffer;
221  
222      return result;
223 < }
223 >  }
224  
225 < //----------------------------------------------------------------------------//
225 >  //----------------------------------------------------------------------------//
226  
227 < XYZVisitor::XYZVisitor(SimInfo *info, bool printDipole) :
228 <    BaseVisitor() {
229 <    this->info = info;
230 <    visitorName = "XYZVisitor";
302 <    this->printDipole = printDipole;
303 < }
227 >  XYZVisitor::XYZVisitor(SimInfo *info) :
228 >    BaseVisitor(), seleMan(info), evaluator(info){
229 >      this->info = info;
230 >      visitorName = "XYZVisitor";
231  
232 < void XYZVisitor::visit(Atom *atom) {
306 <    if (!isIgnore(atom))
307 <        internalVisit(atom);
308 < }
232 >      evaluator.loadScriptString("select all");
233  
234 < void XYZVisitor::visit(DirectionalAtom *datom) {
235 <    if (!isIgnore(datom))
236 <        internalVisit(datom);
237 < }
234 >      if (!evaluator.isDynamic()) {
235 >        seleMan.setSelectionSet(evaluator.evaluate());
236 >      }
237 >      posOnly_ = false;
238 >    }
239  
240 < void XYZVisitor::visit(RigidBody *rb) {
241 <    if (!isIgnore(rb))
242 <        internalVisit(rb);
243 < }
240 >  XYZVisitor::XYZVisitor(SimInfo *info, const std::string& script) :
241 >    BaseVisitor(), seleMan(info), evaluator(info) {
242 >      this->info = info;
243 >      visitorName = "XYZVisitor";
244  
245 < void XYZVisitor::internalVisit(StuntDouble *sd) {
245 >      evaluator.loadScriptString(script);
246 >
247 >      if (!evaluator.isDynamic()) {
248 >        seleMan.setSelectionSet(evaluator.evaluate());
249 >      }
250 >      posOnly_ = false;
251 >    }
252 >    
253 >  void XYZVisitor::visit(Atom *atom) {
254 >    if (isSelected(atom))
255 >      internalVisit(atom);
256 >  }
257 >
258 >  void XYZVisitor::visit(DirectionalAtom *datom) {
259 >    if (isSelected(datom))
260 >      internalVisit(datom);
261 >  }
262 >
263 >  void XYZVisitor::visit(RigidBody *rb) {
264 >    if (isSelected(rb))
265 >      internalVisit(rb);
266 >  }
267 >
268 >  void XYZVisitor::update() {
269 >    //if dynamic, we need to re-evaluate the selection
270 >    if (evaluator.isDynamic()) {
271 >      seleMan.setSelectionSet(evaluator.evaluate());
272 >    }
273 >  }
274 >
275 >  void XYZVisitor::internalVisit(StuntDouble *sd) {
276      GenericData *                     data;
277      AtomData *                        atomData;
278      AtomInfo *                        atomInfo;
# Line 328 | Line 283 | void XYZVisitor::internalVisit(StuntDouble *sd) {
283      data = sd->getPropertyByName("ATOMDATA");
284  
285      if (data != NULL) {
286 <        atomData = dynamic_cast<AtomData *>(data);
286 >      atomData = dynamic_cast<AtomData *>(data);
287  
288 <        if (atomData == NULL)
289 <            return;
288 >      if (atomData == NULL)
289 >        return;
290      } else
291 <        return;
291 >      return;
292  
293 <    for( atomInfo = atomData->beginAtomInfo(i); atomInfo;
294 <        atomInfo = atomData->nextAtomInfo(i) ) {
340 <        if (printDipole)
341 <            sprintf(buffer,
342 <                    "%s%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f",
343 <                    atomInfo->AtomType.c_str(),
344 <                    atomInfo->pos[0],
345 <                    atomInfo->pos[1],
346 <                    atomInfo->pos[2],
347 <                    atomInfo->dipole[0],
348 <                    atomInfo->dipole[1],
349 <                    atomInfo->dipole[2]); else
350 <            sprintf(buffer,                     "%s%15.8f%15.8f%15.8f",
351 <                    atomInfo->AtomType.c_str(), atomInfo->pos[0],
352 <                    atomInfo->pos[1],           atomInfo->pos[2]);
293 >    AtomType* at = dynamic_cast<Atom *>(sd)->getAtomType();
294 >    std::string bn = baseTypeName(at);
295  
296 <        frame.push_back(buffer);
296 >    if (posOnly_){
297 >      for( atomInfo = atomData->beginAtomInfo(i); atomInfo;
298 >           atomInfo = atomData->nextAtomInfo(i) ) {
299 >        if (atomInfo->hasCharge) {
300 >          sprintf(buffer,
301 >                  "%s%15.8f%15.8f%15.8f%15.8f",
302 >                  bn.c_str(),
303 >                  atomInfo->pos[0],
304 >                  atomInfo->pos[1],
305 >                  atomInfo->pos[2],
306 >                  atomInfo->charge);
307 >        } else {
308 >          sprintf(buffer,
309 >                "%s%15.8f%15.8f%15.8f",
310 >                  bn.c_str(),
311 >                  atomInfo->pos[0],
312 >                  atomInfo->pos[1],
313 >                  atomInfo->pos[2]);
314 >        }
315 >        frame.push_back(buffer);
316 >      }
317 >    }else{
318 >      for( atomInfo = atomData->beginAtomInfo(i); atomInfo;
319 >           atomInfo = atomData->nextAtomInfo(i) ) {
320 >        if (atomInfo->hasCharge) {
321 >        sprintf(buffer,
322 >                "%s%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f",
323 >                bn.c_str(),
324 >                atomInfo->pos[0],
325 >                atomInfo->pos[1],
326 >                atomInfo->pos[2],
327 >                atomInfo->charge,
328 >                atomInfo->dipole[0],
329 >                atomInfo->dipole[1],
330 >                atomInfo->dipole[2]);
331 >        } else {
332 >        sprintf(buffer,
333 >                "%s%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f",
334 >                bn.c_str(),
335 >                atomInfo->pos[0],
336 >                atomInfo->pos[1],
337 >                atomInfo->pos[2],
338 >                atomInfo->dipole[0],
339 >                atomInfo->dipole[1],
340 >                atomInfo->dipole[2]);
341 >        }
342 >        frame.push_back(buffer);
343 >      }
344      }
345 < }
345 >  }
346  
347 < bool XYZVisitor::isIgnore(StuntDouble *sd) {
348 <    GenericData *data;
347 >  bool XYZVisitor::isSelected(StuntDouble *sd) {
348 >    return seleMan.isSelected(sd);
349 >  }
350  
351 <    data = sd->getPropertyByName("IGNORE");
362 <    return data == NULL ? false : true;
363 < }
364 <
365 < void XYZVisitor::writeFrame(std::ostream &outStream) {
351 >  void XYZVisitor::writeFrame(std::ostream &outStream) {
352      std::vector<std::string>::iterator i;
353      char buffer[1024];
354  
355      if (frame.size() == 0)
356 <        std::cerr << "Current Frame does not contain any atoms" << std::endl;
356 >      std::cerr << "Current Frame does not contain any atoms" << std::endl;
357  
358      //total number of atoms  
359      outStream << frame.size() << std::endl;
# Line 386 | Line 372 | void XYZVisitor::writeFrame(std::ostream &outStream) {
372      outStream << buffer << std::endl;
373  
374      for( i = frame.begin(); i != frame.end(); ++i )
375 <        outStream << *i << std::endl;
376 < }
375 >      outStream << *i << std::endl;
376 >  }
377  
378 < const std::string XYZVisitor::toString() {
378 >  std::string XYZVisitor::trimmedName(const std::string&atomTypeName) {    
379 >    return atomTypeName.substr(0, atomTypeName.find('-'));
380 >  }
381 >
382 >  std::string XYZVisitor::baseTypeName(AtomType* at) {
383 >    std::vector<AtomType*> ayb = at->allYourBase();
384 >    return ayb[ayb.size()-1]->getName();
385 >  }
386 >
387 >  const std::string XYZVisitor::toString() {
388      char        buffer[65535];
389      std::string result;
390  
# Line 409 | Line 404 | const std::string XYZVisitor::toString() {
404      result += buffer;
405  
406      return result;
407 < }
407 >  }
408  
409 < //----------------------------------------------------------------------------//
409 >  //----------------------------------------------------------------------------//
410  
411 < void PrepareVisitor::internalVisit(Atom *atom) {
411 >  void PrepareVisitor::internalVisit(Atom *atom) {
412      GenericData *data;
413      AtomData *   atomData;
414  
# Line 421 | Line 416 | void PrepareVisitor::internalVisit(Atom *atom) {
416      data = atom->getPropertyByName("VISITED");
417  
418      if (data != NULL) {
419 <    atom->removeProperty("VISITED");
419 >      atom->removeProperty("VISITED");
420      }
421  
422      //remove atomdata
423      data = atom->getPropertyByName("ATOMDATA");
424  
425      if (data != NULL) {
426 <        atomData = dynamic_cast<AtomData *>(data);
426 >      atomData = dynamic_cast<AtomData *>(data);
427  
428 <        if (atomData != NULL)
429 <            atom->removeProperty("ATOMDATA");
430 <    }
431 < }
428 >      if (atomData != NULL)
429 >        atom->removeProperty("ATOMDATA");
430 >    }
431 >  }
432  
433 < void PrepareVisitor::internalVisit(RigidBody *rb) {
433 >  void PrepareVisitor::internalVisit(RigidBody *rb) {
434      GenericData* data;
435      AtomData* atomData;
436      std::vector<Atom *> myAtoms;
# Line 445 | Line 440 | void PrepareVisitor::internalVisit(RigidBody *rb) {
440      data = rb->getPropertyByName("VISITED");
441  
442      if (data != NULL) {
443 <    rb->removeProperty("VISITED");
443 >      rb->removeProperty("VISITED");
444      }
445  
446      //remove atomdata
447      data = rb->getPropertyByName("ATOMDATA");
448  
449      if (data != NULL) {
450 <        atomData = dynamic_cast<AtomData *>(data);
450 >      atomData = dynamic_cast<AtomData *>(data);
451  
452 <        if (atomData != NULL)
453 <            rb->removeProperty("ATOMDATA");
452 >      if (atomData != NULL)
453 >        rb->removeProperty("ATOMDATA");
454      }
455  
456      myAtoms = rb->getAtoms();
457  
458      for( atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter )
459 <        internalVisit(*atomIter);
460 < }
459 >      internalVisit(*atomIter);
460 >  }
461  
462 < const std::string PrepareVisitor::toString() {
462 >  const std::string PrepareVisitor::toString() {
463      char buffer[65535];
464      std::string result;
465 <
465 >
466      sprintf(buffer,
467 <            "------------------------------------------------------------------\n");
467 >            "------------------------------------------------------------------\n");
468      result += buffer;
469 <
469 >
470      sprintf(buffer, "Visitor name: %s", visitorName.c_str());
471      result += buffer;
472 <
472 >
473      sprintf(buffer,
474 <            "Visitor Description: prepare for operation of other vistors\n");
474 >            "Visitor Description: prepare for operation of other vistors\n");
475      result += buffer;
476 <
476 >
477      sprintf(buffer,
478 <            "------------------------------------------------------------------\n");
478 >            "------------------------------------------------------------------\n");
479      result += buffer;
480 <
480 >
481      return result;
482 < }
482 >  }
483  
484 < //----------------------------------------------------------------------------//
484 >  //----------------------------------------------------------------------------//
485  
486 < WaterTypeVisitor::WaterTypeVisitor() {
486 >  WaterTypeVisitor::WaterTypeVisitor() {
487      visitorName = "WaterTypeVisitor";
488      waterTypeList.insert("TIP3P_RB_0");
489      waterTypeList.insert("TIP4P_RB_0");
490      waterTypeList.insert("TIP5P_RB_0");
491      waterTypeList.insert("SPCE_RB_0");
492 < }
492 >  }
493  
494 < void WaterTypeVisitor::visit(RigidBody *rb) {
494 >  void WaterTypeVisitor::visit(RigidBody *rb) {
495      std::string rbName;
496      std::vector<Atom *> myAtoms;
497      std::vector<Atom *>::iterator atomIter;
# Line 508 | Line 503 | void WaterTypeVisitor::visit(RigidBody *rb) {
503      rbName = rb->getType();
504  
505      if (waterTypeList.find(rbName) != waterTypeList.end()) {
506 <        myAtoms = rb->getAtoms();
506 >      myAtoms = rb->getAtoms();
507  
508 <        for( atomIter = myAtoms.begin(); atomIter != myAtoms.end();
509 <            ++atomIter ) {
510 <            data = (*atomIter)->getPropertyByName("ATOMDATA");
508 >      for( atomIter = myAtoms.begin(); atomIter != myAtoms.end();
509 >           ++atomIter ) {
510 >        data = (*atomIter)->getPropertyByName("ATOMDATA");
511  
512 <            if (data != NULL) {
513 <                atomData = dynamic_cast<AtomData *>(data);
512 >        if (data != NULL) {
513 >          atomData = dynamic_cast<AtomData *>(data);
514  
515 <                if (atomData == NULL)
516 <                    continue;
517 <            } else
518 <                continue;
515 >          if (atomData == NULL)
516 >            continue;
517 >        } else
518 >          continue;
519  
520 <            for( atomInfo = atomData->beginAtomInfo(i); atomInfo;
521 <                atomInfo = atomData->nextAtomInfo(i) ) {
522 <            replaceType(atomInfo->AtomType);
523 <            } //end for(atomInfo)
524 <        }     //end for(atomIter)
520 >        for( atomInfo = atomData->beginAtomInfo(i); atomInfo;
521 >             atomInfo = atomData->nextAtomInfo(i) ) {
522 >          atomInfo->atomTypeName = trimmedName(atomInfo->atomTypeName);
523 >        } //end for(atomInfo)
524 >      }     //end for(atomIter)
525      }         //end if (waterTypeList.find(rbName) != waterTypeList.end())
526 < }
526 >  }
527  
528 < void WaterTypeVisitor::replaceType(std::string&atomType) {
529 < atomType = atomType.substr(0, atomType.find('_'));
530 < }
528 >  std::string WaterTypeVisitor::trimmedName(const std::string&atomTypeName) {
529 >    return atomTypeName.substr(0, atomTypeName.find('_'));
530 >  }
531  
532 < const std::string WaterTypeVisitor::toString() {
532 >  const std::string WaterTypeVisitor::toString() {
533      char buffer[65535];
534      std::string result;
535  
# Line 554 | Line 549 | const std::string WaterTypeVisitor::toString() {
549      result += buffer;
550  
551      return result;
552 < }
552 >  }
553  
554   } //namespace oopse

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines