Changes in / [353e82:1cc87e]


Ignore:
Location:
src
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/AnalysisAction/PairCorrelationAction.cpp

    r353e82 r1cc87e  
    7575  ofstream output;
    7676  ofstream binoutput;
    77   std::vector<const element *> elements;
     77  std::vector< element *> elements;
    7878  string type;
    7979  Vector Point;
  • src/Actions/AnalysisAction/PointCorrelationAction.cpp

    r353e82 r1cc87e  
    7676  ofstream output;
    7777  ofstream binoutput;
    78   std::vector<const element *> elements;
     78  std::vector< element *> elements;
    7979  string type;
    8080  Vector Point;
     
    9696  cout << "Point to correlate to is  " << Point << endl;
    9797  CorrelationToPointMap *correlationmap = NULL;
    98   for(std::vector<const element *>::iterator iter = elements.begin(); iter != elements.end(); ++iter)
    99     cout << "element is " << (*iter)->getSymbol() << endl;
     98  for(std::vector< element *>::iterator iter = elements.begin(); iter != elements.end(); ++iter)
     99    cout << "element is " << (*iter)->symbol << endl;
    100100  std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
    101101  if (periodic)
  • src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp

    r353e82 r1cc87e  
    7979  ofstream output;
    8080  ofstream binoutput;
    81   std::vector<const element *> elements;
     81  std::vector< element *> elements;
    8282  string type;
    8383  Vector Point;
  • src/Actions/AtomAction/AddAction.cpp

    r353e82 r1cc87e  
    5252
    5353Action::state_ptr AtomAddAction::performCall() {
    54   const element * elemental = NULL;
     54  element * elemental = NULL;
    5555  Vector position;
    5656
     
    6363  first->setType(elemental);
    6464  first->setPosition(position);
    65   DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->getType()->getName() << " at " << (first->getPosition()) << "." << endl);
     65  DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->getType()->name << " at " << (first->getPosition()) << "." << endl);
    6666  // TODO: remove when all of World's atoms are stored.
    6767  std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
  • src/Actions/AtomAction/ChangeElementAction.cpp

    r353e82 r1cc87e  
    5151Action::state_ptr AtomChangeElementAction::performCall() {
    5252  atom *first = NULL;
    53   const element *elemental;
     53  element *elemental = NULL;
    5454  molecule *mol = NULL;
    5555
     
    5858  for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection(); iter != World::getInstance().endAtomSelection(); ++iter) {
    5959    first = iter->second;
    60     DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << *elemental << "." << endl);
     60    DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << elemental->symbol << "." << endl);
    6161    mol = first->getMolecule();
    6262    first->removeFromMolecule(); // remove atom
  • src/Actions/MapOfActions.cpp

    r353e82 r1cc87e  
    315315
    316316  // value types for the actions
    317   TypeMap["add-atom"] = &typeid(const element);
     317  TypeMap["add-atom"] = &typeid(element);
    318318  TypeMap["bond-file"] = &typeid(std::string);
    319319  TypeMap["bond-table"] = &typeid(std::string);
     
    321321  TypeMap["center-in-box"] = &typeid(BoxValue);
    322322  TypeMap["change-box"] = &typeid(BoxValue);
    323   TypeMap["change-element"] = &typeid(const element);
     323  TypeMap["change-element"] = &typeid(element);
    324324  TypeMap["change-molname"] = &typeid(std::string);
    325325  TypeMap["clear-atom-selection"] = &typeid(void);
     
    386386  TypeMap["distances"] = &typeid(VectorValue);
    387387  TypeMap["DoRotate"] = &typeid(bool);
    388   TypeMap["element"] = &typeid(const element);
    389   TypeMap["elements"] = &typeid(std::vector<const element *>);
     388  TypeMap["element"] = &typeid(element);
     389  TypeMap["elements"] = &typeid(std::vector<element *>);
    390390  TypeMap["end-step"] = &typeid(int);
    391391  TypeMap["id-mapping"] = &typeid(bool);
     
    416416  TypeEnumMap[&typeid(atom)] = Atom;
    417417  TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms;
    418   TypeEnumMap[&typeid(const element)] = Element;
    419   TypeEnumMap[&typeid(std::vector<const element *>)] = ListOfElements;
     418  TypeEnumMap[&typeid(element)] = Element;
     419  TypeEnumMap[&typeid(std::vector<element *>)] = ListOfElements;
    420420
    421421  // default values for any action that needs one (always string!)
     
    622622}
    623623
    624 void MapOfActions::queryCurrentValue(const char * name, const element * &_T)  {
     624void MapOfActions::queryCurrentValue(const char * name, class element * &_T)  {
    625625  int Z = -1;
    626   if (typeid(const element ) == *TypeMap[name]) {
     626  if (typeid( element ) == *TypeMap[name]) {
    627627    if (CurrentValue.find(name) == CurrentValue.end())
    628628      throw MissingValueException(__FILE__, __LINE__);
     
    706706}
    707707
    708 void MapOfActions::queryCurrentValue(const char * name, std::vector<const element *>&_T)
     708void MapOfActions::queryCurrentValue(const char * name, std::vector<element *>&_T)
    709709{
    710710  int Z = -1;
    711   const element *elemental = NULL;
    712   if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
     711  element *elemental = NULL;
     712  if (typeid( std::vector<element *> ) == *TypeMap[name]) {
    713713    if (CurrentValue.find(name) == CurrentValue.end())
    714714      throw MissingValueException(__FILE__, __LINE__);
     
    758758}
    759759
    760 void MapOfActions::setCurrentValue(const char * name, const element * &_T)
    761 {
    762   if (typeid(const element ) == *TypeMap[name]) {
     760void MapOfActions::setCurrentValue(const char * name, class element * &_T)
     761{
     762  if (typeid( element ) == *TypeMap[name]) {
    763763    std::ostringstream stream;
    764764    stream << _T->Z;
     
    818818}
    819819
    820 void MapOfActions::setCurrentValue(const char * name, std::vector<const element *>&_T)
    821 {
    822   if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
     820void MapOfActions::setCurrentValue(const char * name, std::vector<element *>&_T)
     821{
     822  if (typeid( std::vector<element *> ) == *TypeMap[name]) {
    823823    std::ostringstream stream;
    824     for (std::vector<const element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
     824    for (std::vector<element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
    825825      stream << (*iter)->Z << " ";
    826826    }
  • src/Actions/MapOfActions.hpp

    r353e82 r1cc87e  
    164164
    165165  void queryCurrentValue(const char * name, class atom * &_T);
    166   void queryCurrentValue(const char * name, const element * &_T);
     166  void queryCurrentValue(const char * name, class element * &_T);
    167167  void queryCurrentValue(const char * name, class molecule * &_T);
    168168  void queryCurrentValue(const char * name, class Box &_T);
    169169  void queryCurrentValue(const char * name, class Vector &_T);
    170170  void queryCurrentValue(const char * name, std::vector<atom *>&_T);
    171   void queryCurrentValue(const char * name, std::vector<const element *>&_T);
     171  void queryCurrentValue(const char * name, std::vector<element *>&_T);
    172172  void queryCurrentValue(const char * name, std::vector<molecule *>&_T);
    173173  template<typename T> void queryCurrentValue(const char * name, T &_T)
     
    198198
    199199  void setCurrentValue(const char * name, class atom * &_T);
    200   void setCurrentValue(const char * name, const element * &_T);
     200  void setCurrentValue(const char * name, class element * &_T);
    201201  void setCurrentValue(const char * name, class molecule * &_T);
    202202  void setCurrentValue(const char * name, class Box &_T);
    203203  void setCurrentValue(const char * name, class Vector &_T);
    204204  void setCurrentValue(const char * name, std::vector<atom *>&_T);
    205   void setCurrentValue(const char * name, std::vector<const element *>&_T);
     205  void setCurrentValue(const char * name, std::vector<element *>&_T);
    206206  void setCurrentValue(const char * name, std::vector<molecule *>&_T);
    207207  template<class T> void setCurrentValue(const char * name, T &_T)
  • src/Formula.cpp

    r353e82 r1cc87e  
    4747  for(const_iterator iter=end();iter!=begin();){
    4848    --iter;
    49     sstr << (*iter).first->getSymbol();
     49    sstr << (*iter).first->symbol;
    5050    if((*iter).second>1)
    5151      sstr << (*iter).second;
     
    146146
    147147bool Formula::hasElement(const string &shorthand) const{
    148   const element * element = World::getInstance().getPeriode()->FindElement(shorthand);
     148  element * element = World::getInstance().getPeriode()->FindElement(shorthand);
    149149  return hasElement(element);
    150150}
     
    167167
    168168void Formula::operator+=(const string &shorthand){
    169   const element * element = World::getInstance().getPeriode()->FindElement(shorthand);
     169  element * element = World::getInstance().getPeriode()->FindElement(shorthand);
    170170  operator+=(element);
    171171}
     
    198198
    199199void Formula::operator-=(const string &shorthand){
    200   const element * element = World::getInstance().getPeriode()->FindElement(shorthand);
     200  element * element = World::getInstance().getPeriode()->FindElement(shorthand);
    201201  operator-=(element);
    202202}
     
    220220
    221221void Formula::addElements(const string &shorthand,unsigned int count){
    222   const element * element = World::getInstance().getPeriode()->FindElement(shorthand);
     222  element * element = World::getInstance().getPeriode()->FindElement(shorthand);
    223223  addElements(element,count);
    224224}
     
    252252
    253253const unsigned int Formula::operator[](string shorthand) const{
    254   const element * element = World::getInstance().getPeriode()->FindElement(shorthand);
     254  element * element = World::getInstance().getPeriode()->FindElement(shorthand);
    255255  return operator[](element);
    256256}
     
    380380result_type
    381381Formula::_iterator<result_type>::operator*(){
    382   const element *element = World::getInstance().getPeriode()->FindElement(pos+1);
     382  element *element = World::getInstance().getPeriode()->FindElement(pos+1);
    383383  ASSERT(element,"Element with position of iterator not found");
    384384  return make_pair(element,(*set)[pos]);
     
    390390  // no one can keep this value around, so a static is ok to avoid temporaries
    391391  static value_type value=make_pair(reinterpret_cast<element*>(0),0); // no default constructor for std::pair
    392   const element *element = World::getInstance().getPeriode()->FindElement(pos+1);
     392  element *element = World::getInstance().getPeriode()->FindElement(pos+1);
    393393  ASSERT(element,"Element with position of iterator not found");
    394394  value = make_pair(element,(*set)[pos]);
  • src/Parser/PcpParser.cpp

    r353e82 r1cc87e  
    540540    const element * const elemental = World::getInstance().getPeriode()->FindElement(iter->first);
    541541    ZtoIndexMap.insert( pair<int,int> (iter->first, counter) );
    542     *file << "Ion_Type" << counter++ << "\t" << iter->second << "\t" << elemental->Z << "\t1.0\t3\t3\t" << fixed << setprecision(11) << showpoint << elemental->mass << "\t" << elemental->getName() << "\t" << elemental->getSymbol() <<endl;
     542    *file << "Ion_Type" << counter++ << "\t" << iter->second << "\t" << elemental->Z << "\t1.0\t3\t3\t" << fixed << setprecision(11) << showpoint << elemental->mass << "\t" << elemental->name << "\t" << elemental->symbol <<endl;
    543543  }
    544544}
  • src/Parser/XyzParser.cpp

    r353e82 r1cc87e  
    8686  vector<atom*> atoms = World::getInstance().getAllAtoms();
    8787  for(vector<atom*>::iterator it = atoms.begin(); it != atoms.end(); it++) {
    88     *file << noshowpoint << (*it)->getType()->getSymbol() << "\t" << (*it)->at(0) << "\t" << (*it)->at(1) << "\t" << (*it)->at(2) << endl;
     88    *file << noshowpoint << (*it)->getType()->symbol << "\t" << (*it)->at(0) << "\t" << (*it)->at(1) << "\t" << (*it)->at(2) << endl;
    8989  }
    9090}
  • src/UIElements/Dialog.hpp

    r353e82 r1cc87e  
    255255    virtual void setResult();
    256256  protected:
    257     const element * tmp;
     257    element * tmp;
    258258  };
    259259
     
    265265    virtual void setResult();
    266266  protected:
    267     const element *temp;
    268     std::vector<const element *> tmp;
     267    element *temp;
     268    std::vector<element *> tmp;
    269269  };
    270270
  • src/UIElements/QT4/QTDialog.cpp

    r353e82 r1cc87e  
    554554  {
    555555    stringstream sstr;
    556     sstr << (*iter).first << "\t" << (*iter).second->getName();
     556    sstr << (*iter).first << "\t" << (*iter).second->name;
    557557    inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first));
    558558  }
     
    589589  {
    590590    stringstream sstr;
    591     sstr << (*iter).first << "\t" << (*iter).second->getName();
     591    sstr << (*iter).first << "\t" << (*iter).second->name;
    592592    inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first));
    593593  }
     
    816816}
    817817
    818 ElementQTQueryPipe::ElementQTQueryPipe(const element **_content, QTDialog *_dialog, QComboBox *_theBox) :
     818ElementQTQueryPipe::ElementQTQueryPipe(element **_content, QTDialog *_dialog, QComboBox *_theBox) :
    819819  content(_content),
    820820  dialog(_dialog),
     
    832832}
    833833
    834 ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector<const element *>*_content, QTDialog *_dialog, QComboBox *_theBox) :
     834ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector<element *>*_content, QTDialog *_dialog, QComboBox *_theBox) :
    835835  content(_content),
    836836  dialog(_dialog),
     
    844844  QVariant data = theBox->itemData(newIndex);
    845845  int idx = data.toInt();
    846   const element *elemental = World::getInstance().getPeriode()->FindElement(idx);
     846  element *elemental = World::getInstance().getPeriode()->FindElement(idx);
    847847  if(elemental)
    848848    (*content).push_back(elemental);
  • src/UIElements/QT4/QTDialog.hpp

    r353e82 r1cc87e  
    451451  Q_OBJECT
    452452public:
    453   ElementQTQueryPipe(const element **_content, QTDialog *_dialog, QComboBox *_theBox);
     453  ElementQTQueryPipe(element **_content, QTDialog *_dialog, QComboBox *_theBox);
    454454  virtual ~ElementQTQueryPipe();
    455455
     
    458458
    459459private:
    460   const element **content;
     460  element **content;
    461461  QTDialog *dialog;
    462462  QComboBox *theBox;
     
    466466  Q_OBJECT
    467467public:
    468   ElementsQTQueryPipe(std::vector<const element *>*_content, QTDialog *_dialog, QComboBox *_theBox);
     468  ElementsQTQueryPipe(std::vector<element *>*_content, QTDialog *_dialog, QComboBox *_theBox);
    469469  virtual ~ElementsQTQueryPipe();
    470470
     
    473473
    474474private:
    475   std::vector<const element *>*content;
     475  std::vector<element *>*content;
    476476  QTDialog *dialog;
    477477  QComboBox *theBox;
  • src/UIElements/TextUI/TextDialog.cpp

    r353e82 r1cc87e  
    569569  bool badInput=false;
    570570  bool aborted = false;
    571   const element * temp = NULL;
     571  element * temp = NULL;
    572572  do{
    573573    badInput = false;
  • src/analysis_bonds.cpp

    r353e82 r1cc87e  
    215215          if (((OtherAtom->getType() == first) || (OtherAtom->getType() == second)) && (theAtom->nr < OtherAtom->nr)) {
    216216            count++;
    217             DoLog(1) && (Log() << Verbose(1) << *first << "-" << *second << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl);
     217            DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl);
    218218          }
    219219        }
     
    262262        if (result) { // check results
    263263          count++;
    264           DoLog(1) && (Log() << Verbose(1) << *first << "-" << *second << "-" << *third << " bond found at " << *Walker << "." << endl);
     264          DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << "-" << third->name << " bond found at " << *Walker << "." << endl);
    265265        }
    266266      }
  • src/analysis_correlation.cpp

    r353e82 r1cc87e  
    3333 * \return Map of doubles with values the pair of the two atoms.
    3434 */
    35 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements)
     35PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements)
    3636{
    3737  Info FunctionInfo(__func__);
     
    4848
    4949  // create all possible pairs of elements
    50   set <pair<const element *,const element *> > PairsOfElements;
     50  set <pair<element *, element *> > PairsOfElements;
    5151  if (elements.size() >= 2) {
    52     for (vector<const element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
    53       for (vector<const element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
     52    for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
     53      for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
    5454        if (type1 != type2) {
    55           PairsOfElements.insert( make_pair(*type1,*type2) );
    56           DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl);
     55          PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
     56          DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl);
    5757        }
    5858  } else if (elements.size() == 1) { // one to all are valid
    59     const element *elemental = *elements.begin();
    60     PairsOfElements.insert( pair<const element *,const element*>(elemental,0) );
    61     PairsOfElements.insert( pair<const element *,const element*>(0,elemental) );
     59    element *elemental = *elements.begin();
     60    PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) );
     61    PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) );
    6262  } else { // all elements valid
    6363    PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
     
    7474          DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
    7575          if ((*iter)->getId() < (*runner)->getId()){
    76             for (set <pair<const element *, const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
     76            for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
    7777              if ((PairRunner->first == (**iter).getType()) && (PairRunner->second == (**runner).getType())) {
    7878                distance = domain.periodicDistance((*iter)->getPosition(),(*runner)->getPosition());
     
    9595 * \return Map of doubles with values the pair of the two atoms.
    9696 */
    97 PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const int ranges[NDIM] )
     97PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const int ranges[NDIM] )
    9898{
    9999  Info FunctionInfo(__func__);
     
    115115
    116116  // create all possible pairs of elements
    117   set <pair<const element *,const element *> > PairsOfElements;
     117  set <pair<element *, element *> > PairsOfElements;
    118118  if (elements.size() >= 2) {
    119     for (vector<const element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
    120       for (vector<const element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
     119    for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
     120      for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
    121121        if (type1 != type2) {
    122           PairsOfElements.insert( make_pair(*type1,*type2) );
    123           DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl);
     122          PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
     123          DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl);
    124124        }
    125125  } else if (elements.size() == 1) { // one to all are valid
    126     const element *elemental = *elements.begin();
    127     PairsOfElements.insert( pair<const element *,const element*>(elemental,0) );
    128     PairsOfElements.insert( pair<const element *,const element*>(0,elemental) );
     126    element *elemental = *elements.begin();
     127    PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) );
     128    PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) );
    129129  } else { // all elements valid
    130130    PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
     
    149149                  DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
    150150                  if ((*iter)->getId() < (*runner)->getId()){
    151                     for (set <pair<const element *,const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
     151                    for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
    152152                      if ((PairRunner->first == (**iter).getType()) && (PairRunner->second == (**runner).getType())) {
    153153                        periodicOtherX = FullInverseMatrix * ((*runner)->getPosition()); // x now in [0,1)^3
     
    178178 * \return Map of dobules with values as pairs of atom and the vector
    179179 */
    180 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point )
     180CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point )
    181181{
    182182  Info FunctionInfo(__func__);
     
    196196    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    197197      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    198       for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     198      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    199199        if ((*type == NULL) || ((*iter)->getType() == *type)) {
    200200          distance = domain.periodicDistance((*iter)->getPosition(),*point);
     
    215215 * \return Map of dobules with values as pairs of atom and the vector
    216216 */
    217 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point, const int ranges[NDIM] )
     217CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] )
    218218{
    219219  Info FunctionInfo(__func__);
     
    237237    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    238238      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    239       for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     239      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    240240        if ((*type == NULL) || ((*iter)->getType() == *type)) {
    241241          periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3
     
    263263 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    264264 */
    265 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
     265CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
    266266{
    267267  Info FunctionInfo(__func__);
     
    284284    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    285285      DoLog(3) && (Log() << Verbose(3) << "\tCurrent atom is " << *(*iter) << "." << endl);
    286       for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     286      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    287287        if ((*type == NULL) || ((*iter)->getType() == *type)) {
    288288          TriangleIntersectionList Intersections((*iter)->getPosition(),Surface,LC);
     
    309309 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    310310 */
    311 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
     311CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
    312312{
    313313  Info FunctionInfo(__func__);
     
    335335    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    336336      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    337       for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     337      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    338338        if ((*type == NULL) || ((*iter)->getType() == *type)) {
    339339          periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3
  • src/analysis_correlation.hpp

    r353e82 r1cc87e  
    4646/********************************************** declarations *******************************/
    4747
    48 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements);
    49 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point );
    50 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );
    51 PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const int ranges[NDIM] );
    52 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point, const int ranges[NDIM] );
    53 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
     48PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements);
     49CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point );
     50CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );
     51PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const int ranges[NDIM] );
     52CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] );
     53CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
    5454int GetBin ( const double value, const double BinWidth, const double BinStart );
    5555void OutputCorrelation( ofstream * const file, const BinPairMap * const map );
  • src/atom.cpp

    r353e82 r1cc87e  
    194194{
    195195  if (out != NULL) {
    196     *out << getType()->getSymbol() << "\t" << at(0) << "\t" << at(1) << "\t" << at(2) << "\t" << endl;
     196    *out << getType()->symbol << "\t" << at(0) << "\t" << at(1) << "\t" << at(2) << "\t" << endl;
    197197    return true;
    198198  } else
     
    232232{
    233233  if (out != NULL) {
    234     *out << getType()->getSymbol() << "\t";
     234    *out << getType()->symbol << "\t";
    235235    *out << Trajectory.R.at(step)[0] << "\t";
    236236    *out << Trajectory.R.at(step)[1] << "\t";
     
    250250  Vector recentered(getPosition());
    251251  recentered -= *center;
    252   *out << "\t\t" << getType()->getSymbol() << " [ " << recentered[0] << "\t" << recentered[1] << "\t" << recentered[2] << " ]" << endl;
     252  *out << "\t\t" << getType()->symbol << " [ " << recentered[0] << "\t" << recentered[1] << "\t" << recentered[2] << " ]" << endl;
    253253  if (AtomNo != NULL)
    254254    *AtomNo++;
  • src/config.cpp

    r353e82 r1cc87e  
    13391339    AtomNo = 0;
    13401340    for (molecule::const_iterator iter = (*MolRunner)->begin(); iter != (*MolRunner)->end(); ++iter) {
    1341       sprintf(name, "%2s%2d",(*iter)->getType()->getSymbol().c_str(), elementNo[(*iter)->getType()->Z]);
     1341      sprintf(name, "%2s%2d",(*iter)->getType()->symbol, elementNo[(*iter)->getType()->Z]);
    13421342      elementNo[(*iter)->getType()->Z] = (elementNo[(*iter)->getType()->Z]+1) % 100;   // confine to two digits
    13431343      fprintf(f,
     
    13541354             (double)(*iter)->getType()->NoValenceOrbitals,          /* temperature factor */
    13551355             "0",            /* segment identifier */
    1356              (*iter)->getType()->getSymbol().c_str(),    /* element symbol */
     1356             (*iter)->getType()->symbol,    /* element symbol */
    13571357             "0");           /* charge */
    13581358      AtomNo++;
     
    13921392  AtomNo = 0;
    13931393  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    1394     sprintf(name, "%2s%2d",(*iter)->getType()->getSymbol().c_str(), elementNo[(*iter)->getType()->Z]);
     1394    sprintf(name, "%2s%2d",(*iter)->getType()->symbol, elementNo[(*iter)->getType()->Z]);
    13951395    elementNo[(*iter)->getType()->Z] = (elementNo[(*iter)->getType()->Z]+1) % 100;   // confine to two digits
    13961396    fprintf(f,
     
    14071407           (double)(*iter)->getType()->NoValenceOrbitals,          /* temperature factor */
    14081408           "0",            /* segment identifier */
    1409            (*iter)->getType()->getSymbol().c_str(),    /* element symbol */
     1409           (*iter)->getType()->symbol,    /* element symbol */
    14101410           "0");           /* charge */
    14111411    AtomNo++;
     
    14521452    *output << (*iter)->at(0) << "\t" << (*iter)->at(1) << "\t" << (*iter)->at(2) << "\t";
    14531453    *output << static_cast<double>((*iter)->getType()->Valence) << "\t";
    1454     *output << (*iter)->getType()->getSymbol() << "\t";
     1454    *output << (*iter)->getType()->symbol << "\t";
    14551455    for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
    14561456      *output << (*runner)->GetOtherAtom(*iter)->nr << "\t";
     
    15241524        *output << (*iter)->at(0) << "\t" << (*iter)->at(1) << "\t" << (*iter)->at(2) << "\t";
    15251525        *output << (double)(*iter)->getType()->Valence << "\t";
    1526         *output << (*iter)->getType()->getSymbol() << "\t";
     1526        *output << (*iter)->getType()->symbol << "\t";
    15271527        for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
    15281528          *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom((*iter))->getId() ] << "\t";
  • src/element.cpp

    r353e82 r1cc87e  
    2323  VanDerWaalsRadius(0),
    2424        Z(-1),
     25        previous(NULL),
     26        next(NULL),
     27        sort(NULL),
    2528        Valence(0),
    2629        NoValenceOrbitals(0)
     
    2831};
    2932
    30 element::element(const element &src) :
    31   mass(src.mass),
    32   CovalentRadius(src.CovalentRadius),
    33   VanDerWaalsRadius(src.VanDerWaalsRadius),
    34   Z(src.Z),
    35   Valence(src.Valence),
    36   NoValenceOrbitals(src.NoValenceOrbitals),
    37   name(src.name),
    38   symbol(src.symbol)
    39 {
    40   strncpy(period,src.period,strfield_length+1);
    41   strncpy(group,src.group,strfield_length+1);
    42   strncpy(block,src.block,strfield_length+1);
    43 }
    44 
    4533/** Destructor of class element.
    4634 */
    4735element::~element() {};
    48 
    49 element &element::operator=(const element &src){
    50   if(this!=&src){
    51     mass=src.mass;
    52     CovalentRadius=src.CovalentRadius;
    53     VanDerWaalsRadius=src.VanDerWaalsRadius;
    54     Z=src.Z;
    55     Valence=src.Valence;
    56     NoValenceOrbitals=src.NoValenceOrbitals;
    57     name=src.name;
    58     symbol=src.symbol;
    59     strncpy(period,src.period,strfield_length+1);
    60     strncpy(group,src.group,strfield_length+1);
    61     strncpy(block,src.block,strfield_length+1);
    62   }
    63   return *this;
    64 }
    6536
    6637/** Prints element data to \a *out.
     
    9566}
    9667
    97 string &element::getSymbol(){
    98   return symbol;
     68string element::getSymbol() const{
     69  return string(symbol);
    9970}
    10071
    101 const string &element::getSymbol() const{
    102   return symbol;
    103 }
    104 
    105 std::string &element::getName(){
    106   return name;
    107 }
    108 
    109 const std::string &element::getName() const{
    110   return name;
     72std::string element::getName() const{
     73  return string(name);
    11174}
    11275
  • src/element.hpp

    r353e82 r1cc87e  
    2828 */
    2929class element {
    30   enum {strfield_length=7};
    3130  public:
    3231    double mass;    //!< mass in g/mol
     
    3433    double VanDerWaalsRadius;  //!< can-der-Waals radius
    3534    int Z;          //!< atomic number
    36     char period[strfield_length+1];    //!< period: n quantum number
    37     char group[strfield_length+1];    //!< group: l quantum number
    38     char block[strfield_length+1];    //!< block: l quantum number
     35    char name[64];  //!< atom name, i.e. "Hydrogren"
     36    char symbol[3]; //!< short form of the atom, i.e. "H"
     37    char period[8];    //!< period: n quantum number
     38    char group[8];    //!< group: l quantum number
     39    char block[8];    //!< block: l quantum number
     40    element *previous;  //!< previous item in list
     41    element *next;  //!< next element in list
     42    int *sort;      //!< sorc criteria
    3943    double Valence;   //!< number of valence electrons for this element
    4044    int NoValenceOrbitals;  //!< number of valence orbitals, used for determining bond degree in molecule::CreateConnectmatrix()
     
    4246    double HBondAngle[NDIM];     //!< typical angle for one, two, three bonded hydrogen (in degrees)
    4347
    44     element();
    45     element(const element&);
    46     ~element();
     48  element();
     49  ~element();
    4750
    48     element &operator=(const element&);
     51  // accessor functions
     52  atomicNumber_t getNumber() const;
     53  std::string getSymbol() const;
     54  std::string getName() const;
    4955
    50     // accessor functions
    51     atomicNumber_t getNumber() const;
    52     std::string &getSymbol();
    53     const std::string &getSymbol() const;
    54     std::string &getName();
    55     const std::string &getName() const;
    56 
    57     //> print element entries to screen
    58     bool Output(std::ostream * const out) const;
    59     bool Checkout(std::ostream * const out, const int No, const int NoOfAtoms) const;
     56  //> print element entries to screen
     57  bool Output(std::ostream * const out) const;
     58  bool Checkout(std::ostream * const out, const int No, const int NoOfAtoms) const;
    6059
    6160  private:
    62     std::string name;  //!< atom name, i.e. "Hydrogren"
    63     std::string symbol; //!< short form of the atom, i.e. "H"
    6461};
    6562
  • src/molecule.cpp

    r353e82 r1cc87e  
    218218      if(pointer->getName() == "Unknown"){
    219219        stringstream sstr;
    220         sstr << pointer->getType()->getSymbol() << pointer->nr+1;
     220        sstr << pointer->getType()->symbol << pointer->nr+1;
    221221        pointer->setName(sstr.str());
    222222      }
     
    972972      NoNonHydrogen++;
    973973    stringstream sstr;
    974     sstr << (*iter)->getType()->getSymbol() << (*iter)->nr+1;
     974    sstr << (*iter)->getType()->symbol << (*iter)->nr+1;
    975975    (*iter)->setName(sstr.str());
    976976    DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl);
     
    978978  }
    979979  return res;
     980};
     981
     982/** Determines whether two molecules actually contain the same atoms and coordination.
     983 * \param *out output stream for debugging
     984 * \param *OtherMolecule the molecule to compare this one to
     985 * \param threshold upper limit of difference when comparing the coordination.
     986 * \return NULL - not equal, otherwise an allocated (molecule::AtomCount) permutation map of the atom numbers (which corresponds to which)
     987 */
     988int * molecule::IsEqualToWithinThreshold(molecule *OtherMolecule, double threshold)
     989{
     990  int flag;
     991  double *Distances = NULL, *OtherDistances = NULL;
     992  Vector CenterOfGravity, OtherCenterOfGravity;
     993  size_t *PermMap = NULL, *OtherPermMap = NULL;
     994  int *PermutationMap = NULL;
     995  bool result = true; // status of comparison
     996
     997  DoLog(3) && (Log() << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl);
     998  /// first count both their atoms and elements and update lists thereby ...
     999  //Log() << Verbose(0) << "Counting atoms, updating list" << endl;
     1000
     1001  /// ... and compare:
     1002  /// -# AtomCount
     1003  if (result) {
     1004    if (getAtomCount() != OtherMolecule->getAtomCount()) {
     1005      DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl);
     1006      result = false;
     1007    } else Log() << Verbose(4) << "AtomCounts match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl;
     1008  }
     1009  /// -# Formula
     1010  if (result) {
     1011    if (formula != OtherMolecule->formula) {
     1012      DoLog(4) && (Log() << Verbose(4) << "Formulas don't match: " << formula << " == " << OtherMolecule->formula << endl);
     1013      result = false;
     1014    } else Log() << Verbose(4) << "Formulas match: " << formula << " == " << OtherMolecule->formula << endl;
     1015  }
     1016  /// then determine and compare center of gravity for each molecule ...
     1017  if (result) {
     1018    DoLog(5) && (Log() << Verbose(5) << "Calculating Centers of Gravity" << endl);
     1019    DeterminePeriodicCenter(CenterOfGravity);
     1020    OtherMolecule->DeterminePeriodicCenter(OtherCenterOfGravity);
     1021    DoLog(5) && (Log() << Verbose(5) << "Center of Gravity: " << CenterOfGravity << endl);
     1022    DoLog(5) && (Log() << Verbose(5) << "Other Center of Gravity: " << OtherCenterOfGravity << endl);
     1023    if (CenterOfGravity.DistanceSquared(OtherCenterOfGravity) > threshold*threshold) {
     1024      DoLog(4) && (Log() << Verbose(4) << "Centers of gravity don't match." << endl);
     1025      result = false;
     1026    }
     1027  }
     1028
     1029  /// ... then make a list with the euclidian distance to this center for each atom of both molecules
     1030  if (result) {
     1031    DoLog(5) && (Log() << Verbose(5) << "Calculating distances" << endl);
     1032    Distances = new double[getAtomCount()];
     1033    OtherDistances = new double[getAtomCount()];
     1034    SetIndexedArrayForEachAtomTo ( Distances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity);
     1035    SetIndexedArrayForEachAtomTo ( OtherDistances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity);
     1036    for(int i=0;i<getAtomCount();i++) {
     1037      Distances[i] = 0.;
     1038      OtherDistances[i] = 0.;
     1039    }
     1040
     1041    /// ... sort each list (using heapsort (o(N log N)) from GSL)
     1042    DoLog(5) && (Log() << Verbose(5) << "Sorting distances" << endl);
     1043    PermMap = new size_t[getAtomCount()];
     1044    OtherPermMap = new size_t[getAtomCount()];
     1045    for(int i=0;i<getAtomCount();i++) {
     1046      PermMap[i] = 0;
     1047      OtherPermMap[i] = 0;
     1048    }
     1049    gsl_heapsort_index (PermMap, Distances, getAtomCount(), sizeof(double), CompareDoubles);
     1050    gsl_heapsort_index (OtherPermMap, OtherDistances, getAtomCount(), sizeof(double), CompareDoubles);
     1051    PermutationMap = new int[getAtomCount()];
     1052    for(int i=0;i<getAtomCount();i++)
     1053      PermutationMap[i] = 0;
     1054    DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl);
     1055    for(int i=getAtomCount();i--;)
     1056      PermutationMap[PermMap[i]] = (int) OtherPermMap[i];
     1057
     1058    /// ... and compare them step by step, whether the difference is individually(!) below \a threshold for all
     1059    DoLog(4) && (Log() << Verbose(4) << "Comparing distances" << endl);
     1060    flag = 0;
     1061    for (int i=0;i<getAtomCount();i++) {
     1062      DoLog(5) && (Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " <<  threshold << endl);
     1063      if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold)
     1064        flag = 1;
     1065    }
     1066
     1067    // free memory
     1068    delete[](PermMap);
     1069    delete[](OtherPermMap);
     1070    delete[](Distances);
     1071    delete[](OtherDistances);
     1072    if (flag) { // if not equal
     1073      delete[](PermutationMap);
     1074      result = false;
     1075    }
     1076  }
     1077  /// return pointer to map if all distances were below \a threshold
     1078  DoLog(3) && (Log() << Verbose(3) << "End of IsEqualToWithinThreshold." << endl);
     1079  if (result) {
     1080    DoLog(3) && (Log() << Verbose(3) << "Result: Equal." << endl);
     1081    return PermutationMap;
     1082  } else {
     1083    DoLog(3) && (Log() << Verbose(3) << "Result: Not equal." << endl);
     1084    return NULL;
     1085  }
    9801086};
    9811087
  • src/molecule.hpp

    r353e82 r1cc87e  
    324324
    325325  // Recognize doubly appearing molecules in a list of them
     326  int * IsEqualToWithinThreshold(molecule *OtherMolecule, double threshold);
    326327  int * GetFatherSonAtomicMap(molecule *OtherMolecule);
    327328
  • src/periodentafel.cpp

    r353e82 r1cc87e  
    3434  {
    3535    stringstream input(elementsDB,ios_base::in);
    36     bool status = LoadElementsDatabase(input);
     36    bool status = LoadElementsDatabase(&input);
    3737    ASSERT(status,  "General element initialization failed");
    3838  }
     
    7272 * \return iterator to added element
    7373 */
    74 periodentafel::iterator periodentafel::AddElement(element * pointer)
     74periodentafel::iterator periodentafel::AddElement(element * const pointer)
    7575{
    7676  atomicNumber_t Z = pointer->getNumber();
    7777  ASSERT(!elements.count(Z), "Element is already present.");
     78  pointer->sort = &pointer->Z;
    7879  if (pointer->getNumber() < 1 && pointer->getNumber() >= MAX_ELEMENTS)
    7980    DoeLog(0) && (eLog() << Verbose(0) << "Invalid Z number!\n");
     
    8586 * \param *pointer element to be removed
    8687 */
    87 size_t periodentafel::RemoveElement(const element * pointer)
     88size_t periodentafel::RemoveElement(element * const pointer)
    8889{
    8990  return RemoveElement(pointer->getNumber());
     
    113114 * \return pointer to element or NULL if not found
    114115 */
    115 const element * periodentafel::FindElement(atomicNumber_t Z) const
     116element * const periodentafel::FindElement(atomicNumber_t Z) const
    116117{
    117118  const_iterator res = elements.find(Z);
     
    124125 * \return pointer to element
    125126 */
    126 const element * periodentafel::FindElement(const string &shorthand) const
     127element * const periodentafel::FindElement(const string &shorthand) const
    127128{
    128129  element *res = 0;
     
    139140 * \return desired element or NULL
    140141 */
    141 const element * periodentafel::AskElement() const
    142 {
    143   const element * walker = NULL;
     142element * const periodentafel::AskElement() const
     143{
     144  element * walker = NULL;
    144145  int Z;
    145146  do {
     
    154155 * \return pointer to either present or newly created element
    155156 */
    156 const element * periodentafel::EnterElement()
     157element * const periodentafel::EnterElement()
    157158{
    158159  atomicNumber_t Z = 0;
    159160  DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl);
    160161  cin >> Z;
    161   const element *res = FindElement(Z);
     162  element * const res = FindElement(Z);
    162163  if (!res) {
    163164    // TODO: make this using the constructor
     
    168169    cin >> tmp->mass;
    169170    DoLog(0) && (Log() << Verbose(0) << "Name [max 64 chars]: " << endl);
    170     cin >> tmp->getName();
     171    cin >> tmp->name;
    171172    DoLog(0) && (Log() << Verbose(0) << "Short form [max 3 chars]: " << endl);
    172     cin >> tmp->getSymbol();
     173    cin >> tmp->symbol;
    173174    AddElement(tmp);
    174175    return tmp;
     
    179180
    180181/******************** Access to iterators ****************************/
    181 periodentafel::const_iterator periodentafel::begin() const{
     182periodentafel::const_iterator periodentafel::begin(){
    182183  return elements.begin();
    183184}
    184185
    185 periodentafel::const_iterator periodentafel::end() const{
     186periodentafel::const_iterator periodentafel::end(){
    186187  return elements.end();
    187188}
    188189
    189 periodentafel::reverse_iterator periodentafel::rbegin() const{
     190periodentafel::reverse_iterator periodentafel::rbegin(){
    190191  return reverse_iterator(elements.end());
    191192}
    192193
    193 periodentafel::reverse_iterator periodentafel::rend() const{
     194periodentafel::reverse_iterator periodentafel::rend(){
    194195  return reverse_iterator(elements.begin());
    195196}
     
    227228  if (!input.fail())
    228229    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as elements database." << endl);
    229   status = status && LoadElementsDatabase(input);
     230  status = status && LoadElementsDatabase(&input);
    230231  input.close();
    231232  input.clear();
     
    286287 * \return true - parsing successful, false - something went wrong
    287288 */
    288 bool periodentafel::LoadElementsDatabase(istream &input)
     289bool periodentafel::LoadElementsDatabase(istream *input)
    289290{
    290291  bool status = true;
    291   string header1tmp,header2tmp;
    292   // first parse into a map, so we can revert to old status in case something goes wront
    293   map<atomicNumber_t,element*> parsedElements;
    294   if (!input.fail()) {
    295     getline(input,header1tmp);
    296     getline(input,header2tmp); // skip first two header lines
    297     cout << "First header: " << header1tmp << endl;
    298     cout << "Second header: " << header2tmp << endl;
     292  int counter = 0;
     293  pair< std::map<atomicNumber_t,element*>::iterator, bool > InserterTest;
     294  if (!(*input).fail()) {
     295    (*input).getline(header1, MAXSTRINGSIZE);
     296    (*input).getline(header2, MAXSTRINGSIZE); // skip first two header lines
    299297    DoLog(0) && (Log() << Verbose(0) <<  "Parsed elements:");
    300     while (!input.eof()) {
     298    while (!(*input).eof()) {
    301299      element *neues = new element;
    302       input >> neues->getName();;
    303       //(*input) >> ws;
    304       input >> neues->getSymbol();
    305       //(*input) >> ws;
    306       input >> neues->period;
    307       //(*input) >> ws;
    308       input >> neues->group;
    309       //(*input) >> ws;
    310       input >> neues->block;
    311       //(*input) >> ws;
    312       input >> neues->Z;
    313       //(*input) >> ws;
    314       input >> neues->mass;
    315       //(*input) >> ws;
    316       input >> neues->CovalentRadius;
    317       //(*input) >> ws;
    318       input >> neues->VanDerWaalsRadius;
    319       //(*input) >> ws;
    320       input >> ws;
     300      (*input) >> neues->name;
     301      //(*input) >> ws;
     302      (*input) >> neues->symbol;
     303      //(*input) >> ws;
     304      (*input) >> neues->period;
     305      //(*input) >> ws;
     306      (*input) >> neues->group;
     307      //(*input) >> ws;
     308      (*input) >> neues->block;
     309      //(*input) >> ws;
     310      (*input) >> neues->Z;
     311      //(*input) >> ws;
     312      (*input) >> neues->mass;
     313      //(*input) >> ws;
     314      (*input) >> neues->CovalentRadius;
     315      //(*input) >> ws;
     316      (*input) >> neues->VanDerWaalsRadius;
     317      //(*input) >> ws;
     318      (*input) >> ws;
    321319      //neues->Output((ofstream *)&cout);
    322320      if ((neues->getNumber() > 0) && (neues->getNumber() < MAX_ELEMENTS)) {
    323         parsedElements[neues->Z] = neues;
    324         DoLog(0) && (Log() << Verbose(0) << " " << *neues);
     321        if (elements.count(neues->getNumber())) {// if element already present, remove and delete old one (i.e. replace it)
     322          //cout << neues->symbol << " is present already." << endl;
     323          element * const Elemental = FindElement(neues->getNumber());
     324          ASSERT(Elemental != NULL, "element should be present but is not??");
     325          *Elemental = *neues;
     326          delete(neues);
     327          neues = Elemental;
     328        } else {
     329          InserterTest = elements.insert(pair <atomicNumber_t,element*> (neues->getNumber(), neues));
     330          ASSERT(InserterTest.second, "Could not insert new element into periodentafel on LoadElementsDatabase().");
     331        }
     332        DoLog(0) && (Log() << Verbose(0) << " " << elements[neues->getNumber()]->symbol);
     333        counter++;
    325334      } else {
    326335        DoeLog(2) && (eLog() << Verbose(2) << "Detected empty line or invalid element in elements db, discarding." << endl);
     
    328337        delete(neues);
    329338      }
    330       // when the input is in failed state, we most likely just read garbage
    331       if(input.fail()) {
    332         DoeLog(2) && (eLog() << Verbose(2) << "Error parsing elements db." << endl);
    333         status = false;
    334         break;
    335       }
    336339    }
    337340    DoLog(0) && (Log() << Verbose(0) << endl);
     
    341344  }
    342345
    343   if (!parsedElements.size())
     346  if (counter == 0)
    344347    status = false;
    345 
    346   if(status){
    347     for(map<atomicNumber_t,element*>::iterator iter=parsedElements.begin();
    348                                                iter!=parsedElements.end();
    349                                                ++iter){
    350       if (elements.count(iter->first)) {
    351         // if element already present, replace the old one
    352         // pointer to old element might still be in use, so we have to replace into the old element
    353         *(elements[iter->first])=*iter->second;
    354       }
    355       else {
    356         // no such element in periodentafel... we can just insert
    357         elements[iter->first] = iter->second;
    358       }
    359     }
    360     // all went well.. we now copy the header
    361     strncpy(header1,header1tmp.c_str(),MAXSTRINGSIZE);
    362     header1[MAXSTRINGSIZE-1]=0;
    363     strncpy(header2,header2tmp.c_str(),MAXSTRINGSIZE);
    364     header2[MAXSTRINGSIZE-1]=0;
    365   }
    366348
    367349  return status;
  • src/periodentafel.hpp

    r353e82 r1cc87e  
    4343  ~periodentafel();
    4444
    45   iterator AddElement(element * pointer);
    46   size_t RemoveElement(const element * pointer);
     45  iterator AddElement(element * const pointer);
     46  size_t RemoveElement(element * const pointer);
    4747  size_t RemoveElement(atomicNumber_t);
    4848  void CleanupPeriodtable();
    49   const element * FindElement(atomicNumber_t) const;
    50   const element * FindElement(const std::string &shorthand) const;
    51   const element * AskElement() const;
    52   const element * EnterElement();
     49  element * const FindElement(atomicNumber_t) const;
     50  element * const FindElement(const std::string &shorthand) const;
     51  element * const AskElement() const;
     52  element * const EnterElement();
    5353
    54   const_iterator begin() const;
    55   const_iterator end() const;
    56   reverse_iterator rbegin() const;
    57   reverse_iterator rend() const;
     54  const_iterator begin();
     55  const_iterator end();
     56  reverse_iterator rbegin();
     57  reverse_iterator rend();
    5858  bool Output(std::ostream * const output) const;
    5959  bool LoadPeriodentafel(const char * const path);
     
    6262  private:
    6363
    64   bool LoadElementsDatabase(std::istream &input);
     64  bool LoadElementsDatabase(std::istream *input);
    6565  bool LoadValenceDatabase(std::istream *input);
    6666  bool LoadOrbitalsDatabase(std::istream *input);
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    r353e82 r1cc87e  
    4646
    4747  // construct element list
    48   std::vector<const element *> elements;
     48  std::vector<element *> elements;
    4949  hydrogen = World::getInstance().getPeriode()->FindElement(1);
    5050  CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
  • src/unittests/AnalysisCorrelationToPointUnitTest.hpp

    r353e82 r1cc87e  
    3737      std::vector<molecule *> allMolecules;
    3838      molecule *TestMolecule;
    39       const element *hydrogen;
     39      element *hydrogen;
    4040
    4141      CorrelationToPointMap *pointmap;
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp

    r353e82 r1cc87e  
    4545      std::vector<molecule *> allMolecules;
    4646      molecule *TestSurfaceMolecule;
    47       const element *hydrogen;
    48       const element *carbon;
    49       std::vector<const element *> elements;
     47      element *hydrogen;
     48      element *carbon;
     49      std::vector<element *> elements;
    5050
    5151      CorrelationToSurfaceMap *surfacemap;
  • src/unittests/AnalysisPairCorrelationUnitTest.cpp

    r353e82 r1cc87e  
    4949
    5050  // construct element list
    51   std::vector<const element *> elements;
     51  std::vector<element *> elements;
    5252  hydrogen = World::getInstance().getPeriode()->FindElement(1);
    5353  CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
  • src/unittests/AnalysisPairCorrelationUnitTest.hpp

    r353e82 r1cc87e  
    3737      std::vector<molecule *> allMolecules;
    3838      molecule *TestMolecule;
    39       const element *hydrogen;
     39      element *hydrogen;
    4040
    4141      PairCorrelationMap *correlationmap;
  • src/unittests/periodentafelTest.cpp

    r353e82 r1cc87e  
    1111#include <cppunit/extensions/TestFactoryRegistry.h>
    1212#include <cppunit/ui/text/TestRunner.h>
    13 
    14 #include <sstream>
    15 #include <iostream>
    1613
    1714#include "Helpers/Assert.hpp"
     
    7067{
    7168  // reload all databases
    72   stringstream elementsDBstream(elementsDB,ios_base::in);
    73   CPPUNIT_ASSERT(tafel->LoadElementsDatabase(elementsDBstream) && "General element initialization failed");
     69  CPPUNIT_ASSERT(tafel->LoadElementsDatabase(new stringstream(elementsDB,ios_base::in)) && "General element initialization failed");
    7470  CPPUNIT_ASSERT(tafel->LoadValenceDatabase(new stringstream(valenceDB,ios_base::in)) && "Valence entry of element initialization failed");
    7571  CPPUNIT_ASSERT(tafel->LoadOrbitalsDatabase(new stringstream(orbitalsDB,ios_base::in)) && "Orbitals entry of element initialization failed");
  • src/unittests/periodentafelTest.hpp

    r353e82 r1cc87e  
    3131private:
    3232
    33       const element *hydrogen;
    34       const element *carbon;
     33      element *hydrogen;
     34      element *carbon;
    3535      periodentafel *tafel;
    3636
Note: See TracChangeset for help on using the changeset viewer.