Changeset 55736b for src


Ignore:
Timestamp:
Sep 15, 2014, 2:22:29 PM (11 years ago)
Author:
Frederik Heber <heber@…>
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, Candidate_v1.7.0, Candidate_v1.7.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:
b73545
Parents:
29b35e (diff), 5a9f4c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'Cleanup_old_code' into stable

Location:
src
Files:
16 added
9 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FillAction/FillRegularGridAction.cpp

    r29b35e r55736b  
    4444#include "Filling/Cluster.hpp"
    4545#include "Filling/Filler.hpp"
    46 #include "Filling/Inserter/Inserter.hpp"
    47 #include "Filling/Inserter/RandomInserter.hpp"
    48 #include "Filling/Mesh/CubeMesh.hpp"
    49 #include "Filling/Predicates/IsInsideSurface_FillPredicate.hpp"
    50 #include "Filling/Predicates/IsVoidNode_FillPredicate.hpp"
    51 #include "Filling/Predicates/Ops_FillPredicate.hpp"
    52 #include "LinkedCell/linkedcell.hpp"
    53 #include "LinkedCell/PointCloudAdaptor.hpp"
     46#include "Filling/Preparators/BoxFillerPreparator.hpp"
    5447#include "molecule.hpp"
    5548#include "MoleculeListClass.hpp"
    5649#include "Parser/FormatParserInterface.hpp"
    5750#include "Parser/FormatParserStorage.hpp"
    58 #include "Shapes/BaseShapes.hpp"
    59 #include "Tesselation/tesselation.hpp"
    60 #include "Tesselation/BoundaryLineSet.hpp"
    61 #include "Tesselation/BoundaryTriangleSet.hpp"
    62 #include "Tesselation/CandidateForTesselation.hpp"
    6351#include "World.hpp"
    64 
    6552
    6653#include <algorithm>
     
    9279  LOG(1, "INFO: Chosen molecule has " << filler->size() << " atoms.");
    9380
    94   // check for selected molecules and create surfaces from them
    95   std::vector<atom *> atoms(World::getInstance().getSelectedAtoms());
    96   FillPredicate * surface_predicate = NULL;
    97   LinkedCell_deprecated * LC = NULL;
    98   Tesselation * TesselStruct = NULL;
     81  // center filler's tip at origin
     82  filler->CenterEdge();
     83
     84  // prepare the filler preparator
     85  BoxFillerPreparator filler_preparator(filler);
    9986  if (params.SphereRadius.get() != 0.) {
    100     if ( atoms.size() == 0) {
     87    if (World::getInstance().beginAtomSelection() == World::getInstance().endAtomSelection()) {
    10188      STATUS("You have given a sphere radius "+toString(params.SphereRadius.get())
    10289          +" != 0, but have not select any atoms.");
    10390      return Action::failure;
    10491    }
    105     // create adaptor for the selected atoms
    106     PointCloudAdaptor< std::vector<atom *> > cloud(&atoms, std::string("Selected atoms"));
    107 
    108     // create tesselation
    109     LC = new LinkedCell_deprecated(cloud, 2.*params.SphereRadius.get());
    110     TesselStruct = new Tesselation;
    111     (*TesselStruct)(cloud, params.SphereRadius.get());
    112 
    113     // and create predicate
    114     surface_predicate = new FillPredicate( IsInsideSurface_FillPredicate( *TesselStruct, *LC ) );
    115   }
    116 
    117   // create predicate, mesh, and filler
     92    std::vector<atom*> atoms(World::getInstance().getSelectedAtoms());
     93    filler_preparator.addSurfacePredicate(
     94        params.SphereRadius.get(),
     95        atoms);
     96  }
     97  filler_preparator.addVoidPredicate(params.mindistance.get());
     98  filler_preparator.addRandomInserter(
     99      params.RandAtomDisplacement.get(),
     100      params.RandMoleculeDisplacement.get(),
     101      params.DoRotate.get());
     102  filler_preparator.addCubeMesh(
     103      params.counts.get(),
     104      params.offset.get(),
     105      World::getInstance().getDomain().getM());
     106  if (!filler_preparator()) {
     107    STATUS("Filler was not fully constructed.");
     108    return Action::failure;
     109  }
     110
     111  // use filler
     112  bool successflag = false;
    118113  FillRegularGridState *UndoState = NULL;
    119   bool successflag = false;
    120114  {
    121     FillPredicate *voidnode_predicate = new FillPredicate(
    122         IsVoidNode_FillPredicate(
    123             Sphere(zeroVec, params.mindistance.get())
    124             )
    125         );
    126     FillPredicate Andpredicate = (*voidnode_predicate);
    127     if (surface_predicate != NULL)
    128       Andpredicate = (Andpredicate) && !(*surface_predicate);
    129     Mesh *mesh = new CubeMesh(params.counts.get(), params.offset.get(), World::getInstance().getDomain().getM());
    130     Inserter *inserter = new Inserter(
    131         Inserter::impl_ptr(
    132             new RandomInserter(
    133                 params.RandAtomDisplacement.get(),
    134                 params.RandMoleculeDisplacement.get(),
    135                 params.DoRotate.get())
    136             )
    137         );
    138 
    139115    // fill
    140     {
    141       Filler *fillerFunction = new Filler(*mesh, Andpredicate, *inserter);
    142       // TODO: When molecule::getBoundingSphere() does not use a sphere anymore,
    143       // we need to check whether we rotate the molecule randomly. For this to
    144       // work we need a sphere!
    145       const Shape s = filler->getBoundingSphere(params.RandAtomDisplacement.get());
    146       ClusterInterface::Cluster_impl cluster( new Cluster(filler->getAtomIds(), s) );
    147       CopyAtoms_withBonds copyMethod;
    148       Filler::ClusterVector_t ClonedClusters;
    149       successflag = (*fillerFunction)(copyMethod, cluster, ClonedClusters);
    150       delete fillerFunction;
    151 
    152       // append each cluster's atoms to clonedatoms (however not selected ones)
    153       std::vector<const atom *> clonedatoms;
    154       std::vector<AtomicInfo> clonedatominfos;
    155       for (Filler::ClusterVector_t::const_iterator iter = ClonedClusters.begin();
    156           iter != ClonedClusters.end(); ++iter) {
    157         const AtomIdSet &atoms = (*iter)->getAtomIds();
    158         clonedatoms.reserve(clonedatoms.size()+atoms.size());
    159         for (AtomIdSet::const_iterator atomiter = atoms.begin(); atomiter != atoms.end(); ++atomiter)
    160           if (!filler->containsAtom(*atomiter)) {
    161             clonedatoms.push_back( *atomiter );
    162             clonedatominfos.push_back( AtomicInfo(*(*atomiter)) );
    163           }
    164       }
    165       std::vector< BondInfo > clonedbonds;
    166       StoreBondInformationFromAtoms(clonedatoms, clonedbonds);
    167       LOG(2, "DEBUG: There are " << clonedatominfos.size() << " newly created atoms.");
    168 
    169       if (!successflag) {
    170         STATUS("Insertion failed, removing inserted clusters, translating original one back");
    171         RemoveAtomsFromAtomicInfo(clonedatominfos);
    172         clonedatoms.clear();
    173         SetAtomsFromAtomicInfo(movedatoms);
    174       } else {
    175         std::vector<Vector> MovedToVector(filler->size(), zeroVec);
    176         std::transform(filler->begin(), filler->end(), MovedToVector.begin(),
    177             boost::bind(&AtomInfo::getPosition, _1) );
    178         UndoState = new FillRegularGridState(clonedatominfos,clonedbonds,movedatoms,MovedToVector,params);
    179       }
     116    Filler *fillerFunction = filler_preparator.obtainFiller();
     117    // TODO: When molecule::getBoundingSphere() does not use a sphere anymore,
     118    // we need to check whether we rotate the molecule randomly. For this to
     119    // work we need a sphere!
     120    const Shape s = filler->getBoundingSphere(params.RandAtomDisplacement.get());
     121    ClusterInterface::Cluster_impl cluster( new Cluster(filler->getAtomIds(), s) );
     122    CopyAtoms_withBonds copyMethod;
     123    Filler::ClusterVector_t ClonedClusters;
     124    successflag = (*fillerFunction)(copyMethod, cluster, ClonedClusters);
     125    delete fillerFunction;
     126
     127    // append each cluster's atoms to clonedatoms (however not selected ones)
     128    std::vector<const atom *> clonedatoms;
     129    std::vector<AtomicInfo> clonedatominfos;
     130    for (Filler::ClusterVector_t::const_iterator iter = ClonedClusters.begin();
     131        iter != ClonedClusters.end(); ++iter) {
     132      const AtomIdSet &atoms = (*iter)->getAtomIds();
     133      clonedatoms.reserve(clonedatoms.size()+atoms.size());
     134      for (AtomIdSet::const_iterator atomiter = atoms.begin(); atomiter != atoms.end(); ++atomiter)
     135        if (!filler->containsAtom(*atomiter)) {
     136          clonedatoms.push_back( *atomiter );
     137          clonedatominfos.push_back( AtomicInfo(*(*atomiter)) );
     138        }
    180139    }
    181 
    182     // remove
    183     delete mesh;
    184     delete inserter;
    185     delete voidnode_predicate;
    186     delete surface_predicate;
    187     delete LC;
    188     delete TesselStruct;
     140    std::vector< BondInfo > clonedbonds;
     141    StoreBondInformationFromAtoms(clonedatoms, clonedbonds);
     142    LOG(2, "DEBUG: There are " << clonedatominfos.size() << " newly created atoms.");
     143
     144    if (!successflag) {
     145      STATUS("Insertion failed, removing inserted clusters, translating original one back");
     146      RemoveAtomsFromAtomicInfo(clonedatominfos);
     147      clonedatoms.clear();
     148      SetAtomsFromAtomicInfo(movedatoms);
     149    } else {
     150      std::vector<Vector> MovedToVector(filler->size(), zeroVec);
     151      std::transform(filler->begin(), filler->end(), MovedToVector.begin(),
     152          boost::bind(&AtomInfo::getPosition, _1) );
     153      UndoState = new FillRegularGridState(clonedatominfos,clonedbonds,movedatoms,MovedToVector,params);
     154    }
    189155  }
    190156
  • src/Actions/FillAction/FillSurfaceAction.cpp

    r29b35e r55736b  
    4646#include "Filling/Mesh/MeshAdaptor.hpp"
    4747#include "Filling/Predicates/IsVoidNode_FillPredicate.hpp"
     48#include "Filling/Preparators/ShapeSurfaceFillerPreparator.hpp"
    4849#include "molecule.hpp"
    4950#include "Shapes/BaseShapes.hpp"
    5051#include "Shapes/ShapeRegistry.hpp"
     52#include "Shapes/ShapeType.hpp"
    5153#include "World.hpp"
    5254
     
    8183
    8284  // center filler's tip at origin
    83   Vector max;
    84   filler->CenterEdge(&max);
     85  filler->CenterEdge();
    8586
    8687  // determine center with respect to alignment axis
     
    9697  {
    9798    Vector translater = -1.*sum;
    98     filler->Translate(&translater);
    99   }
    100 
    101   // create predicate, mesh, and filler
    102   FillSurfaceState *UndoState = NULL;
    103   bool successflag = false;
    104   {
    105     FillPredicate *voidnode_predicate = new FillPredicate(
    106         IsVoidNode_FillPredicate(
    107             Sphere(zeroVec, params.mindistance.get())
    108             )
    109         );
    110 
    111 
    112     std::vector<Shape*> selectedShapes = ShapeRegistry::getInstance().getSelectedShapes();
    113     if (selectedShapes.size() != 1){
    114       STATUS("There has to be exactly 1 selected shape.");
     99    filler->Translate(translater);
     100  }
     101
     102  // prepare the filler preparator
     103  if (ShapeRegistry::getInstance().countSelectedShapes() != (size_t)1) {
     104    STATUS("Not exactly one shape selected.");
     105    return Action::failure;
     106  }
     107  const std::vector<Shape*> shapes = ShapeRegistry::getInstance().getSelectedShapes();
     108  const Shape &shape = **shapes.begin();
     109
     110  // hard check whether shape is of allowed type, not all are implemented
     111  // but these only fail with an assertion, hence not with disable-debug
     112  switch (shape.getType()) {
     113    case NowhereType:
     114    case EverywhereType:
     115      STATUS("The shape type "+toString(shape.getType())+" is currently not supported.");
     116      return Action::failure;
     117      break;
     118    default:
     119      break;
     120  }
     121
     122  ShapeSurfaceFillerPreparator filler_preparator(filler);
     123  if (params.SphereRadius.get() != 0.) {
     124    if (World::getInstance().beginAtomSelection() == World::getInstance().endAtomSelection()) {
     125      STATUS("You have given a sphere radius "+toString(params.SphereRadius.get())
     126          +" != 0, but have not select any atoms.");
    115127      return Action::failure;
    116128    }
    117 
    118     boost::function<const NodeSet ()> func =
    119         boost::bind(&Shape::getHomogeneousPointsOnSurface, boost::ref(*selectedShapes[0]), params.N.get());
    120     Mesh *mesh = new MeshAdaptor(func);
    121     Inserter *inserter = new Inserter(
    122         Inserter::impl_ptr(new SurfaceInserter(*selectedShapes[0], params.AlignedAxis.get())));
    123 
     129    std::vector<atom*> atoms(World::getInstance().getSelectedAtoms());
     130    filler_preparator.addSurfacePredicate(
     131        params.SphereRadius.get(),
     132        atoms);
     133  }
     134  filler_preparator.addVoidPredicate(params.mindistance.get());
     135  filler_preparator.addSurfaceRandomInserter(
     136      shape,
     137      params.AlignedAxis.get(),
     138      params.RandAtomDisplacement.get(),
     139      params.RandMoleculeDisplacement.get());
     140  filler_preparator.addShapeMesh(
     141      shape,
     142      params.N.get());
     143  if (!filler_preparator()) {
     144    STATUS("Filler was not fully constructed.");
     145    return Action::failure;
     146  }
     147
     148  // use filler
     149  bool successflag = false;
     150  FillSurfaceState *UndoState = NULL;
     151  {
    124152    // fill
    125153    {
    126       Filler *fillerFunction = new Filler(*mesh, *voidnode_predicate, *inserter);
     154      Filler *fillerFunction = filler_preparator.obtainFiller();
    127155      ClusterInterface::Cluster_impl cluster( new Cluster( filler->getAtomIds(), filler->getBoundingSphere() ) );
    128156      CopyAtoms_withBonds copyMethod;
     
    161189      }
    162190    }
    163 
    164     // remove
    165     delete mesh;
    166     delete inserter;
    167     delete voidnode_predicate;
    168191  }
    169192
  • src/Actions/FillAction/FillSurfaceAction.def

    r29b35e r55736b  
    2020// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    2121// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
    22 #define paramtypes (unsigned int)(double)(Vector)
    23 #define paramtokens ("count")("min-distance")("Alignment-Axis")
    24 #define paramdescriptions ("number of instances to be added, changed according to geometric needs")("minimum distance between added instances")("The filler molecule is rotated relative to this alignment axis")
    25 #define paramdefaults (PARAM_DEFAULT(12))(PARAM_DEFAULT(1.))(NOPARAM_DEFAULT)
    26 #define paramreferences (N)(mindistance)(AlignedAxis)
     22#define paramtypes (unsigned int)(double)(double)(double)(double)(Vector)
     23#define paramtokens ("count")("min-distance")("tesselation-radius")("random-atom-displacement")("random-molecule-displacement")("Alignment-Axis")
     24#define paramdescriptions ("number of instances to be added, changed according to geometric needs")("minimum distance between added instances")("radius of rolling sphere in tesselating selected molecule's surfaces")("magnitude of random atom displacement")("magnitude of random molecule displacement")("The filler molecule is rotated relative to this alignment axis")
     25#define paramdefaults (PARAM_DEFAULT(12))(PARAM_DEFAULT(1.))(PARAM_DEFAULT(0.))(PARAM_DEFAULT(0.))(PARAM_DEFAULT(0.))(NOPARAM_DEFAULT)
     26#define paramreferences (N)(mindistance)(SphereRadius)(RandAtomDisplacement)(RandMoleculeDisplacement)(AlignedAxis)
    2727#define paramvalids \
    2828(DummyValidator< unsigned int >()) \
     29(BoxLengthValidator()) \
     30(BoxLengthValidator()) \
     31(BoxLengthValidator()) \
    2932(BoxLengthValidator()) \
    3033(VectorNotZeroValidator())
     
    3639#define CATEGORY Fill
    3740#define MENUNAME "fill"
    38 #define MENUPOSITION 1
     41#define MENUPOSITION 2
    3942#define ACTIONNAME Surface
    4043#define TOKEN "fill-surface"
  • src/Actions/GlobalListOfActions.hpp

    r29b35e r55736b  
    5050  (FillRegularGrid) \
    5151  (FillSurface) \
     52  (FillSuspendInMolecule) \
     53  (FillVolume) \
    5254  (FragmentationAnalyseFragmentationResults) \
    5355  (FragmentationClearFragmentationResults) \
     
    6870  (MoleculeChangeBondAngle) \
    6971  (MoleculeCopy) \
    70   (MoleculeFillWithMolecule) \
    71   (MoleculeFillVoidWithMolecule) \
    7272  (MoleculeForceAnnealing) \
    7373  (MoleculeLinearInterpolationofTrajectories) \
     
    8080  (MoleculeSaveTemperature) \
    8181  (MoleculeStretchBond) \
    82   (MoleculeSuspendInWater) \
    8382  (MoleculeVerletIntegration) \
    8483  (PotentialFitParticleCharges) \
  • src/Actions/Makefile.am

    r29b35e r55736b  
    215215FILLACTIONSOURCE = \
    216216        Actions/FillAction/FillRegularGridAction.cpp \
    217         Actions/FillAction/FillSurfaceAction.cpp
     217        Actions/FillAction/FillSurfaceAction.cpp \
     218        Actions/FillAction/SuspendInMoleculeAction.cpp \
     219        Actions/FillAction/FillVolumeAction.cpp
    218220FILLACTIONHEADER = \
    219221        Actions/FillAction/FillRegularGridAction.hpp \
    220         Actions/FillAction/FillSurfaceAction.hpp
     222        Actions/FillAction/FillSurfaceAction.hpp \
     223        Actions/FillAction/SuspendInMoleculeAction.hpp \
     224        Actions/FillAction/FillVolumeAction.hpp
    221225FILLACTIONDEFS = \
    222226        Actions/FillAction/FillRegularGridAction.def \
    223         Actions/FillAction/FillSurfaceAction.def
     227        Actions/FillAction/FillSurfaceAction.def \
     228        Actions/FillAction/SuspendInMoleculeAction.def \
     229        Actions/FillAction/FillVolumeAction.def
    224230
    225231
     
    279285  Actions/MoleculeAction/ChangeNameAction.cpp \
    280286  Actions/MoleculeAction/CopyAction.cpp \
    281   Actions/MoleculeAction/FillWithMoleculeAction.cpp \
    282   Actions/MoleculeAction/FillVoidWithMoleculeAction.cpp \
    283287  Actions/MoleculeAction/ForceAnnealingAction.cpp \
    284288  Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp \
     
    291295  Actions/MoleculeAction/SaveTemperatureAction.cpp \
    292296  Actions/MoleculeAction/StretchBondAction.cpp \
    293   Actions/MoleculeAction/SuspendInWaterAction.cpp \
    294297  Actions/MoleculeAction/VerletIntegrationAction.cpp
    295298MOLECULEACTIONHEADER = \
     
    298301  Actions/MoleculeAction/ChangeNameAction.hpp \
    299302  Actions/MoleculeAction/CopyAction.hpp \
    300   Actions/MoleculeAction/FillWithMoleculeAction.hpp \
    301   Actions/MoleculeAction/FillVoidWithMoleculeAction.hpp \
    302303  Actions/MoleculeAction/ForceAnnealingAction.hpp \
    303304  Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp \
     
    310311  Actions/MoleculeAction/SaveTemperatureAction.hpp \
    311312  Actions/MoleculeAction/StretchBondAction.hpp \
    312   Actions/MoleculeAction/SuspendInWaterAction.hpp \
    313313  Actions/MoleculeAction/VerletIntegrationAction.hpp
    314314MOLECULEACTIONDEFS = \
     
    317317  Actions/MoleculeAction/ChangeNameAction.def \
    318318  Actions/MoleculeAction/CopyAction.def \
    319   Actions/MoleculeAction/FillWithMoleculeAction.def \
    320   Actions/MoleculeAction/FillVoidWithMoleculeAction.def \
    321319  Actions/MoleculeAction/ForceAnnealingAction.def \
    322320  Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.def \
     
    329327  Actions/MoleculeAction/SaveTemperatureAction.def \
    330328  Actions/MoleculeAction/StretchBondAction.def \
    331   Actions/MoleculeAction/SuspendInWaterAction.def \
    332329  Actions/MoleculeAction/VerletIntegrationAction.def
    333330
  • src/Actions/MoleculeAction/CopyAction.cpp

    r29b35e r55736b  
    6363      iter != World::getInstance().endMoleculeSelection(); ++iter) {
    6464    molecule * const copy = (iter->second)->CopyMolecule();
    65     Vector *Center = (iter->second)->DetermineCenterOfAll();
    66     *Center *= -1.;
    67     *Center += params.position.get();
     65    Vector Center = (iter->second)->DetermineCenterOfAll();
     66    Center *= -1.;
     67    Center += params.position.get();
    6868    copy->Translate(Center);
    69     delete(Center);
    7069    molecules.push_back(copy->getId());
    7170  }
  • src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp

    r29b35e r55736b  
    7474
    7575    // Creation Line that is the rotation axis
    76     Vector *CenterOfGravity = mol->DetermineCenterOfGravity();
    77     LOG(0,  "Center of gravity is " << *CenterOfGravity << ".");
    78     Line RotationAxis(*CenterOfGravity, params.Axis.get());
    79     delete(CenterOfGravity);
     76    const Vector CenterOfGravity = mol->DetermineCenterOfGravity();
     77    LOG(0,  "Center of gravity is " << CenterOfGravity << ".");
     78    Line RotationAxis(CenterOfGravity, params.Axis.get());
    8079    LOG(0, "Rotate " << mol->getName() << " around self by " << params.angle.get() << " radian around axis " << RotationAxis << ".");
    8180
     
    9392
    9493  BOOST_FOREACH(molecule *mol, state->selectedMolecules) {
    95     Vector *CenterOfGravity = mol->DetermineCenterOfGravity();
    96     LOG(0,  "Center of gravity is " << *CenterOfGravity << ".");
    97     Line RotationAxis(*CenterOfGravity, state->params.Axis.get());
    98     delete(CenterOfGravity);
     94    const Vector CenterOfGravity = mol->DetermineCenterOfGravity();
     95    LOG(0,  "Center of gravity is " <<CenterOfGravity << ".");
     96    Line RotationAxis(CenterOfGravity, state->params.Axis.get());
    9997    LOG(0, "Rotate " << mol->getName() << " around self by " << -state->params.angle.get() << " radian around axis " << RotationAxis << ".");
    10098
     
    111109
    112110  BOOST_FOREACH(molecule *mol, state->selectedMolecules) {
    113     Vector *CenterOfGravity = mol->DetermineCenterOfGravity();
    114     LOG(0,  "Center of gravity is " << *CenterOfGravity << ".");
    115     Line RotationAxis(*CenterOfGravity, state->params.Axis.get());
    116     delete(CenterOfGravity);
     111    const Vector CenterOfGravity = mol->DetermineCenterOfGravity();
     112    LOG(0,  "Center of gravity is " << CenterOfGravity << ".");
     113    Line RotationAxis(CenterOfGravity, state->params.Axis.get());
    117114    LOG(0, "Rotate " << mol->getName() << " around self by " << state->params.angle.get() << " radian around axis " << RotationAxis << ".");
    118115
  • src/Analysis/unittests/CountBondsUnitTest.cpp

    r29b35e r55736b  
    148148void CountBondsTest::HydrogenBridgeBondsTest()
    149149{
    150   double *mirror = new double[3];
     150  double mirror[3];
    151151  CPPUNIT_ASSERT(mirror != NULL && "could not create array of doubles");
    152152  for (int i=0;i<3;i++)
     
    161161  cout << "Case 1: offset of (3,0,0), hence angles are (104.5, 0, 75.5, 180) < 30." << endl;
    162162  Translator  = Vector(3,0,0);
    163   TestMolecule1->Translate(&Translator);
     163  TestMolecule1->Translate(Translator);
    164164  CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    165165  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, oxygen, NULL) );
    166166  Translator = Vector(-3,0,0);
    167   TestMolecule1->Translate(&Translator);
     167  TestMolecule1->Translate(Translator);
    168168
    169169  cout << "Case 2: offset of (0,3,0), hence angle are (14.5, 165.5, 90) < 30 (only three, because other 90 is missing due to first H01 only fulfilling H-bond criteria)." << endl;
    170170  Translator = Vector(0,3,0);
    171   TestMolecule1->Translate(&Translator);
     171  TestMolecule1->Translate(Translator);
    172172  CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    173173  Translator = Vector(0,-3,0);
    174   TestMolecule1->Translate(&Translator);
     174  TestMolecule1->Translate(Translator);
    175175
    176176  cout << "Case 3: offset of (0,-3,0) and mirror, hence angle are (165.5, 90, 165.5, 90) > 30." << endl;
    177177  Translator = Vector(0,-3,0);
    178   TestMolecule1->Scale((const double ** const)&mirror);
    179   TestMolecule1->Translate(&Translator);
     178  TestMolecule1->Scale(&mirror[0]);
     179  TestMolecule1->Translate(Translator);
    180180  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    181181  Translator = Vector(0,3,0);
    182   TestMolecule1->Translate(&Translator);
    183   TestMolecule1->Scale((const double ** const)&mirror);
     182  TestMolecule1->Translate(Translator);
     183  TestMolecule1->Scale(&mirror[0]);
    184184
    185185  cout << "Case 4: offset of (2,1,0), hence angle are (78, 26.6, 102, 153.4) < 30." << endl;
    186186  Translator = Vector(2,1,0);
    187   TestMolecule1->Translate(&Translator);
     187  TestMolecule1->Translate(Translator);
    188188  CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    189189  Translator = Vector(-2,-1,0);
    190   TestMolecule1->Translate(&Translator);
     190  TestMolecule1->Translate(Translator);
    191191
    192192  cout << "Case 5: offset of (0,0,3), hence angle are (90, 90, 90, 90) > 30." << endl;
    193193  Translator = Vector(0,0,3);
    194   TestMolecule1->Translate(&Translator);
     194  TestMolecule1->Translate(Translator);
    195195  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    196196  Translator = Vector(0,0,-3);
    197   TestMolecule1->Translate(&Translator);
     197  TestMolecule1->Translate(Translator);
    198198
    199199  cout << "Case 6: offset of (-3,0,0) and mirror, hence angle are (75.5, 180, 104.5, 180) > 30." << endl;
    200200  Translator = Vector(-3,0,0);
    201   TestMolecule1->Scale((const double ** const)&mirror);
    202   TestMolecule1->Translate(&Translator);
     201  TestMolecule1->Scale(&mirror[0]);
     202  TestMolecule1->Translate(Translator);
    203203  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    204204  Translator = Vector(3,0,0);
    205   TestMolecule1->Translate(&Translator);
    206   TestMolecule1->Scale((const double ** const)&mirror);
     205  TestMolecule1->Translate(Translator);
     206  TestMolecule1->Scale(&mirror[0]);
    207207
    208208  cout << "Case 7: offset of (3,0,0) and mirror, hence angles are (104.5, 0, 104.5, 0) < 30, but interfering hydrogens." << endl;
    209209  Translator = Vector(3,0,0);
    210   TestMolecule1->Scale((const double ** const)&mirror);
    211   TestMolecule1->Translate(&Translator);
     210  TestMolecule1->Scale(&mirror[0]);
     211  TestMolecule1->Translate(Translator);
    212212  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    213213  Translator = Vector(-3,0,0);
    214   TestMolecule1->Translate(&Translator);
    215   TestMolecule1->Scale((const double ** const)&mirror);
     214  TestMolecule1->Translate(Translator);
     215  TestMolecule1->Scale(&mirror[0]);
    216216
    217217  cout << "Case 8: offset of (0,3,0), hence angle are (14.5, 90, 14.5, 90) < 30, but interfering hydrogens." << endl;
    218218  Translator = Vector(0,3,0);
    219   TestMolecule1->Scale((const double ** const)&mirror);
    220   TestMolecule1->Translate(&Translator);
     219  TestMolecule1->Scale(&mirror[0]);
     220  TestMolecule1->Translate(Translator);
    221221  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    222222  Translator = Vector(0,-3,0);
    223   TestMolecule1->Translate(&Translator);
    224   TestMolecule1->Scale((const double ** const)&mirror);
    225 
    226   delete[](mirror);
    227 };
     223  TestMolecule1->Translate(Translator);
     224  TestMolecule1->Scale(&mirror[0]);
     225};
  • src/Filling/Makefile.am

    r29b35e r55736b  
    1313        Filling/Inserter/SimpleInserter.cpp \
    1414        Filling/Inserter/SurfaceInserter.cpp \
     15        Filling/Inserter/SurfaceRandomInserter.cpp \
    1516        Filling/Predicates/AnyFillPredicate.cpp \
    1617        Filling/Predicates/FillPredicate.cpp \
     
    1920        Filling/Predicates/IsValidInDomain_FillPredicate.cpp \
    2021        Filling/Predicates/IsVoidNode_FillPredicate.cpp \
    21         Filling/Predicates/Ops_FillPredicate.cpp
     22        Filling/Predicates/Ops_FillPredicate.cpp \
     23        Filling/Preparators/BaseFillerPreparator.cpp \
     24        Filling/Preparators/BoxFillerPreparator.cpp \
     25        Filling/Preparators/ShapeSurfaceFillerPreparator.cpp \
     26        Filling/Preparators/ShapeVolumeFillerPreparator.cpp
    2227       
    2328FILLINGHEADER = \
     
    3439        Filling/Inserter/SimpleInserter.hpp \
    3540        Filling/Inserter/SurfaceInserter.hpp \
     41        Filling/Inserter/SurfaceRandomInserter.hpp \
    3642        Filling/NodeTypes.hpp \
    3743        Filling/Predicates/AnyFillPredicate.hpp \
     
    4450        Filling/Predicates/IsVoidNode_FillPredicate.hpp \
    4551        Filling/Predicates/Ops_FillPredicate.hpp \
    46         Filling/Predicates/Ops_FillPredicate_impl.hpp
    47                                  
     52        Filling/Predicates/Ops_FillPredicate_impl.hpp \
     53        Filling/Preparators/BaseFillerPreparator.hpp \
     54        Filling/Preparators/BoxFillerPreparator.hpp \
     55        Filling/Preparators/ShapeSurfaceFillerPreparator.hpp \
     56        Filling/Preparators/ShapeVolumeFillerPreparator.hpp
    4857
    4958noinst_LTLIBRARIES += libMolecuilderFilling.la
  • src/Filling/Mesh/MeshAdaptor.hpp

    r29b35e r55736b  
    1818
    1919#include "Filling/NodeTypes.hpp"
     20#include "Filling/Mesh/Mesh.hpp"
    2021
    2122class MeshAdaptor : public Mesh
  • src/Tesselation/boundary.cpp

    r29b35e r55736b  
    183183  LineMap LinesOnBoundary;
    184184  TriangleMap TrianglesOnBoundary;
    185   Vector *MolCenter = mol->DetermineCenterOfAll();
     185  Vector MolCenter = mol->DetermineCenterOfAll();
    186186  Vector helper;
    187187  BoundariesTestPair BoundaryTestPair;
     
    207207    // Boundaries stores non-const TesselPoint ref, hence we need iterator here
    208208    for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    209       ProjectedVector = (*iter)->getPosition() - (*MolCenter);
     209      ProjectedVector = (*iter)->getPosition() - (MolCenter);
    210210      ProjectedVector.ProjectOntoPlane(AxisVector);
    211211
     
    233233          LOG(2, "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << ".");
    234234        } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) {
    235           helper = (*iter)->getPosition() - (*MolCenter);
     235          helper = (*iter)->getPosition() - (MolCenter);
    236236          const double oldhelperNorm = helper.NormSquared();
    237           helper = BoundaryTestPair.first->second.second->getPosition() - (*MolCenter);
     237          helper = BoundaryTestPair.first->second.second->getPosition() - (MolCenter);
    238238          if (helper.NormSquared() < oldhelperNorm) {
    239239            BoundaryTestPair.first->second.second = (*iter);
     
    289289        {
    290290          Vector SideA, SideB, SideC, SideH;
    291           SideA = left->second.second->getPosition() - (*MolCenter);
     291          SideA = left->second.second->getPosition() - (MolCenter);
    292292          SideA.ProjectOntoPlane(AxisVector);
    293293          //          LOG(1, "SideA: " << SideA);
    294294
    295           SideB = right->second.second->getPosition() -(*MolCenter);
     295          SideB = right->second.second->getPosition() -(MolCenter);
    296296          SideB.ProjectOntoPlane(AxisVector);
    297297          //          LOG(1, "SideB: " << SideB);
     
    301301          //          LOG(1, "SideC: " << SideC);
    302302
    303           SideH = runner->second.second->getPosition() -(*MolCenter);
     303          SideH = runner->second.second->getPosition() -(MolCenter);
    304304          SideH.ProjectOntoPlane(AxisVector);
    305305          //          LOG(1, "SideH: " << SideH);
     
    329329    } while (flag);
    330330  }
    331   delete(MolCenter);
    332331  return BoundaryPoints;
    333332};
     
    655654};
    656655
    657 /** Creates multiples of the by \a *mol given cluster and suspends them in water with a given final density.
    658  * We get cluster volume by Tesselation::getVolumeOfConvexEnvelope() and its diameters by GetDiametersOfCluster()
    659  * TODO: Here, we need a VolumeOfGeneralEnvelope (i.e. non-convex one)
    660  * \param *out output stream for debugging
    661  * \param *configuration needed for path to store convex envelope file
    662  * \param *mol molecule structure representing the cluster
    663  * \param *&TesselStruct Tesselation structure with triangles on return
    664  * \param ClusterVolume guesstimated cluster volume, if equal 0 we used Tesselation::getVolumeOfConvexEnvelope() instead.
    665  * \param celldensity desired average density in final cell
    666  */
    667 void PrepareClustersinWater(config *configuration, molecule *mol, double ClusterVolume, double celldensity)
    668 {
    669         //Info FunctionInfo(__func__);
    670   bool IsAngstroem = true;
    671   double *GreatestDiameter = NULL;
    672   Boundaries *BoundaryPoints = NULL;
    673   class Tesselation *TesselStruct = NULL;
    674   Vector BoxLengths;
    675   int repetition[NDIM] = { 1, 1, 1 };
    676   int TotalNoClusters = 1;
    677   double totalmass = 0.;
    678   double clustervolume = 0.;
    679   double cellvolume = 0.;
    680 
    681   // transform to PAS by Action
    682   Vector MainAxis(0.,0.,1.);
    683   mol->RotateToPrincipalAxisSystem(MainAxis);
    684 
    685   IsAngstroem = configuration->GetIsAngstroem();
    686   BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
    687   GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem);
    688   PointCloudAdaptor< molecule > cloud(mol, mol->name);
    689   LinkedCell_deprecated *LCList = new LinkedCell_deprecated(cloud, 10.);
    690   FindConvexBorder(mol, BoundaryPoints, TesselStruct, (const LinkedCell_deprecated *&)LCList, NULL);
    691   delete (LCList);
    692   delete[] BoundaryPoints;
    693 
    694 
    695   // some preparations beforehand
    696   if (ClusterVolume == 0)
    697     clustervolume = TesselStruct->getVolumeOfConvexEnvelope(configuration->GetIsAngstroem());
    698   else
    699     clustervolume = ClusterVolume;
    700 
    701   delete TesselStruct;
    702 
    703   for (int i = 0; i < NDIM; i++)
    704     TotalNoClusters *= repetition[i];
    705 
    706   // sum up the atomic masses
    707   for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    708       totalmass += (*iter)->getType()->getMass();
    709   }
    710   LOG(0, "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit.");
    711   LOG(0, "RESULT: The average density is " << setprecision(10) << totalmass / clustervolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3.");
    712 
    713   // solve cubic polynomial
    714   LOG(1, "Solving equidistant suspension in water problem ...");
    715   if (IsAngstroem)
    716     cellvolume = (TotalNoClusters * totalmass / SOLVENTDENSITY_A - (totalmass / clustervolume)) / (celldensity - 1);
    717   else
    718     cellvolume = (TotalNoClusters * totalmass / SOLVENTDENSITY_a0 - (totalmass / clustervolume)) / (celldensity - 1);
    719   LOG(1, "Cellvolume needed for a density of " << celldensity << " g/cm^3 is " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3.");
    720 
    721   double minimumvolume = TotalNoClusters * (GreatestDiameter[0] * GreatestDiameter[1] * GreatestDiameter[2]);
    722   LOG(1, "Minimum volume of the convex envelope contained in a rectangular box is " << minimumvolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3.");
    723   if (minimumvolume > cellvolume) {
    724     ELOG(1, "the containing box already has a greater volume than the envisaged cell volume!");
    725     LOG(0, "Setting Box dimensions to minimum possible, the greatest diameters.");
    726     for (int i = 0; i < NDIM; i++)
    727       BoxLengths[i] = GreatestDiameter[i];
    728     mol->CenterEdge(&BoxLengths);
    729   } else {
    730     BoxLengths[0] = (repetition[0] * GreatestDiameter[0] + repetition[1] * GreatestDiameter[1] + repetition[2] * GreatestDiameter[2]);
    731     BoxLengths[1] = (repetition[0] * repetition[1] * GreatestDiameter[0] * GreatestDiameter[1] + repetition[0] * repetition[2] * GreatestDiameter[0] * GreatestDiameter[2] + repetition[1] * repetition[2] * GreatestDiameter[1] * GreatestDiameter[2]);
    732     BoxLengths[2] = minimumvolume - cellvolume;
    733     double x0 = 0.;
    734     double x1 = 0.;
    735     double x2 = 0.;
    736     if (gsl_poly_solve_cubic(BoxLengths[0], BoxLengths[1], BoxLengths[2], &x0, &x1, &x2) == 1) // either 1 or 3 on return
    737       LOG(0, "RESULT: The resulting spacing is: " << x0 << " .");
    738     else {
    739       LOG(0, "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " .");
    740       x0 = x2; // sorted in ascending order
    741     }
    742 
    743     cellvolume = 1.;
    744     for (int i = 0; i < NDIM; i++) {
    745       BoxLengths[i] = repetition[i] * (x0 + GreatestDiameter[i]);
    746       cellvolume *= BoxLengths[i];
    747     }
    748 
    749     // set new box dimensions
    750     LOG(0, "Translating to box with these boundaries.");
    751     mol->SetBoxDimension(&BoxLengths);
    752     mol->CenterInBox();
    753   }
    754   delete[] GreatestDiameter;
    755   // update Box of atoms by boundary
    756   mol->SetBoxDimension(&BoxLengths);
    757   LOG(0, "RESULT: The resulting cell dimensions are: " << BoxLengths[0] << " and " << BoxLengths[1] << " and " << BoxLengths[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3.");
    758 };
    759 
    760 
    761 /** Fills the empty space around other molecules' surface of the simulation box with a filler.
    762  * \param *out output stream for debugging
    763  * \param *List list of molecules already present in box
    764  * \param *TesselStruct contains tesselated surface
    765  * \param *filler molecule which the box is to be filled with
    766  * \param configuration contains box dimensions
    767  * \param MaxDistance fills in molecules only up to this distance (set to -1 if whole of the domain)
    768  * \param distance[NDIM] distance between filling molecules in each direction
    769  * \param boundary length of boundary zone between molecule and filling mollecules
    770  * \param epsilon distance to surface which is not filled
    771  * \param RandAtomDisplacement maximum distance for random displacement per atom
    772  * \param RandMolDisplacement maximum distance for random displacement per filler molecule
    773  * \param DoRandomRotation true - do random rotiations, false - don't
    774  */
    775 void FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double MaxDistance, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation)
    776 {
    777         //Info FunctionInfo(__func__);
    778   molecule *Filling = World::getInstance().createMolecule();
    779   Vector CurrentPosition;
    780   int N[NDIM];
    781   int n[NDIM];
    782   const RealSpaceMatrix &M = World::getInstance().getDomain().getM();
    783   RealSpaceMatrix Rotations;
    784   const RealSpaceMatrix &MInverse = World::getInstance().getDomain().getMinv();
    785   Vector AtomTranslations;
    786   Vector FillerTranslations;
    787   Vector FillerDistance;
    788   Vector Inserter;
    789   double FillIt = false;
    790   bond::ptr Binder;
    791   double phi[NDIM];
    792   map<molecule *, Tesselation *> TesselStruct;
    793   map<molecule *, LinkedCell_deprecated *> LCList;
    794 
    795   for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++)
    796     if ((*ListRunner)->getAtomCount() > 0) {
    797       LOG(1, "Pre-creating linked cell lists for molecule " << *ListRunner << ".");
    798       PointCloudAdaptor< molecule > cloud(*ListRunner, (*ListRunner)->name);
    799       LCList[(*ListRunner)] = new LinkedCell_deprecated(cloud, 10.); // get linked cell list
    800       LOG(1, "Pre-creating tesselation for molecule " << *ListRunner << ".");
    801       TesselStruct[(*ListRunner)] = NULL;
    802       FindNonConvexBorder((*ListRunner), TesselStruct[(*ListRunner)], (const LinkedCell_deprecated *&)LCList[(*ListRunner)], 5., NULL);
    803     }
    804 
    805   // Center filler at origin
    806   filler->CenterEdge(&Inserter);
    807   const int FillerCount = filler->getAtomCount();
    808   LOG(2, "INFO: Filler molecule has the following bonds:");
    809   for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner) {
    810     const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
    811     for(BondList::const_iterator BondRunner = ListOfBonds.begin();
    812         BondRunner != ListOfBonds.end();
    813         ++BondRunner) {
    814       if ((*BondRunner)->leftatom == *AtomRunner)
    815         LOG(2, "  " << *(*BondRunner));
    816     }
    817   }
    818 
    819   atom * CopyAtoms[FillerCount];
    820 
    821   // calculate filler grid in [0,1]^3
    822   FillerDistance = MInverse * Vector(distance[0], distance[1], distance[2]);
    823   for(int i=0;i<NDIM;i++)
    824     N[i] = (int) ceil(1./FillerDistance[i]);
    825   LOG(1, "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << ".");
    826 
    827   // initialize seed of random number generator to current time
    828   RandomNumberGenerator &random = RandomNumberGeneratorFactory::getInstance().makeRandomNumberGenerator();
    829   const double rng_min = random.min();
    830   const double rng_max = random.max();
    831   //srand ( time(NULL) );
    832 
    833   // go over [0,1]^3 filler grid
    834   for (n[0] = 0; n[0] < N[0]; n[0]++)
    835     for (n[1] = 0; n[1] < N[1]; n[1]++)
    836       for (n[2] = 0; n[2] < N[2]; n[2]++) {
    837         // calculate position of current grid vector in untransformed box
    838         CurrentPosition = M * Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]);
    839         // create molecule random translation vector ...
    840         for (int i=0;i<NDIM;i++)
    841           FillerTranslations[i] = RandomMolDisplacement*(random()/((rng_max-rng_min)/2.) - 1.);
    842         LOG(2, "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << ".");
    843 
    844         // go through all atoms
    845         for (int i=0;i<FillerCount;i++)
    846           CopyAtoms[i] = NULL;
    847 
    848         // have same rotation angles for all molecule's atoms
    849         if (DoRandomRotation)
    850           for (int i=0;i<NDIM;i++)
    851             phi[i] = (random()/(rng_max-rng_min))*(2.*M_PI);
    852 
    853         // atom::clone is not const member function, hence we need iterator here
    854         for(molecule::iterator iter = filler->begin(); iter !=filler->end();++iter){
    855 
    856           // create atomic random translation vector ...
    857           for (int i=0;i<NDIM;i++)
    858             AtomTranslations[i] = RandomAtomDisplacement*(random()/((rng_max-rng_min)/2.) - 1.);
    859 
    860           // ... and rotation matrix
    861           if (DoRandomRotation) {
    862             Rotations.set(0,0,  cos(phi[0])            *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2])));
    863             Rotations.set(0,1,  sin(phi[0])            *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2])));
    864             Rotations.set(0,2,              cos(phi[1])*sin(phi[2])                                        );
    865             Rotations.set(1,0, -sin(phi[0])*cos(phi[1])                                                    );
    866             Rotations.set(1,1,  cos(phi[0])*cos(phi[1])                                                    );
    867             Rotations.set(1,2,              sin(phi[1])                                                    );
    868             Rotations.set(2,0, -cos(phi[0])            *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2])));
    869             Rotations.set(2,1, -sin(phi[0])            *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2])));
    870             Rotations.set(2,2,              cos(phi[1])*cos(phi[2])                                        );
    871           }
    872 
    873           // ... and put at new position
    874           Inserter = (*iter)->getPosition();
    875           if (DoRandomRotation)
    876             Inserter *= Rotations;
    877           Inserter += AtomTranslations + FillerTranslations + CurrentPosition;
    878 
    879           // check whether inserter is inside box
    880           Inserter *= MInverse;
    881           FillIt = true;
    882           for (int i=0;i<NDIM;i++)
    883             FillIt = FillIt && (Inserter[i] >= -MYEPSILON) && ((Inserter[i]-1.) <= MYEPSILON);
    884           Inserter *= M;
    885 
    886           // Check whether point is in- or outside
    887           for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
    888             // get linked cell list
    889             if (TesselStruct[(*ListRunner)] != NULL) {
    890               const double distance = (TesselStruct[(*ListRunner)]->GetDistanceToSurface(Inserter, LCList[(*ListRunner)]));
    891               FillIt = FillIt && (distance > boundary) && ((MaxDistance < 0) || (MaxDistance > distance));
    892             }
    893           }
    894           // insert into Filling
    895           if (FillIt) {
    896             LOG(1, "INFO: Position at " << Inserter << " is outer point.");
    897             // copy atom ...
    898             CopyAtoms[(*iter)->getNr()] = (*iter)->clone();
    899             (*CopyAtoms[(*iter)->getNr()]).setPosition(Inserter);
    900             Filling->AddAtom(CopyAtoms[(*iter)->getNr()]);
    901             LOG(1, "Filling atom " << **iter << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[(*iter)->getNr()]->getPosition()) << ".");
    902           } else {
    903             LOG(1, "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance.");
    904             CopyAtoms[(*iter)->getNr()] = NULL;
    905             continue;
    906           }
    907         }
    908         // go through all bonds and add as well
    909         for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner) {
    910           const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
    911           for(BondList::const_iterator BondRunner = ListOfBonds.begin();
    912               BondRunner != ListOfBonds.end();
    913               ++BondRunner)
    914             if ((*BondRunner)->leftatom == *AtomRunner) {
    915               Binder = (*BondRunner);
    916               if ((CopyAtoms[Binder->leftatom->getNr()] != NULL) && (CopyAtoms[Binder->rightatom->getNr()] != NULL)) {
    917                 LOG(3, "Adding Bond between " << *CopyAtoms[Binder->leftatom->getNr()] << " and " << *CopyAtoms[Binder->rightatom->getNr()]<< ".");
    918                 Filling->AddBond(CopyAtoms[Binder->leftatom->getNr()], CopyAtoms[Binder->rightatom->getNr()], Binder->getDegree());
    919               }
    920             }
    921         }
    922       }
    923   for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
    924     delete LCList[*ListRunner];
    925     delete TesselStruct[(*ListRunner)];
    926   }
    927 };
    928 
    929 /** Rotates given molecule \a Filling and moves its atoms according to given
    930  *  \a RandomAtomDisplacement.
    931  *
    932  *  Note that for rotation to be sensible, the molecule should be centered at
    933  *  the origin. This is not done here!
    934  *
    935  *  \param &Filling molecule whose atoms to displace
    936  *  \param RandomAtomDisplacement magnitude of random displacement
    937  *  \param &Rotations 3D rotation matrix (or unity if no rotation desired)
    938  */
    939 void RandomizeMoleculePositions(
    940     molecule *&Filling,
    941     double RandomAtomDisplacement,
    942     RealSpaceMatrix &Rotations,
    943     RandomNumberGenerator &random
    944     )
    945 {
    946   const double rng_min = random.min();
    947   const double rng_max = random.max();
    948 
    949   Vector AtomTranslations;
    950   for(molecule::iterator miter = Filling->begin(); miter != Filling->end(); ++miter) {
    951     Vector temp = (*miter)->getPosition();
    952     temp *= Rotations;
    953     (*miter)->setPosition(temp);
    954     // create atomic random translation vector ...
    955     for (int i=0;i<NDIM;i++)
    956       AtomTranslations[i] = RandomAtomDisplacement*(random()/((rng_max-rng_min)/2.) - 1.);
    957     (*miter)->setPosition((*miter)->getPosition() + AtomTranslations);
    958   }
    959 }
    960 
    961 /** Removes all atoms of a molecule outside.
    962  *
    963  * If the molecule is empty, it is removed as well.
    964  *
    965  * @param Filling molecule whose atoms to check, removed if eventually left
    966  *        empty.
    967  * @return true - atoms had to be removed, false - no atoms have been removed
    968  */
    969 bool RemoveAtomsOutsideDomain(molecule *&Filling)
    970 {
    971   bool status = false;
    972   Box &Domain = World::getInstance().getDomain();
    973   // check if all is still inside domain
    974   for(molecule::iterator miter = Filling->begin(); miter != Filling->end(); ) {
    975     // check whether each atom is inside box
    976     if (!Domain.isInside((*miter)->getPosition())) {
    977       status = true;
    978       atom *Walker = *miter;
    979       ++miter;
    980       World::getInstance().destroyAtom(Walker);
    981     } else {
    982       ++miter;
    983     }
    984   }
    985   if (Filling->empty()) {
    986     LOG(0, "Removing molecule " << Filling->getName() << ", all atoms have been removed.");
    987     World::getInstance().destroyMolecule(Filling);
    988     Filling = NULL;
    989   }
    990   return status;
    991 }
    992 
    993 /** Checks whether there are no atoms inside a sphere around \a CurrentPosition
    994  *  except those atoms present in \a *filler.
    995  *  If filler is NULL, then we just call LinkedCell_deprecated::GetPointsInsideSphere() and
    996  *  check whether the return list is empty.
    997  * @param *filler
    998  * @param boundary
    999  * @param CurrentPosition
    1000  */
    1001 bool isSpaceAroundPointVoid(
    1002     LinkedCell_deprecated *LC,
    1003     molecule *filler,
    1004     const double boundary,
    1005     Vector &CurrentPosition)
    1006 {
    1007   size_t compareTo = 0;
    1008   TesselPointSTLList* liste = LC->GetPointsInsideSphere(boundary == 0. ? MYEPSILON : boundary, &CurrentPosition);
    1009   if (filler != NULL) {
    1010     for (TesselPointSTLList::const_iterator iter = liste->begin();
    1011         iter != liste->end();
    1012         ++iter) {
    1013       for (molecule::iterator miter = filler->begin();
    1014           miter != filler->end();
    1015           ++miter) {
    1016         if (*iter == *miter)
    1017           ++compareTo;
    1018       }
    1019     }
    1020   }
    1021   const bool result = (liste->size() == compareTo);
    1022   if (!result) {
    1023     LOG(0, "Skipping because of the following atoms:");
    1024     for (TesselPointSTLList::const_iterator iter = liste->begin();
    1025         iter != liste->end();
    1026         ++iter) {
    1027       LOG(0, **iter);
    1028     }
    1029   }
    1030   delete(liste);
    1031   return result;
    1032 }
    1033 
    1034 /** Sets given 3x3 matrix to a random rotation matrix.
    1035  *
    1036  * @param a matrix to set
    1037  */
    1038 inline void setRandomRotation(RealSpaceMatrix &a)
    1039 {
    1040   double phi[NDIM];
    1041   RandomNumberGenerator &random = RandomNumberGeneratorFactory::getInstance().makeRandomNumberGenerator();
    1042   const double rng_min = random.min();
    1043   const double rng_max = random.max();
    1044 
    1045   for (int i=0;i<NDIM;i++) {
    1046     phi[i] = (random()/(rng_max-rng_min))*(2.*M_PI);
    1047     LOG(4, "DEBUG: Random angle is " << phi[i] << ".");
    1048   }
    1049 
    1050   a.setRotation(phi);
    1051 }
    1052 
    1053 /** Fills the empty space of the simulation box with water.
    1054  * \param *filler molecule which the box is to be filled with
    1055  * \param configuration contains box dimensions
    1056  * \param distance[NDIM] distance between filling molecules in each direction
    1057  * \param boundary length of boundary zone between molecule and filling molecules
    1058  * \param RandAtomDisplacement maximum distance for random displacement per atom
    1059  * \param RandMolDisplacement maximum distance for random displacement per filler molecule
    1060  * \param MinDistance minimum distance to boundary of domain and present molecules
    1061  * \param DoRandomRotation true - do random rotations, false - don't
    1062  */
    1063 void FillVoidWithMolecule(
    1064     molecule *&filler,
    1065     config &configuration,
    1066     const double distance[NDIM],
    1067     const double boundary,
    1068     const double RandomAtomDisplacement,
    1069     const double RandomMolDisplacement,
    1070     const double MinDistance,
    1071     const bool DoRandomRotation
    1072     )
    1073 {
    1074   //Info FunctionInfo(__func__);
    1075   molecule *Filling = NULL;
    1076   Vector CurrentPosition;
    1077   int N[NDIM];
    1078   int n[NDIM];
    1079   const RealSpaceMatrix &M = World::getInstance().getDomain().getM();
    1080   RealSpaceMatrix Rotations;
    1081   const RealSpaceMatrix &MInverse = World::getInstance().getDomain().getMinv();
    1082   Vector FillerTranslations;
    1083   Vector FillerDistance;
    1084   Vector Inserter;
    1085   double FillIt = false;
    1086   Vector firstInserter;
    1087   bool firstInsertion = true;
    1088   const Box &Domain = World::getInstance().getDomain();
    1089   map<molecule *, LinkedCell_deprecated *> LCList;
    1090   std::vector<molecule *> List = World::getInstance().getAllMolecules();
    1091   MoleculeListClass *MolList = World::getInstance().getMolecules();
    1092 
    1093   for (std::vector<molecule *>::iterator ListRunner = List.begin(); ListRunner != List.end(); ListRunner++)
    1094     if ((*ListRunner)->getAtomCount() > 0) {
    1095       LOG(1, "Pre-creating linked cell lists for molecule " << *ListRunner << ".");
    1096       PointCloudAdaptor< molecule > cloud(*ListRunner, (*ListRunner)->name);
    1097       LCList[(*ListRunner)] = new LinkedCell_deprecated(cloud, 10.); // get linked cell list
    1098     }
    1099 
    1100   // Center filler at its center of gravity
    1101   Vector *gravity = filler->DetermineCenterOfGravity();
    1102   filler->CenterAtVector(gravity);
    1103   delete gravity;
    1104   //const int FillerCount = filler->getAtomCount();
    1105   LOG(2, "INFO: Filler molecule has the following bonds:");
    1106   for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner) {
    1107     const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
    1108     for(BondList::const_iterator BondRunner = ListOfBonds.begin();
    1109         BondRunner != ListOfBonds.end();
    1110         ++BondRunner)
    1111       if ((*BondRunner)->leftatom == *AtomRunner)
    1112         LOG(2, "  " << *(*BondRunner));
    1113   }
    1114 
    1115   // calculate filler grid in [0,1]^3
    1116   FillerDistance = MInverse * Vector(distance[0], distance[1], distance[2]);
    1117   for(int i=0;i<NDIM;i++)
    1118     N[i] = (int) ceil(1./FillerDistance[i]);
    1119   LOG(1, "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << ".");
    1120 
    1121   // initialize seed of random number generator to current time
    1122   RandomNumberGenerator &random = RandomNumberGeneratorFactory::getInstance().makeRandomNumberGenerator();
    1123   const double rng_min = random.min();
    1124   const double rng_max = random.max();
    1125   //srand ( time(NULL) );
    1126 
    1127   // go over [0,1]^3 filler grid
    1128   for (n[0] = 0; n[0] < N[0]; n[0]++)
    1129     for (n[1] = 0; n[1] < N[1]; n[1]++)
    1130       for (n[2] = 0; n[2] < N[2]; n[2]++) {
    1131         // calculate position of current grid vector in untransformed box
    1132         CurrentPosition = M * Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]);
    1133         // create molecule random translation vector ...
    1134         for (int i=0;i<NDIM;i++) // have the random values [-1,1]*RandomMolDisplacement
    1135           FillerTranslations[i] = RandomMolDisplacement*(random()/((rng_max-rng_min)/2.) - 1.);
    1136         LOG(2, "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << ".");
    1137 
    1138         // ... and rotation matrix
    1139         if (DoRandomRotation)
    1140           setRandomRotation(Rotations);
    1141         else
    1142           Rotations.setIdentity();
    1143 
    1144 
    1145         // Check whether there is anything too close by and whether atom is outside of domain
    1146         FillIt = true;
    1147         for (std::map<molecule *, LinkedCell_deprecated *>::iterator ListRunner = LCList.begin(); ListRunner != LCList.end(); ++ListRunner) {
    1148           FillIt = FillIt && isSpaceAroundPointVoid(
    1149               ListRunner->second,
    1150               (firstInsertion ? filler : NULL),
    1151               boundary,
    1152               CurrentPosition);
    1153           FillIt = FillIt && (Domain.isValid(CurrentPosition))
    1154               && ((Domain.DistanceToBoundary(CurrentPosition) - MinDistance) > -MYEPSILON);
    1155           if (!FillIt)
    1156             break;
    1157         }
    1158 
    1159         // insert into Filling
    1160         if (FillIt) {
    1161           Inserter = CurrentPosition + FillerTranslations;
    1162           LOG(1, "INFO: Position at " << Inserter << " is void point.");
    1163           // fill!
    1164           Filling = filler->CopyMolecule();
    1165           RandomizeMoleculePositions(Filling, RandomAtomDisplacement, Rotations, random);
    1166           // translation
    1167           Filling->Translate(&Inserter);
    1168           // remove out-of-bounds atoms
    1169           const bool status = RemoveAtomsOutsideDomain(Filling);
    1170           if ((firstInsertion) && (!status)) { // no atom has been removed
    1171             // remove copied atoms and molecule again
    1172             Filling->removeAtomsinMolecule();
    1173             World::getInstance().destroyMolecule(Filling);
    1174             // and mark is final filler position
    1175             Filling = filler;
    1176             firstInsertion = false;
    1177             firstInserter = Inserter;
    1178           } else {
    1179             // TODO: Remove when World has no MoleculeListClass anymore
    1180             if (Filling)
    1181               MolList->insert(Filling);
    1182           }
    1183         } else {
    1184          LOG(1, "INFO: Position at " << Inserter << " is non-void point, within boundary or outside of MaxDistance.");
    1185           continue;
    1186         }
    1187       }
    1188 
    1189   // have we inserted any molecules?
    1190   if (firstInsertion) {
    1191     // If not remove filler
    1192     for(molecule::iterator miter = filler->begin(); !filler->empty(); miter = filler->begin()) {
    1193       atom *Walker = *miter;
    1194       World::getInstance().destroyAtom(Walker);
    1195     }
    1196     World::getInstance().destroyMolecule(filler);
    1197   } else {
    1198     // otherwise translate and randomize to final position
    1199     if (DoRandomRotation)
    1200       setRandomRotation(Rotations);
    1201     else
    1202       Rotations.setIdentity();
    1203     RandomizeMoleculePositions(filler, RandomAtomDisplacement, Rotations, random);
    1204     // translation
    1205     filler->Translate(&firstInserter);
    1206     // remove out-of-bounds atoms
    1207     RemoveAtomsOutsideDomain(filler);
    1208   }
    1209 
    1210   LOG(0, MolList->ListOfMolecules.size() << " molecules have been inserted.");
    1211 
    1212   for (std::map<molecule *, LinkedCell_deprecated *>::iterator ListRunner = LCList.begin(); !LCList.empty(); ListRunner = LCList.begin()) {
    1213     delete ListRunner->second;
    1214     LCList.erase(ListRunner);
    1215   }
    1216 };
    1217 
    1218 
    1219 /** Fills the empty space around other molecules' surface of the simulation box with a filler.
    1220  *
    1221  * Note that we use \a FindNonConvexBorder to determine the surface of the found molecules.
    1222  * There, we use a radius of twice the given \a boundary.
    1223  *
    1224  * \param *out output stream for debugging
    1225  * \param *List list of molecules already present in box
    1226  * \param *TesselStruct contains tesselated surface
    1227  * \param *filler molecule which the box is to be filled with
    1228  * \param configuration contains box dimensions
    1229  * \param MaxSurfaceDistance fills in molecules only up to this distance (set to -1 if whole of the domain)
    1230  * \param distance[NDIM] distance between filling molecules in each direction
    1231  * \param boundary length of boundary zone between molecule and filling molecules
    1232  * \param MinDistance distance to boundary of domain which is not filled
    1233  * \param RandAtomDisplacement maximum distance for random displacement per atom
    1234  * \param RandMolDisplacement maximum distance for random displacement per filler molecule
    1235  * \param DoRandomRotation true - do random rotations, false - don't
    1236  */
    1237 void FillBoxWithMolecule(
    1238     MoleculeListClass *MolList,
    1239     molecule *filler,
    1240     config &configuration,
    1241     const double MaxSurfaceDistance,
    1242     const double distance[NDIM],
    1243     const double boundary,
    1244     const double MinDistance,
    1245     const double RandomAtomDisplacement,
    1246     const double RandomMolDisplacement,
    1247     const bool DoRandomRotation)
    1248 {
    1249   //Info FunctionInfo(__func__);
    1250   molecule *Filling = NULL;
    1251   Vector CurrentPosition;
    1252   int N[NDIM];
    1253   int n[NDIM];
    1254   const RealSpaceMatrix &M = World::getInstance().getDomain().getM();
    1255   RealSpaceMatrix Rotations;
    1256   const RealSpaceMatrix &MInverse = World::getInstance().getDomain().getMinv();
    1257   Vector FillerTranslations;
    1258   Vector FillerDistance;
    1259   Vector Inserter;
    1260   double FillIt = false;
    1261   Vector firstInserter;
    1262   bool firstInsertion = true;
    1263   const Box &Domain = World::getInstance().getDomain();
    1264   map<molecule *, LinkedCell_deprecated *> LCList;
    1265   std::vector<molecule *> List = World::getInstance().getAllMolecules();
    1266   map<molecule *, Tesselation *> TesselStruct;
    1267 
    1268   for (MoleculeList::iterator ListRunner = MolList->ListOfMolecules.begin(); ListRunner != MolList->ListOfMolecules.end(); ListRunner++)
    1269     if ((*ListRunner)->getAtomCount() > 0) {
    1270       LOG(1, "Pre-creating linked cell lists for molecule " << *ListRunner << ".");
    1271       PointCloudAdaptor< molecule > cloud(*ListRunner, (*ListRunner)->name);
    1272       LCList[(*ListRunner)] = new LinkedCell_deprecated(cloud, 4.*boundary); // get linked cell list
    1273       LOG(1, "Pre-creating tesselation for molecule " << *ListRunner << ".");
    1274       TesselStruct[(*ListRunner)] = NULL;
    1275       FindNonConvexBorder((*ListRunner), TesselStruct[(*ListRunner)], (const LinkedCell_deprecated *&)LCList[(*ListRunner)], 2.*boundary, NULL);
    1276     }
    1277 
    1278   // Center filler at origin
    1279   filler->CenterEdge(&Inserter);
    1280 //  const int FillerCount = filler->getAtomCount();
    1281   LOG(2, "INFO: Filler molecule has the following bonds:");
    1282   for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner) {
    1283     const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
    1284     for(BondList::const_iterator BondRunner = ListOfBonds.begin();
    1285         BondRunner != ListOfBonds.end();
    1286         ++BondRunner) {
    1287       if ((*BondRunner)->leftatom == *AtomRunner)
    1288         LOG(2, "  " << *(*BondRunner));
    1289     }
    1290   }
    1291 
    1292 //  atom * CopyAtoms[FillerCount];
    1293 
    1294   setVerbosity(4);
    1295 
    1296   // calculate filler grid in [0,1]^3
    1297   FillerDistance = MInverse * Vector(distance[0], distance[1], distance[2]);
    1298   for(int i=0;i<NDIM;i++)
    1299     N[i] = (int) ceil(1./FillerDistance[i]);
    1300   LOG(1, "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << ".");
    1301 
    1302   // initialize seed of random number generator to current time
    1303   RandomNumberGenerator &random = RandomNumberGeneratorFactory::getInstance().makeRandomNumberGenerator();
    1304   const double rng_min = random.min();
    1305   const double rng_max = random.max();
    1306   //srand ( time(NULL) );
    1307 
    1308   // go over [0,1]^3 filler grid
    1309   for (n[0] = 0; n[0] < N[0]; n[0]++)
    1310     for (n[1] = 0; n[1] < N[1]; n[1]++)
    1311       for (n[2] = 0; n[2] < N[2]; n[2]++) {
    1312         // calculate position of current grid vector in untransformed box
    1313         CurrentPosition = M * Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]);
    1314         // create molecule random translation vector ...
    1315         for (int i=0;i<NDIM;i++)
    1316           FillerTranslations[i] = RandomMolDisplacement*(random()/((rng_max-rng_min)/2.) - 1.);
    1317         LOG(1, "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << ".");
    1318 
    1319         // ... and rotation matrix
    1320         if (DoRandomRotation)
    1321           setRandomRotation(Rotations);
    1322         else
    1323           Rotations.setIdentity();
    1324 
    1325 
    1326         // Check whether there is anything too close by and whether atom is outside of domain
    1327         FillIt = true;
    1328         for (std::map<molecule *, LinkedCell_deprecated *>::iterator ListRunner = LCList.begin(); ListRunner != LCList.end(); ++ListRunner) {
    1329           // check whether its void
    1330           FillIt = FillIt && isSpaceAroundPointVoid(
    1331               ListRunner->second,
    1332               (firstInsertion ? filler : NULL),
    1333               boundary,
    1334               CurrentPosition);
    1335           if (!FillIt) {
    1336             LOG(2, "REJECT: Position at " << Inserter << " is non-void.");
    1337             break;
    1338           }
    1339           // check whether inside domain
    1340           FillIt = FillIt && (Domain.isValid(CurrentPosition));
    1341           if (!FillIt) {
    1342             LOG(2, "REJECT: Position at " << CurrentPosition << " is "
    1343                 << distance << ", hence outside of domain.");
    1344             break;
    1345           }
    1346           // check minimum distance to boundary
    1347           const double distance = (Domain.DistanceToBoundary(CurrentPosition) - MinDistance);
    1348           FillIt = FillIt && (distance > -MYEPSILON);
    1349           if (!FillIt) {
    1350             LOG(2, "REJECT: Position at " << CurrentPosition << " is " << distance << ", less than "
    1351                 << MinDistance << " hence, too close to boundary.");
    1352             break;
    1353           }
    1354         }
    1355         // Check whether point is in- or outside of tesselations
    1356         if (FillIt) {
    1357           for (MoleculeList::iterator ListRunner = MolList->ListOfMolecules.begin(); ListRunner != MolList->ListOfMolecules.end(); ListRunner++) {
    1358             // get linked cell list
    1359             if (TesselStruct[(*ListRunner)] != NULL) {
    1360               const double distance = (TesselStruct[(*ListRunner)]->GetDistanceToSurface(Inserter, LCList[(*ListRunner)]));
    1361               LOG(2, "INFO: Distance to surface is " << distance << ".");
    1362               FillIt = FillIt && ((distance == -1.) || (distance > boundary)) && ((MaxSurfaceDistance < 0) || (MaxSurfaceDistance > distance));
    1363               if (!FillIt) {
    1364                 LOG(2, "REJECT: Position at " << CurrentPosition << " is in distance of " << distance
    1365                     << " to a surface, less than " << MaxSurfaceDistance  << " hence, too close.");
    1366                 break;
    1367               }
    1368             }
    1369           }
    1370         }
    1371 
    1372         // insert into Filling
    1373         if (FillIt) {
    1374           Inserter = CurrentPosition + FillerTranslations;
    1375           LOG(2, "ACCEPT: Position at " << CurrentPosition << " is void point.");
    1376           // fill!
    1377           Filling = filler->CopyMolecule();
    1378           RandomizeMoleculePositions(Filling, RandomAtomDisplacement, Rotations, random);
    1379           // translation
    1380           Filling->Translate(&Inserter);
    1381           // remove out-of-bounds atoms
    1382           const bool status = RemoveAtomsOutsideDomain(Filling);
    1383           if ((firstInsertion) && (!status)) { // no atom has been removed
    1384             // remove copied atoms and molecule again
    1385             Filling->removeAtomsinMolecule();
    1386             World::getInstance().destroyMolecule(Filling);
    1387             // and mark is final filler position
    1388             Filling = filler;
    1389             firstInsertion = false;
    1390             firstInserter = Inserter;
    1391           } else {
    1392             // TODO: Remove when World has no MoleculeListClass anymore
    1393             if (Filling)
    1394               MolList->insert(Filling);
    1395           }
    1396         } else {
    1397           LOG(2, "REJECT: Position at " << CurrentPosition << " is non-void point, within boundary or outside of MaxSurfaceDistance.");
    1398           continue;
    1399         }
    1400       }
    1401 
    1402   // have we inserted any molecules?
    1403   if (firstInsertion) {
    1404     // If not remove filler
    1405     for(molecule::iterator miter = filler->begin(); !filler->empty(); miter = filler->begin()) {
    1406       atom *Walker = *miter;
    1407       World::getInstance().destroyAtom(Walker);
    1408     }
    1409     World::getInstance().destroyMolecule(filler);
    1410   } else {
    1411     // otherwise translate and randomize to final position
    1412     if (DoRandomRotation)
    1413       setRandomRotation(Rotations);
    1414     else
    1415       Rotations.setIdentity();
    1416     RandomizeMoleculePositions(filler, RandomAtomDisplacement, Rotations, random);
    1417     // translation
    1418     filler->Translate(&firstInserter);
    1419     // remove out-of-bounds atoms
    1420     RemoveAtomsOutsideDomain(filler);
    1421   }
    1422 
    1423   LOG(0, MolList->ListOfMolecules.size() << " molecules have been inserted.");
    1424 
    1425   for (std::map<molecule *, LinkedCell_deprecated *>::iterator ListRunner = LCList.begin(); !LCList.empty(); ListRunner = LCList.begin()) {
    1426     delete ListRunner->second;
    1427     LCList.erase(ListRunner);
    1428   }
    1429 };
    1430 
    1431656/** Tesselates the non convex boundary by rolling a virtual sphere along the surface of the molecule.
    1432657 * \param *out output stream for debugging
  • src/Tesselation/boundary.hpp

    r29b35e r55736b  
    4040
    4141double ConvexizeNonconvexEnvelope(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename);
    42 void FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double MaxDistance, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation);
    43 void FillVoidWithMolecule(molecule *&filler, config &configuration, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const double MinDistance, const bool DoRandomRotation);
    4442void FindConvexBorder(const molecule* const mol, Boundaries *BoundaryPts, Tesselation *&TesselStruct, const LinkedCell_deprecated *LCList, const char *filename);
    4543Vector* FindEmbeddingHole(MoleculeListClass *mols, molecule *srcmol);
     
    4745Boundaries *GetBoundaryPoints(const molecule *mol, Tesselation *&TesselStruct);
    4846double * GetDiametersOfCluster(const Boundaries *BoundaryPtr, const molecule *mol, Tesselation *&TesselStruct, const bool IsAngstroem);
    49 void PrepareClustersinWater(config *configuration, molecule *mol, double ClusterVolume, double celldensity);
    5047bool RemoveAllBoundaryPoints(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename);
    5148void StoreTrianglesinFile(const molecule * const mol, const Tesselation * const TesselStruct, const char *filename, const char *extraSuffix);
  • src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp

    r29b35e r55736b  
    752752  emit hoverChanged(_atom);
    753753}
    754 
    755 
    756 //#include <GL/glu.h>
    757 //#include <QtGui/qslider.h>
    758 //#include <QtGui/qevent.h>
    759 //
    760 //#include "ui_dialoglight.h"
    761 //
    762 //#include "CodePatterns/MemDebug.hpp"
    763 //
    764 //#include <iostream>
    765 //#include <boost/shared_ptr.hpp>
    766 //
    767 //#include "LinearAlgebra/Line.hpp"
    768 //#include "Atom/atom.hpp"
    769 //#include "Bond/bond.hpp"
    770 //#include "Element/element.hpp"
    771 //#include "molecule.hpp"
    772 //#include "Element/periodentafel.hpp"
    773 //#include "World.hpp"
    774 //
    775 //#if defined(Q_CC_MSVC)
    776 //#pragma warning(disable:4305) // init: truncation from const double to float
    777 //#endif
    778 //
    779 //
    780 //GLMoleculeView::GLMoleculeView(QWidget *parent) :
    781 //  QGLWidget(parent), Observer("GLMoleculeView"), X(Vector(1,0,0)), Y(Vector(0,1,0)), Z(Vector(0,0,1))
    782 //{
    783 //    xRot = yRot = zRot = 0.0;    // default object rotation
    784 //    scale = 5.;      // default object scale
    785 //    object = 0;
    786 //    LightPosition[0] = 0.0f;
    787 //    LightPosition[1] = 2.0f;
    788 //    LightPosition[2] = 2.0f;
    789 //    LightPosition[3] = 0.0f;
    790 //    LightDiffuse[0] = 0.5f;
    791 //    LightDiffuse[1] = 0.5f;
    792 //    LightDiffuse[2] = 0.5f;
    793 //    LightDiffuse[3] = 0.0f;
    794 //    LightAmbient[0] = 0.0f;
    795 //    LightAmbient[1] = 0.0f;
    796 //    LightAmbient[2] = 0.0f;
    797 //    LightAmbient[3] = 0.0f;
    798 //
    799 //    SelectionColor[0] = 0;
    800 //    SelectionColor[1] = 128;
    801 //    SelectionColor[2] = 128;
    802 //
    803 //    MultiViewEnabled = true;
    804 //
    805 //    isSignaller = false;
    806 //
    807 //    World::getInstance().signOn(this);
    808 //}
    809 //
    810 ///** Destructor of GLMoleculeView.
    811 // * Free's the CallList.
    812 // */
    813 //GLMoleculeView::~GLMoleculeView()
    814 //{
    815 //    makeCurrent();
    816 //    glDeleteLists( object, 1 );
    817 //
    818 //    World::getInstance().signOff(this);
    819 //}
    820 //
    821 ///** Paints the conents of the OpenGL window.
    822 // * Clears the GL buffers, enables lighting and depth.
    823 // * Window is either quartered (if GLMoleculeView::MultiViewEnabled) and xy, xz, yz planar views
    824 // * are added. Uses the CallList, constructed during InitializeGL().
    825 // */
    826 //void GLMoleculeView::paintGL()
    827 //{
    828 //  Vector spot;
    829 //
    830 //  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    831 //  glShadeModel(GL_SMOOTH);            // Enable Smooth Shading
    832 //  glEnable(GL_LIGHTING);              // Enable Light One
    833 //  glEnable(GL_DEPTH_TEST);            // Enables Depth Testing
    834 //  glDepthFunc(GL_LEQUAL);              // The Type Of Depth Testing To Do
    835 //  glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);      // Really Nice Perspective Calculations
    836 //
    837 //  // 3d viewport
    838 //  if (MultiViewEnabled)
    839 //    glViewport( 0, 0, (GLint)width/2, (GLint)height/2 );
    840 //  else
    841 //    glViewport( 0, 0, (GLint)width, (GLint)height );
    842 //  glMatrixMode( GL_PROJECTION );
    843 //  glLoadIdentity();
    844 //  glFrustum( -1.0, 1.0, -1.0, 1.0, 1.0, 50.0 );
    845 //  glMatrixMode( GL_MODELVIEW );
    846 //  glLoadIdentity();
    847 //
    848 //  // calculate point of view and direction
    849 //  glTranslated(position[0],position[1],position[2]);
    850 //  glTranslated(0.0, 0.0, -scale);
    851 //  glRotated(xRot, 1.0, 0.0, 0.0);
    852 //  glRotated(yRot, 0.0, 1.0, 0.0);
    853 //  glRotated(zRot, 0.0, 0.0, 1.0);
    854 //
    855 //  // render scene
    856 //  glCallList(object);
    857 //
    858 //  // enable light
    859 //  glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);       // Setup The Ambient Light
    860 //  glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);       // Setup The Diffuse Light
    861 //  glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);      // Position The Light
    862 //  glEnable(GL_LIGHT1);              // Enable Light One
    863 //
    864 //  if (MultiViewEnabled) {
    865 //    // xy view port
    866 //    glViewport( (GLint)width/2, 0, (GLint)width/2, (GLint)height/2 );
    867 //    glMatrixMode( GL_PROJECTION );
    868 //    glLoadIdentity();
    869 //    glScalef(1./scale, 1./scale,1./scale);
    870 //    glOrtho(0, width/2, 0, height/2, 0,0);
    871 //    glMatrixMode( GL_MODELVIEW );
    872 //    glLoadIdentity();
    873 //
    874 //    // calculate point of view and direction
    875 //    view = position;
    876 //    spot = Vector(0.,0.,scale);
    877 //    top = Vector(0.,1.,0.);
    878 //    gluLookAt(
    879 //        spot[0], spot[1], spot[2],
    880 //        view[0], view[1], view[2],
    881 //        top[0], top[1], top[2]);
    882 //
    883 //    // enable light
    884 //    glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);       // Setup The Ambient Light
    885 //    glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);       // Setup The Diffuse Light
    886 //    glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);      // Position The Light
    887 //    glEnable(GL_LIGHT1);              // Enable Light One
    888 //
    889 //    // render scene
    890 //    glCallList(object);
    891 //
    892 //    // xz viewport
    893 //    glViewport( 0, (GLint)height/2, (GLint)width/2, (GLint)height/2 );
    894 //    glMatrixMode( GL_PROJECTION );
    895 //    glLoadIdentity();
    896 //    glScalef(1./scale, 1./scale,1./scale);
    897 //    glOrtho(0, width/2, 0, height/2, 0,0);
    898 //    glMatrixMode( GL_MODELVIEW );
    899 //    glLoadIdentity();
    900 //
    901 //    // calculate point of view and direction
    902 //    view = position;
    903 //    spot = Vector(0.,scale,0.);
    904 //    top = Vector(1.,0.,0.);
    905 //    gluLookAt(
    906 //        spot[0], spot[1], spot[2],
    907 //        view[0], view[1], view[2],
    908 //        top[0], top[1], top[2]);
    909 //
    910 //    // enable light
    911 //    glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);       // Setup The Ambient Light
    912 //    glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);       // Setup The Diffuse Light
    913 //    glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);      // Position The Light
    914 //    glEnable(GL_LIGHT1);              // Enable Light One
    915 //
    916 //    // render scene
    917 //    glCallList(object);
    918 //
    919 //    //yz viewport
    920 //    glViewport( (GLint)width/2, (GLint)height/2, (GLint)width/2, (GLint)height/2 );
    921 //    glMatrixMode( GL_PROJECTION );
    922 //    glLoadIdentity();
    923 //    glScalef(1./scale, 1./scale,1./scale);
    924 //    glOrtho(0, width/2, 0, height/2, 0,0);
    925 //    glMatrixMode( GL_MODELVIEW );
    926 //    glLoadIdentity();
    927 //
    928 //    // calculate point of view and direction
    929 //    view= position;
    930 //    spot = Vector(scale,0.,0.);
    931 //    top = Vector(0.,1.,0.);
    932 //    gluLookAt(
    933 //        spot[0], spot[1], spot[2],
    934 //        view[0], view[1], view[2],
    935 //        top[0], top[1], top[2]);
    936 //
    937 //    // enable light
    938 //    glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);       // Setup The Ambient Light
    939 //    glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);       // Setup The Diffuse Light
    940 //    glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);      // Position The Light
    941 //    glEnable(GL_LIGHT1);              // Enable Light One
    942 //
    943 //    // render scene
    944 //    glCallList(object);
    945 //  }
    946 //  //CoordinatesBar->setText( QString ("X: %1, Y: %2, Z: %3").arg(position[0]).arg(position[1]).arg(position[2]) );
    947 //}
    948 //
    949 ////void polarView{GLdouble distance, GLdouble twist,
    950 ////   GLdouble elevation, GLdouble azimuth)
    951 ////{
    952 ////      glTranslated(0.0, 0.0, -distance);
    953 ////      glRotated(-twist, 0.0, 0.0, 1.0);
    954 ////      glRotated(-elevation, 1.0, 0.0, 0.0);
    955 ////      glRotated(azimuth, 0.0, 0.0, 1.0);
    956 ////}
    957 //
    958 ///** Make a sphere.
    959 // * \param x position
    960 // * \param radius radius
    961 // * \param color[3] color rgb values
    962 // */
    963 //void GLMoleculeView::makeSphere(const Vector &x, double radius, const unsigned char color[3])
    964 //{
    965 //  float blueMaterial[] = { 255./(float)color[0], 255./(float)color[1], 255./(float)color[2], 1 };  // need to recast from [0,255] with integers into [0,1] with floats
    966 //  GLUquadricObj* q = gluNewQuadric ();
    967 //  gluQuadricOrientation(q, GLU_OUTSIDE);
    968 //
    969 //  std::cout << "Setting sphere at " << x << " with color r"
    970 //      << (int)color[0] << ",g" << (int)color[1] << ",b" << (int)color[2] << "." << endl;
    971 //
    972 //  glPushMatrix();
    973 //  glTranslatef( x[0], x[1], x[2]);
    974 ////  glRotatef( xRot, 1.0, 0.0, 0.0);
    975 ////  glRotatef( yRot, 0.0, 1.0, 0.0);
    976 ////  glRotatef( zRot, 0.0, 0.0, 1.0);
    977 //  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blueMaterial);
    978 //  gluSphere (q, (GLdouble)radius, 10, 10);
    979 //  glPopMatrix();
    980 //}
    981 //
    982 ///** Make a cylinder.
    983 // * \param x origin
    984 // * \param y direction
    985 // * \param radius thickness
    986 // * \param height length
    987 // * \color[3] color rgb values
    988 // */
    989 //void GLMoleculeView::makeCylinder(const Vector &x, const Vector &y, double radius, double height, const unsigned char color[3])
    990 //{
    991 //  float blueMaterial[] = { 255./(float)color[0], 255./(float)color[1], 255./(float)color[2], 1 };
    992 //  GLUquadricObj* q = gluNewQuadric ();
    993 //  gluQuadricOrientation(q, GLU_OUTSIDE);
    994 //  Vector a,b;
    995 //  Vector OtherAxis;
    996 //  double alpha;
    997 //  a = x - y;
    998 //  // construct rotation axis
    999 //  b = a;
    1000 //  b.VectorProduct(Z);
    1001 //  Line axis(zeroVec, b);
    1002 //  // calculate rotation angle
    1003 //  alpha = a.Angle(Z);
    1004 //  // construct other axis to check right-hand rule
    1005 //  OtherAxis = b;
    1006 //  OtherAxis.VectorProduct(Z);
    1007 //  // assure right-hand rule for the rotation
    1008 //  if (a.ScalarProduct(OtherAxis) < MYEPSILON)
    1009 //    alpha = M_PI-alpha;
    1010 //  // check
    1011 //  Vector a_rotated = axis.rotateVector(a, alpha);
    1012 //  std::cout << "Setting cylinder from "// << x << " to " << y
    1013 //      << a << " to " << a_rotated << " around " << b << " by " << alpha/M_PI*180. << ", respectively, "
    1014 //      << " with color r"
    1015 //      << (int)color[0] << ",g" << (int)color[1] << ",b" << (int)color[2] << "." << endl;
    1016 //
    1017 //  glPushMatrix();
    1018 //  glTranslatef( x[0], x[1], x[2]);
    1019 //  glRotatef( alpha/M_PI*180., b[0], b[1], b[2]);
    1020 //  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blueMaterial);
    1021 //  gluCylinder (q, (GLdouble)radius, (GLdouble)radius, (GLdouble)height, 10, 10);
    1022 //  glPopMatrix();
    1023 //}
    1024 //
    1025 ///** Defines the display CallList.
    1026 // * Goes through all molecules and their atoms and adds spheres for atoms and cylinders
    1027 // * for bonds. Heeds GLMoleculeView::SelectedAtom and GLMoleculeView::SelectedMolecule.
    1028 // */
    1029 //void GLMoleculeView::initializeGL()
    1030 //{
    1031 //  double x[3] = {-1, 0, -10};
    1032 //  unsigned char white[3] = {255,255,255};
    1033 //  Vector Position, OtherPosition;
    1034 //  QSize window = size();
    1035 //  width = window.width();
    1036 //  height = window.height();
    1037 //  std::cout << "Setting width to " << width << " and height to " << height << std::endl;
    1038 //  GLfloat shininess[] = { 0.0 };
    1039 //  GLfloat specular[] = { 0, 0, 0, 1 };
    1040 //  glClearColor(0.0f, 0.0f, 0.0f, 0.0f);     // Let OpenGL clear to black
    1041 //  object = glGenLists(1);
    1042 //  glNewList( object, GL_COMPILE );
    1043 //  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
    1044 //  glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
    1045 //
    1046 //  const std::vector<molecule*> &molecules = World::getInstance().getAllMolecules();
    1047 //
    1048 //  if (molecules.size() > 0) {
    1049 //    for (std::vector<molecule*>::const_iterator Runner = molecules.begin();
    1050 //        Runner != molecules.end();
    1051 //        Runner++) {
    1052 //      for (molecule::const_iterator atomiter = (*Runner)->begin();
    1053 //          atomiter != (*Runner)->end();
    1054 //          ++atomiter) {
    1055 //        // create atom
    1056 //        const element *ptr = (*atomiter)->getType();
    1057 //        boost::shared_ptr<Vector> MolCenter((*Runner)->DetermineCenterOfGravity());
    1058 //        Position = (*atomiter)->getPosition() - *MolCenter;
    1059 //        const unsigned char* color = NULL;
    1060 //        if ((World::getInstance().isSelected(*atomiter)) || (World::getInstance().isSelected((*Runner))))
    1061 //          color = SelectionColor;
    1062 //        else
    1063 //          color = ptr->getColor();
    1064 //        makeSphere(Position, ptr->getVanDerWaalsRadius()*0.25, color);
    1065 //
    1066 //        // create bonds
    1067 //        const BondList &bonds = (*atomiter)->getListOfBonds();
    1068 //        for (BondList::const_iterator bonditer = bonds.begin();
    1069 //            bonditer != bonds.end();
    1070 //            ++bonditer) {
    1071 //          if ((*bonditer)->leftatom->getId() == (*atomiter)->getId()) {
    1072 //            Position = (*bonditer)->leftatom->getPosition() - *MolCenter;
    1073 //            OtherPosition = (*bonditer)->rightatom->getPosition() - *MolCenter;
    1074 //            const double distance = sqrt(Position.DistanceSquared(OtherPosition))/2.;
    1075 //            const unsigned char *color1 = (*bonditer)->leftatom->getType()->getColor();
    1076 //            const unsigned char *color2 = (*bonditer)->rightatom->getType()->getColor();
    1077 //            makeCylinder(Position, OtherPosition, 0.1, distance, color1);
    1078 //            makeCylinder(OtherPosition, Position, 0.1, distance, color2);
    1079 //          }
    1080 //        }
    1081 //      }
    1082 //    }
    1083 //  } else {
    1084 //    makeSphere( x,1, white);
    1085 //  }
    1086 //  glEndList();
    1087 //}
    1088 //
    1089 //
    1090 ///* ================================== SLOTS ============================== */
    1091 //
    1092 ///** Initializes some public variables.
    1093 // * \param *ptr pointer to QLabel statusbar
    1094 // */
    1095 //void GLMoleculeView::init(QLabel *ptr)
    1096 //{
    1097 //  StatusBar = ptr;
    1098 //}
    1099 //
    1100 ///** Initializes the viewport statusbar.
    1101 // * \param *ptr pointer to QLabel for showing view pointcoordinates.
    1102 // */
    1103 //void GLMoleculeView::initCoordinates(QLabel *ptr)
    1104 //{
    1105 //  CoordinatesBar = ptr;
    1106 //}
    1107 //
    1108 ///** Slot to be called when to initialize GLMoleculeView::MolData.
    1109 // */
    1110 //void GLMoleculeView::createView( )
    1111 //{
    1112 //  initializeGL();
    1113 //  updateGL();
    1114 //}
    1115 //
    1116 ///** Slot of window is resized.
    1117 // * Copies new width and height to GLMoleculeView::width and GLMoleculeView::height and calls updateGL().
    1118 // * \param w new width of window
    1119 // * \param h new height of window
    1120 // */
    1121 //void GLMoleculeView::resizeGL( int w, int h )
    1122 //{
    1123 //  width = w;
    1124 //  height = h;
    1125 //  updateGL();
    1126 //}
    1127 //
    1128 ///** Sets x rotation angle.
    1129 // * sets GLMoleculeView::xRot and calls updateGL().
    1130 // * \param degrees new rotation angle in degrees
    1131 // */
    1132 //void GLMoleculeView::setXRotation( int degrees )
    1133 //{
    1134 //  xRot = (GLfloat)(degrees % 360);
    1135 //  updateGL();
    1136 //}
    1137 //
    1138 //
    1139 ///** Sets y rotation angle.
    1140 // * sets GLMoleculeView::yRot and calls updateGL().
    1141 // * \param degrees new rotation angle in degrees
    1142 // */
    1143 //void GLMoleculeView::setYRotation( int degrees )
    1144 //{
    1145 //  yRot = (GLfloat)(degrees % 360);
    1146 //  updateGL();
    1147 //}
    1148 //
    1149 //
    1150 ///** Sets z rotation angle.
    1151 // * sets GLMoleculeView::zRot and calls updateGL().
    1152 // * \param degrees new rotation angle in degrees
    1153 // */
    1154 //void GLMoleculeView::setZRotation( int degrees )
    1155 //{
    1156 //  zRot = (GLfloat)(degrees % 360);
    1157 //  updateGL();
    1158 //}
    1159 //
    1160 ///** Sets the scale of the scene.
    1161 // * sets GLMoleculeView::scale and calls updateGL().
    1162 // * \param distance distance divided by 100 is the new scale
    1163 // */
    1164 //void GLMoleculeView::setScale( int distance )
    1165 //{
    1166 //  scale = (GLfloat)(distance / 100.);
    1167 //  updateGL();
    1168 //}
    1169 //
    1170 ///** Update the ambient light.
    1171 // * \param light[4] light strength per axis and position (w)
    1172 // */
    1173 //void GLMoleculeView::setLightAmbient( int *light )
    1174 //{
    1175 //  for(int i=0;i<4;i++)
    1176 //    LightAmbient[i] = light[i];
    1177 //  updateGL();
    1178 //}
    1179 //
    1180 ///** Update the diffuse light.
    1181 // * \param light[4] light strength per axis and position (w)
    1182 // */
    1183 //void GLMoleculeView::setLightDiffuse( int *light )
    1184 //{
    1185 //  for(int i=0;i<4;i++)
    1186 //    LightDiffuse[i] = light[i];
    1187 //  updateGL();
    1188 //}
    1189 //
    1190 ///** Update the position of light.
    1191 // * \param light[4] light strength per axis and position (w)
    1192 // */
    1193 //void GLMoleculeView::setLightPosition( int *light )
    1194 //{
    1195 //  for(int i=0;i<4;i++)
    1196 //    LightPosition[i] = light[i];
    1197 //  updateGL();
    1198 //}
    1199 //
    1200 ///** Toggles the boolean GLMoleculeView::MultiViewEnabled.
    1201 // * Flips the boolean and calls updateGL().
    1202 // */
    1203 //void GLMoleculeView::toggleMultiViewEnabled ( )
    1204 //{
    1205 //  MultiViewEnabled = !MultiViewEnabled;
    1206 //  cout << "Setting MultiView to " << MultiViewEnabled << "." << endl;
    1207 //  updateGL();
    1208 //}
    1209 //
    1210 ///** Launch a dialog to configure the lights.
    1211 // */
    1212 //void GLMoleculeView::createDialogLight()
    1213 //{
    1214 ////  Ui_DialogLight *Lights = new Ui_DialogLight();
    1215 ////  if (Lights == NULL)
    1216 ////    return;
    1217 ////  // Set up the dynamic dialog here
    1218 ////  QLineEdit *Field = NULL;
    1219 ////  Field = Lights->findChild<QLineEdit *>("LightPositionX");
    1220 ////  if (Field) Field->setText( QString("%1").arg(LightPosition[0]) );
    1221 ////  Field = Lights->findChild<QLineEdit *>("LightPositionY");
    1222 ////  if (Field) Field->setText( QString("%1").arg(LightPosition[1]) );
    1223 ////  Field = Lights->findChild<QLineEdit *>("LightPositionZ");
    1224 ////  if (Field) Field->setText( QString("%1").arg(LightPosition[2]) );
    1225 ////  Field = Lights->findChild<QLineEdit *>("LightPositionW");
    1226 ////  if (Field) Field->setText( QString("%1").arg(LightPosition[3]) );
    1227 ////
    1228 ////  Field = Lights->findChild<QLineEdit *>("LightDiffuseX");
    1229 ////  if (Field) Field->setText( QString("%1").arg(LightDiffuse[0]) );
    1230 ////  Field = Lights->findChild<QLineEdit *>("LightDiffuseY");
    1231 ////  if (Field) Field->setText( QString("%1").arg(LightDiffuse[1]) );
    1232 ////  Field = Lights->findChild<QLineEdit *>("LightDiffuseZ");
    1233 ////  if (Field) Field->setText( QString("%1").arg(LightDiffuse[2]) );
    1234 ////  Field = Lights->findChild<QLineEdit *>("LightDiffuseW");
    1235 ////  if (Field) Field->setText( QString("%1").arg(LightDiffuse[3]) );
    1236 ////
    1237 ////  Field = Lights->findChild<QLineEdit *>("LightAmbientX");
    1238 ////  if (Field) Field->setText( QString("%1").arg(LightAmbient[0]) );
    1239 ////  Field = Lights->findChild<QLineEdit *>("LightAmbientY");
    1240 ////  if (Field) Field->setText( QString("%1").arg(LightAmbient[1]) );
    1241 ////  Field = Lights->findChild<QLineEdit *>("LightAmbientZ");
    1242 ////  if (Field) Field->setText( QString("%1").arg(LightAmbient[2]) );
    1243 ////  Field = Lights->findChild<QLineEdit *>("LightAmbientW");
    1244 ////  if (Field) Field->setText( QString("%1").arg(LightAmbient[3]) );
    1245 ////
    1246 ////  if ( Lights->exec() ) {
    1247 ////    //cout << "User accepted.\n";
    1248 ////    // The user accepted, act accordingly
    1249 ////    Field = Lights->findChild<QLineEdit *>("LightPositionX");
    1250 ////    if (Field) LightPosition[0] = Field->text().toDouble();
    1251 ////    Field = Lights->findChild<QLineEdit *>("LightPositionY");
    1252 ////    if (Field) LightPosition[1] = Field->text().toDouble();
    1253 ////    Field = Lights->findChild<QLineEdit *>("LightPositionZ");
    1254 ////    if (Field) LightPosition[2] = Field->text().toDouble();
    1255 ////    Field = Lights->findChild<QLineEdit *>("LightPositionW");
    1256 ////    if (Field) LightPosition[3] = Field->text().toDouble();
    1257 ////
    1258 ////    Field = Lights->findChild<QLineEdit *>("LightDiffuseX");
    1259 ////    if (Field) LightDiffuse[0] = Field->text().toDouble();
    1260 ////    Field = Lights->findChild<QLineEdit *>("LightDiffuseY");
    1261 ////    if (Field) LightDiffuse[1] = Field->text().toDouble();
    1262 ////    Field = Lights->findChild<QLineEdit *>("LightDiffuseZ");
    1263 ////    if (Field) LightDiffuse[2] = Field->text().toDouble();
    1264 ////    Field = Lights->findChild<QLineEdit *>("LightDiffuseW");
    1265 ////    if (Field) LightDiffuse[3] = Field->text().toDouble();
    1266 ////
    1267 ////    Field = Lights->findChild<QLineEdit *>("LightAmbientX");
    1268 ////    if (Field) LightAmbient[0] = Field->text().toDouble();
    1269 ////    Field = Lights->findChild<QLineEdit *>("LightAmbientY");
    1270 ////    if (Field) LightAmbient[1] = Field->text().toDouble();
    1271 ////    Field = Lights->findChild<QLineEdit *>("LightAmbientZ");
    1272 ////    if (Field) LightAmbient[2] = Field->text().toDouble();
    1273 ////    Field = Lights->findChild<QLineEdit *>("LightAmbientW");
    1274 ////    if (Field) LightAmbient[3] = Field->text().toDouble();
    1275 ////    updateGL();
    1276 ////  } else {
    1277 ////    //cout << "User reclined.\n";
    1278 ////  }
    1279 ////  delete(Lights);
    1280 //}
    1281 //
    1282 ///** Slot for event of pressed mouse button.
    1283 // * Switch discerns between buttons and stores position of event in GLMoleculeView::LeftButtonPos,
    1284 // * GLMoleculeView::MiddleButtonPos or GLMoleculeView::RightButtonPos.
    1285 // * \param *event structure containing information of the event
    1286 // */
    1287 //void GLMoleculeView::mousePressEvent(QMouseEvent *event)
    1288 //{
    1289 //  std::cout << "MousePressEvent." << endl;
    1290 //  QPoint *pos = NULL;
    1291 //  switch (event->button()) {  // get the right array
    1292 //    case Qt::LeftButton:
    1293 //      pos = &LeftButtonPos;
    1294 //      std::cout << "Left Button" << endl;
    1295 //      break;
    1296 //    case Qt::MidButton:
    1297 //      pos = &MiddleButtonPos;
    1298 //      std::cout << "Middle Button" << endl;
    1299 //      break;
    1300 //    case Qt::RightButton:
    1301 //      pos = &RightButtonPos;
    1302 //      std::cout << "Right Button" << endl;
    1303 //      break;
    1304 //    default:
    1305 //      break;
    1306 //  }
    1307 //  if (pos) {    // store the position
    1308 //    pos->setX(event->pos().x());
    1309 //    pos->setY(event->pos().y());
    1310 //    std::cout << "Stored src position is (" << pos->x() << "," << pos->y() << ")." << endl;
    1311 //  } else {
    1312 //    std::cout << "pos is NULL." << endl;
    1313 //  }
    1314 //}
    1315 //
    1316 ///** Slot for event of pressed mouse button.
    1317 // * Switch discerns between buttons:
    1318 // * -# Left Button: Rotates the view of the GLMoleculeView, relative to GLMoleculeView::LeftButtonPos.
    1319 // * -# Middle Button: nothing
    1320 // * -# Right Button: Shifts the selected molecule or atom, relative to GLMoleculeView::RightButtonPos.
    1321 // * \param *event structure containing information of the event
    1322 // */
    1323 //void GLMoleculeView::mouseReleaseEvent(QMouseEvent *event)
    1324 //{
    1325 //  std::cout << "MouseReleaseEvent." << endl;
    1326 //  QPoint *srcpos = NULL;
    1327 //  QPoint destpos = event->pos();
    1328 //  int Width = (MultiViewEnabled) ? width/2 : width;
    1329 //  int Height = (MultiViewEnabled) ? height/2 : height;
    1330 //  std::cout << "Received dest position is (" << destpos.x() << "," << destpos.y() << ")." << endl;
    1331 //  switch (event->button()) {  // get the right array
    1332 //    case Qt::LeftButton:  // LeftButton rotates the view
    1333 //      srcpos = &LeftButtonPos;
    1334 //      std::cout << "Left Button" << endl;
    1335 //      if (srcpos) {    // subtract the position and act
    1336 //        std::cout << "Stored src position is (" << srcpos->x() << "," << srcpos->y() << ")." << endl;
    1337 //        destpos -= *srcpos;
    1338 //        std::cout << "Resulting diff position is (" << destpos.x() << "," << destpos.y() << ")." << endl;
    1339 //        std::cout << "Width and Height are " << Width << "," << Height << "." << endl;
    1340 //
    1341 //        int pos = (int)floor((double)srcpos->x()/(double)Width) + ((int)floor((double)srcpos->y()/(double)Height))*2;
    1342 //        if ((MultiViewEnabled) && (pos != 2)) { // means four regions, and we are in a shifting one
    1343 //          // switch between three regions
    1344 //          // decide into which of the four screens the initial click has been made
    1345 //          std::cout << "Position is " << pos << "." << endl;
    1346 //          switch(pos) {
    1347 //            case 0:  // lower left = xz
    1348 //              position[0] += -destpos.y()/100.;
    1349 //              position[2] += destpos.x()/100.;
    1350 //              break;
    1351 //            case 1: // lower right = yz
    1352 //              position[1] += -destpos.y()/100.;
    1353 //              position[2] += -destpos.x()/100.;
    1354 //              break;
    1355 //            case 2:  // upper left = projected
    1356 //              std::cout << "This is impossible: Shifting in the projected region, we should rotate!." << endl;
    1357 //              break;
    1358 //            case 3:  // upper right = xy
    1359 //              position[0] += destpos.x()/100.;
    1360 //              position[1] += -destpos.y()/100.;
    1361 //              break;
    1362 //            default:
    1363 //              std::cout << "click was not in any of the four regions." << endl;
    1364 //              break;
    1365 //          }
    1366 //          updateGL();
    1367 //        } else { // we are in rotation region
    1368 //          QWidget *Parent = parentWidget();
    1369 //          QSlider *sliderX = Parent->findChild<QSlider *>("sliderX");
    1370 //          QSlider *sliderY = Parent->findChild<QSlider *>("sliderY");
    1371 //          std::cout << sliderX << " and " << sliderY << endl;
    1372 //          if (sliderX) {
    1373 //            int xrange = sliderX->maximum() - sliderX->minimum();
    1374 //            double xValue = ((destpos.x() + Width) % Width);
    1375 //            xValue *= (double)xrange/(double)Width;
    1376 //            xValue += sliderX->value();
    1377 //            int xvalue = (int) xValue % xrange;
    1378 //            std::cout << "Setting x to " << xvalue << " within range " << xrange << "." << endl;
    1379 //            setXRotation(xvalue);
    1380 //            sliderX->setValue(xvalue);
    1381 //          } else {
    1382 //            std::cout << "sliderX is NULL." << endl;
    1383 //          }
    1384 //          if (sliderY) {
    1385 //            int yrange = sliderY->maximum() - sliderY->minimum();
    1386 //            double yValue = ((destpos.y() + Height) % Height);
    1387 //            yValue *= (double)yrange/(double)Height;
    1388 //            yValue += sliderY->value();
    1389 //            int yvalue = (int) yValue % yrange;
    1390 //            std::cout << "Setting y to " << yvalue << " within range " << yrange << "." << endl;
    1391 //            setYRotation(yvalue);
    1392 //            sliderY->setValue(yvalue);
    1393 //          } else {
    1394 //            std::cout << "sliderY is NULL." << endl;
    1395 //          }
    1396 //        }
    1397 //      } else {
    1398 //        std::cout << "srcpos is NULL." << endl;
    1399 //      }
    1400 //      break;
    1401 //
    1402 //    case Qt::MidButton: // MiddleButton has no function so far
    1403 //      srcpos = &MiddleButtonPos;
    1404 //      std::cout << "Middle Button" << endl;
    1405 //      if (srcpos) {    // subtract the position and act
    1406 //        QWidget *Parent = parentWidget();
    1407 //        QSlider *sliderZ = Parent->findChild<QSlider *>("sliderZ");
    1408 //        QSlider *sliderScale = Parent->findChild<QSlider *>("sliderScale");
    1409 //        std::cout << sliderZ << " and " << sliderScale << endl;
    1410 //        std::cout << "Stored src position is (" << srcpos->x() << "," << srcpos->y() << ")." << endl;
    1411 //        destpos -= *srcpos;
    1412 //        std::cout << "Resulting diff position is (" << destpos.x() << "," << destpos.y() << ")." << endl;
    1413 //        std::cout << "Width and Height are " << Width << "," << Height << "." << endl;
    1414 //        if (sliderZ) {
    1415 //          int xrange = sliderZ->maximum() - sliderZ->minimum();
    1416 //          double xValue = ((destpos.x() + Width) % Width);
    1417 //          xValue *= (double)xrange/(double)Width;
    1418 //          xValue += sliderZ->value();
    1419 //          int xvalue = (int) xValue % xrange;
    1420 //          std::cout << "Setting x to " << xvalue << " within range " << xrange << "." << endl;
    1421 //          setZRotation(xvalue);
    1422 //          sliderZ->setValue(xvalue);
    1423 //        } else {
    1424 //          std::cout << "sliderZ is NULL." << endl;
    1425 //        }
    1426 //        if (sliderScale) {
    1427 //          int yrange = sliderScale->maximum() - sliderScale->minimum();
    1428 //          double yValue = ((destpos.y() + Height) % Height);
    1429 //          yValue *= (double)yrange/(double)Height;
    1430 //          yValue += sliderScale->value();
    1431 //          int yvalue = (int) yValue % yrange;
    1432 //          std::cout << "Setting y to " << yvalue << " within range " << yrange << "." << endl;
    1433 //          setScale(yvalue);
    1434 //          sliderScale->setValue(yvalue);
    1435 //        } else {
    1436 //          std::cout << "sliderScale is NULL." << endl;
    1437 //        }
    1438 //      } else {
    1439 //        std::cout << "srcpos is NULL." << endl;
    1440 //      }
    1441 //      break;
    1442 //      break;
    1443 //
    1444 //    case Qt::RightButton:  // RightButton moves eitstdher the selected molecule or atom
    1445 //      srcpos = &RightButtonPos;
    1446 //      std::cout << "Right Button" << endl;
    1447 //      if (srcpos) {    // subtract the position and act
    1448 //        std::cout << "Stored src position is (" << srcpos->x() << "," << srcpos->y() << ")." << endl;
    1449 //        destpos -= *srcpos;
    1450 //        std::cout << "Resulting diff position is (" << destpos.x() << "," << destpos.y() << ")." << endl;
    1451 //        std::cout << "Width and Height are " << Width << "," << Height << "." << endl;
    1452 //        if (MultiViewEnabled) {
    1453 //          // which vector to change
    1454 //          Vector SelectedPosition;
    1455 //          const std::vector<atom*> &SelectedAtoms = World::getInstance().getSelectedAtoms();
    1456 //          const std::vector<molecule*> &SelectedMolecules = World::getInstance().getSelectedMolecules();
    1457 //          if (SelectedMolecules.size()) {
    1458 //            if (SelectedAtoms.size())
    1459 //              SelectedPosition = (*SelectedAtoms.begin())->getPosition();
    1460 //            else
    1461 //              SelectedPosition = (*(*SelectedMolecules.begin())->begin())->getPosition();
    1462 //          }
    1463 //          // decide into which of the four screens the initial click has been made
    1464 //          int pos = (int)floor((double)srcpos->x()/(double)Width) + ((int)floor((double)srcpos->y()/(double)Height))*2;
    1465 //          if (!SelectedPosition.IsZero()) {
    1466 //            std::cout << "Position is " << pos << "." << endl;
    1467 //            switch(pos) {
    1468 //              case 0:  // lower left = xz
    1469 //                SelectedPosition[0] += -destpos.y()/100.;
    1470 //                SelectedPosition[2] += destpos.x()/100.;
    1471 //                break;
    1472 //              case 1: // lower right = yz
    1473 //                SelectedPosition[1] += -destpos.y()/100.;
    1474 //                SelectedPosition[2] += -destpos.x()/100.;
    1475 //                break;
    1476 //              case 2:  // upper left = projected
    1477 //                SelectedPosition[0] += destpos.x()/100.;
    1478 //                SelectedPosition[1] += destpos.y()/100.;
    1479 //                SelectedPosition[2] += destpos.y()/100.;
    1480 //                break;
    1481 //              case 3:  // upper right = xy
    1482 //                SelectedPosition[0] += destpos.x()/100.;
    1483 //                SelectedPosition[1] += -destpos.y()/100.;
    1484 //                break;
    1485 //              default:
    1486 //                std::cout << "click was not in any of the four regions." << endl;
    1487 //                break;
    1488 //            }
    1489 //          } else {
    1490 //            std::cout << "Nothing selected." << endl;
    1491 //          }
    1492 //          // update Tables
    1493 //          if (SelectedMolecules.size()) {
    1494 //            isSignaller = true;
    1495 //            if (SelectedAtoms.size())
    1496 //              emit notifyAtomChanged( (*SelectedMolecules.begin()), (*SelectedAtoms.begin()), AtomPosition);
    1497 //            else
    1498 //              emit notifyMoleculeChanged( (*SelectedMolecules.begin()), MoleculePosition );
    1499 //          }
    1500 //          // update graphic
    1501 //          initializeGL();
    1502 //          updateGL();
    1503 //        } else {
    1504 //          cout << "MultiView is not enabled." << endl;
    1505 //        }
    1506 //      } else {
    1507 //        cout << "srcpos is NULL." << endl;
    1508 //      }
    1509 //  break;
    1510 //
    1511 //    default:
    1512 //      break;
    1513 //  }
    1514 //}
    1515 //
    1516 ///* ======================================== SLOTS ================================ */
    1517 //
    1518 ///** Hear announcement of selected molecule.
    1519 // * \param *mol pointer to selected molecule
    1520 // */
    1521 //void GLMoleculeView::hearMoleculeSelected(molecule *mol)
    1522 //{
    1523 //  if (isSignaller) { // if we emitted the signal, return
    1524 //    isSignaller = false;
    1525 //    return;
    1526 //  }
    1527 //  initializeGL();
    1528 //  updateGL();
    1529 //};
    1530 //
    1531 ///** Hear announcement of selected atom.
    1532 // * \param *mol pointer to molecule containing atom
    1533 // * \param *Walker pointer to selected atom
    1534 // */
    1535 //void GLMoleculeView::hearAtomSelected(molecule *mol, atom *Walker)
    1536 //{
    1537 //  if (isSignaller) { // if we emitted the signal, return
    1538 //    isSignaller = false;
    1539 //    return;
    1540 //  }
    1541 //  initializeGL();
    1542 //  updateGL();
    1543 //};
    1544 //
    1545 ///** Hear announcement of changed molecule.
    1546 // * \param *mol pointer to changed molecule
    1547 // * \param type of change
    1548 // */
    1549 //void GLMoleculeView::hearMoleculeChanged(molecule *mol, enum ChangesinMolecule type)
    1550 //{
    1551 //  if (isSignaller) { // if we emitted the signal, return
    1552 //    isSignaller = false;
    1553 //    return;
    1554 //  }
    1555 //  initializeGL();
    1556 //  updateGL();
    1557 //};
    1558 //
    1559 ///** Hear announcement of changed atom.
    1560 // * \param *mol pointer to molecule containing atom
    1561 // * \param *Walker pointer to changed atom
    1562 // * \param type type of change
    1563 // */
    1564 //void GLMoleculeView::hearAtomChanged(molecule *mol, atom *Walker, enum ChangesinAtom type)
    1565 //{
    1566 //  if (isSignaller) { // if we emitted the signal, return
    1567 //    isSignaller = false;
    1568 //    return;
    1569 //  }
    1570 //  initializeGL();
    1571 //  updateGL();
    1572 //};
    1573 //
    1574 ///** Hear announcement of changed element.
    1575 // * \param *Runner pointer to changed element
    1576 // * \param type of change
    1577 // */
    1578 //void GLMoleculeView::hearElementChanged(element *Runner, enum ChangesinElement type)
    1579 //{
    1580 //  if (isSignaller) { // if we emitted the signal, return
    1581 //    isSignaller = false;
    1582 //    return;
    1583 //  }
    1584 //  switch(type) {
    1585 //    default:
    1586 //    case ElementName:
    1587 //    case ElementSymbol:
    1588 //    case ElementMass:
    1589 //    case ElementValence:
    1590 //    case ElementZ:
    1591 //      break;
    1592 //    case ElementCovalent:
    1593 //    case ElementVanderWaals:
    1594 //      initializeGL();
    1595 //      updateGL();
    1596 //      break;
    1597 //  }
    1598 //};
    1599 //
    1600 ///** Hear announcement of added molecule.
    1601 // * \param *mol pointer to added molecule
    1602 // */
    1603 //void GLMoleculeView::hearMoleculeAdded(molecule *mol)
    1604 //{
    1605 //  if (isSignaller) { // if we emitted the signal, return
    1606 //    isSignaller = false;
    1607 //    return;
    1608 //  }
    1609 //  initializeGL();
    1610 //  updateGL();
    1611 //};
    1612 //
    1613 ///** Hear announcement of added atom.
    1614 // * \param *mol pointer to molecule containing atom
    1615 // * \param *Walker pointer to added atom
    1616 // */
    1617 //void GLMoleculeView::hearAtomAdded(molecule *mol, atom *Walker)
    1618 //{
    1619 //  if (isSignaller) { // if we emitted the signal, return
    1620 //    isSignaller = false;
    1621 //    return;
    1622 //  }
    1623 //  initializeGL();
    1624 //  updateGL();
    1625 //};
    1626 //
    1627 ///** Hear announcement of removed molecule.
    1628 // * \param *mol pointer to removed molecule
    1629 // */
    1630 //void GLMoleculeView::hearMoleculeRemoved(molecule *mol)
    1631 //{
    1632 //  if (isSignaller) { // if we emitted the signal, return
    1633 //    isSignaller = false;
    1634 //    return;
    1635 //  }
    1636 //  initializeGL();
    1637 //  updateGL();
    1638 //};
    1639 //
    1640 ///** Hear announcement of removed atom.
    1641 // * \param *mol pointer to molecule containing atom
    1642 // * \param *Walker pointer to removed atom
    1643 // */
    1644 //void GLMoleculeView::hearAtomRemoved(molecule *mol, atom *Walker)
    1645 //{
    1646 //  if (isSignaller) { // if we emitted the signal, return
    1647 //    isSignaller = false;
    1648 //    return;
    1649 //  }
    1650 //  initializeGL();
    1651 //  updateGL();
    1652 //};
    1653 //
    1654 //void GLMoleculeView::update(Observable *publisher)
    1655 //{
    1656 //  initializeGL();
    1657 //  updateGL();
    1658 //}
    1659 //
    1660 ///**
    1661 // * This method is called when a special named change
    1662 // * of the Observable occured
    1663 // */
    1664 //void GLMoleculeView::recieveNotification(Observable *publisher, Notification_ptr notification)
    1665 //{
    1666 //  initializeGL();
    1667 //  updateGL();
    1668 //}
    1669 //
    1670 ///**
    1671 // * This method is called when the observed object is destroyed.
    1672 // */
    1673 //void GLMoleculeView::subjectKilled(Observable *publisher)
    1674 //{
    1675 //
    1676 //}
    1677 //
    1678 //
    1679 //// new stuff
    1680 //
    1681 ///** Returns the ref to the Material for element No \a from the map.
    1682 // *
    1683 // * \note We create a new one if the element is missing.
    1684 // *
    1685 // * @param no element no
    1686 // * @return ref to QGLMaterial
    1687 // */
    1688 //QGLMaterial* GLMoleculeView::getMaterial(size_t no)
    1689 //{
    1690 //  if (ElementNoMaterialMap.find(no) != ElementNoMaterialMap.end()){
    1691 //    // get present one
    1692 //
    1693 //  } else {
    1694 //    ASSERT( (no >= 0) && (no < MAX_ELEMENTS),
    1695 //        "GLMoleculeView::getMaterial() - Element no "+toString(no)+" is invalid.");
    1696 //    // create new one
    1697 //    LOG(1, "Creating new material for element "+toString(no)+".");
    1698 //    QGLMaterial *newmaterial = new QGLMaterial(this);
    1699 //    periodentafel *periode = World::getInstance().getPeriode();
    1700 //    element *desiredelement = periode->FindElement(no);
    1701 //    ASSERT(desiredelement != NULL,
    1702 //        "GLMoleculeView::getMaterial() - desired element "+toString(no)+" not present in periodentafel.");
    1703 //    const unsigned char* color = desiredelement->getColor();
    1704 //    newmaterial->setAmbientColor( QColor(color[0], color[1], color[2]) );
    1705 //    newmaterial->setSpecularColor( QColor(60, 60, 60) );
    1706 //    newmaterial->setShininess( QColor(128) );
    1707 //    ElementNoMaterialMap.insert( no, newmaterial);
    1708 //  }
    1709 //}
    1710 //
    1711 //QGLSceneNode* GLMoleculeView::getAtom(size_t no)
    1712 //{
    1713 //  // first some sensibility checks
    1714 //  ASSERT(World::getInstance().getAtom(AtomById(no)) != NULL,
    1715 //      "GLMoleculeView::getAtom() - desired atom "
    1716 //      +toString(no)+" not present in the World.");
    1717 //  ASSERT(AtomsinSceneMap.find(no) != AtomsinSceneMap.end(),
    1718 //      "GLMoleculeView::getAtom() - desired atom "
    1719 //      +toString(no)+" not present in the AtomsinSceneMap.");
    1720 //
    1721 //  return AtomsinSceneMap[no];
    1722 //}
    1723 //
    1724 //QGLSceneNode* GLMoleculeView::getBond(size_t leftno, size_t rightno)
    1725 //{
    1726 //  // first some sensibility checks
    1727 //  ASSERT(World::getInstance().getAtom(AtomById(leftno)) != NULL,
    1728 //      "GLMoleculeView::getAtom() - desired atom "
    1729 //      +toString(leftno)+" of bond not present in the World.");
    1730 //  ASSERT(World::getInstance().getAtom(AtomById(rightno)) != NULL,
    1731 //      "GLMoleculeView::getAtom() - desired atom "
    1732 //      +toString(rightno)+" of bond not present in the World.");
    1733 //  ASSERT(AtomsinSceneMap.find(leftno) != AtomsinSceneMap.end(),
    1734 //      "GLMoleculeView::getAtom() - desired atom "
    1735 //      +toString(leftno)+" of bond not present in the AtomsinSceneMap.");
    1736 //  ASSERT(AtomsinSceneMap.find(rightno) != AtomsinSceneMap.end(),
    1737 //      "GLMoleculeView::getAtom() - desired atom "
    1738 //      +toString(rightno)+" of bond not present in the AtomsinSceneMap.");
    1739 //  ASSERT(leftno == rightno,
    1740 //      "GLMoleculeView::getAtom() - bond must not be between the same atom: "
    1741 //      +toString(leftno)+" == "+toString(rightno)+".");
    1742 //
    1743 //  // then return with smaller index first
    1744 //  if (leftno > rightno)
    1745 //    return AtomsinSceneMap[ make_pair(rightno, leftno) ];
    1746 //  else
    1747 //    return AtomsinSceneMap[ make_pair(leftno, rightno) ];
    1748 //}
    1749 //
  • src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp

    r29b35e r55736b  
    126126};
    127127
    128 
    129 
    130 //#include "CodePatterns/Observer/Observer.hpp"
    131 //#include "LinearAlgebra/Vector.hpp"
    132 //#include "changetypes.hpp"
    133 //
    134 //class atom;
    135 //class element;
    136 //class molecule;
    137 //
    138 //class GLMoleculeView : public QGLWidget, public Observer
    139 //{
    140 //    Q_OBJECT
    141 //
    142 //public:
    143 //
    144 //    GLMoleculeView( QWidget* parent);
    145 //    ~GLMoleculeView();
    146 //
    147 //public slots:
    148 //
    149 //    void    setXRotation( int degrees );
    150 //    void    setYRotation( int degrees );
    151 //    void    setZRotation( int degrees );
    152 //    void    setScale( int distance );
    153 //    void    setLightPosition( int *light );
    154 //    void    setLightDiffuse( int *light );
    155 //    void    setLightAmbient( int *light );
    156 //    void    createDialogLight();
    157 //    void    toggleMultiViewEnabled();
    158 //
    159 //    void    init( QLabel *ptr );
    160 //    void    initCoordinates(QLabel *ptr);
    161 //    void    createView();
    162 //    void    hearMoleculeSelected(molecule *mol);
    163 //    void    hearAtomSelected(molecule *mol, atom *Walker);
    164 //    void    hearMoleculeChanged(molecule *mol, enum ChangesinMolecule type);
    165 //    void    hearAtomChanged(molecule *mol, atom *Walker, enum ChangesinAtom type);
    166 //    void    hearElementChanged(element *Runner, enum ChangesinElement type);
    167 //    void    hearMoleculeAdded(molecule *mol);
    168 //    void    hearAtomAdded(molecule *mol, atom *Walker);
    169 //    void    hearMoleculeRemoved(molecule *mol);
    170 //    void    hearAtomRemoved(molecule *mol, atom *Walker);
    171 //
    172 //signals:
    173 //    void    notifyMoleculeSelected( molecule *mol );
    174 //    void    notifyAtomSelected( molecule *mol, atom *Walker );
    175 //    void    notifyMoleculeChanged( molecule *mol, enum ChangesinMolecule type );
    176 //    void    notifyAtomChanged( molecule *mol, atom *Walker, enum ChangesinAtom type );
    177 //    void    notifyElementChanged( element *Runner, enum ChangesinElement type );
    178 //    void    notifyMoleculeAdded( molecule *mol);
    179 //    void    notifyElementAdded( element *Runner);
    180 //    void    notifyAtomAdded( molecule *mol, atom *Walker );
    181 //    void    notifyMoleculeRemoved( molecule *mol );
    182 //    void    notifyAtomRemoved( molecule *mol, atom *Walker );
    183 //
    184 //protected:
    185 //
    186 //    void    initializeGL();
    187 //    void    paintGL();
    188 //    void    resizeGL( int w, int h );
    189 //    void    makeSphere(const Vector &x, double radius, const unsigned char color[3]);
    190 //    void    makeCylinder(const Vector &x, const Vector &y, double radius, double height, const unsigned char color[3]);
    191 //    void mousePressEvent(QMouseEvent* event);
    192 //    void mouseReleaseEvent(QMouseEvent* event);
    193 //
    194 //public:
    195 //
    196 //    /** Update function as we are an Observer.
    197 //     *
    198 //     * @param publisher ref to Observable
    199 //     */
    200 //    void update(Observable *publisher);
    201 //
    202 //    /**
    203 //     * This method is called when a special named change
    204 //     * of the Observable occured
    205 //     */
    206 //    void recieveNotification(Observable *publisher, Notification_ptr notification);
    207 //
    208 //    /**
    209 //     * This method is called when the observed object is destroyed.
    210 //     */
    211 //    void subjectKilled(Observable *publisher);
    212 //
    213 //
    214 //private:
    215 //
    216 //    typedef std::map< size_t, node > AtomNodeMap;
    217 //    typedef std::map< std::pair< size_t, size_t> , node > BondNodeMap;
    218 //    typedef std::map< size_t, QGLMaterial *> ElementMaterialMap;
    219 //
    220 //    ElementMaterialMap ElementNoMaterialMap;
    221 //    AtomNodeMap AtomsinSceneMap;
    222 //    BondNodeMap BondsinSceneMap;
    223 //
    224 //    QGLMaterial* getMaterial(size_t);
    225 //    QGLSceneNode* getAtom(size_t);
    226 //    QGLSceneNode* getBond(size_t, size_t);
    227 //
    228 //    // old stuff
    229 //
    230 //    GLuint object;  // call list for the scene to be rendered
    231 //    GLfloat xRot, yRot, zRot, scale;  // rotation angles and scaling (zoom)
    232 //    Vector position;  //!< position of observer
    233 //    Vector view;      //!< point along line of view
    234 //    Vector top;       //!< giving upwards direction
    235 //    Vector X,Y,Z;     //!< vectors defining the coordinate system
    236 //    int width;        //!< width of window
    237 //    int height;       //!< height of window
    238 //
    239 //  QLabel *StatusBar;  //!< pointer to status bar for messages
    240 //  QLabel *CoordinatesBar; //!< pointer to coordinates bar for view port
    241 //
    242 //  GLfloat LightPosition[4];        //!< Light Position
    243 //  GLfloat LightDiffuse[4];         //!< Diffuse Light Values
    244 //  GLfloat LightAmbient[4];        //!< Ambient Light Values
    245 //
    246 //  QPoint LeftButtonPos;     //!< mouse position on mousePressEvent for LeftButton
    247 //  QPoint MiddleButtonPos;   //!< mouse position on mousePressEvent for MidButton
    248 //  QPoint RightButtonPos;    //!< mouse position on mousePressEvent for RightButton
    249 //
    250 //  unsigned char SelectionColor[3] ; //!< highlight color
    251 //
    252 //  bool isSignaller;
    253 //
    254 //  bool MultiViewEnabled;    //!< if true, split screen into four parts with additional xy,xz,yz views
    255 //};
    256 
    257128#endif /* GLWORLDVIEW_HPP_ */
  • src/documentation/constructs/filling.dox

    r29b35e r55736b  
    7474 * the specific implementations of the class \ref Inserter.
    7575 *
     76 * \section filling-preparators Filling Preparators
    7677 *
    77  * \date 2014-03-10
     78 * The filling function depends on quite a number of other instances. In order
     79 * to make this a little easier to use, there are so called FillerPreparators
     80 * for various purposes:
     81 * -# BoxFillerPreparator - fills the simulation domain
     82 * -# ShapeSurfaceFillerPreparator - fills on the surface of a selected shape
     83 * -# ShapeVolumeFillerPreparator - fills the volume of a selected shape
     84 *
     85 * These offer various functions to easily install an Inserter, a Mesh, and
     86 * necessary FillPredicates. See the Filling Actions such as
     87 * MoleCuilder::FillVolumeAction as example.
     88 *
     89 * \date 2014-09-04
    7890 */
  • src/molecule.cpp

    r29b35e r55736b  
    751751};
    752752
    753 /** Sets the molecule::cell_size to the components of \a *dim (rectangular box)
    754  * \param *dim vector class
    755  */
    756 void molecule::SetBoxDimension(Vector *dim)
    757 {
    758   RealSpaceMatrix domain;
    759   for(int i =0; i<NDIM;++i)
    760     domain.at(i,i) = dim->at(i);
    761   World::getInstance().setDomain(domain);
    762 };
    763 
    764753/** Removes atom from molecule list, but does not delete it.
    765754 * \param *pointer atom to be removed
  • src/molecule.hpp

    r29b35e r55736b  
    273273  bool CenterInBox();
    274274  bool BoundInBox();
    275   void CenterEdge(Vector *max);
     275  void CenterEdge();
    276276  void CenterOrigin();
    277277  void CenterPeriodic();
    278   void CenterAtVector(Vector *newcenter);
    279   void Translate(const Vector *x);
    280   void TranslatePeriodically(const Vector *trans);
    281   void Mirror(const Vector *x);
    282   void Align(Vector *n);
    283   void Scale(const double ** const factor);
     278  void CenterAtVector(const Vector &newcenter);
     279  void Translate(const Vector &x);
     280  void TranslatePeriodically(const Vector &trans);
     281  void Mirror(const Vector &x);
     282  void Align(const Vector &n);
     283  void Scale(const double *factor);
    284284  void DeterminePeriodicCenter(Vector &center, const enum HydrogenTreatment _treatment = ExcludeHydrogen);
    285   Vector * DetermineCenterOfGravity() const;
    286   Vector * DetermineCenterOfAll() const;
    287   Vector * DetermineCenterOfBox() const;
     285  const Vector DetermineCenterOfGravity() const;
     286  const Vector DetermineCenterOfAll() const;
    288287  void SetNameFromFilename(const char *filename);
    289   void SetBoxDimension(Vector *dim);
    290288  bool ScanForPeriodicCorrection();
    291289  double VolumeOfConvexEnvelope(bool IsAngstroem);
  • src/molecule_geometry.cpp

    r29b35e r55736b  
    5858/************************************* Functions for class molecule *********************************/
    5959
     60/** Returns vector pointing to center of the domain.
     61 * \return pointer to center of the domain
     62 */
     63#ifdef HAVE_INLINE
     64inline
     65#else
     66static
     67#endif
     68const Vector DetermineCenterOfBox()
     69{
     70  Vector a(0.5,0.5,0.5);
     71  const RealSpaceMatrix &M = World::getInstance().getDomain().getM();
     72  a *= M;
     73  return a;
     74}
    6075
    6176/** Centers the molecule in the box whose lengths are defined by vector \a *BoxLengths.
     
    6580{
    6681  bool status = true;
    67   const Vector *Center = DetermineCenterOfAll();
    68   const Vector *CenterBox = DetermineCenterOfBox();
     82  const Vector Center = DetermineCenterOfAll();
     83  const Vector CenterBox = DetermineCenterOfBox();
    6984  Box &domain = World::getInstance().getDomain();
    7085
    7186  // go through all atoms
    72   for (iterator iter = begin(); iter != end(); ++iter) {
    73     if (DoLog(4) && (*Center != *CenterBox))
    74       LOG(4, "INFO: atom before is at " << **iter);
    75     **iter -= *Center;
    76     **iter += *CenterBox;
    77     if (DoLog(4) && (*Center != *CenterBox))
    78       LOG(4, "INFO: atom after is at " << **iter);
    79   }
     87  Translate(CenterBox - Center);
    8088  getAtomSet().transformNodes(boost::bind(&Box::enforceBoundaryConditions,domain,_1));
    8189
    82   delete(Center);
    83   delete(CenterBox);
    8490  return status;
    85 };
     91}
    8692
    8793
     
    98104
    99105  return status;
    100 };
     106}
    101107
    102108/** Centers the edge of the atoms at (0,0,0).
    103  * \param *out output stream for debugging
    104  * \param *max coordinates of other edge, specifying box dimensions.
    105  */
    106 void molecule::CenterEdge(Vector *max)
    107 {
    108 //  Info info(__func__);
    109   Vector *min = new Vector;
    110 
    111   const_iterator iter = begin();  // start at first in list
    112   if (iter != end()) { //list not empty?
    113     for (int i=NDIM;i--;) {
    114       max->at(i) = (*iter)->at(i);
    115       min->at(i) = (*iter)->at(i);
    116     }
    117     for (; iter != end(); ++iter) {// continue with second if present
    118       //(*iter)->Output(1,1,out);
    119       for (int i=NDIM;i--;) {
    120         max->at(i) = (max->at(i) < (*iter)->at(i)) ? (*iter)->at(i) : max->at(i);
    121         min->at(i) = (min->at(i) > (*iter)->at(i)) ? (*iter)->at(i) : min->at(i);
    122       }
    123     }
    124     LOG(1, "INFO: Maximum is " << *max << ", Minimum is " << *min << ".");
    125     min->Scale(-1.);
    126     (*max) += (*min);
    127     Translate(min);
    128   }
    129   delete(min);
    130 };
     109 */
     110void molecule::CenterEdge()
     111{
     112  const_iterator iter = begin();
     113  if (iter != end()) {   //list not empty?
     114    Vector min = (*begin())->getPosition();
     115    for (;iter != end(); ++iter) { // continue with second if present
     116      const Vector &currentPos = (*iter)->getPosition();
     117      for (size_t i=0;i<NDIM;++i)
     118        if (min[i] > currentPos[i])
     119          min[i] = currentPos[i];
     120    }
     121    Translate(-1.*min);
     122  }
     123}
    131124
    132125/** Centers the center of the atoms at (0,0,0).
     
    147140    }
    148141    Center.Scale(-1./(double)Num); // divide through total number (and sign for direction)
    149     Translate(&Center);
    150   }
    151 };
     142    Translate(Center);
     143  }
     144}
    152145
    153146/** Returns vector pointing to center of all atoms.
    154147 * \return pointer to center of all vector
    155148 */
    156 Vector * molecule::DetermineCenterOfAll() const
     149const Vector molecule::DetermineCenterOfAll() const
    157150{
    158151  const_iterator iter = begin();  // start at first in list
    159   Vector *a = new Vector();
     152  Vector a;
    160153  double Num = 0;
    161154
    162   a->Zero();
     155  a.Zero();
    163156
    164157  if (iter != end()) {   //list not empty?
    165158    for (; iter != end(); ++iter) {  // continue with second if present
    166159      Num++;
    167       (*a) += (*iter)->getPosition();
    168     }
    169     a->Scale(1./(double)Num); // divide through total mass (and sign for direction)
     160      a += (*iter)->getPosition();
     161    }
     162    a.Scale(1./(double)Num); // divide through total mass (and sign for direction)
    170163  }
    171164  return a;
    172 };
    173 
    174 /** Returns vector pointing to center of the domain.
    175  * \return pointer to center of the domain
    176  */
    177 Vector * molecule::DetermineCenterOfBox() const
    178 {
    179   Vector *a = new Vector(0.5,0.5,0.5);
    180   const RealSpaceMatrix &M = World::getInstance().getDomain().getM();
    181   (*a) *= M;
    182   return a;
    183 };
     165}
     166
    184167
    185168/** Returns vector pointing to center of gravity.
     
    187170 * \return pointer to center of gravity vector
    188171 */
    189 Vector * molecule::DetermineCenterOfGravity() const
     172const Vector molecule::DetermineCenterOfGravity() const
    190173{
    191174  const_iterator iter = begin();  // start at first in list
    192   Vector *a = new Vector();
     175  Vector a;
    193176  Vector tmp;
    194177  double Num = 0;
    195178
    196   a->Zero();
     179  a.Zero();
    197180
    198181  if (iter != end()) {   //list not empty?
     
    200183      Num += (*iter)->getType()->getMass();
    201184      tmp = (*iter)->getType()->getMass() * (*iter)->getPosition();
    202       (*a) += tmp;
    203     }
    204     a->Scale(1./Num); // divide through total mass
    205   }
    206   LOG(1, "INFO: Resulting center of gravity: " << *a << ".");
     185      a += tmp;
     186    }
     187    a.Scale(1./Num); // divide through total mass
     188  }
     189  LOG(1, "INFO: Resulting center of gravity: " << a << ".");
    207190  return a;
    208 };
     191}
    209192
    210193/** Centers the center of gravity of the atoms at (0,0,0).
     
    216199  Vector NewCenter;
    217200  DeterminePeriodicCenter(NewCenter);
    218   // go through all atoms
    219   for (iterator iter = begin(); iter != end(); ++iter) {
    220     **iter -= NewCenter;
    221   }
    222 };
     201  Translate(-1.*NewCenter);
     202}
    223203
    224204
     
    227207 * \param *center return vector for translation vector
    228208 */
    229 void molecule::CenterAtVector(Vector *newcenter)
    230 {
    231   // go through all atoms
    232   for (iterator iter = begin(); iter != end(); ++iter) {
    233     **iter -= *newcenter;
    234   }
    235 };
     209void molecule::CenterAtVector(const Vector &newcenter)
     210{
     211  Translate(-1.*newcenter);
     212}
    236213
    237214/** Calculate the inertia tensor of a the molecule.
     
    242219{
    243220  RealSpaceMatrix InertiaTensor;
    244   Vector *CenterOfGravity = DetermineCenterOfGravity();
     221  const Vector CenterOfGravity = DetermineCenterOfGravity();
    245222
    246223  // reset inertia tensor
     
    250227  for (const_iterator iter = begin(); iter != end(); ++iter) {
    251228    Vector x = (*iter)->getPosition();
    252     x -= *CenterOfGravity;
     229    x -= CenterOfGravity;
    253230    const double mass = (*iter)->getType()->getMass();
    254231    InertiaTensor.at(0,0) += mass*(x[1]*x[1] + x[2]*x[2]);
     
    265242  LOG(1, "INFO: The inertia tensor of molecule " << getName() <<  " is:" << InertiaTensor);
    266243
    267   delete CenterOfGravity;
    268244  return InertiaTensor;
    269245}
     
    276252void molecule::RotateToPrincipalAxisSystem(const Vector &Axis)
    277253{
    278   Vector *CenterOfGravity = DetermineCenterOfGravity();
     254  const Vector CenterOfGravity = DetermineCenterOfGravity();
    279255  RealSpaceMatrix InertiaTensor = getInertiaTensor();
    280256
     
    288264
    289265  // obtain first column, eigenvector to biggest eigenvalue
    290   Vector BiggestEigenvector(InertiaTensor.column(Eigenvalues.SmallestComponent()));
     266  const Vector BiggestEigenvector(InertiaTensor.column(Eigenvalues.SmallestComponent()));
    291267  Vector DesiredAxis(Axis.getNormalized());
    292268
     
    302278  // and rotate
    303279  for (iterator iter = begin(); iter != end(); ++iter) {
    304     *(*iter) -= *CenterOfGravity;
     280    *(*iter) -= CenterOfGravity;
    305281    (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), alpha));
    306     *(*iter) += *CenterOfGravity;
     282    *(*iter) += CenterOfGravity;
    307283  }
    308284  LOG(0, "STATUS: done.");
    309 
    310   delete CenterOfGravity;
    311285}
    312286
     
    319293 * x=(**factor) * x (as suggested by comment)
    320294 */
    321 void molecule::Scale(const double ** const factor)
     295void molecule::Scale(const double *factor)
    322296{
    323297  for (iterator iter = begin(); iter != end(); ++iter) {
    324298    for (size_t j=0;j<(*iter)->getTrajectorySize();j++) {
    325299      Vector temp = (*iter)->getPositionAtStep(j);
    326       temp.ScaleAll(*factor);
     300      temp.ScaleAll(factor);
    327301      (*iter)->setPositionAtStep(j,temp);
    328302    }
     
    333307 * \param trans[] translation vector.
    334308 */
    335 void molecule::Translate(const Vector *trans)
    336 {
    337   for (iterator iter = begin(); iter != end(); ++iter) {
    338     for (size_t j=0;j<(*iter)->getTrajectorySize();j++) {
    339       (*iter)->setPositionAtStep(j, (*iter)->getPositionAtStep(j) + (*trans));
    340     }
    341   }
     309void molecule::Translate(const Vector &trans)
     310{
     311  getAtomSet().translate(trans);
    342312};
    343313
     
    346316 * TODO treatment of trajectories missing
    347317 */
    348 void molecule::TranslatePeriodically(const Vector *trans)
    349 {
     318void molecule::TranslatePeriodically(const Vector &trans)
     319{
     320  Translate(trans);
    350321  Box &domain = World::getInstance().getDomain();
    351 
    352   // go through all atoms
    353   for (iterator iter = begin(); iter != end(); ++iter) {
    354     **iter += *trans;
    355   }
    356322  getAtomSet().transformNodes(boost::bind(&Box::enforceBoundaryConditions,domain,_1));
    357 
    358323};
    359324
     
    362327 * \param n[] normal vector of mirror plane.
    363328 */
    364 void molecule::Mirror(const Vector *n)
    365 {
    366   OBSERVE;
    367   Plane p(*n,0);
     329void molecule::Mirror(const Vector &n)
     330{
     331  Plane p(n,0);
    368332  getAtomSet().transformNodes(boost::bind(&Plane::mirrorVector,p,_1));
    369333};
     
    381345  Vector Testvector, Translationvector;
    382346  Vector Center;
    383   BondGraph *BG = World::getInstance().getBondGraph();
     347  const BondGraph * const BG = World::getInstance().getBondGraph();
    384348
    385349  do {
     
    432396
    433397  Center.Scale(1./static_cast<double>(getAtomCount()));
    434   CenterAtVector(&Center);
     398  CenterAtVector(Center);
    435399};
    436400
     
    438402 * \param n[] alignment vector.
    439403 */
    440 void molecule::Align(Vector *n)
     404void molecule::Align(const Vector &n)
    441405{
    442406  double alpha, tmp;
    443407  Vector z_axis;
     408  Vector alignment(n);
    444409  z_axis[0] = 0.;
    445410  z_axis[1] = 0.;
     
    448413  // rotate on z-x plane
    449414  LOG(0, "Begin of Aligning all atoms.");
    450   alpha = atan(-n->at(0)/n->at(2));
     415  alpha = atan(-alignment.at(0)/alignment.at(2));
    451416  LOG(1, "INFO: Z-X-angle: " << alpha << " ... ");
    452417  for (iterator iter = begin(); iter != end(); ++iter) {
     
    462427  }
    463428  // rotate n vector
    464   tmp = n->at(0);
    465   n->at(0) =  cos(alpha) * tmp +  sin(alpha) * n->at(2);
    466   n->at(2) = -sin(alpha) * tmp +  cos(alpha) * n->at(2);
    467   LOG(1, "alignment vector after first rotation: " << n);
     429  tmp = alignment.at(0);
     430  alignment.at(0) =  cos(alpha) * tmp +  sin(alpha) * alignment.at(2);
     431  alignment.at(2) = -sin(alpha) * tmp +  cos(alpha) * alignment.at(2);
     432  LOG(1, "alignment vector after first rotation: " << alignment);
    468433
    469434  // rotate on z-y plane
    470   alpha = atan(-n->at(1)/n->at(2));
     435  alpha = atan(-alignment.at(1)/alignment.at(2));
    471436  LOG(1, "INFO: Z-Y-angle: " << alpha << " ... ");
    472437  for (iterator iter = begin(); iter != end(); ++iter) {
     
    482447  }
    483448  // rotate n vector (for consistency check)
    484   tmp = n->at(1);
    485   n->at(1) =  cos(alpha) * tmp +  sin(alpha) * n->at(2);
    486   n->at(2) = -sin(alpha) * tmp +  cos(alpha) * n->at(2);
    487 
    488 
    489   LOG(1, "alignment vector after second rotation: " << n);
     449  tmp = alignment.at(1);
     450  alignment.at(1) =  cos(alpha) * tmp +  sin(alpha) * alignment.at(2);
     451  alignment.at(2) = -sin(alpha) * tmp +  cos(alpha) * alignment.at(2);
     452
     453  LOG(1, "alignment vector after second rotation: " << alignment);
    490454  LOG(0, "End of Aligning all atoms.");
    491455};
  • src/moleculelist.cpp

    r29b35e r55736b  
    229229      }
    230230      // Center and size
    231       Vector *Center = (*ListRunner)->DetermineCenterOfAll();
    232       (*out) << "\t" << *Center << "\t" << sqrt(size) << endl;
    233       delete(Center);
     231      Vector Center = (*ListRunner)->DetermineCenterOfAll();
     232      (*out) << "\t" << Center << "\t" << sqrt(size) << endl;
    234233    }
    235234  }
     
    578577//        if (BoxDimension[k] < 1.)
    579578//          BoxDimension[k] += 1.;
    580 //      (*ListRunner)->SetBoxDimension(&BoxDimension); // update Box of atoms by boundary
     579//      {
     580//        RealSpaceMatrix domain;
     581//        for(int i =0; i<NDIM;++i)
     582//          domain.at(i,i) = BoxDimension[i];
     583//        World::getInstance().setDomain(domain);
     584//      }
    581585//      for (int k = 0; k < NDIM; k++) {
    582586//        BoxDimension[k] = 2.5 * (World::getInstance().getConfig()->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
Note: See TracChangeset for help on using the changeset viewer.