- Timestamp:
- Sep 15, 2014, 2:22:29 PM (11 years ago)
- 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. - Location:
- src
- Files:
-
- 16 added
- 9 deleted
- 19 edited
-
Actions/FillAction/FillRegularGridAction.cpp (modified) (2 diffs)
-
Actions/FillAction/FillSurfaceAction.cpp (modified) (4 diffs)
-
Actions/FillAction/FillSurfaceAction.def (modified) (2 diffs)
-
Actions/FillAction/FillVolumeAction.cpp (added)
-
Actions/FillAction/FillVolumeAction.def (added)
-
Actions/FillAction/FillVolumeAction.hpp (added)
-
Actions/FillAction/SuspendInMoleculeAction.cpp (added)
-
Actions/FillAction/SuspendInMoleculeAction.def (added)
-
Actions/FillAction/SuspendInMoleculeAction.hpp (added)
-
Actions/GlobalListOfActions.hpp (modified) (3 diffs)
-
Actions/Makefile.am (modified) (7 diffs)
-
Actions/MoleculeAction/CopyAction.cpp (modified) (1 diff)
-
Actions/MoleculeAction/FillVoidWithMoleculeAction.cpp (deleted)
-
Actions/MoleculeAction/FillVoidWithMoleculeAction.def (deleted)
-
Actions/MoleculeAction/FillVoidWithMoleculeAction.hpp (deleted)
-
Actions/MoleculeAction/FillWithMoleculeAction.cpp (deleted)
-
Actions/MoleculeAction/FillWithMoleculeAction.def (deleted)
-
Actions/MoleculeAction/FillWithMoleculeAction.hpp (deleted)
-
Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp (modified) (3 diffs)
-
Actions/MoleculeAction/SuspendInWaterAction.cpp (deleted)
-
Actions/MoleculeAction/SuspendInWaterAction.def (deleted)
-
Actions/MoleculeAction/SuspendInWaterAction.hpp (deleted)
-
Analysis/unittests/CountBondsUnitTest.cpp (modified) (2 diffs)
-
Filling/Inserter/SurfaceRandomInserter.cpp (added)
-
Filling/Inserter/SurfaceRandomInserter.hpp (added)
-
Filling/Makefile.am (modified) (4 diffs)
-
Filling/Mesh/MeshAdaptor.hpp (modified) (1 diff)
-
Filling/Preparators/BaseFillerPreparator.cpp (added)
-
Filling/Preparators/BaseFillerPreparator.hpp (added)
-
Filling/Preparators/BoxFillerPreparator.cpp (added)
-
Filling/Preparators/BoxFillerPreparator.hpp (added)
-
Filling/Preparators/ShapeSurfaceFillerPreparator.cpp (added)
-
Filling/Preparators/ShapeSurfaceFillerPreparator.hpp (added)
-
Filling/Preparators/ShapeVolumeFillerPreparator.cpp (added)
-
Filling/Preparators/ShapeVolumeFillerPreparator.hpp (added)
-
Tesselation/boundary.cpp (modified) (7 diffs)
-
Tesselation/boundary.hpp (modified) (2 diffs)
-
UIElements/Views/Qt4/Qt3D/GLWorldView.cpp (modified) (1 diff)
-
UIElements/Views/Qt4/Qt3D/GLWorldView.hpp (modified) (1 diff)
-
documentation/constructs/filling.dox (modified) (1 diff)
-
molecule.cpp (modified) (1 diff)
-
molecule.hpp (modified) (1 diff)
-
molecule_geometry.cpp (modified) (24 diffs)
-
moleculelist.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FillAction/FillRegularGridAction.cpp
r29b35e r55736b 44 44 #include "Filling/Cluster.hpp" 45 45 #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" 54 47 #include "molecule.hpp" 55 48 #include "MoleculeListClass.hpp" 56 49 #include "Parser/FormatParserInterface.hpp" 57 50 #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"63 51 #include "World.hpp" 64 65 52 66 53 #include <algorithm> … … 92 79 LOG(1, "INFO: Chosen molecule has " << filler->size() << " atoms."); 93 80 94 // c heck for selected molecules and create surfaces from them95 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); 99 86 if (params.SphereRadius.get() != 0.) { 100 if ( atoms.size() == 0) {87 if (World::getInstance().beginAtomSelection() == World::getInstance().endAtomSelection()) { 101 88 STATUS("You have given a sphere radius "+toString(params.SphereRadius.get()) 102 89 +" != 0, but have not select any atoms."); 103 90 return Action::failure; 104 91 } 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; 118 113 FillRegularGridState *UndoState = NULL; 119 bool successflag = false;120 114 { 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 139 115 // 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 } 180 139 } 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 } 189 155 } 190 156 -
src/Actions/FillAction/FillSurfaceAction.cpp
r29b35e r55736b 46 46 #include "Filling/Mesh/MeshAdaptor.hpp" 47 47 #include "Filling/Predicates/IsVoidNode_FillPredicate.hpp" 48 #include "Filling/Preparators/ShapeSurfaceFillerPreparator.hpp" 48 49 #include "molecule.hpp" 49 50 #include "Shapes/BaseShapes.hpp" 50 51 #include "Shapes/ShapeRegistry.hpp" 52 #include "Shapes/ShapeType.hpp" 51 53 #include "World.hpp" 52 54 … … 81 83 82 84 // center filler's tip at origin 83 Vector max; 84 filler->CenterEdge(&max); 85 filler->CenterEdge(); 85 86 86 87 // determine center with respect to alignment axis … … 96 97 { 97 98 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."); 115 127 return Action::failure; 116 128 } 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 { 124 152 // fill 125 153 { 126 Filler *fillerFunction = new Filler(*mesh, *voidnode_predicate, *inserter);154 Filler *fillerFunction = filler_preparator.obtainFiller(); 127 155 ClusterInterface::Cluster_impl cluster( new Cluster( filler->getAtomIds(), filler->getBoundingSphere() ) ); 128 156 CopyAtoms_withBonds copyMethod; … … 161 189 } 162 190 } 163 164 // remove165 delete mesh;166 delete inserter;167 delete voidnode_predicate;168 191 } 169 192 -
src/Actions/FillAction/FillSurfaceAction.def
r29b35e r55736b 20 20 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 21 21 // "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) 27 27 #define paramvalids \ 28 28 (DummyValidator< unsigned int >()) \ 29 (BoxLengthValidator()) \ 30 (BoxLengthValidator()) \ 31 (BoxLengthValidator()) \ 29 32 (BoxLengthValidator()) \ 30 33 (VectorNotZeroValidator()) … … 36 39 #define CATEGORY Fill 37 40 #define MENUNAME "fill" 38 #define MENUPOSITION 141 #define MENUPOSITION 2 39 42 #define ACTIONNAME Surface 40 43 #define TOKEN "fill-surface" -
src/Actions/GlobalListOfActions.hpp
r29b35e r55736b 50 50 (FillRegularGrid) \ 51 51 (FillSurface) \ 52 (FillSuspendInMolecule) \ 53 (FillVolume) \ 52 54 (FragmentationAnalyseFragmentationResults) \ 53 55 (FragmentationClearFragmentationResults) \ … … 68 70 (MoleculeChangeBondAngle) \ 69 71 (MoleculeCopy) \ 70 (MoleculeFillWithMolecule) \71 (MoleculeFillVoidWithMolecule) \72 72 (MoleculeForceAnnealing) \ 73 73 (MoleculeLinearInterpolationofTrajectories) \ … … 80 80 (MoleculeSaveTemperature) \ 81 81 (MoleculeStretchBond) \ 82 (MoleculeSuspendInWater) \83 82 (MoleculeVerletIntegration) \ 84 83 (PotentialFitParticleCharges) \ -
src/Actions/Makefile.am
r29b35e r55736b 215 215 FILLACTIONSOURCE = \ 216 216 Actions/FillAction/FillRegularGridAction.cpp \ 217 Actions/FillAction/FillSurfaceAction.cpp 217 Actions/FillAction/FillSurfaceAction.cpp \ 218 Actions/FillAction/SuspendInMoleculeAction.cpp \ 219 Actions/FillAction/FillVolumeAction.cpp 218 220 FILLACTIONHEADER = \ 219 221 Actions/FillAction/FillRegularGridAction.hpp \ 220 Actions/FillAction/FillSurfaceAction.hpp 222 Actions/FillAction/FillSurfaceAction.hpp \ 223 Actions/FillAction/SuspendInMoleculeAction.hpp \ 224 Actions/FillAction/FillVolumeAction.hpp 221 225 FILLACTIONDEFS = \ 222 226 Actions/FillAction/FillRegularGridAction.def \ 223 Actions/FillAction/FillSurfaceAction.def 227 Actions/FillAction/FillSurfaceAction.def \ 228 Actions/FillAction/SuspendInMoleculeAction.def \ 229 Actions/FillAction/FillVolumeAction.def 224 230 225 231 … … 279 285 Actions/MoleculeAction/ChangeNameAction.cpp \ 280 286 Actions/MoleculeAction/CopyAction.cpp \ 281 Actions/MoleculeAction/FillWithMoleculeAction.cpp \282 Actions/MoleculeAction/FillVoidWithMoleculeAction.cpp \283 287 Actions/MoleculeAction/ForceAnnealingAction.cpp \ 284 288 Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp \ … … 291 295 Actions/MoleculeAction/SaveTemperatureAction.cpp \ 292 296 Actions/MoleculeAction/StretchBondAction.cpp \ 293 Actions/MoleculeAction/SuspendInWaterAction.cpp \294 297 Actions/MoleculeAction/VerletIntegrationAction.cpp 295 298 MOLECULEACTIONHEADER = \ … … 298 301 Actions/MoleculeAction/ChangeNameAction.hpp \ 299 302 Actions/MoleculeAction/CopyAction.hpp \ 300 Actions/MoleculeAction/FillWithMoleculeAction.hpp \301 Actions/MoleculeAction/FillVoidWithMoleculeAction.hpp \302 303 Actions/MoleculeAction/ForceAnnealingAction.hpp \ 303 304 Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp \ … … 310 311 Actions/MoleculeAction/SaveTemperatureAction.hpp \ 311 312 Actions/MoleculeAction/StretchBondAction.hpp \ 312 Actions/MoleculeAction/SuspendInWaterAction.hpp \313 313 Actions/MoleculeAction/VerletIntegrationAction.hpp 314 314 MOLECULEACTIONDEFS = \ … … 317 317 Actions/MoleculeAction/ChangeNameAction.def \ 318 318 Actions/MoleculeAction/CopyAction.def \ 319 Actions/MoleculeAction/FillWithMoleculeAction.def \320 Actions/MoleculeAction/FillVoidWithMoleculeAction.def \321 319 Actions/MoleculeAction/ForceAnnealingAction.def \ 322 320 Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.def \ … … 329 327 Actions/MoleculeAction/SaveTemperatureAction.def \ 330 328 Actions/MoleculeAction/StretchBondAction.def \ 331 Actions/MoleculeAction/SuspendInWaterAction.def \332 329 Actions/MoleculeAction/VerletIntegrationAction.def 333 330 -
src/Actions/MoleculeAction/CopyAction.cpp
r29b35e r55736b 63 63 iter != World::getInstance().endMoleculeSelection(); ++iter) { 64 64 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(); 68 68 copy->Translate(Center); 69 delete(Center);70 69 molecules.push_back(copy->getId()); 71 70 } -
src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp
r29b35e r55736b 74 74 75 75 // 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()); 80 79 LOG(0, "Rotate " << mol->getName() << " around self by " << params.angle.get() << " radian around axis " << RotationAxis << "."); 81 80 … … 93 92 94 93 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()); 99 97 LOG(0, "Rotate " << mol->getName() << " around self by " << -state->params.angle.get() << " radian around axis " << RotationAxis << "."); 100 98 … … 111 109 112 110 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()); 117 114 LOG(0, "Rotate " << mol->getName() << " around self by " << state->params.angle.get() << " radian around axis " << RotationAxis << "."); 118 115 -
src/Analysis/unittests/CountBondsUnitTest.cpp
r29b35e r55736b 148 148 void CountBondsTest::HydrogenBridgeBondsTest() 149 149 { 150 double *mirror = new double[3];150 double mirror[3]; 151 151 CPPUNIT_ASSERT(mirror != NULL && "could not create array of doubles"); 152 152 for (int i=0;i<3;i++) … … 161 161 cout << "Case 1: offset of (3,0,0), hence angles are (104.5, 0, 75.5, 180) < 30." << endl; 162 162 Translator = Vector(3,0,0); 163 TestMolecule1->Translate( &Translator);163 TestMolecule1->Translate(Translator); 164 164 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 165 165 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, oxygen, NULL) ); 166 166 Translator = Vector(-3,0,0); 167 TestMolecule1->Translate( &Translator);167 TestMolecule1->Translate(Translator); 168 168 169 169 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; 170 170 Translator = Vector(0,3,0); 171 TestMolecule1->Translate( &Translator);171 TestMolecule1->Translate(Translator); 172 172 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 173 173 Translator = Vector(0,-3,0); 174 TestMolecule1->Translate( &Translator);174 TestMolecule1->Translate(Translator); 175 175 176 176 cout << "Case 3: offset of (0,-3,0) and mirror, hence angle are (165.5, 90, 165.5, 90) > 30." << endl; 177 177 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); 180 180 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 181 181 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]); 184 184 185 185 cout << "Case 4: offset of (2,1,0), hence angle are (78, 26.6, 102, 153.4) < 30." << endl; 186 186 Translator = Vector(2,1,0); 187 TestMolecule1->Translate( &Translator);187 TestMolecule1->Translate(Translator); 188 188 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 189 189 Translator = Vector(-2,-1,0); 190 TestMolecule1->Translate( &Translator);190 TestMolecule1->Translate(Translator); 191 191 192 192 cout << "Case 5: offset of (0,0,3), hence angle are (90, 90, 90, 90) > 30." << endl; 193 193 Translator = Vector(0,0,3); 194 TestMolecule1->Translate( &Translator);194 TestMolecule1->Translate(Translator); 195 195 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 196 196 Translator = Vector(0,0,-3); 197 TestMolecule1->Translate( &Translator);197 TestMolecule1->Translate(Translator); 198 198 199 199 cout << "Case 6: offset of (-3,0,0) and mirror, hence angle are (75.5, 180, 104.5, 180) > 30." << endl; 200 200 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); 203 203 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 204 204 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]); 207 207 208 208 cout << "Case 7: offset of (3,0,0) and mirror, hence angles are (104.5, 0, 104.5, 0) < 30, but interfering hydrogens." << endl; 209 209 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); 212 212 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 213 213 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]); 216 216 217 217 cout << "Case 8: offset of (0,3,0), hence angle are (14.5, 90, 14.5, 90) < 30, but interfering hydrogens." << endl; 218 218 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); 221 221 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 222 222 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 13 13 Filling/Inserter/SimpleInserter.cpp \ 14 14 Filling/Inserter/SurfaceInserter.cpp \ 15 Filling/Inserter/SurfaceRandomInserter.cpp \ 15 16 Filling/Predicates/AnyFillPredicate.cpp \ 16 17 Filling/Predicates/FillPredicate.cpp \ … … 19 20 Filling/Predicates/IsValidInDomain_FillPredicate.cpp \ 20 21 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 22 27 23 28 FILLINGHEADER = \ … … 34 39 Filling/Inserter/SimpleInserter.hpp \ 35 40 Filling/Inserter/SurfaceInserter.hpp \ 41 Filling/Inserter/SurfaceRandomInserter.hpp \ 36 42 Filling/NodeTypes.hpp \ 37 43 Filling/Predicates/AnyFillPredicate.hpp \ … … 44 50 Filling/Predicates/IsVoidNode_FillPredicate.hpp \ 45 51 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 48 57 49 58 noinst_LTLIBRARIES += libMolecuilderFilling.la -
src/Filling/Mesh/MeshAdaptor.hpp
r29b35e r55736b 18 18 19 19 #include "Filling/NodeTypes.hpp" 20 #include "Filling/Mesh/Mesh.hpp" 20 21 21 22 class MeshAdaptor : public Mesh -
src/Tesselation/boundary.cpp
r29b35e r55736b 183 183 LineMap LinesOnBoundary; 184 184 TriangleMap TrianglesOnBoundary; 185 Vector *MolCenter = mol->DetermineCenterOfAll();185 Vector MolCenter = mol->DetermineCenterOfAll(); 186 186 Vector helper; 187 187 BoundariesTestPair BoundaryTestPair; … … 207 207 // Boundaries stores non-const TesselPoint ref, hence we need iterator here 208 208 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) { 209 ProjectedVector = (*iter)->getPosition() - ( *MolCenter);209 ProjectedVector = (*iter)->getPosition() - (MolCenter); 210 210 ProjectedVector.ProjectOntoPlane(AxisVector); 211 211 … … 233 233 LOG(2, "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "."); 234 234 } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) { 235 helper = (*iter)->getPosition() - ( *MolCenter);235 helper = (*iter)->getPosition() - (MolCenter); 236 236 const double oldhelperNorm = helper.NormSquared(); 237 helper = BoundaryTestPair.first->second.second->getPosition() - ( *MolCenter);237 helper = BoundaryTestPair.first->second.second->getPosition() - (MolCenter); 238 238 if (helper.NormSquared() < oldhelperNorm) { 239 239 BoundaryTestPair.first->second.second = (*iter); … … 289 289 { 290 290 Vector SideA, SideB, SideC, SideH; 291 SideA = left->second.second->getPosition() - ( *MolCenter);291 SideA = left->second.second->getPosition() - (MolCenter); 292 292 SideA.ProjectOntoPlane(AxisVector); 293 293 // LOG(1, "SideA: " << SideA); 294 294 295 SideB = right->second.second->getPosition() -( *MolCenter);295 SideB = right->second.second->getPosition() -(MolCenter); 296 296 SideB.ProjectOntoPlane(AxisVector); 297 297 // LOG(1, "SideB: " << SideB); … … 301 301 // LOG(1, "SideC: " << SideC); 302 302 303 SideH = runner->second.second->getPosition() -( *MolCenter);303 SideH = runner->second.second->getPosition() -(MolCenter); 304 304 SideH.ProjectOntoPlane(AxisVector); 305 305 // LOG(1, "SideH: " << SideH); … … 329 329 } while (flag); 330 330 } 331 delete(MolCenter);332 331 return BoundaryPoints; 333 332 }; … … 655 654 }; 656 655 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 debugging661 * \param *configuration needed for path to store convex envelope file662 * \param *mol molecule structure representing the cluster663 * \param *&TesselStruct Tesselation structure with triangles on return664 * \param ClusterVolume guesstimated cluster volume, if equal 0 we used Tesselation::getVolumeOfConvexEnvelope() instead.665 * \param celldensity desired average density in final cell666 */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 Action682 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 beforehand696 if (ClusterVolume == 0)697 clustervolume = TesselStruct->getVolumeOfConvexEnvelope(configuration->GetIsAngstroem());698 else699 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 masses707 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 polynomial714 LOG(1, "Solving equidistant suspension in water problem ...");715 if (IsAngstroem)716 cellvolume = (TotalNoClusters * totalmass / SOLVENTDENSITY_A - (totalmass / clustervolume)) / (celldensity - 1);717 else718 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 return737 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 order741 }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 dimensions750 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 boundary756 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 debugging763 * \param *List list of molecules already present in box764 * \param *TesselStruct contains tesselated surface765 * \param *filler molecule which the box is to be filled with766 * \param configuration contains box dimensions767 * \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 direction769 * \param boundary length of boundary zone between molecule and filling mollecules770 * \param epsilon distance to surface which is not filled771 * \param RandAtomDisplacement maximum distance for random displacement per atom772 * \param RandMolDisplacement maximum distance for random displacement per filler molecule773 * \param DoRandomRotation true - do random rotiations, false - don't774 */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 list800 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 origin806 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]^3822 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 time828 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 grid834 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 box838 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 atoms845 for (int i=0;i<FillerCount;i++)846 CopyAtoms[i] = NULL;847 848 // have same rotation angles for all molecule's atoms849 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 here854 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 matrix861 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 position874 Inserter = (*iter)->getPosition();875 if (DoRandomRotation)876 Inserter *= Rotations;877 Inserter += AtomTranslations + FillerTranslations + CurrentPosition;878 879 // check whether inserter is inside box880 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 outside887 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {888 // get linked cell list889 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 Filling895 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 well909 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 given930 * \a RandomAtomDisplacement.931 *932 * Note that for rotation to be sensible, the molecule should be centered at933 * the origin. This is not done here!934 *935 * \param &Filling molecule whose atoms to displace936 * \param RandomAtomDisplacement magnitude of random displacement937 * \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 &random944 )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 left966 * empty.967 * @return true - atoms had to be removed, false - no atoms have been removed968 */969 bool RemoveAtomsOutsideDomain(molecule *&Filling)970 {971 bool status = false;972 Box &Domain = World::getInstance().getDomain();973 // check if all is still inside domain974 for(molecule::iterator miter = Filling->begin(); miter != Filling->end(); ) {975 // check whether each atom is inside box976 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 CurrentPosition994 * except those atoms present in \a *filler.995 * If filler is NULL, then we just call LinkedCell_deprecated::GetPointsInsideSphere() and996 * check whether the return list is empty.997 * @param *filler998 * @param boundary999 * @param CurrentPosition1000 */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 set1037 */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 with1055 * \param configuration contains box dimensions1056 * \param distance[NDIM] distance between filling molecules in each direction1057 * \param boundary length of boundary zone between molecule and filling molecules1058 * \param RandAtomDisplacement maximum distance for random displacement per atom1059 * \param RandMolDisplacement maximum distance for random displacement per filler molecule1060 * \param MinDistance minimum distance to boundary of domain and present molecules1061 * \param DoRandomRotation true - do random rotations, false - don't1062 */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 DoRandomRotation1072 )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 list1098 }1099 1100 // Center filler at its center of gravity1101 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]^31116 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 time1122 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 grid1128 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 box1132 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]*RandomMolDisplacement1135 FillerTranslations[i] = RandomMolDisplacement*(random()/((rng_max-rng_min)/2.) - 1.);1136 LOG(2, "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << ".");1137 1138 // ... and rotation matrix1139 if (DoRandomRotation)1140 setRandomRotation(Rotations);1141 else1142 Rotations.setIdentity();1143 1144 1145 // Check whether there is anything too close by and whether atom is outside of domain1146 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 Filling1160 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 // translation1167 Filling->Translate(&Inserter);1168 // remove out-of-bounds atoms1169 const bool status = RemoveAtomsOutsideDomain(Filling);1170 if ((firstInsertion) && (!status)) { // no atom has been removed1171 // remove copied atoms and molecule again1172 Filling->removeAtomsinMolecule();1173 World::getInstance().destroyMolecule(Filling);1174 // and mark is final filler position1175 Filling = filler;1176 firstInsertion = false;1177 firstInserter = Inserter;1178 } else {1179 // TODO: Remove when World has no MoleculeListClass anymore1180 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 filler1192 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 position1199 if (DoRandomRotation)1200 setRandomRotation(Rotations);1201 else1202 Rotations.setIdentity();1203 RandomizeMoleculePositions(filler, RandomAtomDisplacement, Rotations, random);1204 // translation1205 filler->Translate(&firstInserter);1206 // remove out-of-bounds atoms1207 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 debugging1225 * \param *List list of molecules already present in box1226 * \param *TesselStruct contains tesselated surface1227 * \param *filler molecule which the box is to be filled with1228 * \param configuration contains box dimensions1229 * \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 direction1231 * \param boundary length of boundary zone between molecule and filling molecules1232 * \param MinDistance distance to boundary of domain which is not filled1233 * \param RandAtomDisplacement maximum distance for random displacement per atom1234 * \param RandMolDisplacement maximum distance for random displacement per filler molecule1235 * \param DoRandomRotation true - do random rotations, false - don't1236 */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 list1273 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 origin1279 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]^31297 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 time1303 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 grid1309 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 box1313 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 matrix1320 if (DoRandomRotation)1321 setRandomRotation(Rotations);1322 else1323 Rotations.setIdentity();1324 1325 1326 // Check whether there is anything too close by and whether atom is outside of domain1327 FillIt = true;1328 for (std::map<molecule *, LinkedCell_deprecated *>::iterator ListRunner = LCList.begin(); ListRunner != LCList.end(); ++ListRunner) {1329 // check whether its void1330 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 domain1340 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 boundary1347 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 tesselations1356 if (FillIt) {1357 for (MoleculeList::iterator ListRunner = MolList->ListOfMolecules.begin(); ListRunner != MolList->ListOfMolecules.end(); ListRunner++) {1358 // get linked cell list1359 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 " << distance1365 << " to a surface, less than " << MaxSurfaceDistance << " hence, too close.");1366 break;1367 }1368 }1369 }1370 }1371 1372 // insert into Filling1373 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 // translation1380 Filling->Translate(&Inserter);1381 // remove out-of-bounds atoms1382 const bool status = RemoveAtomsOutsideDomain(Filling);1383 if ((firstInsertion) && (!status)) { // no atom has been removed1384 // remove copied atoms and molecule again1385 Filling->removeAtomsinMolecule();1386 World::getInstance().destroyMolecule(Filling);1387 // and mark is final filler position1388 Filling = filler;1389 firstInsertion = false;1390 firstInserter = Inserter;1391 } else {1392 // TODO: Remove when World has no MoleculeListClass anymore1393 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 filler1405 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 position1412 if (DoRandomRotation)1413 setRandomRotation(Rotations);1414 else1415 Rotations.setIdentity();1416 RandomizeMoleculePositions(filler, RandomAtomDisplacement, Rotations, random);1417 // translation1418 filler->Translate(&firstInserter);1419 // remove out-of-bounds atoms1420 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 1431 656 /** Tesselates the non convex boundary by rolling a virtual sphere along the surface of the molecule. 1432 657 * \param *out output stream for debugging -
src/Tesselation/boundary.hpp
r29b35e r55736b 40 40 41 41 double 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);44 42 void FindConvexBorder(const molecule* const mol, Boundaries *BoundaryPts, Tesselation *&TesselStruct, const LinkedCell_deprecated *LCList, const char *filename); 45 43 Vector* FindEmbeddingHole(MoleculeListClass *mols, molecule *srcmol); … … 47 45 Boundaries *GetBoundaryPoints(const molecule *mol, Tesselation *&TesselStruct); 48 46 double * GetDiametersOfCluster(const Boundaries *BoundaryPtr, const molecule *mol, Tesselation *&TesselStruct, const bool IsAngstroem); 49 void PrepareClustersinWater(config *configuration, molecule *mol, double ClusterVolume, double celldensity);50 47 bool RemoveAllBoundaryPoints(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename); 51 48 void StoreTrianglesinFile(const molecule * const mol, const Tesselation * const TesselStruct, const char *filename, const char *extraSuffix); -
src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp
r29b35e r55736b 752 752 emit hoverChanged(_atom); 753 753 } 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 float777 //#endif778 //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 rotation784 // scale = 5.; // default object scale785 // 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 views824 // * 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 Shading832 // glEnable(GL_LIGHTING); // Enable Light One833 // glEnable(GL_DEPTH_TEST); // Enables Depth Testing834 // glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do835 // glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations836 //837 // // 3d viewport838 // if (MultiViewEnabled)839 // glViewport( 0, 0, (GLint)width/2, (GLint)height/2 );840 // else841 // 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 direction849 // 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 scene856 // glCallList(object);857 //858 // // enable light859 // glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light860 // glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light861 // glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light862 // glEnable(GL_LIGHT1); // Enable Light One863 //864 // if (MultiViewEnabled) {865 // // xy view port866 // 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 direction875 // 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 light884 // glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light885 // glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light886 // glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light887 // glEnable(GL_LIGHT1); // Enable Light One888 //889 // // render scene890 // glCallList(object);891 //892 // // xz viewport893 // 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 direction902 // 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 light911 // glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light912 // glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light913 // glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light914 // glEnable(GL_LIGHT1); // Enable Light One915 //916 // // render scene917 // glCallList(object);918 //919 // //yz viewport920 // 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 direction929 // 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 light938 // glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light939 // glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light940 // glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light941 // glEnable(GL_LIGHT1); // Enable Light One942 //943 // // render scene944 // 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 position960 // * \param radius radius961 // * \param color[3] color rgb values962 // */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 floats966 // 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 origin984 // * \param y direction985 // * \param radius thickness986 // * \param height length987 // * \color[3] color rgb values988 // */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 axis999 // b = a;1000 // b.VectorProduct(Z);1001 // Line axis(zeroVec, b);1002 // // calculate rotation angle1003 // alpha = a.Angle(Z);1004 // // construct other axis to check right-hand rule1005 // OtherAxis = b;1006 // OtherAxis.VectorProduct(Z);1007 // // assure right-hand rule for the rotation1008 // if (a.ScalarProduct(OtherAxis) < MYEPSILON)1009 // alpha = M_PI-alpha;1010 // // check1011 // Vector a_rotated = axis.rotateVector(a, alpha);1012 // std::cout << "Setting cylinder from "// << x << " to " << y1013 // << 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 cylinders1027 // * 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 black1041 // 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 atom1056 // 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 // else1063 // color = ptr->getColor();1064 // makeSphere(Position, ptr->getVanDerWaalsRadius()*0.25, color);1065 //1066 // // create bonds1067 // 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 statusbar1094 // */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 window1119 // * \param h new height of window1120 // */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 degrees1131 // */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 degrees1142 // */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 degrees1153 // */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 scale1163 // */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 here1218 //// 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 accordingly1249 //// 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 event1286 // */1287 //void GLMoleculeView::mousePressEvent(QMouseEvent *event)1288 //{1289 // std::cout << "MousePressEvent." << endl;1290 // QPoint *pos = NULL;1291 // switch (event->button()) { // get the right array1292 // 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 position1308 // 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: nothing1320 // * -# Right Button: Shifts the selected molecule or atom, relative to GLMoleculeView::RightButtonPos.1321 // * \param *event structure containing information of the event1322 // */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 array1332 // case Qt::LeftButton: // LeftButton rotates the view1333 // srcpos = &LeftButtonPos;1334 // std::cout << "Left Button" << endl;1335 // if (srcpos) { // subtract the position and act1336 // 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 one1343 // // switch between three regions1344 // // decide into which of the four screens the initial click has been made1345 // std::cout << "Position is " << pos << "." << endl;1346 // switch(pos) {1347 // case 0: // lower left = xz1348 // position[0] += -destpos.y()/100.;1349 // position[2] += destpos.x()/100.;1350 // break;1351 // case 1: // lower right = yz1352 // position[1] += -destpos.y()/100.;1353 // position[2] += -destpos.x()/100.;1354 // break;1355 // case 2: // upper left = projected1356 // std::cout << "This is impossible: Shifting in the projected region, we should rotate!." << endl;1357 // break;1358 // case 3: // upper right = xy1359 // 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 region1368 // 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 far1403 // srcpos = &MiddleButtonPos;1404 // std::cout << "Middle Button" << endl;1405 // if (srcpos) { // subtract the position and act1406 // 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 atom1445 // srcpos = &RightButtonPos;1446 // std::cout << "Right Button" << endl;1447 // if (srcpos) { // subtract the position and act1448 // 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 change1454 // 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 // else1461 // SelectedPosition = (*(*SelectedMolecules.begin())->begin())->getPosition();1462 // }1463 // // decide into which of the four screens the initial click has been made1464 // 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 = xz1469 // SelectedPosition[0] += -destpos.y()/100.;1470 // SelectedPosition[2] += destpos.x()/100.;1471 // break;1472 // case 1: // lower right = yz1473 // SelectedPosition[1] += -destpos.y()/100.;1474 // SelectedPosition[2] += -destpos.x()/100.;1475 // break;1476 // case 2: // upper left = projected1477 // SelectedPosition[0] += destpos.x()/100.;1478 // SelectedPosition[1] += destpos.y()/100.;1479 // SelectedPosition[2] += destpos.y()/100.;1480 // break;1481 // case 3: // upper right = xy1482 // 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 Tables1493 // if (SelectedMolecules.size()) {1494 // isSignaller = true;1495 // if (SelectedAtoms.size())1496 // emit notifyAtomChanged( (*SelectedMolecules.begin()), (*SelectedAtoms.begin()), AtomPosition);1497 // else1498 // emit notifyMoleculeChanged( (*SelectedMolecules.begin()), MoleculePosition );1499 // }1500 // // update graphic1501 // 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 molecule1520 // */1521 //void GLMoleculeView::hearMoleculeSelected(molecule *mol)1522 //{1523 // if (isSignaller) { // if we emitted the signal, return1524 // isSignaller = false;1525 // return;1526 // }1527 // initializeGL();1528 // updateGL();1529 //};1530 //1531 ///** Hear announcement of selected atom.1532 // * \param *mol pointer to molecule containing atom1533 // * \param *Walker pointer to selected atom1534 // */1535 //void GLMoleculeView::hearAtomSelected(molecule *mol, atom *Walker)1536 //{1537 // if (isSignaller) { // if we emitted the signal, return1538 // isSignaller = false;1539 // return;1540 // }1541 // initializeGL();1542 // updateGL();1543 //};1544 //1545 ///** Hear announcement of changed molecule.1546 // * \param *mol pointer to changed molecule1547 // * \param type of change1548 // */1549 //void GLMoleculeView::hearMoleculeChanged(molecule *mol, enum ChangesinMolecule type)1550 //{1551 // if (isSignaller) { // if we emitted the signal, return1552 // isSignaller = false;1553 // return;1554 // }1555 // initializeGL();1556 // updateGL();1557 //};1558 //1559 ///** Hear announcement of changed atom.1560 // * \param *mol pointer to molecule containing atom1561 // * \param *Walker pointer to changed atom1562 // * \param type type of change1563 // */1564 //void GLMoleculeView::hearAtomChanged(molecule *mol, atom *Walker, enum ChangesinAtom type)1565 //{1566 // if (isSignaller) { // if we emitted the signal, return1567 // isSignaller = false;1568 // return;1569 // }1570 // initializeGL();1571 // updateGL();1572 //};1573 //1574 ///** Hear announcement of changed element.1575 // * \param *Runner pointer to changed element1576 // * \param type of change1577 // */1578 //void GLMoleculeView::hearElementChanged(element *Runner, enum ChangesinElement type)1579 //{1580 // if (isSignaller) { // if we emitted the signal, return1581 // 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 molecule1602 // */1603 //void GLMoleculeView::hearMoleculeAdded(molecule *mol)1604 //{1605 // if (isSignaller) { // if we emitted the signal, return1606 // isSignaller = false;1607 // return;1608 // }1609 // initializeGL();1610 // updateGL();1611 //};1612 //1613 ///** Hear announcement of added atom.1614 // * \param *mol pointer to molecule containing atom1615 // * \param *Walker pointer to added atom1616 // */1617 //void GLMoleculeView::hearAtomAdded(molecule *mol, atom *Walker)1618 //{1619 // if (isSignaller) { // if we emitted the signal, return1620 // isSignaller = false;1621 // return;1622 // }1623 // initializeGL();1624 // updateGL();1625 //};1626 //1627 ///** Hear announcement of removed molecule.1628 // * \param *mol pointer to removed molecule1629 // */1630 //void GLMoleculeView::hearMoleculeRemoved(molecule *mol)1631 //{1632 // if (isSignaller) { // if we emitted the signal, return1633 // isSignaller = false;1634 // return;1635 // }1636 // initializeGL();1637 // updateGL();1638 //};1639 //1640 ///** Hear announcement of removed atom.1641 // * \param *mol pointer to molecule containing atom1642 // * \param *Walker pointer to removed atom1643 // */1644 //void GLMoleculeView::hearAtomRemoved(molecule *mol, atom *Walker)1645 //{1646 // if (isSignaller) { // if we emitted the signal, return1647 // 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 change1662 // * of the Observable occured1663 // */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 stuff1680 //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 no1686 // * @return ref to QGLMaterial1687 // */1688 //QGLMaterial* GLMoleculeView::getMaterial(size_t no)1689 //{1690 // if (ElementNoMaterialMap.find(no) != ElementNoMaterialMap.end()){1691 // // get present one1692 //1693 // } else {1694 // ASSERT( (no >= 0) && (no < MAX_ELEMENTS),1695 // "GLMoleculeView::getMaterial() - Element no "+toString(no)+" is invalid.");1696 // // create new one1697 // 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 checks1714 // 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 checks1727 // 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 first1744 // if (leftno > rightno)1745 // return AtomsinSceneMap[ make_pair(rightno, leftno) ];1746 // else1747 // return AtomsinSceneMap[ make_pair(leftno, rightno) ];1748 //}1749 // -
src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp
r29b35e r55736b 126 126 }; 127 127 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 Observer139 //{140 // Q_OBJECT141 //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 Observable199 // */200 // void update(Observable *publisher);201 //202 // /**203 // * This method is called when a special named change204 // * of the Observable occured205 // */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 stuff229 //230 // GLuint object; // call list for the scene to be rendered231 // GLfloat xRot, yRot, zRot, scale; // rotation angles and scaling (zoom)232 // Vector position; //!< position of observer233 // Vector view; //!< point along line of view234 // Vector top; //!< giving upwards direction235 // Vector X,Y,Z; //!< vectors defining the coordinate system236 // int width; //!< width of window237 // int height; //!< height of window238 //239 // QLabel *StatusBar; //!< pointer to status bar for messages240 // QLabel *CoordinatesBar; //!< pointer to coordinates bar for view port241 //242 // GLfloat LightPosition[4]; //!< Light Position243 // GLfloat LightDiffuse[4]; //!< Diffuse Light Values244 // GLfloat LightAmbient[4]; //!< Ambient Light Values245 //246 // QPoint LeftButtonPos; //!< mouse position on mousePressEvent for LeftButton247 // QPoint MiddleButtonPos; //!< mouse position on mousePressEvent for MidButton248 // QPoint RightButtonPos; //!< mouse position on mousePressEvent for RightButton249 //250 // unsigned char SelectionColor[3] ; //!< highlight color251 //252 // bool isSignaller;253 //254 // bool MultiViewEnabled; //!< if true, split screen into four parts with additional xy,xz,yz views255 //};256 257 128 #endif /* GLWORLDVIEW_HPP_ */ -
src/documentation/constructs/filling.dox
r29b35e r55736b 74 74 * the specific implementations of the class \ref Inserter. 75 75 * 76 * \section filling-preparators Filling Preparators 76 77 * 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 78 90 */ -
src/molecule.cpp
r29b35e r55736b 751 751 }; 752 752 753 /** Sets the molecule::cell_size to the components of \a *dim (rectangular box)754 * \param *dim vector class755 */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 764 753 /** Removes atom from molecule list, but does not delete it. 765 754 * \param *pointer atom to be removed -
src/molecule.hpp
r29b35e r55736b 273 273 bool CenterInBox(); 274 274 bool BoundInBox(); 275 void CenterEdge( Vector *max);275 void CenterEdge(); 276 276 void CenterOrigin(); 277 277 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 * * constfactor);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); 284 284 void DeterminePeriodicCenter(Vector ¢er, 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; 288 287 void SetNameFromFilename(const char *filename); 289 void SetBoxDimension(Vector *dim);290 288 bool ScanForPeriodicCorrection(); 291 289 double VolumeOfConvexEnvelope(bool IsAngstroem); -
src/molecule_geometry.cpp
r29b35e r55736b 58 58 /************************************* Functions for class molecule *********************************/ 59 59 60 /** Returns vector pointing to center of the domain. 61 * \return pointer to center of the domain 62 */ 63 #ifdef HAVE_INLINE 64 inline 65 #else 66 static 67 #endif 68 const 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 } 60 75 61 76 /** Centers the molecule in the box whose lengths are defined by vector \a *BoxLengths. … … 65 80 { 66 81 bool status = true; 67 const Vector *Center = DetermineCenterOfAll();68 const Vector *CenterBox = DetermineCenterOfBox();82 const Vector Center = DetermineCenterOfAll(); 83 const Vector CenterBox = DetermineCenterOfBox(); 69 84 Box &domain = World::getInstance().getDomain(); 70 85 71 86 // 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); 80 88 getAtomSet().transformNodes(boost::bind(&Box::enforceBoundaryConditions,domain,_1)); 81 89 82 delete(Center);83 delete(CenterBox);84 90 return status; 85 } ;91 } 86 92 87 93 … … 98 104 99 105 return status; 100 } ;106 } 101 107 102 108 /** 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 */ 110 void 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 ¤tPos = (*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 } 131 124 132 125 /** Centers the center of the atoms at (0,0,0). … … 147 140 } 148 141 Center.Scale(-1./(double)Num); // divide through total number (and sign for direction) 149 Translate( &Center);150 } 151 } ;142 Translate(Center); 143 } 144 } 152 145 153 146 /** Returns vector pointing to center of all atoms. 154 147 * \return pointer to center of all vector 155 148 */ 156 Vector *molecule::DetermineCenterOfAll() const149 const Vector molecule::DetermineCenterOfAll() const 157 150 { 158 151 const_iterator iter = begin(); // start at first in list 159 Vector *a = new Vector();152 Vector a; 160 153 double Num = 0; 161 154 162 a ->Zero();155 a.Zero(); 163 156 164 157 if (iter != end()) { //list not empty? 165 158 for (; iter != end(); ++iter) { // continue with second if present 166 159 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) 170 163 } 171 164 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 184 167 185 168 /** Returns vector pointing to center of gravity. … … 187 170 * \return pointer to center of gravity vector 188 171 */ 189 Vector *molecule::DetermineCenterOfGravity() const172 const Vector molecule::DetermineCenterOfGravity() const 190 173 { 191 174 const_iterator iter = begin(); // start at first in list 192 Vector *a = new Vector();175 Vector a; 193 176 Vector tmp; 194 177 double Num = 0; 195 178 196 a ->Zero();179 a.Zero(); 197 180 198 181 if (iter != end()) { //list not empty? … … 200 183 Num += (*iter)->getType()->getMass(); 201 184 tmp = (*iter)->getType()->getMass() * (*iter)->getPosition(); 202 (*a)+= tmp;203 } 204 a ->Scale(1./Num); // divide through total mass205 } 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 << "."); 207 190 return a; 208 } ;191 } 209 192 210 193 /** Centers the center of gravity of the atoms at (0,0,0). … … 216 199 Vector NewCenter; 217 200 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 } 223 203 224 204 … … 227 207 * \param *center return vector for translation vector 228 208 */ 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 }; 209 void molecule::CenterAtVector(const Vector &newcenter) 210 { 211 Translate(-1.*newcenter); 212 } 236 213 237 214 /** Calculate the inertia tensor of a the molecule. … … 242 219 { 243 220 RealSpaceMatrix InertiaTensor; 244 Vector *CenterOfGravity = DetermineCenterOfGravity();221 const Vector CenterOfGravity = DetermineCenterOfGravity(); 245 222 246 223 // reset inertia tensor … … 250 227 for (const_iterator iter = begin(); iter != end(); ++iter) { 251 228 Vector x = (*iter)->getPosition(); 252 x -= *CenterOfGravity;229 x -= CenterOfGravity; 253 230 const double mass = (*iter)->getType()->getMass(); 254 231 InertiaTensor.at(0,0) += mass*(x[1]*x[1] + x[2]*x[2]); … … 265 242 LOG(1, "INFO: The inertia tensor of molecule " << getName() << " is:" << InertiaTensor); 266 243 267 delete CenterOfGravity;268 244 return InertiaTensor; 269 245 } … … 276 252 void molecule::RotateToPrincipalAxisSystem(const Vector &Axis) 277 253 { 278 Vector *CenterOfGravity = DetermineCenterOfGravity();254 const Vector CenterOfGravity = DetermineCenterOfGravity(); 279 255 RealSpaceMatrix InertiaTensor = getInertiaTensor(); 280 256 … … 288 264 289 265 // obtain first column, eigenvector to biggest eigenvalue 290 Vector BiggestEigenvector(InertiaTensor.column(Eigenvalues.SmallestComponent()));266 const Vector BiggestEigenvector(InertiaTensor.column(Eigenvalues.SmallestComponent())); 291 267 Vector DesiredAxis(Axis.getNormalized()); 292 268 … … 302 278 // and rotate 303 279 for (iterator iter = begin(); iter != end(); ++iter) { 304 *(*iter) -= *CenterOfGravity;280 *(*iter) -= CenterOfGravity; 305 281 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), alpha)); 306 *(*iter) += *CenterOfGravity;282 *(*iter) += CenterOfGravity; 307 283 } 308 284 LOG(0, "STATUS: done."); 309 310 delete CenterOfGravity;311 285 } 312 286 … … 319 293 * x=(**factor) * x (as suggested by comment) 320 294 */ 321 void molecule::Scale(const double * * constfactor)295 void molecule::Scale(const double *factor) 322 296 { 323 297 for (iterator iter = begin(); iter != end(); ++iter) { 324 298 for (size_t j=0;j<(*iter)->getTrajectorySize();j++) { 325 299 Vector temp = (*iter)->getPositionAtStep(j); 326 temp.ScaleAll( *factor);300 temp.ScaleAll(factor); 327 301 (*iter)->setPositionAtStep(j,temp); 328 302 } … … 333 307 * \param trans[] translation vector. 334 308 */ 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 } 309 void molecule::Translate(const Vector &trans) 310 { 311 getAtomSet().translate(trans); 342 312 }; 343 313 … … 346 316 * TODO treatment of trajectories missing 347 317 */ 348 void molecule::TranslatePeriodically(const Vector *trans) 349 { 318 void molecule::TranslatePeriodically(const Vector &trans) 319 { 320 Translate(trans); 350 321 Box &domain = World::getInstance().getDomain(); 351 352 // go through all atoms353 for (iterator iter = begin(); iter != end(); ++iter) {354 **iter += *trans;355 }356 322 getAtomSet().transformNodes(boost::bind(&Box::enforceBoundaryConditions,domain,_1)); 357 358 323 }; 359 324 … … 362 327 * \param n[] normal vector of mirror plane. 363 328 */ 364 void molecule::Mirror(const Vector *n) 365 { 366 OBSERVE; 367 Plane p(*n,0); 329 void molecule::Mirror(const Vector &n) 330 { 331 Plane p(n,0); 368 332 getAtomSet().transformNodes(boost::bind(&Plane::mirrorVector,p,_1)); 369 333 }; … … 381 345 Vector Testvector, Translationvector; 382 346 Vector Center; 383 BondGraph *BG = World::getInstance().getBondGraph();347 const BondGraph * const BG = World::getInstance().getBondGraph(); 384 348 385 349 do { … … 432 396 433 397 Center.Scale(1./static_cast<double>(getAtomCount())); 434 CenterAtVector( &Center);398 CenterAtVector(Center); 435 399 }; 436 400 … … 438 402 * \param n[] alignment vector. 439 403 */ 440 void molecule::Align( Vector *n)404 void molecule::Align(const Vector &n) 441 405 { 442 406 double alpha, tmp; 443 407 Vector z_axis; 408 Vector alignment(n); 444 409 z_axis[0] = 0.; 445 410 z_axis[1] = 0.; … … 448 413 // rotate on z-x plane 449 414 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)); 451 416 LOG(1, "INFO: Z-X-angle: " << alpha << " ... "); 452 417 for (iterator iter = begin(); iter != end(); ++iter) { … … 462 427 } 463 428 // 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); 468 433 469 434 // rotate on z-y plane 470 alpha = atan(- n->at(1)/n->at(2));435 alpha = atan(-alignment.at(1)/alignment.at(2)); 471 436 LOG(1, "INFO: Z-Y-angle: " << alpha << " ... "); 472 437 for (iterator iter = begin(); iter != end(); ++iter) { … … 482 447 } 483 448 // 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); 490 454 LOG(0, "End of Aligning all atoms."); 491 455 }; -
src/moleculelist.cpp
r29b35e r55736b 229 229 } 230 230 // 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; 234 233 } 235 234 } … … 578 577 // if (BoxDimension[k] < 1.) 579 578 // 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 // } 581 585 // for (int k = 0; k < NDIM; k++) { 582 586 // BoxDimension[k] = 2.5 * (World::getInstance().getConfig()->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
Note:
See TracChangeset
for help on using the changeset viewer.
