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 2008 by tim, Sun Feb 13 19:10:25 2005 UTC vs.
Revision 2097 by tim, Wed Mar 9 17:30:29 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 45 | Line 45 | namespace oopse {
45   #include "primitives/Molecule.hpp"
46   #include "brains/SimInfo.hpp"
47   namespace oopse {
48
49 //----------------------------------------------------------------------------//
50 void IgnoreVisitor::visit(Atom *atom) {
51    if (isIgnoreType(atom->getType()))
52        internalVisit(atom);
53 }
54
55 void IgnoreVisitor::visit(DirectionalAtom *datom) {
56    if (isIgnoreType(datom->getType()))
57        internalVisit(datom);
58 }
59
60 void IgnoreVisitor::visit(RigidBody *rb) {
61    std::vector<Atom *>           myAtoms;
62    std::vector<Atom *>::iterator atomIter;
63    AtomInfo *                    atomInfo;
64
65    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    info->getSelectionManager()->clearSelection(sd);
81    //GenericData *data;
82    //data = sd->getPropertyByName("IGNORE");
83    //
84    ////if this stuntdoulbe is already marked as ignore just skip it
85    //if (data == NULL) {
86    //    data = new GenericData;
87    //    data->setID("IGNORE");
88    //    sd->addProperty(data);
89    //}
90 }
91
92 const std::string IgnoreVisitor::toString() {
93    char                            buffer[65535];
94    std::string                     result;
95    std::set<std::string>::iterator i;
96
97    sprintf(buffer,
98            "------------------------------------------------------------------\n");
99    result += buffer;
100
101    sprintf(buffer, "Visitor name: %s\n", visitorName.c_str());
102    result += buffer;
103
104    sprintf(buffer, "Visitor Description: ignore  stuntdoubles\n");
105    result += buffer;
106
107    //print the ignore type list
108    sprintf(buffer, "Ignore type list contains below types:\n");
109    result += buffer;
110
111    for( i = itList.begin(); i != itList.end(); ++i ) {
112        sprintf(buffer, "%s\t", i->c_str());
113        result += buffer;
114    }
115
116    sprintf(buffer, "\n");
117    result += buffer;
118
119    sprintf(buffer,
120            "------------------------------------------------------------------\n");
121    result += buffer;
122
123    return result;
124 }
48  
126 //----------------------------------------------------------------------------//
127
49   void WrappingVisitor::visit(Atom *atom) {
50   internalVisit(atom);
51   }
# Line 296 | Line 217 | XYZVisitor::XYZVisitor(SimInfo *info, bool printDipole
217  
218   //----------------------------------------------------------------------------//
219  
220 < XYZVisitor::XYZVisitor(SimInfo *info, bool printDipole) :
221 <    BaseVisitor() {
220 > XYZVisitor::XYZVisitor(SimInfo *info) :
221 >    BaseVisitor(), seleMan(info), evaluator(info){
222      this->info = info;
223      visitorName = "XYZVisitor";
224 <    this->printDipole = printDipole;
224 >
225 >    evaluator.loadScriptString("select all");
226 >
227 >    if (!evaluator.isDynamic()) {
228 >        seleMan.setSelectionSet(evaluator.evaluate());
229 >    }
230 >
231   }
232  
233 + XYZVisitor::XYZVisitor(SimInfo *info, const std::string& script) :
234 +    BaseVisitor(), seleMan(info), evaluator(info) {
235 +    this->info = info;
236 +    visitorName = "XYZVisitor";
237 +
238 +    evaluator.loadScriptString(script);
239 +
240 +    if (!evaluator.isDynamic()) {
241 +        seleMan.setSelectionSet(evaluator.evaluate());
242 +    }
243 +          
244 + }
245 +    
246   void XYZVisitor::visit(Atom *atom) {
247      if (isSelected(atom))
248          internalVisit(atom);
# Line 318 | Line 258 | void XYZVisitor::internalVisit(StuntDouble *sd) {
258          internalVisit(rb);
259   }
260  
261 + void XYZVisitor::update() {
262 +    //if dynamic, we need to re-evaluate the selection
263 +    if (evaluator.isDynamic()) {
264 +       seleMan.setSelectionSet(evaluator.evaluate());
265 +    }
266 + }
267 +
268   void XYZVisitor::internalVisit(StuntDouble *sd) {
269      GenericData *                     data;
270      AtomData *                        atomData;
# Line 338 | Line 285 | void XYZVisitor::internalVisit(StuntDouble *sd) {
285  
286      for( atomInfo = atomData->beginAtomInfo(i); atomInfo;
287          atomInfo = atomData->nextAtomInfo(i) ) {
288 <        if (printDipole)
289 <            sprintf(buffer,
290 <                    "%s%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f",
291 <                    atomInfo->AtomType.c_str(),
292 <                    atomInfo->pos[0],
293 <                    atomInfo->pos[1],
294 <                    atomInfo->pos[2],
295 <                    atomInfo->dipole[0],
296 <                    atomInfo->dipole[1],
350 <                    atomInfo->dipole[2]); else
351 <            sprintf(buffer,                     "%s%15.8f%15.8f%15.8f",
352 <                    atomInfo->AtomType.c_str(), atomInfo->pos[0],
353 <                    atomInfo->pos[1],           atomInfo->pos[2]);
354 <
288 >        sprintf(buffer,
289 >                "%s%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f",
290 >                atomInfo->atomTypeName.c_str(),
291 >                atomInfo->pos[0],
292 >                atomInfo->pos[1],
293 >                atomInfo->pos[2],
294 >                atomInfo->dipole[0],
295 >                atomInfo->dipole[1],
296 >                atomInfo->dipole[2]);
297          frame.push_back(buffer);
298      }
299   }
300  
301   bool XYZVisitor::isSelected(StuntDouble *sd) {
302 <    return info->getSelectionManager()->isSelected(sd);
302 >    return seleMan.isSelected(sd);
303   }
304  
305   void XYZVisitor::writeFrame(std::ostream &outStream) {
# Line 521 | Line 463 | void WaterTypeVisitor::visit(RigidBody *rb) {
463                  continue;
464  
465              for( atomInfo = atomData->beginAtomInfo(i); atomInfo;
466 <                atomInfo = atomData->nextAtomInfo(i) ) {
467 <            replaceType(atomInfo->AtomType);
466 >                 atomInfo = atomData->nextAtomInfo(i) ) {
467 >              atomInfo->atomTypeName = trimmedName(atomInfo->atomTypeName);
468              } //end for(atomInfo)
469          }     //end for(atomIter)
470      }         //end if (waterTypeList.find(rbName) != waterTypeList.end())
471   }
472  
473 < void WaterTypeVisitor::replaceType(std::string&atomType) {
474 < atomType = atomType.substr(0, atomType.find('_'));
475 < }
473 >  std::string WaterTypeVisitor::trimmedName(const std::string&atomTypeName) {
474 >    return atomTypeName.substr(0, atomTypeName.find('_'));
475 >  }
476  
477   const std::string WaterTypeVisitor::toString() {
478      char buffer[65535];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines