Changes in / [e588312:311d688]


Ignore:
Location:
src
Files:
32 edited

Legend:

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

    re588312 r311d688  
    7676  ofstream output;
    7777  ofstream binoutput;
    78   std::vector<const element *> elements;
     78  std::vector< element *> elements;
    7979  string type;
    8080  Vector Point;
  • src/Actions/AnalysisAction/PointCorrelationAction.cpp

    re588312 r311d688  
    7777  ofstream output;
    7878  ofstream binoutput;
    79   std::vector<const element *> elements;
     79  std::vector< element *> elements;
    8080  string type;
    8181  Vector Point;
     
    9797  cout << "Point to correlate to is  " << Point << endl;
    9898  CorrelationToPointMap *correlationmap = NULL;
    99   for(std::vector<const element *>::iterator iter = elements.begin(); iter != elements.end(); ++iter)
    100     cout << "element is " << (*iter)->getSymbol() << endl;
     99  for(std::vector< element *>::iterator iter = elements.begin(); iter != elements.end(); ++iter)
     100    cout << "element is " << (*iter)->symbol << endl;
    101101  std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
    102102  if (periodic)
  • src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp

    re588312 r311d688  
    7878  ofstream output;
    7979  ofstream binoutput;
    80   std::vector<const element *> elements;
     80  std::vector< element *> elements;
    8181  string type;
    8282  Vector Point;
  • src/Actions/AtomAction/AddAction.cpp

    re588312 r311d688  
    5252
    5353Action::state_ptr AtomAddAction::performCall() {
    54   const element * elemental = NULL;
     54  element * elemental = NULL;
    5555  Vector position;
    5656
     
    6363  first->type = elemental;
    6464  first->x = position;
    65   DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << *first->type << " at " << (first->x) << "." << endl);
     65  DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->type->name << " at " << (first->x) << "." << 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

    re588312 r311d688  
    5050Action::state_ptr AtomChangeElementAction::performCall() {
    5151  atom *first = NULL;
    52   const element *elemental = NULL;
     52  element *elemental = NULL;
    5353
    5454  ValueStorage::getInstance().queryCurrentValue(NAME, elemental);
     
    5656  for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection(); iter != World::getInstance().endAtomSelection(); ++iter) {
    5757    first = iter->second;
    58     DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << *elemental << "." << endl);
     58    DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << elemental->symbol << "." << endl);
    5959    first->type = elemental;
    6060  }
  • src/Actions/MapOfActions.cpp

    re588312 r311d688  
    292292
    293293  // value types for the actions
    294   TypeMap["add-atom"] = &typeid(const element);
     294  TypeMap["add-atom"] = &typeid(element);
    295295  TypeMap["bond-file"] = &typeid(std::string);
    296296  TypeMap["bond-table"] = &typeid(std::string);
     
    298298  TypeMap["center-in-box"] = &typeid(BoxValue);
    299299  TypeMap["change-box"] = &typeid(BoxValue);
    300   TypeMap["change-element"] = &typeid(const element);
     300  TypeMap["change-element"] = &typeid(element);
    301301  TypeMap["change-molname"] = &typeid(std::string);
    302302  TypeMap["convex-envelope"] = &typeid(void);
     
    342342  TypeMap["distances"] = &typeid(VectorValue);
    343343  TypeMap["DoRotate"] = &typeid(bool);
    344   TypeMap["element"] = &typeid(const element);
    345   TypeMap["elements"] = &typeid(std::vector<const element *>);
     344  TypeMap["element"] = &typeid(element);
     345  TypeMap["elements"] = &typeid(std::vector<element *>);
    346346  TypeMap["end-step"] = &typeid(int);
    347347  TypeMap["id-mapping"] = &typeid(bool);
     
    380380  TypeEnumMap[&typeid(atom)] = Atom;
    381381  TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms;
    382   TypeEnumMap[&typeid(const element)] = Element;
    383   TypeEnumMap[&typeid(std::vector<const element *>)] = ListOfElements;
     382  TypeEnumMap[&typeid(element)] = Element;
     383  TypeEnumMap[&typeid(std::vector<element *>)] = ListOfElements;
    384384
    385385  // default values for any action that needs one (always string!)
     
    558558}
    559559
    560 void MapOfActions::queryCurrentValue(const char * name, const element * &_T)  {
     560void MapOfActions::queryCurrentValue(const char * name, class element * &_T)  {
    561561  int Z = -1;
    562   if (typeid(const element ) == *TypeMap[name]) {
     562  if (typeid( element ) == *TypeMap[name]) {
    563563    if (CurrentValue.find(name) == CurrentValue.end())
    564564      throw MissingValueException(__FILE__, __LINE__);
     
    642642}
    643643
    644 void MapOfActions::queryCurrentValue(const char * name, std::vector<const element *>&_T)
     644void MapOfActions::queryCurrentValue(const char * name, std::vector<element *>&_T)
    645645{
    646646  int Z = -1;
    647   const element *elemental = NULL;
    648   if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
     647  element *elemental = NULL;
     648  if (typeid( std::vector<element *> ) == *TypeMap[name]) {
    649649    if (CurrentValue.find(name) == CurrentValue.end())
    650650      throw MissingValueException(__FILE__, __LINE__);
     
    694694}
    695695
    696 void MapOfActions::setCurrentValue(const char * name, const element * &_T)
    697 {
    698   if (typeid(const element ) == *TypeMap[name]) {
     696void MapOfActions::setCurrentValue(const char * name, class element * &_T)
     697{
     698  if (typeid( element ) == *TypeMap[name]) {
    699699    std::ostringstream stream;
    700700    stream << _T->Z;
     
    754754}
    755755
    756 void MapOfActions::setCurrentValue(const char * name, std::vector<const element *>&_T)
    757 {
    758   if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
     756void MapOfActions::setCurrentValue(const char * name, std::vector<element *>&_T)
     757{
     758  if (typeid( std::vector<element *> ) == *TypeMap[name]) {
    759759    std::ostringstream stream;
    760     for (std::vector<const element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
     760    for (std::vector<element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
    761761      stream << (*iter)->Z << " ";
    762762    }
  • src/Actions/MapOfActions.hpp

    re588312 r311d688  
    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

    re588312 r311d688  
    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

    re588312 r311d688  
    510510    const element * const elemental = World::getInstance().getPeriode()->FindElement(iter->first);
    511511    ZtoIndexMap.insert( pair<int,int> (iter->first, counter) );
    512     *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;
     512    *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;
    513513  }
    514514}
  • src/Parser/XyzParser.cpp

    re588312 r311d688  
    7272  vector<atom*> atoms = World::getInstance().getAllAtoms();
    7373  for(vector<atom*>::iterator it = atoms.begin(); it != atoms.end(); it++) {
    74     *file << noshowpoint << (*it)->getType()->getSymbol() << "\t" << (*it)->x[0] << "\t" << (*it)->x[1] << "\t" << (*it)->x[2] << endl;
     74    *file << noshowpoint << (*it)->getType()->symbol << "\t" << (*it)->x[0] << "\t" << (*it)->x[1] << "\t" << (*it)->x[2] << endl;
    7575  }
    7676}
  • src/UIElements/Dialog.hpp

    re588312 r311d688  
    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

    re588312 r311d688  
    558558  {
    559559    stringstream sstr;
    560     sstr << (*iter).first << "\t" << (*iter).second->getName();
     560    sstr << (*iter).first << "\t" << (*iter).second->name;
    561561    inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first));
    562562  }
     
    593593  {
    594594    stringstream sstr;
    595     sstr << (*iter).first << "\t" << (*iter).second->getName();
     595    sstr << (*iter).first << "\t" << (*iter).second->name;
    596596    inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first));
    597597  }
     
    820820}
    821821
    822 ElementQTQueryPipe::ElementQTQueryPipe(const element **_content, QTDialog *_dialog, QComboBox *_theBox) :
     822ElementQTQueryPipe::ElementQTQueryPipe(element **_content, QTDialog *_dialog, QComboBox *_theBox) :
    823823  content(_content),
    824824  dialog(_dialog),
     
    836836}
    837837
    838 ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector<const element *>*_content, QTDialog *_dialog, QComboBox *_theBox) :
     838ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector<element *>*_content, QTDialog *_dialog, QComboBox *_theBox) :
    839839  content(_content),
    840840  dialog(_dialog),
     
    848848  QVariant data = theBox->itemData(newIndex);
    849849  int idx = data.toInt();
    850   const element *elemental = World::getInstance().getPeriode()->FindElement(idx);
     850  element *elemental = World::getInstance().getPeriode()->FindElement(idx);
    851851  if(elemental)
    852852    (*content).push_back(elemental);
  • src/UIElements/QT4/QTDialog.hpp

    re588312 r311d688  
    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

    re588312 r311d688  
    568568  bool badInput=false;
    569569  bool aborted = false;
    570   const element * temp = NULL;
     570  element * temp = NULL;
    571571  do{
    572572    badInput = false;
  • src/analysis_bonds.cpp

    re588312 r311d688  
    215215          if (((OtherAtom->type == first) || (OtherAtom->type == 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

    re588312 r311d688  
    3232 * \return Map of doubles with values the pair of the two atoms.
    3333 */
    34 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements)
     34PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements)
    3535{
    3636  Info FunctionInfo(__func__);
     
    4747
    4848  // create all possible pairs of elements
    49   set <pair<const element *,const element *> > PairsOfElements;
     49  set <pair<element *, element *> > PairsOfElements;
    5050  if (elements.size() >= 2) {
    51     for (vector<const element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
    52       for (vector<const element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
     51    for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
     52      for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
    5353        if (type1 != type2) {
    54           PairsOfElements.insert( make_pair(*type1,*type2) );
    55           DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl);
     54          PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
     55          DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl);
    5656        }
    5757  } else if (elements.size() == 1) { // one to all are valid
    58     const element *elemental = *elements.begin();
    59     PairsOfElements.insert( pair<const element *,const element*>(elemental,0) );
    60     PairsOfElements.insert( pair<const element *,const element*>(0,elemental) );
     58    element *elemental = *elements.begin();
     59    PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) );
     60    PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) );
    6161  } else { // all elements valid
    6262    PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
     
    7373          DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
    7474          if ((*iter)->getId() < (*runner)->getId()){
    75             for (set <pair<const element *,const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
     75            for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
    7676              if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
    7777                distance = domain.periodicDistance(*(*iter)->node,*(*runner)->node);
     
    9494 * \return Map of doubles with values the pair of the two atoms.
    9595 */
    96 PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const int ranges[NDIM] )
     96PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const int ranges[NDIM] )
    9797{
    9898  Info FunctionInfo(__func__);
     
    114114
    115115  // create all possible pairs of elements
    116   set <pair<const element *,const element *> > PairsOfElements;
     116  set <pair<element *, element *> > PairsOfElements;
    117117  if (elements.size() >= 2) {
    118     for (vector<const element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
    119       for (vector<const element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
     118    for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
     119      for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
    120120        if (type1 != type2) {
    121           PairsOfElements.insert( make_pair(*type1,*type2) );
    122           DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl);
     121          PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
     122          DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl);
    123123        }
    124124  } else if (elements.size() == 1) { // one to all are valid
    125     const element *elemental = *elements.begin();
    126     PairsOfElements.insert( pair<const element *,const element*>(elemental,0) );
    127     PairsOfElements.insert( pair<const element *,const element*>(0,elemental) );
     125    element *elemental = *elements.begin();
     126    PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) );
     127    PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) );
    128128  } else { // all elements valid
    129129    PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
     
    148148                  DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
    149149                  if ((*iter)->getId() < (*runner)->getId()){
    150                     for (set <pair<const element *,const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
     150                    for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
    151151                      if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
    152152                        periodicOtherX = FullInverseMatrix * (*(*runner)->node); // x now in [0,1)^3
     
    177177 * \return Map of dobules with values as pairs of atom and the vector
    178178 */
    179 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point )
     179CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point )
    180180{
    181181  Info FunctionInfo(__func__);
     
    195195    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    196196      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    197       for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     197      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    198198        if ((*type == NULL) || ((*iter)->type == *type)) {
    199199          distance = domain.periodicDistance(*(*iter)->node,*point);
     
    214214 * \return Map of dobules with values as pairs of atom and the vector
    215215 */
    216 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point, const int ranges[NDIM] )
     216CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] )
    217217{
    218218  Info FunctionInfo(__func__);
     
    236236    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    237237      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    238       for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     238      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    239239        if ((*type == NULL) || ((*iter)->type == *type)) {
    240240          periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
     
    262262 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    263263 */
    264 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
     264CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
    265265{
    266266  Info FunctionInfo(__func__);
     
    283283    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    284284      DoLog(3) && (Log() << Verbose(3) << "\tCurrent atom is " << *(*iter) << "." << endl);
    285       for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     285      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    286286        if ((*type == NULL) || ((*iter)->type == *type)) {
    287287          TriangleIntersectionList Intersections((*iter)->node,Surface,LC);
     
    308308 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    309309 */
    310 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
     310CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
    311311{
    312312  Info FunctionInfo(__func__);
     
    334334    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    335335      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    336       for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     336      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    337337        if ((*type == NULL) || ((*iter)->type == *type)) {
    338338          periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
  • src/analysis_correlation.hpp

    re588312 r311d688  
    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

    re588312 r311d688  
    193193{
    194194  if (out != NULL) {
    195     *out << type->getSymbol() << "\t" << x[0] << "\t" << x[1] << "\t" << x[2] << "\t" << endl;
     195    *out << type->symbol << "\t" << x[0] << "\t" << x[1] << "\t" << x[2] << "\t" << endl;
    196196    return true;
    197197  } else
     
    231231{
    232232  if (out != NULL) {
    233     *out << type->getSymbol() << "\t";
     233    *out << type->symbol << "\t";
    234234    *out << Trajectory.R.at(step)[0] << "\t";
    235235    *out << Trajectory.R.at(step)[1] << "\t";
     
    247247void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const
    248248{
    249   *out << "\t\t" << type->getSymbol() << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl;
     249  *out << "\t\t" << type->symbol << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl;
    250250  if (AtomNo != NULL)
    251251    *AtomNo++;
  • src/config.cpp

    re588312 r311d688  
    12791279    AtomNo = 0;
    12801280    for (molecule::const_iterator iter = (*MolRunner)->begin(); iter != (*MolRunner)->end(); ++iter) {
    1281       sprintf(name, "%2s%2d",(*iter)->type->getSymbol().c_str(), elementNo[(*iter)->type->Z]);
     1281      sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]);
    12821282      elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100;   // confine to two digits
    12831283      fprintf(f,
     
    12941294             (double)(*iter)->type->NoValenceOrbitals,          /* temperature factor */
    12951295             "0",            /* segment identifier */
    1296              (*iter)->type->getSymbol().c_str(),    /* element symbol */
     1296             (*iter)->type->symbol,    /* element symbol */
    12971297             "0");           /* charge */
    12981298      AtomNo++;
     
    13321332  AtomNo = 0;
    13331333  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    1334     sprintf(name, "%2s%2d",(*iter)->type->getSymbol().c_str(), elementNo[(*iter)->type->Z]);
     1334    sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]);
    13351335    elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100;   // confine to two digits
    13361336    fprintf(f,
     
    13471347           (double)(*iter)->type->NoValenceOrbitals,          /* temperature factor */
    13481348           "0",            /* segment identifier */
    1349            (*iter)->type->getSymbol().c_str(),    /* element symbol */
     1349           (*iter)->type->symbol,    /* element symbol */
    13501350           "0");           /* charge */
    13511351    AtomNo++;
     
    13921392    *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t";
    13931393    *output << static_cast<double>((*iter)->type->Valence) << "\t";
    1394     *output << (*iter)->type->getSymbol() << "\t";
     1394    *output << (*iter)->type->symbol << "\t";
    13951395    for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
    13961396      *output << (*runner)->GetOtherAtom(*iter)->nr << "\t";
     
    14641464        *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t";
    14651465        *output << (double)(*iter)->type->Valence << "\t";
    1466         *output << (*iter)->type->getSymbol() << "\t";
     1466        *output << (*iter)->type->symbol << "\t";
    14671467        for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
    14681468          *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom((*iter))->getId() ] << "\t";
  • src/element.cpp

    re588312 r311d688  
    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

    re588312 r311d688  
    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

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

    re588312 r311d688  
    337337
    338338  // Recognize doubly appearing molecules in a list of them
     339  int * IsEqualToWithinThreshold(molecule *OtherMolecule, double threshold);
    339340  int * GetFatherSonAtomicMap(molecule *OtherMolecule);
    340341
  • src/periodentafel.cpp

    re588312 r311d688  
    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

    re588312 r311d688  
    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

    re588312 r311d688  
    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

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

    re588312 r311d688  
    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

    re588312 r311d688  
    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

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

    re588312 r311d688  
    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

    re588312 r311d688  
    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.