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

Comparing trunk/OOPSE-4/src/visitors/AtomVisitor.cpp (file contents):
Revision 2097 by tim, Wed Mar 9 17:30:29 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 45 | Line 45 | void BaseAtomVisitor::visit(RigidBody *rb) {
45   #include "primitives/RigidBody.hpp"
46  
47   namespace oopse {
48 < void BaseAtomVisitor::visit(RigidBody *rb) {
49 < //vector<Atom*> myAtoms;
50 < //vector<Atom*>::iterator atomIter;
48 >  void BaseAtomVisitor::visit(RigidBody *rb) {
49 >    //vector<Atom*> myAtoms;
50 >    //vector<Atom*>::iterator atomIter;
51  
52 < //myAtoms = rb->getAtoms();
52 >    //myAtoms = rb->getAtoms();
53  
54 < //for(atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter)
55 < //  (*atomIter)->accept(this);
56 <    }
54 >    //for(atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter)
55 >    //  (*atomIter)->accept(this);
56 >  }
57  
58 < void BaseAtomVisitor::setVisited(Atom *atom) {
58 >  void BaseAtomVisitor::setVisited(Atom *atom) {
59      GenericData *data;
60      data = atom->getPropertyByName("VISITED");
61  
62      //if visited property is not existed, add it as new property
63      if (data == NULL) {
64 <        data = new GenericData();
65 <        data->setID("VISITED");
66 <        atom->addProperty(data);
64 >      data = new GenericData();
65 >      data->setID("VISITED");
66 >      atom->addProperty(data);
67      }
68 < }
68 >  }
69  
70 < bool BaseAtomVisitor::isVisited(Atom *atom) {
70 >  bool BaseAtomVisitor::isVisited(Atom *atom) {
71      GenericData *data;
72      data = atom->getPropertyByName("VISITED");
73      return data == NULL ? false : true;
74 < }
74 >  }
75  
76 < bool SSDAtomVisitor::isSSDAtom(const std::string&atomType) {
76 >  bool SSDAtomVisitor::isSSDAtom(const std::string&atomType) {
77      std::set<std::string>::iterator strIter;
78      strIter = ssdAtomType.find(atomType);
79      return strIter != ssdAtomType.end() ? true : false;
80 < }
80 >  }
81  
82 < void SSDAtomVisitor::visit(DirectionalAtom *datom) {
82 >  void SSDAtomVisitor::visit(DirectionalAtom *datom) {
83      std::vector<AtomInfo*>atoms;
84  
85      //we need to convert SSD into 4 differnet atoms
# Line 101 | Line 101 | void SSDAtomVisitor::visit(DirectionalAtom *datom) {
101  
102      //if atom is not SSD atom, just skip it
103      if (!isSSDAtom(datom->getType()))
104 <        return;
104 >      return;
105  
106      data = datom->getPropertyByName("ATOMDATA");
107  
108      if (data != NULL) {
109 <        atomData = dynamic_cast<AtomData *>(data);
109 >      atomData = dynamic_cast<AtomData *>(data);
110  
111 <        if (atomData == NULL) {
112 <            std::cerr << "can not get Atom Data from " << datom->getType() << std::endl;
113 <            atomData = new AtomData;
114 <            haveAtomData = false;
115 <        } else
116 <            haveAtomData = true;
111 >      if (atomData == NULL) {
112 >        std::cerr << "can not get Atom Data from " << datom->getType() << std::endl;
113 >        atomData = new AtomData;
114 >        haveAtomData = false;
115 >      } else
116 >        haveAtomData = true;
117      } else {
118 <        atomData = new AtomData;
119 <        haveAtomData = false;
118 >      atomData = new AtomData;
119 >      haveAtomData = false;
120      }
121  
122      pos = datom->getPos();
# Line 185 | Line 185 | void SSDAtomVisitor::visit(DirectionalAtom *datom) {
185      //add atom data into atom's property
186  
187      if (!haveAtomData) {
188 <        atomData->setID("ATOMDATA");
189 <        datom->addProperty(atomData);
188 >      atomData->setID("ATOMDATA");
189 >      datom->addProperty(atomData);
190      }
191  
192      setVisited(datom);
193 < }
193 >  }
194  
195 < const std::string SSDAtomVisitor::toString() {
195 >  const std::string SSDAtomVisitor::toString() {
196      char   buffer[65535];
197      std::string result;
198  
# Line 212 | Line 212 | const std::string SSDAtomVisitor::toString() {
212      result += buffer;
213  
214      return result;
215 < }
215 >  }
216  
217 < bool LinearAtomVisitor::isLinearAtom(const std::string& atomType){
217 >  bool LinearAtomVisitor::isLinearAtom(const std::string& atomType){
218      std::set<std::string>::iterator strIter;
219      strIter = linearAtomType.find(atomType);
220  
221      return strIter != linearAtomType.end() ? true : false;
222 < }
222 >  }
223  
224 < void LinearAtomVisitor::visit(DirectionalAtom* datom){
224 >  void LinearAtomVisitor::visit(DirectionalAtom* datom){
225      std::vector<AtomInfo*> atoms;
226      //we need to convert linear into 4 different atoms
227      Vector3d c1(0.0, 0.0, -1.8);
# Line 240 | Line 240 | void LinearAtomVisitor::visit(DirectionalAtom* datom){
240  
241      //if atom is not SSD atom, just skip it
242      if(!isLinearAtom(datom->getType()))
243 <        return;
243 >      return;
244  
245      data = datom->getPropertyByName("ATOMDATA");
246      if(data != NULL){
247 <        atomData = dynamic_cast<AtomData*>(data);  
248 <        if(atomData == NULL){
249 <            std::cerr << "can not get Atom Data from " << datom->getType() << std::endl;
250 <            atomData = new AtomData;
251 <            haveAtomData = false;      
252 <        } else {
253 <            haveAtomData = true;
254 <        }
247 >      atomData = dynamic_cast<AtomData*>(data);  
248 >      if(atomData == NULL){
249 >        std::cerr << "can not get Atom Data from " << datom->getType() << std::endl;
250 >        atomData = new AtomData;
251 >        haveAtomData = false;      
252 >      } else {
253 >        haveAtomData = true;
254 >      }
255      } else {
256 <        atomData = new AtomData;
257 <        haveAtomData = false;
256 >      atomData = new AtomData;
257 >      haveAtomData = false;
258      }
259    
260    
# Line 312 | Line 312 | void LinearAtomVisitor::visit(DirectionalAtom* datom){
312      //add atom data into atom's property
313  
314      if(!haveAtomData){
315 <        atomData->setID("ATOMDATA");
316 <        datom->addProperty(atomData);
315 >      atomData->setID("ATOMDATA");
316 >      datom->addProperty(atomData);
317      }
318  
319      setVisited(datom);
320  
321 < }
321 >  }
322  
323 < const std::string LinearAtomVisitor::toString(){
324 <  char buffer[65535];
325 <  std::string result;
323 >  const std::string LinearAtomVisitor::toString(){
324 >    char buffer[65535];
325 >    std::string result;
326    
327 <  sprintf(buffer ,"------------------------------------------------------------------\n");
328 <  result += buffer;
327 >    sprintf(buffer ,"------------------------------------------------------------------\n");
328 >    result += buffer;
329  
330 <  sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
331 <  result += buffer;
330 >    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
331 >    result += buffer;
332  
333 <  sprintf(buffer , "Visitor Description: Convert linear into 4 different atoms\n");
334 <  result += buffer;
333 >    sprintf(buffer , "Visitor Description: Convert linear into 4 different atoms\n");
334 >    result += buffer;
335  
336 <  sprintf(buffer ,"------------------------------------------------------------------\n");
337 <  result += buffer;
336 >    sprintf(buffer ,"------------------------------------------------------------------\n");
337 >    result += buffer;
338  
339 <  return result;
340 < }
339 >    return result;
340 >  }
341  
342 < //----------------------------------------------------------------------------//
342 >  //----------------------------------------------------------------------------//
343  
344 < void DefaultAtomVisitor::visit(Atom *atom) {
344 >  void DefaultAtomVisitor::visit(Atom *atom) {
345      AtomData *atomData;
346      AtomInfo *atomInfo;
347      Vector3d  pos;
348  
349      if (isVisited(atom))
350 <        return;
350 >      return;
351  
352      atomInfo = new AtomInfo;
353  
# Line 368 | Line 368 | void DefaultAtomVisitor::visit(Atom *atom) {
368      atom->addProperty(atomData);
369  
370      setVisited(atom);
371 < }
371 >  }
372  
373 < void DefaultAtomVisitor::visit(DirectionalAtom *datom) {
373 >  void DefaultAtomVisitor::visit(DirectionalAtom *datom) {
374      AtomData *atomData;
375      AtomInfo *atomInfo;
376      Vector3d  pos;
377      Vector3d  u;
378  
379      if (isVisited(datom))
380 <        return;
380 >      return;
381  
382      pos = datom->getPos();
383      u = datom->getElectroFrame().getColumn(2);
# Line 399 | Line 399 | void DefaultAtomVisitor::visit(DirectionalAtom *datom)
399      datom->addProperty(atomData);
400  
401      setVisited(datom);
402 < }
402 >  }
403  
404 < const std::string DefaultAtomVisitor::toString() {
404 >  const std::string DefaultAtomVisitor::toString() {
405      char   buffer[65535];
406      std::string result;
407  
# Line 421 | Line 421 | const std::string DefaultAtomVisitor::toString() {
421      result += buffer;
422  
423      return result;
424 < }
424 >  }
425   } //namespace oopse

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines