- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/FormatParserStorage.cpp
rcabb46 r73916f 36 36 37 37 #include "Helpers/Assert.hpp" 38 39 #include "molecule.hpp" 38 40 39 41 #include "Patterns/Singleton_impl.hpp" … … 224 226 * \return true - parsing ok, false - suffix unknown 225 227 */ 226 bool FormatParserStorage:: get(std::istream &input, std::string suffix)228 bool FormatParserStorage::load(std::istream &input, std::string suffix) 227 229 { 228 230 if (suffix == ParserSuffixes[mpqc]) { … … 243 245 } 244 246 247 /** Stores all selected atoms in an ostream depending on its suffix 248 * \param &output output stream 249 * \param suffix 250 * \return true - storing ok, false - suffix unknown 251 */ 252 bool FormatParserStorage::saveSelectedAtoms(std::ostream &output, std::string suffix) 253 { 254 std::vector<atom *> atoms = World::getInstance().getSelectedAtoms(); 255 return save(output, suffix, atoms); 256 } 257 258 /** Stores all selected atoms in an ostream depending on its suffix 259 * We store in the order of the atomic ids, not in the order they appear in the molecules. 260 * Hence, we first create a vector from all selected molecules' atoms. 261 * \param &output output stream 262 * \param suffix 263 * \return true - storing ok, false - suffix unknown 264 */ 265 bool FormatParserStorage::saveSelectedMolecules(std::ostream &output, std::string suffix) 266 { 267 std::vector<molecule *> molecules = World::getInstance().getSelectedMolecules(); 268 std::map<size_t, atom *> IdAtoms; 269 for (std::vector<molecule *>::const_iterator MolIter = molecules.begin(); 270 MolIter != molecules.end(); 271 ++MolIter) { 272 for(molecule::atomSet::const_iterator AtomIter = (*MolIter)->begin(); 273 AtomIter != (*MolIter)->end(); 274 ++AtomIter) { 275 IdAtoms.insert( make_pair((*AtomIter)->getId(), (*AtomIter)) ); 276 } 277 } 278 std::vector<atom *> atoms; 279 atoms.reserve(IdAtoms.size()); 280 for (std::map<size_t, atom *>::const_iterator iter = IdAtoms.begin(); 281 iter != IdAtoms.end(); 282 ++iter) { 283 atoms.push_back(iter->second); 284 } 285 return save(output, suffix, atoms); 286 } 245 287 246 288 /** Stores world in an ostream depending on its suffix … … 249 291 * \return true - storing ok, false - suffix unknown 250 292 */ 251 bool FormatParserStorage::put(std::ostream &output, std::string suffix) 293 bool FormatParserStorage::saveWorld(std::ostream &output, std::string suffix) 294 { 295 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 296 return save(output, suffix, atoms); 297 } 298 299 /** Stores a given vector of \a atoms in an ostream depending on its suffix 300 * \param &output output stream 301 * \param suffix 302 * \return true - storing ok, false - suffix unknown 303 */ 304 bool FormatParserStorage::save(std::ostream &output, std::string suffix, const std::vector<atom *> &atoms) 252 305 { 253 306 if (suffix == ParserSuffixes[mpqc]) { 254 getMpqc().save(&output );307 getMpqc().save(&output, atoms); 255 308 } else if (suffix == ParserSuffixes[pcp]) { 256 getPcp().save(&output );309 getPcp().save(&output, atoms); 257 310 } else if (suffix == ParserSuffixes[pdb]) { 258 getPdb().save(&output );311 getPdb().save(&output, atoms); 259 312 } else if (suffix == ParserSuffixes[tremolo]) { 260 getTremolo().save(&output );313 getTremolo().save(&output, atoms); 261 314 } else if (suffix == ParserSuffixes[xyz]) { 262 getXyz().save(&output );315 getXyz().save(&output, atoms); 263 316 } else { 264 317 DoeLog(1) && (eLog() << Verbose(1) << "Unknown suffix " << suffix << " to for FormatParserStorage::put()." << endl);
Note:
See TracChangeset
for help on using the changeset viewer.