Changeset 1c51c8


Ignore:
Timestamp:
Mar 3, 2010, 3:46:03 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
88d586
Parents:
dbb474
Message:

Added methods for querying molecules using descriptors

Location:
src
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • src/Makefile.am

    rdbb474 r1c51c8  
    2929LEGACYHEADER = Legacy/oldmenu.hpp
    3030
    31 DESCRIPTORSOURCE = Descriptors/AtomDescriptor.cpp Descriptors/AtomIdDescriptor.cpp Descriptors/AtomTypeDescriptor.cpp
    32 DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp Descriptors/AtomIdDescriptor.hpp Descriptors/AtomTypeDescriptor.hpp
     31DESCRIPTORSOURCE = Descriptors/AtomDescriptor.cpp Descriptors/AtomIdDescriptor.cpp Descriptors/AtomTypeDescriptor.cpp Descriptors/MoleculeDescriptor.cpp
     32DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp Descriptors/AtomIdDescriptor.hpp Descriptors/AtomTypeDescriptor.hpp Descriptors/MoleculeDescriptor.hpp
    3333
    3434SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} ${PATTERNSOURCE} ${UISOURCE} ${DESCRIPTORSOURCE} ${LEGACYSOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp info.cpp leastsquaremin.cpp linkedcell.cpp lists.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp vector.cpp verbose.cpp World.cpp WorldIterators.cpp
  • src/World.cpp

    rdbb474 r1c51c8  
    1313#include "Descriptors/AtomDescriptor.hpp"
    1414#include "Descriptors/AtomDescriptor_impl.hpp"
     15#include "Descriptors/MoleculeDescriptor.hpp"
     16#include "Descriptors/MoleculeDescriptor_impl.hpp"
    1517#include "Actions/ManipulateAtomsProcess.hpp"
    1618
     
    2224}
    2325
     26// Atoms
     27
    2428atom* World::getAtom(AtomDescriptor descriptor){
    2529  return descriptor.find();
     
    3640int World::numAtoms(){
    3741  return atoms.size();
     42}
     43
     44// Molecules
     45
     46molecule *World::getMolecule(MoleculeDescriptor descriptor){
     47  return descriptor.find();
     48}
     49
     50std::vector<molecule*> World::getAllMolecules(MoleculeDescriptor descriptor){
     51  return descriptor.findAll();
    3852}
    3953
     
    135149World::AtomSet::iterator World::atomEnd(){
    136150  return atoms.end();
     151}
     152
     153World::MoleculeIterator World::getMoleculeIter(MoleculeDescriptor descr){
     154  return MoleculeIterator(descr,this);
     155}
     156
     157World::MoleculeSet::iterator World::moleculeEnd(){
     158  return molecules.end();
    137159}
    138160
  • src/World.hpp

    rdbb474 r1c51c8  
    2727class AtomDescriptor;
    2828class AtomDescriptor_impl;
     29class MoleculeDescriptor;
     30class MoleculeDescriptor_impl;
    2931class ManipulateAtomsProcess;
    3032template<typename T>
     
    3638friend class AtomDescriptor_impl;
    3739friend class AtomDescriptor;
     40friend class MoleculeDescriptor_impl;
     41friend class MoleculeDescriptor;
    3842
    3943// Actions, calculations etc associated with the World
     
    7781
    7882  /**
     83   * returns the first molecule that matches a given descriptor.
     84   * Do not rely on ordering for descriptors that match more than one molecule.
     85   */
     86  molecule *getMolecule(MoleculeDescriptor descriptor);
     87
     88  /**
     89   * returns a vector containing all molecules that match a given descriptor
     90   */
     91  std::vector<molecule*> getAllMolecules(MoleculeDescriptor descriptor);
     92
     93  /**
    7994   * get the number of molecules in the World
    8095   */
     
    125140protected:
    126141  /**** Iterators to use internal data structures */
     142
     143  // Atoms
     144
    127145  class AtomIterator {
    128146  public:
     
    163181  AtomSet::iterator atomEnd();
    164182
     183  // Molecules
     184
     185  class MoleculeIterator {
     186  public:
     187    MoleculeIterator();
     188    MoleculeIterator(MoleculeDescriptor, World*);
     189    MoleculeIterator(const MoleculeIterator&);
     190    MoleculeIterator& operator=(const MoleculeIterator&);
     191    MoleculeIterator& operator++();     // prefix
     192    MoleculeIterator  operator++(int);  // postfix with dummy parameter
     193    bool operator==(const MoleculeIterator&);
     194    bool operator==(const MoleculeSet::iterator&);
     195    bool operator!=(const MoleculeIterator&);
     196    bool operator!=(const MoleculeSet::iterator&);
     197    molecule* operator*();
     198
     199    int getCount();
     200  protected:
     201    void advanceState();
     202    MoleculeSet::iterator state;
     203    boost::shared_ptr<MoleculeDescriptor_impl>  descr;
     204    int index;
     205
     206    World* world;
     207  };
     208
     209  /**
     210   * returns an iterator over all Molecules matching a given descriptor.
     211   * used for internal purposes, like MoleculeProcesses and MoleculeCalculations.
     212   */
     213  MoleculeIterator getMoleculeIter(MoleculeDescriptor descr);
     214
     215  /**
     216   * returns an iterator to the end of the MoleculeSet. Due to overloading this iterator
     217   * can be compared to iterators produced by getMoleculeIter (see the mis-matching types).
     218   * Thus it can be used to detect when such an iterator is at the end of the list.
     219   * used for internal purposes, like MoleculeProcesses and MoleculeCalculations.
     220   */
     221  MoleculeSet::iterator moleculeEnd();
     222
     223
    165224  /******* Internal manipulation routines for double callback and Observer mechanism ******/
    166225  void doManipulate(ManipulateAtomsProcess *);
  • src/WorldIterators.cpp

    rdbb474 r1c51c8  
    88#include "Descriptors/AtomDescriptor.hpp"
    99#include "Descriptors/AtomDescriptor_impl.hpp"
     10#include "Descriptors/MoleculeDescriptor.hpp"
     11#include "Descriptors/MoleculeDescriptor_impl.hpp"
    1012#include "atom.hpp"
     13#include "molecule.hpp"
    1114#include "World.hpp"
     15
     16/********************** Atoms *************************/
    1217
    1318World::AtomIterator::AtomIterator(){
     
    7681
    7782void World::AtomIterator::advanceState(){
     83  // go forward until we have a matching atom or the end is reached
    7884  while((state!=world->atoms.end()) && (!descr->predicate(*state))){
    7985    ++state;
     
    8591  return index;
    8692}
     93
     94/*********************************** Molecules ************************/
     95
     96World::MoleculeIterator::MoleculeIterator(){
     97  state = World::get()->moleculeEnd();
     98}
     99
     100World::MoleculeIterator::MoleculeIterator(MoleculeDescriptor _descr, World* _world) :
     101    descr(_descr.get_impl()),
     102    index(0),
     103    world(_world)
     104{
     105  state = world->molecules.begin();
     106  advanceState();
     107}
     108
     109World::MoleculeIterator::MoleculeIterator(const MoleculeIterator& rhs) :
     110    state(rhs.state),
     111    descr(rhs.descr),
     112    index(rhs.index),
     113    world(rhs.world)
     114  {}
     115
     116World::MoleculeIterator& World::MoleculeIterator::operator=(const MoleculeIterator& rhs)
     117{
     118  if(&rhs!=this){
     119    state=rhs.state;
     120    descr=rhs.descr;
     121    index=rhs.index;
     122    world=rhs.world;
     123  }
     124  return *this;
     125}
     126
     127World::MoleculeIterator& World::MoleculeIterator::operator++(){
     128  ++state;
     129  ++index;
     130  advanceState();
     131  return *this;
     132}
     133
     134World::MoleculeIterator World::MoleculeIterator::operator++(int){
     135  MoleculeIterator res(*this);
     136  ++(*this);
     137  return res;
     138}
     139
     140bool World::MoleculeIterator::operator==(const MoleculeIterator& rhs){
     141  return state==rhs.state;
     142}
     143
     144bool World::MoleculeIterator::operator==(const World::MoleculeSet::iterator& rhs){
     145  return state==rhs;
     146}
     147
     148bool World::MoleculeIterator::operator!=(const MoleculeIterator& rhs){
     149  return state!=rhs.state;
     150}
     151
     152bool World::MoleculeIterator::operator!=(const World::MoleculeSet::iterator& rhs){
     153  return state!=rhs;
     154}
     155
     156molecule* World::MoleculeIterator::operator*(){
     157  return (*state).second;
     158}
     159
     160void World::MoleculeIterator::advanceState(){
     161  while((state!=world->molecules.end()) && (!descr->predicate(*state))){
     162    ++state;
     163    ++index;
     164  }
     165}
     166
     167int World::MoleculeIterator::getCount(){
     168  return index;
     169}
     170
  • src/molecule_template.hpp

    rdbb474 r1c51c8  
    1616#endif
    1717
     18#include "atom.hpp"
    1819/********************************************** declarations *******************************/
    1920
Note: See TracChangeset for help on using the changeset viewer.