Changes in / [311d688:e588312]
- Location:
- src
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/AnalysisAction/PairCorrelationAction.cpp
r311d688 re588312 76 76 ofstream output; 77 77 ofstream binoutput; 78 std::vector< element *> elements;78 std::vector<const element *> elements; 79 79 string type; 80 80 Vector Point; -
src/Actions/AnalysisAction/PointCorrelationAction.cpp
r311d688 re588312 77 77 ofstream output; 78 78 ofstream binoutput; 79 std::vector< element *> elements;79 std::vector<const element *> elements; 80 80 string type; 81 81 Vector Point; … … 97 97 cout << "Point to correlate to is " << Point << endl; 98 98 CorrelationToPointMap *correlationmap = NULL; 99 for(std::vector< element *>::iterator iter = elements.begin(); iter != elements.end(); ++iter)100 cout << "element is " << (*iter)-> symbol<< endl;99 for(std::vector<const element *>::iterator iter = elements.begin(); iter != elements.end(); ++iter) 100 cout << "element is " << (*iter)->getSymbol() << endl; 101 101 std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules(); 102 102 if (periodic) -
src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp
r311d688 re588312 78 78 ofstream output; 79 79 ofstream binoutput; 80 std::vector< element *> elements;80 std::vector<const element *> elements; 81 81 string type; 82 82 Vector Point; -
src/Actions/AtomAction/AddAction.cpp
r311d688 re588312 52 52 53 53 Action::state_ptr AtomAddAction::performCall() { 54 element * elemental = NULL;54 const element * elemental = NULL; 55 55 Vector position; 56 56 … … 63 63 first->type = elemental; 64 64 first->x = position; 65 DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->type->name << " at " << (first->x) << "." << endl);65 DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << *first->type << " at " << (first->x) << "." << endl); 66 66 // TODO: remove when all of World's atoms are stored. 67 67 std::vector<molecule *> molecules = World::getInstance().getAllMolecules(); -
src/Actions/AtomAction/ChangeElementAction.cpp
r311d688 re588312 50 50 Action::state_ptr AtomChangeElementAction::performCall() { 51 51 atom *first = NULL; 52 element *elemental = NULL;52 const element *elemental = NULL; 53 53 54 54 ValueStorage::getInstance().queryCurrentValue(NAME, elemental); … … 56 56 for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection(); iter != World::getInstance().endAtomSelection(); ++iter) { 57 57 first = iter->second; 58 DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << elemental->symbol << "." << endl);58 DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << *elemental << "." << endl); 59 59 first->type = elemental; 60 60 } -
src/Actions/MapOfActions.cpp
r311d688 re588312 292 292 293 293 // value types for the actions 294 TypeMap["add-atom"] = &typeid( element);294 TypeMap["add-atom"] = &typeid(const element); 295 295 TypeMap["bond-file"] = &typeid(std::string); 296 296 TypeMap["bond-table"] = &typeid(std::string); … … 298 298 TypeMap["center-in-box"] = &typeid(BoxValue); 299 299 TypeMap["change-box"] = &typeid(BoxValue); 300 TypeMap["change-element"] = &typeid( element);300 TypeMap["change-element"] = &typeid(const element); 301 301 TypeMap["change-molname"] = &typeid(std::string); 302 302 TypeMap["convex-envelope"] = &typeid(void); … … 342 342 TypeMap["distances"] = &typeid(VectorValue); 343 343 TypeMap["DoRotate"] = &typeid(bool); 344 TypeMap["element"] = &typeid( element);345 TypeMap["elements"] = &typeid(std::vector< element *>);344 TypeMap["element"] = &typeid(const element); 345 TypeMap["elements"] = &typeid(std::vector<const element *>); 346 346 TypeMap["end-step"] = &typeid(int); 347 347 TypeMap["id-mapping"] = &typeid(bool); … … 380 380 TypeEnumMap[&typeid(atom)] = Atom; 381 381 TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms; 382 TypeEnumMap[&typeid( element)] = Element;383 TypeEnumMap[&typeid(std::vector< element *>)] = ListOfElements;382 TypeEnumMap[&typeid(const element)] = Element; 383 TypeEnumMap[&typeid(std::vector<const element *>)] = ListOfElements; 384 384 385 385 // default values for any action that needs one (always string!) … … 558 558 } 559 559 560 void MapOfActions::queryCurrentValue(const char * name, c lasselement * &_T) {560 void MapOfActions::queryCurrentValue(const char * name, const element * &_T) { 561 561 int Z = -1; 562 if (typeid( element ) == *TypeMap[name]) {562 if (typeid(const element ) == *TypeMap[name]) { 563 563 if (CurrentValue.find(name) == CurrentValue.end()) 564 564 throw MissingValueException(__FILE__, __LINE__); … … 642 642 } 643 643 644 void MapOfActions::queryCurrentValue(const char * name, std::vector< element *>&_T)644 void MapOfActions::queryCurrentValue(const char * name, std::vector<const element *>&_T) 645 645 { 646 646 int Z = -1; 647 element *elemental = NULL;648 if (typeid( std::vector< element *> ) == *TypeMap[name]) {647 const element *elemental = NULL; 648 if (typeid( std::vector<const element *> ) == *TypeMap[name]) { 649 649 if (CurrentValue.find(name) == CurrentValue.end()) 650 650 throw MissingValueException(__FILE__, __LINE__); … … 694 694 } 695 695 696 void MapOfActions::setCurrentValue(const char * name, c lasselement * &_T)697 { 698 if (typeid( element ) == *TypeMap[name]) {696 void MapOfActions::setCurrentValue(const char * name, const element * &_T) 697 { 698 if (typeid(const element ) == *TypeMap[name]) { 699 699 std::ostringstream stream; 700 700 stream << _T->Z; … … 754 754 } 755 755 756 void MapOfActions::setCurrentValue(const char * name, std::vector< element *>&_T)757 { 758 if (typeid( std::vector< element *> ) == *TypeMap[name]) {756 void MapOfActions::setCurrentValue(const char * name, std::vector<const element *>&_T) 757 { 758 if (typeid( std::vector<const element *> ) == *TypeMap[name]) { 759 759 std::ostringstream stream; 760 for (std::vector< element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {760 for (std::vector<const element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) { 761 761 stream << (*iter)->Z << " "; 762 762 } -
src/Actions/MapOfActions.hpp
r311d688 re588312 164 164 165 165 void queryCurrentValue(const char * name, class atom * &_T); 166 void queryCurrentValue(const char * name, c lasselement * &_T);166 void queryCurrentValue(const char * name, const element * &_T); 167 167 void queryCurrentValue(const char * name, class molecule * &_T); 168 168 void queryCurrentValue(const char * name, class Box &_T); 169 169 void queryCurrentValue(const char * name, class Vector &_T); 170 170 void queryCurrentValue(const char * name, std::vector<atom *>&_T); 171 void queryCurrentValue(const char * name, std::vector< element *>&_T);171 void queryCurrentValue(const char * name, std::vector<const element *>&_T); 172 172 void queryCurrentValue(const char * name, std::vector<molecule *>&_T); 173 173 template<typename T> void queryCurrentValue(const char * name, T &_T) … … 198 198 199 199 void setCurrentValue(const char * name, class atom * &_T); 200 void setCurrentValue(const char * name, c lasselement * &_T);200 void setCurrentValue(const char * name, const element * &_T); 201 201 void setCurrentValue(const char * name, class molecule * &_T); 202 202 void setCurrentValue(const char * name, class Box &_T); 203 203 void setCurrentValue(const char * name, class Vector &_T); 204 204 void setCurrentValue(const char * name, std::vector<atom *>&_T); 205 void setCurrentValue(const char * name, std::vector< element *>&_T);205 void setCurrentValue(const char * name, std::vector<const element *>&_T); 206 206 void setCurrentValue(const char * name, std::vector<molecule *>&_T); 207 207 template<class T> void setCurrentValue(const char * name, T &_T) -
src/Formula.cpp
r311d688 re588312 47 47 for(const_iterator iter=end();iter!=begin();){ 48 48 --iter; 49 sstr << (*iter).first-> symbol;49 sstr << (*iter).first->getSymbol(); 50 50 if((*iter).second>1) 51 51 sstr << (*iter).second; … … 146 146 147 147 bool Formula::hasElement(const string &shorthand) const{ 148 element * element = World::getInstance().getPeriode()->FindElement(shorthand);148 const element * element = World::getInstance().getPeriode()->FindElement(shorthand); 149 149 return hasElement(element); 150 150 } … … 167 167 168 168 void Formula::operator+=(const string &shorthand){ 169 element * element = World::getInstance().getPeriode()->FindElement(shorthand);169 const element * element = World::getInstance().getPeriode()->FindElement(shorthand); 170 170 operator+=(element); 171 171 } … … 198 198 199 199 void Formula::operator-=(const string &shorthand){ 200 element * element = World::getInstance().getPeriode()->FindElement(shorthand);200 const element * element = World::getInstance().getPeriode()->FindElement(shorthand); 201 201 operator-=(element); 202 202 } … … 220 220 221 221 void Formula::addElements(const string &shorthand,unsigned int count){ 222 element * element = World::getInstance().getPeriode()->FindElement(shorthand);222 const element * element = World::getInstance().getPeriode()->FindElement(shorthand); 223 223 addElements(element,count); 224 224 } … … 252 252 253 253 const unsigned int Formula::operator[](string shorthand) const{ 254 element * element = World::getInstance().getPeriode()->FindElement(shorthand);254 const element * element = World::getInstance().getPeriode()->FindElement(shorthand); 255 255 return operator[](element); 256 256 } … … 380 380 result_type 381 381 Formula::_iterator<result_type>::operator*(){ 382 element *element = World::getInstance().getPeriode()->FindElement(pos+1);382 const element *element = World::getInstance().getPeriode()->FindElement(pos+1); 383 383 ASSERT(element,"Element with position of iterator not found"); 384 384 return make_pair(element,(*set)[pos]); … … 390 390 // no one can keep this value around, so a static is ok to avoid temporaries 391 391 static value_type value=make_pair(reinterpret_cast<element*>(0),0); // no default constructor for std::pair 392 element *element = World::getInstance().getPeriode()->FindElement(pos+1);392 const element *element = World::getInstance().getPeriode()->FindElement(pos+1); 393 393 ASSERT(element,"Element with position of iterator not found"); 394 394 value = make_pair(element,(*set)[pos]); -
src/Parser/PcpParser.cpp
r311d688 re588312 510 510 const element * const elemental = World::getInstance().getPeriode()->FindElement(iter->first); 511 511 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-> name << "\t" << elemental->symbol<<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->getName() << "\t" << elemental->getSymbol() <<endl; 513 513 } 514 514 } -
src/Parser/XyzParser.cpp
r311d688 re588312 72 72 vector<atom*> atoms = World::getInstance().getAllAtoms(); 73 73 for(vector<atom*>::iterator it = atoms.begin(); it != atoms.end(); it++) { 74 *file << noshowpoint << (*it)->getType()-> symbol<< "\t" << (*it)->x[0] << "\t" << (*it)->x[1] << "\t" << (*it)->x[2] << endl;74 *file << noshowpoint << (*it)->getType()->getSymbol() << "\t" << (*it)->x[0] << "\t" << (*it)->x[1] << "\t" << (*it)->x[2] << endl; 75 75 } 76 76 } -
src/UIElements/Dialog.hpp
r311d688 re588312 255 255 virtual void setResult(); 256 256 protected: 257 element * tmp;257 const element * tmp; 258 258 }; 259 259 … … 265 265 virtual void setResult(); 266 266 protected: 267 element *temp;268 std::vector< element *> tmp;267 const element *temp; 268 std::vector<const element *> tmp; 269 269 }; 270 270 -
src/UIElements/QT4/QTDialog.cpp
r311d688 re588312 558 558 { 559 559 stringstream sstr; 560 sstr << (*iter).first << "\t" << (*iter).second-> name;560 sstr << (*iter).first << "\t" << (*iter).second->getName(); 561 561 inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first)); 562 562 } … … 593 593 { 594 594 stringstream sstr; 595 sstr << (*iter).first << "\t" << (*iter).second-> name;595 sstr << (*iter).first << "\t" << (*iter).second->getName(); 596 596 inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first)); 597 597 } … … 820 820 } 821 821 822 ElementQTQueryPipe::ElementQTQueryPipe( element **_content, QTDialog *_dialog, QComboBox *_theBox) :822 ElementQTQueryPipe::ElementQTQueryPipe(const element **_content, QTDialog *_dialog, QComboBox *_theBox) : 823 823 content(_content), 824 824 dialog(_dialog), … … 836 836 } 837 837 838 ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector< element *>*_content, QTDialog *_dialog, QComboBox *_theBox) :838 ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector<const element *>*_content, QTDialog *_dialog, QComboBox *_theBox) : 839 839 content(_content), 840 840 dialog(_dialog), … … 848 848 QVariant data = theBox->itemData(newIndex); 849 849 int idx = data.toInt(); 850 element *elemental = World::getInstance().getPeriode()->FindElement(idx);850 const element *elemental = World::getInstance().getPeriode()->FindElement(idx); 851 851 if(elemental) 852 852 (*content).push_back(elemental); -
src/UIElements/QT4/QTDialog.hpp
r311d688 re588312 451 451 Q_OBJECT 452 452 public: 453 ElementQTQueryPipe( element **_content, QTDialog *_dialog, QComboBox *_theBox);453 ElementQTQueryPipe(const element **_content, QTDialog *_dialog, QComboBox *_theBox); 454 454 virtual ~ElementQTQueryPipe(); 455 455 … … 458 458 459 459 private: 460 element **content;460 const element **content; 461 461 QTDialog *dialog; 462 462 QComboBox *theBox; … … 466 466 Q_OBJECT 467 467 public: 468 ElementsQTQueryPipe(std::vector< element *>*_content, QTDialog *_dialog, QComboBox *_theBox);468 ElementsQTQueryPipe(std::vector<const element *>*_content, QTDialog *_dialog, QComboBox *_theBox); 469 469 virtual ~ElementsQTQueryPipe(); 470 470 … … 473 473 474 474 private: 475 std::vector< element *>*content;475 std::vector<const element *>*content; 476 476 QTDialog *dialog; 477 477 QComboBox *theBox; -
src/UIElements/TextUI/TextDialog.cpp
r311d688 re588312 568 568 bool badInput=false; 569 569 bool aborted = false; 570 element * temp = NULL;570 const element * temp = NULL; 571 571 do{ 572 572 badInput = false; -
src/analysis_bonds.cpp
r311d688 re588312 215 215 if (((OtherAtom->type == first) || (OtherAtom->type == second)) && (theAtom->nr < OtherAtom->nr)) { 216 216 count++; 217 DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name<< " bond found between " << *Walker << " and " << *OtherAtom << "." << endl);217 DoLog(1) && (Log() << Verbose(1) << *first << "-" << *second << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl); 218 218 } 219 219 } … … 262 262 if (result) { // check results 263 263 count++; 264 DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << "-" << third->name<< " bond found at " << *Walker << "." << endl);264 DoLog(1) && (Log() << Verbose(1) << *first << "-" << *second << "-" << *third << " bond found at " << *Walker << "." << endl); 265 265 } 266 266 } -
src/analysis_correlation.cpp
r311d688 re588312 32 32 * \return Map of doubles with values the pair of the two atoms. 33 33 */ 34 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector< element *> &elements)34 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements) 35 35 { 36 36 Info FunctionInfo(__func__); … … 47 47 48 48 // create all possible pairs of elements 49 set <pair< element *,element *> > PairsOfElements;49 set <pair<const element *,const element *> > PairsOfElements; 50 50 if (elements.size() >= 2) { 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)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) 53 53 if (type1 != type2) { 54 PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );55 DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol<< "." << endl);54 PairsOfElements.insert( make_pair(*type1,*type2) ); 55 DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl); 56 56 } 57 57 } else if (elements.size() == 1) { // one to all are valid 58 element *elemental = *elements.begin();59 PairsOfElements.insert( pair< element *, element*>(elemental,(element *)NULL) );60 PairsOfElements.insert( pair< element *, element*>((element *)NULL,elemental) );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) ); 61 61 } else { // all elements valid 62 62 PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) ); … … 73 73 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 74 74 if ((*iter)->getId() < (*runner)->getId()){ 75 for (set <pair< element *,element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)75 for (set <pair<const element *,const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 76 76 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 77 77 distance = domain.periodicDistance(*(*iter)->node,*(*runner)->node); … … 94 94 * \return Map of doubles with values the pair of the two atoms. 95 95 */ 96 PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const int ranges[NDIM] )96 PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const int ranges[NDIM] ) 97 97 { 98 98 Info FunctionInfo(__func__); … … 114 114 115 115 // create all possible pairs of elements 116 set <pair< element *,element *> > PairsOfElements;116 set <pair<const element *,const element *> > PairsOfElements; 117 117 if (elements.size() >= 2) { 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)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) 120 120 if (type1 != type2) { 121 PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );122 DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol<< "." << endl);121 PairsOfElements.insert( make_pair(*type1,*type2) ); 122 DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl); 123 123 } 124 124 } else if (elements.size() == 1) { // one to all are valid 125 element *elemental = *elements.begin();126 PairsOfElements.insert( pair< element *, element*>(elemental,(element *)NULL) );127 PairsOfElements.insert( pair< element *, element*>((element *)NULL,elemental) );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) ); 128 128 } else { // all elements valid 129 129 PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) ); … … 148 148 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 149 149 if ((*iter)->getId() < (*runner)->getId()){ 150 for (set <pair< element *,element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)150 for (set <pair<const element *,const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 151 151 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 152 152 periodicOtherX = FullInverseMatrix * (*(*runner)->node); // x now in [0,1)^3 … … 177 177 * \return Map of dobules with values as pairs of atom and the vector 178 178 */ 179 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Vector *point )179 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point ) 180 180 { 181 181 Info FunctionInfo(__func__); … … 195 195 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 196 196 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 197 for (vector< element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)197 for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 198 198 if ((*type == NULL) || ((*iter)->type == *type)) { 199 199 distance = domain.periodicDistance(*(*iter)->node,*point); … … 214 214 * \return Map of dobules with values as pairs of atom and the vector 215 215 */ 216 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Vector *point, const int ranges[NDIM] )216 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point, const int ranges[NDIM] ) 217 217 { 218 218 Info FunctionInfo(__func__); … … 236 236 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 237 237 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 238 for (vector< element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)238 for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 239 239 if ((*type == NULL) || ((*iter)->type == *type)) { 240 240 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 … … 262 262 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest 263 263 */ 264 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )264 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC ) 265 265 { 266 266 Info FunctionInfo(__func__); … … 283 283 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 284 284 DoLog(3) && (Log() << Verbose(3) << "\tCurrent atom is " << *(*iter) << "." << endl); 285 for (vector< element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)285 for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 286 286 if ((*type == NULL) || ((*iter)->type == *type)) { 287 287 TriangleIntersectionList Intersections((*iter)->node,Surface,LC); … … 308 308 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest 309 309 */ 310 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )310 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ) 311 311 { 312 312 Info FunctionInfo(__func__); … … 334 334 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 335 335 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 336 for (vector< element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)336 for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 337 337 if ((*type == NULL) || ((*iter)->type == *type)) { 338 338 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 -
src/analysis_correlation.hpp
r311d688 re588312 46 46 /********************************************** declarations *******************************/ 47 47 48 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector< element *> &elements);49 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Vector *point );50 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );51 PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const int ranges[NDIM] );52 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Vector *point, const int ranges[NDIM] );53 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );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] ); 54 54 int GetBin ( const double value, const double BinWidth, const double BinStart ); 55 55 void OutputCorrelation( ofstream * const file, const BinPairMap * const map ); -
src/atom.cpp
r311d688 re588312 193 193 { 194 194 if (out != NULL) { 195 *out << type-> symbol<< "\t" << x[0] << "\t" << x[1] << "\t" << x[2] << "\t" << endl;195 *out << type->getSymbol() << "\t" << x[0] << "\t" << x[1] << "\t" << x[2] << "\t" << endl; 196 196 return true; 197 197 } else … … 231 231 { 232 232 if (out != NULL) { 233 *out << type-> symbol<< "\t";233 *out << type->getSymbol() << "\t"; 234 234 *out << Trajectory.R.at(step)[0] << "\t"; 235 235 *out << Trajectory.R.at(step)[1] << "\t"; … … 247 247 void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const 248 248 { 249 *out << "\t\t" << type-> symbol<< " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl;249 *out << "\t\t" << type->getSymbol() << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl; 250 250 if (AtomNo != NULL) 251 251 *AtomNo++; -
src/config.cpp
r311d688 re588312 1279 1279 AtomNo = 0; 1280 1280 for (molecule::const_iterator iter = (*MolRunner)->begin(); iter != (*MolRunner)->end(); ++iter) { 1281 sprintf(name, "%2s%2d",(*iter)->type-> symbol, elementNo[(*iter)->type->Z]);1281 sprintf(name, "%2s%2d",(*iter)->type->getSymbol().c_str(), elementNo[(*iter)->type->Z]); 1282 1282 elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100; // confine to two digits 1283 1283 fprintf(f, … … 1294 1294 (double)(*iter)->type->NoValenceOrbitals, /* temperature factor */ 1295 1295 "0", /* segment identifier */ 1296 (*iter)->type-> symbol, /* element symbol */1296 (*iter)->type->getSymbol().c_str(), /* element symbol */ 1297 1297 "0"); /* charge */ 1298 1298 AtomNo++; … … 1332 1332 AtomNo = 0; 1333 1333 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1334 sprintf(name, "%2s%2d",(*iter)->type-> symbol, elementNo[(*iter)->type->Z]);1334 sprintf(name, "%2s%2d",(*iter)->type->getSymbol().c_str(), elementNo[(*iter)->type->Z]); 1335 1335 elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100; // confine to two digits 1336 1336 fprintf(f, … … 1347 1347 (double)(*iter)->type->NoValenceOrbitals, /* temperature factor */ 1348 1348 "0", /* segment identifier */ 1349 (*iter)->type-> symbol, /* element symbol */1349 (*iter)->type->getSymbol().c_str(), /* element symbol */ 1350 1350 "0"); /* charge */ 1351 1351 AtomNo++; … … 1392 1392 *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t"; 1393 1393 *output << static_cast<double>((*iter)->type->Valence) << "\t"; 1394 *output << (*iter)->type-> symbol<< "\t";1394 *output << (*iter)->type->getSymbol() << "\t"; 1395 1395 for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++) 1396 1396 *output << (*runner)->GetOtherAtom(*iter)->nr << "\t"; … … 1464 1464 *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t"; 1465 1465 *output << (double)(*iter)->type->Valence << "\t"; 1466 *output << (*iter)->type-> symbol<< "\t";1466 *output << (*iter)->type->getSymbol() << "\t"; 1467 1467 for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++) 1468 1468 *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom((*iter))->getId() ] << "\t"; -
src/element.cpp
r311d688 re588312 23 23 VanDerWaalsRadius(0), 24 24 Z(-1), 25 previous(NULL),26 next(NULL),27 sort(NULL),28 25 Valence(0), 29 26 NoValenceOrbitals(0) … … 31 28 }; 32 29 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 33 45 /** Destructor of class element. 34 46 */ 35 47 element::~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 } 36 65 37 66 /** Prints element data to \a *out. … … 66 95 } 67 96 68 string element::getSymbol() const{69 return s tring(symbol);97 string &element::getSymbol(){ 98 return symbol; 70 99 } 71 100 72 std::string element::getName() const{ 73 return string(name); 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; 74 111 } 75 112 -
src/element.hpp
r311d688 re588312 28 28 */ 29 29 class element { 30 enum {strfield_length=7}; 30 31 public: 31 32 double mass; //!< mass in g/mol … … 33 34 double VanDerWaalsRadius; //!< can-der-Waals radius 34 35 int Z; //!< atomic 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 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 43 39 double Valence; //!< number of valence electrons for this element 44 40 int NoValenceOrbitals; //!< number of valence orbitals, used for determining bond degree in molecule::CreateConnectmatrix() … … 46 42 double HBondAngle[NDIM]; //!< typical angle for one, two, three bonded hydrogen (in degrees) 47 43 48 element(); 49 ~element(); 44 element(); 45 element(const element&); 46 ~element(); 50 47 51 // accessor functions 52 atomicNumber_t getNumber() const; 53 std::string getSymbol() const; 54 std::string getName() const; 48 element &operator=(const element&); 55 49 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; 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; 59 60 60 61 private: 62 std::string name; //!< atom name, i.e. "Hydrogren" 63 std::string symbol; //!< short form of the atom, i.e. "H" 61 64 }; 62 65 -
src/molecule.cpp
r311d688 re588312 218 218 if(pointer->getName() == "Unknown"){ 219 219 stringstream sstr; 220 sstr << pointer->type-> symbol<< pointer->nr+1;220 sstr << pointer->type->getSymbol() << pointer->nr+1; 221 221 pointer->setName(sstr.str()); 222 222 } … … 975 975 NoNonHydrogen++; 976 976 stringstream sstr; 977 sstr << (*iter)->type-> symbol<< (*iter)->nr+1;977 sstr << (*iter)->type->getSymbol() << (*iter)->nr+1; 978 978 (*iter)->setName(sstr.str()); 979 979 DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl); … … 981 981 } 982 982 return res; 983 };984 985 /** Determines whether two molecules actually contain the same atoms and coordination.986 * \param *out output stream for debugging987 * \param *OtherMolecule the molecule to compare this one to988 * \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 */991 int * 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 comparison999 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 /// -# AtomCount1006 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 /// -# Formula1013 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 molecules1033 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 all1062 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 memory1071 delete[](PermMap);1072 delete[](OtherPermMap);1073 delete[](Distances);1074 delete[](OtherDistances);1075 if (flag) { // if not equal1076 delete[](PermutationMap);1077 result = false;1078 }1079 }1080 /// return pointer to map if all distances were below \a threshold1081 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 }1089 983 }; 1090 984 -
src/molecule.hpp
r311d688 re588312 337 337 338 338 // Recognize doubly appearing molecules in a list of them 339 int * IsEqualToWithinThreshold(molecule *OtherMolecule, double threshold);340 339 int * GetFatherSonAtomicMap(molecule *OtherMolecule); 341 340 -
src/periodentafel.cpp
r311d688 re588312 34 34 { 35 35 stringstream input(elementsDB,ios_base::in); 36 bool status = LoadElementsDatabase( &input);36 bool status = LoadElementsDatabase(input); 37 37 ASSERT(status, "General element initialization failed"); 38 38 } … … 72 72 * \return iterator to added element 73 73 */ 74 periodentafel::iterator periodentafel::AddElement(element * constpointer)74 periodentafel::iterator periodentafel::AddElement(element * pointer) 75 75 { 76 76 atomicNumber_t Z = pointer->getNumber(); 77 77 ASSERT(!elements.count(Z), "Element is already present."); 78 pointer->sort = &pointer->Z;79 78 if (pointer->getNumber() < 1 && pointer->getNumber() >= MAX_ELEMENTS) 80 79 DoeLog(0) && (eLog() << Verbose(0) << "Invalid Z number!\n"); … … 86 85 * \param *pointer element to be removed 87 86 */ 88 size_t periodentafel::RemoveElement( element * constpointer)87 size_t periodentafel::RemoveElement(const element * pointer) 89 88 { 90 89 return RemoveElement(pointer->getNumber()); … … 114 113 * \return pointer to element or NULL if not found 115 114 */ 116 element * constperiodentafel::FindElement(atomicNumber_t Z) const115 const element * periodentafel::FindElement(atomicNumber_t Z) const 117 116 { 118 117 const_iterator res = elements.find(Z); … … 125 124 * \return pointer to element 126 125 */ 127 element * constperiodentafel::FindElement(const string &shorthand) const126 const element * periodentafel::FindElement(const string &shorthand) const 128 127 { 129 128 element *res = 0; … … 140 139 * \return desired element or NULL 141 140 */ 142 element * constperiodentafel::AskElement() const143 { 144 element * walker = NULL;141 const element * periodentafel::AskElement() const 142 { 143 const element * walker = NULL; 145 144 int Z; 146 145 do { … … 155 154 * \return pointer to either present or newly created element 156 155 */ 157 element * constperiodentafel::EnterElement()156 const element * periodentafel::EnterElement() 158 157 { 159 158 atomicNumber_t Z = 0; 160 159 DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl); 161 160 cin >> Z; 162 element * constres = FindElement(Z);161 const element *res = FindElement(Z); 163 162 if (!res) { 164 163 // TODO: make this using the constructor … … 169 168 cin >> tmp->mass; 170 169 DoLog(0) && (Log() << Verbose(0) << "Name [max 64 chars]: " << endl); 171 cin >> tmp-> name;170 cin >> tmp->getName(); 172 171 DoLog(0) && (Log() << Verbose(0) << "Short form [max 3 chars]: " << endl); 173 cin >> tmp-> symbol;172 cin >> tmp->getSymbol(); 174 173 AddElement(tmp); 175 174 return tmp; … … 180 179 181 180 /******************** Access to iterators ****************************/ 182 periodentafel::const_iterator periodentafel::begin() {181 periodentafel::const_iterator periodentafel::begin() const{ 183 182 return elements.begin(); 184 183 } 185 184 186 periodentafel::const_iterator periodentafel::end() {185 periodentafel::const_iterator periodentafel::end() const{ 187 186 return elements.end(); 188 187 } 189 188 190 periodentafel::reverse_iterator periodentafel::rbegin() {189 periodentafel::reverse_iterator periodentafel::rbegin() const{ 191 190 return reverse_iterator(elements.end()); 192 191 } 193 192 194 periodentafel::reverse_iterator periodentafel::rend() {193 periodentafel::reverse_iterator periodentafel::rend() const{ 195 194 return reverse_iterator(elements.begin()); 196 195 } … … 228 227 if (!input.fail()) 229 228 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as elements database." << endl); 230 status = status && LoadElementsDatabase( &input);229 status = status && LoadElementsDatabase(input); 231 230 input.close(); 232 231 input.clear(); … … 287 286 * \return true - parsing successful, false - something went wrong 288 287 */ 289 bool periodentafel::LoadElementsDatabase(istream *input)288 bool periodentafel::LoadElementsDatabase(istream &input) 290 289 { 291 290 bool status = true; 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 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; 297 299 DoLog(0) && (Log() << Verbose(0) << "Parsed elements:"); 298 while (! (*input).eof()) {300 while (!input.eof()) { 299 301 element *neues = new element; 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;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; 319 321 //neues->Output((ofstream *)&cout); 320 322 if ((neues->getNumber() > 0) && (neues->getNumber() < MAX_ELEMENTS)) { 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++; 323 parsedElements[neues->Z] = neues; 324 DoLog(0) && (Log() << Verbose(0) << " " << *neues); 334 325 } else { 335 326 DoeLog(2) && (eLog() << Verbose(2) << "Detected empty line or invalid element in elements db, discarding." << endl); … … 337 328 delete(neues); 338 329 } 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 } 339 336 } 340 337 DoLog(0) && (Log() << Verbose(0) << endl); … … 344 341 } 345 342 346 if ( counter == 0)343 if (!parsedElements.size()) 347 344 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 } 348 366 349 367 return status; -
src/periodentafel.hpp
r311d688 re588312 43 43 ~periodentafel(); 44 44 45 iterator AddElement(element * constpointer);46 size_t RemoveElement( element * constpointer);45 iterator AddElement(element * pointer); 46 size_t RemoveElement(const element * pointer); 47 47 size_t RemoveElement(atomicNumber_t); 48 48 void CleanupPeriodtable(); 49 element * constFindElement(atomicNumber_t) const;50 element * constFindElement(const std::string &shorthand) const;51 element * constAskElement() const;52 element * constEnterElement();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(); 53 53 54 const_iterator begin() ;55 const_iterator end() ;56 reverse_iterator rbegin() ;57 reverse_iterator rend() ;54 const_iterator begin() const; 55 const_iterator end() const; 56 reverse_iterator rbegin() const; 57 reverse_iterator rend() const; 58 58 bool Output(std::ostream * const output) const; 59 59 bool LoadPeriodentafel(const char * const path); … … 62 62 private: 63 63 64 bool LoadElementsDatabase(std::istream *input);64 bool LoadElementsDatabase(std::istream &input); 65 65 bool LoadValenceDatabase(std::istream *input); 66 66 bool LoadOrbitalsDatabase(std::istream *input); -
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
r311d688 re588312 46 46 47 47 // construct element list 48 std::vector< element *> elements;48 std::vector<const element *> elements; 49 49 hydrogen = World::getInstance().getPeriode()->FindElement(1); 50 50 CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found"); -
src/unittests/AnalysisCorrelationToPointUnitTest.hpp
r311d688 re588312 37 37 std::vector<molecule *> allMolecules; 38 38 molecule *TestMolecule; 39 element *hydrogen;39 const element *hydrogen; 40 40 41 41 CorrelationToPointMap *pointmap; -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp
r311d688 re588312 45 45 std::vector<molecule *> allMolecules; 46 46 molecule *TestSurfaceMolecule; 47 element *hydrogen;48 element *carbon;49 std::vector< element *> elements;47 const element *hydrogen; 48 const element *carbon; 49 std::vector<const element *> elements; 50 50 51 51 CorrelationToSurfaceMap *surfacemap; -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
r311d688 re588312 49 49 50 50 // construct element list 51 std::vector< element *> elements;51 std::vector<const element *> elements; 52 52 hydrogen = World::getInstance().getPeriode()->FindElement(1); 53 53 CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found"); -
src/unittests/AnalysisPairCorrelationUnitTest.hpp
r311d688 re588312 37 37 std::vector<molecule *> allMolecules; 38 38 molecule *TestMolecule; 39 element *hydrogen;39 const element *hydrogen; 40 40 41 41 PairCorrelationMap *correlationmap; -
src/unittests/periodentafelTest.cpp
r311d688 re588312 11 11 #include <cppunit/extensions/TestFactoryRegistry.h> 12 12 #include <cppunit/ui/text/TestRunner.h> 13 14 #include <sstream> 15 #include <iostream> 13 16 14 17 #include "Helpers/Assert.hpp" … … 67 70 { 68 71 // reload all databases 69 CPPUNIT_ASSERT(tafel->LoadElementsDatabase(new stringstream(elementsDB,ios_base::in)) && "General element initialization failed"); 72 stringstream elementsDBstream(elementsDB,ios_base::in); 73 CPPUNIT_ASSERT(tafel->LoadElementsDatabase(elementsDBstream) && "General element initialization failed"); 70 74 CPPUNIT_ASSERT(tafel->LoadValenceDatabase(new stringstream(valenceDB,ios_base::in)) && "Valence entry of element initialization failed"); 71 75 CPPUNIT_ASSERT(tafel->LoadOrbitalsDatabase(new stringstream(orbitalsDB,ios_base::in)) && "Orbitals entry of element initialization failed"); -
src/unittests/periodentafelTest.hpp
r311d688 re588312 31 31 private: 32 32 33 element *hydrogen;34 element *carbon;33 const element *hydrogen; 34 const element *carbon; 35 35 periodentafel *tafel; 36 36
Note:
See TracChangeset
for help on using the changeset viewer.