Changes in / [06f4ef6:b6da28]


Ignore:
Files:
136 added
24 deleted
295 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r06f4ef6 rb6da28  
     118.04.2008
     2        + essential switch in structure of ESPACK. Instead of having everything
     3        relative to pcp, we now have three tantamount packages: pcp, utilities and
     4        molecuilder
  • Makefile.am

    r06f4ef6 rb6da28  
    77doc:
    88        cd doc && make doxygen-docs
     9       
     10unity:
     11        cd src && make unity
  • README

    r06f4ef6 rb6da28  
     1<<<<<<< HEAD
    12# Project: Molecuilder
    23#
     
    67
    78... is a tool that started as a mean to edit pcp configuration files (adding/remvoing groups of atoms, measuring bond lengths and so forth) and has grown into the many-body fragmentation test base of a new method coined BOSSANOVA (Bond Order diSSection in an ANOVA (ANalysis Of VAriance) -like fashion). It spills out configuration files for each fragment and includes joining and analyzing programs, to put together the partial energies and forces of each fragment to the total energy and forces. It allows for a complete Born-Oppenheimer molecular dynamics run.
     9=======
     10# Project: ParallelCarParrinello
     11# Jan Hamaekers
     12# Frederik Heber
     13# 2005
     14#
     15# File: README
     16
     17        Electronic Structure PACKage
     18
     19Is a collection of mathematical-physical programs to calculate via various ab-initio methods
     20such as density functional theory or Hartree-Fock electronic(-magnetic) properties including
     21the molecular (Car&Parrinello) dynamics of a many electron system. Especially, the linear
     22response of the system to a external magnetic field in a perturbation approach in terms of
     23susceptibility and chemical shielding is implemented via the Density Functional Perturbation
     24Theory. It was developed mainly by Jan Hamaekers (pcp) with additional code by Frederik Heber
     25(dfpt part in pcp) and also Ralf Wildenhuis (Gauss) at the Institute for Numerical Simulation
     26at the University of Bonn[1].
     27
     28
     29>>>>>>> FETCH_HEAD
    830
    931INSTALLATION NOTES
    1032==================
    1133
     34<<<<<<< HEAD
    1235The following packages are needed
    1336* GCC or alike
    1437* GSL (GNU Scientific Library, available at http://www.gnu.org/software/gsl)
     38* Boost 1.4 or newer
     39=======
     40In general gcc or alike is needed to compile the sources, for more specific demands see the README files in the sub directory of each package part.
     41
     42LINKS
     43=====
     44[1] http://www.ins.uni-bonn.de/
     45>>>>>>> FETCH_HEAD
  • configure.ac

    r06f4ef6 rb6da28  
    88AC_CONFIG_HEADER([config.h])
    99
    10 AM_INIT_AUTOMAKE(dist-bzip2)
     10AM_INIT_AUTOMAKE(dist-bzip2 parallel-tests)
    1111
    1212# Checks for programs.
     
    3333AX_BOOST_THREAD
    3434#AX_BOOST_SERIALIZATION
     35
     36#QT4 libraries
     37gw_CHECK_QT4
     38AX_CHECK_GLU
     39AC_MSG_NOTICE(["GLU_CFLAGS: $GLU_CFLAGS, GLU_CXXFLAGS: $GLU_CXXFLAGS, GLU_LDFLAGS: $GLU_LDFLAGS, GLU_LIBS: $GLU_LIBS"])
     40
    3541
    3642# Checks for header files.
     
    6672
    6773# add replacement/saturation hydrogen or not
    68 AC_ARG_ENABLE([ecut],AS_HELP_STRING([--enable-ecut],[Use ECut TestRunnerClient (default is yes)]),
    69               [enable_ecut=$enableval], [enable_ecut=yes])
     74AC_ARG_ENABLE([ecut],AS_HELP_STRING([--enable-ecut],[Use ECut TestRunnerClient (default is no)]),
     75              [enable_ecut=$enableval], [enable_ecut=no])
    7076if test x"$enable_ecut" = xyes; then
    7177  AC_DEFINE(HAVE_ECUT,1, ["Use ECut TestRunnerClient instead of our own."])
  • doc/Doxyfile

    r06f4ef6 rb6da28  
    258258# Configuration::additions related to the search engine   
    259259#---------------------------------------------------------------------------
    260 SEARCHENGINE           = NO
     260SEARCHENGINE           = YES
  • doc/class structure.uxf

    r06f4ef6 rb6da28  
    2121
    2222
    23 // This text will be stored with each diagram;  use it for notes.</help_text><zoom_level>7</zoom_level><element><type>com.umlet.element.base.Class</type><coordinates><x>1855</x><y>294</y><w>147</w><h>70</h></coordinates><panel_attributes>AtomInfo
     23// This text will be stored with each diagram;  use it for notes.</help_text><zoom_level>7</zoom_level><element><type>com.umlet.element.base.Class</type><coordinates><x>1855</x><y>210</y><w>147</w><h>70</h></coordinates><panel_attributes>AtomInfo
    2424--
    2525-x,v,F: Vector
     
    2828#AtomInfo();
    2929#~AtomInfo();
    30 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1645</x><y>315</y><w>223</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>210;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1274</x><y>147</y><w>392</w><h>259</h></coordinates><panel_attributes>Element
     30</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1645</x><y>231</y><w>223</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>210;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1274</x><y>63</y><w>392</w><h>259</h></coordinates><panel_attributes>Element
    3131--
    3232mass: double
     
    4949#~element();
    5050#Output(ofstream * const out) const: bool
    51 #Checkout(ofstream * const out, const int No, const int NoOfAtoms) const: bool</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1960</x><y>532</y><w>280</w><h>161</h></coordinates><panel_attributes>BondedParticle
     51#Checkout(ofstream * const out, const int No, const int NoOfAtoms) const: bool</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1960</x><y>448</y><w>280</w><h>161</h></coordinates><panel_attributes>BondedParticle
    5252--
    5353--
     
    6363#OutputBondOfAtom() const
    6464#OutputAdjacency(ofstream *AdjacencyFile) const
    65 #OutputOrder(ofstream *file) const</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2184</x><y>343</y><w>258</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>245;21;245;154;21;154;21;189</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1925</x><y>343</y><w>293</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-
    66 </panel_attributes><additional_attributes>21;21;21;154;280;154;280;189</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2184</x><y>343</y><w>34</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;189</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2359</x><y>294</y><w>147</w><h>70</h></coordinates><panel_attributes>BondedParticleInfo
     65#OutputOrder(ofstream *file) const</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2184</x><y>259</y><w>258</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>245;21;245;154;21;154;21;189</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1925</x><y>259</y><w>293</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-
     66</panel_attributes><additional_attributes>21;21;21;154;280;154;280;189</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2184</x><y>259</y><w>34</w><h>202</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;189</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2359</x><y>210</y><w>147</w><h>70</h></coordinates><panel_attributes>BondedParticleInfo
    6767--
    6868AdaptiveOrder: unsigned char
     
    7171#BondedParticleInfo()
    7272#~BondedParticleInfo()
    73 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2079</x><y>280</y><w>217</w><h>84</h></coordinates><panel_attributes>ParticleInfo
     73</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2079</x><y>196</y><w>217</w><h>84</h></coordinates><panel_attributes>ParticleInfo
    7474--
    7575nr: int
     
    7979#~ParticleInfo()
    8080#ostream &amp; operator &lt;&lt; (ostream &amp;ost) const
    81 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2485</x><y>315</y><w>174</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;161;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2646</x><y>245</y><w>147</w><h>133</h></coordinates><panel_attributes>BondList
     81</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2485</x><y>231</y><w>174</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;161;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2646</x><y>161</y><w>147</w><h>133</h></coordinates><panel_attributes>BondList
    8282{Some Properties}
    8383--
     
    9090Responsibilities
    9191-- Resp1
    92 *-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1372</x><y>427</y><w>147</w><h>105</h></coordinates><panel_attributes>GraphNodeInfo
     92*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1372</x><y>343</y><w>147</w><h>105</h></coordinates><panel_attributes>GraphNodeInfo
    9393--
    9494--
     
    102102#GraphNodeInfo()
    103103#~GraphNodeInfo()
    104 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1484</x><y>609</y><w>126</w><h>70</h></coordinates><panel_attributes>GraphNode
     104</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1484</x><y>525</y><w>126</w><h>70</h></coordinates><panel_attributes>GraphNode
    105105--
    106106--
     
    109109#OutputGraphInfo() const
    110110#OutputComponentNumber() const
    111 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1484</x><y>343</y><w>748</w><h>279</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>735;21;735;70;217;70;217;210;21;210;21;266</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1484</x><y>511</y><w>34</w><h>111</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;98</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1288</x><y>756</y><w>588</w><h>245</h></coordinates><panel_attributes>Atom
     111</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1484</x><y>259</y><w>748</w><h>279</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>735;21;735;70;217;70;217;210;21;210;21;266</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1484</x><y>427</y><w>34</w><h>111</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;98</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1288</x><y>672</y><w>588</w><h>245</h></coordinates><panel_attributes>Atom
    112112--
    113113sort: int*
     
    129129#DistanceToVector(const Vector &amp;origin) const: double
    130130#DistanceSquaredToVector(const Vector &amp;origin) const: double
    131 #IsInParallelepiped(const Vector offset, const double *parallelepiped) const: bool</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1379</x><y>511</y><w>83</w><h>258</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;182;70;182;70;245</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2226</x><y>749</y><w>504</w><h>210</h></coordinates><panel_attributes>TrajectoryParticle
     131#IsInParallelepiped(const Vector offset, const double *parallelepiped) const: bool</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1379</x><y>427</y><w>83</w><h>258</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;182;70;182;70;245</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2226</x><y>665</y><w>504</w><h>210</h></coordinates><panel_attributes>TrajectoryParticle
    132132--
    133133--
     
    147147#Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration)
    148148#Thermostat_NoseHoover_init(int Step, double *delta_alpha)
    149 #Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration)</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2149</x><y>343</y><w>209</w><h>419</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;112;196;112;196;406</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1967</x><y>343</y><w>391</w><h>419</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;112;378;112;378;406</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1617</x><y>574</y><w>203</w><h>70</h></coordinates><panel_attributes>TrajectoryParticleInfo
     149#Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration)</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>2149</x><y>259</y><w>209</w><h>419</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;112;196;112;196;406</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1967</x><y>259</y><w>391</w><h>419</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;112;378;112;378;406</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1617</x><y>490</y><w>203</w><h>70</h></coordinates><panel_attributes>TrajectoryParticleInfo
    150150--
    151151Trajectory: struct {vector&lt;Vector&gt; R,U,V}
     
    153153--
    154154#TrajectoryParticleInfo()
    155 #~TrajectoryParticleInfo()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1757</x><y>623</y><w>601</w><h>139</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;105;588;105;588;126</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>623</y><w>34</w><h>146</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;133</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1519</x><y>658</y><w>244</w><h>111</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;56;231;56;231;98</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1736</x><y>448</y><w>147</w><h>112</h></coordinates><panel_attributes>TesselPoint
     155#~TrajectoryParticleInfo()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1757</x><y>539</y><w>601</w><h>139</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;105;588;105;588;126</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>539</y><w>34</w><h>146</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;133</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1519</x><y>574</y><w>244</w><h>111</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>21;21;21;56;231;56;231;98</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1736</x><y>364</y><w>147</w><h>112</h></coordinates><panel_attributes>TesselPoint
    156156--
    157157-id: Long
     
    163163Responsibilities
    164164-- Resp1
    165 *-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>539</y><w>146</w><h>230</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>133;21;133;175;21;175;21;217</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>672</y><w>398</w><h>97</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>385;21;385;42;21;42;21;84</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>343</y><w>398</w><h>426</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>385;21;385;168;196;168;196;371;21;371;21;413</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>343</y><w>209</w><h>426</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>196;21;196;371;21;371;21;413</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>833</x><y>854</y><w>357</w><h>224</h></coordinates><panel_attributes>Bond
     165*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>455</y><w>146</w><h>230</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>133;21;133;175;21;175;21;217</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>588</y><w>398</w><h>97</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>385;21;385;42;21;42;21;84</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>259</y><w>398</w><h>426</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>385;21;385;168;196;168;196;371;21;371;21;413</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1729</x><y>259</y><w>209</w><h>426</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>196;21;196;371;21;371;21;413</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>833</x><y>770</y><w>357</w><h>224</h></coordinates><panel_attributes>Bond
    166166--
    167167HydrogenBond: int
     
    182182#bond()
    183183#bond(atom *left, atom *right, const int degree=1, const int number=0)
    184 #~bond()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1834</x><y>707</y><w>107</w><h>125</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
    185 3</panel_attributes><additional_attributes>42;112;91;112;91;35;21;35;21;49</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1169</x><y>896</y><w>132</w><h>49</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
    186 2</panel_attributes><additional_attributes>21;35;119;35</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>770</x><y>742</y><w>111</w><h>167</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
    187 2</panel_attributes><additional_attributes>63;154;28;154;28;35;98;35;98;112</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1113</x><y>1330</y><w>504</w><h>168</h></coordinates><panel_attributes>BondGraph
     184#~bond()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1834</x><y>623</y><w>107</w><h>125</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
     1853</panel_attributes><additional_attributes>42;112;91;112;91;35;21;35;21;49</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1169</x><y>812</y><w>132</w><h>49</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
     1862</panel_attributes><additional_attributes>21;35;119;35</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>770</x><y>658</y><w>111</w><h>167</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
     1872</panel_attributes><additional_attributes>63;154;28;154;28;35;98;35;98;112</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1113</x><y>1246</y><w>504</w><h>168</h></coordinates><panel_attributes>BondGraph
    188188--
    189189max_distance: double
     
    199199                                                        double &amp;MinDistance, double &amp;MaxDistance, bool IsAngstroem)
    200200#CovalentMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker,
    201                                           double &amp;MinDistance, double &amp;MaxDistance, bool IsAngstroem)</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1596</x><y>1407</y><w>167</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;154;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1750</x><y>1365</y><w>147</w><h>133</h></coordinates><panel_attributes>MatrixContainer
     201                                          double &amp;MinDistance, double &amp;MaxDistance, bool IsAngstroem)</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1596</x><y>1323</y><w>167</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;154;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1750</x><y>1281</y><w>147</w><h>133</h></coordinates><panel_attributes>MatrixContainer
    202202--
    203203-id: Long
     
    209209Responsibilities
    210210-- Resp1
    211 *-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>0</x><y>539</y><w>511</w><h>1050</h></coordinates><panel_attributes>config
     211*-- Resp2*</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>0</x><y>455</y><w>511</w><h>1050</h></coordinates><panel_attributes>config
    212212--
    213213PsiType: int
     
    297297#SetDefaultPath(const char * const path);
    298298#InitThermostats();
    299 #ParseThermostats(class ConfigFileBuffer * const fb);</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>490</x><y>1428</y><w>636</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;623;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1596</x><y>84</y><w>121</w><h>139</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
    300 2</panel_attributes><additional_attributes>70;126;105;126;105;35;21;35;21;63</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2520</x><y>980</y><w>224</w><h>140</h></coordinates><panel_attributes>&lt;&lt;Singleton&gt;&gt;
     299#ParseThermostats(class ConfigFileBuffer * const fb);</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>490</x><y>1344</y><w>636</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;623;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1596</x><y>0</y><w>121</w><h>139</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
     3002</panel_attributes><additional_attributes>70;126;105;126;105;35;21;35;21;63</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2520</x><y>896</y><w>224</w><h>140</h></coordinates><panel_attributes>&lt;&lt;Singleton&gt;&gt;
    301301errorLogger
    302302--
     
    310310#static setVerbosity(int verbosityLevel);
    311311#protected errorLogger()
    312 #protected ~errorLogger()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2093</x><y>1064</y><w>364</w><h>35</h></coordinates><panel_attributes>KeyCompare
     312#protected ~errorLogger()</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>2093</x><y>980</y><w>364</w><h>35</h></coordinates><panel_attributes>KeyCompare
    313313--
    314314--
    315315#operator() (const KeySet SubgraphA, const KeySet SubgraphB) const: bool
    316 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1169</x><y>1218</y><w>147</w><h>105</h></coordinates><panel_attributes>UniqueFragments
     316</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1169</x><y>1134</y><w>147</w><h>105</h></coordinates><panel_attributes>UniqueFragments
    317317--
    318318ANOVAOrder: int
     
    322322ShortestPathList: int *
    323323UsedList: bool **
    324 BondsPerSPCount: int *</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>490</x><y>1253</y><w>692</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>679;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1120</x><y>980</y><w>251</w><h>307</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>49;294;21;294;21;224;238;224;238;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>840</x><y>1127</y><w>245</w><h>28</h></coordinates><panel_attributes>Graph
     324BondsPerSPCount: int *</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>490</x><y>1169</y><w>692</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>679;21;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1120</x><y>896</y><w>251</w><h>307</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>49;294;21;294;21;224;238;224;238;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>840</x><y>1043</y><w>245</w><h>28</h></coordinates><panel_attributes>Graph
    325325{map &lt;KeySet, NumberValuePair, KeyCompare&gt;}
    326 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>861</x><y>1134</y><w>321</w><h>153</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>308;140;21;140;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>945</x><y>1190</y><w>56</w><h>28</h></coordinates><panel_attributes>KeySet
    327 {set&lt;int&gt;}</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>945</x><y>1197</y><w>237</w><h>90</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>224;77;21;77;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1085</x><y>1057</y><w>99</w><h>230</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
    328 0...N X 0...N</panel_attributes><additional_attributes>84;217;56;217;56;112;21;112;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1736</x><y>2282</y><w>147</w><h>42</h></coordinates><panel_attributes>LSQ_params
     326</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>861</x><y>1050</y><w>321</w><h>153</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>308;140;21;140;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>945</x><y>1106</y><w>56</w><h>28</h></coordinates><panel_attributes>KeySet
     327{set&lt;int&gt;}</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>945</x><y>1113</y><w>237</w><h>90</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>224;77;21;77;21;21</additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1085</x><y>973</y><w>99</w><h>230</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-
     3280...N X 0...N</panel_attributes><additional_attributes>84;217;56;217;56;112;21;112;21;21</additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1736</x><y>2198</y><w>147</w><h>42</h></coordinates><panel_attributes>LSQ_params
    329329--
    330330vectors: const Vector **
    331331num: int
    332 </panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1043</x><y>266</y><w>147</w><h>35</h></coordinates><panel_attributes>lsq_params
    333 --
    334 x: gsl_vector *</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1169</x><y>266</y><w>118</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;105;21</additional_attributes></element></umlet_diagram>
     332</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Class</type><coordinates><x>1043</x><y>182</y><w>147</w><h>35</h></coordinates><panel_attributes>lsq_params
     333--
     334x: gsl_vector *</panel_attributes><additional_attributes></additional_attributes></element><element><type>com.umlet.element.base.Relation</type><coordinates><x>1169</x><y>182</y><w>118</w><h>34</h></coordinates><panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes><additional_attributes>21;21;105;21</additional_attributes></element></umlet_diagram>
  • src/Actions/Action.cpp

    r06f4ef6 rb6da28  
    1313#include "Actions/ActionRegistry.hpp"
    1414#include "Actions/ActionHistory.hpp"
     15#include "Exceptions/MissingValueException.hpp"
     16#include "UIElements/Dialog.hpp"
    1517#include "Helpers/MemDebug.hpp"
     18#include "UIElements/UIFactory.hpp"
     19
     20#include "log.hpp"
     21#include "verbose.hpp"
    1622
    1723using namespace std;
     
    2935{
    3036  if(_doRegister){
    31     ActionRegistry::getInstance().registerAction(this);
     37    ActionRegistry::getInstance().registerInstance(this);
    3238  }
    3339}
     
    4046}
    4147
    42 void Action::call(){
     48Dialog * Action::createDialog(){
     49  Dialog *dialog = UIFactory::getInstance().makeDialog();
     50  return fillDialog(dialog);
     51}
     52
     53void Action::call(enum QueryOptions flag){
    4354  if(!isActive()){
    4455    return;
    4556  }
    4657  // forward to private virtual
    47   state_ptr state = performCall();
     58  if (flag == Interactive) {
     59    Dialog* dialog = createDialog();
     60    if (dialog->hasQueries()) {
     61      dialog->display();
     62    }
     63    delete(dialog);
     64  }
     65  state_ptr state = Action::failure;
     66//  try {
     67    state = performCall();
     68//  } catch(MissingValueException&) {
     69//    DoeLog(0) && (eLog() << Verbose(0) << "There is a value missing for action " << getName() << endl);
     70//  };
     71
    4872  if(shouldUndo() && state != failure){
    4973    if(canUndo()){
  • src/Actions/Action.hpp

    r06f4ef6 rb6da28  
    1616class ActionState;
    1717class ActionSequence;
     18class Dialog;
    1819
    1920/**
     
    4445 * hasRedo() method respectively.
    4546 *
     47 * Note that an Action always has two functions createDialog() and performCall(). The former
     48 * returns a Dialog filled with query...() functions for all information that we need from the
     49 * user. The latter must not contain any interaction but just uses these values (which are
     50 * temporarily stored by class ValueStorage) to perform the Action.
     51 *
     52 * Furthermore, there is a global action function that makes the action callable with already
     53 * present parameters (i.e. without user interaction and for internal use within the code only).
     54 * This function is basically just a macro, that puts the parameters into the ValueStorage and
     55 * calls Action::call(Action::NonInteractive).
     56 *
    4657 * Actions can be set to be active or inactive. If an action is set to inactive it is signaling, that
    4758 * some condition necessary for this action to be executed is not currently met. For example the
     
    7889 * Building actions is fairly easy. Simply derive from the abstract Action base class and implement
    7990 * the virtual methods. The main code that needs to be executed upon call() should be implemented in
    80  * the performCall() method. You should also indicate whether the action supports undo by implementing
     91 * the performCall() method. Any user interaction should be placed into the dialog returned by
     92 * createDialog(). You should also indicate whether the action supports undo by implementing
    8193 * the shouldUndo() and canUndo() methods to return the appropriate flags.
     94 *
     95 * Also, create the global function to allow for easy calling of your function internally (i.e.
     96 * without user interaction). It should have the name of the Action class without the suffix Action.
    8297 *
    8398 * The constructor of your derived class also needs to call the Base constructor, passing it the
     
    122137 *  <li/> derive YourAction from Action
    123138 *  <li/> pass name and flag for registry to the base constructor
    124  *  <li/> implement performCall(), performUndo(), performRedo()
     139 *  <li/> implement createDialog(), performCall(), performUndo(), performRedo()
     140 *  <li/> implement the global function call/macro.
    125141 *  <li/> implement the functions that return the flags for the undo mechanism
    126142 *  <li/> Derive YourActionState from ActionState as necessary
     
    130146 *
    131147 * <ul>
     148 *  <li/> createDialog():
     149 *  <ul>
     150 *   <li/> Call makeDialog() from the UIFactory.
     151 *   <li/> Call any needed Dialog->Query...() for the values you need with specific keywords.
     152 *   <li/> if the action needs to save a state return a custom state object
     153 *   <li/> otherwise return Action::success
     154 *  </ul>
    132155 *  <li/> performCall():
    133156 *  <ul>
     157 *   <li/> obtain parameters you need by ValueStorage::getCurrentValue, matching
     158 *         key words from createDialog().
    134159 *   <li/> do whatever is needed to make the action work
    135160 *   <li/> if the action was abborted return Action::failure
     
    256281public:
    257282
     283  enum QueryOptions {Interactive, NonInteractive};
     284
    258285  /**
    259286   * This type is used to store pointers to ActionStates while allowing multiple ownership
     
    278305   * If the call needs to undone you have to use the History, to avoid destroying
    279306   * invariants used by the History.
    280    */
    281   void call();
     307   *
     308   * Note that this call can be Interactive (i.e. a dialog will ask the user for
     309   * necessary information) and NonInteractive (i.e. the information will have to
     310   * be present already within the ValueStorage class or else a MissingArgumentException
     311   * is thrown)
     312   */
     313  void call(enum QueryOptions state = Interactive);
    282314
    283315  /**
     
    337369  static state_ptr failure;
    338370
     371  /**
     372   * This creates the dialog requesting the information needed for this action from the user
     373   * via means of the user interface.
     374   */
     375  Dialog * createDialog();
     376
    339377private:
    340   /**
    341    * This is called internally when the call is being done. Implement this method to do the actuall
     378
     379  virtual Dialog * fillDialog(Dialog*)=0;
     380
     381  /**
     382   * This is called internally when the call is being done. Implement this method to do the actual
    342383   * work of the Action. Implement this in your Derived classes. Needs to return a state that can be
    343384   * used to undo the action.
  • src/Actions/ActionHistory.cpp

    r06f4ef6 rb6da28  
    8686}
    8787
     88Dialog* ActionHistory::UndoAction::fillDialog(Dialog *dialog){
     89  ASSERT(dialog,"No Dialog given when filling action dialog");
     90  return dialog;
     91}
     92
    8893Action::state_ptr ActionHistory::UndoAction::performCall(){
    8994  hist->undoLast();
     
    120125}
    121126
     127Dialog* ActionHistory::RedoAction::fillDialog(Dialog *dialog){
     128  ASSERT(dialog,"No Dialog given when filling action dialog");
     129  return dialog;
     130}
     131
    122132Action::state_ptr ActionHistory::RedoAction::performCall(){
    123133  hist->redoLast();
  • src/Actions/ActionHistory.hpp

    r06f4ef6 rb6da28  
    3838
    3939    virtual bool isActive();
    40 
     40  protected:
     41    virtual Dialog * fillDialog(Dialog *dialog);
    4142  private:
    4243    virtual Action::state_ptr performCall();
     
    5758    virtual bool isActive();
    5859
     60  protected:
     61    virtual Dialog * fillDialog(Dialog *dialog);
    5962  private:
    6063    virtual Action::state_ptr performCall();
  • src/Actions/ActionRegistry.cpp

    r06f4ef6 rb6da28  
    11/*
    2  * ActionRegistry.cpp
     2 * Registry<Action>.cpp
    33 *
    44 *  Created on: Jan 7, 2010
     
    99
    1010#include "Actions/ActionRegistry.hpp"
    11 #include "Actions/Action.hpp"
     11#include "Patterns/Singleton_impl.hpp"
     12#include "Patterns/Registry_impl.hpp"
    1213
    13 #include "Patterns/Singleton_impl.hpp"
     14/** Constructor for class ActionRegistry.
     15 */
     16ActionRegistry::ActionRegistry()
     17{}
    1418
    15 #include <string>
    16 #include "Helpers/Assert.hpp"
    17 #include <iostream>
     19/** Destructor for class ActionRegistry.
     20 */
     21ActionRegistry::~ActionRegistry()
     22{}
    1823
    19 using namespace std;
    20 
    21 ActionRegistry::ActionRegistry()
     24/** Just passes on call to Registry<Action>::getByName().
     25 * \param name name of Action
     26 * \return pointer to Action
     27 */
     28Action* ActionRegistry::getActionByName(const std::string name)
    2229{
     30  return getByName(name);
    2331}
    2432
    25 ActionRegistry::~ActionRegistry()
     33/** Just passes on call to Registry<Action>::isPresentByName().
     34 * \param name name of Action
     35 * \return true - Action instance present, false - not
     36 */
     37bool ActionRegistry::isActionPresentByName(const std::string name)
    2638{
    27   map<const string,Action*>::iterator iter;
    28   for(iter=actionMap.begin();iter!=actionMap.end();++iter) {
    29     delete iter->second;
    30   }
    31   actionMap.clear();
    32 }
    33 
    34 Action* ActionRegistry::getActionByName(const std::string name){
    35   map<const string,Action*>::iterator iter;
    36   iter = actionMap.find(name);
    37   ASSERT(iter!=actionMap.end(),"Query for an action not stored in registry");
    38   return iter->second;
    39 }
    40 
    41 bool ActionRegistry::isActionByNamePresent(const std::string name){
    42   map<const string,Action*>::iterator iter;
    43   iter = actionMap.find(name);
    44   return iter!=actionMap.end();
    45 }
    46 
    47 void ActionRegistry::registerAction(Action* action){
    48   pair<map<const string,Action*>::iterator,bool> ret;
    49   ret = actionMap.insert(pair<const string,Action*>(action->getName(),action));
    50   ASSERT(ret.second,"Two actions with the same name added to registry");
    51 }
    52 
    53 void ActionRegistry::unregisterAction(Action* action){
    54   actionMap.erase(action->getName());
    55 }
    56 
    57 std::map<const std::string,Action*>::iterator ActionRegistry::getBeginIter()
    58 {
    59   return actionMap.begin();
    60 }
    61 
    62 std::map<const std::string,Action*>::iterator ActionRegistry::getEndIter()
    63 {
    64   return actionMap.end();
     39  return isPresentByName(name);
    6540}
    6641
    6742CONSTRUCT_SINGLETON(ActionRegistry)
     43CONSTRUCT_REGISTRY(Action)
  • src/Actions/ActionRegistry.hpp

    r06f4ef6 rb6da28  
    11/*
    2  * ActionRegistry.hpp
     2 * Registry<Action>.hpp
    33 *
    44 *  Created on: Jan 7, 2010
     
    99#define ACTIONREGISTRY_HPP_
    1010
     11#include <iosfwd>
    1112#include <string>
    1213#include <map>
    1314
     15#include "Patterns/Registry.hpp"
    1416#include "Patterns/Singleton.hpp"
     17#include "Actions/Action.hpp"
    1518
    16 class Action;
    17 
    18 class ActionRegistry : public Singleton<ActionRegistry>
     19/** Action Registry.
     20 *
     21 * The Action registry is a storage for any Action instance to retrieved by name.
     22 * It is a singleton and can be called from anywhere.
     23 *
     24 */
     25class ActionRegistry : public Singleton<ActionRegistry>, public Registry<Action>
    1926{
    2027  friend class Singleton<ActionRegistry>;
     28  //friend class Registry<Action>;
     29
    2130public:
    22   Action* getActionByName(const std::string);
    23   bool isActionByNamePresent(const std::string name);
    24   void registerAction(Action*);
    25   void unregisterAction(Action*);
    26 
    27   std::map<const std::string,Action*>::iterator getBeginIter();
    28   std::map<const std::string,Action*>::iterator getEndIter();
    29 
    30 private:
    31   std::map<const std::string,Action*> actionMap;
     31  Action* getActionByName(const std::string name);
     32  bool isActionPresentByName(const std::string name);
    3233
    3334private:
    3435  ActionRegistry();
    35   virtual ~ActionRegistry();
     36  ~ActionRegistry();
    3637};
    3738
  • src/Actions/ActionSequence.cpp

    r06f4ef6 rb6da28  
    1010#include "Actions/ActionSequence.hpp"
    1111#include "Actions/Action.hpp"
     12#include "UIElements/Dialog.hpp"
    1213
    1314#include "Helpers/Assert.hpp"
     
    3637    return theAction;
    3738  }
     39}
     40
     41// this method is used outside the ActionModule
     42// Each action registers itself with the history
     43Dialog* ActionSequence::fillAllDialogs(Dialog *dialog){
     44  for(actionSet::iterator it=actions.begin(); it!=actions.end(); it++){
     45    dialog = (*it)->fillDialog(dialog);
     46  }
     47  return dialog;
    3848}
    3949
  • src/Actions/ActionSequence.hpp

    r06f4ef6 rb6da28  
    3636protected:
    3737  stateSet callAll(bool); // Dummy parameter to allow overloading
     38  Dialog* fillAllDialogs(Dialog *dialog);
    3839  stateSet undoAll(stateSet);
    3940  stateSet redoAll(stateSet);
  • src/Actions/AnalysisAction/MolecularVolumeAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "boundary.hpp"
    1213#include "config.hpp"
     
    2425#include "UIElements/UIFactory.hpp"
    2526#include "UIElements/Dialog.hpp"
    26 #include "Actions/MapOfActions.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2728
    2829const char AnalysisMolecularVolumeAction::NAME[] = "molecular-volume";
     
    3536{}
    3637
     38void AnalysisMolecularVolume() {
     39  ActionRegistry::getInstance().getActionByName(AnalysisMolecularVolumeAction::NAME)->call(Action::NonInteractive);
     40};
     41
     42Dialog * AnalysisMolecularVolumeAction::fillDialog(Dialog *dialog) {
     43  ASSERT(dialog,"No Dialog given when filling action dialog");
     44  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
     45
     46  return dialog;
     47}
     48
    3749Action::state_ptr AnalysisMolecularVolumeAction::performCall() {
    38   Dialog *dialog = UIFactory::getInstance().makeDialog();
    39   molecule *mol = NULL;
     50  int molID = -1;
     51  // obtain information
     52  ValueStorage::getInstance().queryCurrentValue(NAME, molID);
    4053
    41   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
    42 
    43   if(dialog->display()) {
     54  // execute action
     55  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     56    molecule *mol = iter->second;
    4457    class Tesselation *TesselStruct = NULL;
    4558    const LinkedCell *LCList = NULL;
     
    4760    LCList = new LinkedCell(mol, 10.);
    4861    config * const configuration = World::getInstance().getConfig();
    49     //FindConvexBorder(mol, LCList, argv[argptr]);
     62    Boundaries *BoundaryPoints = NULL;
     63    //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]);
    5064    FindNonConvexBorder(mol, TesselStruct, LCList, 5., NULL);
    5165    //RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]);
     
    5670    delete(TesselStruct);
    5771    delete(LCList);
    58     delete dialog;
    59     return Action::success;
    60   } else {
    61     delete dialog;
    62     return Action::failure;
    6372  }
     73  return Action::success;
    6474}
    6575
    6676Action::state_ptr AnalysisMolecularVolumeAction::performUndo(Action::state_ptr _state) {
    67 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    68 
    69   return Action::failure;
    70 //  string newName = state->mol->getName();
    71 //  state->mol->setName(state->lastName);
    72 //
    73 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     77  return Action::success;
    7478}
    7579
    7680Action::state_ptr AnalysisMolecularVolumeAction::performRedo(Action::state_ptr _state){
    77   return Action::failure;
     81  return Action::success;
    7882}
    7983
    8084bool AnalysisMolecularVolumeAction::canUndo() {
    81   return false;
     85  return true;
    8286}
    8387
    8488bool AnalysisMolecularVolumeAction::shouldUndo() {
    85   return false;
     89  return true;
    8690}
    8791
  • src/Actions/AnalysisAction/MolecularVolumeAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212
     13void AnalysisMolecularVolume();
     14
    1315class AnalysisMolecularVolumeAction : public Action {
     16  friend void AnalysisMolecularVolume();
    1417public:
    1518  AnalysisMolecularVolumeAction();
     
    2023
    2124  virtual const std::string getName();
     25
     26protected:
     27  virtual Dialog * fillDialog(Dialog*);
    2228private:
    2329  virtual Action::state_ptr performCall();
  • src/Actions/AnalysisAction/PairCorrelationAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/AnalysisAction/PairCorrelationAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "analysis_correlation.hpp"
    1213#include "boundary.hpp"
    1314#include "linkedcell.hpp"
     15#include "verbose.hpp"
    1416#include "log.hpp"
    1517#include "element.hpp"
     
    2628#include "UIElements/UIFactory.hpp"
    2729#include "UIElements/Dialog.hpp"
    28 #include "Actions/MapOfActions.hpp"
     30#include "UIElements/ValueStorage.hpp"
    2931
    3032const char AnalysisPairCorrelationAction::NAME[] = "pair-correlation";
     
    3739{}
    3840
     41void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, string &outputname, string &binoutputname, bool periodic) {
     42  ValueStorage::getInstance().setCurrentValue("elements", elements);
     43  ValueStorage::getInstance().setCurrentValue("bin-start", BinStart);
     44  ValueStorage::getInstance().setCurrentValue("bin-width", BinWidth);
     45  ValueStorage::getInstance().setCurrentValue("bin-end", BinEnd);
     46  ValueStorage::getInstance().setCurrentValue("output-file", outputname);
     47  ValueStorage::getInstance().setCurrentValue("bin-output-file", binoutputname);
     48  ValueStorage::getInstance().setCurrentValue("periodic", periodic);
     49  ActionRegistry::getInstance().getActionByName(AnalysisPairCorrelationAction::NAME)->call(Action::NonInteractive);
     50};
     51
     52
     53Dialog* AnalysisPairCorrelationAction::fillDialog(Dialog* dialog) {
     54  ASSERT(dialog,"No Dialog given when filling action dialog");
     55
     56  dialog->queryElements("elements", ValueStorage::getInstance().getDescription("elements"));
     57  dialog->queryDouble("bin-start", ValueStorage::getInstance().getDescription("bin-start"));
     58  dialog->queryDouble("bin-width", ValueStorage::getInstance().getDescription("bin-width"));
     59  dialog->queryDouble("bin-end", ValueStorage::getInstance().getDescription("bin-end"));
     60  dialog->queryString("output-file", ValueStorage::getInstance().getDescription("output-file"));
     61  dialog->queryString("bin-output-file", ValueStorage::getInstance().getDescription("bin-output-file"));
     62  dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
     63
     64  return dialog;
     65}
     66
    3967Action::state_ptr AnalysisPairCorrelationAction::performCall() {
    40   Dialog *dialog = UIFactory::getInstance().makeDialog();
    4168  int ranges[3] = {1, 1, 1};
    4269  double BinEnd = 0.;
     
    5380  Vector Point;
    5481  BinPairMap *binmap = NULL;
    55   MoleculeListClass *molecules = World::getInstance().getMolecules();
    5682
    57   // first dialog: Obtain which type of correlation
    58   dialog->queryString(NAME, &type, MapOfActions::getInstance().getDescription(NAME));
    59   if(dialog->display()) {
    60     delete dialog;
    61   } else {
    62     delete dialog;
    63     return Action::failure;
    64   }
     83  // obtain information
     84  ValueStorage::getInstance().queryCurrentValue("elements", elements);
     85  ValueStorage::getInstance().queryCurrentValue("bin-start", BinStart);
     86  ValueStorage::getInstance().queryCurrentValue("bin-width", BinWidth);
     87  ValueStorage::getInstance().queryCurrentValue("bin-end", BinEnd);
     88  ValueStorage::getInstance().queryCurrentValue("output-file", outputname);
     89  ValueStorage::getInstance().queryCurrentValue("bin-output-file", binoutputname);
     90  ValueStorage::getInstance().queryCurrentValue("periodic", periodic);
    6591
    66   // second dialog: Obtain parameters specific to this type
    67   dialog = UIFactory::getInstance().makeDialog();
    68   if (type == "P")
    69     dialog->queryVector("position", &Point, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("position"));
    70   if (type == "S")
    71     dialog->queryMolecule("molecule-by-id", &Boundary, MapOfActions::getInstance().getDescription("molecule-by-id"));
    72   dialog->queryElement("elements", &elements, MapOfActions::getInstance().getDescription("elements"));
    73   dialog->queryDouble("bin-start", &BinStart, MapOfActions::getInstance().getDescription("bin-start"));
    74   dialog->queryDouble("bin-width", &BinWidth, MapOfActions::getInstance().getDescription("bin-width"));
    75   dialog->queryDouble("bin-end", &BinEnd, MapOfActions::getInstance().getDescription("bin-end"));
    76   dialog->queryString("output-file", &outputname, MapOfActions::getInstance().getDescription("output-file"));
    77   dialog->queryString("bin-output-file", &binoutputname, MapOfActions::getInstance().getDescription("bin-output-file"));
    78   dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic"));
    79 
    80   if(dialog->display()) {
    81     output.open(outputname.c_str());
    82     binoutput.open(binoutputname.c_str());
    83     PairCorrelationMap *correlationmap = NULL;
    84     if (type == "E") {
    85       PairCorrelationMap *correlationmap = NULL;
    86       if (periodic)
    87         correlationmap = PeriodicPairCorrelation(World::getInstance().getMolecules(), elements, ranges);
    88       else
    89         correlationmap = PairCorrelation(World::getInstance().getMolecules(), elements);
    90       //OutputCorrelationToSurface(&output, correlationmap);
    91       binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
    92     } else if (type == "P")  {
    93       cout << "Point to correlate to is  " << Point << endl;
    94       CorrelationToPointMap *correlationmap = NULL;
    95       if (periodic)
    96         correlationmap  = PeriodicCorrelationToPoint(molecules, elements, &Point, ranges);
    97       else
    98         correlationmap = CorrelationToPoint(molecules, elements, &Point);
    99       //OutputCorrelationToSurface(&output, correlationmap);
    100       binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
    101     } else if (type == "S") {
    102       ASSERT(Boundary != NULL, "No molecule specified for SurfaceCorrelation.");
    103       const double radius = 4.;
    104       double LCWidth = 20.;
    105       if (BinEnd > 0) {
    106         if (BinEnd > 2.*radius)
    107             LCWidth = BinEnd;
    108         else
    109           LCWidth = 2.*radius;
    110       }
    111 
    112       // get the boundary
    113       class Tesselation *TesselStruct = NULL;
    114       const LinkedCell *LCList = NULL;
    115       // find biggest molecule
    116       int counter  = molecules->ListOfMolecules.size();
    117       bool *Actives = new bool[counter];
    118       counter = 0;
    119       for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    120         Actives[counter++] = (*BigFinder)->ActiveFlag;
    121         (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
    122       }
    123       LCList = new LinkedCell(Boundary, LCWidth);
    124       FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
    125       CorrelationToSurfaceMap *surfacemap = NULL;
    126       if (periodic)
    127         surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges);
    128       else
    129         surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList);
    130       OutputCorrelationToSurface(&output, surfacemap);
    131       // check whether radius was appropriate
    132       {
    133         double start; double end;
    134         GetMinMax( surfacemap, start, end);
    135         if (LCWidth < end)
    136           DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl);
    137       }
    138       binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
    139     } else
    140       return Action::failure;
    141     OutputCorrelation ( &binoutput, binmap );
    142     output.close();
    143     binoutput.close();
    144     delete(binmap);
    145     delete(correlationmap);
    146     delete dialog;
    147     return Action::success;
    148   } else {
    149     delete dialog;
    150     return Action::failure;
    151   }
     92  // execute action
     93  output.open(outputname.c_str());
     94  binoutput.open(binoutputname.c_str());
     95  PairCorrelationMap *correlationmap = NULL;
     96  std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
     97  if (periodic)
     98    correlationmap = PeriodicPairCorrelation(molecules, elements, ranges);
     99  else
     100    correlationmap = PairCorrelation(molecules, elements);
     101  OutputPairCorrelation(&output, correlationmap);
     102  binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
     103  OutputCorrelation ( &binoutput, binmap );
     104  delete(binmap);
     105  delete(correlationmap);
     106  output.close();
     107  binoutput.close();
     108  return Action::success;
    152109}
    153110
    154111Action::state_ptr AnalysisPairCorrelationAction::performUndo(Action::state_ptr _state) {
    155 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    156 
    157   return Action::failure;
    158 //  string newName = state->mol->getName();
    159 //  state->mol->setName(state->lastName);
    160 //
    161 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     112  return Action::success;
    162113}
    163114
    164115Action::state_ptr AnalysisPairCorrelationAction::performRedo(Action::state_ptr _state){
    165   return Action::failure;
     116  return Action::success;
    166117}
    167118
    168119bool AnalysisPairCorrelationAction::canUndo() {
    169   return false;
     120  return true;
    170121}
    171122
    172123bool AnalysisPairCorrelationAction::shouldUndo() {
    173   return false;
     124  return true;
    174125}
    175126
  • src/Actions/AnalysisAction/PairCorrelationAction.hpp

    r06f4ef6 rb6da28  
    1010
    1111#include "Actions/Action.hpp"
     12#include <string>
     13#include <vector>
     14
     15class element;
     16
     17void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
    1218
    1319class AnalysisPairCorrelationAction : public Action {
     20  friend void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic);
    1421public:
    1522  AnalysisPairCorrelationAction();
     
    2027
    2128  virtual const std::string getName();
     29protected:
     30  virtual Dialog * fillDialog(Dialog*);
    2231private:
    23   virtual Action::state_ptr performCall();
     32   virtual Action::state_ptr performCall();
    2433  virtual Action::state_ptr performUndo(Action::state_ptr);
    2534  virtual Action::state_ptr performRedo(Action::state_ptr);
  • src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "molecule.hpp"
    1213#include "log.hpp"
     
    2021#include "UIElements/UIFactory.hpp"
    2122#include "UIElements/Dialog.hpp"
    22 #include "Actions/MapOfActions.hpp"
     23#include "UIElements/ValueStorage.hpp"
    2324
    2425const char AnalysisPrincipalAxisSystemAction::NAME[] = "principal-axis-system";
     
    3132{}
    3233
     34void AnalysisPrincipalAxisSystem() {
     35  ActionRegistry::getInstance().getActionByName(AnalysisPrincipalAxisSystemAction::NAME)->call(Action::NonInteractive);
     36};
     37
     38Dialog* AnalysisPrincipalAxisSystemAction::fillDialog(Dialog *dialog) {
     39  ASSERT(dialog,"No Dialog given when filling action dialog");
     40
     41  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
     42
     43  return dialog;
     44}
     45
    3346Action::state_ptr AnalysisPrincipalAxisSystemAction::performCall() {
    34   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3547  molecule *mol = NULL;
    3648
    37   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
    38 
    39   if(dialog->display()) {
    40     DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
     49  ValueStorage::getInstance().queryCurrentValue(NAME, mol);
     50  DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
     51  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     52    molecule *mol = iter->second;
    4153    mol->PrincipalAxisSystem(false);
    42     delete dialog;
    43     return Action::success;
    44   } else {
    45     delete dialog;
    46     return Action::failure;
    4754  }
     55  return Action::success;
    4856}
    4957
    5058Action::state_ptr AnalysisPrincipalAxisSystemAction::performUndo(Action::state_ptr _state) {
    51 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    52 
    53   return Action::failure;
    54 //  string newName = state->mol->getName();
    55 //  state->mol->setName(state->lastName);
    56 //
    57 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     59  return Action::success;
    5860}
    5961
    6062Action::state_ptr AnalysisPrincipalAxisSystemAction::performRedo(Action::state_ptr _state){
    61   return Action::failure;
     63  return Action::success;
    6264}
    6365
    6466bool AnalysisPrincipalAxisSystemAction::canUndo() {
    65   return false;
     67  return true;
    6668}
    6769
    6870bool AnalysisPrincipalAxisSystemAction::shouldUndo() {
    69   return false;
     71  return true;
    7072}
    7173
  • src/Actions/AnalysisAction/PrincipalAxisSystemAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212
     13void AnalysisPrincipalAxisSystem();
     14
    1315class AnalysisPrincipalAxisSystemAction : public Action {
     16  friend void AnalysisPrincipalAxisSystem();
     17
    1418public:
    1519  AnalysisPrincipalAxisSystemAction();
     
    2024
    2125  virtual const std::string getName();
     26protected:
     27  virtual Dialog * fillDialog(Dialog *);
    2228private:
    2329  virtual Action::state_ptr performCall();
  • src/Actions/AtomAction/AddAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/AtomAction/AddAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "element.hpp"
     
    2425#include "UIElements/UIFactory.hpp"
    2526#include "UIElements/Dialog.hpp"
    26 #include "Actions/MapOfActions.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2728
    2829const char AtomAddAction::NAME[] = "add-atom";
     
    3536{}
    3637
     38void AtomAdd(element *elemental, Vector &position) {
     39  ValueStorage::getInstance().setCurrentValue(AtomAddAction::NAME, elemental);
     40  ValueStorage::getInstance().setCurrentValue("position", elemental);
     41  ActionRegistry::getInstance().getActionByName(AtomAddAction::NAME)->call(Action::NonInteractive);
     42};
     43
     44Dialog * AtomAddAction::fillDialog(Dialog *dialog) {
     45  ASSERT(dialog,"No Dialog given when filling action dialog");
     46
     47  dialog->queryElement(NAME, ValueStorage::getInstance().getDescription(NAME));
     48  dialog->queryVector("position", true, ValueStorage::getInstance().getDescription("position"));
     49
     50  return dialog;
     51}
     52
    3753Action::state_ptr AtomAddAction::performCall() {
    38   Dialog *dialog = UIFactory::getInstance().makeDialog();
    39   std::vector<element *> elements;
     54  element * elemental = NULL;
    4055  Vector position;
    4156
    42   dialog->queryElement(NAME, &elements, MapOfActions::getInstance().getDescription(NAME));
    43   dialog->queryVector("position", &position, World::getInstance().getDomain(), true, MapOfActions::getInstance().getDescription("position"));
    44   cout << "pre-dialog" << endl;
     57  // obtain information
     58  ValueStorage::getInstance().queryCurrentValue(NAME, elemental);
     59  ValueStorage::getInstance().queryCurrentValue("position", position);
    4560
    46   if(dialog->display()) {
    47     cout << "post-dialog" << endl;
    48     delete dialog;
    49     if (elements.size() == 1) {
    50       atom * first = World::getInstance().createAtom();
    51       first->type = *(elements.begin());
    52       first->x = position;
    53       DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->type->name << " at " << (first->x) << "." << endl);
    54       // TODO: remove when all of World's atoms are stored.
    55       std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
    56       if (!molecules.empty()) {
    57         std::vector<molecule *>::iterator iter = molecules.begin();
    58         (*iter)->AddAtom(first);
    59       }
    60       return Action::success;
    61     } else {
    62       DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl);
    63       return Action::failure;
    64     }
    65   } else {
    66     delete dialog;
    67     return Action::failure;
     61  // execute action
     62  atom * first = World::getInstance().createAtom();
     63  first->type = elemental;
     64  first->x = position;
     65  DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->type->name << " at " << (first->x) << "." << endl);
     66  // TODO: remove when all of World's atoms are stored.
     67  std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
     68  if (!molecules.empty()) {
     69    std::vector<molecule *>::iterator iter = molecules.begin();
     70    (*iter)->AddAtom(first);
    6871  }
    69 
     72  return Action::success;
    7073}
    7174
  • src/Actions/AtomAction/AddAction.hpp

    r06f4ef6 rb6da28  
    1010
    1111#include "Actions/Action.hpp"
     12#include "vector.hpp"
     13
     14class element;
     15
     16void AtomAdd(element *elemental, Vector &position);
    1217
    1318class AtomAddAction : public Action {
     19  friend void AtomAdd(element *elemental, Vector &position);
     20
    1421public:
    1522  AtomAddAction();
     
    2027
    2128  virtual const std::string getName();
     29protected:
     30  virtual Dialog * fillDialog(Dialog *);
    2231private:
    2332  virtual Action::state_ptr performCall();
  • src/Actions/AtomAction/ChangeElementAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/AtomAction/ChangeElementAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
     13#include "element.hpp"
    1214#include "log.hpp"
    1315#include "vector.hpp"
     
    2224#include "UIElements/UIFactory.hpp"
    2325#include "UIElements/Dialog.hpp"
    24 #include "Actions/MapOfActions.hpp"
     26#include "UIElements/ValueStorage.hpp"
    2527
    2628const char AtomChangeElementAction::NAME[] = "change-element";
     
    3335{}
    3436
     37void AtomChangeElement(element *elemental) {
     38  ValueStorage::getInstance().setCurrentValue(AtomChangeElementAction::NAME, elemental);
     39  ActionRegistry::getInstance().getActionByName(AtomChangeElementAction::NAME)->call(Action::NonInteractive);
     40};
     41
     42Dialog* AtomChangeElementAction::fillDialog(Dialog *dialog) {
     43  ASSERT(dialog,"No Dialog given when filling action dialog");
     44
     45  dialog->queryElement(NAME, ValueStorage::getInstance().getDescription(NAME));
     46
     47return dialog;
     48}
     49
    3550Action::state_ptr AtomChangeElementAction::performCall() {
    36   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3751  atom *first = NULL;
    38   std::vector<element *> elements;
     52  element *elemental = NULL;
    3953
    40   dialog->queryAtom(NAME, &first, MapOfActions::getInstance().getDescription(NAME));
    41   dialog->queryElement("element", &elements, MapOfActions::getInstance().getDescription("element"));
     54  ValueStorage::getInstance().queryCurrentValue(NAME, elemental);
    4255
    43   if(dialog->display()) {
    44     delete dialog;
    45     ASSERT(elements.size() == 1, "Unequal to one element specified when changing an atom's element");
    46     ASSERT(first != NULL, "No valid atom specified");
    47     DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << elements.at(0) << "." << endl);
    48     if (elements.at(0) != NULL) {
    49       first->type = elements.at(0);
    50       return Action::success;
    51     } else
    52       return Action::failure;
    53   } else {
    54     delete dialog;
    55     return Action::failure;
     56  for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection(); iter != World::getInstance().endAtomSelection(); ++iter) {
     57    first = iter->second;
     58    DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << elemental->symbol << "." << endl);
     59    first->type = elemental;
    5660  }
    57 
     61  return Action::success;
    5862}
    5963
  • src/Actions/AtomAction/ChangeElementAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212
     13class element;
     14
     15void AtomChangeElement(element *elemental);
     16
    1317class AtomChangeElementAction : public Action {
     18  friend void AtomChangeElement(element *elemental);
     19
    1420public:
    1521  AtomChangeElementAction();
     
    2026
    2127  virtual const std::string getName();
     28protected:
     29  virtual Dialog * fillDialog(Dialog*);
    2230private:
    2331  virtual Action::state_ptr performCall();
  • src/Actions/AtomAction/RemoveAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/AtomAction/RemoveAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "Descriptors/AtomDescriptor.hpp"
     
    2324#include "UIElements/UIFactory.hpp"
    2425#include "UIElements/Dialog.hpp"
    25 #include "Actions/MapOfActions.hpp"
     26#include "UIElements/ValueStorage.hpp"
    2627
    2728const char AtomRemoveAction::NAME[] = "remove-atom";
     
    3435{}
    3536
     37void AtomRemove() {
     38  ActionRegistry::getInstance().getActionByName(AtomRemoveAction::NAME)->call(Action::NonInteractive);
     39};
     40
     41Dialog* AtomRemoveAction::fillDialog(Dialog *dialog) {
     42  ASSERT(dialog,"No Dialog given when filling action dialog");
     43
     44  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
     45
     46  return dialog;
     47}
     48
    3649Action::state_ptr AtomRemoveAction::performCall() {
    37   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3850  atom *first = NULL;
    3951
    40   dialog->queryAtom(NAME, &first, MapOfActions::getInstance().getDescription(NAME));
    41 
    42   if(dialog->display()) {
    43     delete dialog;
     52  std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
     53  for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection(); iter != World::getInstance().endAtomSelection(); ++iter) {
     54    first = iter->second;
    4455    DoLog(1) && (Log() << Verbose(1) << "Removing atom " << first->getId() << "." << endl);
    4556    // TODO: this is not necessary when atoms and their storing to file are handled by the World
    4657    // simply try to erase in every molecule found
    47     std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
    4858    for (std::vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end(); ++iter) {
    4959      (*iter)->erase(first);
    5060    }
    5161    World::getInstance().destroyAtom(first);
    52     return Action::success;
    53   } else {
    54     delete dialog;
    55     return Action::failure;
    5662  }
    57 
     63  return Action::success;
    5864}
    5965
  • src/Actions/AtomAction/RemoveAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212
     13void AtomRemove();
     14
    1315class AtomRemoveAction : public Action {
     16  friend void AtomRemove();
     17
    1418public:
    1519  AtomRemoveAction();
     
    2024
    2125  virtual const std::string getName();
     26protected:
     27  virtual Dialog * fillDialog(Dialog*);
    2228private:
    2329  virtual Action::state_ptr performCall();
  • src/Actions/AtomsCalculation.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Calculation.hpp"
    1212
     13class Dialog;
     14
    1315template<typename T>
    1416class AtomsCalculation : public Calculation<std::vector<T> >
     
    2022protected:
    2123  virtual std::vector<T>* doCalc();
     24  virtual Dialog *fillDialog(Dialog *dialog);
    2225
    2326private:
  • src/Actions/AtomsCalculation_impl.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/AtomsCalculation.hpp"
    1212#include "Actions/Calculation_impl.hpp"
    13 
    14 #include <iostream>
    1513
    1614using namespace std;
     
    3533  Process::setMaxSteps(steps);
    3634  Process::start();
    37   for(World::AtomIterator iter=world->getAtomIter(descr);iter!=world->atomEnd();++iter){
     35  for(World::internal_AtomIterator
     36      iter=world->getAtomIter_internal(descr);
     37      iter!=world->atomEnd_internal();
     38      ++iter){
     39
    3840    Process::setCurrStep(iter.getCount());
    3941    res->push_back(op(*iter));
     
    4345}
    4446
     47template<typename T>
     48Dialog *AtomsCalculation<T>::fillDialog(Dialog *dialog){
     49  ASSERT(dialog,"No Dialog given when filling action dialog");
     50  return dialog;
     51}
    4552
    4653#endif /* ATOMSCALCULATION_IMPL_HPP_ */
  • src/Actions/CmdAction/BondLengthTableAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/CmdAction/BondLengthTableAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "bondgraph.hpp"
    1113#include "config.hpp"
    1214#include "log.hpp"
     
    2123#include "UIElements/UIFactory.hpp"
    2224#include "UIElements/Dialog.hpp"
    23 #include "Actions/MapOfActions.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2426
    2527const char CommandLineBondLengthTableAction::NAME[] = "bond-table";
     
    3234{}
    3335
     36void CommandBondLengthTable(std::string &BondGraphFileName) {
     37  ValueStorage::getInstance().setCurrentValue(CommandLineBondLengthTableAction::NAME, BondGraphFileName);
     38  ActionRegistry::getInstance().getActionByName(CommandLineBondLengthTableAction::NAME)->call(Action::NonInteractive);
     39};
     40
     41Dialog* CommandLineBondLengthTableAction::fillDialog(Dialog *dialog) {
     42  ASSERT(dialog,"No Dialog given when filling action dialog");
     43
     44  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     45
     46  return dialog;
     47}
     48
    3449Action::state_ptr CommandLineBondLengthTableAction::performCall() {
    3550  ostringstream usage;
    3651  string BondGraphFileName;
    37   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3852
     53  ValueStorage::getInstance().queryCurrentValue(NAME, BondGraphFileName);
     54  DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);
    3955  config *configuration = World::getInstance().getConfig();
    40   dialog->queryString(NAME, &BondGraphFileName, MapOfActions::getInstance().getDescription(NAME));
    41 
    42   if(dialog->display()) {
    43     DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);
    44     delete dialog;
    45   } else {
    46     delete dialog;
    47     return Action::failure;
    48   }
    49 
    5056  if (configuration->BG == NULL) {
    5157    configuration->BG = new BondGraph(configuration->GetIsAngstroem());
  • src/Actions/CmdAction/BondLengthTableAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212
     13void CommandBondLengthTable(std::string &BondGraphFileName);
     14
    1315class CommandLineBondLengthTableAction : public Action {
     16  friend void CommandBondLengthTable(std::string &BondGraphFileName);
     17
    1418public:
    1519  CommandLineBondLengthTableAction();
     
    2024
    2125  virtual const std::string getName();
     26protected:
     27  virtual Dialog * fillDialog(Dialog *dialog);
    2228private:
    2329  virtual Action::state_ptr performCall();
  • src/Actions/CmdAction/ElementDbAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/CmdAction/ElementDbAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "config.hpp"
    1213#include "log.hpp"
     
    2223#include "UIElements/UIFactory.hpp"
    2324#include "UIElements/Dialog.hpp"
    24 #include "Actions/MapOfActions.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2526
    2627const char CommandLineElementDbAction::NAME[] = "element-db";
     
    3334{}
    3435
     36void CommandElementDb(std::string &databasepath) {
     37  ValueStorage::getInstance().setCurrentValue(CommandLineElementDbAction::NAME, databasepath);
     38  ActionRegistry::getInstance().getActionByName(CommandLineElementDbAction::NAME)->call(Action::NonInteractive);
     39};
     40
     41Dialog* CommandLineElementDbAction::fillDialog(Dialog *dialog) {
     42  ASSERT(dialog,"No Dialog given when filling action dialog");
     43
     44  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     45
     46  return dialog;
     47}
     48
    3549Action::state_ptr CommandLineElementDbAction::performCall() {
    3650  ostringstream usage;
    3751  string databasepath;
    38   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3952
    4053  // get the path
    4154  // TODO: Make databasepath a std::string
    4255  config *configuration = World::getInstance().getConfig();
    43   dialog->queryString(NAME, &databasepath, MapOfActions::getInstance().getDescription(NAME));
    44 
    45   if(dialog->display()) {
    46     strcpy(configuration->databasepath, databasepath.c_str());
    47     delete dialog;
    48   } else {
    49     delete dialog;
    50     return Action::failure;
    51   }
     56  ValueStorage::getInstance().queryCurrentValue(NAME, databasepath);
     57  strcpy(configuration->databasepath, databasepath.c_str());
    5258
    5359  // load table
  • src/Actions/CmdAction/ElementDbAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212
     13void CommandElementDb(std::string &databasepath);
     14
    1315class CommandLineElementDbAction : public Action {
     16  friend void CommandElementDb(std::string &databasepath);
     17
    1418public:
    1519  CommandLineElementDbAction();
     
    2024
    2125  virtual const std::string getName();
     26protected:
     27  virtual Dialog * fillDialog(Dialog *dialog);
    2228private:
    2329  virtual Action::state_ptr performCall();
  • src/Actions/CmdAction/FastParsingAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/CmdAction/FastParsingAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "config.hpp"
    1213#include "log.hpp"
     
    2122#include "UIElements/UIFactory.hpp"
    2223#include "UIElements/Dialog.hpp"
    23 #include "Actions/MapOfActions.hpp"
     24#include "UIElements/ValueStorage.hpp"
     25
     26// memento to remember the state when undoing
     27
     28class CommandLineFastParsingState : public ActionState {
     29public:
     30  CommandLineFastParsingState(bool _bool) :
     31    boolean(_bool)
     32  {}
     33  bool boolean;
     34};
     35
    2436
    2537const char CommandLineFastParsingAction::NAME[] = "fastparsing";
     
    3244{}
    3345
     46void CommandFastParsing(bool fastparsing) {
     47  ValueStorage::getInstance().setCurrentValue(CommandLineFastParsingAction::NAME, fastparsing);
     48  ActionRegistry::getInstance().getActionByName(CommandLineFastParsingAction::NAME)->call(Action::NonInteractive);
     49};
     50
     51Dialog* CommandLineFastParsingAction::fillDialog(Dialog *dialog) {
     52  ASSERT(dialog,"No Dialog given when filling action dialog");
     53
     54  dialog->queryBoolean(NAME, MapOfActions::getInstance().getDescription(NAME));
     55
     56  return dialog;
     57}
     58
    3459Action::state_ptr CommandLineFastParsingAction::performCall() {
    35   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3660
    3761  config *configuration = World::getInstance().getConfig();
    38   dialog->queryBoolean(NAME, &configuration->FastParsing, MapOfActions::getInstance().getDescription(NAME));
    39 
    40   if(dialog->display()) {
    41     if (configuration->FastParsing)
    42       DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
    43     else
    44       DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl);
    45     delete dialog;
    46     return Action::success;
    47   } else {
    48     delete dialog;
    49     return Action::failure;
    50   }
     62  ValueStorage::getInstance().queryCurrentValue(NAME, configuration->FastParsing);
     63  if (configuration->FastParsing)
     64    DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
     65  else
     66    DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl);
     67  return Action::success;
    5168}
    5269
    5370Action::state_ptr CommandLineFastParsingAction::performUndo(Action::state_ptr _state) {
    54 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
     71  CommandLineFastParsingState *state = assert_cast<CommandLineFastParsingState*>(_state.get());
    5572
    56   return Action::failure;
    57 //  string newName = state->mol->getName();
    58 //  state->mol->setName(state->lastName);
    59 //
    60 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     73  config *configuration = World::getInstance().getConfig();
     74  configuration->FastParsing = state->boolean;
     75
     76  return Action::state_ptr(new CommandLineFastParsingState(!state->boolean));
    6177}
    6278
    6379Action::state_ptr CommandLineFastParsingAction::performRedo(Action::state_ptr _state){
    64   return Action::failure;
     80  return performUndo(_state);
    6581}
    6682
    6783bool CommandLineFastParsingAction::canUndo() {
    68   return false;
     84  return true;
    6985}
    7086
    7187bool CommandLineFastParsingAction::shouldUndo() {
    72   return false;
     88  return true;
    7389}
    7490
  • src/Actions/CmdAction/FastParsingAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212
     13void CommandFastParsing(bool fastparsing);
     14
    1315class CommandLineFastParsingAction : public Action {
     16  friend void CommandFastParsing(bool fastparsing);
     17
    1418public:
    1519  CommandLineFastParsingAction();
     
    2024
    2125  virtual const std::string getName();
     26protected:
     27  virtual Dialog * fillDialog(Dialog *dialog);
    2228private:
    2329  virtual Action::state_ptr performCall();
  • src/Actions/CmdAction/HelpAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/CmdAction/HelpAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "CommandLineParser.hpp"
    1213
     
    2930{}
    3031
    31 Action::state_ptr CommandLineHelpAction::performCall() {
     32void CommandHelp() {
     33  ActionRegistry::getInstance().getActionByName(CommandLineHelpAction::NAME)->call(Action::NonInteractive);
     34};
     35
     36Dialog* CommandLineHelpAction::fillDialog(Dialog *dialog) {
     37  ASSERT(dialog,"No Dialog given when filling action dialog");
     38
    3239  ostringstream usage;
    33   Dialog *dialog = UIFactory::getInstance().makeDialog();
    34 
    3540  usage << CommandLineParser::getInstance().visible << endl;
    3641  dialog->queryEmpty(NAME, usage.str());
    3742
    38   if(dialog->display()) {
    39     delete dialog;
    40     return Action::success;
    41   } else {
    42     delete dialog;
    43     return Action::failure;
    44   }
     43  return dialog;
     44}
     45
     46Action::state_ptr CommandLineHelpAction::performCall() {
     47  return Action::success;
    4548}
    4649
    4750Action::state_ptr CommandLineHelpAction::performUndo(Action::state_ptr _state) {
    48 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    49 
    50   return Action::failure;
    51 //  string newName = state->mol->getName();
    52 //  state->mol->setName(state->lastName);
    53 //
    54 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     51  return Action::success;
    5552}
    5653
    5754Action::state_ptr CommandLineHelpAction::performRedo(Action::state_ptr _state){
    58   return Action::failure;
     55  return Action::success;
    5956}
    6057
    6158bool CommandLineHelpAction::canUndo() {
    62   return false;
     59  return true;
    6360}
    6461
    6562bool CommandLineHelpAction::shouldUndo() {
    66   return false;
     63  return true;
    6764}
    6865
  • src/Actions/CmdAction/HelpAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212
     13void CommandHelp();
     14
    1315class CommandLineHelpAction : public Action {
     16  friend void CommandHelp();
     17
    1418public:
    1519  CommandLineHelpAction();
     
    2024
    2125  virtual const std::string getName();
     26protected:
     27  virtual Dialog * fillDialog(Dialog *dialog);
    2228private:
    2329  virtual Action::state_ptr performCall();
  • src/Actions/CmdAction/VerboseAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/CmdAction/VerboseAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "log.hpp"
    1213#include "verbose.hpp"
     
    1920#include "UIElements/UIFactory.hpp"
    2021#include "UIElements/Dialog.hpp"
    21 #include "Actions/MapOfActions.hpp"
     22#include "UIElements/ValueStorage.hpp"
     23
     24// memento to remember the state when undoing
     25
     26class CommandLineVerboseState : public ActionState {
     27public:
     28  CommandLineVerboseState(int _verbosity) :
     29    verbosity(_verbosity)
     30  {}
     31  int verbosity;
     32};
     33
    2234
    2335const char CommandLineVerboseAction::NAME[] = "verbose";
     
    3042{}
    3143
     44void CommandVerbose(int verbosity) {
     45  ValueStorage::getInstance().setCurrentValue(CommandLineVerboseAction::NAME, verbosity);
     46  ActionRegistry::getInstance().getActionByName(CommandLineVerboseAction::NAME)->call(Action::NonInteractive);
     47};
     48
     49Dialog* CommandLineVerboseAction::fillDialog(Dialog *dialog) {
     50  ASSERT(dialog,"No Dialog given when filling action dialog");
     51
     52  dialog->queryInt(NAME, ValueStorage::getInstance().getDescription(NAME));
     53
     54  return dialog;
     55}
     56
    3257Action::state_ptr CommandLineVerboseAction::performCall() {
    33   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3458  int verbosity = 2;
    3559
    36   dialog->queryInt(NAME, &verbosity, MapOfActions::getInstance().getDescription(NAME));
     60  ValueStorage::getInstance().queryCurrentValue(NAME, verbosity);
    3761
    38   if(dialog->display()) {
    39     setVerbosity(verbosity);
    40     DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl);
    41     delete dialog;
    42     return Action::success;
    43   } else {
    44     delete dialog;
    45     return Action::failure;
    46   }
     62  setVerbosity(verbosity);
     63  DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl);
     64  return Action::success;
    4765}
    4866
    4967Action::state_ptr CommandLineVerboseAction::performUndo(Action::state_ptr _state) {
    50 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
     68  CommandLineVerboseState *state = assert_cast<CommandLineVerboseState*>(_state.get());
    5169
    52   return Action::failure;
    53 //  string newName = state->mol->getName();
    54 //  state->mol->setName(state->lastName);
    55 //
    56 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     70  int verbosity = 2;
     71  ValueStorage::getInstance().queryCurrentValue(NAME, verbosity);
     72
     73  setVerbosity(state->verbosity);
     74  return Action::state_ptr(new CommandLineVerboseState(verbosity));
    5775}
    5876
    5977Action::state_ptr CommandLineVerboseAction::performRedo(Action::state_ptr _state){
    60   return Action::failure;
     78  return performUndo(_state);
    6179}
    6280
    6381bool CommandLineVerboseAction::canUndo() {
    64   return false;
     82  return true;
    6583}
    6684
    6785bool CommandLineVerboseAction::shouldUndo() {
    68   return false;
     86  return true;
    6987}
    7088
  • src/Actions/CmdAction/VerboseAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212
     13void CommandVerbose(int verbosity);
     14
    1315class CommandLineVerboseAction : public Action {
     16  friend void CommandVerbose(int verbosity);
     17
    1418public:
    1519  CommandLineVerboseAction();
     
    2024
    2125  virtual const std::string getName();
     26protected:
     27  virtual Dialog * fillDialog(Dialog *dialog);
    2228private:
    2329  virtual Action::state_ptr performCall();
  • src/Actions/CmdAction/VersionAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/CmdAction/VersionAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112
    1213#include <iostream>
     
    1718#include "UIElements/UIFactory.hpp"
    1819#include "UIElements/Dialog.hpp"
    19 #include "Actions/MapOfActions.hpp"
     20#include "UIElements/ValueStorage.hpp"
    2021
    2122const char CommandLineVersionAction::NAME[] = "version";
     
    2829{}
    2930
    30 Action::state_ptr CommandLineVersionAction::performCall() {
    31   Dialog *dialog = UIFactory::getInstance().makeDialog();
     31void CommandVersion() {
     32  ActionRegistry::getInstance().getActionByName(CommandLineVersionAction::NAME)->call(Action::NonInteractive);
     33};
     34
     35Dialog* CommandLineVersionAction::fillDialog(Dialog *dialog) {
     36  ASSERT(dialog,"No Dialog given when filling action dialog");
    3237
    3338  dialog->queryEmpty(NAME, ESPACKVersion);
    3439
    35   if(dialog->display()) {
    36     delete dialog;
    37     return Action::success;
    38   } else {
    39     delete dialog;
    40     return Action::failure;
    41   }
     40  return dialog;
     41}
     42
     43Action::state_ptr CommandLineVersionAction::performCall() {
     44  return Action::success;
    4245}
    4346
    4447Action::state_ptr CommandLineVersionAction::performUndo(Action::state_ptr _state) {
    45 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    46 
    47   return Action::failure;
    48 //  string newName = state->mol->getName();
    49 //  state->mol->setName(state->lastName);
    50 //
    51 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     48  return Action::success;
    5249}
    5350
    5451Action::state_ptr CommandLineVersionAction::performRedo(Action::state_ptr _state){
    55   return Action::failure;
     52  return Action::success;
    5653}
    5754
    5855bool CommandLineVersionAction::canUndo() {
    59   return false;
     56  return true;
    6057}
    6158
    6259bool CommandLineVersionAction::shouldUndo() {
    63   return false;
     60  return true;
    6461}
    6562
  • src/Actions/CmdAction/VersionAction.hpp

    r06f4ef6 rb6da28  
    1212#include "version.h"
    1313
     14void CommandVersion();
     15
    1416class CommandLineVersionAction : public Action {
     17  friend void CommandVersion();
     18
    1519public:
    1620  CommandLineVersionAction();
     
    2125
    2226  virtual const std::string getName();
     27protected:
     28  virtual Dialog * fillDialog(Dialog *dialog);
    2329private:
    2430  virtual Action::state_ptr performCall();
  • src/Actions/ErrorAction.cpp

    r06f4ef6 rb6da28  
    2727}
    2828
     29Dialog* ErrorAction::createDialog() {
     30  return NULL;
     31}
     32
    2933Action::state_ptr ErrorAction::performCall() {
    3034  Log() << Verbose(0) << errorMsg << endl;
  • src/Actions/ErrorAction.hpp

    r06f4ef6 rb6da28  
    2222
    2323private:
    24 
     24  virtual Dialog * createDialog();
    2525  virtual Action::state_ptr performCall();
    2626  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/FragmentationAction/DepthFirstSearchAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
     13#include "bondgraph.hpp"
    1214#include "config.hpp"
    1315#include "log.hpp"
     
    2628#include "UIElements/UIFactory.hpp"
    2729#include "UIElements/Dialog.hpp"
    28 #include "Actions/MapOfActions.hpp"
     30#include "UIElements/ValueStorage.hpp"
    2931
    3032const char FragmentationDepthFirstSearchAction::NAME[] = "depth-first-search";
     
    3739{}
    3840
     41void FragmentationDepthFirstSearch(double distance) {
     42  ValueStorage::getInstance().setCurrentValue(FragmentationDepthFirstSearchAction::NAME, distance);
     43  ActionRegistry::getInstance().getActionByName(FragmentationDepthFirstSearchAction::NAME)->call(Action::NonInteractive);
     44};
     45
     46Dialog* FragmentationDepthFirstSearchAction::fillDialog(Dialog *dialog) {
     47  ASSERT(dialog,"No Dialog given when filling action dialog");
     48
     49  dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
     50
     51  return dialog;
     52}
     53
    3954Action::state_ptr FragmentationDepthFirstSearchAction::performCall() {
    40   Dialog *dialog = UIFactory::getInstance().makeDialog();
    4155  double distance;
    4256
    43   dialog->queryDouble(NAME, &distance, MapOfActions::getInstance().getDescription(NAME));
     57  ValueStorage::getInstance().queryCurrentValue(NAME, distance);
    4458
    45   if(dialog->display()) {
    46     DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
    47     molecule * const mol = World::getInstance().getMolecule(MoleculeById(0));
    48     MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
    49     int *MinimumRingSize = new int[mol->getAtomCount()];
    50     atom ***ListOfLocalAtoms = NULL;
    51     class StackClass<bond *> *BackEdgeStack = NULL;
    52     class StackClass<bond *> *LocalBackEdgeStack = NULL;
    53     mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    54     Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
    55     if (Subgraphs != NULL) {
    56       int FragmentCounter = 0;
    57       while (Subgraphs->next != NULL) {
    58         Subgraphs = Subgraphs->next;
    59         Subgraphs->FillBondStructureFromReference(mol, FragmentCounter, ListOfLocalAtoms, false);  // we want to keep the created ListOfLocalAtoms
    60         LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
    61         Subgraphs->Leaf->PickLocalBackEdges(ListOfLocalAtoms[FragmentCounter], BackEdgeStack, LocalBackEdgeStack);
    62         Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
    63         delete(LocalBackEdgeStack);
    64         delete(Subgraphs->previous);
    65         FragmentCounter++;
    66       }
    67       delete(Subgraphs);
    68       for (int i=0;i<FragmentCounter;i++)
    69         delete[](ListOfLocalAtoms[i]);
    70       delete[](ListOfLocalAtoms);
     59  DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
     60  molecule * const mol = World::getInstance().getMolecule(MoleculeById(0));
     61  MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
     62  int *MinimumRingSize = new int[mol->getAtomCount()];
     63  atom **ListOfAtoms = NULL;
     64  class StackClass<bond *> *BackEdgeStack = NULL;
     65  class StackClass<bond *> *LocalBackEdgeStack = NULL;
     66  mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
     67  Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
     68  if (Subgraphs != NULL) {
     69    int FragmentCounter = 0;
     70    while (Subgraphs->next != NULL) {
     71      Subgraphs = Subgraphs->next;
     72      ListOfAtoms = NULL;
     73      Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false);  // we want to keep the created ListOfLocalAtoms
     74      LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
     75      Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack);
     76      Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
     77      delete(LocalBackEdgeStack);
     78      delete(Subgraphs->previous);
     79      delete[](ListOfAtoms);  // and here we remove it
     80      FragmentCounter++;
    7181    }
    72     delete(BackEdgeStack);
    73     delete[](MinimumRingSize);
    74     delete dialog;
    75     return Action::success;
    76   } else {
    77     delete dialog;
    78     return Action::failure;
     82    delete(Subgraphs);
    7983  }
     84  delete(BackEdgeStack);
     85  delete[](MinimumRingSize);
     86  return Action::success;
    8087}
    8188
    8289Action::state_ptr FragmentationDepthFirstSearchAction::performUndo(Action::state_ptr _state) {
    83 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    84 
    85   return Action::failure;
    86 //  string newName = state->mol->getName();
    87 //  state->mol->setName(state->lastName);
    88 //
    89 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     90  return Action::success;
    9091}
    9192
    9293Action::state_ptr FragmentationDepthFirstSearchAction::performRedo(Action::state_ptr _state){
    93   return Action::failure;
     94  return Action::success;
    9495}
    9596
    9697bool FragmentationDepthFirstSearchAction::canUndo() {
    97   return false;
     98  return true;
    9899}
    99100
    100101bool FragmentationDepthFirstSearchAction::shouldUndo() {
    101   return false;
     102  return true;
    102103}
    103104
  • src/Actions/FragmentationAction/DepthFirstSearchAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212
     13void FragmentationDepthFirstSearch(double distance);
     14
    1315class FragmentationDepthFirstSearchAction : public Action {
     16  friend void FragmentationDepthFirstSearch(double distance);
     17
    1418public:
    1519  FragmentationDepthFirstSearchAction();
     
    2024
    2125  virtual const std::string getName();
     26protected:
     27  virtual Dialog * fillDialog(Dialog *dialog);
    2228private:
    2329  virtual Action::state_ptr performCall();
  • src/Actions/FragmentationAction/FragmentationAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/FragmentationAction/FragmentationAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
     13#include "bondgraph.hpp"
    1214#include "config.hpp"
    1315#include "log.hpp"
     
    2426#include "UIElements/UIFactory.hpp"
    2527#include "UIElements/Dialog.hpp"
    26 #include "Actions/MapOfActions.hpp"
     28#include "UIElements/ValueStorage.hpp"
    2729
    2830const char FragmentationFragmentationAction::NAME[] = "fragment-mol";
     
    3537{}
    3638
     39void FragmentationFragmentation(std::string &path, double distance, int order) {
     40  ValueStorage::getInstance().setCurrentValue(FragmentationFragmentationAction::NAME, path);
     41  ValueStorage::getInstance().setCurrentValue("distance", distance);
     42  ValueStorage::getInstance().setCurrentValue("order", order);
     43  ActionRegistry::getInstance().getActionByName(FragmentationFragmentationAction::NAME)->call(Action::NonInteractive);
     44};
     45
     46Dialog* FragmentationFragmentationAction::fillDialog(Dialog *dialog) {
     47  ASSERT(dialog,"No Dialog given when filling action dialog");
     48
     49  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     50  dialog->queryDouble("distance", ValueStorage::getInstance().getDescription("distance"));
     51  dialog->queryInt("order", ValueStorage::getInstance().getDescription("order"));
     52
     53  return dialog;
     54}
     55
    3756Action::state_ptr FragmentationFragmentationAction::performCall() {
    38   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3957  clock_t start,end;
    4058  molecule *mol = NULL;
    4159  double distance = -1.;
    4260  int order = 0;
     61  std::string path;
    4362  config *configuration = World::getInstance().getConfig();
    4463  int ExitFlag = 0;
    4564
    46   cout << "pre-dialog"<< endl;
    47   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
    48   dialog->queryDouble("distance", &distance, MapOfActions::getInstance().getDescription("distance"));
    49   dialog->queryInt("order", &order, MapOfActions::getInstance().getDescription("order"));
     65  ValueStorage::getInstance().queryCurrentValue(NAME, path);
     66  ValueStorage::getInstance().queryCurrentValue("distance", distance);
     67  ValueStorage::getInstance().queryCurrentValue("order", order);
    5068
    51   if(dialog->display()) {
    52     cout << "POST-dialog"<< endl;
     69  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     70    mol = iter->second;
    5371    ASSERT(mol != NULL, "No molecule has been picked for fragmentation.");
    5472    DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with bond distance " << distance << " angstroem, order of " << order << "." << endl);
     
    5876    DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
    5977    if (mol->hasBondStructure()) {
    60       ExitFlag = mol->FragmentMolecule(order, configuration);
     78      ExitFlag = mol->FragmentMolecule(order, path);
    6179    }
    6280    World::getInstance().setExitFlag(ExitFlag);
    6381    end = clock();
    6482    DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    65     delete dialog;
    66     return Action::success;
    67   } else {
    68     delete dialog;
    69     return Action::failure;
    7083  }
     84  return Action::success;
    7185}
    7286
    7387Action::state_ptr FragmentationFragmentationAction::performUndo(Action::state_ptr _state) {
    74 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    75 
    76   return Action::failure;
    77 //  string newName = state->mol->getName();
    78 //  state->mol->setName(state->lastName);
    79 //
    80 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     88  return Action::success;
    8189}
    8290
    8391Action::state_ptr FragmentationFragmentationAction::performRedo(Action::state_ptr _state){
    84   return Action::failure;
     92  return Action::success;
    8593}
    8694
    8795bool FragmentationFragmentationAction::canUndo() {
    88   return false;
     96  return true;
    8997}
    9098
    9199bool FragmentationFragmentationAction::shouldUndo() {
    92   return false;
     100  return true;
    93101}
    94102
  • src/Actions/FragmentationAction/FragmentationAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212
     13void FragmentationFragmentation(std::string &path, double distance, int order);
     14
    1315class FragmentationFragmentationAction : public Action {
     16  friend void FragmentationFragmentation(std::string &path, double distance, int order);
     17
    1418public:
    1519  FragmentationFragmentationAction();
     
    2024
    2125  virtual const std::string getName();
     26protected:
     27  virtual Dialog * fillDialog(Dialog *dialog);
    2228private:
    2329  virtual Action::state_ptr performCall();
  • src/Actions/FragmentationAction/SubgraphDissectionAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "config.hpp"
     
    2425#include "UIElements/UIFactory.hpp"
    2526#include "UIElements/Dialog.hpp"
    26 #include "Actions/MapOfActions.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2728
    2829const char FragmentationSubgraphDissectionAction::NAME[] = "subgraph-dissect";
     
    3536{}
    3637
    37 Action::state_ptr FragmentationSubgraphDissectionAction::performCall() {
    38   Dialog *dialog = UIFactory::getInstance().makeDialog();
     38void FragmentationSubgraphDissection() {
     39  ActionRegistry::getInstance().getActionByName(FragmentationSubgraphDissectionAction::NAME)->call(Action::NonInteractive);
     40};
     41
     42Dialog* FragmentationSubgraphDissectionAction::fillDialog(Dialog *dialog) {
     43  ASSERT(dialog,"No Dialog given when filling action dialog");
    3944
    4045  dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
    4146
    42   if(dialog->display()) {
    43     DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
    44     // @TODO rather do the dissection afterwards
    45     MoleculeListClass *molecules = World::getInstance().getMolecules();
    46     molecules->DissectMoleculeIntoConnectedSubgraphs(World::getInstance().getPeriode(), World::getInstance().getConfig());
    47     delete dialog;
    48     return Action::success;
    49   } else {
    50     delete dialog;
    51     return Action::failure;
    52   }
     47  return dialog;
     48}
     49
     50
     51Action::state_ptr FragmentationSubgraphDissectionAction::performCall() {
     52  DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
     53  // @TODO rather do the dissection afterwards
     54  MoleculeListClass *molecules = World::getInstance().getMolecules();
     55  molecules->DissectMoleculeIntoConnectedSubgraphs(World::getInstance().getPeriode(), World::getInstance().getConfig());
     56  return Action::success;
    5357}
    5458
  • src/Actions/FragmentationAction/SubgraphDissectionAction.hpp

    r06f4ef6 rb6da28  
    77
    88#ifndef SUBGRAPHDISSECTIONACTION_HPP_
    9 #define SUBGRAPHDISSECTIONACTION_HPP_f
     9#define SUBGRAPHDISSECTIONACTION_HPP_
    1010
    1111#include "Actions/Action.hpp"
    1212
     13void FragmentationSubgraphDissection();
     14
    1315class FragmentationSubgraphDissectionAction : public Action {
     16  friend void FragmentationSubgraphDissection();
     17
    1418public:
    1519  FragmentationSubgraphDissectionAction();
     
    2024
    2125  virtual const std::string getName();
     26protected:
     27  virtual Dialog * fillDialog(Dialog *dialog);
    2228private:
    2329  virtual Action::state_ptr performCall();
  • src/Actions/Makefile.am

    r06f4ef6 rb6da28  
    1717  ${MOLECULEACTIONSOURCE} \
    1818  ${PARSERACTIONSOURCE} \
     19  ${SELECTIONACTIONSOURCE} \
    1920  ${TESSELATIONACTIONSOURCE} \
    2021  ${WORLDACTIONSOURCE} \
     
    2829  ${MOLECULEACTIONHEADER} \
    2930  ${PARSERACTIONHEADER} \
     31  ${SELECTIONACTIONHEADER} \
    3032  ${TESSELATIONACTIONHEADER} \
    3133  ${WORLDACTIONHEADER} \
     
    3638  AnalysisAction/MolecularVolumeAction.cpp \
    3739  AnalysisAction/PairCorrelationAction.cpp \
    38   AnalysisAction/PrincipalAxisSystemAction.cpp
     40  AnalysisAction/PointCorrelationAction.cpp \
     41  AnalysisAction/PrincipalAxisSystemAction.cpp \
     42  AnalysisAction/SurfaceCorrelationAction.cpp
    3943ANALYSISACTIONHEADER = \
    4044  AnalysisAction/MolecularVolumeAction.hpp \
    4145  AnalysisAction/PairCorrelationAction.hpp \
    42   AnalysisAction/PrincipalAxisSystemAction.hpp
     46  AnalysisAction/PointCorrelationAction.hpp \
     47  AnalysisAction/PrincipalAxisSystemAction.hpp \
     48  AnalysisAction/SurfaceCorrelationAction.hpp
    4349
    4450ATOMACTIONSOURCE = \
     
    107113  ParserAction/SaveXyzAction.hpp
    108114
     115SELECTIONACTIONSOURCE = \
     116        SelectionAction/AllAtomsAction.cpp \
     117        SelectionAction/AllMoleculesAction.cpp \
     118        SelectionAction/AtomByIdAction.cpp \
     119        SelectionAction/MoleculeByIdAction.cpp \
     120        SelectionAction/NotAllAtomsAction.cpp \
     121        SelectionAction/NotAllMoleculesAction.cpp \
     122        SelectionAction/NotAtomByIdAction.cpp \
     123        SelectionAction/NotMoleculeByIdAction.cpp
     124SELECTIONACTIONHEADER = \
     125        SelectionAction/AllAtomsAction.hpp \
     126        SelectionAction/AllMoleculesAction.hpp \
     127        SelectionAction/AtomByIdAction.hpp \
     128        SelectionAction/MoleculeByIdAction.hpp \
     129        SelectionAction/NotAllAtomsAction.hpp \
     130        SelectionAction/NotAllMoleculesAction.hpp \
     131        SelectionAction/NotAtomByIdAction.hpp \
     132        SelectionAction/NotMoleculeByIdAction.hpp
     133
    109134TESSELATIONACTIONSOURCE = \
    110135  TesselationAction/ConvexEnvelopeAction.cpp \
     
    120145  WorldAction/CenterOnEdgeAction.cpp \
    121146  WorldAction/ChangeBoxAction.cpp \
     147  WorldAction/InputAction.cpp \
     148  WorldAction/OutputAction.cpp \
    122149  WorldAction/RemoveSphereOfAtomsAction.cpp \
    123150  WorldAction/RepeatBoxAction.cpp \
    124151  WorldAction/ScaleBoxAction.cpp \
    125152  WorldAction/SetDefaultNameAction.cpp \
    126   WorldAction/SetGaussianBasisAction.cpp               
     153  WorldAction/SetGaussianBasisAction.cpp \
     154  WorldAction/SetOutputFormatsAction.cpp
    127155WORLDACTIONHEADER = \
    128156  WorldAction/AddEmptyBoundaryAction.hpp \
     
    131159  WorldAction/CenterOnEdgeAction.hpp \
    132160  WorldAction/ChangeBoxAction.hpp \
     161  WorldAction/InputAction.hpp \
     162  WorldAction/OutputAction.hpp \
    133163  WorldAction/RemoveSphereOfAtomsAction.hpp \
    134164  WorldAction/RepeatBoxAction.hpp \
    135165  WorldAction/ScaleBoxAction.hpp \
    136166  WorldAction/SetDefaultNameAction.hpp \
    137   WorldAction/SetGaussianBasisAction.hpp
     167  WorldAction/SetGaussianBasisAction.hpp \
     168  WorldAction/SetOutputFormatsAction.hpp               
    138169
     170unity.cpp:
     171        echo "" >  unity.cpp; \
     172        list='$(ACTIONSSOURCE)'; for file in $$list; do \
     173          echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \
     174        done;
     175       
     176MOSTLYCLEANFILES = unity.cpp
  • src/Actions/MakroAction.cpp

    r06f4ef6 rb6da28  
    4444}
    4545
     46Dialog* MakroAction::fillDialog(Dialog *dialog) {
     47  return actions->fillAllDialogs(dialog);
     48}
    4649
    4750Action::state_ptr MakroAction::performCall(){
  • src/Actions/MakroAction.hpp

    r06f4ef6 rb6da28  
    2929  bool shouldUndo();
    3030
     31protected:
     32  virtual Dialog *fillDialog(Dialog *dialog);
    3133private:
    3234  virtual Action::state_ptr performCall();
  • src/Actions/ManipulateAtomsProcess.cpp

    r06f4ef6 rb6da28  
    2727{}
    2828
     29Dialog* ManipulateAtomsProcess::fillDialog(Dialog *dialog){
     30  ASSERT(dialog,"No Dialog given when filling action dialog");
     31  return dialog;
     32}
     33
    2934Action::state_ptr ManipulateAtomsProcess::performCall(){
    3035  World::getInstance().doManipulate(this);
     
    5358  setMaxSteps(world->numAtoms());
    5459  start();
    55   for(World::AtomIterator iter=world->getAtomIter(descr);iter!=world->atomEnd();++iter){
     60  for(World::internal_AtomIterator
     61      iter=world->getAtomIter_internal(descr);
     62      iter!=world->atomEnd_internal();
     63      ++iter){
     64
    5665    setCurrStep(iter.getCount());
    5766    operation(*iter);
  • src/Actions/ManipulateAtomsProcess.hpp

    r06f4ef6 rb6da28  
    2727
    2828  virtual void doManipulate(World *);
     29
     30protected:
     31  virtual Dialog * fillDialog(Dialog*);
    2932private:
    30 
    3133  virtual Action::state_ptr performCall();
    3234  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/MapOfActions.cpp

    r06f4ef6 rb6da28  
    1010using namespace std;
    1111
     12#include "Actions/MapOfActions.hpp"
     13#include "Descriptors/AtomIdDescriptor.hpp"
     14#include "Descriptors/MoleculeIdDescriptor.hpp"
     15#include "Helpers/Assert.hpp"
    1216#include "Patterns/Singleton_impl.hpp"
    13 #include "Actions/MapOfActions.hpp"
    14 #include "Helpers/Assert.hpp"
    1517
    1618#include <boost/lexical_cast.hpp>
     
    1820#include <boost/program_options.hpp>
    1921
     22#include <iostream>
     23
     24#include "atom.hpp"
     25#include "Box.hpp"
    2026#include "CommandLineParser.hpp"
     27#include "element.hpp"
    2128#include "log.hpp"
     29#include "Matrix.hpp"
     30#include "molecule.hpp"
     31#include "periodentafel.hpp"
     32#include "vector.hpp"
    2233#include "verbose.hpp"
    2334
     35#include "Actions/ActionRegistry.hpp"
     36#include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
     37#include "Actions/AnalysisAction/PairCorrelationAction.hpp"
     38#include "Actions/AnalysisAction/PointCorrelationAction.hpp"
     39#include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
     40#include "Actions/AnalysisAction/SurfaceCorrelationAction.hpp"
     41#include "Actions/AtomAction/AddAction.hpp"
     42#include "Actions/AtomAction/ChangeElementAction.hpp"
     43#include "Actions/AtomAction/RemoveAction.hpp"
     44#include "Actions/CmdAction/BondLengthTableAction.hpp"
     45#include "Actions/CmdAction/ElementDbAction.hpp"
     46#include "Actions/CmdAction/FastParsingAction.hpp"
     47#include "Actions/CmdAction/HelpAction.hpp"
     48#include "Actions/CmdAction/VerboseAction.hpp"
     49#include "Actions/CmdAction/VersionAction.hpp"
     50#include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
     51#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
     52#include "Actions/FragmentationAction/FragmentationAction.hpp"
     53#include "Actions/MoleculeAction/BondFileAction.hpp"
     54#include "Actions/MoleculeAction/ChangeNameAction.hpp"
     55#include "Actions/MoleculeAction/FillWithMoleculeAction.hpp"
     56#include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp"
     57#include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
     58#include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
     59#include "Actions/MoleculeAction/SaveBondsAction.hpp"
     60#include "Actions/MoleculeAction/SaveTemperatureAction.hpp"
     61#include "Actions/MoleculeAction/SuspendInWaterAction.hpp"
     62#include "Actions/MoleculeAction/TranslateAction.hpp"
     63#include "Actions/MoleculeAction/VerletIntegrationAction.hpp"
     64#include "Actions/ParserAction/LoadXyzAction.hpp"
     65#include "Actions/ParserAction/SaveXyzAction.hpp"
     66#include "Actions/SelectionAction/AllAtomsAction.hpp"
     67#include "Actions/SelectionAction/AllMoleculesAction.hpp"
     68#include "Actions/SelectionAction/AtomByIdAction.hpp"
     69#include "Actions/SelectionAction/MoleculeByIdAction.hpp"
     70#include "Actions/SelectionAction/NotAllAtomsAction.hpp"
     71#include "Actions/SelectionAction/NotAllMoleculesAction.hpp"
     72#include "Actions/SelectionAction/NotAtomByIdAction.hpp"
     73#include "Actions/SelectionAction/NotMoleculeByIdAction.hpp"
     74#include "Actions/TesselationAction/ConvexEnvelopeAction.hpp"
     75#include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
     76#include "Actions/WorldAction/AddEmptyBoundaryAction.hpp"
     77#include "Actions/WorldAction/BoundInBoxAction.hpp"
     78#include "Actions/WorldAction/CenterInBoxAction.hpp"
     79#include "Actions/WorldAction/CenterOnEdgeAction.hpp"
     80#include "Actions/WorldAction/ChangeBoxAction.hpp"
     81#include "Actions/WorldAction/InputAction.hpp"
     82#include "Actions/WorldAction/OutputAction.hpp"
     83#include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp"
     84#include "Actions/WorldAction/RepeatBoxAction.hpp"
     85#include "Actions/WorldAction/ScaleBoxAction.hpp"
     86#include "Actions/WorldAction/SetDefaultNameAction.hpp"
     87#include "Actions/WorldAction/SetGaussianBasisAction.hpp"
     88#include "Actions/WorldAction/SetOutputFormatsAction.hpp"
    2489#include "Actions/Values.hpp"
    2590
     
    2792{
    2893  VectorValue VV;
    29   if (values.size() != 3) {
    30     cerr <<  "Specified vector does not have three components but " << values.size() << endl;
     94  std::vector<std::string> components;
     95
     96  // split comma-separated values
     97  if (values.size() != 1) {
     98    cerr <<  "Not one vector but " << components.size() << " given " << endl;
     99    throw boost::program_options::validation_error("Unequal to one vector given");
     100  }
     101  std::string argument(values.at(0));
     102  std::string::iterator Aiter = argument.begin();
     103  std::string::iterator Biter = argument.begin();
     104  for (; Aiter != argument.end(); ++Aiter) {
     105    if (*Aiter == ',') {
     106      components.push_back(string(Biter,Aiter));
     107      do {
     108        Aiter++;
     109      } while (*Aiter == ' ' || *Aiter == '\t');
     110      Biter = Aiter;
     111    }
     112  }
     113  components.push_back(string(Biter,argument.end()));
     114
     115  if (components.size() != 3) {
     116    cerr <<  "Specified vector does not have three components but " << components.size() << endl;
    31117    throw boost::program_options::validation_error("Specified vector does not have three components");
    32118  }
    33   VV.x = boost::lexical_cast<double>(values.at(0));
    34   VV.y = boost::lexical_cast<double>(values.at(1));
    35   VV.z = boost::lexical_cast<double>(values.at(2));
     119  VV.x = boost::lexical_cast<double>(components.at(0));
     120  VV.y = boost::lexical_cast<double>(components.at(1));
     121  VV.z = boost::lexical_cast<double>(components.at(2));
    36122  v = boost::any(VectorValue(VV));
    37123}
     
    40126{
    41127  BoxValue BV;
    42   if (values.size() != 6) {
    43     cerr <<  "Specified vector does not have three components but " << values.size() << endl;
     128  std::vector<std::string> components;
     129
     130  // split comma-separated values
     131  if (values.size() != 1) {
     132    cerr <<  "Not one vector but " << components.size() << " given " << endl;
     133    throw boost::program_options::validation_error("Unequal to one vector given");
     134  }
     135  std::string argument(values.at(0));
     136  std::string::iterator Aiter = argument.begin();
     137  std::string::iterator Biter = argument.begin();
     138  for (; Aiter != argument.end(); ++Aiter) {
     139    if (*Aiter == ',') {
     140      components.push_back(string(Biter,Aiter));
     141      do {
     142        Aiter++;
     143      } while (*Aiter == ' ' || *Aiter == '\t');
     144      Biter = Aiter;
     145    }
     146  }
     147  components.push_back(string(Biter,argument.end()));
     148
     149  if (components.size() != 6) {
     150    cerr <<  "Specified vector does not have three components but " << components.size() << endl;
    44151    throw boost::program_options::validation_error("Specified symmetric box matrix does not have six components");
    45152  }
    46   BV.xx = boost::lexical_cast<double>(values.at(0));
    47   BV.xy = boost::lexical_cast<double>(values.at(1));
    48   BV.xz = boost::lexical_cast<double>(values.at(2));
    49   BV.yy = boost::lexical_cast<double>(values.at(3));
    50   BV.yz = boost::lexical_cast<double>(values.at(4));
    51   BV.zz = boost::lexical_cast<double>(values.at(5));
     153  BV.xx = boost::lexical_cast<double>(components.at(0));
     154  BV.yx = boost::lexical_cast<double>(components.at(1));
     155  BV.yy = boost::lexical_cast<double>(components.at(2));
     156  BV.zx = boost::lexical_cast<double>(components.at(3));
     157  BV.zy = boost::lexical_cast<double>(components.at(4));
     158  BV.zz = boost::lexical_cast<double>(components.at(5));
    52159  v = boost::any(BoxValue(BV));
    53160}
     
    83190  DescriptionMap["fragment-mol"] = "create for a given molecule into fragments up to given order";
    84191  DescriptionMap["help"] = "Give this help screen";
     192  DescriptionMap["input"] = "specify input files";
    85193  DescriptionMap["linear-interpolate"] = "linear interpolation in discrete steps between start and end position of a molecule";
     194  DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule";
    86195  DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule";
    87   DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule";
    88   DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements, element and point or element and surface";
     196  DescriptionMap["output"] = "write output files";
     197  DescriptionMap["set-output"] = "specify output formats";
     198  DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements";
    89199  DescriptionMap["parse-xyz"] = "parse xyz file into World";
     200  DescriptionMap["point-correlation"] = "pair correlation analysis between element and point";
    90201  DescriptionMap["principal-axis-system"] = "calculate the principal axis system of the specified molecule";
    91202  DescriptionMap["remove-atom"] = "remove a specified atom";
     
    93204  DescriptionMap["repeat-box"] = "create periodic copies of the simulation box per axis";
    94205  DescriptionMap["rotate-to-pas"] = "calculate the principal axis system of the specified molecule and rotate specified axis to align with main axis";
    95   DescriptionMap["set-basis"] = "set the name of the gaussian basis set for MPQC";
    96206  DescriptionMap["save-adjacency"] = "name of the adjacency file to write to";
    97207  DescriptionMap["save-bonds"] = "name of the bonds file to write to";
    98208  DescriptionMap["save-temperature"] = "name of the temperature file to write to";
     209  DescriptionMap["SaveXyz"] = "save world as xyz file";
    99210  DescriptionMap["scale-box"] = "scale box and atomic positions inside";
     211  DescriptionMap["select-all-atoms"] = "select all atoms";
     212  DescriptionMap["select-all-molecules"] = "select all molecules";
     213  DescriptionMap["select-atom-by-id"] = "select an atom by index";
     214  DescriptionMap["select-molecule-by-id"] = "select a molecule by index";
     215  DescriptionMap["set-basis"] = "set the name of the gaussian basis set for MPQC";
     216  DescriptionMap["set-output"] = "specify output formats";
    100217  DescriptionMap["subgraph-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs";
     218  DescriptionMap["surface-correlation"] = "pair correlation analysis between element and surface";
    101219  DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified";
    102220  DescriptionMap["translate-mol"] = "translate molecule by given vector";
     221  DescriptionMap["unselect-all-atoms"] = "unselect all atoms";
     222  DescriptionMap["unselect-all-molecules"] = "unselect all molecules";
     223  DescriptionMap["unselect-atom-by-id"] = "unselect an atom by index";
     224  DescriptionMap["unselect-molecule-by-id"] = "unselect a molecule by index";
    103225  DescriptionMap["verbose"] = "set verbosity level";
    104226  DescriptionMap["verlet-integrate"] = "perform verlet integration of a given force file";
    105227  DescriptionMap["version"] = "show version";
    106228  // keys for values
    107   DescriptionMap["atom-by-id"] = "index of an atom";
    108229  DescriptionMap["bin-output-file"] = "name of the bin output file";
    109230  DescriptionMap["bin-end"] = "start of the last bin";
     
    123244  DescriptionMap["MaxDistance"] = "maximum distance in space";
    124245  DescriptionMap["molecule-by-id"] = "index of a molecule";
    125   DescriptionMap["molecule-by-name"] = "name of a molecule";
    126246  DescriptionMap["nonconvex-file"] = "filename of the non-convex envelope";
    127247  DescriptionMap["order"] = "order of a discretization, dissection, ...";
     
    129249  DescriptionMap["periodic"] = "system is constraint to periodic boundary conditions (y/n)";
    130250  DescriptionMap["position"] = "position in R^3 space";
    131   DescriptionMap["sphere-radius"] = "radius of tesselation sphere";
    132251  DescriptionMap["start-step"] = "first or start step";
    133252
     
    141260  ShortFormMap["center-in-box"] = "b";
    142261  ShortFormMap["change-element"] = "E";
    143   ShortFormMap["convex-envelope"] = "o";
     262//  ShortFormMap["convex-envelope"] = "x";
    144263  ShortFormMap["default-molname"] = "X";
    145264  ShortFormMap["depth-first-search"] = "D";
     
    152271  ShortFormMap["linear-interpolate"] = "L";
    153272  ShortFormMap["nonconvex-envelope"] = "N";
    154   ShortFormMap["pair-correlation"] = "C";
     273//  ShortFormMap["output"] = "o";
     274//  ShortFormMap["pair-correlation"] = "C";
    155275  ShortFormMap["parse-xyz"] = "p";
    156276  ShortFormMap["remove-atom"] = "r";
     
    163283  ShortFormMap["scale-box"] = "s";
    164284  ShortFormMap["set-basis"] = "M";
     285  ShortFormMap["set-output"] = "o";
    165286  ShortFormMap["subgraph-dissect"] = "I";
    166287  ShortFormMap["suspend-in-water"] = "u";
     
    171292
    172293  // value types for the actions
    173   TypeMap["add-atom"] = Element;
    174   TypeMap["bond-file"] = String;
    175   TypeMap["bond-table"] = String;
    176   TypeMap["boundary"] = Vector;
    177   TypeMap["center-in-box"] = Box;
    178   TypeMap["change-box"] = Box;
    179   TypeMap["change-element"] = Atom;
    180   TypeMap["change-molname"] = String;
    181   TypeMap["convex-envelope"] = Molecule;
    182   TypeMap["default-molname"] = String;
    183   TypeMap["depth-first-search"] = Double;
    184   TypeMap["element-db"] = String;
    185   TypeMap["fastparsing"] = Boolean;
    186   TypeMap["fill-molecule"] = String;
    187   TypeMap["fragment-mol"] = Molecule;
    188   TypeMap["input"] = String;
    189   TypeMap["linear-interpolate"] = String;
    190   TypeMap["molecular-volume"] = Molecule;
    191   TypeMap["nonconvex-envelope"] = Molecule;
    192   TypeMap["parse-xyz"] = String;
    193   TypeMap["pair-correlation"] = String;
    194   TypeMap["principal-axis-system"] = Molecule;
    195   TypeMap["remove-atom"] = Atom;
    196   TypeMap["remove-sphere"] = Double;
    197   TypeMap["repeat-box"] = Vector;
    198   TypeMap["rotate-to-pas"] = Molecule;
    199   TypeMap["save-adjacency"] = String;
    200   TypeMap["save-bonds"] = String;
    201   TypeMap["save-temperature"] = String;
    202   TypeMap["scale-box"] = Vector;
    203   TypeMap["set-basis"] = String;
    204   TypeMap["subgraph-dissect"] = None;
    205   TypeMap["suspend-in-water"] = Double;
    206   TypeMap["translate-mol"] = Vector;
    207   TypeMap["verlet-integrate"] = String;
    208   TypeMap["verbose"] = Integer;
     294  TypeMap["add-atom"] = &typeid(element);
     295  TypeMap["bond-file"] = &typeid(std::string);
     296  TypeMap["bond-table"] = &typeid(std::string);
     297  TypeMap["boundary"] = &typeid(VectorValue);
     298  TypeMap["center-in-box"] = &typeid(BoxValue);
     299  TypeMap["change-box"] = &typeid(BoxValue);
     300  TypeMap["change-element"] = &typeid(element);
     301  TypeMap["change-molname"] = &typeid(std::string);
     302  TypeMap["convex-envelope"] = &typeid(void);
     303  TypeMap["default-molname"] = &typeid(std::string);
     304  TypeMap["depth-first-search"] = &typeid(double);
     305  TypeMap["element-db"] = &typeid(std::string);
     306  TypeMap["fastparsing"] = &typeid(bool);
     307  TypeMap["fill-molecule"] = &typeid(std::string);
     308  TypeMap["fragment-mol"] = &typeid(std::string);
     309  TypeMap["input"] = &typeid(std::string);
     310  TypeMap["linear-interpolate"] = &typeid(std::string);
     311  TypeMap["molecular-volume"] = &typeid(molecule);
     312  TypeMap["nonconvex-envelope"] = &typeid(double);
     313  TypeMap["output"] = &typeid(void);
     314  TypeMap["parse-xyz"] = &typeid(std::string);
     315  TypeMap["pair-correlation"] = &typeid(void);
     316  TypeMap["point-correlation"] = &typeid(void);
     317  TypeMap["principal-axis-system"] = &typeid(void);
     318  TypeMap["remove-atom"] = &typeid(void);
     319  TypeMap["remove-sphere"] = &typeid(double);
     320  TypeMap["repeat-box"] = &typeid(VectorValue);
     321  TypeMap["rotate-to-pas"] = &typeid(molecule);
     322  TypeMap["save-adjacency"] = &typeid(std::string);
     323  TypeMap["save-bonds"] = &typeid(std::string);
     324  TypeMap["save-temperature"] = &typeid(std::string);
     325  TypeMap["scale-box"] = &typeid(VectorValue);
     326  TypeMap["set-basis"] = &typeid(std::string);
     327  TypeMap["set-output"] = &typeid(std::vector<std::string>);
     328  TypeMap["subgraph-dissect"] = &typeid(void);
     329  TypeMap["surface-correlation"] = &typeid(void);
     330  TypeMap["suspend-in-water"] = &typeid(double);
     331  TypeMap["translate-mol"] = &typeid(VectorValue);
     332  TypeMap["verlet-integrate"] = &typeid(std::string);
     333  TypeMap["verbose"] = &typeid(int);
    209334
    210335  // value types for the values
    211   TypeMap["atom-by-id"] = Atom;
    212   TypeMap["bin-output-file"] = String;
    213   TypeMap["bin-end"] = Double;
    214   TypeMap["bin-start"] = Double;
    215   TypeMap["bin-width"] = Double;
    216   TypeMap["convex-file"] = String;
    217   TypeMap["distance"] = Double;
    218   TypeMap["distances"] = Vector;
    219   TypeMap["DoRotate"] = Boolean;
    220   TypeMap["element"] = Element;
    221   TypeMap["elements"] = ListOfElements;
    222   TypeMap["end-step"] = Integer;
    223   TypeMap["id-mapping"] = Boolean;
    224   TypeMap["length"] = Double;
    225   TypeMap["lengths"] = Vector;
    226   TypeMap["MaxDistance"] = Double;
    227   TypeMap["molecule-by-id"] = Molecule;
    228   TypeMap["molecule-by-name"] = Molecule;
    229   TypeMap["nonconvex-file"] = String;
    230   TypeMap["order"] = Integer;
    231   TypeMap["output-file"] = String;
    232   TypeMap["periodic"] = Boolean;
    233   TypeMap["position"] = Vector;
    234   TypeMap["sphere-radius"] = Double;
    235   TypeMap["start-step"] = Integer;
     336  TypeMap["bin-output-file"] = &typeid(std::string);
     337  TypeMap["bin-end"] = &typeid(double);
     338  TypeMap["bin-start"] = &typeid(double);
     339  TypeMap["bin-width"] = &typeid(double);
     340  TypeMap["convex-file"] = &typeid(std::string);
     341  TypeMap["distance"] = &typeid(double);
     342  TypeMap["distances"] = &typeid(VectorValue);
     343  TypeMap["DoRotate"] = &typeid(bool);
     344  TypeMap["element"] = &typeid(element);
     345  TypeMap["elements"] = &typeid(std::vector<element *>);
     346  TypeMap["end-step"] = &typeid(int);
     347  TypeMap["id-mapping"] = &typeid(bool);
     348  TypeMap["length"] = &typeid(double);
     349  TypeMap["lengths"] = &typeid(VectorValue);
     350  TypeMap["MaxDistance"] = &typeid(double);
     351  TypeMap["molecule-by-id"] = &typeid(molecule);
     352  TypeMap["nonconvex-file"] = &typeid(std::string);
     353  TypeMap["order"] = &typeid(int);
     354  TypeMap["output-file"] = &typeid(std::string);
     355  TypeMap["periodic"] = &typeid(bool);
     356  TypeMap["position"] = &typeid(VectorValue);
     357  TypeMap["select-all-atoms"] = &typeid(void);
     358  TypeMap["select-all-molecules"] = &typeid(void);
     359  TypeMap["select-atom-by-id"] = &typeid(atom);
     360  TypeMap["select-molecule-by-id"] = &typeid(molecule);
     361  TypeMap["start-step"] = &typeid(int);
     362  TypeMap["unselect-all-atoms"] = &typeid(void);
     363  TypeMap["unselect-all-molecules"] = &typeid(void);
     364  TypeMap["unselect-atom-by-id"] = &typeid(atom);
     365  TypeMap["unselect-molecule-by-id"] = &typeid(molecule);
     366
     367  TypeEnumMap[&typeid(void)] = None;
     368  TypeEnumMap[&typeid(bool)] = Boolean;
     369  TypeEnumMap[&typeid(int)] = Integer;
     370  TypeEnumMap[&typeid(std::vector<int>)] = ListOfIntegers;
     371  TypeEnumMap[&typeid(double)] = Double;
     372  TypeEnumMap[&typeid(std::vector<double>)] = ListOfDoubles;
     373  TypeEnumMap[&typeid(std::string)] = String;
     374  TypeEnumMap[&typeid(std::vector<std::string>)] = ListOfStrings;
     375  TypeEnumMap[&typeid(VectorValue)] = Vector;
     376  TypeEnumMap[&typeid(std::vector<VectorValue>)] = ListOfVectors;
     377  TypeEnumMap[&typeid(BoxValue)] = Box;
     378  TypeEnumMap[&typeid(molecule)] = Molecule;
     379  TypeEnumMap[&typeid(std::vector<molecule *>)] = ListOfMolecules;
     380  TypeEnumMap[&typeid(atom)] = Atom;
     381  TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms;
     382  TypeEnumMap[&typeid(element)] = Element;
     383  TypeEnumMap[&typeid(std::vector<element *>)] = ListOfElements;
    236384
    237385  // default values for any action that needs one (always string!)
    238   DefaultValue["bin-width"] = "0.5";
    239   DefaultValue["fastparsing"] = "0";
    240   DefaultValue["atom-by-id"] = "-1";
    241   DefaultValue["molecule-by-id"] = "-1";
    242   DefaultValue["periodic"] = "0";
    243 
    244 
    245   // list of generic actions
     386  CurrentValue["bin-width"] = "0.5";
     387  CurrentValue["fastparsing"] = "0";
     388  CurrentValue["periodic"] = "0";
     389
     390  // put action into each menu category
     391  MenuDescription["analysis"] = pair<std::string,std::string>("Analysis (pair correlation, volume)", "Analysis");
     392  MenuDescription["atom"] = pair<std::string,std::string>("Edit atoms", "Atoms");
     393  MenuDescription["command"] = pair<std::string,std::string>("Configuration", "configuration options");
     394  MenuDescription["fragmentation"] = pair<std::string,std::string>("Fragmentation", "Fragmentation");
     395  MenuDescription["molecule"] = pair<std::string,std::string>("Parse files into system", "Molecules");
     396  MenuDescription["parser"] = pair<std::string,std::string>("Edit molecules (load, parse, save)", "Input/Output");
     397  MenuDescription["selection"] = pair<std::string,std::string>("Select atoms/molecules", "Selection");
     398  MenuDescription["tesselation"] = pair<std::string,std::string>("Tesselate molecules", "Tesselation");
     399  MenuDescription["world"] = pair<std::string,std::string>("Edit world", "Globals");
     400
     401  MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "molecular-volume") );
     402  MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "pair-correlation") );
     403  MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "point-correlation") );
     404  MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "surface-correlation") );
     405  MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "principal-axis-system") );
     406
     407  MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "add-atom") );
     408  MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "change-element") );
     409  MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "remove-atom") );
     410
     411  MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "bond-table") );
     412  MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "element-db") );
     413  MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "fastparsing") );
     414  MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "verbose") );
     415  MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "version") );
     416
     417  MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "depth-first-search") );
     418  MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "fragment-mol") );
     419  MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "subgraph-dissect") );
     420
     421  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "bond-file") );
     422  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "change-molname") );
     423  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "fill-molecule") );
     424  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "linear-interpolate") );
     425  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-to-pas") );
     426  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-adjacency") );
     427  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-bonds") );
     428  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-temperature") );
     429  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "suspend-in-water") );
     430  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "translate-mol") );
     431  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "verlet-integrate") );
     432
     433  MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "parse-xyz") );
     434  MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "SaveXyz") );
     435
     436  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atom-by-id") );
     437  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-by-id") );
     438  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atom-by-id") );
     439  MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-by-id") );
     440
     441  MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "convex-envelope") );
     442  MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "nonconvex-envelope") );
     443
     444  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "boundary") );
     445  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "bound-in-box") );
     446  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-in-box") );
     447  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-edge") );
     448  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "change-box") );
     449  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "input") );
     450  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "output") );
     451  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "remove-sphere") );
     452  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "repeat-box") );
     453  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "scale-box") );
     454  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "default-molname") );
     455  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-basis") );
     456  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-output") );
     457
     458  // put actions into command line category
    246459        generic.insert("add-atom");
    247460  generic.insert("bond-file");
     
    262475  generic.insert("fragment-mol");
    263476  generic.insert("help");
    264         generic.insert("linear-interpolate");
     477  generic.insert("input");
     478  generic.insert("linear-interpolate");
    265479//  generic.insert("molecular-volume");
    266480  generic.insert("nonconvex-envelope");
     481  generic.insert("output");
    267482        generic.insert("pair-correlation");
    268 //      generic.insert("parse-xyz");
     483        generic.insert("parse-xyz");
     484  generic.insert("point-correlation");
    269485//  generic.insert("principal-axis-system");
    270486  generic.insert("remove-atom");
     
    276492  generic.insert("save-temperature");
    277493  generic.insert("scale-box");
     494  generic.insert("select-all-atoms");
     495  generic.insert("select-all-molecules");
     496  generic.insert("select-atom-by-id");
     497  generic.insert("select-molecule-by-id");
    278498  generic.insert("set-basis");
     499  generic.insert("set-output");
    279500        generic.insert("subgraph-dissect");
     501  generic.insert("surface-correlation");
    280502  generic.insert("suspend-in-water");
    281503  generic.insert("translate-mol");
     504  generic.insert("unselect-all-atoms");
     505  generic.insert("unselect-all-molecules");
     506  generic.insert("unselect-atom-by-id");
     507  generic.insert("unselect-molecule-by-id");
    282508        generic.insert("verbose");
    283509  generic.insert("verlet-integrate");
     
    286512    // positional arguments
    287513  generic.insert("input");
    288   inputfile.insert("input");
    289514
    290515    // hidden arguments
    291   generic.insert("atom-by-id");
    292   generic.insert("bin-end");
    293   generic.insert("bin-output-file");
    294   generic.insert("bin-start");
    295   generic.insert("bin-width");
    296   generic.insert("convex-file");
    297   generic.insert("distance");
    298   generic.insert("DoRotate");
    299   generic.insert("distances");
    300   generic.insert("element");
    301   generic.insert("elements");
    302   generic.insert("end-step");
    303   generic.insert("id-mapping");
    304   generic.insert("lengths");
    305   generic.insert("MaxDistance");
    306   generic.insert("molecule-by-id");
    307   generic.insert("molecule-by-name");
    308   generic.insert("nonconvex-file");
    309   generic.insert("order");
    310   generic.insert("output-file");
    311   generic.insert("periodic");
    312   generic.insert("position");
    313   generic.insert("sphere-radius");
    314   generic.insert("start-step");
     516  hidden.insert("bin-end");
     517  hidden.insert("bin-output-file");
     518  hidden.insert("bin-start");
     519  hidden.insert("bin-width");
     520  hidden.insert("convex-file");
     521  hidden.insert("distance");
     522  hidden.insert("DoRotate");
     523  hidden.insert("distances");
     524  hidden.insert("element");
     525  hidden.insert("elements");
     526  hidden.insert("end-step");
     527  hidden.insert("id-mapping");
     528  hidden.insert("lengths");
     529  hidden.insert("MaxDistance");
     530  hidden.insert("molecule-by-id");
     531  hidden.insert("nonconvex-file");
     532  hidden.insert("order");
     533  hidden.insert("output-file");
     534  hidden.insert("periodic");
     535  hidden.insert("position");
     536  hidden.insert("start-step");
    315537}
    316538
     
    323545}
    324546
     547void MapOfActions::queryCurrentValue(const char * name, class atom * &_T)
     548{
     549  int atomID = -1;
     550  if (typeid( atom ) == *TypeMap[name]) {
     551    if (CurrentValue.find(name) == CurrentValue.end())
     552      throw MissingValueException(__FILE__, __LINE__);
     553    atomID = lexical_cast<int>(CurrentValue[name].c_str());
     554    CurrentValue.erase(name);
     555  } else
     556    throw IllegalTypeException(__FILE__,__LINE__);
     557  _T = World::getInstance().getAtom(AtomById(atomID));
     558}
     559
     560void MapOfActions::queryCurrentValue(const char * name, class element * &_T)  {
     561  int Z = -1;
     562  if (typeid( element ) == *TypeMap[name]) {
     563    if (CurrentValue.find(name) == CurrentValue.end())
     564      throw MissingValueException(__FILE__, __LINE__);
     565    Z = lexical_cast<int>(CurrentValue[name].c_str());
     566    CurrentValue.erase(name);
     567  } else
     568    throw IllegalTypeException(__FILE__,__LINE__);
     569  _T = World::getInstance().getPeriode()->FindElement(Z);
     570}
     571
     572void MapOfActions::queryCurrentValue(const char * name, class molecule * &_T) {
     573  int molID = -1;
     574  if (typeid( molecule ) == *TypeMap[name]) {
     575    if (CurrentValue.find(name) == CurrentValue.end())
     576      throw MissingValueException(__FILE__, __LINE__);
     577    molID = lexical_cast<int>(CurrentValue[name].c_str());
     578    CurrentValue.erase(name);
     579  } else
     580    throw IllegalTypeException(__FILE__,__LINE__);
     581  _T = World::getInstance().getMolecule(MoleculeById(molID));
     582}
     583
     584void MapOfActions::queryCurrentValue(const char * name, class Box &_T) {
     585  Matrix M;
     586  double tmp;
     587  if (typeid( BoxValue ) == *TypeMap[name]) {
     588    if (CurrentValue.find(name) == CurrentValue.end())
     589      throw MissingValueException(__FILE__, __LINE__);
     590    std::istringstream stream(CurrentValue[name]);
     591    stream >> tmp;
     592    M.set(0,0,tmp);
     593    stream >> tmp;
     594    M.set(0,1,tmp);
     595    M.set(1,0,tmp);
     596    stream >> tmp;
     597    M.set(0,2,tmp);
     598    M.set(2,0,tmp);
     599    stream >> tmp;
     600    M.set(1,1,tmp);
     601    stream >> tmp;
     602    M.set(1,2,tmp);
     603    M.set(2,1,tmp);
     604    stream >> tmp;
     605    M.set(2,2,tmp);
     606    _T = M;
     607    CurrentValue.erase(name);
     608  } else
     609    throw IllegalTypeException(__FILE__,__LINE__);
     610}
     611
     612void MapOfActions::queryCurrentValue(const char * name, class Vector &_T) {
     613  if (typeid( VectorValue ) == *TypeMap[name]) {
     614    std::istringstream stream(CurrentValue[name]);
     615    CurrentValue.erase(name);
     616    stream >> _T[0];
     617    stream >> _T[1];
     618    stream >> _T[2];
     619  } else
     620    throw IllegalTypeException(__FILE__,__LINE__);
     621}
     622
     623void MapOfActions::queryCurrentValue(const char * name, std::vector<atom *>&_T)
     624{
     625  int atomID = -1;
     626  atom *Walker = NULL;
     627  if (typeid( std::vector<atom *> ) == *TypeMap[name]) {
     628    if (CurrentValue.find(name) == CurrentValue.end())
     629      throw MissingValueException(__FILE__, __LINE__);
     630    std::istringstream stream(CurrentValue[name]);
     631    CurrentValue.erase(name);
     632    while (!stream.fail()) {
     633      stream >> atomID >> ws;
     634      Walker = World::getInstance().getAtom(AtomById(atomID));
     635      if (Walker != NULL)
     636        _T.push_back(Walker);
     637      atomID = -1;
     638      Walker = NULL;
     639    }
     640  } else
     641    throw IllegalTypeException(__FILE__,__LINE__);
     642}
     643
     644void MapOfActions::queryCurrentValue(const char * name, std::vector<element *>&_T)
     645{
     646  int Z = -1;
     647  element *elemental = NULL;
     648  if (typeid( std::vector<element *> ) == *TypeMap[name]) {
     649    if (CurrentValue.find(name) == CurrentValue.end())
     650      throw MissingValueException(__FILE__, __LINE__);
     651    std::istringstream stream(CurrentValue[name]);
     652    CurrentValue.erase(name);
     653    while (!stream.fail()) {
     654      stream >> Z >> ws;
     655      elemental = World::getInstance().getPeriode()->FindElement(Z);
     656      if (elemental != NULL)
     657        _T.push_back(elemental);
     658      Z = -1;
     659    }
     660  } else
     661    throw IllegalTypeException(__FILE__,__LINE__);
     662}
     663
     664void MapOfActions::queryCurrentValue(const char * name, std::vector<molecule *>&_T)
     665{
     666  int molID = -1;
     667  molecule *mol = NULL;
     668  if (typeid( std::vector<molecule *> ) == *TypeMap[name]) {
     669    if (CurrentValue.find(name) == CurrentValue.end())
     670      throw MissingValueException(__FILE__, __LINE__);
     671    std::istringstream stream(CurrentValue[name]);
     672    CurrentValue.erase(name);
     673    while (!stream.fail()) {
     674      stream >> molID >> ws;
     675      mol = World::getInstance().getMolecule(MoleculeById(molID));
     676      if (mol != NULL)
     677        _T.push_back(mol);
     678      molID = -1;
     679      mol = NULL;
     680    }
     681  } else
     682    throw IllegalTypeException(__FILE__,__LINE__);
     683}
     684
     685
     686void MapOfActions::setCurrentValue(const char * name, class atom * &_T)
     687{
     688  if (typeid( atom ) == *TypeMap[name]) {
     689    std::ostringstream stream;
     690    stream << _T->getId();
     691    CurrentValue[name] = stream.str();
     692  } else
     693    throw IllegalTypeException(__FILE__,__LINE__);
     694}
     695
     696void MapOfActions::setCurrentValue(const char * name, class element * &_T)
     697{
     698  if (typeid( element ) == *TypeMap[name]) {
     699    std::ostringstream stream;
     700    stream << _T->Z;
     701    CurrentValue[name] = stream.str();
     702  } else
     703    throw IllegalTypeException(__FILE__,__LINE__);
     704}
     705
     706void MapOfActions::setCurrentValue(const char * name, class molecule * &_T)
     707{
     708  if (typeid( molecule ) == *TypeMap[name]) {
     709    std::ostringstream stream;
     710    stream << _T->getId();
     711    CurrentValue[name] = stream.str();
     712  } else
     713    throw IllegalTypeException(__FILE__,__LINE__);
     714}
     715
     716void MapOfActions::setCurrentValue(const char * name, class Box &_T)
     717{
     718  const Matrix &M = _T.getM();
     719  if (typeid( BoxValue ) == *TypeMap[name]) {
     720    std::ostringstream stream;
     721    stream << M.at(0,0) << " ";
     722    stream << M.at(0,1) << " ";
     723    stream << M.at(0,2) << " ";
     724    stream << M.at(1,1) << " ";
     725    stream << M.at(1,2) << " ";
     726    stream << M.at(2,2) << " ";
     727    CurrentValue[name] = stream.str();
     728  } else
     729    throw IllegalTypeException(__FILE__,__LINE__);
     730}
     731
     732void MapOfActions::setCurrentValue(const char * name, class Vector &_T)
     733{
     734  if (typeid( VectorValue ) == *TypeMap[name]){
     735    std::ostringstream stream;
     736    stream << _T[0] << " ";
     737    stream << _T[1] << " ";
     738    stream << _T[2] << " ";
     739    CurrentValue[name] = stream.str();
     740  } else
     741    throw IllegalTypeException(__FILE__,__LINE__);
     742}
     743
     744void MapOfActions::setCurrentValue(const char * name, std::vector<atom *>&_T)
     745{
     746  if (typeid( std::vector<atom *> ) == *TypeMap[name]) {
     747    std::ostringstream stream;
     748    for (std::vector<atom *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
     749      stream << (*iter)->getId() << " ";
     750    }
     751    CurrentValue[name] = stream.str();
     752  } else
     753    throw IllegalTypeException(__FILE__,__LINE__);
     754}
     755
     756void MapOfActions::setCurrentValue(const char * name, std::vector<element *>&_T)
     757{
     758  if (typeid( std::vector<element *> ) == *TypeMap[name]) {
     759    std::ostringstream stream;
     760    for (std::vector<element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
     761      stream << (*iter)->Z << " ";
     762    }
     763    CurrentValue[name] = stream.str();
     764  } else
     765    throw IllegalTypeException(__FILE__,__LINE__);
     766}
     767
     768void MapOfActions::setCurrentValue(const char * name, std::vector<molecule *>&_T)
     769{
     770  if (typeid( std::vector<molecule *> ) == *TypeMap[name]) {
     771    std::ostringstream stream;
     772    for (std::vector<molecule *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
     773      stream << (*iter)->getId() << " ";
     774    }
     775    CurrentValue[name] = stream.str();
     776  } else
     777    throw IllegalTypeException(__FILE__,__LINE__);
     778}
     779
     780
     781
     782void MapOfActions::populateActions()
     783{
     784  new AnalysisMolecularVolumeAction();
     785  new AnalysisPairCorrelationAction();
     786  new AnalysisPointCorrelationAction();
     787  new AnalysisPrincipalAxisSystemAction();
     788  new AnalysisSurfaceCorrelationAction();
     789
     790  new AtomAddAction();
     791  new AtomChangeElementAction();
     792  new AtomRemoveAction();
     793
     794  new CommandLineBondLengthTableAction();
     795  new CommandLineElementDbAction();
     796  new CommandLineFastParsingAction();
     797  new CommandLineHelpAction();
     798  new CommandLineVerboseAction();
     799  new CommandLineVersionAction();
     800
     801  new FragmentationDepthFirstSearchAction();
     802  new FragmentationFragmentationAction();
     803  new FragmentationSubgraphDissectionAction();
     804
     805  new MoleculeBondFileAction();
     806  new MoleculeChangeNameAction();
     807  new MoleculeFillWithMoleculeAction();
     808  new MoleculeLinearInterpolationofTrajectoriesAction();
     809  new MoleculeRotateToPrincipalAxisSystemAction();
     810  new MoleculeSaveAdjacencyAction();
     811  new MoleculeSaveBondsAction();
     812  new MoleculeSaveTemperatureAction();
     813  new MoleculeSuspendInWaterAction();
     814  new MoleculeTranslateAction();
     815  new MoleculeVerletIntegrationAction();
     816
     817  new ParserLoadXyzAction();
     818  new ParserSaveXyzAction();
     819
     820  new SelectionAllAtomsAction();
     821  new SelectionAllMoleculesAction();
     822  new SelectionAtomByIdAction();
     823  new SelectionMoleculeByIdAction();
     824  new SelectionNotAllAtomsAction();
     825  new SelectionNotAllMoleculesAction();
     826  new SelectionNotAtomByIdAction();
     827  new SelectionNotMoleculeByIdAction();
     828
     829  new TesselationConvexEnvelopeAction();
     830  new TesselationNonConvexEnvelopeAction();
     831
     832  new WorldAddEmptyBoundaryAction();
     833  new WorldBoundInBoxAction();
     834  new WorldCenterInBoxAction();
     835  new WorldCenterOnEdgeAction();
     836  new WorldChangeBoxAction();
     837  new WorldInputAction();
     838  new WorldOutputAction();
     839  new WorldRemoveSphereOfAtomsAction();
     840  new WorldRepeatBoxAction();
     841  new WorldScaleBoxAction();
     842  new WorldSetDefaultNameAction();
     843  new WorldSetGaussianBasisAction();
     844  new WorldSetOutputFormatsAction();
     845}
     846
    325847/** Adds all options to the CommandLineParser.
    326848 *
     
    332854    for (set<string>::iterator OptionRunner = ListRunner->first->begin(); OptionRunner != ListRunner->first->end(); ++OptionRunner) {
    333855      if (hasValue(*OptionRunner)) {
    334         DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner] << " to CommandLineParser." << endl);
    335            switch((enum OptionTypes) TypeMap[*OptionRunner]) {
     856        DoLog(1) && (Log() << Verbose(1) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner]->name() << " to CommandLineParser." << endl);
     857           switch(TypeEnumMap[TypeMap[*OptionRunner]]) {
    336858          default:
    337859          case None:
     
    343865            ListRunner->second->add_options()
    344866              (getKeyAndShortForm(*OptionRunner).c_str(),
    345                   DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
    346                         po::value< bool >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
     867                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
     868                        po::value< bool >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
    347869                        po::value< bool >(),
    348870                  getDescription(*OptionRunner).c_str())
     
    352874            ListRunner->second->add_options()
    353875              (getKeyAndShortForm(*OptionRunner).c_str(),
    354                   po::value<BoxValue>()->multitoken(),
     876                  po::value<BoxValue>(),
    355877                  getDescription(*OptionRunner).c_str())
    356878              ;
     
    359881            ListRunner->second->add_options()
    360882              (getKeyAndShortForm(*OptionRunner).c_str(),
    361                   DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
    362                         po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
     883                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
     884                        po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
    363885                        po::value< int >(),
    364886                  getDescription(*OptionRunner).c_str())
    365887              ;
    366888            break;
    367           case ListOfInts:
     889          case ListOfIntegers:
    368890            ListRunner->second->add_options()
    369891              (getKeyAndShortForm(*OptionRunner).c_str(),
     
    375897            ListRunner->second->add_options()
    376898              (getKeyAndShortForm(*OptionRunner).c_str(),
    377                   DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
    378                         po::value< double >()->default_value(atof(DefaultValue[*OptionRunner].c_str())) :
     899                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
     900                        po::value< double >()->default_value(lexical_cast<double>(CurrentValue[*OptionRunner].c_str())) :
    379901                        po::value< double >(),
    380902                  getDescription(*OptionRunner).c_str())
     
    391913            ListRunner->second->add_options()
    392914              (getKeyAndShortForm(*OptionRunner).c_str(),
    393                   DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
    394                         po::value< std::string >()->default_value(DefaultValue[*OptionRunner]) :
     915                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
     916                        po::value< std::string >()->default_value(CurrentValue[*OptionRunner]) :
    395917                        po::value< std::string >(),
    396918                  getDescription(*OptionRunner).c_str())
    397919              ;
    398920            break;
    399           case Axis:
    400             ListRunner->second->add_options()
    401               (getKeyAndShortForm(*OptionRunner).c_str(),
    402                   DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
    403                         po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
     921          case ListOfStrings:
     922            ListRunner->second->add_options()
     923              (getKeyAndShortForm(*OptionRunner).c_str(),
     924                  po::value< vector<std::string> >()->multitoken(),
     925                  getDescription(*OptionRunner).c_str())
     926              ;
     927            break;
     928          case Vector:
     929            ListRunner->second->add_options()
     930              (getKeyAndShortForm(*OptionRunner).c_str(),
     931                  po::value<VectorValue>(),
     932                  getDescription(*OptionRunner).c_str())
     933              ;
     934            break;
     935          case ListOfVectors:
     936            ListRunner->second->add_options()
     937              (getKeyAndShortForm(*OptionRunner).c_str(),
     938                  po::value< vector<VectorValue> >()->multitoken(),
     939                  getDescription(*OptionRunner).c_str())
     940              ;
     941            break;
     942          case Molecule:
     943            ListRunner->second->add_options()
     944              (getKeyAndShortForm(*OptionRunner).c_str(),
     945                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
     946                        po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
    404947                        po::value< int >(),
    405948                  getDescription(*OptionRunner).c_str())
    406949              ;
    407950            break;
    408           case Vector:
    409             ListRunner->second->add_options()
    410               (getKeyAndShortForm(*OptionRunner).c_str(),
    411                   po::value<VectorValue>()->multitoken(),
    412                   getDescription(*OptionRunner).c_str())
    413               ;
    414             break;
    415           case Molecule:
    416             ListRunner->second->add_options()
    417               (getKeyAndShortForm(*OptionRunner).c_str(),
    418                   DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
    419                         po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
     951          case ListOfMolecules:
     952            ListRunner->second->add_options()
     953              (getKeyAndShortForm(*OptionRunner).c_str(),
     954                  po::value< vector<int> >()->multitoken(),
     955                  getDescription(*OptionRunner).c_str())
     956              ;
     957            break;
     958          case Atom:
     959            ListRunner->second->add_options()
     960              (getKeyAndShortForm(*OptionRunner).c_str(),
     961                  CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
     962                        po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
    420963                        po::value< int >(),
    421964                  getDescription(*OptionRunner).c_str())
    422965              ;
    423966            break;
    424           case ListOfMolecules:
     967          case ListOfAtoms:
    425968            ListRunner->second->add_options()
    426969              (getKeyAndShortForm(*OptionRunner).c_str(),
     
    429972              ;
    430973            break;
    431           case Atom:
    432             ListRunner->second->add_options()
    433               (getKeyAndShortForm(*OptionRunner).c_str(),
    434                   DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
    435                         po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
    436                         po::value< int >(),
    437                   getDescription(*OptionRunner).c_str())
    438               ;
    439             break;
    440           case ListOfAtoms:
    441             ListRunner->second->add_options()
    442               (getKeyAndShortForm(*OptionRunner).c_str(),
    443                   po::value< vector<int> >()->multitoken(),
    444                   getDescription(*OptionRunner).c_str())
    445               ;
    446             break;
    447974          case Element:
    448975            ListRunner->second->add_options()
    449976              (getKeyAndShortForm(*OptionRunner).c_str(),
    450                   po::value< vector<int> >(),
     977                  po::value< int >(),
    451978                  getDescription(*OptionRunner).c_str())
    452979              ;
     
    461988        }
    462989      } else {
    463         DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);
     990        DoLog(3) && (Log() << Verbose(3) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);
    464991        ListRunner->second->add_options()
    465992          (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
     
    468995    }
    469996  }
    470   // add positional arguments
    471   for (set<string>::iterator OptionRunner = inputfile.begin(); OptionRunner != inputfile.end(); ++OptionRunner) {
    472     DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to positional CommandLineParser." << endl);
    473     CommandLineParser::getInstance().inputfile.add((*OptionRunner).c_str(), -1);
    474   }
    475   cout << "Name for position 1: " << CommandLineParser::getInstance().inputfile.name_for_position(1) << endl;
    476997}
    477998
     
    5291050 * \return type of the action
    5301051 */
    531 enum MapOfActions::OptionTypes MapOfActions::getValueType(string actionname)
    532 {
    533   return TypeMap[actionname];
     1052std::string MapOfActions::getValueType(string actionname)
     1053{
     1054  return TypeMap[actionname]->name();
    5341055}
    5351056
  • src/Actions/MapOfActions.hpp

    r06f4ef6 rb6da28  
    99#define MAPOFACTIONS_HPP_
    1010
    11 #include "Helpers/Assert.hpp"
    1211#include <boost/program_options.hpp>
     12#include <boost/lexical_cast.hpp>
     13
    1314#include <map>
    1415#include <set>
     16#include <vector>
     17#include <typeinfo>
     18
     19#include "Exceptions/IllegalTypeException.hpp"
     20#include "Exceptions/MissingValueException.hpp"
     21#include "Helpers/Assert.hpp"
     22#include "Patterns/Singleton.hpp"
    1523
    1624class MapOfActionsTest;
    1725
    18 #include "Patterns/Singleton.hpp"
     26class Box;
     27class atom;
     28class element;
     29class molecule;
     30class Vector;
    1931
    2032namespace po = boost::program_options;
    2133
     34using boost::lexical_cast;
     35
     36/** Central class for adding functionality to the code.
     37 *
     38 * In Molecuilder everything that can be done - such as adding atoms,
     39 * translating molecules, saving bind information - is an Action.
     40 *
     41 * In order to reference Action's with what the user sees, this class is the
     42 * mediator.
     43 *
     44 * An Action is described to the user by:
     45 * -# a name (this is the most important information)
     46 * -# a description
     47 * -# a shortform (single letter for use on the command line)
     48 * -# a text menu it resides in
     49 * -# the type of its argument
     50 * -# the command line category
     51 *
     52 * The Action::NAME is the most important information because every Action
     53 * registers itself automatically with the ActionRegistry and can be retrieved
     54 * therefrom and from this MapOfActions simply by knowing its name alone.
     55 *
     56 * In the constructor of MapOfActions all this is set.
     57 *
     58 * Note that Action will require input from the user. This is done via class
     59 * Query.
     60 *
     61 * And note also that MapOfActions actually contains more than just all
     62 * Actions: There are a number of names that actually are just arguments to
     63 * actions (e.g. "output-file").
     64 *
     65 * <h1> Howto add an Action</h1>
     66 *
     67 * Let us assume your new action (class) is called SuperDuperAction, consisting
     68 * of two files SuperDuperAction.cpp and SuperDuperAction.hpp.
     69 *
     70 * Furthermore, let's say you Action needs two values: a double value as a
     71 * upper threshold and a string which is the name of the output file.
     72 *
     73 * <h2> Command Line preliminaries </h2>
     74 *
     75 * You have to decide whether (for the command line) it makes sense to have an
     76 * extra argument requesting the arguments, or one should be the argument of
     77 * your action. I.e. your action name is "super-duper", then the use may
     78 * call your action like this:
     79 *
     80 * ./molecuilder --super-duper 4 --output-file test.dat
     81 *
     82 * Here, we have picked the threshold as the value for your action and the
     83 * name of the output file is given by an additional argument. Of course,
     84 * it can be the other way round or by two arguments such as here:
     85 *
     86 * ./molecuilder --super-duper --threshold 4 --output-file test.dat
     87 *
     88 * It depends on what possible arguments are already there (don't make up
     89 * new ones if present ones actually make sense for your action) and which
     90 * argument is more natural or closer to what your action does.
     91 *
     92 * <h2> Menu preliminaries </h2>
     93 *
     94 * Whatever you decide, your action will need some Query dialogs to request
     95 * the necessary information from the user, either via a command line
     96 * argument (--output-file) via a text dialog (referenced by "output-file")
     97 * or via a graphical dialog (same reference). And therein, the names
     98 * of the arguments have to re-appear.
     99 *
     100 * Then, the following steps have to be done to incorporate your Action:
     101 * -# create a unique name for your action (no capital letters) to reference
     102 *    it, this name has to appear in the file SuperDuperAction.cpp, e.g.
     103 *    "super-duper"
     104 * -# pick names the other required arguments, best if they are already
     105 *    present in the MapOfActions. They have to appear in Query's in the
     106 *    code of your Action.
     107 * -# With this name create entries in the following maps for the action
     108 *    name and for each names of a desired addtional argument if not present:
     109 *   -# DescriptionMap, a catchy description of what your action does
     110 *   -# TypeMap, see MapOfActions::OptionTypes for possible types of the single
     111 *      argument it takes.
     112 *   -# MenuContainsActionMap, in which menu should your action appear
     113 *   -# ShortFormMap (optional), single letter for command line call
     114 *   -# DefaultValueMap (optional), the default value (always a string)
     115 * -# add to one of the command line sets by the following categories
     116 *   -# generic - generic options (i.e. not one of the others)
     117 *   -# config - action/argument only considers internal bevahior, user
     118 *      does not have to see it while still having full functionality
     119 *   -# hidden - this should be hidden from the user
     120 *   -# visible - this should be visible to the user
     121 *   -# inputfile - this should only be parsed from an input file, not
     122 *      from command line
     123 * -# add to a menu, i.e. make an entry in MenuContainsActionMap.
     124 * -# add header file SuperDuperAction.hpp to MapOfActions.cpp and instantiate
     125 *    your action in populateMenu() (mind the sorting: 1. menu,
     126 *    2. alphabetical)
     127 *
     128 *  And that's.
     129 *
     130 *  Now, your action can be called from the command line, within the text
     131 *  menu and the graphical user interface.
     132 *
     133 */
    22134class MapOfActions : public Singleton<MapOfActions> {
    23135  friend class Singleton<MapOfActions>;
    24136  friend class MapOfActionsTest;
    25137public:
    26   enum OptionTypes { None, Boolean, Integer, ListOfInts, Double, ListOfDoubles, String, Axis, Vector, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements };
     138  enum OptionTypes { None, Boolean, Integer, ListOfIntegers, Double, ListOfDoubles, String, ListOfStrings, Vector, ListOfVectors, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements };
    27139
    28140  // getter for the action descriptions and short forms
    29   std::string getDescription(string actionname);
    30   std::string getKeyAndShortForm(string actionname);
    31   std::string getShortForm(string actionname);
    32   map <std::string, std::string> getShortFormToActionMap();
     141  std::string getDescription(std::string actionname);
     142  std::string getKeyAndShortForm(std::string actionname);
     143  std::string getShortForm(std::string actionname);
     144  std::map <std::string, std::string> getShortFormToActionMap();
    33145
    34146  void AddOptionsToParser();
    35147
    36148  // check presence and getter for action type
    37   bool hasValue(string actionname);
    38   bool isShortFormPresent(string shortform);
    39   enum OptionTypes getValueType(string actionname);
    40 
    41   set<string> generic;
    42   set<string> config;
    43   set<string> hidden;
    44   set<string> visible;
    45   set<string> inputfile;
     149  bool hasValue(std::string actionname);
     150  bool isShortFormPresent(std::string shortform);
     151  std::string  getValueType(std::string actionname);
     152
     153  std::set<std::string> generic;
     154  std::set<std::string> config;
     155  std::set<std::string> hidden;
     156  std::set<std::string> visible;
     157  std::set<std::string> inputfile;
     158
     159  std::multimap <std::string, std::string> MenuContainsActionMap;
     160  std::map <std::string, std::pair<std::string,std::string> > MenuDescription;
     161
     162  // instantiates and puts all known actions into the ActionRegistry
     163  void populateActions();
     164
     165  void queryCurrentValue(const char * name, class atom * &_T);
     166  void queryCurrentValue(const char * name, class element * &_T);
     167  void queryCurrentValue(const char * name, class molecule * &_T);
     168  void queryCurrentValue(const char * name, class Box &_T);
     169  void queryCurrentValue(const char * name, class Vector &_T);
     170  void queryCurrentValue(const char * name, std::vector<atom *>&_T);
     171  void queryCurrentValue(const char * name, std::vector<element *>&_T);
     172  void queryCurrentValue(const char * name, std::vector<molecule *>&_T);
     173  template<typename T> void queryCurrentValue(const char * name, T &_T)
     174  {
     175    if (typeid( T ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr
     176      if (CurrentValue.find(name) == CurrentValue.end())
     177        throw MissingValueException(__FILE__, __LINE__);
     178      _T = lexical_cast<T>(CurrentValue[name].c_str());
     179      CurrentValue.erase(name);
     180    } else
     181      throw IllegalTypeException(__FILE__,__LINE__);
     182  }
     183  template<typename T> void queryCurrentValue(const char * name, std::vector<T> &_T)
     184  {
     185    T temp;
     186    if (typeid( std::vector<T> ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr
     187      if (CurrentValue.find(name) == CurrentValue.end())
     188        throw MissingValueException(__FILE__, __LINE__);
     189      std::istringstream stream(CurrentValue[name]);
     190      CurrentValue.erase(name);
     191      while (!stream.fail()) {
     192        stream >> temp >> std::ws;
     193        _T.push_back(temp);
     194      }
     195    } else
     196      throw IllegalTypeException(__FILE__,__LINE__);
     197  }
     198
     199  void setCurrentValue(const char * name, class atom * &_T);
     200  void setCurrentValue(const char * name, class element * &_T);
     201  void setCurrentValue(const char * name, class molecule * &_T);
     202  void setCurrentValue(const char * name, class Box &_T);
     203  void setCurrentValue(const char * name, class Vector &_T);
     204  void setCurrentValue(const char * name, std::vector<atom *>&_T);
     205  void setCurrentValue(const char * name, std::vector<element *>&_T);
     206  void setCurrentValue(const char * name, std::vector<molecule *>&_T);
     207  template<class T> void setCurrentValue(const char * name, T &_T)
     208  {
     209    std::ostringstream stream;
     210    if (typeid( T ) == *TypeMap[name]) {  // constructor of type_info is private, hence can only store by ref or ptr
     211      stream << _T;
     212      CurrentValue[name] = stream.str();
     213    } else
     214      throw IllegalTypeException(__FILE__,__LINE__);
     215  }
     216  template<class T> void setCurrentValue(const char * name, std::vector<T> &_T)
     217  {
     218    std::ostringstream stream;
     219    if (typeid( std::vector<T> ) == *TypeMap[name]) {  // constructor of type_info is private, hence can only store by ref or ptr
     220      std::ostringstream stream;
     221      for (typename std::vector<T>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
     222        stream << (*iter) << " ";
     223      }
     224      CurrentValue[name] = stream.str();
     225    } else
     226      throw IllegalTypeException(__FILE__,__LINE__);
     227  }
     228
    46229
    47230private:
     
    51234
    52235  // lookup list from our configs to the ones of CommandLineParser
    53   map< set<std::string> *, po::options_description *> CmdParserLookup;
     236  std::map< std::set<std::string> *, po::options_description *> CmdParserLookup;
    54237
    55238  // map of the action names and their description
    56   map<std::string, std::string> DefaultValue;
    57   map<std::string, std::string> DescriptionMap;
    58   map<std::string, std::string> ShortFormMap;
    59   map<std::string, enum OptionTypes > TypeMap;
     239  std::map<std::string, std::string> CurrentValue;
     240  std::map<std::string, std::string> DescriptionMap;
     241  std::map<std::string, std::string> ShortFormMap;
     242  std::map<std::string, const std::type_info * > TypeMap;
     243  std::map<const std::type_info *, enum OptionTypes > TypeEnumMap;
    60244};
    61245
  • src/Actions/MethodAction.cpp

    r06f4ef6 rb6da28  
    2626{}
    2727
     28Dialog* MethodAction::fillDialog(Dialog *dialog) {
     29  ASSERT(dialog,"No Dialog given when filling action dialog");
     30  return dialog;
     31}
     32
    2833
    2934Action::state_ptr MethodAction::performCall() {
  • src/Actions/MethodAction.hpp

    r06f4ef6 rb6da28  
    2525  virtual bool shouldUndo();
    2626
     27protected:
     28  virtual Dialog * fillDialog(Dialog *dialog);
    2729private:
    2830  virtual Action::state_ptr performCall();
  • src/Actions/MoleculeAction/BondFileAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/MoleculeAction/BondFileAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "log.hpp"
     13#include "molecule.hpp"
     14#include "verbose.hpp"
     15#include "World.hpp"
    1116
    1217#include <iostream>
     
    1823#include "UIElements/UIFactory.hpp"
    1924#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2126
    22 #include "atom.hpp"
    23 #include "bondgraph.hpp"
    24 #include "config.hpp"
    25 #include "defs.hpp"
    26 #include "log.hpp"
    27 #include "molecule.hpp"
    28 #include "vector.hpp"
    29 #include "World.hpp"
    3027
    3128/****** MoleculeBondFileAction *****/
     
    5249{}
    5350
     51void MoleculeBondFile(std::string &bondfile) {
     52  ValueStorage::getInstance().setCurrentValue(MoleculeBondFileAction::NAME, bondfile);
     53  ActionRegistry::getInstance().getActionByName(MoleculeBondFileAction::NAME)->call(Action::NonInteractive);
     54};
     55
     56Dialog* MoleculeBondFileAction::fillDialog(Dialog *dialog) {
     57  ASSERT(dialog,"No Dialog given when filling action dialog");
     58
     59  dialog->queryString(NAME, MapOfActions::getInstance().getDescription(NAME));
     60
     61  return dialog;
     62}
     63
    5464Action::state_ptr MoleculeBondFileAction::performCall() {
    5565  string filename;
    56   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5766  molecule *mol = NULL;
    5867
    59   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    60   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     68  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    6169
    62   if(dialog->display()) {
     70  if(World::getInstance().countSelectedMolecules() == 1) {
     71    mol = World::getInstance().beginMoleculeSelection()->second;
    6372    DoLog(0) && (Log() << Verbose(0) << "Parsing bonds from " << filename << "." << endl);
    6473    ifstream input(filename.c_str());
    6574    mol->CreateAdjacencyListFromDbondFile(&input);
    6675    input.close();
    67     delete dialog;
    6876    return Action::success;
    69   }
    70   delete dialog;
    71   return Action::failure;
     77  } else
     78    return Action::failure;
    7279}
    7380
  • src/Actions/MoleculeAction/BondFileAction.hpp

    r06f4ef6 rb6da28  
    1414class MoleculeListClass;
    1515
     16void MoleculeBondFile(std::string &bondfile);
     17
    1618class MoleculeBondFileAction : public Action {
     19  friend void MoleculeBondFile(std::string &bondfile);
     20
    1721public:
    1822  MoleculeBondFileAction();
     
    2327
    2428  virtual const std::string getName();
     29protected:
     30  virtual Dialog * fillDialog(Dialog *dialog);
    2531private:
    2632  virtual Action::state_ptr performCall();
  • src/Actions/MoleculeAction/ChangeNameAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/MoleculeAction/ChangeNameAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "atom.hpp"
     13#include "molecule.hpp"
    1114
    1215#include <iostream>
     
    1720#include "UIElements/UIFactory.hpp"
    1821#include "UIElements/Dialog.hpp"
    19 #include "Actions/MapOfActions.hpp"
    20 
    21 #include "atom.hpp"
    22 #include "molecule.hpp"
     22#include "UIElements/ValueStorage.hpp"
    2323
    2424/****** MoleculeChangeNameAction *****/
     
    3636};
    3737
    38 const char MoleculeChangeNameAction::NAME[] = "Change filename of Molecule";
     38const char MoleculeChangeNameAction::NAME[] = "change-molname";
    3939
    4040MoleculeChangeNameAction::MoleculeChangeNameAction() :
     
    4545{}
    4646
     47void MoleculeChangeName(std::string &name) {
     48  ValueStorage::getInstance().setCurrentValue(MoleculeChangeNameAction::NAME, name);
     49  ActionRegistry::getInstance().getActionByName(MoleculeChangeNameAction::NAME)->call(Action::NonInteractive);
     50};
     51
     52Dialog* MoleculeChangeNameAction::fillDialog(Dialog *dialog) {
     53  ASSERT(dialog,"No Dialog given when filling action dialog");
     54
     55  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     56
     57  return dialog;
     58}
     59
    4760Action::state_ptr MoleculeChangeNameAction::performCall() {
    4861  string filename;
    4962  molecule *mol = NULL;
    50   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5163
    52   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
    53   dialog->queryString("Enter name: ",&filename);
     64  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    5465
    55   if(dialog->display()) {
     66  if (World::getInstance().countSelectedMolecules() == 1) {
     67    mol = World::getInstance().beginMoleculeSelection()->second;
    5668    string oldName = mol->getName();
    5769    mol->setName(filename);
    58     delete dialog;
    5970    return Action::state_ptr(new MoleculeChangeNameState(mol,oldName));
    60   }
    61   delete dialog;
    62   return Action::failure;
     71  } else
     72    return Action::failure;
    6373}
    6474
  • src/Actions/MoleculeAction/ChangeNameAction.hpp

    r06f4ef6 rb6da28  
    1414class MoleculeListClass;
    1515
     16void MoleculeChangeName(std::string &name);
     17
    1618class MoleculeChangeNameAction : public Action {
     19  friend void MoleculeChangeName(std::string &name);
     20
    1721public:
    1822  MoleculeChangeNameAction();
     
    2327
    2428  virtual const std::string getName();
     29protected:
     30  virtual Dialog * fillDialog(Dialog *dialog);
    2531private:
    2632  virtual Action::state_ptr performCall();
  • src/Actions/MoleculeAction/FillWithMoleculeAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/MoleculeAction/FillWithMoleculeAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "atom.hpp"
     13#include "bondgraph.hpp"
     14#include "boundary.hpp"
     15#include "config.hpp"
     16#include "molecule.hpp"
     17#include "verbose.hpp"
     18#include "World.hpp"
     19
    1120
    1221#include <iostream>
     
    1726#include "UIElements/UIFactory.hpp"
    1827#include "UIElements/Dialog.hpp"
    19 #include "Actions/MapOfActions.hpp"
    20 
    21 #include "atom.hpp"
    22 #include "bondgraph.hpp"
    23 #include "boundary.hpp"
    24 #include "config.hpp"
    25 #include "defs.hpp"
    26 #include "molecule.hpp"
    27 #include "periodentafel.hpp"
    28 #include "vector.hpp"
    29 #include "verbose.hpp"
    30 #include "World.hpp"
     28#include "UIElements/ValueStorage.hpp"
    3129
    3230/****** MoleculeFillWithMoleculeAction *****/
     
    5351{}
    5452
     53void MoleculeFillWithMolecule(std::string &fillername, Vector &distances, Vector &lengths, double MaxDistance, bool DoRotate) {
     54  ValueStorage::getInstance().setCurrentValue(MoleculeFillWithMoleculeAction::NAME, fillername);
     55  ValueStorage::getInstance().setCurrentValue("distances", distances);
     56  ValueStorage::getInstance().setCurrentValue("lengths", lengths);
     57  ValueStorage::getInstance().setCurrentValue("DoRotate", MaxDistance);
     58  ValueStorage::getInstance().setCurrentValue("MaxDistance", DoRotate);
     59  ActionRegistry::getInstance().getActionByName(MoleculeFillWithMoleculeAction::NAME)->call(Action::NonInteractive);
     60};
     61
     62Dialog* MoleculeFillWithMoleculeAction::fillDialog(Dialog *dialog) {
     63  ASSERT(dialog,"No Dialog given when filling action dialog");
     64
     65  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     66  dialog->queryVector("distances", false, ValueStorage::getInstance().getDescription("distances"));
     67  dialog->queryVector("lengths", false, ValueStorage::getInstance().getDescription("lengths"));
     68  dialog->queryBoolean("DoRotate", ValueStorage::getInstance().getDescription("DoRotate"));
     69  dialog->queryDouble("MaxDistance", ValueStorage::getInstance().getDescription("MaxDistance"));
     70
     71  return dialog;
     72}
     73
    5574Action::state_ptr MoleculeFillWithMoleculeAction::performCall() {
    5675  string filename;
    57   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5876  Vector distances;
    5977  Vector lengths;
     
    6179  bool DoRotate = false;
    6280
    63   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    64   dialog->queryVector("distances", &distances, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("distances"));
    65   dialog->queryVector("lengths", &lengths, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("lengths"));
    66   dialog->queryBoolean("DoRotate", &DoRotate, MapOfActions::getInstance().getDescription("DoRotate"));
    67   dialog->queryDouble("MaxDistance", &MaxDistance, MapOfActions::getInstance().getDescription("MaxDistance"));
     81  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
     82  ValueStorage::getInstance().queryCurrentValue("distances", distances);
     83  ValueStorage::getInstance().queryCurrentValue("lengths", lengths);
     84  ValueStorage::getInstance().queryCurrentValue("DoRotate", DoRotate);
     85  ValueStorage::getInstance().queryCurrentValue("MaxDistance", MaxDistance);
    6886
    69   if(dialog->display()) {
    70     DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, lengths(" << lengths[0] << "," << lengths[1] << "," << lengths[2] << "), distances (" << distances[0] << "," << distances[1] << "," << distances[2] << "), MaxDistance " << MaxDistance << ", DoRotate " << DoRotate << "." << endl);
    71     // construct water molecule
    72     molecule *filler = World::getInstance().createMolecule();
    73     if (!filler->AddXYZFile(filename)) {
    74       DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << filename << "." << endl);
    75     }
    76     filler->SetNameFromFilename(filename.c_str());
    77     molecule *Filling = NULL;
     87  DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, lengths(" << lengths[0] << "," << lengths[1] << "," << lengths[2] << "), distances (" << distances[0] << "," << distances[1] << "," << distances[2] << "), MaxDistance " << MaxDistance << ", DoRotate " << DoRotate << "." << endl);
     88  // construct water molecule
     89  molecule *filler = World::getInstance().createMolecule();
     90  if (!filler->AddXYZFile(filename)) {
     91    DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << filename << "." << endl);
     92  }
     93  filler->SetNameFromFilename(filename.c_str());
     94  molecule *Filling = NULL;
    7895//    atom *first = NULL, *second = NULL, *third = NULL;
    7996//    first = World::getInstance().createAtom();
     
    91108//    filler->AddBond(first, third, 1);
    92109//    filler->AddBond(second, third, 1);
    93     World::getInstance().getConfig()->BG->ConstructBondGraph(filler);
     110  World::getInstance().getConfig()->BG->ConstructBondGraph(filler);
    94111//    filler->SetNameFromFilename("water");
    95     // call routine
    96     double distance[NDIM];
    97     for (int i=0;i<NDIM;i++)
    98       distance[i] = distances[i];
    99     Filling = FillBoxWithMolecule(World::getInstance().getMolecules(), filler, *(World::getInstance().getConfig()), MaxDistance, distance, lengths[0], lengths[1], lengths[2], DoRotate);
    100     if (Filling != NULL) {
    101       Filling->ActiveFlag = false;
    102       World::getInstance().getMolecules()->insert(Filling);
    103     }
    104     World::getInstance().destroyMolecule(filler);
     112  // call routine
     113  double distance[NDIM];
     114  for (int i=0;i<NDIM;i++)
     115    distance[i] = distances[i];
     116  Filling = FillBoxWithMolecule(World::getInstance().getMolecules(), filler, *(World::getInstance().getConfig()), MaxDistance, distance, lengths[0], lengths[1], lengths[2], DoRotate);
     117  if (Filling != NULL) {
     118    Filling->ActiveFlag = false;
     119    World::getInstance().getMolecules()->insert(Filling);
     120  }
     121  for (molecule::iterator iter = filler->begin(); !filler->empty(); iter = filler->begin()) {
     122    atom *Walker = *iter;
     123    filler->erase(iter);
     124    World::getInstance().destroyAtom(Walker);
     125  }
     126  World::getInstance().destroyMolecule(filler);
    105127
    106     delete dialog;
    107     return Action::success;
    108   }
    109   delete dialog;
    110   return Action::failure;
     128  return Action::success;
    111129}
    112130
  • src/Actions/MoleculeAction/FillWithMoleculeAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212#include "Actions/Process.hpp"
     13#include "vector.hpp"
    1314
    1415class MoleculeListClass;
    1516
     17void MoleculeFillWithMolecule(std::string &fillername, Vector &distances, Vector &lengths, double MaxDistance, bool DoRotate);
     18
    1619class MoleculeFillWithMoleculeAction : public Action {
     20  friend void MoleculeFillWithMolecule(std::string &fillername, Vector &distances, Vector &lengths, double MaxDistance, bool DoRotate);
     21
    1722public:
    1823  MoleculeFillWithMoleculeAction();
     
    2328
    2429  virtual const std::string getName();
     30protected:
     31  virtual Dialog * fillDialog(Dialog *dialog);
    2532private:
    2633  virtual Action::state_ptr performCall();
  • src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "atom.hpp"
     13#include "defs.hpp"
     14#include "log.hpp"
     15#include "molecule.hpp"
     16#include "verbose.hpp"
     17#include "World.hpp"
    1118
    1219#include <iostream>
     
    1825#include "UIElements/UIFactory.hpp"
    1926#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2128
    22 #include "atom.hpp"
    23 #include "defs.hpp"
    24 #include "log.hpp"
    25 #include "molecule.hpp"
    26 #include "verbose.hpp"
    27 #include "World.hpp"
    2829
    2930/****** MoleculeLinearInterpolationofTrajectoriesAction *****/
     
    5051{}
    5152
     53void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping) {
     54  ValueStorage::getInstance().setCurrentValue(MoleculeLinearInterpolationofTrajectoriesAction::NAME, filename);
     55  ValueStorage::getInstance().setCurrentValue("start-step", start);
     56  ValueStorage::getInstance().setCurrentValue("end-step", end);
     57  ValueStorage::getInstance().setCurrentValue("id-mapping", IdMapping);
     58  ActionRegistry::getInstance().getActionByName(MoleculeLinearInterpolationofTrajectoriesAction::NAME)->call(Action::NonInteractive);
     59};
     60
     61Dialog* MoleculeLinearInterpolationofTrajectoriesAction::fillDialog(Dialog *dialog) {
     62  ASSERT(dialog,"No Dialog given when filling action dialog");
     63
     64  dialog->queryString(NAME, MapOfActions::getInstance().getDescription(NAME));
     65  dialog->queryInt("start-step", MapOfActions::getInstance().getDescription("start-step"));
     66  dialog->queryInt("end-step", MapOfActions::getInstance().getDescription("end-step"));
     67  dialog->queryBoolean("id-mapping", MapOfActions::getInstance().getDescription("id-mapping"));
     68
     69  return dialog;
     70}
     71
    5272Action::state_ptr MoleculeLinearInterpolationofTrajectoriesAction::performCall() {
    5373  string filename;
    54   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5574  molecule *mol = NULL;
    5675  int start = -1;
     
    5877  bool IdMapping = true;
    5978
     79  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
     80  ValueStorage::getInstance().queryCurrentValue("start-step", start);
     81  ValueStorage::getInstance().queryCurrentValue("end-step", end);
     82  ValueStorage::getInstance().queryCurrentValue("id-mapping", IdMapping);
    6083
    61   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    62   dialog->queryInt("start-step", &start, MapOfActions::getInstance().getDescription("start-step"));
    63   dialog->queryInt("end-step", &end, MapOfActions::getInstance().getDescription("end-step"));
    64   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    65   dialog->queryBoolean("id-mapping", &IdMapping, MapOfActions::getInstance().getDescription("id-mapping"));
    66 
    67   if(dialog->display()) {
     84  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     85    mol = iter->second;
    6886    DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << start << " and " << end << "." << endl);
    6987    if (IdMapping)
    7088      DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl);
    71     char outputname[MAXSTRINGSIZE];
    72     strcpy(outputname, filename.c_str());
    73     // TODO: LinearInterpolationBetweenConfiguration should use stream, not the filename directly! (better for unit test)
    74     if (!mol->LinearInterpolationBetweenConfiguration(start, end, outputname, *(World::getInstance().getConfig()), IdMapping))
    75       DoLog(2) && (Log() << Verbose(2) << "Could not store " << outputname << " files." << endl);
     89    if (!mol->LinearInterpolationBetweenConfiguration(start, end, filename, *(World::getInstance().getConfig()), IdMapping))
     90      DoLog(2) && (Log() << Verbose(2) << "Could not store " << filename << " files." << endl);
    7691    else
    7792      DoLog(2) && (Log() << Verbose(2) << "Steps created and " << filename << " files stored." << endl);
    78     delete dialog;
    79     return Action::success;
    8093  }
    81   delete dialog;
    82   return Action::failure;
     94  return Action::success;
    8395}
    8496
  • src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp

    r06f4ef6 rb6da28  
    1414class MoleculeListClass;
    1515
     16void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping);
     17
    1618class MoleculeLinearInterpolationofTrajectoriesAction : public Action {
     19  friend void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping);
     20
    1721public:
    1822  MoleculeLinearInterpolationofTrajectoriesAction();
     
    2327
    2428  virtual const std::string getName();
     29protected:
     30  virtual Dialog * fillDialog(Dialog *dialog);
    2531private:
    2632  virtual Action::state_ptr performCall();
  • src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "log.hpp"
     13#include "molecule.hpp"
     14#include "verbose.hpp"
     15
    1116
    1217#include <iostream>
     
    1823#include "UIElements/UIFactory.hpp"
    1924#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
    21 
    22 #include "log.hpp"
    23 #include "molecule.hpp"
    24 #include "verbose.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2526
    2627/****** MoleculeRotateToPrincipalAxisSystemAction *****/
     
    4748{}
    4849
     50void MoleculeRotateToPrincipalAxisSystem() {
     51  ActionRegistry::getInstance().getActionByName(MoleculeRotateToPrincipalAxisSystemAction::NAME)->call(Action::NonInteractive);
     52};
     53
     54Dialog* MoleculeRotateToPrincipalAxisSystemAction::fillDialog(Dialog *dialog) {
     55  ASSERT(dialog,"No Dialog given when filling action dialog");
     56
     57  dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
     58
     59  return dialog;
     60}
     61
    4962Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performCall() {
    50   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5163  molecule *mol = NULL;
    5264
    53   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
    54 
    55   if(dialog->display()) {
     65  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     66    mol = iter->second;
    5667    DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
    5768    mol->PrincipalAxisSystem(true);
    58     delete dialog;
    59     return Action::success;
    6069  }
    61   delete dialog;
    62   return Action::failure;
     70  return Action::success;
    6371}
    6472
  • src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp

    r06f4ef6 rb6da28  
    1414class MoleculeListClass;
    1515
     16void MoleculeRotateToPrincipalAxisSystem();
     17
    1618class MoleculeRotateToPrincipalAxisSystemAction : public Action {
     19  friend void MoleculeRotateToPrincipalAxisSystem();
     20
    1721public:
    1822  MoleculeRotateToPrincipalAxisSystemAction();
     
    2327
    2428  virtual const std::string getName();
     29protected:
     30  virtual Dialog * fillDialog(Dialog *dialog);
    2531private:
    2632  virtual Action::state_ptr performCall();
  • src/Actions/MoleculeAction/SaveAdjacencyAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "bondgraph.hpp"
     13#include "config.hpp"
     14#include "log.hpp"
     15#include "molecule.hpp"
     16#include "verbose.hpp"
     17#include "World.hpp"
     18
    1119
    1220#include <iostream>
     
    1826#include "UIElements/UIFactory.hpp"
    1927#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
    21 
    22 #include "atom.hpp"
    23 #include "bondgraph.hpp"
    24 #include "config.hpp"
    25 #include "defs.hpp"
    26 #include "log.hpp"
    27 #include "molecule.hpp"
    28 #include "vector.hpp"
    29 #include "verbose.hpp"
    30 #include "World.hpp"
     28#include "UIElements/ValueStorage.hpp"
    3129
    3230/****** MoleculeSaveAdjacencyAction *****/
     
    5351{}
    5452
     53void MoleculeSaveAdjacency(std::string &adjacencyfile) {
     54  ValueStorage::getInstance().setCurrentValue(MoleculeSaveAdjacencyAction::NAME, adjacencyfile);
     55  ActionRegistry::getInstance().getActionByName(MoleculeSaveAdjacencyAction::NAME)->call(Action::NonInteractive);
     56};
     57
     58Dialog* MoleculeSaveAdjacencyAction::fillDialog(Dialog *dialog) {
     59  ASSERT(dialog,"No Dialog given when filling action dialog");
     60
     61  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     62
     63  return dialog;
     64}
     65
    5566Action::state_ptr MoleculeSaveAdjacencyAction::performCall() {
    5667  string filename;
    57   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5868  molecule *mol = NULL;
    5969
    60   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    61   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     70  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    6271
    63   if(dialog->display()) {
     72  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     73    mol = iter->second;
    6474    DoLog(0) && (Log() << Verbose(0) << "Storing adjacency to path " << filename << "." << endl);
    6575    World::getInstance().getConfig()->BG->ConstructBondGraph(mol);
    6676    // TODO: sollte stream nicht filename benutzen, besser fuer unit test
    67     char outputname[MAXSTRINGSIZE];
    68     strcpy(outputname, filename.c_str());
    69     mol->StoreAdjacencyToFile(NULL, outputname);
    70     delete dialog;
    71     return Action::success;
     77    mol->StoreAdjacencyToFile(filename);
    7278  }
    73   delete dialog;
    74   return Action::failure;
     79  return Action::success;
    7580}
    7681
  • src/Actions/MoleculeAction/SaveAdjacencyAction.hpp

    r06f4ef6 rb6da28  
    1414class MoleculeListClass;
    1515
     16void MoleculeSaveAdjacency(std::string &adjacencyfile);
     17
    1618class MoleculeSaveAdjacencyAction : public Action {
     19  friend void MoleculeSaveAdjacency(std::string &adjacencyfile);
     20
    1721public:
    1822  MoleculeSaveAdjacencyAction();
     
    2327
    2428  virtual const std::string getName();
     29protected:
     30  virtual Dialog * fillDialog(Dialog *dialog);
    2531private:
    2632  virtual Action::state_ptr performCall();
  • src/Actions/MoleculeAction/SaveBondsAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/MoleculeAction/SaveBondsAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "bondgraph.hpp"
     13#include "config.hpp"
     14#include "log.hpp"
     15#include "molecule.hpp"
     16#include "verbose.hpp"
     17#include "World.hpp"
     18
    1119
    1220#include <iostream>
     
    1826#include "UIElements/UIFactory.hpp"
    1927#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
    21 
    22 #include "atom.hpp"
    23 #include "bondgraph.hpp"
    24 #include "config.hpp"
    25 #include "defs.hpp"
    26 #include "log.hpp"
    27 #include "molecule.hpp"
    28 #include "vector.hpp"
    29 #include "verbose.hpp"
    30 #include "World.hpp"
     28#include "UIElements/ValueStorage.hpp"
    3129
    3230/****** MoleculeSaveBondsAction *****/
     
    5351{}
    5452
     53void MoleculeSaveBonds(std::string &bondsfile) {
     54  ValueStorage::getInstance().setCurrentValue(MoleculeSaveBondsAction::NAME, bondsfile);
     55  ActionRegistry::getInstance().getActionByName(MoleculeSaveBondsAction::NAME)->call(Action::NonInteractive);
     56};
     57
     58Dialog* MoleculeSaveBondsAction::fillDialog(Dialog *dialog) {
     59  ASSERT(dialog,"No Dialog given when filling action dialog");
     60
     61  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     62
     63  return dialog;
     64}
     65
    5566Action::state_ptr MoleculeSaveBondsAction::performCall() {
    5667  string filename;
    57   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5868  molecule *mol = NULL;
    5969
    60   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    61   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     70  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    6271
    63   if(dialog->display()) {
     72  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     73    mol = iter->second;
    6474    DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << filename << "." << endl);
    6575    World::getInstance().getConfig()->BG->ConstructBondGraph(mol);
    66     // TODO: sollte stream, nicht filenamen direkt nutzen, beser fuer unit tests
    67     char outputname[MAXSTRINGSIZE];
    68     strcpy(outputname, filename.c_str());
    69     mol->StoreBondsToFile(NULL, outputname);
    70     delete dialog;
    71     return Action::success;
     76    // TODO: sollte stream, nicht filenamen direkt nutzen, besser fuer unit tests
     77    mol->StoreBondsToFile(filename);
    7278  }
    73   delete dialog;
    74   return Action::failure;
     79  return Action::success;
    7580}
    7681
  • src/Actions/MoleculeAction/SaveBondsAction.hpp

    r06f4ef6 rb6da28  
    1414class MoleculeListClass;
    1515
     16void MoleculeSaveBonds(std::string &bondsfile);
     17
    1618class MoleculeSaveBondsAction : public Action {
     19  friend void MoleculeSaveBonds(std::string &bondsfile);
     20
    1721public:
    1822  MoleculeSaveBondsAction();
     
    2327
    2428  virtual const std::string getName();
     29protected:
     30  virtual Dialog * fillDialog(Dialog *dialog);
    2531private:
    2632  virtual Action::state_ptr performCall();
  • src/Actions/MoleculeAction/SaveTemperatureAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/MoleculeAction/SaveTemperatureAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "log.hpp"
     13#include "molecule.hpp"
     14#include "verbose.hpp"
     15#include "World.hpp"
    1116
    1217#include <iostream>
     
    1823#include "UIElements/UIFactory.hpp"
    1924#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
    21 
    22 #include "atom.hpp"
    23 #include "log.hpp"
    24 #include "molecule.hpp"
    25 #include "verbose.hpp"
    26 #include "World.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2726
    2827/****** MoleculeSaveTemperatureAction *****/
     
    4948{}
    5049
     50void MoleculeSaveTemperature(std::string &temperaturefile) {
     51  ValueStorage::getInstance().setCurrentValue(MoleculeSaveTemperatureAction::NAME, temperaturefile);
     52  ActionRegistry::getInstance().getActionByName(MoleculeSaveTemperatureAction::NAME)->call(Action::NonInteractive);
     53};
     54
     55Dialog* MoleculeSaveTemperatureAction::fillDialog(Dialog *dialog) {
     56  ASSERT(dialog,"No Dialog given when filling action dialog");
     57
     58  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     59
     60  return dialog;
     61}
     62
    5163Action::state_ptr MoleculeSaveTemperatureAction::performCall() {
    5264  string filename;
    53   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5465  molecule *mol = NULL;
    5566
    56   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    57   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     67  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    5868
    59   if(dialog->display()) {
     69  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     70    mol = iter->second;
    6071    DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl);
    6172    ofstream output;
     
    6677      DoLog(2) && (Log() << Verbose(2) << "File stored." << endl);
    6778    output.close();
    68     delete dialog;
    69     return Action::success;
    7079  }
    71   delete dialog;
    72   return Action::failure;
     80  return Action::success;
    7381}
    7482
  • src/Actions/MoleculeAction/SaveTemperatureAction.hpp

    r06f4ef6 rb6da28  
    1414class MoleculeListClass;
    1515
     16void MoleculeSaveTemperature(std::string &temperaturefile);
     17
    1618class MoleculeSaveTemperatureAction : public Action {
     19  friend void MoleculeSaveTemperature(std::string &temperaturefile);
     20
    1721public:
    1822  MoleculeSaveTemperatureAction();
     
    2327
    2428  virtual const std::string getName();
     29protected:
     30  virtual Dialog * fillDialog(Dialog *dialog);
    2531private:
    2632  virtual Action::state_ptr performCall();
  • src/Actions/MoleculeAction/SuspendInWaterAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/MoleculeAction/SuspendInWaterAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "boundary.hpp"
     13#include "config.hpp"
     14#include "log.hpp"
     15#include "verbose.hpp"
     16#include "World.hpp"
    1117
    1218#include <iostream>
     
    1723#include "UIElements/UIFactory.hpp"
    1824#include "UIElements/Dialog.hpp"
    19 #include "Actions/MapOfActions.hpp"
    20 
    21 #include "atom.hpp"
    22 #include "boundary.hpp"
    23 #include "config.hpp"
    24 #include "log.hpp"
    25 #include "config.hpp"
    26 #include "World.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2726
    2827/****** MoleculeSuspendInWaterAction *****/
     
    4948{}
    5049
     50void MoleculeSuspendInWater(double density) {
     51  ValueStorage::getInstance().setCurrentValue(MoleculeSuspendInWaterAction::NAME, density);
     52  ActionRegistry::getInstance().getActionByName(MoleculeSuspendInWaterAction::NAME)->call(Action::NonInteractive);
     53};
     54
     55Dialog* MoleculeSuspendInWaterAction::fillDialog(Dialog *dialog) {
     56  ASSERT(dialog,"No Dialog given when filling action dialog");
     57
     58  dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
     59
     60  return dialog;
     61}
     62
    5163Action::state_ptr MoleculeSuspendInWaterAction::performCall() {
    5264  molecule *mol = NULL;
    53   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5465  double density;
    5566  double volume = 0.;
    5667
    57   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
    58   dialog->queryDouble("density", &density, MapOfActions::getInstance().getDescription("density"));
     68  ValueStorage::getInstance().queryCurrentValue(NAME, density);
    5969
    60   if(dialog->display()) {
     70  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     71    mol = iter->second;
    6172    DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.");
    6273    if (density < 1.0) {
     
    6475    } else {
    6576      PrepareClustersinWater(World::getInstance().getConfig(), mol, volume, density);  // if volume == 0, will calculate from ConvexEnvelope
    66       delete dialog;
    67       return Action::success;
    6877    }
    6978  }
    70   delete dialog;
    71   return Action::failure;
     79  return Action::success;
    7280}
    7381
  • src/Actions/MoleculeAction/SuspendInWaterAction.hpp

    r06f4ef6 rb6da28  
    1414class MoleculeListClass;
    1515
     16void MoleculeSuspendInWater(double density);
     17
    1618class MoleculeSuspendInWaterAction : public Action {
     19  friend void MoleculeSuspendInWater(double density);
     20
    1721public:
    1822  MoleculeSuspendInWaterAction();
     
    2327
    2428  virtual const std::string getName();
     29protected:
     30  virtual Dialog * fillDialog(Dialog *dialog);
    2531private:
    2632  virtual Action::state_ptr performCall();
  • src/Actions/MoleculeAction/TranslateAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/MoleculeAction/TranslateAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "log.hpp"
     13#include "molecule.hpp"
     14#include "vector.hpp"
     15#include "verbose.hpp"
     16#include "World.hpp"
    1117
    1218#include <iostream>
     
    1824#include "UIElements/UIFactory.hpp"
    1925#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
    21 
    22 #include "atom.hpp"
    23 #include "log.hpp"
    24 #include "molecule.hpp"
    25 #include "verbose.hpp"
    26 #include "World.hpp"
     26#include "UIElements/ValueStorage.hpp"
    2727
    2828/****** MoleculeTranslateAction *****/
     
    4949{}
    5050
     51void MoleculeTranslate(Vector &x, bool periodic) {
     52  ValueStorage::getInstance().setCurrentValue(MoleculeTranslateAction::NAME, x);
     53  ValueStorage::getInstance().setCurrentValue("periodic", periodic);
     54  ActionRegistry::getInstance().getActionByName(MoleculeTranslateAction::NAME)->call(Action::NonInteractive);
     55};
     56
     57Dialog* MoleculeTranslateAction::fillDialog(Dialog *dialog) {
     58  ASSERT(dialog,"No Dialog given when filling action dialog");
     59
     60  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
     61  dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
     62
     63  return dialog;
     64}
     65
    5166Action::state_ptr MoleculeTranslateAction::performCall() {
    52   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5367  molecule *mol = NULL;
    5468  Vector x;
    5569  bool periodic = false;
    5670
    57   dialog->queryVector(NAME, &x, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));
    58   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    59   dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic"));
    60   cout << "pre-dialog" << endl;
     71  ValueStorage::getInstance().queryCurrentValue(NAME, x);
     72  ValueStorage::getInstance().queryCurrentValue("periodic", periodic);
    6173
    62   if(dialog->display()) {
    63     cout << "post-dialog" << endl;
     74  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     75    mol = iter->second;
    6476    DoLog(1) && (Log() << Verbose(1) << "Translating all ions by given vector." << endl);
    6577    if (periodic)
     
    6779    else
    6880      mol->Translate((const Vector *)&x);
    69     delete dialog;
    70     return Action::success;
    7181  }
    72   delete dialog;
    73   return Action::failure;
     82  return Action::success;
    7483}
    7584
  • src/Actions/MoleculeAction/TranslateAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212#include "Actions/Process.hpp"
     13#include "vector.hpp"
    1314
    1415class MoleculeListClass;
    1516
     17void MoleculeTranslate(Vector &x, bool periodic);
     18
    1619class MoleculeTranslateAction : public Action {
     20  friend void MoleculeTranslate(Vector &x, bool periodic);
     21
    1722public:
    1823  MoleculeTranslateAction();
     
    2328
    2429  virtual const std::string getName();
     30protected:
     31  virtual Dialog * fillDialog(Dialog *dialog);
    2532private:
    2633  virtual Action::state_ptr performCall();
  • src/Actions/MoleculeAction/VerletIntegrationAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/MoleculeAction/VerletIntegrationAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "log.hpp"
     13#include "molecule.hpp"
     14#include "verbose.hpp"
     15#include "World.hpp"
    1116
    1217#include <iostream>
     
    1823#include "UIElements/UIFactory.hpp"
    1924#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
    21 
    22 #include "atom.hpp"
    23 #include "log.hpp"
    24 #include "molecule.hpp"
    25 #include "verbose.hpp"
    26 #include "World.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2726
    2827/****** MoleculeVerletIntegrationAction *****/
     
    4948{}
    5049
     50void MoleculeVerletIntegration(std::string &forcesfile) {
     51  ValueStorage::getInstance().setCurrentValue(MoleculeVerletIntegrationAction::NAME, forcesfile);
     52  ActionRegistry::getInstance().getActionByName(MoleculeVerletIntegrationAction::NAME)->call(Action::NonInteractive);
     53};
     54
     55Dialog* MoleculeVerletIntegrationAction::fillDialog(Dialog *dialog) {
     56  ASSERT(dialog,"No Dialog given when filling action dialog");
     57
     58  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     59
     60  return dialog;
     61}
     62
    5163Action::state_ptr MoleculeVerletIntegrationAction::performCall() {
    5264  string filename;
    53   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5465  molecule *mol = NULL;
    5566
    56   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    57   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     67  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    5868
    59   if(dialog->display()) {
     69  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     70    mol = iter->second;
    6071    DoLog(1) && (Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl);
    6172    // TODO: sollte besser stream nutzen, nicht filename direkt (es sei denn, ist prefix), besser fuer unit test
    6273    char outputname[MAXSTRINGSIZE];
    6374    strcpy(outputname, filename.c_str());
    64     if (!mol->VerletForceIntegration(outputname, *(World::getInstance().getConfig())))
     75    if (!mol->VerletForceIntegration(outputname, *(World::getInstance().getConfig()), 0))
    6576      DoLog(2) && (Log() << Verbose(2) << "File not found." << endl);
    6677    else
    6778      DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl);
    68 
    69     delete dialog;
    70     return Action::success;
    7179  }
    72   delete dialog;
    73   return Action::failure;
     80  return Action::success;
    7481}
    7582
  • src/Actions/MoleculeAction/VerletIntegrationAction.hpp

    r06f4ef6 rb6da28  
    1414class MoleculeListClass;
    1515
     16void MoleculeVerletIntegration(std::string &forcesfile);
     17
    1618class MoleculeVerletIntegrationAction : public Action {
     19  friend void MoleculeVerletIntegration(std::string &forcesfile);
     20
    1721public:
    1822  MoleculeVerletIntegrationAction();
     
    2327
    2428  virtual const std::string getName();
     29protected:
     30  virtual Dialog * fillDialog(Dialog *dialog);
    2531private:
    2632  virtual Action::state_ptr performCall();
  • src/Actions/ParserAction/LoadXyzAction.cpp

    r06f4ef6 rb6da28  
    88#include "Helpers/MemDebug.hpp"
    99
     10using namespace std;
     11
    1012#include "Actions/ParserAction/LoadXyzAction.hpp"
     13#include "Actions/ActionRegistry.hpp"
    1114#include "Parser/XyzParser.hpp"
     15#include "atom.hpp"
     16#include "log.hpp"
     17#include "molecule.hpp"
     18#include "verbose.hpp"
     19#include "World.hpp"
    1220
    1321#include <iostream>
     22#include <set>
    1423#include <string>
    15 
    16 using namespace std;
     24#include <vector>
    1725
    1826#include "UIElements/UIFactory.hpp"
    1927#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
    21 
    22 #include "atom.hpp"
    23 #include "molecule.hpp"
     28#include "UIElements/ValueStorage.hpp"
    2429
    2530/****** ParserLoadXyzAction *****/
     
    3742//};
    3843
    39 const char ParserLoadXyzAction::NAME[] = "LoadXyz";
     44const char ParserLoadXyzAction::NAME[] = "parse-xyz";
    4045
    4146ParserLoadXyzAction::ParserLoadXyzAction() :
     
    4651{}
    4752
     53void ParserLoadXyz(std::string &filename) {
     54  ValueStorage::getInstance().setCurrentValue(ParserLoadXyzAction::NAME, filename);
     55  ActionRegistry::getInstance().getActionByName(ParserLoadXyzAction::NAME)->call(Action::NonInteractive);
     56};
     57
     58Dialog* ParserLoadXyzAction::fillDialog(Dialog *dialog) {
     59  ASSERT(dialog,"No Dialog given when filling action dialog");
     60
     61  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     62
     63  return dialog;
     64}
     65
    4866Action::state_ptr ParserLoadXyzAction::performCall() {
    4967  string filename;
    50   XyzParser parser;
    51   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5268
    53   dialog->queryString("filename",&filename, "Filename of the xyz file");
     69  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    5470
    55   if(dialog->display()) {
    56     // parse xyz file
    57     ifstream input;
    58     input.open(filename.c_str());
    59     if (!input.fail())
    60       parser.load(&input);
    61     input.close();
     71  DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);
     72  // parse xyz file
     73  ifstream input;
     74  input.open(filename.c_str());
     75  if (!input.fail()) {
     76    // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include
     77    set <atom*> UniqueList;
     78    {
     79      vector<atom *> ListBefore = World::getInstance().getAllAtoms();
     80      for (vector<atom *>::iterator runner = ListBefore.begin();runner != ListBefore.end(); ++runner)
     81        UniqueList.insert(*runner);
     82    }
     83    XyzParser parser; // briefly instantiate a parser which is removed at end of focus
     84    parser.load(&input);
     85    {
     86      vector<atom *> ListAfter = World::getInstance().getAllAtoms();
     87      pair< set<atom *>::iterator, bool > Inserter;
     88      if (UniqueList.size() != ListAfter.size()) { // only create if new atoms have been parsed
     89        MoleculeListClass *molecules = World::getInstance().getMolecules();
     90        molecule *mol = World::getInstance().createMolecule();
     91        molecules->insert(mol);
     92        for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) {
     93          Inserter = UniqueList.insert(*runner);
     94          if (Inserter.second) { // if not present, then new (just parsed) atom, add ...
     95            cout << "Adding new atom " << **runner << " to new mol." << endl;
     96            mol->AddAtom(*runner);
     97          }
     98        }
     99        mol->doCountAtoms();
     100      } else {
     101        cout << "No atoms parsed?" << endl;
     102      }
     103    }
     104  } else {
     105    DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl);
    62106  }
    63   delete dialog;
    64   return Action::failure;
     107  input.close();
     108  return Action::success;
    65109}
    66110
  • src/Actions/ParserAction/LoadXyzAction.hpp

    r06f4ef6 rb6da28  
    1212#include "Actions/Process.hpp"
    1313
     14void ParserLoadXyz(std::string &filename);
     15
    1416class ParserLoadXyzAction : public Action {
     17  friend void ParserLoadXyz(std::string &filename);
     18
    1519public:
    1620  ParserLoadXyzAction();
     
    2125
    2226  virtual const std::string getName();
     27protected:
     28  virtual Dialog * fillDialog(Dialog *dialog);
    2329private:
    2430  virtual Action::state_ptr performCall();
  • src/Actions/ParserAction/SaveXyzAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/ParserAction/SaveXyzAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "Parser/XyzParser.hpp"
     13#include "atom.hpp"
     14#include "molecule.hpp"
    1215
    1316#include <iostream>
     
    1821#include "UIElements/UIFactory.hpp"
    1922#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
     23#include "UIElements/ValueStorage.hpp"
    2124
    22 #include "atom.hpp"
    23 #include "molecule.hpp"
    2425
    2526/****** ParserSaveXyzAction *****/
     
    4647{}
    4748
     49void ParserSaveXyz(std::string &filename) {
     50  ValueStorage::getInstance().setCurrentValue(ParserSaveXyzAction::NAME, filename);
     51  ActionRegistry::getInstance().getActionByName(ParserSaveXyzAction::NAME)->call(Action::NonInteractive);
     52};
     53
     54Dialog* ParserSaveXyzAction::fillDialog(Dialog *dialog) {
     55  ASSERT(dialog,"No Dialog given when filling action dialog");
     56
     57  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     58
     59  return dialog;
     60}
     61
    4862Action::state_ptr ParserSaveXyzAction::performCall() {
    4963  string filename;
    5064  XyzParser parser;
    51   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5265
    53   dialog->queryString("filename",&filename, "Filename of the xyz file");
     66  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    5467
    55   if(dialog->display()) {
    56     // store xyz file
    57     ofstream output;
    58     output.open(filename.c_str());
    59     if (!output.fail())
    60       parser.save(&output);
    61     output.close();
    62   }
    63   delete dialog;
     68  // store xyz file
     69  ofstream output;
     70  output.open(filename.c_str());
     71  if (!output.fail())
     72    parser.save(&output);
     73  output.close();
    6474  return Action::failure;
    6575}
  • src/Actions/ParserAction/SaveXyzAction.hpp

    r06f4ef6 rb6da28  
    1212#include "Actions/Process.hpp"
    1313
     14void ParserSaveXyz(std::string &filename);
     15
    1416class ParserSaveXyzAction : public Action {
     17  friend void ParserSaveXyz(std::string &filename);
     18
    1519public:
    1620  ParserSaveXyzAction();
     
    2125
    2226  virtual const std::string getName();
     27protected:
     28  virtual Dialog * fillDialog(Dialog *dialog);
    2329private:
    2430  virtual Action::state_ptr performCall();
  • src/Actions/Process.cpp

    r06f4ef6 rb6da28  
    1313
    1414Process::Process(int _maxSteps, std::string _name, bool _doRegister) :
     15  Action(_name,_doRegister),
    1516  Observable("Process"),
    16   Action(_name,_doRegister),
    1717  maxSteps(_maxSteps),
    1818  active(false),
     
    4141
    4242int Process::getCurrStep(){
    43   OBSERVE;
    4443  return currStep;
    4544}
    4645
    4746void Process::setCurrStep(int _currStep){
     47  OBSERVE;
    4848  currStep = _currStep;
    4949}
     
    5555    return 0;
    5656}
    57 
    5857int Process::getMaxSteps(){
    5958  return maxSteps;
  • src/Actions/TesselationAction/ConvexEnvelopeAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/TesselationAction/ConvexEnvelopeAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "boundary.hpp"
     13#include "config.hpp"
     14#include "linkedcell.hpp"
     15#include "log.hpp"
     16#include "molecule.hpp"
     17#include "verbose.hpp"
     18#include "World.hpp"
    1119
    1220#include <iostream>
     
    1725#include "UIElements/UIFactory.hpp"
    1826#include "UIElements/Dialog.hpp"
    19 #include "Actions/MapOfActions.hpp"
    20 
    21 #include "atom.hpp"
    22 #include "boundary.hpp"
    23 #include "config.hpp"
    24 #include "linkedcell.hpp"
    25 #include "log.hpp"
    26 #include "molecule.hpp"
    27 #include "verbose.hpp"
    28 #include "World.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2928
    3029/****** TesselationConvexEnvelopeAction *****/
     
    5150{}
    5251
     52void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex) {
     53  ValueStorage::getInstance().setCurrentValue("convex-file", filenameConvex);
     54  ValueStorage::getInstance().setCurrentValue("nonconvex-file", filenameConvex);
     55  ActionRegistry::getInstance().getActionByName(TesselationConvexEnvelopeAction::NAME)->call(Action::NonInteractive);
     56};
     57
     58Dialog* TesselationConvexEnvelopeAction::fillDialog(Dialog *dialog) {
     59  ASSERT(dialog,"No Dialog given when filling action dialog");
     60
     61  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
     62  dialog->queryString("convex-file", ValueStorage::getInstance().getDescription("convex-file"));
     63  dialog->queryString("nonconvex-file", ValueStorage::getInstance().getDescription("nonconvex-file"));
     64
     65  return dialog;
     66}
     67
    5368Action::state_ptr TesselationConvexEnvelopeAction::performCall() {
    5469  string filenameConvex;
    5570  string filenameNonConvex;
    56   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5771  molecule * mol = NULL;
    58   bool Success = false;
     72  bool Success = true;
    5973  config *configuration = World::getInstance().getConfig();
    6074
    61   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
    62   dialog->queryString("convex-file", &filenameConvex, MapOfActions::getInstance().getDescription("convex-file"));
    63   dialog->queryString("nonconvex-file", &filenameNonConvex, MapOfActions::getInstance().getDescription("nonconvex-file"));
     75  ValueStorage::getInstance().queryCurrentValue("convex-file", filenameConvex);
     76  ValueStorage::getInstance().queryCurrentValue("nonconvex-file", filenameNonConvex);
    6477
    65   if(dialog->display()) {
     78  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     79    mol = iter->second;
    6680    class Tesselation *TesselStruct = NULL;
    6781    const LinkedCell *LCList = NULL;
     
    7084    DoLog(1) && (Log() << Verbose(1) << "Storing tecplot non-convex data in " << filenameNonConvex << "." << endl);
    7185    LCList = new LinkedCell(mol, 100.);
    72     //FindConvexBorder(mol, LCList, argv[argptr]);
     86    Boundaries *BoundaryPoints = NULL;
     87    //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]);
    7388    // TODO: Beide Funktionen sollten streams anstelle des Filenamen benutzen, besser fuer unit tests
    7489    FindNonConvexBorder(mol, TesselStruct, LCList, 50., filenameNonConvex.c_str());
     
    8095    delete(TesselStruct);
    8196    delete(LCList);
    82     delete dialog;
    83     if (Success)
    84       return Action::success;
    85     else
    86       return Action::failure;
    8797  }
    88   delete dialog;
    89   return Action::failure;
     98  if (Success)
     99    return Action::success;
     100  else
     101    return Action::failure;
    90102}
    91103
  • src/Actions/TesselationAction/ConvexEnvelopeAction.hpp

    r06f4ef6 rb6da28  
    1414class TesselationListClass;
    1515
     16void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex);
     17
    1618class TesselationConvexEnvelopeAction : public Action {
     19  friend void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex);
     20
    1721public:
    1822  TesselationConvexEnvelopeAction();
     
    2327
    2428  virtual const std::string getName();
     29protected:
     30  virtual Dialog * fillDialog(Dialog *dialog);
    2531private:
    2632  virtual Action::state_ptr performCall();
     
    3137};
    3238
    33 
    3439#endif // CONVEXENVELOPEACTION_HPP
  • src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "boundary.hpp"
     13#include "linkedcell.hpp"
     14#include "log.hpp"
     15#include "molecule.hpp"
     16#include "verbose.hpp"
     17#include "World.hpp"
    1118
    1219#include <iostream>
     
    1724#include "UIElements/UIFactory.hpp"
    1825#include "UIElements/Dialog.hpp"
    19 #include "Actions/MapOfActions.hpp"
    20 
    21 #include "atom.hpp"
    22 #include "boundary.hpp"
    23 #include "linkedcell.hpp"
    24 #include "log.hpp"
    25 #include "molecule.hpp"
    26 #include "verbose.hpp"
    27 #include "World.hpp"
     26#include "UIElements/ValueStorage.hpp"
    2827
    2928/****** TesselationNonConvexEnvelopeAction *****/
     
    5049{}
    5150
     51void TesselationNonConvexEnvelope(double radius, std::string &filename) {
     52  ValueStorage::getInstance().setCurrentValue(TesselationNonConvexEnvelopeAction::NAME, radius);
     53  ValueStorage::getInstance().setCurrentValue("nonconvex-file", filename);
     54  ActionRegistry::getInstance().getActionByName(TesselationNonConvexEnvelopeAction::NAME)->call(Action::NonInteractive);
     55};
     56
     57Dialog* TesselationNonConvexEnvelopeAction::fillDialog(Dialog *dialog) {
     58  ASSERT(dialog,"No Dialog given when filling action dialog");
     59
     60  dialog->queryDouble(NAME, MapOfActions::getInstance().getDescription(NAME));
     61  dialog->queryString("nonconvex-file", MapOfActions::getInstance().getDescription("nonconvex-file"));
     62
     63  return dialog;
     64}
     65
    5266Action::state_ptr TesselationNonConvexEnvelopeAction::performCall() {
    5367  string filename;
    54   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5568  molecule * Boundary = NULL;
    5669  double SphereRadius = 0;
     
    5871  clock_t start,end;
    5972
    60   dialog->queryMolecule(NAME, &Boundary, MapOfActions::getInstance().getDescription(NAME));
    61   dialog->queryString("nonconvex-file", &filename, MapOfActions::getInstance().getDescription("nonconvex-file"));
    62   dialog->queryDouble("sphere-radius", &SphereRadius, MapOfActions::getInstance().getDescription("sphere-radius"));
     73  ValueStorage::getInstance().queryCurrentValue(NAME, SphereRadius);
     74  ValueStorage::getInstance().queryCurrentValue("nonconvex-file", filename);
    6375
    64   if(dialog->display()) {
     76  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     77    Boundary = iter->second;
    6578    class Tesselation *T = NULL;
    6679    const LinkedCell *LCList = NULL;
     
    7689    delete(LCList);
    7790    delete(T);
    78     delete dialog;
    79     if (Success)
    80       return Action::success;
    81     else
    82       return Action::failure;
    8391  }
    84   delete dialog;
    85   return Action::failure;
     92  if (Success)
     93    return Action::success;
     94  else
     95    return Action::failure;
    8696}
    8797
  • src/Actions/TesselationAction/NonConvexEnvelopeAction.hpp

    r06f4ef6 rb6da28  
    1414class TesselationListClass;
    1515
     16void TesselationNonConvexEnvelope(double radius, std::string &filename);
     17
    1618class TesselationNonConvexEnvelopeAction : public Action {
     19  friend void TesselationNonConvexEnvelope(double radius, std::string &filename);
     20
    1721public:
    1822  TesselationNonConvexEnvelopeAction();
     
    2327
    2428  virtual const std::string getName();
     29protected:
     30  virtual Dialog * fillDialog(Dialog *dialog);
    2531private:
    2632  virtual Action::state_ptr performCall();
  • src/Actions/Values.hpp

    r06f4ef6 rb6da28  
    1919{
    2020  double xx;
    21   double xy;
    22   double xz;
     21  double yx;
    2322  double yy;
    24   double yz;
     23  double zx;
     24  double zy;
    2525  double zz;
    2626};
  • src/Actions/WorldAction/AddEmptyBoundaryAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/WorldAction/AddEmptyBoundaryAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "log.hpp"
     
    2223#include "UIElements/UIFactory.hpp"
    2324#include "UIElements/Dialog.hpp"
    24 #include "Actions/MapOfActions.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2526#include "Helpers/Assert.hpp"
    2627
     
    3435{}
    3536
     37void WorldAddEmptyBoundary(Vector &boundary) {
     38  ValueStorage::getInstance().setCurrentValue(WorldAddEmptyBoundaryAction::NAME, boundary);
     39  ActionRegistry::getInstance().getActionByName(WorldAddEmptyBoundaryAction::NAME)->call(Action::NonInteractive);
     40};
     41
     42Dialog* WorldAddEmptyBoundaryAction::fillDialog(Dialog *dialog) {
     43  ASSERT(dialog,"No Dialog given when filling action dialog");
     44
     45  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
     46
     47  return dialog;
     48}
     49
    3650Action::state_ptr WorldAddEmptyBoundaryAction::performCall() {
    37   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3851  Vector boundary;
    3952  Vector Min;
     
    4154  int j=0;
    4255
    43   dialog->queryVector(NAME, &boundary, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));
     56  ValueStorage::getInstance().queryCurrentValue(NAME, boundary);
    4457
    45   if(dialog->display()) {
    46     // get maximum and minimum
    47     vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
    48     ASSERT(AllAtoms.size() > 0, "There must be atoms present for AddingEmptyBoundary.");
    49     vector<atom *>::iterator AtomRunner = AllAtoms.begin();
    50     Min = (*AtomRunner)->x;
    51     Max = (*AtomRunner)->x;
    52     for (; AtomRunner != AllAtoms.end(); ++AtomRunner) {
    53       for (int i=0;i<NDIM;i++) {
    54         if ((*AtomRunner)->x[i] > Max[i])
    55           Max[i] = (*AtomRunner)->x[i];
    56         if ((*AtomRunner)->x[i] < Min[i])
    57           Min[i] = (*AtomRunner)->x[i];
    58       }
     58  // get maximum and minimum
     59  vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
     60  ASSERT(AllAtoms.size() > 0, "There must be atoms present for AddingEmptyBoundary.");
     61  vector<atom *>::iterator AtomRunner = AllAtoms.begin();
     62  Min = (*AtomRunner)->x;
     63  Max = (*AtomRunner)->x;
     64  for (; AtomRunner != AllAtoms.end(); ++AtomRunner) {
     65    for (int i=0;i<NDIM;i++) {
     66      if ((*AtomRunner)->x[i] > Max[i])
     67        Max[i] = (*AtomRunner)->x[i];
     68      if ((*AtomRunner)->x[i] < Min[i])
     69        Min[i] = (*AtomRunner)->x[i];
    5970    }
    60     // set new box size
    61     double * const cell_size = World::getInstance().getDomain();
    62     for (j=0;j<6;j++)
    63       cell_size[j] = 0.;
    64     j=-1;
    65     for (int i=0;i<NDIM;i++) {
    66       j += i+1;
    67       cell_size[j] = (Max[i]-Min[i]+2.*boundary[i]);
    68     }
    69     // translate all atoms, such that Min is aty (0,0,0)
    70     AtomRunner = AllAtoms.begin();
    71     for (; AtomRunner != AllAtoms.end(); ++AtomRunner)
    72       (*AtomRunner)->x -= Min - boundary;
    73     delete dialog;
    74     return Action::success;
    75   } else {
    76     delete dialog;
    77     return Action::failure;
    7871  }
     72  // set new box size
     73  double * const cell_size = new double[6];
     74  for (j=0;j<6;j++)
     75    cell_size[j] = 0.;
     76  j=-1;
     77  for (int i=0;i<NDIM;i++) {
     78    j += i+1;
     79    cell_size[j] = (Max[i]-Min[i]+2.*boundary[i]);
     80  }
     81  World::getInstance().setDomain(cell_size);
     82  delete[] cell_size;
     83  // translate all atoms, such that Min is aty (0,0,0)
     84  AtomRunner = AllAtoms.begin();
     85  for (; AtomRunner != AllAtoms.end(); ++AtomRunner)
     86    (*AtomRunner)->x -= Min - boundary;
     87  return Action::success;
    7988}
    8089
  • src/Actions/WorldAction/AddEmptyBoundaryAction.hpp

    r06f4ef6 rb6da28  
    1010
    1111#include "Actions/Action.hpp"
     12#include "vector.hpp"
     13
     14void WorldAddEmptyBoundary(Vector &boundary);
    1215
    1316class WorldAddEmptyBoundaryAction : public Action {
     17  friend void WorldAddEmptyBoundary(Vector &boundary);
     18
    1419public:
    1520  WorldAddEmptyBoundaryAction();
     
    2025
    2126  virtual const std::string getName();
     27protected:
     28  virtual Dialog * fillDialog(Dialog *dialog);
    2229private:
    2330  virtual Action::state_ptr performCall();
  • src/Actions/WorldAction/BoundInBoxAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/WorldAction/BoundInBoxAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "log.hpp"
    1213#include "molecule.hpp"
     
    2122#include "UIElements/UIFactory.hpp"
    2223#include "UIElements/Dialog.hpp"
    23 #include "Actions/MapOfActions.hpp"
     24#include "UIElements/ValueStorage.hpp"
    2425
    2526const char WorldBoundInBoxAction::NAME[] = "bound-in-box";
     
    3233{}
    3334
     35void WorldBoundInBox() {
     36  ActionRegistry::getInstance().getActionByName(WorldBoundInBoxAction::NAME)->call(Action::NonInteractive);
     37};
     38
     39Dialog* WorldBoundInBoxAction::fillDialog(Dialog *dialog) {
     40  ASSERT(dialog,"No Dialog given when filling action dialog");
     41
     42  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
     43
     44  return dialog;
     45}
     46
    3447Action::state_ptr WorldBoundInBoxAction::performCall() {
    35   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3648
    37   dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
    38 
    39   if(dialog->display()) {
    40     // center
    41     vector<molecule*> AllMolecules = World::getInstance().getAllMolecules();
    42     for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
    43       (*MolRunner)->BoundInBox();
    44     }
    45     delete dialog;
    46     return Action::success;
    47   } else {
    48     delete dialog;
    49     return Action::failure;
     49  // center
     50  vector<molecule*> AllMolecules = World::getInstance().getAllMolecules();
     51  for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
     52    (*MolRunner)->BoundInBox();
    5053  }
     54  return Action::success;
    5155}
    5256
  • src/Actions/WorldAction/BoundInBoxAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212
     13void WorldBoundInBox();
     14
    1315class WorldBoundInBoxAction : public Action {
     16  friend void WorldBoundInBox();
     17
    1418public:
    1519  WorldBoundInBoxAction();
     
    2024
    2125  virtual const std::string getName();
     26protected:
     27  virtual Dialog * fillDialog(Dialog *dialog);
    2228private:
    2329  virtual Action::state_ptr performCall();
  • src/Actions/WorldAction/CenterInBoxAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/WorldAction/CenterInBoxAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "Box.hpp"
    1113#include "log.hpp"
    1214#include "molecule.hpp"
     
    2022#include "UIElements/UIFactory.hpp"
    2123#include "UIElements/Dialog.hpp"
    22 #include "Actions/MapOfActions.hpp"
     24#include "UIElements/ValueStorage.hpp"
    2325
    2426const char WorldCenterInBoxAction::NAME[] = "center-in-box";
     
    3133{}
    3234
     35void WorldCenterInBox(Box &_box) {
     36  ValueStorage::getInstance().setCurrentValue(WorldCenterInBoxAction::NAME, _box);
     37  ActionRegistry::getInstance().getActionByName(WorldCenterInBoxAction::NAME)->call(Action::NonInteractive);
     38};
     39
     40Dialog* WorldCenterInBoxAction::fillDialog(Dialog *dialog) {
     41  ASSERT(dialog,"No Dialog given when filling action dialog");
     42
     43  dialog->queryBox(NAME, ValueStorage::getInstance().getDescription(NAME));
     44
     45  return dialog;
     46}
     47
    3348Action::state_ptr WorldCenterInBoxAction::performCall() {
    34   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3549
    36   double * cell_size = World::getInstance().getDomain();
    37   dialog->queryBox(NAME, &cell_size, MapOfActions::getInstance().getDescription(NAME));
     50  Box& cell_size = World::getInstance().getDomain();
     51  ValueStorage::getInstance().queryCurrentValue(NAME, cell_size);
     52  World::getInstance().setDomain(cell_size.getM());
    3853
    39   if(dialog->display()) {
    40     // center
    41     vector<molecule *> AllMolecules = World::getInstance().getAllMolecules();
    42     for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
    43       (*MolRunner)->CenterInBox();
    44     }
    45     delete dialog;
    46     return Action::success;
    47   } else {
    48     delete dialog;
    49     return Action::failure;
     54  // center
     55  vector<molecule *> AllMolecules = World::getInstance().getAllMolecules();
     56  for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
     57    (*MolRunner)->CenterInBox();
    5058  }
     59  return Action::success;
    5160}
    5261
  • src/Actions/WorldAction/CenterInBoxAction.hpp

    r06f4ef6 rb6da28  
    1010
    1111#include "Actions/Action.hpp"
     12#include "Box.hpp"
     13
     14void WorldCenterInBox(Box &_box);
    1215
    1316class WorldCenterInBoxAction : public Action {
     17  friend void WorldCenterInBox(Box &_box);
     18
    1419public:
    1520  WorldCenterInBoxAction();
     
    2025
    2126  virtual const std::string getName();
     27protected:
     28  virtual Dialog * fillDialog(Dialog *dialog);
    2229private:
    2330  virtual Action::state_ptr performCall();
  • src/Actions/WorldAction/CenterOnEdgeAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/WorldAction/CenterOnEdgeAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "log.hpp"
    1314#include "vector.hpp"
    1415#include "World.hpp"
     16#include "Matrix.hpp"
    1517
    1618#include <iostream>
     
    2123#include "UIElements/UIFactory.hpp"
    2224#include "UIElements/Dialog.hpp"
    23 #include "Actions/MapOfActions.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2426#include "Helpers/Assert.hpp"
    2527
     
    3335{}
    3436
     37void WorldCenterOnEdge() {
     38  ActionRegistry::getInstance().getActionByName(WorldCenterOnEdgeAction::NAME)->call(Action::NonInteractive);
     39};
     40
     41Dialog* WorldCenterOnEdgeAction::fillDialog(Dialog *dialog) {
     42  ASSERT(dialog,"No Dialog given when filling action dialog");
     43
     44  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
     45
     46  return dialog;
     47}
     48
    3549Action::state_ptr WorldCenterOnEdgeAction::performCall() {
    36   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3750  Vector Min;
    3851  Vector Max;
    39   int j=0;
    4052
    41   dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
     53  // get maximum and minimum
     54  vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
     55  ASSERT(AllAtoms.size() > 0, "For CenteronEdge atoms must be present.");
     56  vector<atom *>::iterator AtomRunner = AllAtoms.begin();
     57  Min = (*AtomRunner)->x;
     58  Max = (*AtomRunner)->x;
     59  for (; AtomRunner != AllAtoms.end(); ++AtomRunner) {
     60    for (int i=0;i<NDIM;i++) {
     61      if ((*AtomRunner)->x[i] > Max[i])
     62        Max[i] = (*AtomRunner)->x[i];
     63      if ((*AtomRunner)->x[i] < Min[i])
     64        Min[i] = (*AtomRunner)->x[i];
     65    }
     66  }
     67  // set new box size
     68  Matrix domain;
     69  for (int i=0;i<NDIM;i++) {
     70    double tmp = Max[i]-Min[i];
     71    tmp = fabs(tmp)>=1. ? tmp : 1.0;
     72    domain.at(i,i) = tmp;
     73  }
     74  World::getInstance().setDomain(domain);
     75  // translate all atoms, such that Min is aty (0,0,0)
     76  for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner)
     77    (*AtomRunner)->x -= Min;
    4278
    43   if(dialog->display()) {
    44     // get maximum and minimum
    45     vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
    46     ASSERT(AllAtoms.size() > 0, "For CenteronEdge atoms must be present.");
    47     vector<atom *>::iterator AtomRunner = AllAtoms.begin();
    48     Min = (*AtomRunner)->x;
    49     Max = (*AtomRunner)->x;
    50     for (; AtomRunner != AllAtoms.end(); ++AtomRunner) {
    51       for (int i=0;i<NDIM;i++) {
    52         if ((*AtomRunner)->x[i] > Max[i])
    53           Max[i] = (*AtomRunner)->x[i];
    54         if ((*AtomRunner)->x[i] < Min[i])
    55           Min[i] = (*AtomRunner)->x[i];
    56       }
    57     }
    58     // set new box size
    59     double * const cell_size = World::getInstance().getDomain();
    60     for (j=0;j<6;j++)
    61       cell_size[j] = 0.;
    62     j=-1;
    63     for (int i=0;i<NDIM;i++) {
    64       j += i+1;
    65       cell_size[j] = (Max[i]-Min[i]);
    66     }
    67     // translate all atoms, such that Min is aty (0,0,0)
    68     for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner)
    69       (*AtomRunner)->x -= Min;
    70     delete dialog;
    71     return Action::success;
    72   } else {
    73     delete dialog;
    74     return Action::failure;
    75   }
     79  return Action::success;
    7680}
    7781
  • src/Actions/WorldAction/CenterOnEdgeAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212
     13void WorldCenterOnEdge();
     14
    1315class WorldCenterOnEdgeAction : public Action {
     16  friend void WorldCenterOnEdge();
     17
    1418public:
    1519  WorldCenterOnEdgeAction();
     
    2024
    2125  virtual const std::string getName();
     26protected:
     27  virtual Dialog * fillDialog(Dialog *dialog);
    2228private:
    2329  virtual Action::state_ptr performCall();
  • src/Actions/WorldAction/ChangeBoxAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/WorldAction/ChangeBoxAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "log.hpp"
    1213#include "verbose.hpp"
    1314#include "World.hpp"
     15#include "Box.hpp"
     16#include "Matrix.hpp"
    1417
    1518#include <iostream>
     
    2023#include "UIElements/UIFactory.hpp"
    2124#include "UIElements/Dialog.hpp"
    22 #include "Actions/MapOfActions.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2326
    2427const char WorldChangeBoxAction::NAME[] = "change-box";
     
    3134{}
    3235
     36void WorldChangeBox(Box &_box) {
     37  ValueStorage::getInstance().setCurrentValue(WorldChangeBoxAction::NAME, _box);
     38  ActionRegistry::getInstance().getActionByName(WorldChangeBoxAction::NAME)->call(Action::NonInteractive);
     39};
     40
     41Dialog* WorldChangeBoxAction::fillDialog(Dialog *dialog) {
     42  ASSERT(dialog,"No Dialog given when filling action dialog");
     43
     44  dialog->queryBox(NAME, ValueStorage::getInstance().getDescription(NAME));
     45
     46  return dialog;
     47}
     48
    3349Action::state_ptr WorldChangeBoxAction::performCall() {
    34   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3550
    36   double * cell_size = World::getInstance().getDomain();
    37   dialog->queryBox(NAME, &cell_size, MapOfActions::getInstance().getDescription(NAME));
     51  Box cell_size;
     52  ValueStorage::getInstance().queryCurrentValue(NAME, cell_size);
     53  World::getInstance().setDomain(cell_size.getM()); // this is needed as only this function is OBSERVEd.
    3854
    39   if(dialog->display()) {
    40     DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << cell_size[0] << "," << cell_size[1] << "," << cell_size[2] << "," << cell_size[3] << "," << cell_size[4] << "," << cell_size[5] << "," << endl);
    41     delete dialog;
    42     return Action::success;
    43   } else {
    44     delete dialog;
    45     return Action::failure;
    46   }
     55  DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << World::getInstance().getDomain().getM() << endl);
     56  return Action::success;
    4757}
    4858
  • src/Actions/WorldAction/ChangeBoxAction.hpp

    r06f4ef6 rb6da28  
    1010
    1111#include "Actions/Action.hpp"
     12#include "Box.hpp"
     13
     14void WorldChangeBox(Box &_box);
    1215
    1316class WorldChangeBoxAction : public Action {
     17  friend void WorldChangeBox(Box &_box);
     18
    1419public:
    1520  WorldChangeBoxAction();
     
    2025
    2126  virtual const std::string getName();
     27protected:
     28  virtual Dialog * fillDialog(Dialog *dialog);
    2229private:
    2330  virtual Action::state_ptr performCall();
  • src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "Descriptors/AtomDescriptor.hpp"
    1113#include "atom.hpp"
    12 #include "Descriptors/AtomDescriptor.hpp"
    1314#include "log.hpp"
    1415#include "molecule.hpp"
     
    2425#include "UIElements/UIFactory.hpp"
    2526#include "UIElements/Dialog.hpp"
    26 #include "Actions/MapOfActions.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2728
    2829const char WorldRemoveSphereOfAtomsAction::NAME[] = "remove-sphere";
     
    3536{}
    3637
     38void WorldRemoveSphereOfAtoms(double radius, Vector &point) {
     39  ValueStorage::getInstance().setCurrentValue(WorldRemoveSphereOfAtomsAction::NAME, radius);
     40  ValueStorage::getInstance().setCurrentValue("position", point);
     41  ActionRegistry::getInstance().getActionByName(WorldRemoveSphereOfAtomsAction::NAME)->call(Action::NonInteractive);
     42};
     43
     44Dialog* WorldRemoveSphereOfAtomsAction::fillDialog(Dialog *dialog) {
     45  ASSERT(dialog,"No Dialog given when filling action dialog");
     46
     47  dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
     48  dialog->queryVector("position", false, ValueStorage::getInstance().getDescription("position"));
     49
     50  return dialog;
     51}
     52
    3753Action::state_ptr WorldRemoveSphereOfAtomsAction::performCall() {
    38   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3954  double radius = 0.;
    4055  Vector point;
    4156
    42   dialog->queryDouble(NAME, &radius, MapOfActions::getInstance().getDescription(NAME));
    43   dialog->queryVector("position", &point, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("position"));
     57  ValueStorage::getInstance().queryCurrentValue(NAME, radius);
     58  ValueStorage::getInstance().queryCurrentValue("position", point);
    4459
    45   if(dialog->display()) {
    46     delete dialog;
    47     DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << point << " with radius " << radius << "." << endl);
    48     vector<atom*> AllAtoms = World::getInstance().getAllAtoms();
    49     vector<molecule *> molecules = World::getInstance().getAllMolecules();
    50     for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) {
    51       if (point.DistanceSquared((*AtomRunner)->x) > radius*radius) { // distance to first above radius ...
    52         // TODO: This is not necessary anymore when atoms are completely handled by World (create/destroy and load/save)
    53         for (vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end();++iter)
    54           (*iter)->erase(*AtomRunner);
    55         World::getInstance().destroyAtom(*AtomRunner);
    56       }
     60  DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << point << " with radius " << radius << "." << endl);
     61  vector<atom*> AllAtoms = World::getInstance().getAllAtoms();
     62  vector<molecule *> molecules = World::getInstance().getAllMolecules();
     63  for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) {
     64    if (point.DistanceSquared((*AtomRunner)->x) > radius*radius) { // distance to first above radius ...
     65      // TODO: This is not necessary anymore when atoms are completely handled by World (create/destroy and load/save)
     66      for (vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end();++iter)
     67        (*iter)->erase(*AtomRunner);
     68      World::getInstance().destroyAtom(*AtomRunner);
    5769    }
    58     return Action::success;
    59   } else {
    60     delete dialog;
    61     return Action::failure;
    6270  }
    63 
     71  return Action::success;
    6472}
    6573
  • src/Actions/WorldAction/RemoveSphereOfAtomsAction.hpp

    r06f4ef6 rb6da28  
    1010
    1111#include "Actions/Action.hpp"
     12#include "vector.hpp"
     13
     14
     15void WorldRemoveSphereOfAtoms(double radius, Vector &point);
    1216
    1317class WorldRemoveSphereOfAtomsAction : public Action {
     18  friend void WorldRemoveSphereOfAtoms(double radius, Vector &point);
     19
    1420public:
    1521  WorldRemoveSphereOfAtomsAction();
     
    2026
    2127  virtual const std::string getName();
     28protected:
     29  virtual Dialog * fillDialog(Dialog *dialog);
    2230private:
    2331  virtual Action::state_ptr performCall();
  • src/Actions/WorldAction/RepeatBoxAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/WorldAction/RepeatBoxAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "log.hpp"
    1314#include "molecule.hpp"
    1415#include "vector.hpp"
     16#include "Matrix.hpp"
    1517#include "verbose.hpp"
    1618#include "World.hpp"
     19#include "Box.hpp"
    1720
    1821#include <iostream>
     
    2326#include "UIElements/UIFactory.hpp"
    2427#include "UIElements/Dialog.hpp"
    25 #include "Actions/MapOfActions.hpp"
     28#include "UIElements/ValueStorage.hpp"
    2629#include "Descriptors/MoleculeDescriptor.hpp"
    2730#include "Descriptors/MoleculePtrDescriptor.hpp"
     
    3639{}
    3740
     41void WorldRepeatBox(Vector &Repeater) {
     42  ValueStorage::getInstance().setCurrentValue(WorldRepeatBoxAction::NAME, Repeater);
     43  ActionRegistry::getInstance().getActionByName(WorldRepeatBoxAction::NAME)->call(Action::NonInteractive);
     44};
     45
     46Dialog * WorldRepeatBoxAction::fillDialog(Dialog *dialog) {
     47  ASSERT(dialog,"No Dialog given when filling action dialog");
     48
     49  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
     50
     51  return dialog;
     52}
     53
    3854Action::state_ptr WorldRepeatBoxAction::performCall() {
    39   Dialog *dialog = UIFactory::getInstance().makeDialog();
    4055  Vector Repeater;
    4156  int count;
     
    4661  MoleculeListClass *molecules = World::getInstance().getMolecules();
    4762
    48   dialog->queryVector(NAME, &Repeater, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));
    49   //dialog->queryMolecule("molecule-by-id", &mol,MapOfActions::getInstance().getDescription("molecule-by-id"));
     63  ValueStorage::getInstance().queryCurrentValue(NAME, Repeater);
     64
    5065  vector<molecule *> AllMolecules;
    5166  if (mol != NULL) {
     
    5772  }
    5873
    59   if(dialog->display()) {
    60     (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl);
    61     double * const cell_size = World::getInstance().getDomain();
    62     double *M = ReturnFullMatrixforSymmetric(cell_size);
    63     Vector x,y;
    64     int n[NDIM];
    65     for (int axis = 0; axis < NDIM; axis++) {
    66       Repeater[axis] = floor(Repeater[axis]);
    67       if (Repeater[axis] < 1) {
    68         DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor must be greater than 1!" << endl);
    69         Repeater[axis] = 1;
    70       }
    71       cell_size[(abs(axis+1) == 2) ? 2 : ((abs(axis+2) == 3) ? 5 : 0)] *= Repeater[axis];
     74  (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl);
     75  Matrix M = World::getInstance().getDomain().getM();
     76  Matrix newM = M;
     77  Vector x,y;
     78  int n[NDIM];
     79  Matrix repMat;
     80  for (int axis = 0; axis < NDIM; axis++) {
     81    Repeater[axis] = floor(Repeater[axis]);
     82    if (Repeater[axis] < 1) {
     83      DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor must be greater than 1!" << endl);
     84      Repeater[axis] = 1;
    7285    }
     86    repMat.at(axis,axis) = Repeater[axis];
     87  }
     88  newM *= repMat;
     89  World::getInstance().setDomain(newM);
    7390
    74     molecule *newmol = NULL;
    75     Vector ** vectors = NULL;
    76     for (n[0] = 0; n[0] < Repeater[0]; n[0]++) {
    77       y[0] = n[0];
    78       for (n[1] = 0; n[1] < Repeater[1]; n[1]++) {
    79         y[1] = n[1];
    80         for (n[2] = 0; n[2] < Repeater[2]; n[2]++) {
    81           y[2] = n[2];
    82           if (n[0] == n[1] == n[2] == 0)
    83             continue;
    84           for (vector<molecule *>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
    85             mol = *MolRunner;
    86             DoLog(1) && (Log() << Verbose(1) << "Current mol is " << mol->name << "." << endl);
    87             count = mol->getAtomCount();   // is changed becausing of adding, thus has to be stored away beforehand
    88             if (count != 0) {  // if there is more than none
    89               Elements = new const element *[count];
    90               vectors = new Vector *[count];
    91               j = 0;
    92               for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) {
    93                 Elements[j] = (*AtomRunner)->type;
    94                 vectors[j] = &(*AtomRunner)->x;
    95                 j++;
    96               }
    97               if (count != j)
    98                 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
    99               x = y;
    100               x.MatrixMultiplication(M);
    101               newmol = World::getInstance().createMolecule();
    102               molecules->insert(newmol);
    103               for (int k=count;k--;) { // go through every atom of the original cell
    104                 Walker = World::getInstance().createAtom(); // create a new body
    105                 Walker->x = (*vectors[k]) + x;
    106                 Walker->type = Elements[k];  // insert original element
    107                 cout << "new atom is " << *Walker << endl;
    108                 newmol->AddAtom(Walker);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
    109               }
    110               // free memory
    111               delete[](Elements);
    112               delete[](vectors);
    113             } else {
    114               DoLog(1) && (Log() << Verbose(1) << "\t ... is empty." << endl);
     91  molecule *newmol = NULL;
     92  Vector ** vectors = NULL;
     93  for (n[0] = 0; n[0] < Repeater[0]; n[0]++) {
     94    y[0] = n[0];
     95    for (n[1] = 0; n[1] < Repeater[1]; n[1]++) {
     96      y[1] = n[1];
     97      for (n[2] = 0; n[2] < Repeater[2]; n[2]++) {
     98        y[2] = n[2];
     99        if ((n[0] == 0) && (n[1] == 0) && (n[2] == 0))
     100          continue;
     101        for (vector<molecule *>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
     102          mol = *MolRunner;
     103          DoLog(1) && (Log() << Verbose(1) << "Current mol is " << mol->name << "." << endl);
     104          count = mol->getAtomCount();   // is changed becausing of adding, thus has to be stored away beforehand
     105          if (count != 0) {  // if there is more than none
     106            Elements = new const element *[count];
     107            vectors = new Vector *[count];
     108            j = 0;
     109            for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) {
     110              Elements[j] = (*AtomRunner)->type;
     111              vectors[j] = &(*AtomRunner)->x;
     112              j++;
    115113            }
     114            if (count != j)
     115              DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
     116            x = y;
     117            x *= M;
     118            newmol = World::getInstance().createMolecule();
     119            molecules->insert(newmol);
     120            for (int k=count;k--;) { // go through every atom of the original cell
     121              Walker = World::getInstance().createAtom(); // create a new body
     122              Walker->x = (*vectors[k]) + x;
     123              Walker->type = Elements[k];  // insert original element
     124              cout << "new atom is " << *Walker << endl;
     125              newmol->AddAtom(Walker);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
     126            }
     127            // free memory
     128            delete[](Elements);
     129            delete[](vectors);
     130          } else {
     131            DoLog(1) && (Log() << Verbose(1) << "\t ... is empty." << endl);
    116132          }
    117133        }
    118134      }
    119135    }
    120     delete(M);
    121     delete dialog;
    122     return Action::success;
    123   } else {
    124     delete dialog;
    125     return Action::failure;
    126136  }
     137  return Action::success;
    127138}
    128139
  • src/Actions/WorldAction/RepeatBoxAction.hpp

    r06f4ef6 rb6da28  
    1010
    1111#include "Actions/Action.hpp"
     12#include "vector.hpp"
     13
     14void WorldRepeatBox(Vector &Repeater);
    1215
    1316class WorldRepeatBoxAction : public Action {
     17  friend void WorldRepeatBox(Vector &Repeater);
     18
    1419public:
    1520  WorldRepeatBoxAction();
     
    2025
    2126  virtual const std::string getName();
     27protected:
     28  virtual Dialog * fillDialog(Dialog *dialog);
    2229private:
    2330  virtual Action::state_ptr performCall();
  • src/Actions/WorldAction/ScaleBoxAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/WorldAction/ScaleBoxAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "log.hpp"
     
    1415#include "verbose.hpp"
    1516#include "World.hpp"
     17#include "Box.hpp"
     18#include "Matrix.hpp"
    1619
    1720#include <iostream>
     
    2225#include "UIElements/UIFactory.hpp"
    2326#include "UIElements/Dialog.hpp"
    24 #include "Actions/MapOfActions.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2528
    2629const char WorldScaleBoxAction::NAME[] = "scale-box";
     
    3336{}
    3437
     38void WorldScaleBox(Vector &Scaler) {
     39  ValueStorage::getInstance().setCurrentValue(WorldScaleBoxAction::NAME, Scaler);
     40  ActionRegistry::getInstance().getActionByName(WorldScaleBoxAction::NAME)->call(Action::NonInteractive);
     41};
     42
     43Dialog* WorldScaleBoxAction::fillDialog(Dialog *dialog) {
     44  ASSERT(dialog,"No Dialog given when filling action dialog");
     45
     46  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
     47
     48  return dialog;
     49}
     50
    3551Action::state_ptr WorldScaleBoxAction::performCall() {
    36   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3752  Vector Scaler;
    3853  double x[NDIM];
    39   int j=0;
    4054
    41   dialog->queryVector(NAME, &Scaler, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));
     55  ValueStorage::getInstance().queryCurrentValue(NAME, Scaler);
    4256
    43   if(dialog->display()) {
    44     DoLog(1) && (Log() << Verbose(1) << "Scaling all atomic positions by factor." << endl);
    45     for (int i=0;i<NDIM;i++)
    46       x[i] = Scaler[i];
    47     vector<atom*> AllAtoms = World::getInstance().getAllAtoms();
    48     for(vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) {
    49       (*AtomRunner)->x.ScaleAll(x);
    50     }
    51     j = -1;
    52     double * const cell_size = World::getInstance().getDomain();
    53     for (int i=0;i<NDIM;i++) {
    54       j += i+1;
    55       cell_size[j]*=x[i];
    56     }
     57  DoLog(1) && (Log() << Verbose(1) << "Scaling all atomic positions by factor." << endl);
     58  for (int i=0;i<NDIM;i++)
     59    x[i] = Scaler[i];
     60  vector<atom*> AllAtoms = World::getInstance().getAllAtoms();
     61  for(vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) {
     62    (*AtomRunner)->x.ScaleAll(x);
     63  }
    5764
    58     delete dialog;
    59     return Action::success;
    60   } else {
    61     delete dialog;
    62     return Action::failure;
     65  Matrix M = World::getInstance().getDomain().getM();
     66  Matrix scale;
     67
     68  for (int i=0;i<NDIM;i++) {
     69    scale.at(i,i) = x[i];
    6370  }
     71  M *= scale;
     72  World::getInstance().setDomain(M);
     73
     74  return Action::success;
    6475}
    6576
  • src/Actions/WorldAction/ScaleBoxAction.hpp

    r06f4ef6 rb6da28  
    1010
    1111#include "Actions/Action.hpp"
     12#include "vector.hpp"
     13
     14void WorldScaleBox(Vector &Scaler);
    1215
    1316class WorldScaleBoxAction : public Action {
     17  friend void WorldScaleBox(Vector &Scaler);
     18
    1419public:
    1520  WorldScaleBoxAction();
     
    2025
    2126  virtual const std::string getName();
     27protected:
     28  virtual Dialog * fillDialog(Dialog *dialog);
    2229private:
    2330  virtual Action::state_ptr performCall();
  • src/Actions/WorldAction/SetDefaultNameAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/WorldAction/SetDefaultNameAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "log.hpp"
    1213#include "verbose.hpp"
     
    2021#include "UIElements/UIFactory.hpp"
    2122#include "UIElements/Dialog.hpp"
    22 #include "Actions/MapOfActions.hpp"
     23#include "UIElements/ValueStorage.hpp"
     24
     25
     26// memento to remember the state when undoing
     27
     28class WorldSetDefaultNameState : public ActionState {
     29public:
     30  WorldSetDefaultNameState(std::string _lastName) :
     31    lastName(_lastName)
     32  {}
     33  std::string lastName;
     34};
    2335
    2436const char WorldSetDefaultNameAction::NAME[] = "default-molname";
     
    3143{}
    3244
     45void WorldSetDefaultName(std::string &defaultname) {
     46  ValueStorage::getInstance().setCurrentValue(WorldSetDefaultNameAction::NAME, defaultname);
     47  ActionRegistry::getInstance().getActionByName(WorldSetDefaultNameAction::NAME)->call(Action::NonInteractive);
     48};
     49
     50Dialog* WorldSetDefaultNameAction::fillDialog(Dialog *dialog) {
     51  ASSERT(dialog,"No Dialog given when filling action dialog");
     52
     53  string defaultname = World::getInstance().getDefaultName();
     54  ValueStorage::getInstance().setCurrentValue(NAME, defaultname);
     55  dialog->queryString(NAME, MapOfActions::getInstance().getDescription(NAME));
     56
     57  return dialog;
     58}
     59
    3360Action::state_ptr WorldSetDefaultNameAction::performCall() {
    34   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3561  string defaultname;
    3662
    3763  defaultname = World::getInstance().getDefaultName();
    38   dialog->queryString(NAME, &defaultname, MapOfActions::getInstance().getDescription(NAME));
     64  ValueStorage::getInstance().queryCurrentValue(NAME, defaultname);
    3965
    40   if(dialog->display()) {
    41     World::getInstance().setDefaultName(defaultname);
    42     DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << World::getInstance().getDefaultName() << "." << endl);
    43     delete dialog;
    44     return Action::success;
    45   } else {
    46     delete dialog;
    47     return Action::failure;
    48   }
     66  World::getInstance().setDefaultName(defaultname);
     67  DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << World::getInstance().getDefaultName() << "." << endl);
     68  return Action::success;
    4969}
    5070
    5171Action::state_ptr WorldSetDefaultNameAction::performUndo(Action::state_ptr _state) {
    52 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
     72  WorldSetDefaultNameState *state = assert_cast<WorldSetDefaultNameState*>(_state.get());
    5373
    54   return Action::failure;
    55 //  string newName = state->mol->getName();
    56 //  state->mol->setName(state->lastName);
    57 //
    58 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     74  string newName = World::getInstance().getDefaultName();
     75  World::getInstance().setDefaultName(state->lastName);
     76
     77  return Action::state_ptr(new WorldSetDefaultNameState(newName));
    5978}
    6079
    6180Action::state_ptr WorldSetDefaultNameAction::performRedo(Action::state_ptr _state){
    62   return Action::failure;
     81  return performUndo(_state);
    6382}
    6483
    6584bool WorldSetDefaultNameAction::canUndo() {
    66   return false;
     85  return true;
    6786}
    6887
    6988bool WorldSetDefaultNameAction::shouldUndo() {
    70   return false;
     89  return true;
    7190}
    7291
  • src/Actions/WorldAction/SetDefaultNameAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212
     13void WorldSetDefaultName(std::string &defaultname);
     14
    1315class WorldSetDefaultNameAction : public Action {
     16  friend void WorldSetDefaultName(std::string &defaultname);
     17
    1418public:
    1519  WorldSetDefaultNameAction();
     
    2024
    2125  virtual const std::string getName();
     26protected:
     27  virtual Dialog * fillDialog(Dialog *dialog);
    2228private:
    2329  virtual Action::state_ptr performCall();
  • src/Actions/WorldAction/SetGaussianBasisAction.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "Actions/WorldAction/SetGaussianBasisAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "config.hpp"
    1213#include "log.hpp"
     
    2122#include "UIElements/UIFactory.hpp"
    2223#include "UIElements/Dialog.hpp"
    23 #include "Actions/MapOfActions.hpp"
     24#include "UIElements/ValueStorage.hpp"
     25
     26
     27// memento to remember the state when undoing
     28
     29class WorldSetGaussianBasisState : public ActionState {
     30public:
     31  WorldSetGaussianBasisState(std::string _lastName) :
     32    lastName(_lastName)
     33  {}
     34  std::string lastName;
     35};
     36
    2437
    2538const char WorldSetGaussianBasisAction::NAME[] = "set-basis";
     
    3245{}
    3346
     47void WorldSetGaussianBasis(std::string &basisname) {
     48  ValueStorage::getInstance().setCurrentValue(WorldSetGaussianBasisAction::NAME, basisname);
     49  ActionRegistry::getInstance().getActionByName(WorldSetGaussianBasisAction::NAME)->call(Action::NonInteractive);
     50};
     51
     52Dialog* WorldSetGaussianBasisAction::fillDialog(Dialog *dialog) {
     53  ASSERT(dialog,"No Dialog given when filling action dialog");
     54
     55  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     56
     57  return dialog;
     58}
     59
    3460Action::state_ptr WorldSetGaussianBasisAction::performCall() {
    35   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3661  config *configuration = World::getInstance().getConfig();
    37   dialog->queryString(NAME, &(configuration->basis), MapOfActions::getInstance().getDescription(NAME));
    3862
    39   if(dialog->display()) {
    40     DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration->basis << "." << endl);
    41     delete dialog;
    42     return Action::success;
    43   } else {
    44     delete dialog;
    45     return Action::failure;
    46   }
     63  string lastname = configuration->basis;
     64  ValueStorage::getInstance().queryCurrentValue(NAME, configuration->basis);
     65
     66  DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration->basis << "." << endl);
     67  return Action::success;
    4768}
    4869
    4970Action::state_ptr WorldSetGaussianBasisAction::performUndo(Action::state_ptr _state) {
    50 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
     71  WorldSetGaussianBasisState *state = assert_cast<WorldSetGaussianBasisState*>(_state.get());
    5172
    52   return Action::failure;
    53 //  string newName = state->mol->getName();
    54 //  state->mol->setName(state->lastName);
    55 //
    56 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     73  config *configuration = World::getInstance().getConfig();
     74  string newName = configuration->basis;
     75  configuration->basis = state->lastName;
     76
     77  return Action::state_ptr(new WorldSetGaussianBasisState(newName));
    5778}
    5879
    5980Action::state_ptr WorldSetGaussianBasisAction::performRedo(Action::state_ptr _state){
    60   return Action::failure;
     81  return performUndo(_state);
    6182}
    6283
    6384bool WorldSetGaussianBasisAction::canUndo() {
    64   return false;
     85  return true;
    6586}
    6687
    6788bool WorldSetGaussianBasisAction::shouldUndo() {
    68   return false;
     89  return true;
    6990}
    7091
  • src/Actions/WorldAction/SetGaussianBasisAction.hpp

    r06f4ef6 rb6da28  
    1111#include "Actions/Action.hpp"
    1212
     13void WorldSetGaussianBasis(std::string &basisname);
     14
    1315class WorldSetGaussianBasisAction : public Action {
     16  friend void WorldSetGaussianBasis(std::string &basisname);
     17
    1418public:
    1519  WorldSetGaussianBasisAction();
     
    2024
    2125  virtual const std::string getName();
     26protected:
     27  virtual Dialog * fillDialog(Dialog *dialog);
    2228private:
    2329  virtual Action::state_ptr performCall();
  • src/CommandLineParser.cpp

    r06f4ef6 rb6da28  
    4141void CommandLineParser::Parse()
    4242{
    43   po::store(po::command_line_parser(argc,argv).options(cmdline_options).options(visible).positional(inputfile).run(), vm);
     43  po::store(po::command_line_parser(argc,argv).options(cmdline_options).run(), vm);
    4444  ifstream input;
    4545  input.open("example.cfg");
  • src/CommandLineParser.hpp

    r06f4ef6 rb6da28  
    1717#include <list>
    1818
     19/** This class is a wrapper for boost::program_options.
     20 *
     21 * <h1> CommandLine Howto </h1>
     22 * <h2> Introduction </h2>
     23 *
     24 * The UIFactory is a base class for the User Interaction. There are three UI specializations:
     25 * Text, GUI and CommandLine. Accessing functionality via the CommandLine UI is explained here.
     26 *
     27 * First, an Action has to be written for the specific functionality. This Action should
     28 * be added in Actions/...Action in the respective subdirectory of the following types:
     29 *  -# Analysis: Analysis actions like evaluating pair correlation, bonds, ...
     30 *  -# Atom: adding, removing, manipulating atoms
     31 *  -# Cmd: specifying data bases, verbosity, ...
     32 *  -# Fragmentation: fragmenting a system, performing graph analysis, ...
     33 *  -# Molecule: adding, removing, manipulating molecules
     34 *  -# Parser: Parsing files (loading, saving)
     35 *  -# Tesselation: obtaining (non)convex surface of a molecule, embedding, ...
     36 *  -# World: Setting Box dimensions, default name of new molecules, ...
     37 *
     38 *  The CommandLineUIFactory is a specialization of the UIFactory for parsing command
     39 *  line parameters, generating and executing actions there from.
     40 *
     41 *  The idea of the CommandLineFactory is explained elsewhere, here we would like to give a
     42 *  receipe for creating new actions.
     43 *
     44 * <h3>Introducing new actions</h3>
     45 *
     46 * Let us now introduce what to do if a new action is to be implemented. Here, we use the
     47 * CommandLineVersionAction as an example.
     48 * This consists if basically three parts:
     49 * 1. Create the files, write the classes and make them compilable
     50 *   - Create new source and header files in one of the above subfolders in the Actions folder,
     51 *     e.g. create VersionAction.cpp and VersionAction.hpp in Actions/Cmd/
     52 *   - Give it a sensible class name, the convention is <type><what it does>Action,
     53 *     where <type> is basically the naming (written out) of the subdirectory,
     54 *     e.g. class CommandLineVersionAction.
     55 *   - Add the source and header file to the respective variables in molecuilder/src/Makefile.am,
     56 *     e.g. if you add a Cmd action the variables are CMDACTIONSOURCE and CMDACTIONHEADER,
     57 *     such that they get compiled.
     58 * 2. Add an instance to the CommandLineUIFactory, such that they are known to the UI.
     59 *   - Add the header file as an include to UIElements/CommandLineWindow.cpp, e.g.
     60 *     #include "Actions/Cmd/VersionAction.hpp"
     61 *   - Add an instance of your class to the specific populater-function in
     62 *     UIElements/CommandLineWindow.cpp, e.g. for the above Cmd action, add to populateCmdActions()
     63 *     add new CommandLineVersionAction().
     64 *     This will automatically register in the ActionRegistry.
     65 * 3. Give them an option name, short hand an description, such that they can be referenced from
     66 *    the command line.
     67 *   - think of a new key name, e.g. "version", which is the long form of the command parameter,
     68 *     i.e. --version).
     69 *   - add this key to every map of MapofActions, i.e. to
     70 *     - MapofActions::DescriptionMap: the description which appears as help and tooltip
     71 *     - MapofActions::ShortFormMap: the short form of the command parameter (e.g. -v)
     72 *     - MapofActions::ValueMap: the value the command parameter has (do not create if it does not need one)
     73 *   - If your action requires additional parameters, these need to be added in the same manner as in
     74 *     the list item above.
     75 *
     76 *  Don't forget to write the actual code. :)
     77 *
     78 * <h3>Writing an action</h3>
     79 *
     80 *  As you write a new action you may think in terms of the command line, i.e. you want to use this
     81 *  new functionality you add by calling molecuilder as: ./molecuilder --super-action foobar.txt, where
     82 *  the key of your new action would be "super-action". While this is fine, keep in mind, that your action
     83 *  should be useable for the other UI specializations as well, i.e. from the menu and the GUI. Therefore,
     84 *  -# Don't use cin to ask the user for input: Use Query...()!
     85 *  -# Rather don't use cout/cerrs, but either give Log() or eLog() or use QueryEmpty() if you want to give
     86 *     the user specific information what you ask of him.
     87 *
     88 */
    1989class CommandLineParser : public Singleton<CommandLineParser> {
    2090  friend class Singleton<CommandLineParser>;
  • src/Descriptors/AtomDescriptor.cpp

    r06f4ef6 rb6da28  
    1212
    1313#include "World.hpp"
    14 
    1514#include "atom.hpp"
     15#include "Patterns/ObservedContainer_impl.hpp"
    1616
    1717#include <boost/bind.hpp>
    18 #include <cassert>
     18
    1919#include <iostream>
    2020
    2121using namespace std;
    2222
    23 typedef World::AtomSet::iterator atoms_iter_t;
     23typedef World::AtomSet::internal_iterator atoms_iter_t;
    2424
    2525/************************ Forwarding object **************************************/
     
    7474
    7575atom* AtomDescriptor_impl::find() {
    76   World::AtomSet atoms = getAtoms();
    77   atoms_iter_t res = find_if(atoms.begin(),atoms.end(),boost::bind(&AtomDescriptor_impl::predicate,this,_1));
    78   return (res!=atoms.end())?((*res).second):0;
     76  World::AtomSet &atoms = getAtoms();
     77  atoms_iter_t res = find_if(atoms.begin_internal(),atoms.end_internal(),boost::bind(&AtomDescriptor_impl::predicate,this,_1));
     78  return (res!=atoms.end_internal())?((*res).second):0;
    7979}
    8080
     
    8282  vector<atom*> res;
    8383  World::AtomSet atoms = getAtoms();
    84   atoms_iter_t iter;
    85   for(iter=atoms.begin();iter!=atoms.end();++iter) {
    86     if(predicate(*iter)){
    87       res.push_back((*iter).second);
    88     }
     84  for_each(atoms.begin_internal(),
     85           atoms.end_internal(),
     86           boost::bind(&AtomDescriptor_impl::checkAndAdd,
     87                       this,&res,_1));
     88  return res;
     89}
     90
     91void AtomDescriptor_impl::checkAndAdd(std::vector<atom*> *v,std::pair<atomId_t,atom*> p){
     92  if(predicate(p)){
     93    v->push_back(p.second);
    8994  }
    90   return res;
    9195}
    9296
  • src/Descriptors/AtomDescriptor.hpp

    r06f4ef6 rb6da28  
    3535  // close coupling to the world to allow access
    3636  friend atom* World::getAtom(AtomDescriptor descriptor);
    37   friend std::vector<atom*> World::getAllAtoms(AtomDescriptor descriptor);
     37  friend World::AtomComposite World::getAllAtoms(AtomDescriptor descriptor);
    3838  template <class,class,class> friend class SelectiveIterator;
    3939
  • src/Descriptors/AtomDescriptor_impl.hpp

    r06f4ef6 rb6da28  
    5050   */
    5151  World::AtomSet& getAtoms();
     52
     53  void checkAndAdd(std::vector<atom*>*,std::pair<atomId_t,atom*>);
    5254};
    5355
  • src/Descriptors/AtomIdDescriptor.cpp

    r06f4ef6 rb6da28  
    1212
    1313#include "atom.hpp"
     14#include "Patterns/ObservedContainer_impl.hpp"
    1415
    1516using namespace std;
     
    3233
    3334atom *AtomIdDescriptor_impl::find(){
    34   World::AtomSet atoms = getAtoms();
     35  World::AtomSet &atoms = getAtoms();
    3536  World::AtomSet::iterator res = atoms.find(id);
    3637  return (res!=atoms.end())?((*res).second):0;
  • src/Descriptors/MoleculeDescriptor.cpp

    r06f4ef6 rb6da28  
    1212
    1313#include "World.hpp"
     14#include "Patterns/ObservedContainer_impl.hpp"
    1415
    1516#include "molecule.hpp"
    1617
    1718#include <boost/bind.hpp>
    18 #include <cassert>
    1919#include <iostream>
    2020
    2121using namespace std;
    2222
    23 typedef World::MoleculeSet::iterator molecules_iter_t;
     23typedef World::MoleculeSet::internal_iterator molecules_iter_t;
    2424
    2525/************************ Forwarding object **************************************/
     
    7474
    7575molecule* MoleculeDescriptor_impl::find() {
    76   World::MoleculeSet molecules = getMolecules();
    77   molecules_iter_t res = find_if(molecules.begin(),molecules.end(),boost::bind(&MoleculeDescriptor_impl::predicate,this,_1));
    78   return (res!=molecules.end())?((*res).second):0;
     76  World::MoleculeSet &molecules = getMolecules();
     77  molecules_iter_t res = find_if(molecules.begin_internal(),molecules.end_internal(),boost::bind(&MoleculeDescriptor_impl::predicate,this,_1));
     78  return (res!=molecules.end_internal())?((*res).second):0;
    7979}
    8080
    8181vector<molecule*> MoleculeDescriptor_impl::findAll() {
    8282  vector<molecule*> res;
    83   World::MoleculeSet molecules = getMolecules();
    84   molecules_iter_t iter;
    85   for(iter=molecules.begin();iter!=molecules.end();++iter) {
    86     if(predicate(*iter)){
    87       res.push_back((*iter).second);
    88     }
     83  World::MoleculeSet &molecules = getMolecules();
     84  for_each(molecules.begin_internal(),
     85           molecules.end_internal(),
     86           boost::bind(&MoleculeDescriptor_impl::checkAndAdd,
     87                       this,&res,_1));
     88  return res;
     89}
     90
     91void MoleculeDescriptor_impl::checkAndAdd(std::vector<molecule*> *v,std::pair<moleculeId_t,molecule*> p){
     92  if(predicate(p)){
     93    v->push_back(p.second);
    8994  }
    90   return res;
    9195}
    9296
  • src/Descriptors/MoleculeDescriptor_impl.hpp

    r06f4ef6 rb6da28  
    5050   */
    5151  World::MoleculeSet& getMolecules();
     52
     53  void checkAndAdd(std::vector<molecule*>*,std::pair<moleculeId_t,molecule*>);
    5254};
    5355
  • src/Descriptors/MoleculeIdDescriptor.cpp

    r06f4ef6 rb6da28  
    1010#include "MoleculeIdDescriptor.hpp"
    1111#include "MoleculeIdDescriptor_impl.hpp"
     12
     13#include "Patterns/ObservedContainer_impl.hpp"
    1214
    1315#include "molecule.hpp"
     
    3234
    3335molecule *MoleculeIdDescriptor_impl::find(){
    34   World::MoleculeSet molecules = getMolecules();
     36  World::MoleculeSet &molecules = getMolecules();
    3537  World::MoleculeSet::iterator res = molecules.find(id);
    3638  return (res!=molecules.end())?((*res).second):0;
  • src/Descriptors/MoleculeNameDescriptor.cpp

    r06f4ef6 rb6da28  
    3030
    3131molecule *MoleculeNameDescriptor_impl::find(){
    32   World::MoleculeSet molecules = getMolecules();
     32  World::MoleculeSet &molecules = getMolecules();
    3333  World::MoleculeSet::iterator res = molecules.begin();
    3434  for (; res != molecules.end(); res++)
  • src/Descriptors/MoleculePtrDescriptor.cpp

    r06f4ef6 rb6da28  
    1010#include "MoleculePtrDescriptor.hpp"
    1111#include "MoleculePtrDescriptor_impl.hpp"
     12
     13#include "Patterns/ObservedContainer_impl.hpp"
    1214
    1315#include "molecule.hpp"
     
    3234
    3335molecule *MoleculePtrDescriptor_impl::find(){
    34   World::MoleculeSet molecules = getMolecules();
     36  World::MoleculeSet &molecules = getMolecules();
    3537  World::MoleculeSet::iterator res = molecules.find(ptr->getId());
    3638  return (res!=molecules.end())?((*res).second):0;
  • src/Exceptions/CustomException.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "CustomException.hpp"
     11#include <iostream>
    1112
    1213using namespace std;
  • src/Exceptions/CustomException.hpp

    r06f4ef6 rb6da28  
    1010
    1111#include <exception>
    12 #include <iostream>
     12#include <iosfwd>
     13#include <string>
    1314
    1415/**
  • src/Hbondangle.db

    r06f4ef6 rb6da28  
     1# atomicnumber angles for single, double and triple bond (-1 no angle)
    121       180     -1      -1
    235       180     131.0   109.2
  • src/Hbonddistance.db

    r06f4ef6 rb6da28  
     1#atomic number bond distances for single, double and triple bond (-1 no bond)
    121       0.74    -1      -1
    232       0.77429209      -1      -1
  • src/Helpers/Assert.cpp

    r06f4ef6 rb6da28  
    55 *      Author: crueger
    66 */
    7 
    8 #include "Helpers/MemDebug.hpp"
    97
    108#include "Helpers/Assert.hpp"
     
    4644}
    4745
    48 using namespace Assert;
    49 
    5046#ifndef NDEBUG
    5147
    52 Action _my_assert::defaultAction = Ask;
    53 std::vector<Assert::hook_t> _my_assert::hooks;
     48#ifdef __GNUC__
     49#include <cstdlib>
     50#include <execinfo.h>
     51#include <cxxabi.h>
     52#endif
    5453
    55 std::map<std::string,bool> _wrapper::ignores;
    56 const char* _wrapper::message_ptr = "source pointer did not point to object of desired type";
    57 const char* _wrapper::message_ref = "source reference did not contain object of desired type";
     54Assert::Action Assert::_my_assert::defaultAction = Ask;
     55std::vector<Assert::hook_t> Assert::_my_assert::hooks;
    5856
     57std::map<std::string,bool> Assert::_wrapper::ignores;
     58const char* Assert::_wrapper::message_ptr = "source pointer did not point to object of desired type";
     59const char* Assert::_wrapper::message_ref = "source reference did not contain object of desired type";
    5960
    60 bool _my_assert::check(const bool res,
    61                        const char* condition,
    62                        const char* message,
    63                        const char* filename,
    64                        const int line,
    65                        bool& ignore)
     61bool Assert::_my_assert::check(const char* condition,
     62                               const char* message,
     63                               const char* filename,
     64                               const int line,
     65                               bool& ignore)
    6666{
    67   if(!res){
    68     cout << "Assertion \"" << condition << "\" failed in file " << filename << " at line " << line << endl;
    69     cout << "Assertion Message: " << message << std::endl;
    70     while(true){
    71       char choice;
    72       if(defaultAction==Ask) {
    73         cout << "Please choose: (a)bort, (t)hrow execption, (i)gnore, al(w)ays ignore" << endl;
    74         cin >> choice;
    75       }
    76       else{
    77         choice = ActionKeys[defaultAction];
    78       }
    79       switch(choice){
    80         case 'a':
    81           return true;
    82           break;
    83         case 't':
    84           throw AssertionFailure(condition,filename,line,message);
    85           break;
    86         case 'w':
    87           ignore = true;
    88           // fallthrough
    89         case 'i':
    90           return false;
    91           break;
    92       }
     67  cout << "Assertion \"" << condition << "\" failed in file " << filename << " at line " << line << endl;
     68  cout << "Assertion Message: " << message << std::endl;
     69  while(true){
     70    char choice;
     71    if(defaultAction==Assert::Ask) {
     72#ifdef __GNUC__
     73      cout << "Please choose: (a)bort, (t)hrow execption, show (b)actrace, (i)gnore, al(w)ays ignore" << endl;
     74#else
     75      cout << "Please choose: (a)bort, (t)hrow execption, (i)gnore, al(w)ays ignore" << endl;
     76#endif /* __GNUC__ */
     77      cin >> choice;
     78    }
     79    else{
     80      choice = ActionKeys[defaultAction];
     81    }
     82    switch(choice){
     83      case 'a':
     84        return true;
     85        break;
     86      case 't':
     87        throw AssertionFailure(condition,filename,line,message);
     88        break;
     89#ifdef __GNUC__
     90      case 'b':
     91        Assert::_my_assert::backtrace(filename,line);
     92       break;
     93#endif /* __GNUC__ */
     94      case 'w':
     95        ignore = true;
     96        // fallthrough
     97      case 'i':
     98        return false;
     99        break;
    93100    }
    94101  }
     
    96103}
    97104
    98 void _my_assert::doHooks(){
     105#ifdef __GNUC__
     106void Assert::_my_assert::backtrace(const char *file, int line){
     107  const size_t max_depth = 100;
     108  void* stack_addrs[max_depth];
     109  size_t stack_depth;
     110  char **stack_strings=0;
     111  const char *func_name=0;
     112  size_t sz = 64;
     113
     114  // get the backtrace
     115  stack_depth   = ::backtrace(stack_addrs,max_depth);
     116  stack_strings = backtrace_symbols(stack_addrs, stack_depth);
     117  // used later for demangling
     118  // reserved here, so we can free it unconditionally
     119  char *dm_function = static_cast<char*>(malloc(sz));
     120  if(!dm_function){
     121    // malloc failed... we are out of luck
     122    cout << "cannot provide stack trace due to exhausted memory" << endl;
     123    return;
     124  }
     125
     126  cout << "Backtrace from  " << file << "@" << line << ":" << endl;
     127
     128  // i=2 because we don't want this function, nor the assertion handler
     129  for(unsigned int i=2;i<stack_depth-2;++i){
     130    // find the mangled function name
     131    char *begin = stack_strings[i];
     132    // function name starts with a (
     133    while(*begin && *begin!='(') ++begin;
     134    char *end=begin;
     135    while(*end && *end!='+') ++end;
     136
     137    // see if we found our function name
     138    if(*begin && *end){
     139      *begin++ = 0;
     140      *end = 0;
     141      // use the C++ demangler
     142
     143      int status;
     144      char *func_ret = abi::__cxa_demangle(begin, dm_function, &sz, &status);
     145      if(func_ret){
     146        // abi might have realloced...
     147        dm_function = func_ret;
     148        func_name = dm_function;
     149      }
     150      else{
     151        // demangling failed... get the function name without demangling
     152        func_name = begin;
     153      }
     154    }
     155    else{
     156      // function name not found... get the whole line
     157      func_name = stack_strings[i];
     158    }
     159    cout << func_name << endl;
     160  }
     161  free(dm_function);
     162  free(stack_strings); // malloc()ed by backtrace_symbols
     163}
     164#endif /* __GNUC__ */
     165
     166void Assert::_my_assert::doHooks(){
    99167  for(vector<hook_t>::reverse_iterator iter = hooks.rbegin(); iter!=hooks.rend(); ++iter ){
    100168    (*iter)();
     
    102170}
    103171
    104 void _my_assert::addHook(hook_t hook){
     172void Assert::_my_assert::addHook(hook_t hook){
    105173  hooks.push_back(hook);
    106174}
    107175
    108 void _my_assert::removeHook(Assert::hook_t hook){
     176void Assert::_my_assert::removeHook(Assert::hook_t hook){
    109177  for(vector<hook_t>::iterator iter = hooks.begin(); iter!=hooks.end();){
    110178    if((*iter)==hook){
     
    117185}
    118186
    119 void _my_assert::setDefault(Assert::Action action){
     187void Assert::_my_assert::setDefault(Assert::Action action){
    120188  defaultAction = action;
    121189}
    122 Assert::Action _my_assert::getDefault(){
     190Assert::Action Assert::_my_assert::getDefault(){
    123191  return defaultAction;
    124192}
    125 std::string _my_assert::printDefault(){
     193std::string Assert::_my_assert::printDefault(){
    126194  return ActionNames[defaultAction];
    127195}
  • src/Helpers/Assert.hpp

    r06f4ef6 rb6da28  
    1111#include<sstream>
    1212#include<string>
    13 #include<iostream>
     13#include<iosfwd>
    1414#include<vector>
    1515#include<map>
     
    234234      static bool ignore = false;\
    235235      if(!ignore){\
    236         if(Assert::_my_assert::check((condition),STRINGIFY(condition),(message),\
    237                                      __FILE__,__LINE__,ignore)){\
     236        if(!(condition) && Assert::_my_assert::check(STRINGIFY(condition),(message),\
     237                                                     __FILE__,__LINE__,ignore)){\
    238238          Assert::_my_assert::doHooks();\
    239239          DEBUG_BREAK;\
     
    247247                  static bool ignore = false; \
    248248                  if(!ignore){\
    249                           if(Assert::_my_assert::check(false,"Exception caught",(message),__FILE__,__LINE__,ignore)){\
     249                          if(Assert::_my_assert::check("Exception caught",(message),__FILE__,__LINE__,ignore)){\
    250250                            Assert::_my_assert::doHooks();\
    251           DEBUG_BREAK;\
     251                            DEBUG_BREAK;\
    252252                          }\
    253253                  }\
     
    299299    class _my_assert{
    300300    public:
    301       static bool check(const bool res,
    302                         const char* condition,
     301      static bool check(const char* condition,
    303302                        const char* message,
    304303                        const char* filename,
    305304                        const int line,
    306305                        bool& ignore);
     306#ifdef __GNUC__
     307      static void backtrace(const char *file, int line);
     308#endif /* __GNUC__ */
    307309      static void addHook(Assert::hook_t hook);
    308310      static void removeHook(Assert::hook_t hook);
     
    332334
    333335      if(!ignore){
    334         if(_my_assert::check(dynamic_cast<target>(src)==static_cast<target>(src),"type-safe typecast",
    335                                        message_ptr,file,line,ignore)){
     336        bool res = dynamic_cast<target>(src)==static_cast<target>(src);
     337        if(!res && _my_assert::check("type-safe typecast",message_ptr,file,line,ignore)){
    336338          _my_assert::doHooks();
    337339          DEBUG_BREAK;
     
    354356      catch(...){
    355357        if(!ignore){
    356           if(_my_assert::check(0,"type-safe typecast",message_ref,file,line,ignore)){
     358          if(_my_assert::check("type-safe typecast",message_ref,file,line,ignore)){
    357359            _my_assert::doHooks();
    358360            DEBUG_BREAK;
  • src/Helpers/MemDebug.cpp

    r06f4ef6 rb6da28  
    66 */
    77
    8 #ifndef NDBEGUG
    9 #ifndef NO_MEMDEBUG
     8// NDEBUG implies NO_MEMDEBUG
     9#ifdef NDEBUG
     10# ifndef NO_MEMDEBUG
     11#   define NO_MEMDEBUG
     12# endif
     13#endif
     14
     15// NO_MEMDEBUG and MEMDEBUG are mutually exclusive, but at least one must be set
     16#ifdef NO_MEMDEBUG
     17# ifdef MEMDEBUG
     18#   undef MEMDEBUG
     19# endif
     20#else
     21# ifndef MEMDEBUG
     22#   define MEMDEBUG
     23# endif
     24#endif
     25
     26#ifdef MEMDEBUG
    1027
    1128#include <iostream>
     
    5572  // all allocated memory blocks
    5673  struct entry_t {
     74    typedef unsigned int checksum_t;
    5775    // we seperate the tracking info from the rest
    5876    // A checksum will be calculated for this part of
     
    7391    } info;
    7492    bool isIgnored;
    75     char checksum;
     93    checksum_t checksum;
    7694    entry_t *prev;
    7795    entry_t *next;
     
    100118  // calculates a simple checksum for the info block
    101119  // the checksum is used to find memory corruptions
    102   inline char calcChecksum(entry_t::info_t *info){
     120  inline entry_t::checksum_t calcChecksum(entry_t::info_t *info){
    103121    char *buffer = (char*)info;
    104     char checksum =0;
     122    entry_t::checksum_t checksum =0;
    105123    for(size_t i=0;i<sizeof(entry_t::info_t);i++){
    106124      checksum+=buffer[i];
     
    137155      cout << "Chunk reserved at: " << pos->info.file << ":" << pos->info.line << endl;
    138156#endif
     157    }
     158  }
     159
     160  void dumpMemory(std::ostream &ost){
     161    ost << "Maximum allocated Memory: " << max << " bytes" << endl;
     162    ost << "Maximum allocated Memory: " << max << " bytes" << endl;
     163    ost << "Currently allocated Memory: " << state <<" bytes" << endl;
     164    ost << allocs << " allocated chunks total" << endl;
     165    bool corrupted=false;
     166    for(entry_t *pos=begin;pos;pos=pos->next){
     167      ost << "\nChunk of " << pos->info.nbytes << " bytes" << " still available" << endl;
     168#     ifdef __GNUC__
     169        ost << "Chunk reserved at: " << pos->info.function
     170             << " (" << pos->info.file << ":" << pos->info.line  << ")" << endl;
     171#     else
     172        ost << "Chunk reserved at: " << pos->info.file << ":" << pos->info.line << endl;
     173#     endif
     174        ost << "Chunk address: " << pos->info.location << endl;
     175        entry_t::checksum_t checksum = calcChecksum(&pos->info);
     176        ost << "Checksum of chunk: " << checksum << endl;
     177        ost << "Checksum at allocation time: " << pos->checksum << endl;
     178        if(checksum!=pos->checksum){
     179          ost << "!!!Chunk was corrupted!!!" << endl;
     180          corrupted=true;
     181        }
     182    }
     183    if(corrupted){
     184      ost << "\n!!!Memory corruption detected!!!" << endl;
    139185    }
    140186  }
     
    489535}
    490536#endif
    491 #endif
  • src/Helpers/MemDebug.hpp

    r06f4ef6 rb6da28  
    2121 * your sourcefiles.
    2222 */
    23 #ifndef NDEBUG
    24 #ifndef NO_MEMDEBUG
    2523
    26 #ifndef MEMDEBUG
    27 #define MEMDEBUG
     24// Set all flags in a way that makes sense
     25
     26// NDEBUG implies NO_MEMDEBUG
     27#ifdef NDEBUG
     28# ifndef NO_MEMDEBUG
     29#   define NO_MEMDEBUG
     30# endif
    2831#endif
     32
     33// NO_MEMDEBUG and MEMDEBUG are mutually exclusive, but at least one must be set
     34#ifdef NO_MEMDEBUG
     35# ifdef MEMDEBUG
     36#   undef MEMDEBUG
     37# endif
     38#else
     39# ifndef MEMDEBUG
     40#   define MEMDEBUG
     41# endif
     42#endif
     43
     44#ifdef MEMDEBUG
    2945
    3046#include <new>
     
    4561   */
    4662  void getState();
     63  void dumpMemory(std::ostream&);
    4764
    4865  void _ignore(void*);
     
    83100#endif
    84101
    85 #endif
    86 #endif
    87 
    88 
    89 #ifdef NDEBUG
    90 #undef MEMDEBUG
    91 #endif
    92 
    93 #ifndef MEMDEBUG
     102#else
    94103// memory debugging was disabled
    95104
    96105namespace Memory {
    97106  inline void getState(){}
     107
     108  inline void dumpMemory(std::ostream&){};
    98109
    99110  template <typename T>
     
    104115
    105116#endif
     117
     118
    106119#endif /* MEMDEBUG_HPP_ */
  • src/Legacy/oldmenu.cpp

    r06f4ef6 rb6da28  
    1010
    1111#include "Legacy/oldmenu.hpp"
     12#include "analysis_bonds.hpp"
    1213#include "analysis_correlation.hpp"
    1314#include "World.hpp"
     
    509510  Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl;
    510511  Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl;
     512  Log() << Verbose(0) << " h - count the number of hydrogen bonds" << endl;
    511513  Log() << Verbose(0) << "all else - go back" << endl;
    512514  Log() << Verbose(0) << "===============================================" << endl;
     
    574576        const LinkedCell *LCList = NULL;
    575577        LCList = new LinkedCell(mol, 10.);
    576         FindConvexBorder(mol, TesselStruct, LCList, NULL);
     578        Boundaries *BoundaryPoints = NULL;
     579        FindConvexBorder(mol, BoundaryPoints TesselStruct, LCList, NULL);
    577580        double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
    578581        Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl;\
     
    599602      }
    600603      break;
     604    case 'h':
     605      {
     606        int Z1;
     607        cout << "Please enter first interface element: ";
     608        cin >> Z1;
     609        const element * InterfaceElement = World::getInstance().getPeriode()->FindElement(Z1);
     610        int Z2;
     611        cout << "Please enter second interface element: ";
     612        cin >> Z2;
     613        const element * InterfaceElement2 = World::getInstance().getPeriode()->FindElement(Z2);
     614        cout << endl << "There are " << CountHydrogenBridgeBonds(World::getInstance().getMolecules(), InterfaceElement, InterfaceElement2) << " hydrogen bridges with connections to " << (InterfaceElement != 0 ? InterfaceElement->name : "None") << " and " << (InterfaceElement2 != 0 ? InterfaceElement2->name : "None") << "." << endl;
     615      }
     616      break;
    601617  }
    602618};
     
    609625{
    610626  int Order1;
     627  std::string path;
    611628  clock_t start, end;
    612629
     
    614631  Log() << Verbose(0) << "What's the desired bond order: ";
    615632  cin >> Order1;
     633  DoLog(0) && (Log() << Verbose(0) << "What's the output path and prefix [e.g. /home/foo/BondFragment]: ");
     634  cin >> path;
    616635  if (mol->hasBondStructure()) {
    617636    start = clock();
    618     mol->FragmentMolecule(Order1, configuration);
     637    mol->FragmentMolecule(Order1, path);
    619638    end = clock();
    620639    Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
  • src/Line.cpp

    r06f4ef6 rb6da28  
    215215}
    216216
     217std::vector<Vector> Line::getSphereIntersections() const{
     218  std::vector<Vector> res;
     219
     220  // line is kept in normalized form, so we can skip a lot of calculations
     221  double discriminant = 1-origin->NormSquared();
     222  // we might have 2, 1 or 0 solutions, depending on discriminant
     223  if(discriminant>=0){
     224    if(discriminant==0){
     225      res.push_back(*origin);
     226    }
     227    else{
     228      Vector helper = sqrt(discriminant)*(*direction);
     229      res.push_back(*origin+helper);
     230      res.push_back(*origin-helper);
     231    }
     232  }
     233  return res;
     234}
     235
    217236Line makeLineThrough(const Vector &x1, const Vector &x2){
    218237  if(x1==x2){
  • src/Line.hpp

    r06f4ef6 rb6da28  
    3838  Plane getOrthogonalPlane(const Vector &origin) const;
    3939
     40  std::vector<Vector> getSphereIntersections() const;
     41
    4042private:
    4143  std::auto_ptr<Vector> origin;
  • src/Makefile.am

    r06f4ef6 rb6da28  
    88  Helpers/Assert.cpp \
    99  Helpers/MemDebug.cpp
     10 
     11BASESOURCE = \
     12  ${HELPERSOURCE} \
     13  Space.cpp \
     14  vector.cpp
     15 
     16BASEHEADER = \
     17  ${HELPERHEADER} \
     18  Space.hpp \
     19  vector.hpp
    1020                       
    1121ATOMSOURCE = \
     
    3141
    3242LINALGSOURCE = \
    33   ${HELPERSOURCE} \
    3443  gslmatrix.cpp \
    3544  gslvector.cpp \
    36   linearsystemofequations.cpp \
    37   Space.cpp \
    38   vector.cpp
     45  linearsystemofequations.cpp
    3946                           
    40 LINALGHEADER = gslmatrix.hpp \
     47LINALGHEADER = \
     48  gslmatrix.hpp \
    4149  gslvector.hpp \
    42   linearsystemofequations.hpp \
    43   Space.hpp \
    44   vector.hpp
     50  linearsystemofequations.hpp
    4551                           
    4652ANALYSISSOURCE = \
     
    6369
    6470ACTIONSHEADER = \
    65   ${ANALYSISACTIONHEADER} \
    66   ${ATOMACTIONHEADER} \
    67   ${CMDACTIONHEADER} \
    68   ${FRAGMENTATIONACTIONHEADER} \
    69   ${MOLECULEACTIONHEADER} \
    70   ${PARSERACTIONHEADER} \
    71   ${TESSELATIONACTIONHEADER} \
    72   ${WORLDACTIONHEADER} \
    7371  Actions/Action.hpp \
    7472  Actions/ActionHistory.hpp \
     
    8381  Actions/MethodAction.hpp \
    8482  Actions/Process.hpp
    85  
     83
     84EXCEPTIONSOURCE = \
     85  Exceptions/CustomException.cpp \
     86  Exceptions/IllegalTypeException.cpp \
     87  Exceptions/LinearDependenceException.cpp \
     88  Exceptions/MathException.cpp \
     89  Exceptions/MissingValueException.cpp \
     90  Exceptions/NotInvertibleException.cpp \
     91  Exceptions/ParseError.cpp \
     92  Exceptions/SkewException.cpp \
     93  Exceptions/ZeroVectorException.cpp
     94                                 
     95EXCEPTIONHEADER = \
     96  Exceptions/CustomException.hpp \
     97  Exceptions/IllegalTypeException.hpp \
     98  Exceptions/LinearDependenceException.hpp \
     99  Exceptions/MathException.hpp \
     100  Exceptions/MissingValueException.hpp \
     101  Exceptions/NotInvertibleException.hpp \
     102  Exceptions/ParseError.hpp \
     103  Exceptions/SkewException.hpp \
     104  Exceptions/ZeroVectorException.hpp
    86105
    87106PARSERSOURCE = \
    88107  Parser/ChangeTracker.cpp \
    89108  Parser/FormatParser.cpp \
     109  Parser/FormatParserStorage.cpp \
     110  Parser/MpqcParser.cpp \
     111  Parser/PcpParser.cpp \
    90112  Parser/TremoloParser.cpp \
    91113  Parser/XyzParser.cpp
     114
    92115PARSERHEADER = \
    93116  Parser/ChangeTracker.hpp \
    94117  Parser/FormatParser.hpp \
     118  Parser/FormatParserStorage.hpp \
     119  Parser/MpqcParser.hpp \
     120  Parser/PcpParser.hpp \
    95121  Parser/TremoloParser.hpp \
    96122  Parser/XyzParser.hpp
     
    104130 
    105131SHAPESOURCE = \
    106   Shapes/Shape.cpp
     132  Shapes/BaseShapes.cpp \
     133  Shapes/Shape.cpp \
     134  Shapes/ShapeOps.cpp
    107135SHAPEHEADER = \
    108   Shapes/Shape.hpp
     136  Shapes/BaseShapes.hpp \
     137  Shapes/Shape.hpp \
     138  Shapes/ShapeOps.hpp
     139
    109140 
    110 
    111 # all these files are only used for legacy reasons while the transition is in progress
    112 # they are only needed to keep the program usable at any point of the transition and will be
    113 # deleted once everything is fully refactored
    114 LEGACYSOURCE = Legacy/oldmenu.cpp
    115 LEGACYHEADER = Legacy/oldmenu.hpp
    116 
    117141DESCRIPTORSOURCE = Descriptors/AtomDescriptor.cpp \
    118142  Descriptors/AtomIdDescriptor.cpp \
     143  Descriptors/AtomSelectionDescriptor.cpp \
    119144  Descriptors/AtomTypeDescriptor.cpp \
    120145  Descriptors/MoleculeDescriptor.cpp \
     146  Descriptors/MoleculeFormulaDescriptor.cpp \
    121147  Descriptors/MoleculeIdDescriptor.cpp \
    122148  Descriptors/MoleculeNameDescriptor.cpp \
    123   Descriptors/MoleculePtrDescriptor.cpp
     149  Descriptors/MoleculePtrDescriptor.cpp \
     150  Descriptors/MoleculeSelectionDescriptor.cpp
    124151                                   
    125152
    126153DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \
    127154  Descriptors/AtomIdDescriptor.hpp \
     155  Descriptors/AtomSelectionDescriptor.hpp \
    128156  Descriptors/AtomTypeDescriptor.hpp \
    129157  Descriptors/MoleculeDescriptor.hpp \
     158  Descriptors/MoleculeFormulaDescriptor.hpp \
    130159  Descriptors/MoleculeIdDescriptor.hpp \
    131160  Descriptors/MoleculeNameDescriptor.hpp \
    132   Descriptors/MoleculePtrDescriptor.hpp
    133                                    
    134 EXCEPTIONSOURCE = Exceptions/CustomException.cpp \
    135                                   Exceptions/LinearDependenceException.cpp \
    136                                   Exceptions/MathException.cpp \
    137                                   Exceptions/SkewException.cpp \
    138                                   Exceptions/ZeroVectorException.cpp
     161  Descriptors/MoleculePtrDescriptor.hpp \
     162  Descriptors/MoleculeSelectionDescriptor.cpp
     163
     164
     165QTUIMOC_HEADER = UIElements/QT4/QTDialog.hpp \
     166        UIElements/QT4/QTMainWindow.hpp \
     167        UIElements/Menu/QT4/QTMenu.hpp \
     168        UIElements/Views/QT4/QTWorldView.hpp \
     169        UIElements/Views/QT4/GLMoleculeView.hpp \
     170        UIElements/Views/QT4/QTMoleculeView.hpp \
     171        UIElements/Views/QT4/QTStatusBar.hpp
    139172                                 
    140 EXCEPTIONHEADER = Exceptions/CustomException.hpp \
    141                                   Exceptions/LinearDependenceException.hpp \
    142                                   Exceptions/MathException.hpp \
    143                                   Exceptions/SkewException.hpp \
    144                                   Exceptions/ZeroVectorException.hpp
     173QTUISOURCE = allmocs.moc.cpp \
     174        UIElements/QT4/QTMainWindow.cpp \
     175        UIElements/QT4/QTDialog.cpp \
     176        UIElements/QT4/QTUIFactory.cpp \
     177        UIElements/Menu/QT4/QTMenu.cpp \
     178        UIElements/Views/QT4/QTWorldView.cpp \
     179        UIElements/Views/QT4/GLMoleculeView.cpp \
     180        UIElements/Views/QT4/QTMoleculeView.cpp \
     181        UIElements/Views/QT4/QTStatusBar.cpp
     182             
     183QTUIHEADER = ${QTUIMOC_HEADER} UIElements/QT4/QTUIFactory.hpp
     184
     185QTUI_DEFS =
    145186
    146187SOURCE = \
     
    148189  ${ACTIONSSOURCE} \
    149190  ${ATOMSOURCE} \
     191  ${EXCEPTIONSOURCE} \
    150192  ${PATTERNSOURCE} \
    151193  ${PARSERSOURCE} \
    152194  ${SHAPESOURCE} \
    153195  ${DESCRIPTORSOURCE} \
    154   ${HELPERSOURCE} \
    155   ${LEGACYSOURCE} \
    156   ${EXCEPTIONSOURCE} \
    157196  bond.cpp \
    158197  bondgraph.cpp \
    159198  boundary.cpp \
     199  Box.cpp \
    160200  CommandLineParser.cpp \
    161201  config.cpp \
     202  ConfigFileBuffer.cpp \
    162203  element.cpp \
    163204  elements_db.cpp \
    164205  ellipsoid.cpp \
    165206  errorlogger.cpp \
     207  Formula.cpp \
    166208  graph.cpp \
    167209  helpers.cpp \
     
    172214  log.cpp \
    173215  logger.cpp \
     216  Matrix.cpp \
    174217  moleculelist.cpp \
    175218  molecule.cpp \
     
    182225  periodentafel.cpp \
    183226  Plane.cpp \
    184   Space.cpp \
    185227  tesselation.cpp \
    186228  tesselationhelpers.cpp \
     229  ThermoStatContainer.cpp \
    187230  triangleintersectionlist.cpp \
    188   vector.cpp \
     231  UIElements/UIFactory.cpp \
    189232  vector_ops.cpp \
    190233  verbose.cpp \
     
    195238  ${ACTIONSHEADER} \
    196239  ${ATOMHEADER} \
     240  ${EXCEPTIONHEADER} \
    197241  ${PARSERHEADER} \
    198242  ${PATTERNHEADER} \
    199243  ${SHAPEHEADER} \
    200244  ${DESCRIPTORHEADER} \
    201   ${EXCEPTIONHEADER} \
    202   ${LEGACYHEADER} \
    203245  bond.hpp \
    204246  bondgraph.hpp \
    205247  boundary.hpp \
     248  Box.hpp \
    206249  CommandLineParser.hpp \
    207250  config.hpp \
     251  ConfigFileBuffer.hpp \
    208252  defs.hpp \
    209253  element.hpp \
     
    211255  ellipsoid.hpp \
    212256  errorlogger.hpp \
     257  Formula.hpp \
    213258  graph.hpp \
    214259  helpers.hpp \
     
    220265  log.hpp \
    221266  logger.hpp \
     267  Matrix.hpp \
    222268  molecule.hpp \
    223269  molecule_template.hpp \
     
    228274  tesselation.hpp \
    229275  tesselationhelpers.hpp \
     276  ThermoStatContainer.hpp \
    230277  triangleintersectionlist.hpp \
     278  UIElements/UIFactory.hpp \
    231279  verbose.hpp \
    232280  vector_ops.hpp \
     
    240288
    241289BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB)
     290GUI_LIBS = ${QT_LDADD} ${QT_LIB_GUI} -lQtOpenGL ${GLU_LIBS}
    242291INCLUDES = -I$(top_srcdir)/src/unittests -I$(top_srcdir)/src/Actions -I$(top_srcdir)/src/UIElements
    243292
    244 noinst_LIBRARIES = libmolecuilder.a libgslwrapper.a
    245 bin_PROGRAMS = molecuilder joiner analyzer
     293noinst_LIBRARIES = libmolecuilderbase.a libmolecuilder.a libgslwrapper.a libmenu.a libparser.a
     294bin_PROGRAMS = molecuilder molecuildergui joiner analyzer
     295EXTRA_PROGRAMS = unity
     296
    246297molecuilderdir = ${bindir}
     298
     299libmolecuilderbase_a_SOURCES = ${BASESOURCE} ${BASEHEADER}
    247300libmolecuilder_a_SOURCES = ${SOURCE} ${HEADER}
     301libmenu_a_SOURCES = ${UISOURCE} ${UIHEADER}
     302libparser_a_SOURCES = ${PARSERSOURCE} ${PARSERHEADER}
    248303libgslwrapper_a_SOURCES = ${LINALGSOURCE} ${LINALGHEADER}
     304
    249305molecuilder_DATA = elements.db valence.db orbitals.db Hbonddistance.db Hbondangle.db
    250 molecuilder_LDFLAGS = $(BOOST_LDFLAGS)
    251 molecuilder_SOURCES = builder.cpp
    252 molecuilder_LDADD =  UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilder.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}
     306
     307molecuilder_CXXFLAGS = $(BOOST_CPPFLAGS)
     308#molecuilder_CXXFLAGS += -DNO_CACHING
     309molecuilder_LDFLAGS = $(BOOST_LIB)
     310molecuilder_SOURCES = ${LEGACYSOURCE} builder.cpp
     311molecuilder_SOURCES += $(srcdir)/version.c
     312molecuilder_LDADD = UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilderbase.a libmolecuilder.a libparser.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}
     313
     314#Stuff for building the GUI using QT
     315molecuildergui_SOURCES = ${QTUISOURCE} ${LEGACYSOURCE} builder.cpp
     316molecuildergui_SOURCES += $(srcdir)/version.c
     317molecuildergui_CXXFLAGS = ${QT_CXXFLAGS} ${GLU_CXXFLAGS} -DUSE_GUI_QT
     318molecuildergui_LDFLAGS = $(BOOST_LIB) ${QT_LDFLAGS} ${GLU_LDFLAGS}
     319molecuildergui_LDADD = UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilderbase.a libmolecuilder.a libparser.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}  ${GUI_LIBS}
     320
    253321joiner_SOURCES = joiner.cpp datacreator.cpp parser.cpp datacreator.hpp helpers.hpp parser.hpp periodentafel.hpp
    254 joiner_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
     322joiner_LDADD = libmolecuilder.a libmolecuilderbase.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
     323
    255324analyzer_SOURCES = analyzer.cpp datacreator.cpp parser.cpp helpers.hpp periodentafel.hpp parser.hpp datacreator.hpp
    256 analyzer_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
     325analyzer_LDADD = libmolecuilder.a libmolecuilderbase.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
     326
     327unity_SOURCES = unity.cpp $(srcdir)/version.c
     328unity_LDADD = $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}
     329
     330#Rules needed for QT4
     331# UI-Files are scattered throughout several subdirectories
     332# Therfore `%'-rules do not seem to work
     333#Quick fix to get it done otherwise
     334allmocs.moc.cpp: ${QTUIMOC_HEADER}
     335        echo "" > allmocs.moc.cpp;\
     336        list='$(QTUIMOC_HEADER)'; for header in $$list; do \
     337        echo "Making mocfile for $$header"; \
     338        target=`basename $$header | sed "s/\(.*\)\..*/\1.moc.cpp/"`;\
     339        $(MOC) $(srcdir)/$$header -o $$target \
     340        || eval $$failcom; \
     341        echo "#include \"$$target\"" >> allmocs.moc.cpp; \
     342        done;
     343
     344unity.cpp: ${LINALGSOURCE} ${LINALGHEADER} ${SOURCE} ${HEADER}
     345        echo "" >  unity.cpp; \
     346        list='$(BASESOURCE)'; for file in $$list; do \
     347          echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \
     348        done; \
     349        list='$(LINALGSOURCE)'; for file in $$list; do \
     350          echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \
     351        done; \
     352        list='$(SOURCE)'; for file in $$list; do \
     353          echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \
     354        done; \
     355        subdirs='$(SUBDIRS)';for directory in $$subdirs; do\
     356                olddir=$$PWD;\
     357                cd $$directory && make unity.cpp;\
     358                cd $$olddir;\
     359                echo "#include \"$$directory/unity.cpp\"" >> unity.cpp;\
     360        done;\
     361        echo "#include \"$(srcdir)/builder.cpp\"" >> unity.cpp;
     362
     363MOSTLYCLEANFILES = allmocs.moc.cpp unity.cpp
     364       
     365#EXTRA_DIST = ${molecuilder_DATA}
    257366
    258367FORCE:
    259368$(srcdir)/.git-version: FORCE
    260         @if (test -d $(top_srcdir)/../.git && cd $(srcdir) && git describe HEAD) > .git-version-t 2>/dev/null \
     369        @if (test -d $(top_srcdir)/.git && cd $(srcdir) \
     370             && { git describe --dirty --always || git describe; } ) > .git-version-t 2>/dev/null \
    261371          && ! diff .git-version-t $(srcdir)/.git-version >/dev/null 2>&1; then \
    262372          mv -f .git-version-t $(srcdir)/.git-version; \
     
    270380        echo "const char *ESPACKVersion = \"$(PACKAGE_NAME) -- git version: "`cat $(srcdir)/.git-version`"\";" > $@
    271381
    272 molecuilder_SOURCES += $(srcdir)/version.c
     382
  • src/Parser/ChangeTracker.cpp

    r06f4ef6 rb6da28  
    77
    88#include "Helpers/MemDebug.hpp"
     9#include "Parser/ChangeTracker.hpp"
     10#include "Patterns/Singleton_impl.hpp"
    911
    10 #include "ChangeTracker.hpp"
    11 
    12 ChangeTracker* ChangeTracker::instance = NULL;
    1312
    1413/**
     
    2726ChangeTracker::~ChangeTracker() {
    2827  World::getInstance().signOff(this);
    29 }
    30 
    31 /**
    32  * Returns the change tracker instance.
    33  *
    34  * \return this
    35  */
    36 ChangeTracker* ChangeTracker::get() {
    37   if (instance == NULL) {
    38     instance = new ChangeTracker();
    39   }
    40 
    41   return instance;
    42 }
    43 
    44 /**
    45  * Destroys the change tracker instance. Be careful, the change tracker is a
    46  * singleton and destruction might lead to a loss of consistency.
    47  */
    48 void ChangeTracker::destroy() {
    49   delete instance;
    50   instance = NULL;
    5128}
    5229
     
    7653  }
    7754}
     55
     56CONSTRUCT_SINGLETON(ChangeTracker)
  • src/Parser/ChangeTracker.hpp

    r06f4ef6 rb6da28  
    1818 * changes to it.
    1919 */
    20 class ChangeTracker : public Observable {
     20class ChangeTracker : public Singleton<ChangeTracker>, public Observable {
     21  friend class Singleton<ChangeTracker>;
    2122public:
    2223  void saveStatus();
     
    3132  bool isConsistent;
    3233  static ChangeTracker* instance;
     34
     35  // private constructor and destructor due to singleton
    3336  ChangeTracker();
    3437  ~ChangeTracker();
  • src/Parser/FormatParser.cpp

    r06f4ef6 rb6da28  
    1919  Observer("FormatParser")
    2020{
    21   ChangeTracker::get()->signOn(this);
     21  ChangeTracker::getInstance().signOn(this);
    2222  saveStream = NULL;
    2323}
     
    2727 */
    2828FormatParser::~FormatParser() {
    29   ChangeTracker::get()->signOff(this);
     29  ChangeTracker::getInstance().signOff(this);
    3030}
    3131
  • src/Parser/TremoloParser.cpp

    r06f4ef6 rb6da28  
    2121
    2222using namespace std;
    23 using namespace boost;
    2423
    2524/**
     
    4948  knownKeys["GrpTypeNo"] = TremoloKey::GrpTypeNo;
    5049  knownKeys["torsion"] = TremoloKey::torsion;
     50
     51  // default behavior: use all possible keys on output
     52  for (std::map<std::string, TremoloKey::atomDataKey>::iterator iter = knownKeys.begin(); iter != knownKeys.end(); ++iter)
     53    usedFields.push_back(iter->first);
    5154}
    5255
     
    193196
    194197  lineStream << line.substr(offset);
     198  usedFields.clear();
    195199  while (lineStream.good()) {
    196200    lineStream >> keyword;
  • src/Parser/TremoloParser.hpp

    r06f4ef6 rb6da28  
    1010
    1111#include <string>
    12 #include "FormatParser.hpp"
     12#include "Parser/FormatParser.hpp"
    1313
    1414/**
  • src/Parser/XyzParser.cpp

    r06f4ef6 rb6da28  
    2727 */
    2828XyzParser::~XyzParser() {
    29   delete(&comment);
    3029}
    3130
     
    5857 */
    5958void XyzParser::save(ostream* file) {
    60   *file << World::getInstance().numAtoms() << endl << comment << endl;
     59  if (comment == "") {
     60    time_t now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
     61    comment = "Created by molecuilder on ";
     62    // ctime ends in \n\0, we have to cut away the newline
     63    std::string time(ctime(&now));
     64    size_t pos = time.find('\n');
     65    if (pos != 0)
     66      comment += time.substr(0,pos);
     67    else
     68      comment += time;
     69  }
     70  *file << World::getInstance().numAtoms() << endl << "\t" << comment << endl;
    6171
    6272  vector<atom*> atoms = World::getInstance().getAllAtoms();
    6373  for(vector<atom*>::iterator it = atoms.begin(); it != atoms.end(); it++) {
    64     *file << fixed << (*it)->getType()->symbol << "\t" << (*it)->x[0] << "\t" << (*it)->x[1] << "\t" << (*it)->x[2] << endl;
     74    *file << noshowpoint << (*it)->getType()->symbol << "\t" << (*it)->x[0] << "\t" << (*it)->x[1] << "\t" << (*it)->x[2] << endl;
    6575  }
    6676}
  • src/Parser/XyzParser.hpp

    r06f4ef6 rb6da28  
    1010
    1111#include <string>
    12 #include "FormatParser.hpp"
     12#include "Parser/FormatParser.hpp"
    1313
    1414/**
  • src/Patterns/Cacheable.hpp

    r06f4ef6 rb6da28  
    1212#include <boost/function.hpp>
    1313#include <boost/shared_ptr.hpp>
    14 #include <iostream>
    1514
    1615#include "Helpers/Assert.hpp"
  • src/Patterns/ObservedIterator.hpp

    r06f4ef6 rb6da28  
    8484  {
    8585    --iter;
     86    return *this;
    8687  }
    8788
     
    105106    acquireLock();
    106107    return (*iter);
     108  }
     109
     110  value_type *operator->(){
     111    acquireLock();
     112    return &(*iter);
    107113  }
    108114
  • src/Patterns/Observer.hpp

    r06f4ef6 rb6da28  
    170170  //! @cond
    171171  // Structure for RAII-Style notification
    172 protected:
     172public:
    173173  /**
    174174   * This structure implements the Observer-mechanism RAII-Idiom.
     
    241241#define OBSERVE Observable::_Observable_protector PASTE(_scope_obs_protector_,__LINE__)(this)
    242242#define NOTIFY(notification) do{Observable::enque_notification_internal(this,notification);}while(0)
     243#define LOCK_OBSERVABLE(observable) Observable::_Observable_protector PASTE(_scope_obs_protector_,__LINE__)(&(observable))
    243244
    244245#endif /* OBSERVER_HPP_ */
  • src/Patterns/Singleton.hpp

    r06f4ef6 rb6da28  
    99#define SINGLETON_HPP_
    1010
    11 #include <cassert>
    1211#include <boost/thread.hpp>
    1312
     13#include "Helpers/Assert.hpp"
    1414#include "defs.hpp"
    1515
     
    181181
    182182    inline static void set(creator_T*&,creator_T*){
    183       assert(0 && "Cannot set the Instance for a singleton of this type");
     183      ASSERT(0, "Cannot set the Instance for a singleton of this type");
    184184    }
    185185  };
     
    191191  struct creator_t<creator_T,false>{
    192192    inline static creator_T* make(){
    193       assert(0 && "Cannot create a singleton of this type directly");
     193      ASSERT(0, "Cannot create a singleton of this type directly");
     194      return 0;
    194195    }
    195196    inline static void set(ptr_t& dest,creator_T* src){
  • src/Patterns/Singleton_impl.hpp

    r06f4ef6 rb6da28  
    7272template <class T,bool _may_create>
    7373void Singleton<T,_may_create>::setInstance(T* newInstance){
    74   assert(!theInstance.get() && "Trying to set the instance of an already created singleton");
     74  ASSERT(!theInstance.get(), "Trying to set the instance of an already created singleton");
    7575  boost::recursive_mutex::scoped_lock guard(instanceLock);
    7676  theInstance.reset(newInstance);
     
    8383template <class T, bool _may_create>
    8484Singleton<T,_may_create>::Singleton(const Singleton<T,_may_create>&){
    85   assert(0 && "Copy constructor of singleton template called");
     85  ASSERT(0, "Copy constructor of singleton template called");
    8686}
    8787
  • src/Plane.hpp

    r06f4ef6 rb6da28  
    1111#include <memory>
    1212#include <vector>
    13 #include <iostream>
     13#include <iosfwd>
    1414#include "Space.hpp"
    1515#include "Exceptions/LinearDependenceException.hpp"
  • src/Shapes/Shape.cpp

    r06f4ef6 rb6da28  
    1515Shape::~Shape(){}
    1616
    17 bool Shape::isInside(const Vector &point){
     17bool Shape::isInside(const Vector &point) const{
    1818  return impl->isInside(point);
    1919}
     
    3232Shape::impl_ptr Shape::getImpl() const{
    3333  return impl;
     34}
     35
     36// allows arbitrary friendship, but only if implementation is known
     37Shape::impl_ptr getShapeImpl(const Shape &shape){
     38  return shape.getImpl();
    3439}
    3540
     
    6166
    6267Shape operator&&(const Shape &lhs,const Shape &rhs){
    63   Shape::impl_ptr newImpl = Shape::impl_ptr(new AndShape_impl(lhs.getImpl(),rhs.getImpl()));
     68  Shape::impl_ptr newImpl = Shape::impl_ptr(new AndShape_impl(getShapeImpl(lhs),getShapeImpl(rhs)));
    6469  return Shape(newImpl);
    6570}
     
    7883
    7984Shape operator||(const Shape &lhs,const Shape &rhs){
    80   Shape::impl_ptr newImpl = Shape::impl_ptr(new OrShape_impl(lhs.getImpl(),rhs.getImpl()));
     85  Shape::impl_ptr newImpl = Shape::impl_ptr(new OrShape_impl(getShapeImpl(lhs),getShapeImpl(rhs)));
    8186  return Shape(newImpl);
    8287}
     
    95100
    96101Shape operator!(const Shape &arg){
    97   Shape::impl_ptr newImpl = Shape::impl_ptr(new NotShape_impl(arg.getImpl()));
     102  Shape::impl_ptr newImpl = Shape::impl_ptr(new NotShape_impl(getShapeImpl(arg)));
    98103  return Shape(newImpl);
    99104}
  • src/Shapes/Shape.hpp

    r06f4ef6 rb6da28  
    1616class Shape
    1717{
    18 friend Shape operator&&(const Shape&,const Shape&);
    19 friend Shape operator||(const Shape&,const Shape&);
    20 friend Shape operator!(const Shape&);
    2118public:
    2219  typedef boost::shared_ptr<Shape_impl> impl_ptr;
     20  friend impl_ptr getShapeImpl(const Shape&);
    2321
    2422  Shape(impl_ptr);
     
    2624  virtual ~Shape();
    2725
    28   bool isInside(const Vector &point);
     26  bool isInside(const Vector &point) const;
    2927
    3028  Shape &operator=(const Shape& rhs);
  • src/Shapes/Shape_impl.hpp

    r06f4ef6 rb6da28  
    1313class Shape_impl {
    1414public:
     15  Shape_impl(){};
     16  virtual ~Shape_impl(){};
    1517  virtual bool isInside(const Vector &point)=0;
    1618};
     
    5860};
    5961
     62Shape::impl_ptr getShapeImpl(const Shape&);
     63
    6064#endif /* SHAPE_IMPL_HPP_ */
  • src/UIElements/CommandLineUI/CommandLineDialog.cpp

    r06f4ef6 rb6da28  
    2424#include "defs.hpp"
    2525#include "log.hpp"
     26#include "Matrix.hpp"
    2627#include "periodentafel.hpp"
    2728#include "verbose.hpp"
    2829#include "World.hpp"
     30#include "Box.hpp"
    2931
    3032#include "atom.hpp"
     
    4951}
    5052
    51 void CommandLineDialog::queryInt(const char* title, int* target, string _description){
    52   registerQuery(new IntCommandLineQuery(title,target, _description));
    53 }
    54 
    55 void CommandLineDialog::queryBoolean(const char* title, bool* target, string _description){
    56   registerQuery(new BooleanCommandLineQuery(title,target, _description));
    57 }
    58 
    59 void CommandLineDialog::queryDouble(const char* title, double* target, string _description){
    60   registerQuery(new DoubleCommandLineQuery(title,target, _description));
    61 }
    62 
    63 void CommandLineDialog::queryString(const char* title, string* target, string _description){
    64   registerQuery(new StringCommandLineQuery(title,target, _description));
    65 }
    66 
    67 void CommandLineDialog::queryAtom(const char* title, atom **target, string _description) {
    68   registerQuery(new AtomCommandLineQuery(title,target, _description));
    69 }
    70 
    71 void CommandLineDialog::queryMolecule(const char* title, molecule **target, string _description) {
    72   registerQuery(new MoleculeCommandLineQuery(title,target, _description));
    73 }
    74 
    75 void CommandLineDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check, string _description) {
    76   registerQuery(new VectorCommandLineQuery(title,target,cellSize,check, _description));
    77 }
    78 
    79 void CommandLineDialog::queryBox(const char* title, double ** const cellSize, string _description) {
    80   registerQuery(new BoxCommandLineQuery(title,cellSize,_description));
    81 }
    82 
    83 void CommandLineDialog::queryElement(const char* title, std::vector<element *> *target, string _description){
    84   registerQuery(new ElementCommandLineQuery(title,target, _description));
     53void CommandLineDialog::queryInt(const char* title, string _description){
     54  registerQuery(new IntCommandLineQuery(title, _description));
     55}
     56
     57void CommandLineDialog::queryInts(const char* title, string _description){
     58  registerQuery(new IntsCommandLineQuery(title, _description));
     59}
     60
     61void CommandLineDialog::queryBoolean(const char* title, string _description){
     62  registerQuery(new BooleanCommandLineQuery(title, _description));
     63}
     64
     65void CommandLineDialog::queryDouble(const char* title, string _description){
     66  registerQuery(new DoubleCommandLineQuery(title, _description));
     67}
     68
     69void CommandLineDialog::queryDoubles(const char* title, string _description){
     70  registerQuery(new DoublesCommandLineQuery(title, _description));
     71}
     72
     73void CommandLineDialog::queryString(const char* title, string _description){
     74  registerQuery(new StringCommandLineQuery(title, _description));
     75}
     76
     77void CommandLineDialog::queryStrings(const char* title, string _description){
     78  registerQuery(new StringsCommandLineQuery(title, _description));
     79}
     80
     81void CommandLineDialog::queryAtom(const char* title, string _description) {
     82  registerQuery(new AtomCommandLineQuery(title, _description));
     83}
     84
     85void CommandLineDialog::queryAtoms(const char* title, string _description) {
     86  registerQuery(new AtomsCommandLineQuery(title, _description));
     87}
     88
     89void CommandLineDialog::queryMolecule(const char* title, string _description) {
     90  registerQuery(new MoleculeCommandLineQuery(title, _description));
     91}
     92
     93void CommandLineDialog::queryMolecules(const char* title, string _description) {
     94  registerQuery(new MoleculesCommandLineQuery(title, _description));
     95}
     96
     97void CommandLineDialog::queryVector(const char* title, bool check, string _description) {
     98  registerQuery(new VectorCommandLineQuery(title,check, _description));
     99}
     100
     101void CommandLineDialog::queryVectors(const char* title, bool check, string _description) {
     102  registerQuery(new VectorsCommandLineQuery(title,check, _description));
     103}
     104
     105void CommandLineDialog::queryBox(const char* title, string _description) {
     106  registerQuery(new BoxCommandLineQuery(title,_description));
     107}
     108
     109void CommandLineDialog::queryElement(const char* title, string _description){
     110  registerQuery(new ElementCommandLineQuery(title, _description));
     111}
     112
     113void CommandLineDialog::queryElements(const char* title, string _description){
     114  registerQuery(new ElementsCommandLineQuery(title, _description));
    85115}
    86116
     
    98128}
    99129
    100 CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title,int *_target, string _description) :
    101     Dialog::IntQuery(title,_target, _description)
     130CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title, string _description) :
     131    Dialog::IntQuery(title, _description)
    102132{}
    103133
     
    114144}
    115145
    116 CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title,bool *_target, string _description) :
    117     Dialog::BooleanQuery(title,_target, _description)
     146CommandLineDialog::IntsCommandLineQuery::IntsCommandLineQuery(string title, string _description) :
     147    Dialog::IntsQuery(title, _description)
     148{}
     149
     150CommandLineDialog::IntsCommandLineQuery::~IntsCommandLineQuery() {}
     151
     152bool CommandLineDialog::IntsCommandLineQuery::handle() {
     153  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     154    tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >();
     155    return true;
     156  } else {
     157    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integers for " << getTitle() << "." << endl);
     158    return false;
     159  }
     160}
     161
     162CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title, string _description) :
     163    Dialog::BooleanQuery(title, _description)
    118164{}
    119165
     
    130176}
    131177
    132 CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title,string *_target, string _description) :
    133     Dialog::StringQuery(title,_target, _description)
     178CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title, string _description) :
     179    Dialog::StringQuery(title, _description)
    134180{}
    135181
     
    146192}
    147193
    148 CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title,double *_target, string _description) :
    149     Dialog::DoubleQuery(title,_target, _description)
     194CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title, string _description) :
     195    Dialog::StringsQuery(title, _description)
     196{}
     197
     198CommandLineDialog::StringsCommandLineQuery::~StringsCommandLineQuery() {}
     199
     200bool CommandLineDialog::StringsCommandLineQuery::handle() {
     201  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     202    tmp = CommandLineParser::getInstance().vm[getTitle()].as< vector<string> >();
     203    return true;
     204  } else {
     205    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing strings for " << getTitle() << "." << endl);
     206    return false;
     207  }
     208}
     209
     210CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title, string _description) :
     211    Dialog::DoubleQuery(title, _description)
    150212{}
    151213
     
    162224}
    163225
    164 CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, atom **_target, string _description) :
    165     Dialog::AtomQuery(title,_target, _description)
     226CommandLineDialog::DoublesCommandLineQuery::DoublesCommandLineQuery(string title, string _description) :
     227    Dialog::DoublesQuery(title, _description)
     228{}
     229
     230CommandLineDialog::DoublesCommandLineQuery::~DoublesCommandLineQuery() {}
     231
     232bool CommandLineDialog::DoublesCommandLineQuery::handle() {
     233  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     234    tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<double> >();
     235    return true;
     236  } else {
     237    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing doubles for " << getTitle() << "." << endl);
     238    return false;
     239  }
     240}
     241
     242CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, string _description) :
     243    Dialog::AtomQuery(title, _description)
    166244{}
    167245
     
    180258}
    181259
    182 CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, string _description) :
    183     Dialog::MoleculeQuery(title,_target, _description)
     260CommandLineDialog::AtomsCommandLineQuery::AtomsCommandLineQuery(string title, string _description) :
     261    Dialog::AtomsQuery(title, _description)
     262{}
     263
     264CommandLineDialog::AtomsCommandLineQuery::~AtomsCommandLineQuery() {}
     265
     266bool CommandLineDialog::AtomsCommandLineQuery::handle() {
     267  std::vector<int> IdxOfAtom;
     268  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     269    IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >();
     270    for (std::vector<int>::iterator iter = IdxOfAtom.begin(); iter != IdxOfAtom.end(); ++iter) {
     271      temp = World::getInstance().getAtom(AtomById(*iter));
     272      if (temp)
     273        tmp.push_back(temp);
     274    }
     275    return true;
     276  } else {
     277    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atoms for " << getTitle() << "." << endl);
     278    return false;
     279  }
     280}
     281
     282CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, string _description) :
     283    Dialog::MoleculeQuery(title, _description)
    184284{}
    185285
     
    190290  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    191291    IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as<int>();
    192     cout << "IdxOfMol " << IdxOfMol << endl;
    193     if (IdxOfMol >= 0)
    194       tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol));
    195     else
    196       tmp = NULL;
     292    tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol));
    197293    return true;
    198294  } else {
     
    202298}
    203299
    204 CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, Vector *_target, const double *const _cellSize, bool _check, string _description) :
    205     Dialog::VectorQuery(title,_target,_cellSize,_check, _description)
     300CommandLineDialog::MoleculesCommandLineQuery::MoleculesCommandLineQuery(string title, string _description) :
     301    Dialog::MoleculesQuery(title, _description)
     302{}
     303
     304CommandLineDialog::MoleculesCommandLineQuery::~MoleculesCommandLineQuery() {}
     305
     306bool CommandLineDialog::MoleculesCommandLineQuery::handle() {
     307  std::vector<int> IdxOfMol;
     308  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     309    IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >();
     310    for (std::vector<int>::iterator iter = IdxOfMol.begin(); iter != IdxOfMol.end(); ++iter) {
     311      temp = World::getInstance().getMolecule(MoleculeById(*iter));
     312      if (temp)
     313        tmp.push_back(temp);
     314    }
     315    return true;
     316  } else {
     317    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecules for " << getTitle() << "." << endl);
     318    return false;
     319  }
     320}
     321
     322CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, bool _check, string _description) :
     323    Dialog::VectorQuery(title,_check, _description)
    206324{}
    207325
     
    213331  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    214332    temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >();
    215     tmp->at(0) = temp.x;
    216     tmp->at(1) = temp.y;
    217     tmp->at(2) = temp.z;
     333    tmp[0] = temp.x;
     334    tmp[1] = temp.y;
     335    tmp[2] = temp.z;
     336    if ((check) && (!World::getInstance().getDomain().isInside(tmp))) {
     337      DoeLog(1) && (eLog() << Verbose(1) << "Vector " << tmp << " would be outside of box domain." << endl);
     338      return false;
     339    }
    218340    return true;
    219341  } else {
     
    223345}
    224346
    225 
    226 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, double ** const _cellSize, string _description) :
    227     Dialog::BoxQuery(title,_cellSize, _description)
     347CommandLineDialog::VectorsCommandLineQuery::VectorsCommandLineQuery(string title, bool _check, string _description) :
     348    Dialog::VectorsQuery(title,_check, _description)
     349{}
     350
     351CommandLineDialog::VectorsCommandLineQuery::~VectorsCommandLineQuery()
     352{}
     353
     354bool CommandLineDialog::VectorsCommandLineQuery::handle() {
     355  std::vector<VectorValue> temporary;
     356  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     357    temporary = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<VectorValue> >();
     358    for(std::vector<VectorValue>::iterator iter = temporary.begin(); iter != temporary.end(); ++iter) {
     359      temp[0] = (*iter).x;
     360      temp[1] = (*iter).y;
     361      temp[2] = (*iter).z;
     362      if ((!check) || (World::getInstance().getDomain().isInside(temp)))
     363        tmp.push_back(temp);
     364      else
     365        DoeLog(1) && (eLog() << Verbose(1) << "Vector " << temp << " would be outside of box domain." << endl);
     366    }
     367    return true;
     368  } else {
     369    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vectors for " << getTitle() << "." << endl);
     370    return false;
     371  }
     372}
     373
     374CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, string _description) :
     375    Dialog::BoxQuery(title, _description)
    228376{}
    229377
     
    235383  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    236384    temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >();
    237     tmp[0] = temp.xx;
    238     tmp[1] = temp.xy;
    239     tmp[2] = temp.xz;
    240     tmp[3] = temp.yy;
    241     tmp[4] = temp.yz;
    242     tmp[5] = temp.zz;
     385    Matrix M;
     386    M.set(0,0, temp.xx);
     387    M.set(0,1, temp.yx);
     388    M.set(0,2, temp.zx);
     389    M.set(1,0, temp.yx);
     390    M.set(1,1, temp.yy);
     391    M.set(1,2, temp.zy);
     392    M.set(2,0, temp.zx);
     393    M.set(2,1, temp.zy);
     394    M.set(2,2, temp.zz);
     395    tmp.setM(M);
    243396    return true;
    244397  } else {
     
    248401}
    249402
    250 CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, std::vector<element *> *target, string _description) :
    251     Dialog::ElementQuery(title,target, _description)
     403CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, string _description) :
     404    Dialog::ElementQuery(title, _description)
    252405{}
    253406
     
    258411  // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
    259412  periodentafel *periode = World::getInstance().getPeriode();
    260   element *elemental = NULL;
     413  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     414    int Z = CommandLineParser::getInstance().vm[getTitle()].as< int >();
     415    tmp = periode->FindElement(Z);
     416    ASSERT(tmp != NULL, "Invalid element specified in ElementCommandLineQuery");
     417    return true;
     418  } else {
     419    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl);
     420    return false;
     421  }
     422}
     423
     424CommandLineDialog::ElementsCommandLineQuery::ElementsCommandLineQuery(string title, string _description) :
     425    Dialog::ElementsQuery(title, _description)
     426{}
     427
     428CommandLineDialog::ElementsCommandLineQuery::~ElementsCommandLineQuery()
     429{}
     430
     431bool CommandLineDialog::ElementsCommandLineQuery::handle() {
     432  // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
     433  periodentafel *periode = World::getInstance().getPeriode();
    261434  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    262435    vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >();
    263436    for (vector<int>::iterator ZRunner = AllElements.begin(); ZRunner != AllElements.end(); ++ZRunner) {
    264       elemental = periode->FindElement(*ZRunner);
    265       ASSERT(elemental != NULL, "Invalid element specified in ElementCommandLineQuery");
    266       elements.push_back(elemental);
     437      temp = periode->FindElement(*ZRunner);
     438      ASSERT(temp != NULL, "Invalid element specified in ElementCommandLineQuery");
     439      tmp.push_back(temp);
    267440    }
    268441    return true;
    269442  } else {
    270     DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl);
    271     return false;
    272   }
    273 }
     443    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing elements for " << getTitle() << "." << endl);
     444    return false;
     445  }
     446}
  • src/UIElements/CommandLineUI/CommandLineDialog.hpp

    r06f4ef6 rb6da28  
    2828
    2929  virtual void queryEmpty(const char *, std::string = "");
    30   virtual void queryInt(const char *, int *, std::string = "");
    31   virtual void queryBoolean(const char *, bool *, std::string = "");
    32   virtual void queryString(const char*, std::string *, std::string = "");
    33   virtual void queryDouble(const char*, double*, std::string = "");
    34   virtual void queryAtom(const char*,atom**, std::string = "");
    35   virtual void queryMolecule(const char*,molecule**,std::string = "");
    36   virtual void queryVector(const char*,Vector *,const double * const,bool, std::string = "");
    37   virtual void queryBox(const char*,double ** const, std::string = "");
    38   virtual void queryElement(const char*, std::vector<element *> *, std::string = "");
     30  virtual void queryInt(const char *, std::string = "");
     31  virtual void queryInts(const char *, std::string = "");
     32  virtual void queryBoolean(const char *, std::string = "");
     33  virtual void queryString(const char*, std::string = "");
     34  virtual void queryStrings(const char*, std::string = "");
     35  virtual void queryDouble(const char*, std::string = "");
     36  virtual void queryDoubles(const char*, std::string = "");
     37  virtual void queryAtom(const char*, std::string = "");
     38  virtual void queryAtoms(const char*, std::string = "");
     39  virtual void queryMolecule(const char*, std::string = "");
     40  virtual void queryMolecules(const char*, std::string = "");
     41  virtual void queryVector(const char*, bool, std::string = "");
     42  virtual void queryVectors(const char*, bool, std::string = "");
     43  virtual void queryBox(const char*, std::string = "");
     44  virtual void queryElement(const char*, std::string = "");
     45  virtual void queryElements(const char*, std::string = "");
    3946
    4047protected:
     
    4956  class IntCommandLineQuery : public Dialog::IntQuery {
    5057  public:
    51     IntCommandLineQuery(std::string title, int *_target, std::string _description = "");
     58    IntCommandLineQuery(std::string title, std::string _description = "");
    5259    virtual ~IntCommandLineQuery();
     60    virtual bool handle();
     61  };
     62
     63  class IntsCommandLineQuery : public Dialog::IntsQuery {
     64  public:
     65    IntsCommandLineQuery(std::string title, std::string _description = "");
     66    virtual ~IntsCommandLineQuery();
    5367    virtual bool handle();
    5468  };
     
    5670  class BooleanCommandLineQuery : public Dialog::BooleanQuery {
    5771  public:
    58     BooleanCommandLineQuery(std::string title, bool *_target, std::string _description = "");
     72    BooleanCommandLineQuery(std::string title, std::string _description = "");
    5973    virtual ~BooleanCommandLineQuery();
    6074    virtual bool handle();
     
    6377  class DoubleCommandLineQuery : public Dialog::DoubleQuery {
    6478  public:
    65     DoubleCommandLineQuery(std::string title, double *_target, std::string _description = "");
     79    DoubleCommandLineQuery(std::string title, std::string _description = "");
    6680    virtual ~DoubleCommandLineQuery();
     81    virtual bool handle();
     82  };
     83
     84  class DoublesCommandLineQuery : public Dialog::DoublesQuery {
     85  public:
     86    DoublesCommandLineQuery(std::string title, std::string _description = "");
     87    virtual ~DoublesCommandLineQuery();
    6788    virtual bool handle();
    6889  };
     
    7091  class StringCommandLineQuery : public Dialog::StringQuery {
    7192  public:
    72     StringCommandLineQuery(std::string title, std::string *_target, std::string _description = "");
     93    StringCommandLineQuery(std::string title, std::string _description = "");
    7394    virtual ~StringCommandLineQuery();
     95    virtual bool handle();
     96  };
     97
     98  class StringsCommandLineQuery : public Dialog::StringsQuery {
     99  public:
     100    StringsCommandLineQuery(std::string title, std::string _description = "");
     101    virtual ~StringsCommandLineQuery();
    74102    virtual bool handle();
    75103  };
     
    77105  class AtomCommandLineQuery : public Dialog::AtomQuery {
    78106  public:
    79     AtomCommandLineQuery(std::string title, atom **_target, std::string _description = "");
     107    AtomCommandLineQuery(std::string title, std::string _description = "");
    80108    virtual ~AtomCommandLineQuery();
     109    virtual bool handle();
     110  };
     111
     112  class AtomsCommandLineQuery : public Dialog::AtomsQuery {
     113  public:
     114    AtomsCommandLineQuery(std::string title, std::string _description = "");
     115    virtual ~AtomsCommandLineQuery();
    81116    virtual bool handle();
    82117  };
     
    84119  class MoleculeCommandLineQuery : public Dialog::MoleculeQuery {
    85120  public:
    86     MoleculeCommandLineQuery(std::string title, molecule **_target, std::string _description = "");
     121    MoleculeCommandLineQuery(std::string title, std::string _description = "");
    87122    virtual ~MoleculeCommandLineQuery();
     123    virtual bool handle();
     124  };
     125
     126  class MoleculesCommandLineQuery : public Dialog::MoleculesQuery {
     127  public:
     128    MoleculesCommandLineQuery(std::string title, std::string _description = "");
     129    virtual ~MoleculesCommandLineQuery();
    88130    virtual bool handle();
    89131  };
     
    91133  class VectorCommandLineQuery : public Dialog::VectorQuery {
    92134  public:
    93     VectorCommandLineQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description = "");
     135    VectorCommandLineQuery(std::string title,bool _check, std::string _description = "");
    94136    virtual ~VectorCommandLineQuery();
     137    virtual bool handle();
     138  };
     139
     140  class VectorsCommandLineQuery : public Dialog::VectorsQuery {
     141  public:
     142    VectorsCommandLineQuery(std::string title,bool _check, std::string _description = "");
     143    virtual ~VectorsCommandLineQuery();
    95144    virtual bool handle();
    96145  };
     
    98147  class BoxCommandLineQuery : public Dialog::BoxQuery {
    99148  public:
    100     BoxCommandLineQuery(std::string title,double ** const _cellSize, std::string _description = "");
     149    BoxCommandLineQuery(std::string title, std::string _description = "");
    101150    virtual ~BoxCommandLineQuery();
    102151    virtual bool handle();
     
    105154  class ElementCommandLineQuery : public Dialog::ElementQuery {
    106155  public:
    107     ElementCommandLineQuery(std::string title, std::vector<element *> *_target, std::string _description = "");
     156    ElementCommandLineQuery(std::string title, std::string _description = "");
    108157    virtual ~ElementCommandLineQuery();
     158    virtual bool handle();
     159  };
     160
     161  class ElementsCommandLineQuery : public Dialog::ElementsQuery {
     162  public:
     163    ElementsCommandLineQuery(std::string title, std::string _description = "");
     164    virtual ~ElementsCommandLineQuery();
    109165    virtual bool handle();
    110166  };
  • src/UIElements/CommandLineUI/CommandLineUIFactory.hpp

    r06f4ef6 rb6da28  
    1111#include "UIFactory.hpp"
    1212
     13/** This class is a specialization of the UIFactory.
     14 *
     15 * <h2> Introduction </h2>
     16 *
     17 * The UIFactory is a base class for the User Interaction. There are three UI specializations:
     18 * Text, GUI and CommandLine.
     19 *
     20 * The idea of the command line part is as follows:
     21 *
     22 * All actions that can be called from the command line are instantiated via populater-functions.
     23 * In the constructor of an action it is automatically registered with the ActionRegistry and can
     24 * henceforth be looked up there.
     25 *
     26 * There is a CommandLineParser which parses the command line parameters and puts all found values
     27 * into a map. Then, MainWindow::Display of the CommandLineUIFactory is called, which goes through
     28 * every action (by the ActionRegistry) and looks through the parsed commands whether the action is
     29 * desired.
     30 *
     31 * In the action itself, Query's ask for user input. In the CommandLine case, we don't want direct
     32 * user interaction, but the user has to have those values already delivered along with the desired
     33 * action. Hence, the Query implementations just look up the desired values in the CommandLineParser
     34 * vaults. When they are not found, an exception is thrown. When all are found, the action is performed.
     35 *
     36 */
    1337class CommandLineUIFactory : public UIFactory
    1438{
  • src/UIElements/CommandLineUI/CommandLineWindow.cpp

    r06f4ef6 rb6da28  
    1313#include "CommandLineUI/CommandLineStatusIndicator.hpp"
    1414
     15#include "Actions/Action.hpp"
     16#include "Actions/MapOfActions.hpp"
    1517#include "Actions/ActionRegistry.hpp"
    16 #include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
    17 #include "Actions/AnalysisAction/PairCorrelationAction.hpp"
    18 #include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
    19 #include "Actions/AtomAction/AddAction.hpp"
    20 #include "Actions/AtomAction/ChangeElementAction.hpp"
    21 #include "Actions/AtomAction/RemoveAction.hpp"
    22 #include "Actions/CmdAction/BondLengthTableAction.hpp"
    23 #include "Actions/CmdAction/ElementDbAction.hpp"
    24 #include "Actions/CmdAction/FastParsingAction.hpp"
    25 #include "Actions/CmdAction/HelpAction.hpp"
    26 #include "Actions/CmdAction/VerboseAction.hpp"
    27 #include "Actions/CmdAction/VersionAction.hpp"
    28 #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
    29 #include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
    30 #include "Actions/FragmentationAction/FragmentationAction.hpp"
    31 #include "Actions/MoleculeAction/BondFileAction.hpp"
    32 #include "Actions/MoleculeAction/ChangeNameAction.hpp"
    33 #include "Actions/MoleculeAction/FillWithMoleculeAction.hpp"
    34 #include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp"
    35 #include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
    36 #include "Actions/MoleculeAction/SaveBondsAction.hpp"
    37 #include "Actions/MoleculeAction/SaveTemperatureAction.hpp"
    38 #include "Actions/MoleculeAction/TranslateAction.hpp"
    39 #include "Actions/MoleculeAction/VerletIntegrationAction.hpp"
    40 #include "Actions/ParserAction/LoadXyzAction.hpp"
    41 #include "Actions/ParserAction/SaveXyzAction.hpp"
    42 #include "Actions/TesselationAction/ConvexEnvelopeAction.hpp"
    43 #include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
    44 #include "Actions/WorldAction/AddEmptyBoundaryAction.hpp"
    45 #include "Actions/WorldAction/BoundInBoxAction.hpp"
    46 #include "Actions/WorldAction/CenterInBoxAction.hpp"
    47 #include "Actions/WorldAction/CenterOnEdgeAction.hpp"
    48 #include "Actions/WorldAction/ChangeBoxAction.hpp"
    49 #include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp"
    50 #include "Actions/WorldAction/RepeatBoxAction.hpp"
    51 #include "Actions/WorldAction/ScaleBoxAction.hpp"
    52 #include "Actions/WorldAction/SetDefaultNameAction.hpp"
    53 #include "Actions/WorldAction/SetGaussianBasisAction.hpp"
     18
    5419#include "CommandLineParser.hpp"
    5520
     
    6227{
    6328  // create and register all command line callable actions
    64   populateAnalysisActions();
    65   populateAtomActions();
    66   populateCmdActions();
    67   populateFragmentationActions();
    68   populateMoleculeActions();
    69   populateParserActions();
    70   populateTesselationActions();
    71   populateWorldActions();
     29  MapOfActions::getInstance().populateActions();
    7230
    7331  // Add status indicators etc...
     
    8139
    8240void CommandLineWindow::display() {
     41  //cout << ActionRegistry::getInstance();
     42
    8343  // go through all possible actions
    8444  for (std::list<std::string>::iterator CommandRunner = CommandLineParser::getInstance().SequenceOfActions.begin(); CommandRunner != CommandLineParser::getInstance().SequenceOfActions.end(); ++CommandRunner) {
    85     cout << "Checking presence of " << *CommandRunner << endl;
    86     if (ActionRegistry::getInstance().isActionByNamePresent(*CommandRunner))
     45    cout << "Checking presence of " << *CommandRunner << ": ";
     46    if (ActionRegistry::getInstance().isActionPresentByName(*CommandRunner)) {
     47      cout << "calling " << *CommandRunner << endl;
    8748      ActionRegistry::getInstance().getActionByName(*CommandRunner)->call();
     49    } else {
     50      cout << "absent." << endl;
     51    }
    8852  }
    8953}
    9054
    91 void CommandLineWindow::populateAnalysisActions()
    92 {
    93   new AnalysisMolecularVolumeAction();
    94   new AnalysisPairCorrelationAction();
    95   new AnalysisPrincipalAxisSystemAction();
    96 }
    97 
    98 void CommandLineWindow::populateAtomActions()
    99 {
    100   new AtomAddAction();
    101   new AtomChangeElementAction();
    102   new AtomRemoveAction();
    103 }
    104 
    105 void CommandLineWindow::populateCmdActions()
    106 {
    107   new CommandLineBondLengthTableAction();
    108   new CommandLineElementDbAction();
    109   new CommandLineFastParsingAction();
    110   new CommandLineHelpAction();
    111   new CommandLineVerboseAction();
    112   new CommandLineVersionAction();
    113 }
    114 
    115 void CommandLineWindow::populateFragmentationActions()
    116 {
    117   new FragmentationDepthFirstSearchAction();
    118   new FragmentationFragmentationAction();
    119   new FragmentationSubgraphDissectionAction();
    120 }
    121 
    122 void CommandLineWindow::populateMoleculeActions()
    123 {
    124   new MoleculeBondFileAction();
    125   new MoleculeChangeNameAction();
    126   new MoleculeFillWithMoleculeAction();
    127   new MoleculeLinearInterpolationofTrajectoriesAction();
    128   new MoleculeSaveAdjacencyAction();
    129   new MoleculeSaveBondsAction();
    130   new MoleculeSaveTemperatureAction();
    131   new MoleculeTranslateAction();
    132   new MoleculeVerletIntegrationAction();
    133 }
    134 
    135 void CommandLineWindow::populateParserActions()
    136 {
    137   new ParserLoadXyzAction();
    138   new ParserSaveXyzAction();
    139 }
    140 
    141 void CommandLineWindow::populateTesselationActions()
    142 {
    143   new TesselationConvexEnvelopeAction();
    144   new TesselationNonConvexEnvelopeAction();
    145 }
    146 
    147 void CommandLineWindow::populateWorldActions()
    148 {
    149   new WorldAddEmptyBoundaryAction();
    150   new WorldBoundInBoxAction();
    151   new WorldCenterInBoxAction();
    152   new WorldCenterOnEdgeAction();
    153   new WorldChangeBoxAction();
    154   new WorldRemoveSphereOfAtomsAction();
    155   new WorldRepeatBoxAction();
    156   new WorldScaleBoxAction();
    157   new WorldSetDefaultNameAction();
    158   new WorldSetGaussianBasisAction();
    159 }
  • src/UIElements/Dialog.cpp

    r06f4ef6 rb6da28  
    88#include "Helpers/MemDebug.hpp"
    99
    10 #include <cassert>
    11 
    1210#include "Dialog.hpp"
    13 
     11#include "ValueStorage.hpp"
     12
     13#include "verbose.hpp"
    1414#include "atom.hpp"
    1515#include "element.hpp"
    1616#include "molecule.hpp"
    1717#include "vector.hpp"
     18#include "Matrix.hpp"
     19#include "Box.hpp"
    1820
    1921using namespace std;
     
    3638
    3739bool Dialog::display(){
     40  if(checkAll()){
     41    setAll();
     42    return true;
     43  }
     44  else{
     45    return false;
     46  }
     47}
     48
     49bool Dialog::checkAll(){
    3850  list<Query*>::iterator iter;
    3951  bool retval = true;
     
    4658    }
    4759  }
    48   if (retval){
    49     // if all queries succeeded we can set the targets to appropriate values
    50     for(iter=queries.begin(); iter!=queries.end(); iter++) {
    51       (*iter)->setResult();
    52     }
    53   }
    5460  return retval;
     61}
     62
     63void Dialog::setAll(){
     64  list<Query*>::iterator iter;
     65  for(iter=queries.begin(); iter!=queries.end(); iter++) {
     66    (*iter)->setResult();
     67  }
     68}
     69
     70bool Dialog::hasQueries(){
     71  return queries.size();
    5572}
    5673
     
    85102// Int Queries
    86103
    87 Dialog::IntQuery::IntQuery(string title,int *_target, std::string description) :
    88     Query(title, description), target(_target)
     104Dialog::IntQuery::IntQuery(string title, std::string description) :
     105    Query(title, description)
    89106{}
    90107
     
    92109
    93110void Dialog::IntQuery::setResult() {
    94   *target = tmp;
    95 }
    96 
    97 // Int Queries
    98 
    99 Dialog::BooleanQuery::BooleanQuery(string title,bool *_target, std::string description) :
    100     Query(title, description), target(_target)
     111  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     112}
     113
     114// Ints Queries
     115
     116Dialog::IntsQuery::IntsQuery(string title, std::string description) :
     117    Query(title, description)
     118{}
     119
     120Dialog::IntsQuery::~IntsQuery() {}
     121
     122void Dialog::IntsQuery::setResult() {
     123  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     124}
     125
     126// Bool Queries
     127
     128Dialog::BooleanQuery::BooleanQuery(string title,std::string description) :
     129    Query(title, description)
    101130{}
    102131
     
    104133
    105134void Dialog::BooleanQuery::setResult() {
    106   *target = tmp;
     135  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    107136}
    108137
    109138// String Queries
    110139
    111 Dialog::StringQuery::StringQuery(string title,string *_target, std::string _description) :
    112     Query(title, _description), target(_target)
     140Dialog::StringQuery::StringQuery(string title,std::string _description) :
     141    Query(title, _description)
    113142{}
    114143
     
    116145
    117146void Dialog::StringQuery::setResult() {
    118   *target = tmp;
     147  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     148}
     149
     150// Strings Queries
     151
     152Dialog::StringsQuery::StringsQuery(string title,std::string _description) :
     153    Query(title, _description)
     154{}
     155
     156Dialog::StringsQuery::~StringsQuery() {};
     157
     158void Dialog::StringsQuery::setResult() {
     159  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    119160}
    120161
    121162// Double Queries
    122163
    123 Dialog::DoubleQuery::DoubleQuery(string title,double *_target, std::string _description) :
    124     Query(title, _description), target(_target)
     164Dialog::DoubleQuery::DoubleQuery(string title, std::string _description) :
     165    Query(title, _description)
    125166{}
    126167
     
    128169
    129170void Dialog::DoubleQuery::setResult() {
    130   *target = tmp;
     171  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     172}
     173
     174// Doubles Queries
     175
     176Dialog::DoublesQuery::DoublesQuery(string title, std::string _description) :
     177    Query(title, _description)
     178{}
     179
     180Dialog::DoublesQuery::~DoublesQuery() {};
     181
     182void Dialog::DoublesQuery::setResult() {
     183  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    131184}
    132185
     
    134187// Atom Queries
    135188
    136 Dialog::AtomQuery::AtomQuery(string title, atom **_target, std::string _description) :
     189Dialog::AtomQuery::AtomQuery(string title, std::string _description) :
    137190    Query(title, _description),
    138     tmp(0),
    139     target(_target)
    140 
     191    tmp(0)
    141192{}
    142193
     
    144195
    145196void Dialog::AtomQuery::setResult() {
    146   *target = tmp;
     197  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     198}
     199
     200// Atoms Queries
     201
     202Dialog::AtomsQuery::AtomsQuery(string title, std::string _description) :
     203    Query(title, _description),
     204    tmp(0)
     205{}
     206
     207Dialog::AtomsQuery::~AtomsQuery() {}
     208
     209void Dialog::AtomsQuery::setResult() {
     210  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    147211}
    148212
    149213// Molecule Queries
    150214
    151 Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, std::string _description) :
     215Dialog::MoleculeQuery::MoleculeQuery(string title, std::string _description) :
    152216    Query(title, _description),
    153     tmp(0),
    154     target(_target)
    155 
     217    tmp(0)
    156218{}
    157219
     
    159221
    160222void Dialog::MoleculeQuery::setResult() {
    161   *target = tmp;
     223  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     224}
     225
     226// Molecules Queries
     227
     228Dialog::MoleculesQuery::MoleculesQuery(string title, std::string _description) :
     229    Query(title, _description),
     230    tmp(0)
     231{}
     232
     233Dialog::MoleculesQuery::~MoleculesQuery() {}
     234
     235void Dialog::MoleculesQuery::setResult() {
     236  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    162237}
    163238
    164239// Vector Queries
    165240
    166 Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description) :
     241Dialog::VectorQuery::VectorQuery(std::string title,bool _check, std::string _description) :
    167242  Query(title, _description),
    168   cellSize(_cellSize),
    169   check(_check),
    170   target(_target)
    171 {
    172   tmp = new Vector();
    173 }
     243  check(_check)
     244{}
    174245
    175246Dialog::VectorQuery::~VectorQuery()
    176 {
    177   delete tmp;
    178 }
     247{}
    179248
    180249void Dialog::VectorQuery::setResult() {
    181   *target = *tmp;
     250  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     251}
     252
     253// Vectors Queries
     254
     255Dialog::VectorsQuery::VectorsQuery(std::string title,bool _check, std::string _description) :
     256  Query(title, _description),
     257  check(_check)
     258{}
     259
     260Dialog::VectorsQuery::~VectorsQuery()
     261{}
     262
     263void Dialog::VectorsQuery::setResult() {
     264  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    182265}
    183266
    184267// Box Queries
    185268
    186 Dialog::BoxQuery::BoxQuery(std::string title, double ** const _cellSize, std::string _description) :
    187   Query(title, _description),
    188   target(_cellSize)
    189 {
    190     tmp = new double[6];
    191 }
     269Dialog::BoxQuery::BoxQuery(std::string title, std::string _description) :
     270  Query(title, _description)
     271{}
    192272
    193273Dialog::BoxQuery::~BoxQuery()
    194 {
    195   delete[] tmp;
    196 }
     274{}
    197275
    198276void Dialog::BoxQuery::setResult() {
    199   for (int i=0;i<6;i++) {
    200     (*target)[i] = tmp[i];
    201   }
     277  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
    202278}
    203279
    204280// Element Queries
    205 Dialog::ElementQuery::ElementQuery(std::string title, std::vector<element *> *_target, std::string _description) :
    206   Query(title, _description),
    207   target(_target)
     281Dialog::ElementQuery::ElementQuery(std::string title, std::string _description) :
     282  Query(title, _description)
    208283  {}
    209284
     
    211286
    212287void Dialog::ElementQuery::setResult(){
    213   *target=elements;
    214 }
     288  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     289}
     290
     291// Elements Queries
     292Dialog::ElementsQuery::ElementsQuery(std::string title, std::string _description) :
     293  Query(title, _description)
     294  {}
     295
     296Dialog::ElementsQuery::~ElementsQuery(){}
     297
     298void Dialog::ElementsQuery::setResult(){
     299  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     300}
  • src/UIElements/Dialog.hpp

    r06f4ef6 rb6da28  
    1313#include<vector>
    1414
     15#include "Box.hpp"
     16#include "vector.hpp"
     17
    1518class atom;
     19class Box;
    1620class element;
    1721class molecule;
    18 class Vector;
    19 
     22
     23
     24/** Dialog is one of the two main classes of the UIFactory base class.
     25 *
     26 * The Dialog is meant for asking the user for information needed to perform actions he
     27 * desires, such as asking for a position in space or a length.
     28 *
     29 * For this purpose there is the base class Query and numerous specializations for each
     30 * of the types to be asked. There are primitives integer, doubles and string, but also
     31 * advanced types such as element, molecule or Vector. There is also an empty query for
     32 * displaying text.
     33 */
    2034class Dialog
    2135{
     
    2539
    2640  virtual void queryEmpty(const char *, std::string = "")=0;
    27   virtual void queryBoolean(const char *, bool *, std::string = "")=0;
    28   virtual void queryInt(const char *, int *, std::string = "")=0;
    29   virtual void queryDouble(const char*,double *, std::string = "")=0;
    30   virtual void queryString(const char*, std::string *, std::string = "")=0;
    31   virtual void queryAtom(const char*,atom**,std::string = "")=0;
    32   virtual void queryMolecule(const char*,molecule**, std::string = "")=0;
    33   virtual void queryVector(const char*,Vector *,const double *const,bool, std::string = "")=0;
    34   virtual void queryBox(const char*,double ** const, std::string = "")=0;
    35   virtual void queryElement(const char*, std::vector<element *> *, std::string = "")=0;
     41  virtual void queryBoolean(const char *, std::string = "")=0;
     42  virtual void queryInt(const char *, std::string = "")=0;
     43  virtual void queryInts(const char *, std::string = "")=0;
     44  virtual void queryDouble(const char*, std::string = "")=0;
     45  virtual void queryDoubles(const char*, std::string = "")=0;
     46  virtual void queryString(const char*, std::string = "")=0;
     47  virtual void queryStrings(const char*, std::string = "")=0;
     48  virtual void queryAtom(const char*,std::string = "")=0;
     49  virtual void queryAtoms(const char*,std::string = "")=0;
     50  virtual void queryMolecule(const char*, std::string = "")=0;
     51  virtual void queryMolecules(const char*, std::string = "")=0;
     52  virtual void queryVector(const char*,bool, std::string = "")=0;
     53  virtual void queryVectors(const char*,bool, std::string = "")=0;
     54  virtual void queryBox(const char*, std::string = "")=0;
     55  virtual void queryElement(const char*, std::string = "")=0;
     56  virtual void queryElements(const char*, std::string = "")=0;
    3657
    3758  virtual bool display();
     59
     60  virtual bool checkAll();
     61  virtual void setAll();
     62
     63  virtual bool hasQueries();
    3864
    3965protected:
     
    76102  class BooleanQuery : public Query {
    77103  public:
    78     BooleanQuery(std::string title,bool *_target, std::string _description = "");
     104    BooleanQuery(std::string title, std::string _description = "");
    79105    virtual ~BooleanQuery();
    80106    virtual bool handle()=0;
     
    82108  protected:
    83109    bool tmp;
    84   private:
    85     bool *target;
    86110  };
    87111
    88112  class IntQuery : public Query {
    89113  public:
    90     IntQuery(std::string title,int *_target, std::string _description = "");
     114    IntQuery(std::string title, std::string _description = "");
    91115    virtual ~IntQuery();
    92116    virtual bool handle()=0;
     
    94118  protected:
    95119    int tmp;
    96   private:
    97     int *target;
     120  };
     121
     122  class IntsQuery : public Query {
     123  public:
     124    IntsQuery(std::string title, std::string _description = "");
     125    virtual ~IntsQuery();
     126    virtual bool handle()=0;
     127    virtual void setResult();
     128  protected:
     129    int temp;
     130    std::vector<int> tmp;
    98131  };
    99132
    100133  class DoubleQuery : public Query {
    101134  public:
    102     DoubleQuery(std::string title,double *_target, std::string _description = "");
     135    DoubleQuery(std::string title, std::string _description = "");
    103136    virtual ~DoubleQuery();
    104137    virtual bool handle()=0;
     
    106139  protected:
    107140    double tmp;
    108   private:
    109     double *target;
     141  };
     142
     143  class DoublesQuery : public Query {
     144  public:
     145    DoublesQuery(std::string title, std::string _description = "");
     146    virtual ~DoublesQuery();
     147    virtual bool handle()=0;
     148    virtual void setResult();
     149  protected:
     150    double temp;
     151    std::vector<double> tmp;
    110152  };
    111153
    112154  class StringQuery : public Query {
    113155  public:
    114     StringQuery(std::string title,std::string *_target, std::string _description = "");
     156    StringQuery(std::string title, std::string _description = "");
    115157    virtual ~StringQuery();
    116158    virtual bool handle()=0;
     
    118160  protected:
    119161    std::string tmp;
    120   private:
    121     std::string *target;
     162  };
     163
     164  class StringsQuery : public Query {
     165  public:
     166    StringsQuery(std::string title, std::string _description = "");
     167    virtual ~StringsQuery();
     168    virtual bool handle()=0;
     169    virtual void setResult();
     170  protected:
     171    std::string temp;
     172    std::vector<std::string> tmp;
    122173  };
    123174
    124175  class MoleculeQuery : public Query {
    125176  public:
    126     MoleculeQuery(std::string title, molecule **_target, std::string _description = "");
     177    MoleculeQuery(std::string title, std::string _description = "");
    127178    virtual ~MoleculeQuery();
    128179    virtual bool handle()=0;
     
    130181  protected:
    131182    molecule *tmp;
    132   private:
    133     molecule **target;
     183  };
     184
     185  class MoleculesQuery : public Query {
     186  public:
     187    MoleculesQuery(std::string title, std::string _description = "");
     188    virtual ~MoleculesQuery();
     189    virtual bool handle()=0;
     190    virtual void setResult();
     191  protected:
     192    molecule * temp;
     193    std::vector<molecule *> tmp;
    134194  };
    135195
    136196  class AtomQuery : public Query {
    137197  public:
    138     AtomQuery(std::string title, atom **_target, std::string _description = "");
     198    AtomQuery(std::string title, std::string _description = "");
    139199    virtual ~AtomQuery();
    140200    virtual bool handle()=0;
     
    142202  protected:
    143203    atom *tmp;
    144   private:
    145     atom **target;
     204  };
     205
     206  class AtomsQuery : public Query {
     207  public:
     208    AtomsQuery(std::string title, std::string _description = "");
     209    virtual ~AtomsQuery();
     210    virtual bool handle()=0;
     211    virtual void setResult();
     212  protected:
     213    atom *temp;
     214    std::vector<atom *> tmp;
    146215  };
    147216
    148217  class VectorQuery : public Query {
    149218  public:
    150       VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description = "");
     219      VectorQuery(std::string title,bool _check, std::string _description = "");
    151220      virtual ~VectorQuery();
    152221      virtual bool handle()=0;
    153222      virtual void setResult();
    154223    protected:
    155       Vector *tmp;
    156       const double *const cellSize;
     224      Vector tmp;
    157225      bool check;
    158     private:
    159       Vector *target;
     226  };
     227
     228  class VectorsQuery : public Query {
     229  public:
     230      VectorsQuery(std::string title,bool _check, std::string _description = "");
     231      virtual ~VectorsQuery();
     232      virtual bool handle()=0;
     233      virtual void setResult();
     234    protected:
     235      Vector temp;
     236      std::vector<Vector> tmp;
     237      bool check;
    160238  };
    161239
    162240  class BoxQuery : public Query {
    163241  public:
    164       BoxQuery(std::string title,double ** const _cellSize, std::string _description = "");
     242      BoxQuery(std::string title, std::string _description = "");
    165243      virtual ~BoxQuery();
    166244      virtual bool handle()=0;
    167245      virtual void setResult();
    168246    protected:
    169       double *tmp;
    170     private:
    171       double **target;
     247      Box tmp;
    172248  };
    173249
    174250  class ElementQuery : public Query {
    175251  public:
    176     ElementQuery(std::string title, std::vector<element *> *_target, std::string _description = "");
     252    ElementQuery(std::string title, std::string _description = "");
    177253    virtual ~ElementQuery();
    178254    virtual bool handle()=0;
    179255    virtual void setResult();
    180256  protected:
    181     std::vector<element *> elements;
    182   private:
    183     std::vector<element *> * const target;
     257    element * tmp;
     258  };
     259
     260  class ElementsQuery : public Query {
     261  public:
     262    ElementsQuery(std::string title, std::string _description = "");
     263    virtual ~ElementsQuery();
     264    virtual bool handle()=0;
     265    virtual void setResult();
     266  protected:
     267    element *temp;
     268    std::vector<element *> tmp;
    184269  };
    185270
  • src/UIElements/MainWindow.cpp

    r06f4ef6 rb6da28  
    1111
    1212MainWindow::MainWindow()
    13 {
    14   // TODO Auto-generated constructor stub
    15 
    16 }
     13{}
    1714
    1815MainWindow::~MainWindow()
    19 {
    20   // TODO Auto-generated destructor stub
    21 }
     16{}
  • src/UIElements/Makefile.am

    r06f4ef6 rb6da28  
    4646  Dialog.cpp \
    4747  MainWindow.cpp \
    48   UIFactory.cpp
     48  ValueStorage.cpp
    4949 
    5050UIHEADER = \
     
    5656  Dialog.hpp \
    5757  MainWindow.hpp \
    58   UIFactory.hpp
     58  ValueStorage.hpp
    5959
    6060TEXTUISOURCE = \
     
    8080  CommandLineUI/CommandLineWindow.hpp
    8181
    82 
     82unity.cpp:
     83        echo "" >  unity.cpp; \
     84        list='$(UISOURCE)'; for file in $$list; do \
     85          echo "#include \"$(srcdir)/$$file\"" >> unity.cpp; \
     86        done;
     87       
     88MOSTLYCLEANFILES = unity.cpp
  • src/UIElements/Menu/TextMenu.cpp

    r06f4ef6 rb6da28  
    127127}
    128128
     129Dialog* TextMenu::LeaveAction::fillDialog(Dialog *dialog){
     130  ASSERT(dialog,"No Dialog given when filling action dialog");
     131  return dialog;
     132}
     133
     134
    129135Action::state_ptr TextMenu::LeaveAction::performCall(){
    130136  menu->doQuit();
  • src/UIElements/Menu/TextMenu.hpp

    r06f4ef6 rb6da28  
    3535    bool shouldUndo();
    3636
     37  protected:
     38    virtual Dialog* fillDialog(Dialog *dialog);
    3739  private:
    3840    virtual Action::state_ptr performCall();
  • src/UIElements/TextUI/TextDialog.cpp

    r06f4ef6 rb6da28  
    1414#include <Descriptors/MoleculeDescriptor.hpp>
    1515#include <Descriptors/MoleculeIdDescriptor.hpp>
     16#include <boost/lexical_cast.hpp>
    1617#include "TextUI/TextDialog.hpp"
    1718
     
    2526#include "molecule.hpp"
    2627#include "vector.hpp"
     28#include "Matrix.hpp"
     29#include "Box.hpp"
     30
     31#include <boost/lexical_cast.hpp>
    2732
    2833using namespace std;
     34
     35using boost::lexical_cast;
     36using boost::bad_lexical_cast;
    2937
    3038
     
    4250}
    4351
    44 void TextDialog::queryBoolean(const char* title, bool* target, string description){
    45   registerQuery(new BooleanTextQuery(title,target,description));
    46 }
    47 
    48 void TextDialog::queryInt(const char* title, int* target, string description){
    49   registerQuery(new IntTextQuery(title,target,description));
    50 }
    51 
    52 void TextDialog::queryDouble(const char* title, double* target, string description){
    53   registerQuery(new DoubleTextQuery(title,target,description));
    54 }
    55 
    56 void TextDialog::queryString(const char* title, string* target, string description){
    57   registerQuery(new StringTextQuery(title,target,description));
    58 }
    59 
    60 void TextDialog::queryAtom(const char* title, atom **target, string description) {
    61   registerQuery(new AtomTextQuery(title,target,description));
    62 }
    63 
    64 void TextDialog::queryMolecule(const char* title, molecule **target, string description) {
    65   registerQuery(new MoleculeTextQuery(title,target,description));
    66 }
    67 
    68 void TextDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check, string description) {
    69   registerQuery(new VectorTextQuery(title,target,cellSize,check,description));
    70 }
    71 
    72 void TextDialog::queryBox(const char* title,double ** const cellSize, string description) {
    73   registerQuery(new BoxTextQuery(title,cellSize,description));
    74 }
    75 
    76 void TextDialog::queryElement(const char* title, std::vector<element *> *target, string description){
    77   registerQuery(new ElementTextQuery(title,target,description));
     52void TextDialog::queryBoolean(const char* title, string description){
     53  registerQuery(new BooleanTextQuery(title,description));
     54}
     55
     56void TextDialog::queryInt(const char* title, string description){
     57  registerQuery(new IntTextQuery(title,description));
     58}
     59
     60void TextDialog::queryInts(const char* title, string description){
     61  registerQuery(new IntsTextQuery(title,description));
     62}
     63
     64void TextDialog::queryDouble(const char* title, string description){
     65  registerQuery(new DoubleTextQuery(title,description));
     66}
     67
     68void TextDialog::queryDoubles(const char* title, string description){
     69  registerQuery(new DoublesTextQuery(title,description));
     70}
     71
     72void TextDialog::queryString(const char* title, string description){
     73  registerQuery(new StringTextQuery(title,description));
     74}
     75
     76void TextDialog::queryStrings(const char* title, string description){
     77  registerQuery(new StringsTextQuery(title,description));
     78}
     79
     80void TextDialog::queryAtom(const char* title, string description) {
     81  registerQuery(new AtomTextQuery(title,description));
     82}
     83
     84void TextDialog::queryAtoms(const char* title, string description) {
     85  registerQuery(new AtomsTextQuery(title,description));
     86}
     87
     88void TextDialog::queryMolecule(const char* title, string description) {
     89  registerQuery(new MoleculeTextQuery(title,description));
     90}
     91
     92void TextDialog::queryMolecules(const char* title, string description) {
     93  registerQuery(new MoleculesTextQuery(title,description));
     94}
     95
     96void TextDialog::queryVector(const char* title, bool check, string description) {
     97  registerQuery(new VectorTextQuery(title,check,description));
     98}
     99
     100void TextDialog::queryVectors(const char* title, bool check, string description) {
     101  registerQuery(new VectorsTextQuery(title,check,description));
     102}
     103
     104void TextDialog::queryBox(const char* title, string description) {
     105  registerQuery(new BoxTextQuery(title,description));
     106}
     107
     108void TextDialog::queryElement(const char* title, string description){
     109  registerQuery(new ElementTextQuery(title,description));
     110}
     111
     112void TextDialog::queryElements(const char* title, string description){
     113  registerQuery(new ElementsTextQuery(title,description));
    78114}
    79115
     
    91127}
    92128
    93 TextDialog::IntTextQuery::IntTextQuery(string title, int * _target, std::string _description) :
    94     Dialog::IntQuery(title,_target,_description)
     129TextDialog::IntTextQuery::IntTextQuery(string title, std::string _description) :
     130    Dialog::IntQuery(title,_description)
    95131{}
    96132
     
    115151}
    116152
    117 TextDialog::BooleanTextQuery::BooleanTextQuery(string title, bool * _target, std::string _description) :
    118     Dialog::BooleanQuery(title,_target,_description)
     153TextDialog::IntsTextQuery::IntsTextQuery(string title, std::string _description) :
     154    Dialog::IntsQuery(title,_description)
     155{}
     156
     157TextDialog::IntsTextQuery::~IntsTextQuery() {}
     158
     159bool TextDialog::IntsTextQuery::handle() {
     160  Log() << Verbose(0) << getTitle();
     161  std::string line;
     162  getline(cin,line);
     163  // dissect by " "
     164  string::iterator olditer = line.begin();
     165  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
     166    if (*iter == ' ') {
     167      std::istringstream stream(string(iter, olditer));
     168      stream >> temp;
     169      tmp.push_back(temp);
     170      olditer = iter;
     171    }
     172  }
     173  if (olditer != line.begin()) { // insert last part also
     174    std::istringstream stream(string(olditer, line.end()));
     175    stream >> temp;
     176    tmp.push_back(temp);
     177  }
     178
     179  return true;
     180}
     181
     182TextDialog::BooleanTextQuery::BooleanTextQuery(string title, std::string _description) :
     183    Dialog::BooleanQuery(title,_description)
    119184{}
    120185
     
    144209}
    145210
    146 TextDialog::StringTextQuery::StringTextQuery(string title,string *_target, std::string _description) :
    147     Dialog::StringQuery(title,_target,_description)
     211TextDialog::StringTextQuery::StringTextQuery(string title, std::string _description) :
     212    Dialog::StringQuery(title,_description)
    148213{}
    149214
     
    156221}
    157222
    158 TextDialog::DoubleTextQuery::DoubleTextQuery(string title,double *_target, std::string _description) :
    159     Dialog::DoubleQuery(title,_target,_description)
     223TextDialog::StringsTextQuery::StringsTextQuery(string title, std::string _description) :
     224    Dialog::StringsQuery(title,_description)
     225{}
     226
     227TextDialog::StringsTextQuery::~StringsTextQuery() {}
     228
     229bool TextDialog::StringsTextQuery::handle() {
     230  Log() << Verbose(0) << getTitle();
     231  getline(cin,temp);
     232  // dissect by " "
     233  string::iterator olditer = temp.begin();
     234  for(string::iterator iter = temp.begin(); iter != temp.end(); ++iter) {
     235    if (*iter == ' ') {
     236      tmp.push_back(string(iter, olditer));
     237      olditer = iter;
     238    }
     239  }
     240  if (olditer != temp.begin())  // insert last part also
     241    tmp.push_back(string(olditer, temp.end()));
     242
     243  return true;
     244}
     245
     246TextDialog::DoubleTextQuery::DoubleTextQuery(string title, std::string _description) :
     247    Dialog::DoubleQuery(title,_description)
    160248{}
    161249
     
    179267}
    180268
    181 TextDialog::AtomTextQuery::AtomTextQuery(string title, atom **_target, std::string _description) :
    182     Dialog::AtomQuery(title,_target,_description)
     269
     270TextDialog::DoublesTextQuery::DoublesTextQuery(string title, std::string _description) :
     271    Dialog::DoublesQuery(title,_description)
     272{}
     273
     274TextDialog::DoublesTextQuery::~DoublesTextQuery() {}
     275
     276bool TextDialog::DoublesTextQuery::handle() {
     277  Log() << Verbose(0) << getTitle();
     278  std::string line;
     279  getline(cin,line);
     280  // dissect by " "
     281  string::iterator olditer = line.begin();
     282  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
     283    if (*iter == ' ') {
     284      std::istringstream stream(string(iter, olditer));
     285      stream >> temp;
     286      tmp.push_back(temp);
     287      olditer = iter;
     288    }
     289  }
     290  if (olditer != line.begin()) { // insert last part also
     291    std::istringstream stream(string(olditer, line.end()));
     292    stream >> temp;
     293    tmp.push_back(temp);
     294  }
     295
     296  return true;
     297}
     298
     299TextDialog::AtomTextQuery::AtomTextQuery(string title, std::string _description) :
     300    Dialog::AtomQuery(title,_description)
    183301{}
    184302
     
    186304
    187305bool TextDialog::AtomTextQuery::handle() {
    188   int idxOfAtom=0;
     306  int idxOfAtom=-1;
    189307  bool badInput = false;
    190308  do{
     
    202320    tmp = World::getInstance().getAtom(AtomById(idxOfAtom));
    203321    if(!tmp && idxOfAtom!=-1){
    204       Log() << Verbose(0) << "Invalid Atom Index" << endl;
     322      Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl;
    205323      badInput = true;
    206324    }
     
    211329}
    212330
    213 TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, molecule **_target, std::string _description) :
    214     Dialog::MoleculeQuery(title,_target,_description)
     331
     332TextDialog::AtomsTextQuery::AtomsTextQuery(string title, std::string _description) :
     333    Dialog::AtomsQuery(title,_description)
     334{}
     335
     336TextDialog::AtomsTextQuery::~AtomsTextQuery() {}
     337
     338bool TextDialog::AtomsTextQuery::handle() {
     339  int idxOfAtom=-1;
     340  Log() << Verbose(0) << getTitle();
     341  std::string line;
     342  getline(cin,line);
     343  // dissect by " "
     344  string::iterator olditer = line.begin();
     345  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
     346    if (*iter == ' ') {
     347      std::istringstream stream(string(iter, olditer));
     348      stream >> idxOfAtom;
     349      temp = World::getInstance().getAtom(AtomById(idxOfAtom));
     350      if(!temp && idxOfAtom!=-1){
     351        Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl;
     352        break;
     353      }
     354      tmp.push_back(temp);
     355      olditer = iter;
     356    }
     357  }
     358  if (olditer != line.begin()) { // insert last part also
     359    std::istringstream stream(string(olditer, line.end()));
     360    stream >> idxOfAtom;
     361    temp = World::getInstance().getAtom(AtomById(idxOfAtom));
     362    if(!temp && idxOfAtom!=-1) {
     363      Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl;
     364      tmp.push_back(temp);
     365    }
     366  }
     367
     368  return (idxOfAtom!=-1);
     369}
     370
     371TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, std::string _description) :
     372    Dialog::MoleculeQuery(title,_description)
    215373{}
    216374
     
    243401}
    244402
    245 TextDialog::VectorTextQuery::VectorTextQuery(std::string title, Vector *_target, const double *const _cellSize, bool _check, std::string _description) :
    246     Dialog::VectorQuery(title,_target,_cellSize,_check,_description)
     403
     404TextDialog::MoleculesTextQuery::MoleculesTextQuery(string title, std::string _description) :
     405    Dialog::MoleculesQuery(title,_description)
     406{}
     407
     408TextDialog::MoleculesTextQuery::~MoleculesTextQuery() {}
     409
     410bool TextDialog::MoleculesTextQuery::handle() {
     411  int idxOfMol=-1;
     412  Log() << Verbose(0) << getTitle();
     413  std::string line;
     414  getline(cin,line);
     415  // dissect by " "
     416  string::iterator olditer = line.begin();
     417  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
     418    if (*iter == ' ') {
     419      std::istringstream stream(string(iter, olditer));
     420      stream >> idxOfMol;
     421      temp = World::getInstance().getMolecule(MoleculeById(idxOfMol));
     422      if(!temp && idxOfMol!=-1){
     423        Log() << Verbose(0) << "Invalid Molecule Index" << idxOfMol << endl;
     424        break;
     425      }
     426      tmp.push_back(temp);
     427      olditer = iter;
     428    }
     429  }
     430  if (olditer != line.begin()) { // insert last part also
     431    std::istringstream stream(string(olditer, line.end()));
     432    stream >> idxOfMol;
     433    temp = World::getInstance().getMolecule(MoleculeById(idxOfMol));
     434    if(!temp && idxOfMol!=-1){
     435      Log() << Verbose(0) << "Invalid Molecule Index" << idxOfMol << endl;
     436      tmp.push_back(temp);
     437    }
     438  }
     439
     440  return (idxOfMol!=-1);
     441}
     442
     443TextDialog::VectorTextQuery::VectorTextQuery(std::string title, bool _check, std::string _description) :
     444    Dialog::VectorQuery(title,_check,_description)
    247445{}
    248446
     
    251449
    252450bool TextDialog::VectorTextQuery::handle() {
    253   Log() << Verbose(0) << getTitle();
    254 
    255   char coords[3] = {'x','y','z'};
    256   int j = -1;
    257   for (int i=0;i<3;i++) {
    258     j += i+1;
    259     do {
    260       Log() << Verbose(0) << coords[i] << "[0.." << cellSize[j] << "]: ";
    261       cin >> (*tmp)[i];
    262     } while ((((*tmp)[i] < 0) || ((*tmp)[i] >= cellSize[j])) && (check));
    263   }
    264   return true;
    265 }
    266 
    267 TextDialog::BoxTextQuery::BoxTextQuery(std::string title, double ** const _cellSize, std::string _description) :
    268     Dialog::BoxQuery(title,_cellSize,_description)
     451  std::cout << getTitle();
     452  const Matrix &M = World::getInstance().getDomain().getM();
     453  char coords[3] = {'x', 'y', 'z'};
     454  for (int i=0;i<3;i++)
     455    std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: ");
     456
     457  std::string line;
     458  getline(cin,line);
     459
     460  // dissect by ","
     461  double coord = 0.;
     462  int counter = 0;
     463  string::iterator olditer = line.begin();
     464  for(string::iterator iter = line.begin(); (iter != line.end()) && (counter != 3); ++iter) {
     465    if (*iter == ',') {
     466      std::istringstream stream(string(iter, olditer));
     467      stream >> coord;
     468      tmp[counter++] = coord;
     469      olditer = iter;
     470    }
     471  }
     472  if ((olditer != line.begin()) && (counter != 3)) { // insert last part also
     473    std::istringstream stream(string(olditer, line.end()));
     474    stream >> coord;
     475    tmp[counter++] = coord;
     476  }
     477
     478  // check vector
     479  return World::getInstance().getDomain().isInside(tmp);
     480}
     481
     482TextDialog::VectorsTextQuery::VectorsTextQuery(std::string title, bool _check, std::string _description) :
     483    Dialog::VectorsQuery(title,_check,_description)
     484{}
     485
     486TextDialog::VectorsTextQuery::~VectorsTextQuery()
     487{}
     488
     489bool TextDialog::VectorsTextQuery::handle() {
     490  std::cout << getTitle();
     491  char coords[3] = {'x', 'y', 'z'};
     492  const Matrix &M = World::getInstance().getDomain().getM();
     493  for (int i=0;i<3;i++)
     494    std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: ");
     495
     496  std::string line;
     497  getline(cin,line);
     498
     499  // dissect by ","
     500  double coord = 0.;
     501  string::iterator olditerspace = line.begin();
     502  string::iterator olditercomma = line.begin();
     503  int counter = 0;
     504  for(string::iterator vectoriter = line.begin(); vectoriter != line.end(); ++vectoriter) {
     505    if (*vectoriter == ',')
     506      counter++;
     507    if ((*vectoriter == ' ') && (counter == 2)) {
     508      counter = 0;
     509      for(string::iterator componentiter = olditerspace; (componentiter != vectoriter) && (counter !=3); ++componentiter) {
     510        if (*componentiter == ',') {
     511          std::istringstream stream(string(componentiter, olditercomma));
     512          stream >> coord;
     513          temp[counter++] = coord;
     514          olditercomma = componentiter;
     515        }
     516      }
     517      if ((olditercomma != line.begin()) && (counter != 3)) { // insert last part also
     518        std::istringstream stream(string(olditercomma, vectoriter));
     519        stream >> coord;
     520        temp[counter++] = coord;
     521      }
     522      if (World::getInstance().getDomain().isInside(temp))
     523        tmp.push_back(temp);
     524      olditerspace = vectoriter;
     525    }
     526  }
     527  return true;
     528}
     529
     530TextDialog::BoxTextQuery::BoxTextQuery(std::string title, std::string _description) :
     531    Dialog::BoxQuery(title,_description)
    269532{}
    270533
     
    275538  Log() << Verbose(0) << getTitle();
    276539
    277   std::string coords[6] = {"xx","xy","xz", "yy", "yz", "zz"};
     540  double temp[6];
     541  std::string coords[6] = {"xx","yx","yy", "zx", "zy", "zz"};
    278542  for (int i=0;i<6;i++) {
    279543    Log() << Verbose(0) << coords[i] << ": ";
    280     cin >> tmp[i];
    281   }
    282   return true;
    283 }
    284 
    285 TextDialog::ElementTextQuery::ElementTextQuery(std::string title, std::vector<element *> *_target, std::string _description) :
    286     Dialog::ElementQuery(title,_target,_description)
     544    cin >> temp[i];
     545  }
     546  Matrix M;
     547  M.set(0,0, temp[0]);
     548  M.set(0,1, temp[1]);
     549  M.set(0,2, temp[2]);
     550  M.set(1,0, temp[1]);
     551  M.set(1,1, temp[3]);
     552  M.set(1,2, temp[4]);
     553  M.set(2,0, temp[2]);
     554  M.set(2,1, temp[4]);
     555  M.set(2,2, temp[5]);
     556  tmp.setM(M);
     557  return true;
     558}
     559
     560TextDialog::ElementTextQuery::ElementTextQuery(std::string title, std::string _description) :
     561    Dialog::ElementQuery(title,_description)
    287562{}
    288563
     
    293568  bool badInput=false;
    294569  bool aborted = false;
    295   element * tmp = NULL;
     570  element * temp = NULL;
    296571  do{
    297572    badInput = false;
     
    306581      }
    307582      else{
    308         tmp = World::getInstance().getPeriode()->FindElement(Z);
    309         if(!tmp){
     583        temp = World::getInstance().getPeriode()->FindElement(Z);
     584        if(!temp){
    310585          Log() << Verbose(0) << "No element with this atomic number!" << endl;
    311586          badInput = true;
    312         } else {
    313           elements.push_back(tmp);
    314587        }
    315588      }
     
    330603      }
    331604      else{
    332         tmp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
    333         if(!tmp){
     605        temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
     606        if(!temp){
    334607          Log() << Verbose(0) << "No element with this shorthand!" << endl;
    335608          badInput = true;
    336         } else {
    337           elements.push_back(tmp);
    338609        }
    339610      }
     
    350621  return !aborted;
    351622}
     623
     624TextDialog::ElementsTextQuery::ElementsTextQuery(std::string title, std::string _description) :
     625    Dialog::ElementsQuery(title,_description)
     626{}
     627
     628TextDialog::ElementsTextQuery::~ElementsTextQuery()
     629{}
     630
     631bool TextDialog::ElementsTextQuery::handle() {
     632  std::string shorthand;
     633  int Z=-1;
     634  Log() << Verbose(0) << getTitle();
     635  std::string line;
     636  getline(cin,line);
     637  // dissect by " "
     638  string::iterator olditer = line.begin();
     639  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
     640    if (*iter == ' ') {
     641      std::istringstream stream(string(iter, olditer));
     642      stream >> shorthand;
     643      try {
     644        Z = lexical_cast<int>(shorthand);
     645        temp = World::getInstance().getPeriode()->FindElement(Z);
     646      } catch (bad_lexical_cast) {
     647        temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
     648      };
     649      if(!temp && Z!=-1){
     650        Log() << Verbose(0) << "Invalid Element" << shorthand << endl;
     651        break;
     652      }
     653      tmp.push_back(temp);
     654      olditer = iter;
     655    }
     656  }
     657  if (olditer != line.begin()) { // insert last part also
     658    std::istringstream stream(string(olditer, line.end()));
     659    stream >> shorthand;
     660    try {
     661      Z = lexical_cast<int>(shorthand);
     662      temp = World::getInstance().getPeriode()->FindElement(Z);
     663    } catch (bad_lexical_cast) {
     664      temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
     665    };
     666    if(!temp && Z!=-1) {
     667      Log() << Verbose(0) << "Invalid Element" << shorthand << endl;
     668      tmp.push_back(temp);
     669    }
     670  }
     671
     672  return (Z!=-1);
     673}
  • src/UIElements/TextUI/TextDialog.hpp

    r06f4ef6 rb6da28  
    2525
    2626  virtual void queryEmpty(const char *, std::string = "");
    27   virtual void queryBoolean(const char *, bool *, std::string = "");
    28   virtual void queryInt(const char *, int *, std::string = "");
    29   virtual void queryString(const char*, std::string *, std::string = "");
    30   virtual void queryDouble(const char*, double*, std::string = "");
    31   virtual void queryAtom(const char*,atom**,std::string = "");
    32   virtual void queryMolecule(const char*,molecule**,std::string = "");
    33   virtual void queryVector(const char*,Vector *,const double * const,bool, std::string = "");
    34   virtual void queryBox(const char*,double ** const, std::string = "");
    35   virtual void queryElement(const char*, std::vector<element *> *, std::string = "");
     27  virtual void queryBoolean(const char *, std::string = "");
     28  virtual void queryInt(const char *, std::string = "");
     29  virtual void queryInts(const char *, std::string = "");
     30  virtual void queryString(const char*, std::string = "");
     31  virtual void queryStrings(const char*, std::string = "");
     32  virtual void queryDouble(const char*, std::string = "");
     33  virtual void queryDoubles(const char*, std::string = "");
     34  virtual void queryAtom(const char*,std::string = "");
     35  virtual void queryAtoms(const char*,std::string = "");
     36  virtual void queryMolecule(const char*,std::string = "");
     37  virtual void queryMolecules(const char*,std::string = "");
     38  virtual void queryVector(const char*,bool, std::string = "");
     39  virtual void queryVectors(const char*,bool, std::string = "");
     40  virtual void queryBox(const char*, std::string = "");
     41  virtual void queryElement(const char*, std::string = "");
     42  virtual void queryElements(const char*, std::string = "");
    3643
    3744protected:
     
    4653  class BooleanTextQuery : public Dialog::BooleanQuery {
    4754  public:
    48     BooleanTextQuery(std::string title, bool *_target, std::string _description = NULL);
     55    BooleanTextQuery(std::string title, std::string _description = NULL);
    4956    virtual ~BooleanTextQuery();
    5057    virtual bool handle();
     
    5360  class IntTextQuery : public Dialog::IntQuery {
    5461  public:
    55     IntTextQuery(std::string title, int *_target, std::string _description = NULL);
     62    IntTextQuery(std::string title, std::string _description = NULL);
    5663    virtual ~IntTextQuery();
     64    virtual bool handle();
     65  };
     66
     67  class IntsTextQuery : public Dialog::IntsQuery {
     68  public:
     69    IntsTextQuery(std::string title, std::string _description = NULL);
     70    virtual ~IntsTextQuery();
    5771    virtual bool handle();
    5872  };
     
    6074  class DoubleTextQuery : public Dialog::DoubleQuery {
    6175  public:
    62     DoubleTextQuery(std::string title, double *_target, std::string _description = NULL);
     76    DoubleTextQuery(std::string title, std::string _description = NULL);
    6377    virtual ~DoubleTextQuery();
     78    virtual bool handle();
     79  };
     80
     81  class DoublesTextQuery : public Dialog::DoublesQuery {
     82  public:
     83    DoublesTextQuery(std::string title, std::string _description = NULL);
     84    virtual ~DoublesTextQuery();
    6485    virtual bool handle();
    6586  };
     
    6788  class StringTextQuery : public Dialog::StringQuery {
    6889  public:
    69     StringTextQuery(std::string title, std::string *_target, std::string _description = NULL);
     90    StringTextQuery(std::string title, std::string _description = NULL);
    7091    virtual ~StringTextQuery();
     92    virtual bool handle();
     93  };
     94
     95  class StringsTextQuery : public Dialog::StringsQuery {
     96  public:
     97    StringsTextQuery(std::string title, std::string _description = NULL);
     98    virtual ~StringsTextQuery();
    7199    virtual bool handle();
    72100  };
     
    74102  class AtomTextQuery : public Dialog::AtomQuery {
    75103  public:
    76     AtomTextQuery(std::string title, atom **_target, std::string _description = NULL);
     104    AtomTextQuery(std::string title, std::string _description = NULL);
    77105    virtual ~AtomTextQuery();
     106    virtual bool handle();
     107  };
     108
     109  class AtomsTextQuery : public Dialog::AtomsQuery {
     110  public:
     111    AtomsTextQuery(std::string title, std::string _description = NULL);
     112    virtual ~AtomsTextQuery();
    78113    virtual bool handle();
    79114  };
     
    81116  class MoleculeTextQuery : public Dialog::MoleculeQuery {
    82117  public:
    83     MoleculeTextQuery(std::string title, molecule **_target, std::string _description = NULL);
     118    MoleculeTextQuery(std::string title, std::string _description = NULL);
    84119    virtual ~MoleculeTextQuery();
     120    virtual bool handle();
     121  };
     122
     123  class MoleculesTextQuery : public Dialog::MoleculesQuery {
     124  public:
     125    MoleculesTextQuery(std::string title, std::string _description = NULL);
     126    virtual ~MoleculesTextQuery();
    85127    virtual bool handle();
    86128  };
     
    88130  class VectorTextQuery : public Dialog::VectorQuery {
    89131  public:
    90     VectorTextQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description = NULL);
     132    VectorTextQuery(std::string title,bool _check, std::string _description = NULL);
    91133    virtual ~VectorTextQuery();
     134    virtual bool handle();
     135  };
     136
     137  class VectorsTextQuery : public Dialog::VectorsQuery {
     138  public:
     139    VectorsTextQuery(std::string title,bool _check, std::string _description = NULL);
     140    virtual ~VectorsTextQuery();
    92141    virtual bool handle();
    93142  };
     
    95144  class BoxTextQuery : public Dialog::BoxQuery {
    96145  public:
    97     BoxTextQuery(std::string title,double ** const _cellSize, std::string _description = NULL);
     146    BoxTextQuery(std::string title, std::string _description = NULL);
    98147    virtual ~BoxTextQuery();
    99148    virtual bool handle();
     
    102151  class ElementTextQuery : public Dialog::ElementQuery {
    103152  public:
    104     ElementTextQuery(std::string title, std::vector<element *> *_target, std::string _description = NULL);
     153    ElementTextQuery(std::string title, std::string _description = NULL);
    105154    virtual ~ElementTextQuery();
     155    virtual bool handle();
     156  };
     157
     158  class ElementsTextQuery : public Dialog::ElementsQuery {
     159  public:
     160    ElementsTextQuery(std::string title, std::string _description = NULL);
     161    virtual ~ElementsTextQuery();
    106162    virtual bool handle();
    107163  };
  • src/UIElements/TextUI/TextUIFactory.cpp

    r06f4ef6 rb6da28  
    99#include "UIElements/TextUI/TextWindow.hpp"
    1010#include "UIElements/TextUI/TextDialog.hpp"
    11 
    1211
    1312TextUIFactory::TextUIFactory()
  • src/UIElements/TextUI/TextUIFactory.hpp

    r06f4ef6 rb6da28  
    1313class TextUIFactory : public UIFactory
    1414{
    15 friend class UIFactory;
     15  friend class UIFactory;
    1616
    1717public:
  • src/UIElements/TextUI/TextWindow.cpp

    r06f4ef6 rb6da28  
    88#include "Helpers/MemDebug.hpp"
    99
    10 #include "TextUI/TextWindow.hpp"
    11 
    1210#include <boost/bind.hpp>
    13 
    14 
    15 // TODO: When done with refactoring most of these wont be needed anymore
    16 #include "analysis_correlation.hpp"
    17 #include "atom.hpp"
    18 #include "bond.hpp"
    19 #include "bondgraph.hpp"
    20 #include "boundary.hpp"
    21 #include "config.hpp"
    22 #include "element.hpp"
    23 #include "ellipsoid.hpp"
    24 #include "helpers.hpp"
    25 #include "leastsquaremin.hpp"
    26 #include "linkedcell.hpp"
    27 #include "log.hpp"
    28 #include "memoryusageobserver.hpp"
    29 #include "molecule.hpp"
    30 #include "periodentafel.hpp"
    31 #include "World.hpp"
    32 
    33 #include "Legacy/oldmenu.hpp"
    3411
    3512#include "Menu/Menu.hpp"
     
    4017#include "Menu/SubMenuItem.hpp"
    4118#include "TextUI/TextStatusIndicator.hpp"
     19#include "TextUI/TextWindow.hpp"
     20#include "Actions/MapOfActions.hpp"
    4221#include "Actions/MethodAction.hpp"
    43 #include "Actions/MoleculeAction/ChangeNameAction.hpp"
    4422#include "Actions/ErrorAction.hpp"
    4523#include "Actions/ActionRegistry.hpp"
     24#include "Parser/ChangeTracker.hpp"
    4625#include "Views/StreamStringView.hpp"
    4726#include "Views/MethodStringView.hpp"
    4827
     28#include "defs.hpp"
     29#include "log.hpp"
     30#include "verbose.hpp"
     31
     32// all needed due to config::SaveAll()
     33#include "config.hpp"
     34#include "periodentafel.hpp"
     35
     36// config::SaveAll() and enumerate()
     37#include "molecule.hpp"
     38
    4939#include <iostream>
    50 
    51 using namespace std;
     40#include <map>
    5241
    5342// TODO: see what code can be moved to a base class for Graphic and Text Windows
    5443TextWindow::TextWindow()
    5544{
    56   MoleculeListClass *molecules = World::getInstance().getMolecules();
    57   config *configuration = World::getInstance().getConfig();
    58   periodentafel *periode = World::getInstance().getPeriode();
    59   char *ConfigFileName = NULL;
    60   old_menu = new oldmenu;
     45  map <std::string, TextMenu *> NametoTextMenuMap;
     46
     47  // populate all actions
     48  MapOfActions::getInstance().populateActions();
    6149
    6250  // build the main menu
    6351  main_menu = new TextMenu(Log() << Verbose(0), "Main Menu");
    6452
    65   moleculeView = new StreamStringView(boost::bind(&MoleculeListClass::Enumerate,molecules,_1));
     53  moleculeView = new StreamStringView(boost::bind(&MoleculeListClass::Enumerate,World::getInstance().getMolecules(),_1));
    6654  new DisplayMenuItem(main_menu,moleculeView,"Molecule List");
    6755
     
    7664  new SeperatorItem(main_menu);
    7765
    78   Action *setMoleculeAction = new MethodAction("setMoleculeAction",boost::bind(&MoleculeListClass::flipChosen,molecules));
     66  Action *setMoleculeAction = new MethodAction("setMoleculeAction",boost::bind(&MoleculeListClass::flipChosen,World::getInstance().getMolecules()));
    7967  new ActionMenuItem('a',"set molecule (in)active",main_menu,setMoleculeAction);
    8068
    81   TextMenu *editMoleculesMenu = new TextMenu(Log() << Verbose(0), "Edit Molecules");
    82   new SubMenuItem('e',"edit molecules (load, parse, save)",main_menu,editMoleculesMenu);
    83 
    84   Action *manipulateMoleculeAction = new MethodAction("manipulateMoleculeAction",boost::bind(&oldmenu::ManipulateMolecules,old_menu,periode, molecules, configuration));
    85   new ActionMenuItem('g',"globally manipulate atoms in molecule",main_menu,manipulateMoleculeAction);
    86 
    87   Action *mergeMoleculeAction = new MethodAction("mergeMoleculeAction",boost::bind(&oldmenu::MergeMolecules,old_menu,periode, molecules));
    88   new ActionMenuItem('M',"Merge molecules",main_menu,mergeMoleculeAction);
    89 
    90   Action *manipulateAtomsAction = new MethodAction("manipulateAtomsAction",boost::bind(&oldmenu::ManipulateAtoms,old_menu,periode, molecules, configuration));
    91   new ActionMenuItem('m',"manipulate atoms",main_menu,manipulateAtomsAction);
     69  TextMenu *Menu = NULL;
     70  std::set <char> ShortcutList;
     71  for(map<std::string, pair<std::string,std::string> >::iterator iter = MapOfActions::getInstance().MenuDescription.begin(); iter != MapOfActions::getInstance().MenuDescription.end(); ++iter) {
     72    Menu = new TextMenu(Log() << Verbose(0), iter->second.second);
     73    NametoTextMenuMap.insert( pair <std::string, TextMenu *> (iter->first, Menu) );
     74    new SubMenuItem(getSuitableShortForm(ShortcutList,iter->first),iter->second.first.c_str(),main_menu,Menu);
     75  }
    9276
    9377  new SeperatorItem(main_menu);
    9478
    95   Action *editConfigAction = new MethodAction("editConfigAction",boost::bind(&config::Edit,configuration));
    96   new ActionMenuItem('c',"edit the current configuration",main_menu,editConfigAction);
    97 
    98   new SeperatorItem(main_menu);
    99 
    100   Action *saveConfigAction = new MethodAction("saveConfigAction",boost::bind(&config::SaveAll,configuration, ConfigFileName, periode, molecules));
    101   new ActionMenuItem('s',"save current setup to config file",main_menu,saveConfigAction);
    102 
    103   Action *doTestAction = new MethodAction("doTestAction",boost::bind(&oldmenu::testroutine,old_menu,molecules));
    104   new ActionMenuItem('T',"call the current test routine",main_menu,doTestAction);
     79  Action *saveConfigAction = ActionRegistry::getInstance().getActionByName("output");
     80  new ActionMenuItem('s',"save current setup to config files",main_menu,saveConfigAction);
    10581
    10682  quitAction = new MethodAction("quitAction",boost::bind(&TextMenu::doQuit,main_menu),false);
    10783  new ActionMenuItem('q',"quit",main_menu,quitAction);
    10884
    109   // call all functions used to build the submenus
    110 
    111   populateEditMoleculesMenu(editMoleculesMenu);
    112 
    113   Action *returnFromEditMoleculeAction = new TextMenu::LeaveAction(editMoleculesMenu);
    114   MenuItem *returnItem = new ActionMenuItem('q',"return to Main menu",editMoleculesMenu,returnFromEditMoleculeAction);
    115 
    116   editMoleculesMenu->addDefault(returnItem);
     85  // go through all menus and create them
     86  for (map <std::string, TextMenu *>::iterator MenuRunner = NametoTextMenuMap.begin(); MenuRunner != NametoTextMenuMap.end(); ++MenuRunner) {
     87    cout << "Creating Menu " << MenuRunner->first << "." << endl;
     88    populateMenu(MenuRunner->second, MenuRunner->first);
     89  }
    11790
    11891  // Add status indicators etc...
     
    12396TextWindow::~TextWindow()
    12497{
    125   delete old_menu;
    12698  delete quitAction;
    12799  delete moleculeView;
     
    134106}
    135107
    136 void TextWindow::populateEditMoleculesMenu(Menu* editMoleculesMenu)
     108char TextWindow::getSuitableShortForm(std::set <char> &ShortcutList, const std::string name) const
    137109{
    138   MoleculeListClass *molecules = World::getInstance().getMolecules();
    139   periodentafel *periode = World::getInstance().getPeriode();
     110  for (std::string::const_iterator CharRunner = name.begin(); CharRunner != name.end(); ++CharRunner) {
     111    if (ShortcutList.find(*CharRunner) == ShortcutList.end())
     112      return *CharRunner;
     113  }
     114  DoeLog(1) && (eLog() << Verbose(1) << "Could not find a suitable shortform for TextWindow::getSuitableShortForm()." << endl);
     115  return ((char)(ShortcutList.size() % 10) + '0');
     116}
    140117
    141   // build the EditMoleculesMenu
    142   Action *createMoleculeAction = new MethodAction("createMoleculeAction",boost::bind(&MoleculeListClass::createNewMolecule,molecules,periode));
    143   new ActionMenuItem('c',"create new molecule",editMoleculesMenu,createMoleculeAction);
    144 
    145   Action *loadMoleculeAction = new MethodAction("loadMoleculeAction",boost::bind(&MoleculeListClass::loadFromXYZ,molecules,periode));
    146   new ActionMenuItem('l',"load molecule from xyz file",editMoleculesMenu,loadMoleculeAction);
    147 
    148   Action *changeFilenameAction = new MoleculeChangeNameAction();
    149   new ActionMenuItem('n',"change molecule's name",editMoleculesMenu,changeFilenameAction);
    150 
    151   Action *giveFilenameAction = new MethodAction("giveFilenameAction",boost::bind(&MoleculeListClass::setMoleculeFilename,molecules));
    152   new ActionMenuItem('N',"give molecules filename",editMoleculesMenu,giveFilenameAction);
    153 
    154   Action *parseAtomsAction = new MethodAction("parseAtomsAction",boost::bind(&MoleculeListClass::parseXYZIntoMolecule,molecules));
    155   new ActionMenuItem('p',"parse atoms in xyz file into molecule",editMoleculesMenu,parseAtomsAction);
    156 
    157   Action *eraseMoleculeAction = new MethodAction("eraseMoleculeAction",boost::bind(&MoleculeListClass::eraseMolecule,molecules));
    158   new ActionMenuItem('r',"remove a molecule",editMoleculesMenu,eraseMoleculeAction);
    159 
     118void TextWindow::populateMenu(TextMenu* Menu, const  std::string &MenuName)
     119{
     120  Action *ActionItem = NULL;
     121  set <char> ShortcutList;
     122  // through all actions for this menu
     123  pair < multimap <std::string, std::string>::iterator, multimap <std::string, std::string>::iterator > MenuActions = MapOfActions::getInstance().MenuContainsActionMap.equal_range(MenuName);
     124  for (multimap <std::string, std::string>::const_iterator MenuRunner = MenuActions.first; MenuRunner != MenuActions.second; ++MenuRunner) {
     125    cout << " Adding " << MenuRunner->second << " to submenu " << MenuName << endl;
     126    ActionItem = ActionRegistry::getInstance().getActionByName(MenuRunner->second);
     127    new ActionMenuItem(getSuitableShortForm(ShortcutList, MenuRunner->second),MapOfActions::getInstance().getDescription(MenuRunner->second).c_str(),Menu,ActionItem);
     128  }
     129  // finally add default quit item
     130  Action *returnFromAction = new TextMenu::LeaveAction(Menu);
     131  MenuItem *returnFromItem = new ActionMenuItem('q',"return to Main menu",Menu,returnFromAction);
     132  Menu->addDefault(returnFromItem);
    160133}
  • src/UIElements/TextUI/TextWindow.hpp

    r06f4ef6 rb6da28  
    1111#include "MainWindow.hpp"
    1212
     13#include <string>
     14#include <set>
     15
    1316class TextMenu;
    1417class Action;
    15 class oldmenu;
    1618class StringView;
    1719class TextStatusIndicator;
     
    2527
    2628  virtual void display();
     29
    2730private:
    2831  // populaters
    29   void populateEditMoleculesMenu(Menu* editMoleculesMenu);
     32  char getSuitableShortForm(std::set <char> &ShortcutList, const std::string name) const;
     33  void populateMenu(TextMenu* Menu, const std::string &name);
    3034
    3135  TextMenu *main_menu;
     
    3640  StringView *moleculeView;
    3741  TextStatusIndicator *statusIndicator;
    38 
    39   // This class still contains a lot of scattered functionality
    40   oldmenu *old_menu;
    4142};
    4243
  • src/UIElements/UIFactory.cpp

    r06f4ef6 rb6da28  
    1212#include "UIElements/UIFactory.hpp"
    1313#include "Helpers/Assert.hpp"
     14#include "Helpers/MemDebug.hpp"
    1415
    1516using namespace std;
  • src/UIElements/UIFactory.hpp

    r06f4ef6 rb6da28  
    2525 * only create UIelements of that certain type, so that all UIElements match. This way different
    2626 * UIs can be handled in a concise abstract way.
     27 *
     28 * The main functionality is the MainWindow and the Dialog.
     29 *
     30 * MainWindow basically is the framework if the UI. The MainWindow has a run function which is
     31 * called MainWindow::Display(), which will listen for user input and react to it via actions for
     32 * as long as the user desires or tells the MainWindow to quit.
     33 *
     34 * Within the MainWindow Dialog classes may be instantiated which ask the user for input to
     35 * certain actions he wants to perform.
     36 *
    2737 */
    2838class UIFactory : public Singleton<UIFactory,false>
     
    3040  friend class Singleton<UIFactory,false>;
    3141public:
     42
    3243  /**
    3344   * Produce some kind of main window, of whichever type was chosen when the factory was created
  • src/UIElements/Views/StreamStringView.hpp

    r06f4ef6 rb6da28  
    1010
    1111#include <boost/function.hpp>
    12 #include <iostream>
     12#include <iosfwd>
    1313
    1414#include "Views/StringView.hpp"
  • src/VectorSet.hpp

    r06f4ef6 rb6da28  
    1212#include <functional>
    1313#include <algorithm>
     14#include <limits>
    1415
    1516/**
     
    1920 */
    2021
    21 class Vector;
     22#include "vector.hpp"
     23#include <list>
    2224
    2325// this tests, whether we actually have a Vector
     
    4850  void translate(const Vector &translater){
    4951    // this is needed to allow template lookup
    50     transform(this->begin(),this->end(),this->begin(),bind1st(plus<Vector>(),translater));
     52    transform(this->begin(),this->end(),this->begin(),std::bind1st(std::plus<Vector>(),translater));
     53  }
     54
     55  double minDistSquared(const Vector &point){
     56    if(!this->size())
     57      return std::numeric_limits<double>::infinity();
     58    std::list<double> helper;
     59    helper.resize(this->size());
     60    transform(this->begin(),this->end(),
     61              helper.begin(),
     62              std::bind2nd(std::mem_fun_ref(&Vector::DistanceSquared),point));
     63    return *min_element(helper.begin(),helper.end());
    5164  }
    5265};
    5366
     67// allows simpler definition of VectorSets
     68#define VECTORSET(container_type) VectorSet<container_type<Vector> >
     69
    5470#endif /* VECTORSET_HPP_ */
  • src/World.cpp

    r06f4ef6 rb6da28  
    1010#include "World.hpp"
    1111
     12#include <functional>
     13
    1214#include "atom.hpp"
    1315#include "config.hpp"
    1416#include "molecule.hpp"
    1517#include "periodentafel.hpp"
     18#include "ThermoStatContainer.hpp"
    1619#include "Descriptors/AtomDescriptor.hpp"
    1720#include "Descriptors/AtomDescriptor_impl.hpp"
     
    2023#include "Descriptors/SelectiveIterator_impl.hpp"
    2124#include "Actions/ManipulateAtomsProcess.hpp"
     25#include "Helpers/Assert.hpp"
     26#include "Box.hpp"
     27#include "Matrix.hpp"
     28#include "defs.hpp"
    2229
    2330#include "Patterns/Singleton_impl.hpp"
     31#include "Patterns/ObservedContainer_impl.hpp"
    2432
    2533using namespace std;
     34
     35const unsigned int MAX_POOL_FRAGMENTATION=20;
     36const unsigned int MAX_FRAGMENTATION_SKIPS=100;
    2637
    2738/******************************* getter and setter ************************/
     
    4051}
    4152
    42 vector<atom*> World::getAllAtoms(AtomDescriptor descriptor){
     53World::AtomComposite World::getAllAtoms(AtomDescriptor descriptor){
    4354  return descriptor.findAll();
    4455}
    4556
    46 vector<atom*> World::getAllAtoms(){
     57World::AtomComposite World::getAllAtoms(){
    4758  return getAllAtoms(AllAtoms());
    4859}
     
    7283// system
    7384
    74 double * World::getDomain() {
    75   return cell_size;
     85Box& World::getDomain() {
     86  return *cell_size;
     87}
     88
     89void World::setDomain(const Matrix &mat){
     90  OBSERVE;
     91  *cell_size = mat;
    7692}
    7793
    7894void World::setDomain(double * matrix)
    7995{
    80 
     96  OBSERVE;
     97  Matrix M = ReturnFullMatrixforSymmetric(matrix);
     98  cell_size->setM(M);
    8199}
    82100
     
    87105void World::setDefaultName(std::string name)
    88106{
     107  OBSERVE;
    89108  defaultName = name;
    90109};
     110
     111class ThermoStatContainer * World::getThermostats()
     112{
     113  return Thermostats;
     114}
     115
    91116
    92117int World::getExitFlag() {
     
    105130  molecule *mol = NULL;
    106131  mol = NewMolecule();
    107   assert(!molecules.count(currMoleculeId));
    108   mol->setId(currMoleculeId++);
     132  moleculeId_t id = getNextMoleculeId();
     133  ASSERT(!molecules.count(id),"proposed id did not specify an unused ID");
     134  mol->setId(id);
    109135  // store the molecule by ID
    110136  molecules[mol->getId()] = mol;
     
    121147  OBSERVE;
    122148  molecule *mol = molecules[id];
    123   assert(mol);
     149  ASSERT(mol,"Molecule id that was meant to be destroyed did not exist");
    124150  DeleteMolecule(mol);
    125151  molecules.erase(id);
    126 }
    127 
    128 double *World::cell_size = NULL;
     152  releaseMoleculeId(id);
     153}
    129154
    130155atom *World::createAtom(){
    131156  OBSERVE;
    132157  atomId_t id = getNextAtomId();
     158  ASSERT(!atoms.count(id),"proposed id did not specify an unused ID");
    133159  atom *res = NewAtom(id);
    134160  res->setWorld(this);
     
    157183  OBSERVE;
    158184  atom *atom = atoms[id];
    159   assert(atom);
     185  ASSERT(atom,"Atom ID that was meant to be destroyed did not exist");
    160186  DeleteAtom(atom);
    161187  atoms.erase(id);
     
    169195  if(!target){
    170196    target = atoms[oldId];
    171     assert(target && "Atom with that ID not found");
     197    ASSERT(target,"Atom with that ID not found");
    172198    return target->changeId(newId);
    173199  }
     
    207233
    208234atomId_t World::getNextAtomId(){
    209   // see if we can reuse some Id
    210   if(atomIdPool.empty()){
    211     return currAtomId++;
    212   }
    213   else{
    214     // we give out the first ID from the pool
    215     atomId_t id = *(atomIdPool.begin());
    216     atomIdPool.erase(id);
     235  // try to find an Id in the pool;
     236  if(!atomIdPool.empty()){
     237    atomIdPool_t::iterator iter=atomIdPool.begin();
     238    atomId_t id = iter->first;
     239    range<atomId_t> newRange = makeRange(id+1,iter->last);
     240    // we wont use this iterator anymore, so we don't care about invalidating
     241    atomIdPool.erase(iter);
     242    if(newRange.first<newRange.last){
     243      atomIdPool.insert(newRange);
     244    }
    217245    return id;
    218246  }
     247  // Nothing in the pool... we are out of luck
     248  return currAtomId++;
    219249}
    220250
    221251void World::releaseAtomId(atomId_t id){
    222   atomIdPool.insert(id);
    223   // defragmentation of the pool
    224   set<atomId_t>::reverse_iterator iter;
    225   // go through all Ids in the pool that lie immediately below the border
    226   while(!atomIdPool.empty() && *(atomIdPool.rbegin())==(currAtomId-1)){
    227     atomIdPool.erase(--currAtomId);
    228   }
     252  atomIdPool.insert(makeRange(id,id+1));
     253  defragAtomIdPool();
    229254}
    230255
    231256bool World::reserveAtomId(atomId_t id){
    232257  if(id>=currAtomId ){
    233     // add all ids between the new one and current border as available
    234     for(atomId_t pos=currAtomId; pos<id; ++pos){
    235       atomIdPool.insert(pos);
     258    range<atomId_t> newRange = makeRange(currAtomId,id);
     259    if(newRange.first<newRange.last){
     260      atomIdPool.insert(newRange);
    236261    }
    237262    currAtomId=id+1;
     263    defragAtomIdPool();
    238264    return true;
    239265  }
    240   else if(atomIdPool.count(id)){
    241     atomIdPool.erase(id);
     266  // look for a range that matches the request
     267  for(atomIdPool_t::iterator iter=atomIdPool.begin();iter!=atomIdPool.end();++iter){
     268    if(iter->isBefore(id)){
     269      // we have covered all available ranges... nothing to be found here
     270      break;
     271    }
     272    // no need to check first, since it has to be <=id, since otherwise we would have broken out
     273    if(!iter->isBeyond(id)){
     274      // we found a matching range... get the id from this range
     275
     276      // split up this range at the point of id
     277      range<atomId_t> bottomRange = makeRange(iter->first,id);
     278      range<atomId_t> topRange = makeRange(id+1,iter->last);
     279      // remove this range
     280      atomIdPool.erase(iter);
     281      if(bottomRange.first<bottomRange.last){
     282        atomIdPool.insert(bottomRange);
     283      }
     284      if(topRange.first<topRange.last){
     285        atomIdPool.insert(topRange);
     286      }
     287      defragAtomIdPool();
     288      return true;
     289    }
     290  }
     291  // this ID could not be reserved
     292  return false;
     293}
     294
     295void World::defragAtomIdPool(){
     296  // check if the situation is bad enough to make defragging neccessary
     297  if((numAtomDefragSkips<MAX_FRAGMENTATION_SKIPS) &&
     298     (atomIdPool.size()<lastAtomPoolSize+MAX_POOL_FRAGMENTATION)){
     299    ++numAtomDefragSkips;
     300    return;
     301  }
     302  for(atomIdPool_t::iterator iter = atomIdPool.begin();iter!=atomIdPool.end();){
     303    // see if this range is adjacent to the next one
     304    atomIdPool_t::iterator next = iter;
     305    next++;
     306    if(next!=atomIdPool.end() && (next->first==iter->last)){
     307      // merge the two ranges
     308      range<atomId_t> newRange = makeRange(iter->first,next->last);
     309      atomIdPool.erase(iter);
     310      atomIdPool.erase(next);
     311      pair<atomIdPool_t::iterator,bool> res = atomIdPool.insert(newRange);
     312      ASSERT(res.second,"Id-Pool was confused");
     313      iter=res.first;
     314      continue;
     315    }
     316    ++iter;
     317  }
     318  if(!atomIdPool.empty()){
     319    // check if the last range is at the border
     320    atomIdPool_t::iterator iter = atomIdPool.end();
     321    iter--;
     322    if(iter->last==currAtomId){
     323      currAtomId=iter->first;
     324      atomIdPool.erase(iter);
     325    }
     326  }
     327  lastAtomPoolSize=atomIdPool.size();
     328  numAtomDefragSkips=0;
     329}
     330
     331// Molecules
     332
     333moleculeId_t World::getNextMoleculeId(){
     334  // try to find an Id in the pool;
     335  if(!moleculeIdPool.empty()){
     336    moleculeIdPool_t::iterator iter=moleculeIdPool.begin();
     337    moleculeId_t id = iter->first;
     338    range<moleculeId_t> newRange = makeRange(id+1,iter->last);
     339    // we wont use this iterator anymore, so we don't care about invalidating
     340    moleculeIdPool.erase(iter);
     341    if(newRange.first<newRange.last){
     342      moleculeIdPool.insert(newRange);
     343    }
     344    return id;
     345  }
     346  // Nothing in the pool... we are out of luck
     347  return currMoleculeId++;
     348}
     349
     350void World::releaseMoleculeId(moleculeId_t id){
     351  moleculeIdPool.insert(makeRange(id,id+1));
     352  defragMoleculeIdPool();
     353}
     354
     355bool World::reserveMoleculeId(moleculeId_t id){
     356  if(id>=currMoleculeId ){
     357    range<moleculeId_t> newRange = makeRange(currMoleculeId,id);
     358    if(newRange.first<newRange.last){
     359      moleculeIdPool.insert(newRange);
     360    }
     361    currMoleculeId=id+1;
     362    defragMoleculeIdPool();
    242363    return true;
    243364  }
    244   else{
    245     // this ID could not be reserved
    246     return false;
    247   }
    248 }
     365  // look for a range that matches the request
     366  for(moleculeIdPool_t::iterator iter=moleculeIdPool.begin();iter!=moleculeIdPool.end();++iter){
     367    if(iter->isBefore(id)){
     368      // we have coverd all available ranges... nothing to be found here
     369      break;
     370    }
     371    // no need to check first, since it has to be <=id, since otherwise we would have broken out
     372    if(!iter->isBeyond(id)){
     373      // we found a matching range... get the id from this range
     374
     375      // split up this range at the point of id
     376      range<moleculeId_t> bottomRange = makeRange(iter->first,id);
     377      range<moleculeId_t> topRange = makeRange(id+1,iter->last);
     378      // remove this range
     379      moleculeIdPool.erase(iter);
     380      if(bottomRange.first<bottomRange.last){
     381        moleculeIdPool.insert(bottomRange);
     382      }
     383      if(topRange.first<topRange.last){
     384        moleculeIdPool.insert(topRange);
     385      }
     386      defragMoleculeIdPool();
     387      return true;
     388    }
     389  }
     390  // this ID could not be reserved
     391  return false;
     392}
     393
     394void World::defragMoleculeIdPool(){
     395  // check if the situation is bad enough to make defragging neccessary
     396  if((numMoleculeDefragSkips<MAX_FRAGMENTATION_SKIPS) &&
     397     (moleculeIdPool.size()<lastMoleculePoolSize+MAX_POOL_FRAGMENTATION)){
     398    ++numMoleculeDefragSkips;
     399    return;
     400  }
     401  for(moleculeIdPool_t::iterator iter = moleculeIdPool.begin();iter!=moleculeIdPool.end();){
     402    // see if this range is adjacent to the next one
     403    moleculeIdPool_t::iterator next = iter;
     404    next++;
     405    if(next!=moleculeIdPool.end() && (next->first==iter->last)){
     406      // merge the two ranges
     407      range<moleculeId_t> newRange = makeRange(iter->first,next->last);
     408      moleculeIdPool.erase(iter);
     409      moleculeIdPool.erase(next);
     410      pair<moleculeIdPool_t::iterator,bool> res = moleculeIdPool.insert(newRange);
     411      ASSERT(res.second,"Id-Pool was confused");
     412      iter=res.first;
     413      continue;
     414    }
     415    ++iter;
     416  }
     417  if(!moleculeIdPool.empty()){
     418    // check if the last range is at the border
     419    moleculeIdPool_t::iterator iter = moleculeIdPool.end();
     420    iter--;
     421    if(iter->last==currMoleculeId){
     422      currMoleculeId=iter->first;
     423      moleculeIdPool.erase(iter);
     424    }
     425  }
     426  lastMoleculePoolSize=moleculeIdPool.size();
     427  numMoleculeDefragSkips=0;
     428}
     429
     430/******************************* Iterators ********************************/
     431
     432// external parts with observers
     433
     434CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet,AtomDescriptor);
     435
     436World::AtomIterator
     437World::getAtomIter(AtomDescriptor descr){
     438    return AtomIterator(descr,atoms);
     439}
     440
     441World::AtomIterator
     442World::getAtomIter(){
     443    return AtomIterator(AllAtoms(),atoms);
     444}
     445
     446World::AtomIterator
     447World::atomEnd(){
     448  return AtomIterator(AllAtoms(),atoms,atoms.end());
     449}
     450
     451CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet,MoleculeDescriptor);
     452
     453World::MoleculeIterator
     454World::getMoleculeIter(MoleculeDescriptor descr){
     455    return MoleculeIterator(descr,molecules);
     456}
     457
     458World::MoleculeIterator
     459World::getMoleculeIter(){
     460    return MoleculeIterator(AllMolecules(),molecules);
     461}
     462
     463World::MoleculeIterator
     464World::moleculeEnd(){
     465  return MoleculeIterator(AllMolecules(),molecules,molecules.end());
     466}
     467
     468// Internal parts, without observers
     469
     470// Build the AtomIterator from template
     471CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet::set_t,AtomDescriptor);
     472
     473
     474World::internal_AtomIterator
     475World::getAtomIter_internal(AtomDescriptor descr){
     476  return internal_AtomIterator(descr,atoms.getContent());
     477}
     478
     479World::internal_AtomIterator
     480World::atomEnd_internal(){
     481  return internal_AtomIterator(AllAtoms(),atoms.getContent(),atoms.end_internal());
     482}
     483
     484// build the MoleculeIterator from template
     485CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet::set_t,MoleculeDescriptor);
     486
     487World::internal_MoleculeIterator World::getMoleculeIter_internal(MoleculeDescriptor descr){
     488  return internal_MoleculeIterator(descr,molecules.getContent());
     489}
     490
     491World::internal_MoleculeIterator World::moleculeEnd_internal(){
     492  return internal_MoleculeIterator(AllMolecules(),molecules.getContent(),molecules.end_internal());
     493}
     494
     495/************************** Selection of Atoms and molecules ******************/
     496
     497// Atoms
     498
     499void World::clearAtomSelection(){
     500  selectedAtoms.clear();
     501}
     502
     503void World::selectAtom(atom *atom){
     504  ASSERT(atom,"Invalid pointer in selection of atom");
     505  selectedAtoms[atom->getId()]=atom;
     506}
     507
     508void World::selectAtom(atomId_t id){
     509  ASSERT(atoms.count(id),"Atom Id selected that was not in the world");
     510  selectedAtoms[id]=atoms[id];
     511}
     512
     513void World::selectAllAtoms(AtomDescriptor descr){
     514  internal_AtomIterator begin = getAtomIter_internal(descr);
     515  internal_AtomIterator end = atomEnd_internal();
     516  void (World::*func)(atom*) = &World::selectAtom; // needed for type resolution of overloaded function
     517  for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above
     518}
     519
     520void World::selectAtomsOfMolecule(molecule *_mol){
     521  ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule");
     522  // need to make it const to get the fast iterators
     523  const molecule *mol = _mol;
     524  void (World::*func)(atom*) = &World::selectAtom; // needed for type resolution of overloaded function
     525  for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is select... see above
     526}
     527
     528void World::selectAtomsOfMolecule(moleculeId_t id){
     529  ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule");
     530  selectAtomsOfMolecule(molecules[id]);
     531}
     532
     533void World::unselectAtom(atom *atom){
     534  ASSERT(atom,"Invalid pointer in unselection of atom");
     535  unselectAtom(atom->getId());
     536}
     537
     538void World::unselectAtom(atomId_t id){
     539  ASSERT(atoms.count(id),"Atom Id unselected that was not in the world");
     540  selectedAtoms.erase(id);
     541}
     542
     543void World::unselectAllAtoms(AtomDescriptor descr){
     544  internal_AtomIterator begin = getAtomIter_internal(descr);
     545  internal_AtomIterator end = atomEnd_internal();
     546  void (World::*func)(atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
     547  for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above
     548}
     549
     550void World::unselectAtomsOfMolecule(molecule *_mol){
     551  ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule");
     552  // need to make it const to get the fast iterators
     553  const molecule *mol = _mol;
     554  void (World::*func)(atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
     555  for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is unsselect... see above
     556}
     557
     558void World::unselectAtomsOfMolecule(moleculeId_t id){
     559  ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule");
     560  unselectAtomsOfMolecule(molecules[id]);
     561}
     562
     563size_t World::countSelectedAtoms() const {
     564  size_t count = 0;
     565  for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter)
     566    count++;
     567  return count;
     568}
     569
     570bool World::isSelected(atom *atom) const {
     571  return selectedAtoms.find(atom->getId()) != selectedAtoms.end();
     572}
     573
     574const std::vector<atom *> World::getSelectedAtoms() const {
     575  std::vector<atom *> returnAtoms;
     576  returnAtoms.resize(countSelectedAtoms());
     577  int count = 0;
     578  for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter)
     579    returnAtoms[count++] = iter->second;
     580  return returnAtoms;
     581}
     582
    249583
    250584// Molecules
    251585
    252 /******************************* Iterators ********************************/
    253 
    254 // Build the AtomIterator from template
    255 CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet,AtomDescriptor);
    256 
    257 
    258 World::AtomIterator World::getAtomIter(AtomDescriptor descr){
    259   return AtomIterator(descr,atoms);
    260 }
    261 
    262 World::AtomIterator World::atomEnd(){
    263   return AtomIterator(AllAtoms(),atoms,atoms.end());
    264 }
    265 
    266 // build the MoleculeIterator from template
    267 CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet,MoleculeDescriptor);
    268 
    269 World::MoleculeIterator World::getMoleculeIter(MoleculeDescriptor descr){
    270   return MoleculeIterator(descr,molecules);
    271 }
    272 
    273 World::MoleculeIterator World::moleculeEnd(){
    274   return MoleculeIterator(AllMolecules(),molecules,molecules.end());
     586void World::clearMoleculeSelection(){
     587  selectedMolecules.clear();
     588}
     589
     590void World::selectMolecule(molecule *mol){
     591  ASSERT(mol,"Invalid pointer to molecule in selection");
     592  selectedMolecules[mol->getId()]=mol;
     593}
     594
     595void World::selectMolecule(moleculeId_t id){
     596  ASSERT(molecules.count(id),"Molecule Id selected that was not in the world");
     597  selectedMolecules[id]=molecules[id];
     598}
     599
     600void World::selectAllMolecules(MoleculeDescriptor descr){
     601  internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
     602  internal_MoleculeIterator end = moleculeEnd_internal();
     603  void (World::*func)(molecule*) = &World::selectMolecule; // needed for type resolution of overloaded function
     604  for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above
     605}
     606
     607void World::selectMoleculeOfAtom(atom *atom){
     608  ASSERT(atom,"Invalid atom pointer in selection of MoleculeOfAtom");
     609  molecule *mol=atom->getMolecule();
     610  // the atom might not be part of a molecule
     611  if(mol){
     612    selectMolecule(mol);
     613  }
     614}
     615
     616void World::selectMoleculeOfAtom(atomId_t id){
     617  ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\
     618  selectMoleculeOfAtom(atoms[id]);
     619}
     620
     621void World::unselectMolecule(molecule *mol){
     622  ASSERT(mol,"invalid pointer in unselection of molecule");
     623  unselectMolecule(mol->getId());
     624}
     625
     626void World::unselectMolecule(moleculeId_t id){
     627  ASSERT(molecules.count(id),"No such molecule with ID in unselection");
     628  selectedMolecules.erase(id);
     629}
     630
     631void World::unselectAllMolecules(MoleculeDescriptor descr){
     632  internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
     633  internal_MoleculeIterator end = moleculeEnd_internal();
     634  void (World::*func)(molecule*) = &World::unselectMolecule; // needed for type resolution of overloaded function
     635  for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above
     636}
     637
     638void World::unselectMoleculeOfAtom(atom *atom){
     639  ASSERT(atom,"Invalid atom pointer in selection of MoleculeOfAtom");
     640  molecule *mol=atom->getMolecule();
     641  // the atom might not be part of a molecule
     642  if(mol){
     643    unselectMolecule(mol);
     644  }
     645}
     646
     647void World::unselectMoleculeOfAtom(atomId_t id){
     648  ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\
     649  unselectMoleculeOfAtom(atoms[id]);
     650}
     651
     652size_t World::countSelectedMolecules() const {
     653  size_t count = 0;
     654  for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter)
     655    count++;
     656  return count;
     657}
     658
     659bool World::isSelected(molecule *mol) const {
     660  return selectedMolecules.find(mol->getId()) != selectedMolecules.end();
     661}
     662
     663const std::vector<molecule *> World::getSelectedMolecules() const {
     664  std::vector<molecule *> returnMolecules;
     665  returnMolecules.resize(countSelectedMolecules());
     666  int count = 0;
     667  for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter)
     668    returnMolecules[count++] = iter->second;
     669  return returnMolecules;
     670}
     671
     672/******************* Iterators over Selection *****************************/
     673World::AtomSelectionIterator World::beginAtomSelection(){
     674  return selectedAtoms.begin();
     675}
     676
     677World::AtomSelectionIterator World::endAtomSelection(){
     678  return selectedAtoms.end();
     679}
     680
     681
     682World::MoleculeSelectionIterator World::beginMoleculeSelection(){
     683  return selectedMolecules.begin();
     684}
     685
     686World::MoleculeSelectionIterator World::endMoleculeSelection(){
     687  return selectedMolecules.end();
    275688}
    276689
     
    281694    periode(new periodentafel),
    282695    configuration(new config),
     696    Thermostats(new ThermoStatContainer),
    283697    ExitFlag(0),
    284     atoms(),
     698    atoms(this),
     699    selectedAtoms(this),
    285700    currAtomId(0),
    286     molecules(),
     701    lastAtomPoolSize(0),
     702    numAtomDefragSkips(0),
     703    molecules(this),
     704    selectedMolecules(this),
    287705    currMoleculeId(0),
    288706    molecules_deprecated(new MoleculeListClass(this))
    289707{
    290   cell_size = new double[6];
    291   cell_size[0] = 20.;
    292   cell_size[1] = 0.;
    293   cell_size[2] = 20.;
    294   cell_size[3] = 0.;
    295   cell_size[4] = 0.;
    296   cell_size[5] = 20.;
     708  cell_size = new Box;
     709  Matrix domain;
     710  domain.at(0,0) = 20;
     711  domain.at(1,1) = 20;
     712  domain.at(2,2) = 20;
     713  cell_size->setM(domain);
    297714  defaultName = "none";
    298715  molecules_deprecated->signOn(this);
     
    302719{
    303720  molecules_deprecated->signOff(this);
    304   delete[] cell_size;
     721  delete cell_size;
    305722  delete molecules_deprecated;
    306   delete periode;
    307   delete configuration;
    308723  MoleculeSet::iterator molIter;
    309724  for(molIter=molecules.begin();molIter!=molecules.end();++molIter){
     
    316731  }
    317732  atoms.clear();
     733  delete periode;
     734  delete configuration;
     735  delete Thermostats;
    318736}
    319737
  • src/World.hpp

    r06f4ef6 rb6da28  
    2323#include "Patterns/Cacheable.hpp"
    2424#include "Patterns/Singleton.hpp"
     25#include "Patterns/ObservedContainer.hpp"
     26#include "Helpers/Range.hpp"
     27#include "AtomSet.hpp"
    2528
    2629// include config.h
     
    3033
    3134// forward declarations
    32 class config;
    33 class periodentafel;
    34 class MoleculeListClass;
    3535class atom;
    36 class molecule;
    3736class AtomDescriptor;
    3837class AtomDescriptor_impl;
     38template<typename T> class AtomsCalculation;
     39class Box;
     40class config;
     41class ManipulateAtomsProcess;
     42class Matrix;
     43class molecule;
    3944class MoleculeDescriptor;
    4045class MoleculeDescriptor_impl;
    41 class ManipulateAtomsProcess;
    42 template<typename T>
    43 class AtomsCalculation;
     46class MoleculeListClass;
     47class periodentafel;
     48class ThermoStatContainer;
     49
    4450
    4551/****************************************** forward declarations *****************************/
     
    5864friend class MoleculeDescriptor_impl;
    5965friend class MoleculeDescriptor;
     66// coupling with descriptors over selection
     67friend class AtomSelectionDescriptor_impl;
     68friend class MoleculeSelectionDescriptor_impl;
    6069
    6170// Actions, calculations etc associated with the World
     
    6574
    6675  // Types for Atom and Molecule structures
    67   typedef std::map<atomId_t,atom*> AtomSet;
    68   typedef std::map<moleculeId_t,molecule*> MoleculeSet;
     76  typedef ObservedContainer<std::map<atomId_t,atom*> > AtomSet;
     77  typedef ObservedContainer<std::map<moleculeId_t,molecule*> > MoleculeSet;
     78
     79  typedef ATOMSET(std::vector) AtomComposite;
    6980
    7081  /***** getter and setter *****/
     
    89100   * returns a vector containing all atoms that match a given descriptor
    90101   */
    91   std::vector<atom*> getAllAtoms(AtomDescriptor descriptor);
    92   std::vector<atom*> getAllAtoms();
     102  AtomComposite getAllAtoms(AtomDescriptor descriptor);
     103  AtomComposite getAllAtoms();
    93104
    94105  /**
     
    125136   * get the domain size as a symmetric matrix (6 components)
    126137   */
    127   double * getDomain();
     138  Box& getDomain();
     139
     140  /**
     141   * Set the domain size from a matrix object
     142   *
     143   * Matrix needs to be symmetric
     144   */
     145  void setDomain(const Matrix &mat);
    128146
    129147  /**
     
    141159   */
    142160  void setDefaultName(std::string name);
     161
     162  /**
     163   * get pointer to World's ThermoStatContainer
     164   */
     165  ThermoStatContainer * getThermostats();
    143166
    144167  /*
     
    202225  ManipulateAtomsProcess* manipulateAtoms(boost::function<void(atom*)>,std::string);
    203226
     227  /****
     228   * Iterators to use internal data structures
     229   * All these iterators are observed to track changes.
     230   * There is a corresponding protected section with unobserved iterators,
     231   * which can be used internally when the extra speed is needed
     232   */
     233
     234  typedef SelectiveIterator<atom*,AtomSet,AtomDescriptor>       AtomIterator;
     235
     236  /**
     237   * returns an iterator over all Atoms matching a given descriptor.
     238   * This iterator is observed, so don't keep it around unnecessary to
     239   * avoid unintended blocking.
     240   */
     241  AtomIterator getAtomIter(AtomDescriptor descr);
     242  AtomIterator getAtomIter();
     243
     244  AtomIterator atomEnd();
     245
     246  typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor>   MoleculeIterator;
     247
     248  /**
     249   * returns an iterator over all Molecules matching a given descriptor.
     250   * This iterator is observed, so don't keep it around unnecessary to
     251   * avoid unintended blocking.
     252   */
     253  MoleculeIterator getMoleculeIter(MoleculeDescriptor descr);
     254  MoleculeIterator getMoleculeIter();
     255
     256  MoleculeIterator moleculeEnd();
     257
     258  /******** Selections of molecules and Atoms *************/
     259  void clearAtomSelection();
     260  void selectAtom(atom*);
     261  void selectAtom(atomId_t);
     262  void selectAllAtoms(AtomDescriptor);
     263  void selectAtomsOfMolecule(molecule*);
     264  void selectAtomsOfMolecule(moleculeId_t);
     265  void unselectAtom(atom*);
     266  void unselectAtom(atomId_t);
     267  void unselectAllAtoms(AtomDescriptor);
     268  void unselectAtomsOfMolecule(molecule*);
     269  void unselectAtomsOfMolecule(moleculeId_t);
     270  size_t countSelectedAtoms() const;
     271  bool isSelected(atom *_atom) const;
     272  const std::vector<atom *> getSelectedAtoms() const;
     273
     274  void clearMoleculeSelection();
     275  void selectMolecule(molecule*);
     276  void selectMolecule(moleculeId_t);
     277  void selectAllMolecules(MoleculeDescriptor);
     278  void selectMoleculeOfAtom(atom*);
     279  void selectMoleculeOfAtom(atomId_t);
     280  void unselectMolecule(molecule*);
     281  void unselectMolecule(moleculeId_t);
     282  void unselectAllMolecules(MoleculeDescriptor);
     283  void unselectMoleculeOfAtom(atom*);
     284  void unselectMoleculeOfAtom(atomId_t);
     285  size_t countSelectedMolecules() const;
     286  bool isSelected(molecule *_mol) const;
     287  const std::vector<molecule *> getSelectedMolecules() const;
     288
     289  /******************** Iterators to selections *****************/
     290  typedef AtomSet::iterator AtomSelectionIterator;
     291  AtomSelectionIterator beginAtomSelection();
     292  AtomSelectionIterator endAtomSelection();
     293
     294  typedef MoleculeSet::iterator MoleculeSelectionIterator;
     295  MoleculeSelectionIterator beginMoleculeSelection();
     296  MoleculeSelectionIterator endMoleculeSelection();
     297
    204298protected:
    205   /**** Iterators to use internal data structures */
     299  /****
     300   * Iterators to use internal data structures
     301   * All these iterators are unobserved for speed reasons.
     302   * There is a corresponding public section to these methods,
     303   * which produce observed iterators.*/
    206304
    207305  // Atoms
    208   typedef SelectiveIterator<atom*,AtomSet,AtomDescriptor> AtomIterator;
     306  typedef SelectiveIterator<atom*,AtomSet::set_t,AtomDescriptor>        internal_AtomIterator;
    209307
    210308  /**
     
    212310   * used for internal purposes, like AtomProcesses and AtomCalculations.
    213311   */
    214   AtomIterator getAtomIter(AtomDescriptor descr);
     312  internal_AtomIterator getAtomIter_internal(AtomDescriptor descr);
    215313
    216314  /**
     
    220318   * used for internal purposes, like AtomProcesses and AtomCalculations.
    221319   */
    222   AtomIterator atomEnd();
     320  internal_AtomIterator atomEnd_internal();
    223321
    224322  // Molecules
    225 
    226   typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor> MoleculeIterator;
     323  typedef SelectiveIterator<molecule*,MoleculeSet::set_t,MoleculeDescriptor>   internal_MoleculeIterator;
     324
    227325
    228326  /**
     
    230328   * used for internal purposes, like MoleculeProcesses and MoleculeCalculations.
    231329   */
    232   MoleculeIterator getMoleculeIter(MoleculeDescriptor descr);
     330  internal_MoleculeIterator getMoleculeIter_internal(MoleculeDescriptor descr);
    233331
    234332  /**
     
    238336   * used for internal purposes, like MoleculeProcesses and MoleculeCalculations.
    239337   */
    240   MoleculeIterator moleculeEnd();
     338  internal_MoleculeIterator moleculeEnd_internal();
    241339
    242340
     
    249347  void releaseAtomId(atomId_t);
    250348  bool reserveAtomId(atomId_t);
     349  void defragAtomIdPool();
     350
     351  moleculeId_t getNextMoleculeId();
     352  void releaseMoleculeId(moleculeId_t);
     353  bool reserveMoleculeId(moleculeId_t);
     354  void defragMoleculeIdPool();
    251355
    252356  periodentafel *periode;
    253357  config *configuration;
    254   static double *cell_size;
     358  Box *cell_size;
    255359  std::string defaultName;
     360  class ThermoStatContainer *Thermostats;
    256361  int ExitFlag;
    257 public:
     362private:
     363
    258364  AtomSet atoms;
    259 private:
    260   std::set<atomId_t> atomIdPool; //<!stores the pool for all available AtomIds below currAtomId
     365  AtomSet selectedAtoms;
     366  typedef std::set<range<atomId_t> > atomIdPool_t;
     367  /**
     368   * stores the pool for all available AtomIds below currAtomId
     369   *
     370   * The pool contains ranges of free ids in the form [bottom,top).
     371   */
     372  atomIdPool_t atomIdPool;
    261373  atomId_t currAtomId; //!< stores the next available Id for atoms
     374  size_t lastAtomPoolSize; //!< size of the pool after last defrag, to skip some defrags
     375  unsigned int numAtomDefragSkips;
     376
    262377  MoleculeSet molecules;
     378  MoleculeSet selectedMolecules;
     379  typedef std::set<range<atomId_t> > moleculeIdPool_t;
     380  /**
     381   * stores the pool for all available AtomIds below currAtomId
     382   *
     383   * The pool contains ranges of free ids in the form [bottom,top).
     384   */
     385  moleculeIdPool_t moleculeIdPool;
    263386  moleculeId_t currMoleculeId;
     387  size_t lastMoleculePoolSize; //!< size of the pool after last defrag, to skip some defrags
     388  unsigned int numMoleculeDefragSkips;
    264389private:
    265390  /**
  • src/analysis_bonds.cpp

    r06f4ef6 rb6da28  
    1313#include "element.hpp"
    1414#include "info.hpp"
     15#include "verbose.hpp"
    1516#include "log.hpp"
    1617#include "molecule.hpp"
     
    121122 * \param *molecules molecules to count bonds
    122123 * \param *InterfaceElement or NULL
    123  */
    124 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL)
     124 * \param *Interface2Element or NULL
     125 */
     126int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL, const element * Interface2Element = NULL)
    125127{
    126128  int count = 0;
     
    128130  double Otherangle = 0.;
    129131  bool InterfaceFlag = false;
     132  bool Interface2Flag = false;
    130133  bool OtherHydrogenFlag = true;
    131134  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); ++MolWalker) {
     
    145148              OtherHydrogens = 0;
    146149              InterfaceFlag = (InterfaceElement == NULL);
     150              Interface2Flag = (Interface2Element == NULL);
    147151              for (BondList::const_iterator BondRunner = (*Runner)->ListOfBonds.begin(); BondRunner != (*Runner)->ListOfBonds.end(); BondRunner++) {
    148152                atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Runner);
     
    155159                }
    156160                InterfaceFlag = InterfaceFlag || (OtherAtom->type == InterfaceElement);
     161                Interface2Flag = Interface2Flag || (OtherAtom->type == Interface2Element);
    157162              }
    158163              DoLog(1) && (Log() << Verbose(1) << "Otherangle is " << Otherangle << " for " << OtherHydrogens << " hydrogens." << endl);
     
    168173                  break;
    169174              }
    170               if (InterfaceFlag && OtherHydrogenFlag) {
     175              if (InterfaceFlag && Interface2Flag && OtherHydrogenFlag) {
    171176                // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule
    172177                for (BondList::const_iterator BondRunner = (*Walker)->ListOfBonds.begin(); BondRunner != (*Walker)->ListOfBonds.end(); BondRunner++) {
  • src/analysis_bonds.hpp

    r06f4ef6 rb6da28  
    3333void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, const element *type1, const element *type2, double &Min, double &Mean, double &Max);
    3434
    35 int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, const element * InterfaceElement);
     35int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, const element * InterfaceElement, const element * Interface2Element);
    3636int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second);
    3737int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third);
  • src/analysis_correlation.cpp

    r06f4ef6 rb6da28  
    99
    1010#include <iostream>
     11#include <iomanip>
    1112
    1213#include "analysis_correlation.hpp"
     
    1920#include "triangleintersectionlist.hpp"
    2021#include "vector.hpp"
     22#include "Matrix.hpp"
    2123#include "verbose.hpp"
    2224#include "World.hpp"
     25#include "Box.hpp"
    2326
    2427
    2528/** Calculates the pair correlation between given elements.
    2629 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
    27  * \param *molecules list of molecules structure
     30 * \param *molecules vector of molecules
    2831 * \param &elements vector of elements to correlate
    2932 * \return Map of doubles with values the pair of the two atoms.
    3033 */
    31 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements)
     34PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements)
    3235{
    3336  Info FunctionInfo(__func__);
    3437  PairCorrelationMap *outmap = NULL;
    3538  double distance = 0.;
    36   double *domain = World::getInstance().getDomain();
    37 
    38   if (molecules->ListOfMolecules.empty()) {
     39  Box &domain = World::getInstance().getDomain();
     40
     41  if (molecules.empty()) {
    3942    DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
    4043    return outmap;
    4144  }
    42   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     45  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
    4346    (*MolWalker)->doCountAtoms();
    4447
     
    6164
    6265  outmap = new PairCorrelationMap;
    63   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){
    64     if ((*MolWalker)->ActiveFlag) {
    65       DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    66       eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    67       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    68         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    69         for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
    70           if ((*MolOtherWalker)->ActiveFlag) {
    71             DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    72             for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
    73               DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
    74               if ((*iter)->getId() < (*runner)->getId()){
    75                 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
    76                   if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
    77                     distance = (*iter)->node->PeriodicDistance(*(*runner)->node,  domain);
    78                     //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
    79                     outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    80                   }
     66  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){
     67    DoLog(2) && (Log()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     68    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     69      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     70      for (std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules.end(); MolOtherWalker++){
     71        DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
     72        for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
     73          DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
     74          if ((*iter)->getId() < (*runner)->getId()){
     75            for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
     76              if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
     77                distance = domain.periodicDistance(*(*iter)->node,*(*runner)->node);
     78                //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
     79                outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    8180              }
    82             }
    8381          }
    8482        }
     
    9694 * \return Map of doubles with values the pair of the two atoms.
    9795 */
    98 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] )
     96PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const int ranges[NDIM] )
    9997{
    10098  Info FunctionInfo(__func__);
     
    108106  Vector periodicOtherX;
    109107
    110   if (molecules->ListOfMolecules.empty()) {
     108  if (molecules.empty()) {
    111109    DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
    112110    return outmap;
    113111  }
    114   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     112  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
    115113    (*MolWalker)->doCountAtoms();
    116114
     
    133131
    134132  outmap = new PairCorrelationMap;
    135   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){
    136     if ((*MolWalker)->ActiveFlag) {
    137       double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
    138       double * FullInverseMatrix = InverseMatrix(FullMatrix);
    139       DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    140       eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    141       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    142         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    143         periodicX = *(*iter)->node;
    144         periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    145         // go through every range in xyz and get distance
    146         for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    147           for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    148             for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    149               checkX = Vector(n[0], n[1], n[2]) + periodicX;
    150               checkX.MatrixMultiplication(FullMatrix);
    151               for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
    152                 if ((*MolOtherWalker)->ActiveFlag) {
    153                   DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    154                   for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
    155                     DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
    156                     if ((*iter)->getId() < (*runner)->getId()){
    157                       for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
    158                         if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
    159                           periodicOtherX = *(*runner)->node;
    160                           periodicOtherX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    161                           // go through every range in xyz and get distance
    162                           for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++)
    163                             for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++)
    164                               for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) {
    165                                 checkOtherX = Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX;
    166                                 checkOtherX.MatrixMultiplication(FullMatrix);
    167                                 distance = checkX.distance(checkOtherX);
    168                                 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
    169                                 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    170                               }
    171                         }
     133  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){
     134    Matrix FullMatrix = World::getInstance().getDomain().getM();
     135    Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
     136    DoLog(2) && (Log()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     137    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     138      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     139      periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
     140      // go through every range in xyz and get distance
     141      for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     142        for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     143          for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     144            checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
     145            for (std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules.end(); MolOtherWalker++){
     146                DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
     147                for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
     148                  DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
     149                  if ((*iter)->getId() < (*runner)->getId()){
     150                    for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
     151                      if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
     152                        periodicOtherX = FullInverseMatrix * (*(*runner)->node); // x now in [0,1)^3
     153                        // go through every range in xyz and get distance
     154                        for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++)
     155                          for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++)
     156                            for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) {
     157                              checkOtherX = FullMatrix * (Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX);
     158                              distance = checkX.distance(checkOtherX);
     159                              //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
     160                              outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
     161                            }
     162                      }
    172163                    }
    173164                  }
    174165                }
    175               }
    176             }
    177166      }
    178       delete[](FullMatrix);
    179       delete[](FullInverseMatrix);
    180167    }
    181168  }
     
    190177 * \return Map of dobules with values as pairs of atom and the vector
    191178 */
    192 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point )
     179CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point )
    193180{
    194181  Info FunctionInfo(__func__);
    195182  CorrelationToPointMap *outmap = NULL;
    196183  double distance = 0.;
    197   double *cell_size = World::getInstance().getDomain();
    198 
    199   if (molecules->ListOfMolecules.empty()) {
     184  Box &domain = World::getInstance().getDomain();
     185
     186  if (molecules.empty()) {
    200187    DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
    201188    return outmap;
    202189  }
    203   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     190  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
    204191    (*MolWalker)->doCountAtoms();
    205192  outmap = new CorrelationToPointMap;
    206   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    207     if ((*MolWalker)->ActiveFlag) {
    208       DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    209       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    210         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    211         for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    212           if ((*type == NULL) || ((*iter)->type == *type)) {
    213             distance = (*iter)->node->PeriodicDistance(*point, cell_size);
    214             DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    215             outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
    216           }
    217       }
    218     }
     193  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
     194    DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     195    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     196      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     197      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     198        if ((*type == NULL) || ((*iter)->type == *type)) {
     199          distance = domain.periodicDistance(*(*iter)->node,*point);
     200          DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
     201          outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
     202        }
     203    }
     204  }
    219205
    220206  return outmap;
     
    228214 * \return Map of dobules with values as pairs of atom and the vector
    229215 */
    230 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] )
     216CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] )
    231217{
    232218  Info FunctionInfo(__func__);
     
    237223  Vector checkX;
    238224
    239   if (molecules->ListOfMolecules.empty()) {
     225  if (molecules.empty()) {
    240226    DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
    241227    return outmap;
    242228  }
    243   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     229  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
    244230    (*MolWalker)->doCountAtoms();
    245231  outmap = new CorrelationToPointMap;
    246   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    247     if ((*MolWalker)->ActiveFlag) {
    248       double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
    249       double * FullInverseMatrix = InverseMatrix(FullMatrix);
    250       DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    251       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    252         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    253         for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    254           if ((*type == NULL) || ((*iter)->type == *type)) {
    255             periodicX = *(*iter)->node;
    256             periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    257             // go through every range in xyz and get distance
    258             for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    259               for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    260                 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    261                   checkX = Vector(n[0], n[1], n[2]) + periodicX;
    262                   checkX.MatrixMultiplication(FullMatrix);
    263                   distance = checkX.distance(*point);
    264                   DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    265                   outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) );
    266                 }
    267           }
    268       }
    269       delete[](FullMatrix);
    270       delete[](FullInverseMatrix);
    271     }
     232  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
     233    Matrix FullMatrix = World::getInstance().getDomain().getM();
     234    Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
     235    DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     236    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     237      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     238      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     239        if ((*type == NULL) || ((*iter)->type == *type)) {
     240          periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
     241          // go through every range in xyz and get distance
     242          for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     243            for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     244              for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     245                checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
     246                distance = checkX.distance(*point);
     247                DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
     248                outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) );
     249              }
     250        }
     251    }
     252  }
    272253
    273254  return outmap;
     
    281262 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    282263 */
    283 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
     264CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
    284265{
    285266  Info FunctionInfo(__func__);
     
    289270  Vector centroid;
    290271
    291   if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
     272  if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) {
    292273    DoeLog(1) && (eLog()<< Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
    293274    return outmap;
    294275  }
    295   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     276  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
    296277    (*MolWalker)->doCountAtoms();
    297278  outmap = new CorrelationToSurfaceMap;
    298   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    299     if ((*MolWalker)->ActiveFlag) {
    300       DoLog(1) && (Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl);
    301       if ((*MolWalker)->empty())
    302         DoLog(1) && (1) && (Log() << Verbose(1) << "\t is empty." << endl);
    303       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    304         DoLog(1) && (Log() << Verbose(1) << "\tCurrent atom is " << *(*iter) << "." << endl);
    305         for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    306           if ((*type == NULL) || ((*iter)->type == *type)) {
    307             TriangleIntersectionList Intersections((*iter)->node,Surface,LC);
    308             distance = Intersections.GetSmallestDistance();
    309             triangle = Intersections.GetClosestTriangle();
    310             outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
    311           }
    312       }
    313     } else {
    314       DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl);
    315     }
     279  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
     280    DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << (*MolWalker)->name << "." << endl);
     281    if ((*MolWalker)->empty())
     282      DoLog(2) && (2) && (Log() << Verbose(2) << "\t is empty." << endl);
     283    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     284      DoLog(3) && (Log() << Verbose(3) << "\tCurrent atom is " << *(*iter) << "." << endl);
     285      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     286        if ((*type == NULL) || ((*iter)->type == *type)) {
     287          TriangleIntersectionList Intersections((*iter)->node,Surface,LC);
     288          distance = Intersections.GetSmallestDistance();
     289          triangle = Intersections.GetClosestTriangle();
     290          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
     291        }
     292    }
     293  }
    316294
    317295  return outmap;
     
    330308 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    331309 */
    332 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
     310CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
    333311{
    334312  Info FunctionInfo(__func__);
     
    341319  Vector checkX;
    342320
    343   if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
     321  if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) {
    344322    DoLog(1) && (Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
    345323    return outmap;
    346324  }
    347   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     325  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++)
    348326    (*MolWalker)->doCountAtoms();
    349327  outmap = new CorrelationToSurfaceMap;
    350328  double ShortestDistance = 0.;
    351329  BoundaryTriangleSet *ShortestTriangle = NULL;
    352   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    353     if ((*MolWalker)->ActiveFlag) {
    354       double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
    355       double * FullInverseMatrix = InverseMatrix(FullMatrix);
    356       DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    357       for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    358         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
    359         for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
    360           if ((*type == NULL) || ((*iter)->type == *type)) {
    361             periodicX = *(*iter)->node;
    362             periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    363             // go through every range in xyz and get distance
    364             ShortestDistance = -1.;
    365             for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    366               for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    367                 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    368                   checkX = Vector(n[0], n[1], n[2]) + periodicX;
    369                   checkX.MatrixMultiplication(FullMatrix);
    370                   TriangleIntersectionList Intersections(&checkX,Surface,LC);
    371                   distance = Intersections.GetSmallestDistance();
    372                   triangle = Intersections.GetClosestTriangle();
    373                   if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
    374                     ShortestDistance = distance;
    375                     ShortestTriangle = triangle;
    376                   }
     330  for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) {
     331    Matrix FullMatrix = World::getInstance().getDomain().getM();
     332    Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();
     333    DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     334    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     335      DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     336      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     337        if ((*type == NULL) || ((*iter)->type == *type)) {
     338          periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
     339          // go through every range in xyz and get distance
     340          ShortestDistance = -1.;
     341          for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     342            for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     343              for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     344                checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX);
     345                TriangleIntersectionList Intersections(&checkX,Surface,LC);
     346                distance = Intersections.GetSmallestDistance();
     347                triangle = Intersections.GetClosestTriangle();
     348                if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
     349                  ShortestDistance = distance;
     350                  ShortestTriangle = triangle;
    377351                }
    378             // insert
    379             outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) );
    380             //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
    381           }
    382       }
    383       delete[](FullMatrix);
    384       delete[](FullInverseMatrix);
    385     }
     352              }
     353          // insert
     354          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) );
     355          //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
     356        }
     357    }
     358  }
    386359
    387360  return outmap;
  • src/analysis_correlation.hpp

    r06f4ef6 rb6da28  
    2222// STL headers
    2323#include <map>
     24#include <vector>
    2425
    2526#include "defs.hpp"
    2627
    2728#include "atom.hpp"
     29#include "verbose.hpp"
    2830
    2931/****************************************** forward declarations *****************************/
     
    3234class element;
    3335class LinkedCell;
    34 class MoleculeListClass;
    3536class Tesselation;
    3637class Vector;
     
    4546/********************************************** declarations *******************************/
    4647
    47 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements);
    48 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point );
    49 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );
    50 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] );
    51 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] );
    52 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
     48PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements);
     49CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point );
     50CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );
     51PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const int ranges[NDIM] );
     52CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] );
     53CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
    5354int GetBin ( const double value, const double BinWidth, const double BinStart );
    5455void OutputCorrelation( ofstream * const file, const BinPairMap * const map );
  • src/analyzer.cpp

    r06f4ef6 rb6da28  
    1414#include "datacreator.hpp"
    1515#include "helpers.hpp"
    16 #include "memoryallocator.hpp"
    1716#include "parser.hpp"
    1817#include "periodentafel.hpp"
     18#include "verbose.hpp"
    1919
    2020// include config.h
  • src/atom.cpp

    r06f4ef6 rb6da28  
    1212#include "element.hpp"
    1313#include "lists.hpp"
    14 #include "memoryallocator.hpp"
    1514#include "parser.hpp"
    1615#include "vector.hpp"
    1716#include "World.hpp"
    1817#include "molecule.hpp"
     18#include "Shapes/Shape.hpp"
     19
     20#include <iomanip>
     21#include <iostream>
    1922
    2023/************************************* Functions for class atom *************************************/
     
    107110};
    108111
     112bool atom::isFather(const atom *ptr){
     113  return ptr==father;
     114}
     115
    109116/** Checks whether atom is within the given box.
    110117 * \param offset offset to box origin
     
    112119 * \return true - is inside, false - is not
    113120 */
    114 bool atom::IsInParallelepiped(const Vector offset, const double *parallelepiped) const
    115 {
    116   return (node->IsInParallelepiped(offset, parallelepiped));
     121bool atom::IsInShape(const Shape& shape) const
     122{
     123  return shape.isInside(*node);
    117124};
    118125
     
    159166  * \return true - \a *out present, false - \a *out is NULL
    160167 */
    161 bool atom::OutputArrayIndexed(ofstream * const out, const int *ElementNo, int *AtomNo, const char *comment) const
     168bool atom::OutputArrayIndexed(ostream * const out,const enumeration<const element*> &elementLookup, int *AtomNo, const char *comment) const
    162169{
    163170  AtomNo[type->Z]++;  // increment number
    164171  if (out != NULL) {
    165     *out << "Ion_Type" << ElementNo[type->Z] << "_" << AtomNo[type->Z] << "\t"  << fixed << setprecision(9) << showpoint;
     172    cout << "Looking for atom with element " << *type << endl;
     173    ASSERT(elementLookup.there.find(type)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration");
     174    *out << "Ion_Type" << elementLookup.there.find(type)->second << "_" << AtomNo[type->Z] << "\t"  << fixed << setprecision(9) << showpoint;
    166175    *out << x[0] << "\t" << x[1] << "\t" << x[2];
    167176    *out << "\t" << FixedIon;
     
    236245 * \param *AtomNo pointer to atom counter that is increased by one
    237246 */
    238 void atom::OutputMPQCLine(ofstream * const out, const Vector *center, int *AtomNo = NULL) const
     247void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const
    239248{
    240249  *out << "\t\t" << type->symbol << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl;
     
    315324}
    316325
    317 atomId_t atom::getId() {
     326atomId_t atom::getId() const {
    318327  return id;
    319328}
     
    328337}
    329338
     339molecule* atom::getMolecule(){
     340  return mol;
     341}
     342
    330343void atom::removeFromMolecule(){
    331344  if(mol){
  • src/atom.hpp

    r06f4ef6 rb6da28  
    1818#endif
    1919
    20 #include <iostream>
     20#include <iosfwd>
    2121#include <list>
    2222#include <vector>
     
    3535class World;
    3636class molecule;
     37class Shape;
    3738
    3839/********************************************** declarations *******************************/
     
    5152
    5253  bool OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const;
    53   bool OutputArrayIndexed(ofstream * const out, const int *ElementNo, int *AtomNo, const char *comment = NULL) const;
     54  bool OutputArrayIndexed(ostream * const out,const enumeration<const element*>&, int *AtomNo, const char *comment = NULL) const;
    5455  bool OutputXYZLine(ofstream *out) const;
    5556  bool OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const;
    5657  bool OutputTrajectoryXYZ(ofstream * const out, const int step) const;
    57   void OutputMPQCLine(ofstream * const out, const Vector *center, int *AtomNo) const;
     58  void OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo) const;
    5859
    5960  void InitComponentNr();
    6061
    6162  void EqualsFather ( const atom *ptr, const atom **res ) const;
     63  bool isFather(const atom *ptr);
    6264  void CorrectFather();
    6365  atom *GetTrueFather();
     
    6668  double DistanceToVector(const Vector &origin) const;
    6769  double DistanceSquaredToVector(const Vector &origin) const;
    68   bool IsInParallelepiped(const Vector offset, const double *parallelepiped) const;
     70  bool IsInShape(const Shape&) const;
    6971
    7072  // getter and setter
     
    7981  void setWorld(World*);
    8082
    81   virtual atomId_t getId();
     83  virtual atomId_t getId() const;
    8284  virtual bool changeId(atomId_t newId);
    8385
     
    8991
    9092   void setMolecule(molecule*);
     93   molecule* getMolecule();
    9194   void removeFromMolecule();
    9295
  • src/atom_graphnodeinfo.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "atom_graphnodeinfo.hpp"
    11 #include "memoryallocator.hpp"
    1211
    1312/** Constructor of class GraphNodeInfo.
    1413 */
    15 GraphNodeInfo::GraphNodeInfo() : GraphNr(-1), ComponentNr(NULL), LowpointNr(-1), SeparationVertex(false), IsCyclic(false), Ancestor(NULL) {};
     14GraphNodeInfo::GraphNodeInfo() : GraphNr(-1), ComponentNr(0), LowpointNr(-1), SeparationVertex(false), IsCyclic(false), Ancestor(0) {};
    1615
    1716/** Destructor of class GraphNodeInfo.
  • src/atom_particleinfo.cpp

    r06f4ef6 rb6da28  
    99
    1010#include "atom_particleinfo.hpp"
    11 #include "memoryallocator.hpp"
     11
     12#include <iostream>
    1213
    1314/** Constructor of ParticleInfo.
  • src/atom_particleinfo.hpp

    r06f4ef6 rb6da28  
    1818#endif
    1919
    20 #include <iostream>
     20#include <iosfwd>
     21#include <string>
    2122
    2223/****************************************** forward declarations *****************************/
  • src/atom_trajectoryparticle.cpp

    r06f4ef6 rb6da28  
    1515#include "log.hpp"
    1616#include "parser.hpp"
     17#include "ThermoStatContainer.hpp"
    1718#include "verbose.hpp"
    1819
     
    105106 * \param *Force matrix with forces
    106107 */
    107 void TrajectoryParticle::VelocityVerletUpdate(int NextStep, config *configuration, ForceMatrix *Force)
     108void TrajectoryParticle::VelocityVerletUpdate(int NextStep, config *configuration, ForceMatrix *Force, const size_t offset)
    108109{
    109110  //a = configuration.Deltat*0.5/walker->type->mass;        // (F+F_old)/2m = a and thus: v = (F+F_old)/2m * t = (F + F_old) * a
    110111  for (int d=0; d<NDIM; d++) {
    111     Trajectory.F.at(NextStep)[d] = -Force->Matrix[0][nr][d+5]*(configuration->GetIsAngstroem() ? AtomicLengthToAngstroem : 1.);
     112    Trajectory.F.at(NextStep)[d] = -Force->Matrix[0][nr][d+offset]*(configuration->GetIsAngstroem() ? AtomicLengthToAngstroem : 1.);
    112113    Trajectory.R.at(NextStep)[d] = Trajectory.R.at(NextStep-1)[d];
    113114    Trajectory.R.at(NextStep)[d] += configuration->Deltat*(Trajectory.U.at(NextStep-1)[d]);     // s(t) = s(0) + v * deltat + 1/2 a * deltat^2
     
    197198void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration)
    198199{
    199   double sigma  = sqrt(configuration->TargetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)
     200  double sigma  = sqrt(configuration->Thermostats->TargetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)
    200201  Vector &U = Trajectory.U.at(Step);
    201202  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    202203    // throw a dice to determine whether it gets hit by a heat bath particle
    203     if (((((rand()/(double)RAND_MAX))*configuration->TempFrequency) < 1.)) {
     204    if (((((rand()/(double)RAND_MAX))*configuration->Thermostats->TempFrequency) < 1.)) {
    204205      DoLog(3) && (Log() << Verbose(3) << "Particle " << *this << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> ");
    205206      // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis
     
    225226  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    226227    for (int d=0; d<NDIM; d++) {
    227       U[d] *= sqrt(1+(configuration->Deltat/configuration->TempFrequency)*(ScaleTempFactor-1));
     228      U[d] *= sqrt(1+(configuration->Deltat/configuration->Thermostats->TempFrequency)*(ScaleTempFactor-1));
    228229      *ekin += 0.5*type->mass * U[d]*U[d];
    229230    }
     
    255256  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    256257    for (int d=0; d<NDIM; d++) {
    257         U[d] += configuration->Deltat/type->mass * (configuration->alpha * (U[d] * type->mass));
     258        U[d] += configuration->Deltat/type->mass * (configuration->Thermostats->alpha * (U[d] * type->mass));
    258259        *ekin += (0.5*type->mass) * U[d]*U[d];
    259260      }
  • src/atom_trajectoryparticle.hpp

    r06f4ef6 rb6da28  
    2020#include <fstream>
    2121
     22#include <gsl/gsl_inline.h>
    2223#include <gsl/gsl_randist.h>
    2324
     
    5051  void ResizeTrajectory(int MaxSteps);
    5152  void CopyStepOnStep(int dest, int src);
    52   void VelocityVerletUpdate(int MDSteps, config *configuration, ForceMatrix *Force);
     53  void VelocityVerletUpdate(int MDSteps, config *configuration, ForceMatrix *Force, const size_t offset);
    5354  void SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) const;
    5455
  • src/bond.cpp

    r06f4ef6 rb6da28  
    77#include "Helpers/MemDebug.hpp"
    88
     9#include "verbose.hpp"
    910#include "atom.hpp"
    1011#include "bond.hpp"
  • src/bondgraph.cpp

    r06f4ef6 rb6da28  
    1515#include "element.hpp"
    1616#include "info.hpp"
     17#include "verbose.hpp"
    1718#include "log.hpp"
    1819#include "molecule.hpp"
  • src/bondgraph.hpp

    r06f4ef6 rb6da28  
    1818#endif
    1919
    20 #include <iostream>
     20#include <iosfwd>
    2121
    2222/*********************************************** defines ***********************************/
  • src/boundary.cpp

    r06f4ef6 rb6da28  
    1515#include "info.hpp"
    1616#include "linkedcell.hpp"
     17#include "verbose.hpp"
    1718#include "log.hpp"
    18 #include "memoryallocator.hpp"
    1919#include "molecule.hpp"
    2020#include "tesselation.hpp"
     
    2222#include "World.hpp"
    2323#include "Plane.hpp"
     24#include "Matrix.hpp"
     25#include "Box.hpp"
     26
     27#include <iostream>
     28#include <iomanip>
    2429
    2530#include<gsl/gsl_poly.h>
     
    296301 * \param *out output stream for debugging
    297302 * \param *mol molecule structure with Atom's and Bond's.
     303 * \param *BoundaryPts set of boundary points to use or NULL
    298304 * \param *TesselStruct Tesselation filled with points, lines and triangles on boundary on return
    299305 * \param *LCList atoms in LinkedCell list
     
    301307 * \return *TesselStruct is filled with convex boundary and tesselation is stored under \a *filename.
    302308 */
    303 void FindConvexBorder(const molecule* mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename)
     309void FindConvexBorder(const molecule* mol, Boundaries *BoundaryPts, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename)
    304310{
    305311        Info FunctionInfo(__func__);
     
    312318
    313319  // 1. Find all points on the boundary
    314   if (BoundaryPoints == NULL) {
    315       BoundaryFreeFlag = true;
    316       BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
     320  if (BoundaryPts == NULL) {
     321    BoundaryFreeFlag = true;
     322    BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
    317323  } else {
    318       DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl);
     324    BoundaryPoints = BoundaryPts;
     325    DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl);
    319326  }
    320327
    321328// printing all inserted for debugging
    322   for (int axis=0; axis < NDIM; axis++)
    323     {
    324       DoLog(1) && (Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl);
    325       int i=0;
    326       for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
    327         if (runner != BoundaryPoints[axis].begin())
    328           DoLog(0) && (Log() << Verbose(0) << ", " << i << ": " << *runner->second.second);
    329         else
    330           DoLog(0) && (Log() << Verbose(0) << i << ": " << *runner->second.second);
    331         i++;
    332       }
    333       DoLog(0) && (Log() << Verbose(0) << endl);
    334     }
     329  for (int axis=0; axis < NDIM; axis++) {
     330    DoLog(1) && (Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl);
     331    int i=0;
     332    for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
     333      if (runner != BoundaryPoints[axis].begin())
     334        DoLog(0) && (Log() << Verbose(0) << ", " << i << ": " << *runner->second.second);
     335      else
     336        DoLog(0) && (Log() << Verbose(0) << i << ": " << *runner->second.second);
     337      i++;
     338    }
     339    DoLog(0) && (Log() << Verbose(0) << endl);
     340  }
    335341
    336342  // 2. fill the boundary point list
     
    338344    for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++)
    339345        if (!TesselStruct->AddBoundaryPoint(runner->second.second, 0))
    340           DoeLog(2) && (eLog()<< Verbose(2) << "Point " << *(runner->second.second) << " is already present!" << endl);
     346          DoLog(2) && (Log()<< Verbose(2) << "Point " << *(runner->second.second) << " is already present." << endl);
    341347
    342348  DoLog(0) && (Log() << Verbose(0) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl);
     
    672678
    673679  IsAngstroem = configuration->GetIsAngstroem();
     680  BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
    674681  GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem);
    675   BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
    676682  LinkedCell *LCList = new LinkedCell(mol, 10.);
    677   FindConvexBorder(mol, TesselStruct, (const LinkedCell *&)LCList, NULL);
     683  FindConvexBorder(mol, BoundaryPoints, TesselStruct, (const LinkedCell *&)LCList, NULL);
    678684  delete (LCList);
     685  delete[] BoundaryPoints;
    679686
    680687
     
    684691  else
    685692    clustervolume = ClusterVolume;
     693
     694  delete TesselStruct;
    686695
    687696  for (int i = 0; i < NDIM; i++)
     
    736745    mol->CenterInBox();
    737746  }
     747  delete GreatestDiameter;
    738748  // update Box of atoms by boundary
    739749  mol->SetBoxDimension(&BoxLengths);
     
    764774  int N[NDIM];
    765775  int n[NDIM];
    766   double *M =  ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
    767   double Rotations[NDIM*NDIM];
    768   double *MInverse = InverseMatrix(M);
     776  const Matrix &M = World::getInstance().getDomain().getM();
     777  Matrix Rotations;
     778  const Matrix &MInverse = World::getInstance().getDomain().getMinv();
    769779  Vector AtomTranslations;
    770780  Vector FillerTranslations;
     
    799809
    800810  // calculate filler grid in [0,1]^3
    801   FillerDistance = Vector(distance[0], distance[1], distance[2]);
    802   FillerDistance.InverseMatrixMultiplication(M);
     811  FillerDistance = MInverse * Vector(distance[0], distance[1], distance[2]);
    803812  for(int i=0;i<NDIM;i++)
    804813    N[i] = (int) ceil(1./FillerDistance[i]);
     
    813822      for (n[2] = 0; n[2] < N[2]; n[2]++) {
    814823        // calculate position of current grid vector in untransformed box
    815         CurrentPosition = Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]);
    816         CurrentPosition.MatrixMultiplication(M);
     824        CurrentPosition = M * Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]);
    817825        // create molecule random translation vector ...
    818826        for (int i=0;i<NDIM;i++)
     
    835843            }
    836844
    837             Rotations[0] =   cos(phi[0])            *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2]));
    838             Rotations[3] =   sin(phi[0])            *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2]));
    839             Rotations[6] =               cos(phi[1])*sin(phi[2])                                     ;
    840             Rotations[1] = - sin(phi[0])*cos(phi[1])                                                ;
    841             Rotations[4] =   cos(phi[0])*cos(phi[1])                                                ;
    842             Rotations[7] =               sin(phi[1])                                                ;
    843             Rotations[3] = - cos(phi[0])            *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2]));
    844             Rotations[5] = - sin(phi[0])            *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2]));
    845             Rotations[8] =               cos(phi[1])*cos(phi[2])                                     ;
     845            Rotations.set(0,0,  cos(phi[0])            *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2])));
     846            Rotations.set(0,1,  sin(phi[0])            *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2])));
     847            Rotations.set(0,2,              cos(phi[1])*sin(phi[2])                                        );
     848            Rotations.set(1,0, -sin(phi[0])*cos(phi[1])                                                    );
     849            Rotations.set(1,1,  cos(phi[0])*cos(phi[1])                                                    );
     850            Rotations.set(1,2,              sin(phi[1])                                                    );
     851            Rotations.set(2,0, -cos(phi[0])            *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2])));
     852            Rotations.set(2,1, -sin(phi[0])            *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2])));
     853            Rotations.set(2,2,              cos(phi[1])*cos(phi[2])                                        );
    846854          }
    847855
     
    849857          Inserter = (*iter)->x;
    850858          if (DoRandomRotation)
    851             Inserter.MatrixMultiplication(Rotations);
     859            Inserter *= Rotations;
    852860          Inserter += AtomTranslations + FillerTranslations + CurrentPosition;
    853861
    854862          // check whether inserter is inside box
    855           Inserter.MatrixMultiplication(MInverse);
     863          Inserter *= MInverse;
    856864          FillIt = true;
    857865          for (int i=0;i<NDIM;i++)
    858866            FillIt = FillIt && (Inserter[i] >= -MYEPSILON) && ((Inserter[i]-1.) <= MYEPSILON);
    859           Inserter.MatrixMultiplication(M);
     867          Inserter *= M;
    860868
    861869          // Check whether point is in- or outside
     
    892900            }
    893901      }
    894   delete[](M);
    895   delete[](MInverse);
     902  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
     903    delete LCList[*ListRunner];
     904    delete TesselStruct[(*ListRunner)];
     905  }
    896906
    897907  return Filling;
     
    10041014//  // Purges surplus triangles.
    10051015//  TesselStruct->RemoveDegeneratedTriangles();
    1006 
    1007   // check envelope for consistency
    1008   status = CheckListOfBaselines(TesselStruct);
     1016//
     1017//  // check envelope for consistency
     1018//  status = CheckListOfBaselines(TesselStruct);
    10091019
    10101020  cout << "before correction" << endl;
  • src/boundary.hpp

    r06f4ef6 rb6da28  
    1212
    1313#include <fstream>
    14 #include <iostream>
     14#include <iosfwd>
    1515
    1616// STL headers
     
    5050double ConvexizeNonconvexEnvelope(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename);
    5151molecule * 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);
    52 void FindConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename);
     52void FindConvexBorder(const molecule* const mol, Boundaries *BoundaryPts, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename);
    5353Vector* FindEmbeddingHole(MoleculeListClass *mols, molecule *srcmol);
    5454void FindNextSuitablePoint(class BoundaryTriangleSet *BaseTriangle, class BoundaryLineSet *BaseLine, atom*& OptCandidate, Vector *OptCandidateCenter, double *ShortestAngle, const double RADIUS, LinkedCell *LC);
  • src/builder.cpp

    r06f4ef6 rb6da28  
    11/** \file builder.cpp
    22 *
    3  * By stating absolute positions or binding angles and distances atomic positions of a molecule can be constructed.
    4  * The output is the complete configuration file for PCP for direct use.
    5  * Features:
    6  * -# Atomic data is retrieved from a file, if not found requested and stored there for later re-use
    7  * -# step-by-step construction of the molecule beginning either at a centre of with a certain atom
     3 *  date: Jan 1, 2007
     4 *  author: heber
    85 *
    96 */
    107
    11 /*! \mainpage Molecuilder - a molecular set builder
     8/*! \mainpage MoleCuilder - a molecular set builder
    129 *
    13  * This introductory shall briefly make aquainted with the program, helping in installing and a first run.
     10 * This introductory shall briefly make acquainted with the program, helping in installing and a first run.
    1411 *
    1512 * \section about About the Program
    1613 *
    17  *  Molecuilder is a short program, written in C++, that enables the construction of a coordinate set for the
    18  *  atoms making up an molecule by the successive statement of binding angles and distances and referencing to
    19  *  already constructed atoms.
     14 *  MoleCuilder is a program, written entirely in C++, that enables the construction of a coordinate set for the
     15 *  atoms making up an molecule. It allows for both building of simple molecules by adding atom-wise giving bond
     16 *  angles and distances or absolute coordinates, but also using them as templates. Regions can be specified and
     17 *  ordered to be filled with a molecule in a certain manner. Greater conglomerations of molecules can be tesselated
     18 *  and recognized as a region themselves to be subsequently surrounded by other (surface solvated) molecules.
     19 *  In the end, MoleCuilder allows the construction of arbitrary nano structures, whether they be crystalline or
     20 *  amorphic in nature.
    2021 *
    21  *  A configuration file may be written that is compatible to the format used by PCP - a parallel Car-Parrinello
    22  *  molecular dynamics implementation.
    2322 *
    2423 * \section install Installation
     
    3231 *  -# make clean uninstall: deletes .o-files and removes executable from the given binary directory\n
    3332 *  -# make doxygen-doc: Creates these html pages out of the documented source
     33 *  -# make check: Runs an extensive set of unit tests and a testsuite which also gives a good overview on the set of
     34 *                 functions.
    3435 *
    3536 * \section run Running
     
    3738 *  The program can be executed by running: ./molecuilder
    3839 *
    39  *  Note, that it uses a database, called "elements.db", in the executable's directory. If the file is not found,
    40  *  it is created and any given data on elements of the periodic table will be stored therein and re-used on
    41  *  later re-execution.
     40 *  MoleCuilder has three interfaces at your disposal:
     41 *  -# Textmenu: A simple interactive console-based menu, where awaits your choices and inputs in order to set atoms
     42 *               as you like
     43 *  -# CommandLineUI: Every command can also be chained up as a sequence of actions on the command line to be executed
     44 *               with any user interaction.
     45 *  -# GraphicalUI: A graphical user interface that also display the molecular structure being built and lots of other
     46 *               informations to ease the construction of bigger geometries.
    4247 *
    43  * \section ref References
    44  *
    45  *  For the special configuration file format, see the documentation of pcp.
     48 *  The supported output formats right now are:
     49 *  -# mpqc: Configuration files of the Massively Parallel Quantum Chemistry package (Sandia labs)
     50 *  -# pcp: Configuration files of the Parallel Car-Parrinello program (Institute for Numerical Simulation)
     51 *  -# tremolo: Configuration files of TREMOLO (Institute for Numerical Simulation)
     52 *  -# xyz: the most basic format for the 3d arrangement of atoms consisting of a list of element and 3 coordinates.
    4653 *
    4754 */
     
    4956#include "Helpers/MemDebug.hpp"
    5057
    51 #include <boost/bind.hpp>
    52 
    53 using namespace std;
    54 
    55 #include <cstring>
    56 #include <cstdlib>
    57 
    58 #include "analysis_bonds.hpp"
    59 #include "analysis_correlation.hpp"
    60 #include "atom.hpp"
    61 #include "bond.hpp"
    6258#include "bondgraph.hpp"
    63 #include "boundary.hpp"
    6459#include "CommandLineParser.hpp"
    6560#include "config.hpp"
    66 #include "element.hpp"
    67 #include "ellipsoid.hpp"
    68 #include "helpers.hpp"
    69 #include "leastsquaremin.hpp"
    70 #include "linkedcell.hpp"
    7161#include "log.hpp"
    72 #include "memoryusageobserver.hpp"
    7362#include "molecule.hpp"
    7463#include "periodentafel.hpp"
     64#include "tesselationhelpers.hpp"
     65#include "UIElements/UIFactory.hpp"
     66#include "UIElements/TextUI/TextUIFactory.hpp"
     67#include "UIElements/CommandLineUI/CommandLineUIFactory.hpp"
     68#ifdef USE_GUI_QT
     69#include "UIElements/QT4/QTUIFactory.hpp"
     70#endif
     71#include "UIElements/MainWindow.hpp"
     72#include "UIElements/Dialog.hpp"
     73#include "Menu/ActionMenuItem.hpp"
     74#include "verbose.hpp"
     75#include "World.hpp"
     76
     77#include "Actions/ActionRegistry.hpp"
     78#include "Actions/ActionHistory.hpp"
     79#include "Actions/MapOfActions.hpp"
     80
     81#include "Parser/ChangeTracker.hpp"
     82#include "Parser/FormatParserStorage.hpp"
     83
    7584#include "UIElements/UIFactory.hpp"
    7685#include "UIElements/TextUI/TextUIFactory.hpp"
     
    7887#include "UIElements/MainWindow.hpp"
    7988#include "UIElements/Dialog.hpp"
    80 #include "Menu/ActionMenuItem.hpp"
    81 #include "Actions/ActionRegistry.hpp"
    82 #include "Actions/ActionHistory.hpp"
    83 #include "Actions/MapOfActions.hpp"
    84 #include "Actions/MethodAction.hpp"
    85 #include "Actions/MoleculeAction/ChangeNameAction.hpp"
    86 #include "World.hpp"
     89
    8790#include "version.h"
    88 #include "World.hpp"
    8991
    90 
    91 /********************************************* Subsubmenu routine ************************************/
    92 #if 0
    93 /** Submenu for adding atoms to the molecule.
    94  * \param *periode periodentafel
    95  * \param *molecule molecules with atoms
    96  */
    97 static void AddAtoms(periodentafel *periode, molecule *mol)
    98 {
    99   atom *first, *second, *third, *fourth;
    100   Vector **atoms;
    101   Vector x,y,z,n;  // coordinates for absolute point in cell volume
    102   double a,b,c;
    103   char choice;  // menu choice char
    104   bool valid;
    105 
    106   cout << Verbose(0) << "===========ADD ATOM============================" << endl;
    107   cout << Verbose(0) << " a - state absolute coordinates of atom" << endl;
    108   cout << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;
    109   cout << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;
    110   cout << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;
    111   cout << Verbose(0) << " e - least square distance position to a set of atoms" << endl;
    112   cout << Verbose(0) << "all else - go back" << endl;
    113   cout << Verbose(0) << "===============================================" << endl;
    114   cout << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;
    115   cout << Verbose(0) << "INPUT: ";
    116   cin >> choice;
    117 
    118   switch (choice) {
    119     default:
    120       DoeLog(2) && (eLog()<< Verbose(2) << "Not a valid choice." << endl);
    121       break;
    122       case 'a': // absolute coordinates of atom
    123         cout << Verbose(0) << "Enter absolute coordinates." << endl;
    124         first = new atom;
    125         first->x.AskPosition(World::getInstance().getDomain(), false);
    126         first->type = periode->AskElement();  // give type
    127         mol->AddAtom(first);  // add to molecule
    128         break;
    129 
    130       case 'b': // relative coordinates of atom wrt to reference point
    131         first = new atom;
    132         valid = true;
    133         do {
    134           if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl);
    135           cout << Verbose(0) << "Enter reference coordinates." << endl;
    136           x.AskPosition(World::getInstance().getDomain(), true);
    137           cout << Verbose(0) << "Enter relative coordinates." << endl;
    138           first->x.AskPosition(World::getInstance().getDomain(), false);
    139           first->x.AddVector((const Vector *)&x);
    140           cout << Verbose(0) << "\n";
    141         } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    142         first->type = periode->AskElement();  // give type
    143         mol->AddAtom(first);  // add to molecule
    144         break;
    145 
    146       case 'c': // relative coordinates of atom wrt to already placed atom
    147         first = new atom;
    148         valid = true;
    149         do {
    150           if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl);
    151           second = mol->AskAtom("Enter atom number: ");
    152           DoLog(0) && (Log() << Verbose(0) << "Enter relative coordinates." << endl);
    153           first->x.AskPosition(World::getInstance().getDomain(), false);
    154           for (int i=NDIM;i--;) {
    155             first->x.x[i] += second->x.x[i];
    156           }
    157         } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    158         first->type = periode->AskElement();  // give type
    159         mol->AddAtom(first);  // add to molecule
    160         break;
    161 
    162     case 'd': // two atoms, two angles and a distance
    163         first = new atom;
    164         valid = true;
    165         do {
    166           if (!valid) {
    167             DoeLog(2) && (eLog()<< Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl);
    168           }
    169           cout << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;
    170           second = mol->AskAtom("Enter central atom: ");
    171           third = mol->AskAtom("Enter second atom (specifying the axis for first angle): ");
    172           fourth = mol->AskAtom("Enter third atom (specifying a plane for second angle): ");
    173           a = ask_value("Enter distance between central (first) and new atom: ");
    174           b = ask_value("Enter angle between new, first and second atom (degrees): ");
    175           b *= M_PI/180.;
    176           bound(&b, 0., 2.*M_PI);
    177           c = ask_value("Enter second angle between new and normal vector of plane defined by first, second and third atom (degrees): ");
    178           c *= M_PI/180.;
    179           bound(&c, -M_PI, M_PI);
    180           cout << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;
    181 /*
    182           second->Output(1,1,(ofstream *)&cout);
    183           third->Output(1,2,(ofstream *)&cout);
    184           fourth->Output(1,3,(ofstream *)&cout);
    185           n.MakeNormalvector((const vector *)&second->x, (const vector *)&third->x, (const vector *)&fourth->x);
    186           x.Copyvector(&second->x);
    187           x.SubtractVector(&third->x);
    188           x.Copyvector(&fourth->x);
    189           x.SubtractVector(&third->x);
    190 
    191           if (!z.SolveSystem(&x,&y,&n, b, c, a)) {
    192          coutg() << Verbose(0) << "Failure solving self-dependent linear system!" << endl;
    193             continue;
    194           }
    195           DoLog(0) && (Log() << Verbose(0) << "resulting relative coordinates: ");
    196           z.Output();
    197           DoLog(0) && (Log() << Verbose(0) << endl);
    198           */
    199           // calc axis vector
    200           x.CopyVector(&second->x);
    201           x.SubtractVector(&third->x);
    202           x.Normalize();
    203           Log() << Verbose(0) << "x: ",
    204           x.Output();
    205           DoLog(0) && (Log() << Verbose(0) << endl);
    206           z.MakeNormalVector(&second->x,&third->x,&fourth->x);
    207           Log() << Verbose(0) << "z: ",
    208           z.Output();
    209           DoLog(0) && (Log() << Verbose(0) << endl);
    210           y.MakeNormalVector(&x,&z);
    211           Log() << Verbose(0) << "y: ",
    212           y.Output();
    213           DoLog(0) && (Log() << Verbose(0) << endl);
    214 
    215           // rotate vector around first angle
    216           first->x.CopyVector(&x);
    217           first->x.RotateVector(&z,b - M_PI);
    218           Log() << Verbose(0) << "Rotated vector: ",
    219           first->x.Output();
    220           DoLog(0) && (Log() << Verbose(0) << endl);
    221           // remove the projection onto the rotation plane of the second angle
    222           n.CopyVector(&y);
    223           n.Scale(first->x.ScalarProduct(&y));
    224           Log() << Verbose(0) << "N1: ",
    225           n.Output();
    226           DoLog(0) && (Log() << Verbose(0) << endl);
    227           first->x.SubtractVector(&n);
    228           Log() << Verbose(0) << "Subtracted vector: ",
    229           first->x.Output();
    230           DoLog(0) && (Log() << Verbose(0) << endl);
    231           n.CopyVector(&z);
    232           n.Scale(first->x.ScalarProduct(&z));
    233           Log() << Verbose(0) << "N2: ",
    234           n.Output();
    235           DoLog(0) && (Log() << Verbose(0) << endl);
    236           first->x.SubtractVector(&n);
    237           Log() << Verbose(0) << "2nd subtracted vector: ",
    238           first->x.Output();
    239           DoLog(0) && (Log() << Verbose(0) << endl);
    240 
    241           // rotate another vector around second angle
    242           n.CopyVector(&y);
    243           n.RotateVector(&x,c - M_PI);
    244           Log() << Verbose(0) << "2nd Rotated vector: ",
    245           n.Output();
    246           DoLog(0) && (Log() << Verbose(0) << endl);
    247 
    248           // add the two linear independent vectors
    249           first->x.AddVector(&n);
    250           first->x.Normalize();
    251           first->x.Scale(a);
    252           first->x.AddVector(&second->x);
    253 
    254           DoLog(0) && (Log() << Verbose(0) << "resulting coordinates: ");
    255           first->x.Output();
    256           DoLog(0) && (Log() << Verbose(0) << endl);
    257         } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    258         first->type = periode->AskElement();  // give type
    259         mol->AddAtom(first);  // add to molecule
    260         break;
    261 
    262       case 'e': // least square distance position to a set of atoms
    263         first = new atom;
    264         atoms = new (Vector*[128]);
    265         valid = true;
    266         for(int i=128;i--;)
    267           atoms[i] = NULL;
    268         int i=0, j=0;
    269         cout << Verbose(0) << "Now we need at least three molecules.\n";
    270         do {
    271           cout << Verbose(0) << "Enter " << i+1 << "th atom: ";
    272           cin >> j;
    273           if (j != -1) {
    274             second = mol->FindAtom(j);
    275             atoms[i++] = &(second->x);
    276           }
    277         } while ((j != -1) && (i<128));
    278         if (i >= 2) {
    279           first->x.LSQdistance((const Vector **)atoms, i);
    280           first->x.Output();
    281           first->type = periode->AskElement();  // give type
    282           mol->AddAtom(first);  // add to molecule
    283         } else {
    284           delete first;
    285           cout << Verbose(0) << "Please enter at least two vectors!\n";
    286         }
    287         break;
    288   };
    289 };
    290 
    291 /** Submenu for centering the atoms in the molecule.
    292  * \param *mol molecule with all the atoms
    293  */
    294 static void CenterAtoms(molecule *mol)
    295 {
    296   Vector x, y, helper;
    297   char choice;  // menu choice char
    298 
    299   cout << Verbose(0) << "===========CENTER ATOMS=========================" << endl;
    300   cout << Verbose(0) << " a - on origin" << endl;
    301   cout << Verbose(0) << " b - on center of gravity" << endl;
    302   cout << Verbose(0) << " c - within box with additional boundary" << endl;
    303   cout << Verbose(0) << " d - within given simulation box" << endl;
    304   cout << Verbose(0) << "all else - go back" << endl;
    305   cout << Verbose(0) << "===============================================" << endl;
    306   cout << Verbose(0) << "INPUT: ";
    307   cin >> choice;
    308 
    309   switch (choice) {
    310     default:
    311       cout << Verbose(0) << "Not a valid choice." << endl;
    312       break;
    313     case 'a':
    314       cout << Verbose(0) << "Centering atoms in config file on origin." << endl;
    315       mol->CenterOrigin();
    316       break;
    317     case 'b':
    318       cout << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;
    319       mol->CenterPeriodic();
    320       break;
    321     case 'c':
    322       cout << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;
    323       for (int i=0;i<NDIM;i++) {
    324         cout << Verbose(0) << "Enter axis " << i << " boundary: ";
    325         cin >> y.x[i];
    326       }
    327       mol->CenterEdge(&x);  // make every coordinate positive
    328       mol->Center.AddVector(&y); // translate by boundary
    329       helper.CopyVector(&y);
    330       helper.Scale(2.);
    331       helper.AddVector(&x);
    332       mol->SetBoxDimension(&helper);  // update Box of atoms by boundary
    333       break;
    334     case 'd':
    335       cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
    336       for (int i=0;i<NDIM;i++) {
    337         cout << Verbose(0) << "Enter axis " << i << " boundary: ";
    338         cin >> x.x[i];
    339       }
    340       // update Box of atoms by boundary
    341       mol->SetBoxDimension(&x);
    342       // center
    343       mol->CenterInBox();
    344       break;
    345   }
    346 };
    347 
    348 /** Submenu for aligning the atoms in the molecule.
    349  * \param *periode periodentafel
    350  * \param *mol molecule with all the atoms
    351  */
    352 static void AlignAtoms(periodentafel *periode, molecule *mol)
    353 {
    354   atom *first, *second, *third;
    355   Vector x,n;
    356   char choice;  // menu choice char
    357 
    358   cout << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;
    359   cout << Verbose(0) << " a - state three atoms defining align plane" << endl;
    360   cout << Verbose(0) << " b - state alignment vector" << endl;
    361   cout << Verbose(0) << " c - state two atoms in alignment direction" << endl;
    362   cout << Verbose(0) << " d - align automatically by least square fit" << endl;
    363   cout << Verbose(0) << "all else - go back" << endl;
    364   cout << Verbose(0) << "===============================================" << endl;
    365   cout << Verbose(0) << "INPUT: ";
    366   cin >> choice;
    367 
    368   switch (choice) {
    369     default:
    370     case 'a': // three atoms defining mirror plane
    371       first = mol->AskAtom("Enter first atom: ");
    372       second = mol->AskAtom("Enter second atom: ");
    373       third = mol->AskAtom("Enter third atom: ");
    374 
    375       n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
    376       break;
    377     case 'b': // normal vector of mirror plane
    378       cout << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    379       n.AskPosition(World::getInstance().getDomain(),0);
    380       n.Normalize();
    381       break;
    382     case 'c': // three atoms defining mirror plane
    383       first = mol->AskAtom("Enter first atom: ");
    384       second = mol->AskAtom("Enter second atom: ");
    385 
    386       n.CopyVector((const Vector *)&first->x);
    387       n.SubtractVector((const Vector *)&second->x);
    388       n.Normalize();
    389       break;
    390     case 'd':
    391       char shorthand[4];
    392       Vector a;
    393       struct lsq_params param;
    394       do {
    395         fprintf(stdout, "Enter the element of atoms to be chosen: ");
    396         fscanf(stdin, "%3s", shorthand);
    397       } while ((param.type = periode->FindElement(shorthand)) == NULL);
    398       cout << Verbose(0) << "Element is " << param.type->name << endl;
    399       mol->GetAlignvector(&param);
    400       for (int i=NDIM;i--;) {
    401         x.x[i] = gsl_vector_get(param.x,i);
    402         n.x[i] = gsl_vector_get(param.x,i+NDIM);
    403       }
    404       gsl_vector_free(param.x);
    405       cout << Verbose(0) << "Offset vector: ";
    406       x.Output();
    407       DoLog(0) && (Log() << Verbose(0) << endl);
    408       n.Normalize();
    409       break;
    410   };
    411   DoLog(0) && (Log() << Verbose(0) << "Alignment vector: ");
    412   n.Output();
    413   DoLog(0) && (Log() << Verbose(0) << endl);
    414   mol->Align(&n);
    415 };
    416 
    417 /** Submenu for mirroring the atoms in the molecule.
    418  * \param *mol molecule with all the atoms
    419  */
    420 static void MirrorAtoms(molecule *mol)
    421 {
    422   atom *first, *second, *third;
    423   Vector n;
    424   char choice;  // menu choice char
    425 
    426   DoLog(0) && (Log() << Verbose(0) << "===========MIRROR ATOMS=========================" << endl);
    427   DoLog(0) && (Log() << Verbose(0) << " a - state three atoms defining mirror plane" << endl);
    428   DoLog(0) && (Log() << Verbose(0) << " b - state normal vector of mirror plane" << endl);
    429   DoLog(0) && (Log() << Verbose(0) << " c - state two atoms in normal direction" << endl);
    430   DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
    431   DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    432   DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    433   cin >> choice;
    434 
    435   switch (choice) {
    436     default:
    437     case 'a': // three atoms defining mirror plane
    438       first = mol->AskAtom("Enter first atom: ");
    439       second = mol->AskAtom("Enter second atom: ");
    440       third = mol->AskAtom("Enter third atom: ");
    441 
    442       n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
    443       break;
    444     case 'b': // normal vector of mirror plane
    445       DoLog(0) && (Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl);
    446       n.AskPosition(World::getInstance().getDomain(),0);
    447       n.Normalize();
    448       break;
    449     case 'c': // three atoms defining mirror plane
    450       first = mol->AskAtom("Enter first atom: ");
    451       second = mol->AskAtom("Enter second atom: ");
    452 
    453       n.CopyVector((const Vector *)&first->x);
    454       n.SubtractVector((const Vector *)&second->x);
    455       n.Normalize();
    456       break;
    457   };
    458   DoLog(0) && (Log() << Verbose(0) << "Normal vector: ");
    459   n.Output();
    460   DoLog(0) && (Log() << Verbose(0) << endl);
    461   mol->Mirror((const Vector *)&n);
    462 };
    463 
    464 /** Submenu for removing the atoms from the molecule.
    465  * \param *mol molecule with all the atoms
    466  */
    467 static void RemoveAtoms(molecule *mol)
    468 {
    469   atom *first, *second;
    470   int axis;
    471   double tmp1, tmp2;
    472   char choice;  // menu choice char
    473 
    474   DoLog(0) && (Log() << Verbose(0) << "===========REMOVE ATOMS=========================" << endl);
    475   DoLog(0) && (Log() << Verbose(0) << " a - state atom for removal by number" << endl);
    476   DoLog(0) && (Log() << Verbose(0) << " b - keep only in radius around atom" << endl);
    477   DoLog(0) && (Log() << Verbose(0) << " c - remove this with one axis greater value" << endl);
    478   DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
    479   DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    480   DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    481   cin >> choice;
    482 
    483   switch (choice) {
    484     default:
    485     case 'a':
    486       if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: ")))
    487         DoLog(1) && (Log() << Verbose(1) << "Atom removed." << endl);
    488       else
    489         DoLog(1) && (Log() << Verbose(1) << "Atom not found." << endl);
    490       break;
    491     case 'b':
    492       second = mol->AskAtom("Enter number of atom as reference point: ");
    493       DoLog(0) && (Log() << Verbose(0) << "Enter radius: ");
    494       cin >> tmp1;
    495       first = mol->start;
    496       second = first->next;
    497       while(second != mol->end) {
    498         first = second;
    499         second = first->next;
    500         if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...
    501           mol->RemoveAtom(first);
    502       }
    503       break;
    504     case 'c':
    505       DoLog(0) && (Log() << Verbose(0) << "Which axis is it: ");
    506       cin >> axis;
    507       DoLog(0) && (Log() << Verbose(0) << "Lower boundary: ");
    508       cin >> tmp1;
    509       DoLog(0) && (Log() << Verbose(0) << "Upper boundary: ");
    510       cin >> tmp2;
    511       first = mol->start;
    512       second = first->next;
    513       while(second != mol->end) {
    514         first = second;
    515         second = first->next;
    516         if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
    517           //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
    518           mol->RemoveAtom(first);
    519         }
    520       }
    521       break;
    522   };
    523   //mol->Output();
    524   choice = 'r';
    525 };
    526 
    527 /** Submenu for measuring out the atoms in the molecule.
    528  * \param *periode periodentafel
    529  * \param *mol molecule with all the atoms
    530  */
    531 static void MeasureAtoms(periodentafel *periode, molecule *mol, config *configuration)
    532 {
    533   atom *first, *second, *third;
    534   Vector x,y;
    535   double min[256], tmp1, tmp2, tmp3;
    536   int Z;
    537   char choice;  // menu choice char
    538 
    539   DoLog(0) && (Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl);
    540   DoLog(0) && (Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl);
    541   DoLog(0) && (Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl);
    542   DoLog(0) && (Log() << Verbose(0) << " c - calculate bond angle" << endl);
    543   DoLog(0) && (Log() << Verbose(0) << " d - calculate principal axis of the system" << endl);
    544   DoLog(0) && (Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl);
    545   DoLog(0) && (Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl);
    546   DoLog(0) && (Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl);
    547   DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
    548   DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    549   DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    550   cin >> choice;
    551 
    552   switch(choice) {
    553     default:
    554       DoLog(1) && (Log() << Verbose(1) << "Not a valid choice." << endl);
    555       break;
    556     case 'a':
    557       first = mol->AskAtom("Enter first atom: ");
    558       for (int i=MAX_ELEMENTS;i--;)
    559         min[i] = 0.;
    560 
    561       second = mol->start;
    562       while ((second->next != mol->end)) {
    563         second = second->next; // advance
    564         Z = second->type->Z;
    565         tmp1 = 0.;
    566         if (first != second) {
    567           x.CopyVector((const Vector *)&first->x);
    568           x.SubtractVector((const Vector *)&second->x);
    569           tmp1 = x.Norm();
    570         }
    571         if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
    572         //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
    573       }
    574       for (int i=MAX_ELEMENTS;i--;)
    575         if (min[i] != 0.) Log() << Verbose(0) << "Minimum Bond length between " << first->type->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl;
    576       break;
    577 
    578     case 'b':
    579       first = mol->AskAtom("Enter first atom: ");
    580       second = mol->AskAtom("Enter second atom: ");
    581       for (int i=NDIM;i--;)
    582         min[i] = 0.;
    583       x.CopyVector((const Vector *)&first->x);
    584       x.SubtractVector((const Vector *)&second->x);
    585       tmp1 = x.Norm();
    586       DoLog(1) && (Log() << Verbose(1) << "Distance vector is ");
    587       x.Output();
    588       DoLog(0) && (Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl);
    589       break;
    590 
    591     case 'c':
    592       DoLog(0) && (Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl);
    593       first = mol->AskAtom("Enter first atom: ");
    594       second = mol->AskAtom("Enter central atom: ");
    595       third  = mol->AskAtom("Enter last atom: ");
    596       tmp1 = tmp2 = tmp3 = 0.;
    597       x.CopyVector((const Vector *)&first->x);
    598       x.SubtractVector((const Vector *)&second->x);
    599       y.CopyVector((const Vector *)&third->x);
    600       y.SubtractVector((const Vector *)&second->x);
    601       DoLog(0) && (Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ");
    602       DoLog(0) && (Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl);
    603       break;
    604     case 'd':
    605       DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
    606       DoLog(0) && (Log() << Verbose(0) << "Shall we rotate? [0/1]: ");
    607       cin >> Z;
    608       if ((Z >=0) && (Z <=1))
    609         mol->PrincipalAxisSystem((bool)Z);
    610       else
    611         mol->PrincipalAxisSystem(false);
    612       break;
    613     case 'e':
    614       {
    615         DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");
    616         class Tesselation *TesselStruct = NULL;
    617         const LinkedCell *LCList = NULL;
    618         LCList = new LinkedCell(mol, 10.);
    619         FindConvexBorder(mol, TesselStruct, LCList, NULL);
    620         double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
    621         DoLog(0) && (Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl);\
    622         delete(LCList);
    623         delete(TesselStruct);
    624       }
    625       break;
    626     case 'f':
    627       mol->OutputTemperatureFromTrajectories((ofstream *)&cout, mol->MDSteps-1, mol->MDSteps);
    628       break;
    629     case 'g':
    630       {
    631         char filename[255];
    632         DoLog(0) && (Log() << Verbose(0) << "Please enter filename: " << endl);
    633         cin >> filename;
    634         DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl);
    635         ofstream *output = new ofstream(filename, ios::trunc);
    636         if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
    637           DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl);
    638         else
    639           DoLog(2) && (Log() << Verbose(2) << "File stored." << endl);
    640         output->close();
    641         delete(output);
    642       }
    643       break;
    644   }
    645 };
    646 
    647 /** Submenu for measuring out the atoms in the molecule.
    648  * \param *mol molecule with all the atoms
    649  * \param *configuration configuration structure for the to be written config files of all fragments
    650  */
    651 static void FragmentAtoms(molecule *mol, config *configuration)
    652 {
    653   int Order1;
    654   clock_t start, end;
    655 
    656   DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
    657   DoLog(0) && (Log() << Verbose(0) << "What's the desired bond order: ");
    658   cin >> Order1;
    659   if (mol->first->next != mol->last) {  // there are bonds
    660     start = clock();
    661     mol->FragmentMolecule(Order1, configuration);
    662     end = clock();
    663     DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    664   } else
    665     DoLog(0) && (Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl);
    666 };
    667 
    668 /********************************************** Submenu routine **************************************/
    669 
    670 /** Submenu for manipulating atoms.
    671  * \param *periode periodentafel
    672  * \param *molecules list of molecules whose atoms are to be manipulated
    673  */
    674 static void ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
    675 {
    676   atom *first, *second, *third;
    677   molecule *mol = NULL;
    678   Vector x,y,z,n; // coordinates for absolute point in cell volume
    679   double *factor; // unit factor if desired
    680   double bond, minBond;
    681   char choice;  // menu choice char
    682   bool valid;
    683 
    684   DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl);
    685   DoLog(0) && (Log() << Verbose(0) << "a - add an atom" << endl);
    686   DoLog(0) && (Log() << Verbose(0) << "r - remove an atom" << endl);
    687   DoLog(0) && (Log() << Verbose(0) << "b - scale a bond between atoms" << endl);
    688   DoLog(0) && (Log() << Verbose(0) << "t - turn an atom round another bond" << endl);
    689   DoLog(0) && (Log() << Verbose(0) << "u - change an atoms element" << endl);
    690   DoLog(0) && (Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl);
    691   DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
    692   DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    693   if (molecules->NumberOfActiveMolecules() > 1)
    694     DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl);
    695   DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    696   cin >> choice;
    697 
    698   switch (choice) {
    699     default:
    700       DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    701       break;
    702 
    703     case 'a': // add atom
    704       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    705         if ((*ListRunner)->ActiveFlag) {
    706         mol = *ListRunner;
    707         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    708         AddAtoms(periode, mol);
    709       }
    710       break;
    711 
    712     case 'b': // scale a bond
    713       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    714         if ((*ListRunner)->ActiveFlag) {
    715         mol = *ListRunner;
    716         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    717         DoLog(0) && (Log() << Verbose(0) << "Scaling bond length between two atoms." << endl);
    718         first = mol->AskAtom("Enter first (fixed) atom: ");
    719         second = mol->AskAtom("Enter second (shifting) atom: ");
    720         minBond = 0.;
    721         for (int i=NDIM;i--;)
    722           minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]);
    723         minBond = sqrt(minBond);
    724         DoLog(0) && (Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl);
    725         DoLog(0) && (Log() << Verbose(0) << "Enter new bond length [a.u.]: ");
    726         cin >> bond;
    727         for (int i=NDIM;i--;) {
    728           second->x.x[i] -= (second->x.x[i]-first->x.x[i])/minBond*(minBond-bond);
    729         }
    730         //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
    731         //second->Output(second->type->No, 1);
    732       }
    733       break;
    734 
    735     case 'c': // unit scaling of the metric
    736       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    737         if ((*ListRunner)->ActiveFlag) {
    738         mol = *ListRunner;
    739         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    740        DoLog(0) && (Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl);
    741        DoLog(0) && (Log() << Verbose(0) << "Enter three factors: ");
    742        factor = new double[NDIM];
    743        cin >> factor[0];
    744        cin >> factor[1];
    745        cin >> factor[2];
    746        valid = true;
    747        mol->Scale((const double ** const)&factor);
    748        delete[](factor);
    749       }
    750      break;
    751 
    752     case 'l': // measure distances or angles
    753       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    754         if ((*ListRunner)->ActiveFlag) {
    755         mol = *ListRunner;
    756         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    757         MeasureAtoms(periode, mol, configuration);
    758       }
    759       break;
    760 
    761     case 'r': // remove atom
    762       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    763         if ((*ListRunner)->ActiveFlag) {
    764         mol = *ListRunner;
    765         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    766         RemoveAtoms(mol);
    767       }
    768       break;
    769 
    770     case 't': // turn/rotate atom
    771       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    772         if ((*ListRunner)->ActiveFlag) {
    773           mol = *ListRunner;
    774           DoLog(0) && (Log() << Verbose(0) << "Turning atom around another bond - first is atom to turn, second (central) and third specify bond" << endl);
    775           first = mol->AskAtom("Enter turning atom: ");
    776           second = mol->AskAtom("Enter central atom: ");
    777           third  = mol->AskAtom("Enter bond atom: ");
    778           cout << Verbose(0) << "Enter new angle in degrees: ";
    779           double tmp = 0.;
    780           cin >> tmp;
    781           // calculate old angle
    782           x.CopyVector((const Vector *)&first->x);
    783           x.SubtractVector((const Vector *)&second->x);
    784           y.CopyVector((const Vector *)&third->x);
    785           y.SubtractVector((const Vector *)&second->x);
    786           double alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.);
    787           cout << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
    788           cout << Verbose(0) << alpha << " degrees" << endl;
    789           // rotate
    790           z.MakeNormalVector(&x,&y);
    791           x.RotateVector(&z,(alpha-tmp)*M_PI/180.);
    792           x.AddVector(&second->x);
    793           first->x.CopyVector(&x);
    794           // check new angle
    795           x.CopyVector((const Vector *)&first->x);
    796           x.SubtractVector((const Vector *)&second->x);
    797           alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.);
    798           cout << Verbose(0) << "new Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
    799           cout << Verbose(0) << alpha << " degrees" << endl;
    800         }
    801       break;
    802 
    803     case 'u': // change an atom's element
    804       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    805         if ((*ListRunner)->ActiveFlag) {
    806         int Z;
    807         mol = *ListRunner;
    808         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    809         first = NULL;
    810         do {
    811           DoLog(0) && (Log() << Verbose(0) << "Change the element of which atom: ");
    812           cin >> Z;
    813         } while ((first = mol->FindAtom(Z)) == NULL);
    814         DoLog(0) && (Log() << Verbose(0) << "New element by atomic number Z: ");
    815         cin >> Z;
    816         first->type = periode->FindElement(Z);
    817         DoLog(0) && (Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl);
    818       }
    819       break;
    820   }
    821 };
    822 
    823 /** Submenu for manipulating molecules.
    824  * \param *periode periodentafel
    825  * \param *molecules list of molecule to manipulate
    826  */
    827 static void ManipulateMolecules(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
    828 {
    829   atom *first = NULL;
    830   Vector x,y,z,n; // coordinates for absolute point in cell volume
    831   int j, axis, count, faktor;
    832   char choice;  // menu choice char
    833   molecule *mol = NULL;
    834   element **Elements;
    835   Vector **vectors;
    836   MoleculeLeafClass *Subgraphs = NULL;
    837 
    838   DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl);
    839   DoLog(0) && (Log() << Verbose(0) << "c - scale by unit transformation" << endl);
    840   DoLog(0) && (Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl);
    841   DoLog(0) && (Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl);
    842   DoLog(0) && (Log() << Verbose(0) << "g - center atoms in box" << endl);
    843   DoLog(0) && (Log() << Verbose(0) << "i - realign molecule" << endl);
    844   DoLog(0) && (Log() << Verbose(0) << "m - mirror all molecules" << endl);
    845   DoLog(0) && (Log() << Verbose(0) << "o - create connection matrix" << endl);
    846   DoLog(0) && (Log() << Verbose(0) << "t - translate molecule by vector" << endl);
    847   DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
    848   DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    849   if (molecules->NumberOfActiveMolecules() > 1)
    850     DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl);
    851   DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    852   cin >> choice;
    853 
    854   switch (choice) {
    855     default:
    856       DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    857       break;
    858 
    859     case 'd': // duplicate the periodic cell along a given axis, given times
    860       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    861         if ((*ListRunner)->ActiveFlag) {
    862         mol = *ListRunner;
    863         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    864         DoLog(0) && (Log() << Verbose(0) << "State the axis [(+-)123]: ");
    865         cin >> axis;
    866         DoLog(0) && (Log() << Verbose(0) << "State the factor: ");
    867         cin >> faktor;
    868 
    869         mol->CountAtoms(); // recount atoms
    870         if (mol->getAtomCount() != 0) {  // if there is more than none
    871           count = mol->getAtomCount();  // is changed becausing of adding, thus has to be stored away beforehand
    872           Elements = new element *[count];
    873           vectors = new Vector *[count];
    874           j = 0;
    875           first = mol->start;
    876           while (first->next != mol->end) { // make a list of all atoms with coordinates and element
    877             first = first->next;
    878             Elements[j] = first->type;
    879             vectors[j] = &first->x;
    880             j++;
    881           }
    882           if (count != j)
    883             DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
    884           x.Zero();
    885           y.Zero();
    886           y.x[abs(axis)-1] = World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
    887           for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    888             x.AddVector(&y); // per factor one cell width further
    889             for (int k=count;k--;) { // go through every atom of the original cell
    890               first = new atom(); // create a new body
    891               first->x.CopyVector(vectors[k]);  // use coordinate of original atom
    892               first->x.AddVector(&x);     // translate the coordinates
    893               first->type = Elements[k];  // insert original element
    894               mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
    895             }
    896           }
    897           if (mol->first->next != mol->last) // if connect matrix is present already, redo it
    898             mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    899           // free memory
    900           delete[](Elements);
    901           delete[](vectors);
    902           // correct cell size
    903           if (axis < 0) { // if sign was negative, we have to translate everything
    904             x.Zero();
    905             x.AddVector(&y);
    906             x.Scale(-(faktor-1));
    907             mol->Translate(&x);
    908           }
    909           World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
    910         }
    911       }
    912       break;
    913 
    914     case 'f':
    915       FragmentAtoms(mol, configuration);
    916       break;
    917 
    918     case 'g': // center the atoms
    919       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    920         if ((*ListRunner)->ActiveFlag) {
    921         mol = *ListRunner;
    922         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    923         CenterAtoms(mol);
    924       }
    925       break;
    926 
    927     case 'i': // align all atoms
    928       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    929         if ((*ListRunner)->ActiveFlag) {
    930         mol = *ListRunner;
    931         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    932         AlignAtoms(periode, mol);
    933       }
    934       break;
    935 
    936     case 'm': // mirror atoms along a given axis
    937       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    938         if ((*ListRunner)->ActiveFlag) {
    939         mol = *ListRunner;
    940         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    941         MirrorAtoms(mol);
    942       }
    943       break;
    944 
    945     case 'o': // create the connection matrix
    946       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    947         if ((*ListRunner)->ActiveFlag) {
    948           mol = *ListRunner;
    949           double bonddistance;
    950           clock_t start,end;
    951           DoLog(0) && (Log() << Verbose(0) << "What's the maximum bond distance: ");
    952           cin >> bonddistance;
    953           start = clock();
    954           mol->CreateAdjacencyList(bonddistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    955           end = clock();
    956           DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    957         }
    958       break;
    959 
    960     case 't': // translate all atoms
    961       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    962         if ((*ListRunner)->ActiveFlag) {
    963         mol = *ListRunner;
    964         DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    965         DoLog(0) && (Log() << Verbose(0) << "Enter translation vector." << endl);
    966         x.AskPosition(World::getInstance().getDomain(),0);
    967         mol->Center.AddVector((const Vector *)&x);
    968      }
    969      break;
    970   }
    971   // Free all
    972   if (Subgraphs != NULL) {  // free disconnected subgraph list of DFS analysis was performed
    973     while (Subgraphs->next != NULL) {
    974       Subgraphs = Subgraphs->next;
    975       delete(Subgraphs->previous);
    976     }
    977     delete(Subgraphs);
    978   }
    979 };
    980 
    981 
    982 /** Submenu for creating new molecules.
    983  * \param *periode periodentafel
    984  * \param *molecules list of molecules to add to
    985  */
    986 static void EditMolecules(periodentafel *periode, MoleculeListClass *molecules)
    987 {
    988   char choice;  // menu choice char
    989   Vector center;
    990   int nr, count;
    991   molecule *mol = NULL;
    992 
    993   DoLog(0) && (Log() << Verbose(0) << "==========EDIT MOLECULES=====================" << endl);
    994   DoLog(0) && (Log() << Verbose(0) << "c - create new molecule" << endl);
    995   DoLog(0) && (Log() << Verbose(0) << "l - load molecule from xyz file" << endl);
    996   DoLog(0) && (Log() << Verbose(0) << "n - change molecule's name" << endl);
    997   DoLog(0) && (Log() << Verbose(0) << "N - give molecules filename" << endl);
    998   DoLog(0) && (Log() << Verbose(0) << "p - parse atoms in xyz file into molecule" << endl);
    999   DoLog(0) && (Log() << Verbose(0) << "r - remove a molecule" << endl);
    1000   DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
    1001   DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    1002   DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    1003   cin >> choice;
    1004 
    1005   switch (choice) {
    1006     default:
    1007       DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    1008       break;
    1009     case 'c':
    1010       mol = World::getInstance().createMolecule();
    1011       molecules->insert(mol);
    1012       break;
    1013 
    1014     case 'l': // load from XYZ file
    1015       {
    1016         char filename[MAXSTRINGSIZE];
    1017         DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl);
    1018         mol = World::getInstance().createMolecule();
    1019         do {
    1020           DoLog(0) && (Log() << Verbose(0) << "Enter file name: ");
    1021           cin >> filename;
    1022         } while (!mol->AddXYZFile(filename));
    1023         mol->SetNameFromFilename(filename);
    1024         // center at set box dimensions
    1025         mol->CenterEdge(&center);
    1026         double * const cell_size = World::getInstance().getDomain();
    1027         cell_size[0] = center.x[0];
    1028         cell_size[1] = 0;
    1029         cell_size[2] = center.x[1];
    1030         cell_size[3] = 0;
    1031         cell_size[4] = 0;
    1032         cell_size[5] = center.x[2];
    1033         molecules->insert(mol);
    1034       }
    1035       break;
    1036 
    1037     case 'n':
    1038       {
    1039         char filename[MAXSTRINGSIZE];
    1040         do {
    1041           DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    1042           cin >> nr;
    1043           mol = molecules->ReturnIndex(nr);
    1044         } while (mol == NULL);
    1045         DoLog(0) && (Log() << Verbose(0) << "Enter name: ");
    1046         cin >> filename;
    1047         strcpy(mol->name, filename);
    1048       }
    1049       break;
    1050 
    1051     case 'N':
    1052       {
    1053         char filename[MAXSTRINGSIZE];
    1054         do {
    1055           DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    1056           cin >> nr;
    1057           mol = molecules->ReturnIndex(nr);
    1058         } while (mol == NULL);
    1059         DoLog(0) && (Log() << Verbose(0) << "Enter name: ");
    1060         cin >> filename;
    1061         mol->SetNameFromFilename(filename);
    1062       }
    1063       break;
    1064 
    1065     case 'p': // parse XYZ file
    1066       {
    1067         char filename[MAXSTRINGSIZE];
    1068         mol = NULL;
    1069         do {
    1070           DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    1071           cin >> nr;
    1072           mol = molecules->ReturnIndex(nr);
    1073         } while (mol == NULL);
    1074         DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl);
    1075         do {
    1076           DoLog(0) && (Log() << Verbose(0) << "Enter file name: ");
    1077           cin >> filename;
    1078         } while (!mol->AddXYZFile(filename));
    1079         mol->SetNameFromFilename(filename);
    1080       }
    1081       break;
    1082 
    1083     case 'r':
    1084       DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    1085       cin >> nr;
    1086       count = 1;
    1087       for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    1088         if (nr == (*ListRunner)->IndexNr) {
    1089           mol = *ListRunner;
    1090           molecules->ListOfMolecules.erase(ListRunner);
    1091           delete(mol);
    1092           break;
    1093         }
    1094       break;
    1095   }
    1096 };
    1097 
    1098 
    1099 /** Submenu for merging molecules.
    1100  * \param *periode periodentafel
    1101  * \param *molecules list of molecules to add to
    1102  */
    1103 static void MergeMolecules(periodentafel *periode, MoleculeListClass *molecules)
    1104 {
    1105   char choice;  // menu choice char
    1106 
    1107   DoLog(0) && (Log() << Verbose(0) << "===========MERGE MOLECULES=====================" << endl);
    1108   DoLog(0) && (Log() << Verbose(0) << "a - simple add of one molecule to another" << endl);
    1109   DoLog(0) && (Log() << Verbose(0) << "b - count the number of bonds of two elements" << endl);
    1110   DoLog(0) && (Log() << Verbose(0) << "B - count the number of bonds of three elements " << endl);
    1111   DoLog(0) && (Log() << Verbose(0) << "e - embedding merge of two molecules" << endl);
    1112   DoLog(0) && (Log() << Verbose(0) << "h - count the number of hydrogen bonds" << endl);
    1113   DoLog(0) && (Log() << Verbose(0) << "b - count the number of hydrogen bonds" << endl);
    1114   DoLog(0) && (Log() << Verbose(0) << "m - multi-merge of all molecules" << endl);
    1115   DoLog(0) && (Log() << Verbose(0) << "s - scatter merge of two molecules" << endl);
    1116   DoLog(0) && (Log() << Verbose(0) << "t - simple merge of two molecules" << endl);
    1117   DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
    1118   DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    1119   DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    1120   cin >> choice;
    1121 
    1122   switch (choice) {
    1123     default:
    1124       DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    1125       break;
    1126 
    1127     case 'a':
    1128       {
    1129         int src, dest;
    1130         molecule *srcmol = NULL, *destmol = NULL;
    1131         {
    1132           do {
    1133             DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: ");
    1134             cin >> dest;
    1135             destmol = molecules->ReturnIndex(dest);
    1136           } while ((destmol == NULL) && (dest != -1));
    1137           do {
    1138             DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to add from: ");
    1139             cin >> src;
    1140             srcmol = molecules->ReturnIndex(src);
    1141           } while ((srcmol == NULL) && (src != -1));
    1142           if ((src != -1) && (dest != -1))
    1143             molecules->SimpleAdd(srcmol, destmol);
    1144         }
    1145       }
    1146       break;
    1147 
    1148     case 'b':
    1149       {
    1150         const int nr = 2;
    1151         char *names[nr] = {"first", "second"};
    1152         int Z[nr];
    1153         element *elements[nr];
    1154         for (int i=0;i<nr;i++) {
    1155           Z[i] = 0;
    1156           do {
    1157             cout << "Enter " << names[i] << " element: ";
    1158             cin >> Z[i];
    1159           } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS));
    1160           elements[i] = periode->FindElement(Z[i]);
    1161         }
    1162         const int count = CountBondsOfTwo(molecules, elements[0], elements[1]);
    1163         cout << endl << "There are " << count << " ";
    1164         for (int i=0;i<nr;i++) {
    1165           if (i==0)
    1166             cout << elements[i]->symbol;
    1167           else
    1168             cout << "-" << elements[i]->symbol;
    1169         }
    1170         cout << " bonds." << endl;
    1171       }
    1172     break;
    1173 
    1174     case 'B':
    1175       {
    1176         const int nr = 3;
    1177         char *names[nr] = {"first", "second", "third"};
    1178         int Z[nr];
    1179         element *elements[nr];
    1180         for (int i=0;i<nr;i++) {
    1181           Z[i] = 0;
    1182           do {
    1183             cout << "Enter " << names[i] << " element: ";
    1184             cin >> Z[i];
    1185           } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS));
    1186           elements[i] = periode->FindElement(Z[i]);
    1187         }
    1188         const int count = CountBondsOfThree(molecules, elements[0], elements[1], elements[2]);
    1189         cout << endl << "There are " << count << " ";
    1190         for (int i=0;i<nr;i++) {
    1191           if (i==0)
    1192             cout << elements[i]->symbol;
    1193           else
    1194             cout << "-" << elements[i]->symbol;
    1195         }
    1196         cout << " bonds." << endl;
    1197       }
    1198     break;
    1199 
    1200     case 'e':
    1201       {
    1202         int src, dest;
    1203         molecule *srcmol = NULL, *destmol = NULL;
    1204         do {
    1205           DoLog(0) && (Log() << Verbose(0) << "Enter index of matrix molecule (the variable one): ");
    1206           cin >> src;
    1207           srcmol = molecules->ReturnIndex(src);
    1208         } while ((srcmol == NULL) && (src != -1));
    1209         do {
    1210           DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into (the fixed one): ");
    1211           cin >> dest;
    1212           destmol = molecules->ReturnIndex(dest);
    1213         } while ((destmol == NULL) && (dest != -1));
    1214         if ((src != -1) && (dest != -1))
    1215           molecules->EmbedMerge(destmol, srcmol);
    1216       }
    1217       break;
    1218 
    1219     case 'h':
    1220       {
    1221         int Z;
    1222         cout << "Please enter interface element: ";
    1223         cin >> Z;
    1224         element * const InterfaceElement = periode->FindElement(Z);
    1225         cout << endl << "There are " << CountHydrogenBridgeBonds(molecules, InterfaceElement) << " hydrogen bridges with connections to " << (InterfaceElement != 0 ? InterfaceElement->name : "None") << "." << endl;
    1226       }
    1227       break;
    1228 
    1229     case 'm':
    1230       {
    1231         int nr;
    1232         molecule *mol = NULL;
    1233         do {
    1234           DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into: ");
    1235           cin >> nr;
    1236           mol = molecules->ReturnIndex(nr);
    1237         } while ((mol == NULL) && (nr != -1));
    1238         if (nr != -1) {
    1239           int N = molecules->ListOfMolecules.size()-1;
    1240           int *src = new int(N);
    1241           for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    1242             if ((*ListRunner)->IndexNr != nr)
    1243               src[N++] = (*ListRunner)->IndexNr;       
    1244           molecules->SimpleMultiMerge(mol, src, N);
    1245           delete[](src);
    1246         }
    1247       }
    1248       break;
    1249 
    1250     case 's':
    1251       DoLog(0) && (Log() << Verbose(0) << "Not implemented yet." << endl);
    1252       break;
    1253 
    1254     case 't':
    1255       {
    1256         int src, dest;
    1257         molecule *srcmol = NULL, *destmol = NULL;
    1258         {
    1259           do {
    1260             DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: ");
    1261             cin >> dest;
    1262             destmol = molecules->ReturnIndex(dest);
    1263           } while ((destmol == NULL) && (dest != -1));
    1264           do {
    1265             DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to merge into: ");
    1266             cin >> src;
    1267             srcmol = molecules->ReturnIndex(src);
    1268           } while ((srcmol == NULL) && (src != -1));
    1269           if ((src != -1) && (dest != -1))
    1270             molecules->SimpleMerge(srcmol, destmol);
    1271         }
    1272       }
    1273       break;
    1274   }
    1275 };
    1276 
    1277 /********************************************** Test routine **************************************/
    1278 
    1279 /** Is called always as option 'T' in the menu.
    1280  * \param *molecules list of molecules
    1281  */
    1282 static void testroutine(MoleculeListClass *molecules)
    1283 {
    1284   // the current test routine checks the functionality of the KeySet&Graph concept:
    1285   // We want to have a multiindex (the KeySet) describing a unique subgraph
    1286   int i, comp, counter=0;
    1287 
    1288   // create a clone
    1289   molecule *mol = NULL;
    1290   if (molecules->ListOfMolecules.size() != 0) // clone
    1291     mol = (molecules->ListOfMolecules.front())->CopyMolecule();
    1292   else {
    1293     DoeLog(0) && (eLog()<< Verbose(0) << "I don't have anything to test on ... ");
    1294     performCriticalExit();
    1295     return;
    1296   }
    1297   atom *Walker = mol->start;
    1298 
    1299   // generate some KeySets
    1300   DoLog(0) && (Log() << Verbose(0) << "Generating KeySets." << endl);
    1301   KeySet TestSets[mol->getAtomCount()+1];
    1302   i=1;
    1303   while (Walker->next != mol->end) {
    1304     Walker = Walker->next;
    1305     for (int j=0;j<i;j++) {
    1306       TestSets[j].insert(Walker->nr);
    1307     }
    1308     i++;
    1309   }
    1310   DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl);
    1311   KeySetTestPair test;
    1312   test = TestSets[mol->getAtomCount()-1].insert(Walker->nr);
    1313   if (test.second) {
    1314     DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
    1315   } else {
    1316     DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl);
    1317   }
    1318   TestSets[mol->getAtomCount()].insert(mol->end->previous->nr);
    1319   TestSets[mol->getAtomCount()].insert(mol->end->previous->previous->previous->nr);
    1320 
    1321   // constructing Graph structure
    1322   DoLog(0) && (Log() << Verbose(0) << "Generating Subgraph class." << endl);
    1323   Graph Subgraphs;
    1324 
    1325   // insert KeySets into Subgraphs
    1326   DoLog(0) && (Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl);
    1327   for (int j=0;j<mol->getAtomCount();j++) {
    1328     Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
    1329   }
    1330   DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl);
    1331   GraphTestPair test2;
    1332   test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.)));
    1333   if (test2.second) {
    1334     DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
    1335   } else {
    1336     DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl);
    1337   }
    1338 
    1339   // show graphs
    1340   DoLog(0) && (Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl);
    1341   Graph::iterator A = Subgraphs.begin();
    1342   while (A !=  Subgraphs.end()) {
    1343     DoLog(0) && (Log() << Verbose(0) << (*A).second.first << ": ");
    1344     KeySet::iterator key = (*A).first.begin();
    1345     comp = -1;
    1346     while (key != (*A).first.end()) {
    1347       if ((*key) > comp)
    1348         DoLog(0) && (Log() << Verbose(0) << (*key) << " ");
    1349       else
    1350         DoLog(0) && (Log() << Verbose(0) << (*key) << "! ");
    1351       comp = (*key);
    1352       key++;
    1353     }
    1354     DoLog(0) && (Log() << Verbose(0) << endl);
    1355     A++;
    1356   }
    1357   delete(mol);
    1358 };
    1359 
    1360 #endif
    1361 
    1362 /** Tries given filename or standard on saving the config file.
    1363  * \param *ConfigFileName name of file
    1364  * \param *configuration pointer to configuration structure with all the values
    1365  * \param *periode pointer to periodentafel structure with all the elements
    1366  * \param *molecules list of molecules structure with all the atoms and coordinates
    1367  */
    1368 static void SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, MoleculeListClass *molecules)
    1369 {
    1370   char filename[MAXSTRINGSIZE];
    1371   ofstream output;
    1372   molecule *mol = World::getInstance().createMolecule();
    1373   mol->SetNameFromFilename(ConfigFileName);
    1374 
    1375   if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
    1376     DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);
    1377   }
    1378 
    1379 
    1380   // first save as PDB data
    1381   if (ConfigFileName != NULL)
    1382     strcpy(filename, ConfigFileName);
    1383   if (output == NULL)
    1384     strcpy(filename,"main_pcp_linux");
    1385   DoLog(0) && (Log() << Verbose(0) << "Saving as pdb input ");
    1386   if (configuration->SavePDB(filename, molecules))
    1387     DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    1388   else
    1389     DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    1390 
    1391   // then save as tremolo data file
    1392   if (ConfigFileName != NULL)
    1393     strcpy(filename, ConfigFileName);
    1394   if (output == NULL)
    1395     strcpy(filename,"main_pcp_linux");
    1396   DoLog(0) && (Log() << Verbose(0) << "Saving as tremolo data input ");
    1397   if (configuration->SaveTREMOLO(filename, molecules))
    1398     DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    1399   else
    1400     DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    1401 
    1402   // translate each to its center and merge all molecules in MoleculeListClass into this molecule
    1403   int N = molecules->ListOfMolecules.size();
    1404   int *src = new int[N];
    1405   N=0;
    1406   for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
    1407     src[N++] = (*ListRunner)->IndexNr;
    1408     (*ListRunner)->Translate(&(*ListRunner)->Center);
    1409   }
    1410   molecules->SimpleMultiAdd(mol, src, N);
    1411   delete[](src);
    1412 
    1413   // ... and translate back
    1414   for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
    1415     (*ListRunner)->Center.Scale(-1.);
    1416     (*ListRunner)->Translate(&(*ListRunner)->Center);
    1417     (*ListRunner)->Center.Scale(-1.);
    1418   }
    1419 
    1420   DoLog(0) && (Log() << Verbose(0) << "Storing configuration ... " << endl);
    1421   // get correct valence orbitals
    1422   mol->CalculateOrbitals(*configuration);
    1423   configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble;
    1424   if (ConfigFileName != NULL) { // test the file name
    1425     strcpy(filename, ConfigFileName);
    1426     output.open(filename, ios::trunc);
    1427   } else if (strlen(configuration->configname) != 0) {
    1428     strcpy(filename, configuration->configname);
    1429     output.open(configuration->configname, ios::trunc);
    1430     } else {
    1431       strcpy(filename, DEFAULTCONFIG);
    1432       output.open(DEFAULTCONFIG, ios::trunc);
    1433     }
    1434   output.close();
    1435   output.clear();
    1436   DoLog(0) && (Log() << Verbose(0) << "Saving of config file ");
    1437   if (configuration->Save(filename, periode, mol))
    1438     DoLog(0) && (Log() << Verbose(0) << "successful." << endl);
    1439   else
    1440     DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    1441 
    1442   // and save to xyz file
    1443   if (ConfigFileName != NULL) {
    1444     strcpy(filename, ConfigFileName);
    1445     strcat(filename, ".xyz");
    1446     output.open(filename, ios::trunc);
    1447   }
    1448   if (output == NULL) {
    1449     strcpy(filename,"main_pcp_linux");
    1450     strcat(filename, ".xyz");
    1451     output.open(filename, ios::trunc);
    1452   }
    1453   DoLog(0) && (Log() << Verbose(0) << "Saving of XYZ file ");
    1454   if (mol->MDSteps <= 1) {
    1455     if (mol->OutputXYZ(&output))
    1456       DoLog(0) && (Log() << Verbose(0) << "successful." << endl);
    1457     else
    1458       DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    1459   } else {
    1460     if (mol->OutputTrajectoriesXYZ(&output))
    1461       DoLog(0) && (Log() << Verbose(0) << "successful." << endl);
    1462     else
    1463       DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    1464   }
    1465   output.close();
    1466   output.clear();
    1467 
    1468   // and save as MPQC configuration
    1469   if (ConfigFileName != NULL)
    1470     strcpy(filename, ConfigFileName);
    1471   if (output == NULL)
    1472     strcpy(filename,"main_pcp_linux");
    1473   DoLog(0) && (Log() << Verbose(0) << "Saving as mpqc input ");
    1474   if (configuration->SaveMPQC(filename, mol))
    1475     DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    1476   else
    1477     DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    1478 
    1479   if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
    1480     DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);
    1481   }
    1482 
    1483   World::getInstance().destroyMolecule(mol);
    1484 };
    1485 
    1486 /** Parses the command line options.
    1487  * Note that this function is from now on transitional. All commands that are not passed
    1488  * here are handled by CommandLineParser and the actions of CommandLineUIFactory.
    1489  * \param argc argument count
    1490  * \param **argv arguments array
    1491  * \param *molecules list of molecules structure
    1492  * \param *periode elements structure
    1493  * \param configuration config file structure
    1494  * \param *ConfigFileName pointer to config file name in **argv
    1495  * \param *PathToDatabases pointer to db's path in **argv
    1496  * \param &ArgcList list of arguments that we do not parse here
    1497  * \return exit code (0 - successful, all else - something's wrong)
    1498  */
    1499 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode,
    1500                                    config& configuration, char **ConfigFileName, set<int> &ArgcList)
    1501 {
    1502   Vector x,y,z,n;  // coordinates for absolute point in cell volume
    1503   double *factor; // unit factor if desired
    1504   ifstream test;
    1505   ofstream output;
    1506   string line;
    1507   atom *first;
    1508   bool SaveFlag = false;
    1509   int ExitFlag = 0;
    1510   int j;
    1511   double volume = 0.;
    1512   enum ConfigStatus configPresent = absent;
    1513   clock_t start,end;
    1514   double MaxDistance = -1;
    1515   int argptr;
    1516   molecule *mol = NULL;
    1517   string BondGraphFileName("\n");
    1518   bool DatabasePathGiven = false;
    1519 
    1520   if (argc > 1) { // config file specified as option
    1521     // 1. : Parse options that just set variables or print help
    1522     argptr = 1;
    1523     do {
    1524       if (argv[argptr][0] == '-') {
    1525         DoLog(0) && (Log() << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n");
    1526         argptr++;
    1527         switch(argv[argptr-1][1]) {
    1528           case 'h':
    1529           case 'H':
    1530           case '?':
    1531             ArgcList.insert(argptr-1);
    1532             return(1);
    1533             break;
    1534           case 'v':
    1535             if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1536               DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying verbosity: -v <level>" << endl);
    1537               performCriticalExit();
    1538             } else {
    1539               setVerbosity(atoi(argv[argptr]));
    1540               ArgcList.insert(argptr-1);
    1541               ArgcList.insert(argptr);
    1542               argptr++;
    1543             }
    1544             break;
    1545           case 'V':
    1546             ArgcList.insert(argptr-1);
    1547             return(1);
    1548             break;
    1549           case 'B':
    1550             if (ExitFlag == 0) ExitFlag = 1;
    1551             if ((argptr+5 >= argc)) {
    1552               DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for setting Box: -B <xx> <<xy> <<xz> <yy> <yz> <zz>" << endl);
    1553               performCriticalExit();
    1554             } else {
    1555               ArgcList.insert(argptr-1);
    1556               ArgcList.insert(argptr);
    1557               ArgcList.insert(argptr+1);
    1558               ArgcList.insert(argptr+2);
    1559               ArgcList.insert(argptr+3);
    1560               ArgcList.insert(argptr+4);
    1561               ArgcList.insert(argptr+5);
    1562               argptr+=6;
    1563             }
    1564             break;
    1565           case 'e':
    1566             if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1567               DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl);
    1568               performCriticalExit();
    1569             } else {
    1570               ArgcList.insert(argptr-1);
    1571               ArgcList.insert(argptr);
    1572               argptr+=1;
    1573             }
    1574             break;
    1575           case 'g':
    1576             if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1577               DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying bond length table: -g <table file>" << endl);
    1578               performCriticalExit();
    1579             } else {
    1580               ArgcList.insert(argptr-1);
    1581               ArgcList.insert(argptr);
    1582               argptr+=1;
    1583             }
    1584             break;
    1585           case 'M':
    1586             if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1587               ExitFlag = 255;
    1588               DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -M <basis name>" << endl);
    1589               performCriticalExit();
    1590             } else {
    1591               ArgcList.insert(argptr-1);
    1592               ArgcList.insert(argptr);
    1593               argptr+=1;
    1594             }
    1595             break;
    1596           case 'n':
    1597             if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1598               ExitFlag = 255;
    1599               DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting fast-parsing: -n <0/1>" << endl);
    1600               performCriticalExit();
    1601             } else {
    1602               ArgcList.insert(argptr-1);
    1603               ArgcList.insert(argptr);
    1604               argptr+=1;
    1605             }
    1606             break;
    1607           case 'X':
    1608             if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1609               ExitFlag = 255;
    1610               DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting default molecule name: -X <name>" << endl);
    1611               performCriticalExit();
    1612             } else {
    1613               ArgcList.insert(argptr-1);
    1614               ArgcList.insert(argptr);
    1615               argptr+=1;
    1616             }
    1617             break;
    1618           default:   // no match? Step on
    1619             argptr++;
    1620             break;
    1621         }
    1622       } else
    1623         argptr++;
    1624     } while (argptr < argc);
    1625 
    1626     // 3b. Find config file name and parse if possible, also BondGraphFileName
    1627     if (argv[1][0] != '-') {
    1628       // simply create a new molecule, wherein the config file is loaded and the manipulation takes place
    1629       DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl);
    1630       test.open(argv[1], ios::in);
    1631       if (test == NULL) {
    1632         //return (1);
    1633         output.open(argv[1], ios::out);
    1634         if (output == NULL) {
    1635           DoLog(1) && (Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl);
    1636           configPresent = absent;
    1637         } else {
    1638           DoLog(0) && (Log() << Verbose(0) << "Empty configuration file." << endl);
    1639           strcpy(*ConfigFileName, argv[1]);
    1640           configPresent = empty;
    1641           output.close();
    1642         }
    1643       } else {
    1644         test.close();
    1645         strcpy(*ConfigFileName, argv[1]);
    1646         DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
    1647         switch (configuration.TestSyntax(*ConfigFileName, periode)) {
    1648           case 1:
    1649             DoLog(0) && (Log() << Verbose(0) << "new syntax." << endl);
    1650             configuration.Load(*ConfigFileName, BondGraphFileName, periode, molecules);
    1651             configPresent = present;
    1652             break;
    1653           case 0:
    1654             DoLog(0) && (Log() << Verbose(0) << "old syntax." << endl);
    1655             configuration.LoadOld(*ConfigFileName, BondGraphFileName, periode, molecules);
    1656             configPresent = present;
    1657             break;
    1658           default:
    1659             DoLog(0) && (Log() << Verbose(0) << "Unknown syntax or empty, yet present file." << endl);
    1660             configPresent = empty;
    1661        }
    1662       }
    1663     } else
    1664       configPresent = absent;
    1665      // set mol to first active molecule
    1666      if (molecules->ListOfMolecules.size() != 0) {
    1667        for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    1668          if ((*ListRunner)->ActiveFlag) {
    1669            mol = *ListRunner;
    1670            break;
    1671          }
    1672      }
    1673      if (mol == NULL) {
    1674        mol = World::getInstance().createMolecule();
    1675        mol->ActiveFlag = true;
    1676        if (*ConfigFileName != NULL)
    1677          mol->SetNameFromFilename(*ConfigFileName);
    1678        molecules->insert(mol);
    1679      }
    1680 
    1681     // 4. parse again through options, now for those depending on elements db and config presence
    1682     argptr = 1;
    1683     do {
    1684       DoLog(0) && (Log() << Verbose(0) << "Current Command line argument: " << argv[argptr] << "." << endl);
    1685       if (argv[argptr][0] == '-') {
    1686         argptr++;
    1687         if ((configPresent == present) || (configPresent == empty)) {
    1688           switch(argv[argptr-1][1]) {
    1689             case 'p':
    1690               if (ExitFlag == 0) ExitFlag = 1;
    1691               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1692                 ExitFlag = 255;
    1693                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough arguments for parsing: -p <xyz file>" << endl);
    1694                 performCriticalExit();
    1695               } else {
    1696                 SaveFlag = true;
    1697                 DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);
    1698                 if (!mol->AddXYZFile(argv[argptr]))
    1699                   DoLog(2) && (Log() << Verbose(2) << "File not found." << endl);
    1700                 else {
    1701                   DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl);
    1702                   configPresent = present;
    1703                 }
    1704               }
    1705               break;
    1706             case 'a':
    1707               if (ExitFlag == 0) ExitFlag = 1;
    1708               if ((argptr+4 >= argc) || (argv[argptr][0] == '-')) {
    1709                 ExitFlag = 255;
    1710                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough arguments for adding atom: -a <Z> --position <x> <y> <z>" << endl);
    1711                 performCriticalExit();
    1712               } else {
    1713                 ArgcList.insert(argptr-1);
    1714                 ArgcList.insert(argptr);
    1715                 ArgcList.insert(argptr+1);
    1716                 ArgcList.insert(argptr+2);
    1717                 ArgcList.insert(argptr+3);
    1718                 ArgcList.insert(argptr+4);
    1719                 argptr+=5;
    1720               }
    1721               break;
    1722             default:   // no match? Don't step on (this is done in next switch's default)
    1723               break;
    1724           }
    1725         }
    1726         if (configPresent == present) {
    1727           switch(argv[argptr-1][1]) {
    1728             case 'D':
    1729               if (ExitFlag == 0) ExitFlag = 1;
    1730               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1731                 ExitFlag = 255;
    1732                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for depth-first-search analysis: -D <max. bond distance>" << endl);
    1733                 performCriticalExit();
    1734               } else {
    1735                 ArgcList.insert(argptr-1);
    1736                 ArgcList.insert(argptr);
    1737                 argptr+=1;
    1738               }
    1739               break;
    1740             case 'I':
    1741               DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
    1742               ArgcList.insert(argptr-1);
    1743               argptr+=0;
    1744               break;
    1745             case 'C':
    1746               {
    1747                 if (ExitFlag == 0) ExitFlag = 1;
    1748                 if ((argptr+11 >= argc)) {
    1749                   ExitFlag = 255;
    1750                   DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C[p] <type: E/P/S> [more params] <output> <bin output> <BinStart> <BinEnd>" << endl);
    1751                   performCriticalExit();
    1752                 } else {
    1753                   switch(argv[argptr][0]) {
    1754                     case 'E':
    1755                       ArgcList.insert(argptr-1);
    1756                       ArgcList.insert(argptr);
    1757                       ArgcList.insert(argptr+1);
    1758                       ArgcList.insert(argptr+2);
    1759                       ArgcList.insert(argptr+3);
    1760                       ArgcList.insert(argptr+4);
    1761                       ArgcList.insert(argptr+5);
    1762                       ArgcList.insert(argptr+6);
    1763                       ArgcList.insert(argptr+7);
    1764                       ArgcList.insert(argptr+8);
    1765                       ArgcList.insert(argptr+9);
    1766                       ArgcList.insert(argptr+10);
    1767                       ArgcList.insert(argptr+11);
    1768                       argptr+=12;
    1769                       break;
    1770 
    1771                     case 'P':
    1772                       ArgcList.insert(argptr-1);
    1773                       ArgcList.insert(argptr);
    1774                       ArgcList.insert(argptr+1);
    1775                       ArgcList.insert(argptr+2);
    1776                       ArgcList.insert(argptr+3);
    1777                       ArgcList.insert(argptr+4);
    1778                       ArgcList.insert(argptr+5);
    1779                       ArgcList.insert(argptr+6);
    1780                       ArgcList.insert(argptr+7);
    1781                       ArgcList.insert(argptr+8);
    1782                       ArgcList.insert(argptr+9);
    1783                       ArgcList.insert(argptr+10);
    1784                       ArgcList.insert(argptr+11);
    1785                       ArgcList.insert(argptr+12);
    1786                       ArgcList.insert(argptr+13);
    1787                       ArgcList.insert(argptr+14);
    1788                       argptr+=15;
    1789                       break;
    1790 
    1791                     case 'S':
    1792                       ArgcList.insert(argptr-1);
    1793                       ArgcList.insert(argptr);
    1794                       ArgcList.insert(argptr+1);
    1795                       ArgcList.insert(argptr+2);
    1796                       ArgcList.insert(argptr+3);
    1797                       ArgcList.insert(argptr+4);
    1798                       ArgcList.insert(argptr+5);
    1799                       ArgcList.insert(argptr+6);
    1800                       ArgcList.insert(argptr+7);
    1801                       ArgcList.insert(argptr+8);
    1802                       ArgcList.insert(argptr+9);
    1803                       ArgcList.insert(argptr+10);
    1804                       ArgcList.insert(argptr+11);
    1805                       ArgcList.insert(argptr+12);
    1806                       ArgcList.insert(argptr+13);
    1807                       ArgcList.insert(argptr+14);
    1808                       argptr+=15;
    1809                       break;
    1810 
    1811                     default:
    1812                       ExitFlag = 255;
    1813                       DoeLog(0) && (eLog()<< Verbose(0) << "Invalid type given for pair correlation analysis: -C <type: E/P/S> [more params] <output> <bin output>" << endl);
    1814                       performCriticalExit();
    1815                       break;
    1816                   }
    1817                 }
    1818                 break;
    1819               }
    1820             case 'E':
    1821               if (ExitFlag == 0) ExitFlag = 1;
    1822               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr]))) {
    1823                 ExitFlag = 255;
    1824                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> --element <Z>" << endl);
    1825                 performCriticalExit();
    1826               } else {
    1827                 ArgcList.insert(argptr-1);
    1828                 ArgcList.insert(argptr);
    1829                 ArgcList.insert(argptr+1);
    1830                 ArgcList.insert(argptr+2);
    1831                 argptr+=3;
    1832               }
    1833               break;
    1834             case 'F':
    1835               if (ExitFlag == 0) ExitFlag = 1;
    1836               if ((argptr+12 >= argc) || (argv[argptr][0] == '-')) {
    1837                 ExitFlag = 255;
    1838                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for filling with molecule: -F <filler xyz file> --MaxDistance <distance or -1> --distances <x> <y> <z>  --lengths <surface> <randatm> <randmol> --DoRotate <0/1>" << endl);
    1839                 performCriticalExit();
    1840               } else {
    1841                 ArgcList.insert(argptr-1);
    1842                 ArgcList.insert(argptr);
    1843                 ArgcList.insert(argptr+1);
    1844                 ArgcList.insert(argptr+2);
    1845                 ArgcList.insert(argptr+3);
    1846                 ArgcList.insert(argptr+4);
    1847                 ArgcList.insert(argptr+5);
    1848                 ArgcList.insert(argptr+6);
    1849                 ArgcList.insert(argptr+7);
    1850                 ArgcList.insert(argptr+8);
    1851                 ArgcList.insert(argptr+9);
    1852                 ArgcList.insert(argptr+10);
    1853                 ArgcList.insert(argptr+11);
    1854                 ArgcList.insert(argptr+12);
    1855                 argptr+=13;
    1856               }
    1857               break;
    1858             case 'A':
    1859               if (ExitFlag == 0) ExitFlag = 1;
    1860               if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) {
    1861                 ExitFlag =255;
    1862                 DoeLog(0) && (eLog()<< Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile> --molecule-by-id <molecule_id>" << endl);
    1863                 performCriticalExit();
    1864               } else {
    1865                 ArgcList.insert(argptr-1);
    1866                 ArgcList.insert(argptr);
    1867                 ArgcList.insert(argptr+1);
    1868                 ArgcList.insert(argptr+2);
    1869                 argptr+=3;
    1870               }
    1871               break;
    1872 
    1873             case 'J':
    1874               if (ExitFlag == 0) ExitFlag = 1;
    1875               if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) {
    1876                 ExitFlag =255;
    1877                 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of adjacency file: -J <path> --molecule-by-id <molecule_id>" << endl);
    1878                 performCriticalExit();
    1879               } else {
    1880                 ArgcList.insert(argptr-1);
    1881                 ArgcList.insert(argptr);
    1882                 ArgcList.insert(argptr+1);
    1883                 ArgcList.insert(argptr+2);
    1884                 argptr+=3;
    1885               }
    1886               break;
    1887 
    1888             case 'j':
    1889               if (ExitFlag == 0) ExitFlag = 1;
    1890               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1891                 ExitFlag =255;
    1892                 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of bonds file: -j <path> --molecule-by-id <molecule_id>" << endl);
    1893                 performCriticalExit();
    1894               } else {
    1895                 ArgcList.insert(argptr-1);
    1896                 ArgcList.insert(argptr);
    1897                 ArgcList.insert(argptr+1);
    1898                 ArgcList.insert(argptr+2);
    1899                 argptr+=3;
    1900               }
    1901               break;
    1902 
    1903             case 'N':
    1904               if (ExitFlag == 0) ExitFlag = 1;
    1905               if ((argptr+4 >= argc) || (argv[argptr][0] == '-')){
    1906                 ExitFlag = 255;
    1907                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -N <molecule_id> --sphere-radius <radius> --nonconvex-file <output prefix>" << endl);
    1908                 performCriticalExit();
    1909               } else {
    1910                 ArgcList.insert(argptr-1);
    1911                 ArgcList.insert(argptr);
    1912                 ArgcList.insert(argptr+1);
    1913                 ArgcList.insert(argptr+2);
    1914                 ArgcList.insert(argptr+3);
    1915                 ArgcList.insert(argptr+4);
    1916                 argptr+=5;
    1917               }
    1918               break;
    1919             case 'S':
    1920               if (ExitFlag == 0) ExitFlag = 1;
    1921               if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) {
    1922                 ExitFlag = 255;
    1923                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file> --molecule-by-id 0" << endl);
    1924                 performCriticalExit();
    1925               } else {
    1926                 ArgcList.insert(argptr-1);
    1927                 ArgcList.insert(argptr);
    1928                 ArgcList.insert(argptr+1);
    1929                 ArgcList.insert(argptr+2);
    1930                 argptr+=3;
    1931               }
    1932               break;
    1933             case 'L':
    1934               if (ExitFlag == 0) ExitFlag = 1;
    1935               if ((argptr+8 >= argc) || (argv[argptr][0] == '-')) {
    1936                 ExitFlag = 255;
    1937                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for linear interpolation: -L <prefix> --start-step <step0> --end-step <step1> --molecule-by-id 0 --id-mapping <0/1>" << endl);
    1938                 performCriticalExit();
    1939               } else {
    1940                 ArgcList.insert(argptr-1);
    1941                 ArgcList.insert(argptr);
    1942                 ArgcList.insert(argptr+1);
    1943                 ArgcList.insert(argptr+2);
    1944                 ArgcList.insert(argptr+3);
    1945                 ArgcList.insert(argptr+4);
    1946                 ArgcList.insert(argptr+5);
    1947                 ArgcList.insert(argptr+6);
    1948                 ArgcList.insert(argptr+7);
    1949                 ArgcList.insert(argptr+8);
    1950                 argptr+=9;
    1951               }
    1952               break;
    1953             case 'P':
    1954               if (ExitFlag == 0) ExitFlag = 1;
    1955               if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) {
    1956                 ExitFlag = 255;
    1957                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file> --molecule-by-id <molecule_id>" << endl);
    1958                 performCriticalExit();
    1959               } else {
    1960                 ArgcList.insert(argptr-1);
    1961                 ArgcList.insert(argptr);
    1962                 ArgcList.insert(argptr+1);
    1963                 ArgcList.insert(argptr+2);
    1964                 argptr+=3;
    1965               }
    1966               break;
    1967             case 'R':
    1968               if (ExitFlag == 0) ExitFlag = 1;
    1969               if ((argptr+4 >= argc) || (argv[argptr][0] == '-'))  {
    1970                 ExitFlag = 255;
    1971                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <distance> --position <x> <y> <z>" << endl);
    1972                 performCriticalExit();
    1973               } else {
    1974                 ArgcList.insert(argptr-1);
    1975                 ArgcList.insert(argptr);
    1976                 ArgcList.insert(argptr+1);
    1977                 ArgcList.insert(argptr+2);
    1978                 ArgcList.insert(argptr+3);
    1979                 ArgcList.insert(argptr+4);
    1980                 argptr+=5;
    1981               }
    1982               break;
    1983             case 't':
    1984               if (ExitFlag == 0) ExitFlag = 1;
    1985               if ((argptr+4 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    1986                 ExitFlag = 255;
    1987                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z> --molecule-by-id <molecule_id> --periodic <0/1>" << endl);
    1988                 performCriticalExit();
    1989               } else {
    1990                 ArgcList.insert(argptr-1);
    1991                 ArgcList.insert(argptr);
    1992                 ArgcList.insert(argptr+1);
    1993                 ArgcList.insert(argptr+2);
    1994                 ArgcList.insert(argptr+3);
    1995                 ArgcList.insert(argptr+4);
    1996                 ArgcList.insert(argptr+5);
    1997                 ArgcList.insert(argptr+6);
    1998                 argptr+=7;
    1999               }
    2000               break;
    2001             case 's':
    2002               if (ExitFlag == 0) ExitFlag = 1;
    2003               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    2004                 ExitFlag = 255;
    2005                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl);
    2006                 performCriticalExit();
    2007               } else {
    2008                 ArgcList.insert(argptr-1);
    2009                 ArgcList.insert(argptr);
    2010                 ArgcList.insert(argptr+1);
    2011                 ArgcList.insert(argptr+2);
    2012                 argptr+=3;
    2013               }
    2014               break;
    2015             case 'b':
    2016               if (ExitFlag == 0) ExitFlag = 1;
    2017               if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
    2018                 ExitFlag = 255;
    2019                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl);
    2020                 performCriticalExit();
    2021               } else {
    2022                 ArgcList.insert(argptr-1);
    2023                 ArgcList.insert(argptr);
    2024                 ArgcList.insert(argptr+1);
    2025                 ArgcList.insert(argptr+2);
    2026                 ArgcList.insert(argptr+3);
    2027                 ArgcList.insert(argptr+4);
    2028                 ArgcList.insert(argptr+5);
    2029                 argptr+=6;
    2030               }
    2031               break;
    2032             case 'B':
    2033               if (ExitFlag == 0) ExitFlag = 1;
    2034               if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
    2035                 ExitFlag = 255;
    2036                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl);
    2037                 performCriticalExit();
    2038               } else {
    2039                 ArgcList.insert(argptr-1);
    2040                 ArgcList.insert(argptr);
    2041                 ArgcList.insert(argptr+1);
    2042                 ArgcList.insert(argptr+2);
    2043                 ArgcList.insert(argptr+3);
    2044                 ArgcList.insert(argptr+4);
    2045                 ArgcList.insert(argptr+5);
    2046                 argptr+=6;
    2047               }
    2048               break;
    2049             case 'c':
    2050               if (ExitFlag == 0) ExitFlag = 1;
    2051               if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    2052                 ExitFlag = 255;
    2053                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl);
    2054                 performCriticalExit();
    2055               } else {
    2056                 ArgcList.insert(argptr-1);
    2057                 ArgcList.insert(argptr);
    2058                 ArgcList.insert(argptr+1);
    2059                 ArgcList.insert(argptr+2);
    2060                 argptr+=3;
    2061               }
    2062               break;
    2063             case 'O':
    2064               if (ExitFlag == 0) ExitFlag = 1;
    2065               ArgcList.insert(argptr-1);
    2066               argptr+=0;
    2067               break;
    2068             case 'r':
    2069               if (ExitFlag == 0) ExitFlag = 1;
    2070               if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])))  {
    2071                 ExitFlag = 255;
    2072                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -r <id>" << endl);
    2073                 performCriticalExit();
    2074               } else {
    2075                 ArgcList.insert(argptr-1);
    2076                 ArgcList.insert(argptr);
    2077                 argptr+=1;
    2078               }
    2079               break;
    2080             case 'f':
    2081               if (ExitFlag == 0) ExitFlag = 1;
    2082               if ((argptr+1 >= argc) || (argv[argptr][0] == '-')) {
    2083                 ExitFlag = 255;
    2084                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl);
    2085                 performCriticalExit();
    2086               } else {
    2087                 ArgcList.insert(argptr-1);
    2088                 ArgcList.insert(argptr);
    2089                 ArgcList.insert(argptr+1);
    2090                 ArgcList.insert(argptr+2);
    2091                 ArgcList.insert(argptr+3);
    2092                 ArgcList.insert(argptr+4);
    2093                 argptr+=5;
    2094               }
    2095               break;
    2096             case 'm':
    2097               if (ExitFlag == 0) ExitFlag = 1;
    2098               j = atoi(argv[argptr++]);
    2099               if ((j<0) || (j>1)) {
    2100                 DoeLog(1) && (eLog()<< Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl);
    2101                 j = 0;
    2102               }
    2103               if (j) {
    2104                 SaveFlag = true;
    2105                 DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
    2106                 mol->PrincipalAxisSystem((bool)j);
    2107               } else
    2108                 ArgcList.insert(argptr-1);
    2109                 argptr+=0;
    2110               break;
    2111             case 'o':
    2112               if (ExitFlag == 0) ExitFlag = 1;
    2113               if ((argptr+4 >= argc) || (argv[argptr][0] == '-')){
    2114                 ExitFlag = 255;
    2115                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <molecule_id> --output-file <output file> --output-file <binned output file>" << endl);
    2116                 performCriticalExit();
    2117               } else {
    2118                 ArgcList.insert(argptr-1);
    2119                 ArgcList.insert(argptr);
    2120                 ArgcList.insert(argptr+1);
    2121                 ArgcList.insert(argptr+2);
    2122                 ArgcList.insert(argptr+3);
    2123                 ArgcList.insert(argptr+4);
    2124                 argptr+=5;
    2125               }
    2126               break;
    2127             case 'U':
    2128               if (ExitFlag == 0) ExitFlag = 1;
    2129               if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) {
    2130                 ExitFlag = 255;
    2131                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl);
    2132                 performCriticalExit();
    2133               } else {
    2134                 volume = atof(argv[argptr++]);
    2135                 DoLog(0) && (Log() << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl);
    2136               }
    2137             case 'u':
    2138               if (ExitFlag == 0) ExitFlag = 1;
    2139               if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) ) {
    2140                 if (volume != -1)
    2141                   ExitFlag = 255;
    2142                   DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension: -u <density>" << endl);
    2143                   performCriticalExit();
    2144               } else {
    2145                 ArgcList.insert(argptr-1);
    2146                 ArgcList.insert(argptr);
    2147                 argptr+=1;
    2148               }
    2149               break;
    2150             case 'd':
    2151               if (ExitFlag == 0) ExitFlag = 1;
    2152               if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    2153                 ExitFlag = 255;
    2154                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl);
    2155                 performCriticalExit();
    2156               } else {
    2157                 ArgcList.insert(argptr-1);
    2158                 ArgcList.insert(argptr);
    2159                 ArgcList.insert(argptr+1);
    2160                 ArgcList.insert(argptr+2);
    2161                 argptr+=3;
    2162               }
    2163               break;
    2164             default:   // no match? Step on
    2165               if ((argptr < argc) && (argv[argptr][0] != '-')) // if it started with a '-' we've already made a step!
    2166                 argptr++;
    2167               break;
    2168           }
    2169         }
    2170       } else argptr++;
    2171     } while (argptr < argc);
    2172     if (SaveFlag)
    2173       configuration.SaveAll(*ConfigFileName, periode, molecules);
    2174   } else {  // no arguments, hence scan the elements db
    2175     if (periode->LoadPeriodentafel(configuration.databasepath))
    2176       DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
    2177     else
    2178       DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
    2179     configuration.RetrieveConfigPathAndName("main_pcp_linux");
    2180   }
    2181   return(ExitFlag);
    2182 };
    218392
    218493/********************************************** Main routine **************************************/
    218594
    218695void cleanUp(){
     96  FormatParserStorage::purgeInstance();
     97  ChangeTracker::purgeInstance();
    218798  World::purgeInstance();
    218899  logger::purgeInstance();
     
    2199110}
    2200111
     112void dumpMemory(){
     113  ofstream ost("molecuilder.memdump");
     114  Memory::dumpMemory(ost);
     115}
     116
    2201117int main(int argc, char **argv)
    2202118{
    2203     config *configuration = World::getInstance().getConfig();
    2204     // while we are non interactive, we want to abort from asserts
    2205     //ASSERT_DO(Assert::Abort);
    2206     molecule *mol = NULL;
    2207     Vector x, y, z, n;
    2208     ifstream test;
    2209     ofstream output;
    2210     string line;
    2211     char **Arguments = NULL;
    2212     int ArgcSize = 0;
    2213     int ExitFlag = 0;
    2214     bool ArgumentsCopied = false;
    2215     char *ConfigFileName = new char[MAXSTRINGSIZE];
     119  // while we are non interactive, we want to abort from asserts
     120  ASSERT_DO(Assert::Abort);
     121  ASSERT_HOOK(dumpMemory);
     122  string line;
     123  char **Arguments = NULL;
     124  int ArgcSize = 0;
     125  int ExitFlag = 0;
     126  bool ArgumentsCopied = false;
     127  std::string BondGraphFileName("\n");
    2216128
    2217     // print version check whether arguments are present at all
    2218     cout << ESPACKVersion << endl;
    2219     if (argc < 2) {
    2220       cout << "Obtain help with " << argv[0] << " -h." << endl;
    2221       cleanUp();
    2222       Memory::getState();
    2223       return(1);
     129  // print version check whether arguments are present at all
     130  cout << ESPACKVersion << endl;
     131
     132  setVerbosity(0);
     133  // need to init the history before any action is created
     134  ActionHistory::init();
     135
     136  // from this moment on, we need to be sure to deeinitialize in the correct order
     137  // this is handled by the cleanup function
     138  atexit(cleanUp);
     139
     140  // Parse command line options and if present create respective UI
     141  {
     142    // construct bond graph
     143    if (World::getInstance().getConfig()->BG == NULL) {
     144      World::getInstance().getConfig()->BG = new BondGraph(World::getInstance().getConfig()->GetIsAngstroem());
     145      if (World::getInstance().getConfig()->BG->LoadBondLengthTable(BondGraphFileName)) {
     146        DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
     147      } else {
     148        DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
     149      }
    2224150    }
    2225 
    2226 
    2227     setVerbosity(0);
    2228     // need to init the history before any action is created
    2229     ActionHistory::init();
    2230 
    2231     // In the interactive mode, we can leave the user the choice in case of error
    2232     ASSERT_DO(Assert::Ask);
    2233 
    2234     // from this moment on, we need to be sure to deeinitialize in the correct order
    2235     // this is handled by the cleanup function
    2236     atexit(cleanUp);
    2237 
    2238     // Parse command line options and if present create respective UI
    2239     {
    2240       set<int> ArgcList;
    2241       ArgcList.insert(0); // push back program!
    2242       ArgcList.insert(1); // push back config file name
    2243       // handle arguments by ParseCommandLineOptions()
    2244       ExitFlag = ParseCommandLineOptions(argc,argv,World::getInstance().getMolecules(),World::getInstance().getPeriode(),*World::getInstance().getConfig(), &ConfigFileName, ArgcList);
    2245       World::getInstance().setExitFlag(ExitFlag);
    2246       // copy all remaining arguments to a new argv
    2247       Arguments = new char *[ArgcList.size()];
    2248       cout << "The following arguments are handled by CommandLineParser: ";
    2249       for (set<int>::iterator ArgcRunner = ArgcList.begin(); ArgcRunner != ArgcList.end(); ++ArgcRunner) {
    2250         Arguments[ArgcSize] = new char[strlen(argv[*ArgcRunner])+2];
    2251         strcpy(Arguments[ArgcSize], argv[*ArgcRunner]);
    2252         cout << " " << argv[*ArgcRunner];
    2253         ArgcSize++;
    2254       }
    2255       cout << endl;
    2256       ArgumentsCopied = true;
    2257       // handle remaining arguments by CommandLineParser
     151    // handle remaining arguments by CommandLineParser
     152    if (argc>1) {
    2258153      MapOfActions::getInstance().AddOptionsToParser();
    2259154      map <std::string, std::string> ShortFormToActionMap = MapOfActions::getInstance().getShortFormToActionMap();
    2260       CommandLineParser::getInstance().Run(ArgcSize,Arguments, ShortFormToActionMap);
    2261       if (!CommandLineParser::getInstance().isEmpty()) {
    2262         DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl);
    2263         UIFactory::registerFactory(new CommandLineUIFactory::description());
    2264         UIFactory::makeUserInterface("CommandLine");
    2265       } else {
     155      CommandLineParser::getInstance().Run(argc,argv, ShortFormToActionMap);
     156      DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl);
     157      UIFactory::registerFactory(new CommandLineUIFactory::description());
     158      UIFactory::makeUserInterface("CommandLine");
     159    } else {
     160      // In the interactive mode, we can leave the user the choice in case of error
     161      ASSERT_DO(Assert::Ask);
     162      #ifdef USE_GUI_QT
     163        DoLog(0) && (Log() << Verbose(0) << "Setting UI to QT4." << endl);
     164        UIFactory::registerFactory(new QTUIFactory::description());
     165        UIFactory::makeUserInterface("QT4");
     166      #else
    2266167        DoLog(0) && (Log() << Verbose(0) << "Setting UI to Text." << endl);
     168        cout << ESPACKVersion << endl;
    2267169        UIFactory::registerFactory(new TextUIFactory::description());
    2268170        UIFactory::makeUserInterface("Text");
    2269       }
     171      #endif
    2270172    }
     173  }
    2271174
    2272     {
    2273       MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow();
    2274       mainWindow->display();
    2275       delete mainWindow;
    2276     }
     175  {
     176    MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow();
     177    mainWindow->display();
     178    delete mainWindow;
     179  }
    2277180
    2278     Log() << Verbose(0) << "Saving to " << ConfigFileName << "." << endl;
    2279     World::getInstance().getConfig()->SaveAll(ConfigFileName, World::getInstance().getPeriode(), World::getInstance().getMolecules());
     181  FormatParserStorage::getInstance().SaveAll();
     182  ChangeTracker::getInstance().saveStatus();
    2280183
    2281184  // free the new argv
     
    2285188    delete[](Arguments);
    2286189  }
    2287   delete[](ConfigFileName);
     190  //delete[](ConfigFileName);
    2288191
    2289192  ExitFlag = World::getInstance().getExitFlag();
  • src/config.cpp

    r06f4ef6 rb6da28  
    1010#include <cstring>
    1111
    12 #include "World.hpp"
    1312#include "atom.hpp"
    1413#include "bond.hpp"
     14#include "bondgraph.hpp"
    1515#include "config.hpp"
     16#include "ConfigFileBuffer.hpp"
    1617#include "element.hpp"
    1718#include "helpers.hpp"
    1819#include "info.hpp"
    1920#include "lists.hpp"
     21#include "verbose.hpp"
    2022#include "log.hpp"
    2123#include "molecule.hpp"
    22 #include "memoryallocator.hpp"
    2324#include "molecule.hpp"
    2425#include "periodentafel.hpp"
     26#include "ThermoStatContainer.hpp"
    2527#include "World.hpp"
    26 
    27 /******************************** Functions for class ConfigFileBuffer **********************/
    28 
    29 /** Structure containing compare function for Ion_Type sorting.
    30  */
    31 struct IonTypeCompare {
    32   bool operator()(const char* s1, const char *s2) const {
    33     char number1[8];
    34     char number2[8];
    35     const char *dummy1, *dummy2;
    36     //Log() << Verbose(0) << s1 << "  " << s2 << endl;
    37     dummy1 = strchr(s1, '_')+sizeof(char)*5;  // go just after "Ion_Type"
    38     dummy2 = strchr(dummy1, '_');
    39     strncpy(number1, dummy1, dummy2-dummy1); // copy the number
    40     number1[dummy2-dummy1]='\0';
    41     dummy1 = strchr(s2, '_')+sizeof(char)*5;  // go just after "Ion_Type"
    42     dummy2 = strchr(dummy1, '_');
    43     strncpy(number2, dummy1, dummy2-dummy1); // copy the number
    44     number2[dummy2-dummy1]='\0';
    45     if (atoi(number1) != atoi(number2))
    46       return (atoi(number1) < atoi(number2));
    47     else {
    48       dummy1 = strchr(s1, '_')+sizeof(char);
    49       dummy1 = strchr(dummy1, '_')+sizeof(char);
    50       dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t');
    51       strncpy(number1, dummy1, dummy2-dummy1); // copy the number
    52       number1[dummy2-dummy1]='\0';
    53       dummy1 = strchr(s2, '_')+sizeof(char);
    54       dummy1 = strchr(dummy1, '_')+sizeof(char);
    55       dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t');
    56       strncpy(number2, dummy1, dummy2-dummy1); // copy the number
    57       number2[dummy2-dummy1]='\0';
    58       return (atoi(number1) < atoi(number2));
    59     }
    60   }
    61 };
    62 
    63 /** Constructor for ConfigFileBuffer class.
    64  */
    65 ConfigFileBuffer::ConfigFileBuffer() : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)
    66 {
    67 };
    68 
    69 /** Constructor for ConfigFileBuffer class with filename to be parsed.
    70  * \param *filename file name
    71  */
    72 ConfigFileBuffer::ConfigFileBuffer(const char * const filename) : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)
    73 {
    74   ifstream *file = NULL;
    75   char line[MAXSTRINGSIZE];
    76 
    77   // prescan number of lines
    78   file= new ifstream(filename);
    79   if (file == NULL) {
    80     DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl);
    81     return;
    82   }
    83   NoLines = 0; // we're overcounting by one
    84   long file_position = file->tellg(); // mark current position
    85   do {
    86     file->getline(line, 256);
    87     NoLines++;
    88   } while (!file->eof());
    89   file->clear();
    90   file->seekg(file_position, ios::beg);
    91   DoLog(1) && (Log() << Verbose(1) << NoLines-1 << " lines were recognized." << endl);
    92 
    93   // allocate buffer's 1st dimension
    94   if (buffer != NULL) {
    95     DoeLog(1) && (eLog()<< Verbose(1) << "FileBuffer->buffer is not NULL!" << endl);
    96     return;
    97   } else
    98     buffer = new char *[NoLines];
    99 
    100   // scan each line and put into buffer
    101   int lines=0;
    102   int i;
    103   do {
    104     buffer[lines] = new char[MAXSTRINGSIZE];
    105     file->getline(buffer[lines], MAXSTRINGSIZE-1);
    106     i = strlen(buffer[lines]);
    107     buffer[lines][i] = '\n';
    108     buffer[lines][i+1] = '\0';
    109     lines++;
    110   } while((!file->eof()) && (lines < NoLines));
    111   DoLog(1) && (Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl);
    112 
    113   // close and exit
    114   file->close();
    115   file->clear();
    116   delete(file);
    117 }
    118 
    119 /** Destructor for ConfigFileBuffer class.
    120  */
    121 ConfigFileBuffer::~ConfigFileBuffer()
    122 {
    123   for(int i=0;i<NoLines;++i)
    124     delete[](buffer[i]);
    125   delete[](buffer);
    126   delete[](LineMapping);
    127 }
    128 
    129 
    130 /** Create trivial mapping.
    131  */
    132 void ConfigFileBuffer::InitMapping()
    133 {
    134   LineMapping = new int[NoLines];
    135   for (int i=0;i<NoLines;i++)
    136     LineMapping[i] = i;
    137 }
    138 
    139 /** Creates a mapping for the \a *FileBuffer's lines containing the Ion_Type keyword such that they are sorted.
    140  * \a *map on return contains a list of NoAtom entries such that going through the list, yields indices to the
    141  * lines in \a *FileBuffer in a sorted manner of the Ion_Type?_? keywords. We assume that ConfigFileBuffer::CurrentLine
    142  * points to first Ion_Type entry.
    143  * \param *FileBuffer pointer to buffer structure
    144  * \param NoAtoms of subsequent lines to look at
    145  */
    146 void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms)
    147 {
    148   map<const char *, int, IonTypeCompare> IonTypeLineMap;
    149   if (LineMapping == NULL) {
    150     DoeLog(0) && (eLog()<< Verbose(0) << "map pointer is NULL: " << LineMapping << endl);
    151     performCriticalExit();
    152     return;
    153   }
    154 
    155   // put all into hashed map
    156   for (int i=0; i<NoAtoms; ++i) {
    157     IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i));
    158   }
    159 
    160   // fill map
    161   int nr=0;
    162   for (map<const char *, int, IonTypeCompare>::iterator runner = IonTypeLineMap.begin(); runner != IonTypeLineMap.end(); ++runner) {
    163     if (CurrentLine+nr < NoLines)
    164       LineMapping[CurrentLine+(nr++)] = runner->second;
    165     else {
    166       DoeLog(0) && (eLog()<< Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl);
    167       performCriticalExit();
    168     }
    169   }
    170 }
     28#include "Matrix.hpp"
     29#include "Box.hpp"
    17130
    17231/************************************* Functions for class config ***************************/
     
    17433/** Constructor for config file class.
    17534 */
    176 config::config() : BG(NULL), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), configpath(NULL),
    177     configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), Thermostat(4), ThermostatImplemented(NULL),
    178     ThermostatNames(NULL), TempFrequency(2.5), alpha(0.), HooverMass(0.), TargetTemp(0.00095004455), ScaleTempStep(25),  mainname(NULL), defaultpath(NULL), pseudopotpath(NULL),
     35config::config() : BG(NULL), Thermostats(0), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1),
     36    configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL),
    17937    DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01),
    18038    VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7),
     
    18644  pseudopotpath = new char[MAXSTRINGSIZE];
    18745  databasepath = new char[MAXSTRINGSIZE];
    188   configpath = new char[MAXSTRINGSIZE];
    18946  configname = new char[MAXSTRINGSIZE];
     47  Thermostats = new ThermoStatContainer();
    19048  strcpy(mainname,"pcp");
    19149  strcpy(defaultpath,"not specified");
    19250  strcpy(pseudopotpath,"not specified");
    193   configpath[0]='\0';
    19451  configname[0]='\0';
    19552  basis = "3-21G";
    196 
    197   InitThermostats();
    19853};
    19954
     
    20661  delete[](pseudopotpath);
    20762  delete[](databasepath);
    208   delete[](configpath);
    20963  delete[](configname);
    210   delete[](ThermostatImplemented);
    211   for (int j=0;j<MaxThermostats;j++)
    212     delete[](ThermostatNames[j]);
    213   delete[](ThermostatNames);
     64  if (Thermostats != NULL)
     65    delete(Thermostats);
    21466
    21567  if (BG != NULL)
    21668    delete(BG);
    21769};
    218 
    219 /** Initialises variables in class config for Thermostats.
    220  */
    221 void config::InitThermostats()
    222 {
    223   ThermostatImplemented = new int[MaxThermostats];
    224   ThermostatNames = new char *[MaxThermostats];
    225   for (int j=0;j<MaxThermostats;j++)
    226     ThermostatNames[j] = new char[12];
    227 
    228   strcpy(ThermostatNames[0],"None");
    229   ThermostatImplemented[0] = 1;
    230   strcpy(ThermostatNames[1],"Woodcock");
    231   ThermostatImplemented[1] = 1;
    232   strcpy(ThermostatNames[2],"Gaussian");
    233   ThermostatImplemented[2] = 1;
    234   strcpy(ThermostatNames[3],"Langevin");
    235   ThermostatImplemented[3] = 1;
    236   strcpy(ThermostatNames[4],"Berendsen");
    237   ThermostatImplemented[4] = 1;
    238   strcpy(ThermostatNames[5],"NoseHoover");
    239   ThermostatImplemented[5] = 1;
    240 };
    241 
    242 /** Readin of Thermostat related values from parameter file.
    243  * \param *fb file buffer containing the config file
    244  */
    245 void config::ParseThermostats(class ConfigFileBuffer * const fb)
    246 {
    247   char * const thermo = new char[12];
    248   const int verbose = 0;
    249 
    250   // read desired Thermostat from file along with needed additional parameters
    251   if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {
    252     if (strcmp(thermo, ThermostatNames[0]) == 0) { // None
    253       if (ThermostatImplemented[0] == 1) {
    254         Thermostat = None;
    255       } else {
    256         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    257         Thermostat = None;
    258       }
    259     } else if (strcmp(thermo, ThermostatNames[1]) == 0) { // Woodcock
    260       if (ThermostatImplemented[1] == 1) {
    261         Thermostat = Woodcock;
    262         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency
    263       } else {
    264         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    265         Thermostat = None;
    266       }
    267     } else if (strcmp(thermo, ThermostatNames[2]) == 0) { // Gaussian
    268       if (ThermostatImplemented[2] == 1) {
    269         Thermostat = Gaussian;
    270         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate
    271       } else {
    272         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    273         Thermostat = None;
    274       }
    275     } else if (strcmp(thermo, ThermostatNames[3]) == 0) { // Langevin
    276       if (ThermostatImplemented[3] == 1) {
    277         Thermostat = Langevin;
    278         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma
    279         if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &alpha, 1, optional)) {
    280           DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl);
    281         } else {
    282           alpha = 1.;
    283         }
    284       } else {
    285         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    286         Thermostat = None;
    287       }
    288     } else if (strcmp(thermo, ThermostatNames[4]) == 0) { // Berendsen
    289       if (ThermostatImplemented[4] == 1) {
    290         Thermostat = Berendsen;
    291         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T
    292       } else {
    293         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    294         Thermostat = None;
    295       }
    296     } else if (strcmp(thermo, ThermostatNames[5]) == 0) { // Nose-Hoover
    297       if (ThermostatImplemented[5] == 1) {
    298         Thermostat = NoseHoover;
    299         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &HooverMass, 1, critical); // read Hoovermass
    300         alpha = 0.;
    301       } else {
    302         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    303         Thermostat = None;
    304       }
    305     } else {
    306       DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);
    307       Thermostat = None;
    308     }
    309   } else {
    310     if ((MaxOuterStep > 0) && (TargetTemp != 0))
    311       DoLog(2) && (Log() << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl);
    312     Thermostat = None;
    313   }
    314   delete[](thermo);
    315 };
    316 
    31770
    31871/** Displays menu for editing each entry of the config file.
     
    629382};
    630383
    631 /** Retrieves the path in the given config file name.
    632  * \param filename config file string
    633  */
    634 void config::RetrieveConfigPathAndName(const string filename)
    635 {
    636   char *ptr = NULL;
    637   char *buffer = new char[MAXSTRINGSIZE];
    638   strncpy(buffer, filename.c_str(), MAXSTRINGSIZE);
    639   int last = -1;
    640   for(last=MAXSTRINGSIZE;last--;) {
    641     if (buffer[last] == '/')
    642       break;
    643   }
    644   if (last == -1) { // no path in front, set to local directory.
    645     strcpy(configpath, "./");
    646     ptr = buffer;
    647   } else {
    648     strncpy(configpath, buffer, last+1);
    649     ptr = &buffer[last+1];
    650     if (last < 254)
    651       configpath[last+1]='\0';
    652   }
    653   strcpy(configname, ptr);
    654   DoLog(0) && (Log() << Verbose(0) << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl);
    655   delete[](buffer);
    656 };
    657 
    658 /** Initializes ConfigFileBuffer from a file.
    659  * \param *file input file stream being the opened config file
    660  * \param *FileBuffer pointer to FileBuffer on return, should point to NULL
    661  */
    662 void PrepareFileBuffer(const char * const filename, struct ConfigFileBuffer *&FileBuffer)
    663 {
    664   if (FileBuffer != NULL) {
    665     DoeLog(2) && (eLog()<< Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl);
    666     delete(FileBuffer);
    667   }
    668   FileBuffer = new ConfigFileBuffer(filename);
    669 
    670   FileBuffer->InitMapping();
    671 };
    672 
    673384/** Loads a molecule from a ConfigFileBuffer.
    674385 * \param *mol molecule to load
     
    864575  file->close();
    865576  delete(file);
    866   RetrieveConfigPathAndName(filename);
    867577
    868578  // ParseParameterFile
    869   struct ConfigFileBuffer *FileBuffer = NULL;
    870   PrepareFileBuffer(filename,FileBuffer);
     579  class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer(filename);
    871580
    872581  /* Oeffne Hauptparameterdatei */
     
    877586  int verbose = 0;
    878587 
     588  //TODO: This is actually sensible?: if (MaxOuterStep > 0)
    879589  ParseThermostats(FileBuffer);
    880590 
     
    941651  ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional);
    942652  ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional);
    943   ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional);
     653  ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(Thermostats->TargetTemp), 1, optional);
    944654  //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional);
    945655  if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional))
     
    971681  // Unit cell and magnetic field
    972682  ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */
    973   double * const cell_size = World::getInstance().getDomain();
     683  double * cell_size = new double[6];
    974684  cell_size[0] = BoxLength[0];
    975685  cell_size[1] = BoxLength[3];
     
    978688  cell_size[4] = BoxLength[7];
    979689  cell_size[5] = BoxLength[8];
     690  World::getInstance().setDomain(cell_size);
     691  delete cell_size;
    980692  //if (1) fprintf(stderr,"\n");
    981693
     
    1101813    return;
    1102814  }
    1103   RetrieveConfigPathAndName(filename);
    1104815  // ParseParameters
    1105816
     
    1150861  ParseForParameter(verbose,file,"VisOuterStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional);
    1151862  ParseForParameter(verbose,file,"VisSrcOuterStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional);
    1152   ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional);
    1153   ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional);
     863  ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &(Thermostats->TargetTemp), 1, optional);
     864  ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &(Thermostats->ScaleTempStep), 1, optional);
    1154865  config::EpsWannier = 1e-8;
    1155866
     
    1176887
    1177888  ParseForParameter(verbose,file, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */
    1178   double * const cell_size = World::getInstance().getDomain();
     889  double * cell_size = new double[6];
    1179890  cell_size[0] = BoxLength[0];
    1180891  cell_size[1] = BoxLength[3];
     
    1183894  cell_size[4] = BoxLength[7];
    1184895  cell_size[5] = BoxLength[8];
     896  World::getInstance().setDomain(cell_size);
     897  delete[] cell_size;
    1185898  if (1) fprintf(stderr,"\n");
    1186899  config::DoPerturbation = 0;
     
    13181031{
    13191032  bool result = true;
    1320   // bring MaxTypes up to date
    1321   mol->CountElements();
    1322   const double * const cell_size = World::getInstance().getDomain();
     1033  const Matrix &domain = World::getInstance().getDomain().getM();
    13231034  ofstream * const output = new ofstream(filename, ios::out);
    13241035  if (output != NULL) {
     
    13391050    *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl;
    13401051    *output << "DoConstrainedMD\t" << config::DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl;
    1341     *output << "Thermostat\t" << ThermostatNames[Thermostat] << "\t";
    1342     switch(Thermostat) {
     1052    *output << "Thermostat\t" << Thermostats->ThermostatNames[Thermostats->Thermostat] << "\t";
     1053    switch(Thermostats->Thermostat) {
    13431054      default:
    13441055      case None:
    13451056        break;
    13461057      case Woodcock:
    1347         *output << ScaleTempStep;
     1058        *output << Thermostats->ScaleTempStep;
    13481059        break;
    13491060      case Gaussian:
    1350         *output << ScaleTempStep;
     1061        *output << Thermostats->ScaleTempStep;
    13511062        break;
    13521063      case Langevin:
    1353         *output << TempFrequency << "\t" << alpha;
     1064        *output << Thermostats->TempFrequency << "\t" << Thermostats->alpha;
    13541065        break;
    13551066      case Berendsen:
    1356         *output << TempFrequency;
     1067        *output << Thermostats->TempFrequency;
    13571068        break;
    13581069      case NoseHoover:
    1359         *output << HooverMass;
     1070        *output << Thermostats->HooverMass;
    13601071        break;
    13611072    };
     
    13721083    *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl;
    13731084    *output << "OutSrcStep\t" << config::OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl;
    1374     *output << "TargetTemp\t" << config::TargetTemp << "\t# Target temperature" << endl;
     1085    *output << "TargetTemp\t" << Thermostats->TargetTemp << "\t# Target temperature" << endl;
    13751086    *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl;
    13761087    *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl;
     
    13911102    *output << endl;
    13921103    *output << "BoxLength\t\t\t# (Length of a unit cell)" << endl;
    1393     *output << cell_size[0] << "\t" << endl;
    1394     *output << cell_size[1] << "\t" << cell_size[2] << "\t" << endl;
    1395     *output << cell_size[3] << "\t" << cell_size[4] << "\t" << cell_size[5] << "\t" << endl;
     1104    *output << domain.at(0,0) << "\t" << endl;
     1105    *output << domain.at(1,0) << "\t" << domain.at(1,1) << "\t" << endl;
     1106    *output << domain.at(2,0) << "\t" << domain.at(2,1) << "\t" << domain.at(2,2) << "\t" << endl;
    13961107    // FIXME
    13971108    *output << endl;
     
    14251136    *output << "IsAngstroem\t" << config::IsAngstroem << "\t# 0 - Bohr, 1 - Angstroem" << endl;
    14261137    *output << "RelativeCoord\t" << config::RelativeCoord << "\t# whether ion coordinates are relative (1) or absolute (0)" << endl;
    1427     *output << "MaxTypes\t" << mol->ElementCount <<  "\t# maximum number of different ion types" << endl;
     1138    *output << "MaxTypes\t" << mol->getElementCount() <<  "\t# maximum number of different ion types" << endl;
    14281139    *output << endl;
    14291140    result = result && mol->Checkout(output);
     
    14831194    // output of atoms
    14841195    AtomNo = 0;
    1485     mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
     1196    mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo );
    14861197    delete(center);
    14871198    *output << "\t}" << endl;
     
    15251236    // output of atoms
    15261237    AtomNo = 0;
    1527     mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
     1238    mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo );
    15281239    delete(center);
    15291240    *output << "\t}" << endl;
     
    17841495  char filename[MAXSTRINGSIZE];
    17851496  ofstream output;
    1786   molecule *mol = World::getInstance().createMolecule();
    1787   mol->SetNameFromFilename(ConfigFileName);
    1788 
    1789   if (!strcmp(configpath, GetDefaultPath())) {
    1790     eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
    1791   }
    1792 
     1497  molecule *mol = NULL;
    17931498
    17941499  // first save as PDB data
     
    18161521  // translate each to its center and merge all molecules in MoleculeListClass into this molecule
    18171522  int N = molecules->ListOfMolecules.size();
    1818   int *src = new int[N];
    1819   N=0;
    1820   for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
    1821     src[N++] = (*ListRunner)->IndexNr;
    1822     (*ListRunner)->Translate(&(*ListRunner)->Center);
    1823   }
    1824   molecules->SimpleMultiAdd(mol, src, N);
    1825   delete[](src);
    1826 
    1827   // ... and translate back
    1828   for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
    1829     (*ListRunner)->Center.Scale(-1.);
    1830     (*ListRunner)->Translate(&(*ListRunner)->Center);
    1831     (*ListRunner)->Center.Scale(-1.);
     1523  if (N != 1) { // don't do anything in case of only one molecule (shifts mol ids otherwise)
     1524    int *src = new int[N];
     1525    N=0;
     1526    for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
     1527      src[N++] = (*ListRunner)->IndexNr;
     1528      (*ListRunner)->Translate(&(*ListRunner)->Center);
     1529    }
     1530    mol = World::getInstance().createMolecule();
     1531    mol->SetNameFromFilename(ConfigFileName);
     1532    molecules->SimpleMultiMerge(mol, src, N);
     1533    //mol->CalculateOrbitals(*this);
     1534    delete[](src);
     1535  } else {
     1536    if (!molecules->ListOfMolecules.empty()) {
     1537      mol = *(molecules->ListOfMolecules.begin());
     1538      mol->doCountAtoms();
     1539      //mol->CalculateOrbitals(*this);
     1540    } else {
     1541      DoeLog(1) && (eLog() << Verbose(1) << "There are no molecules to save!" << endl);
     1542    }
    18321543  }
    18331544
    18341545  Log() << Verbose(0) << "Storing configuration ... " << endl;
    18351546  // get correct valence orbitals
    1836   mol->CalculateOrbitals(*this);
    1837   InitMaxMinStopStep = MaxMinStopStep = MaxPsiDouble;
    18381547  if (ConfigFileName != NULL) { // test the file name
    18391548    strcpy(filename, ConfigFileName);
     
    18911600    Log() << Verbose(0) << "\t... failed." << endl;
    18921601
    1893   if (!strcmp(configpath, GetDefaultPath())) {
    1894     eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
    1895   }
    1896 
    1897   World::getInstance().destroyMolecule(mol);
     1602  // don't destroy molecule as it contains all our atoms
     1603  //World::getInstance().destroyMolecule(mol);
    18981604};
    18991605
     
    23402046  return (found); // true if found, false if not
    23412047}
     2048
     2049/** Reading of Thermostat related values from parameter file.
     2050 * \param *fb file buffer containing the config file
     2051 */
     2052void config::ParseThermostats(class ConfigFileBuffer * const fb)
     2053{
     2054  char * const thermo = new char[12];
     2055  const int verbose = 0;
     2056
     2057  // read desired Thermostat from file along with needed additional parameters
     2058  if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {
     2059    if (strcmp(thermo, Thermostats->ThermostatNames[0]) == 0) { // None
     2060      if (Thermostats->ThermostatImplemented[0] == 1) {
     2061        Thermostats->Thermostat = None;
     2062      } else {
     2063        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2064        Thermostats->Thermostat = None;
     2065      }
     2066    } else if (strcmp(thermo, Thermostats->ThermostatNames[1]) == 0) { // Woodcock
     2067      if (Thermostats->ThermostatImplemented[1] == 1) {
     2068        Thermostats->Thermostat = Woodcock;
     2069        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read scaling frequency
     2070      } else {
     2071        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2072        Thermostats->Thermostat = None;
     2073      }
     2074    } else if (strcmp(thermo, Thermostats->ThermostatNames[2]) == 0) { // Gaussian
     2075      if (Thermostats->ThermostatImplemented[2] == 1) {
     2076        Thermostats->Thermostat = Gaussian;
     2077        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read collision rate
     2078      } else {
     2079        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2080        Thermostats->Thermostat = None;
     2081      }
     2082    } else if (strcmp(thermo, Thermostats->ThermostatNames[3]) == 0) { // Langevin
     2083      if (Thermostats->ThermostatImplemented[3] == 1) {
     2084        Thermostats->Thermostat = Langevin;
     2085        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read gamma
     2086        if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &Thermostats->alpha, 1, optional)) {
     2087          DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << Thermostats->alpha << "." << endl);
     2088        } else {
     2089          Thermostats->alpha = 1.;
     2090        }
     2091      } else {
     2092        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2093        Thermostats->Thermostat = None;
     2094      }
     2095    } else if (strcmp(thermo, Thermostats->ThermostatNames[4]) == 0) { // Berendsen
     2096      if (Thermostats->ThermostatImplemented[4] == 1) {
     2097        Thermostats->Thermostat = Berendsen;
     2098        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read \tau_T
     2099      } else {
     2100        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2101        Thermostats->Thermostat = None;
     2102      }
     2103    } else if (strcmp(thermo, Thermostats->ThermostatNames[5]) == 0) { // Nose-Hoover
     2104      if (Thermostats->ThermostatImplemented[5] == 1) {
     2105        Thermostats->Thermostat = NoseHoover;
     2106        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->HooverMass, 1, critical); // read Hoovermass
     2107        Thermostats->alpha = 0.;
     2108      } else {
     2109        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2110        Thermostats->Thermostat = None;
     2111      }
     2112    } else {
     2113      DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);
     2114      Thermostats->Thermostat = None;
     2115    }
     2116  } else {
     2117    if ((Thermostats->TargetTemp != 0))
     2118      DoLog(2) && (Log() << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl);
     2119    Thermostats->Thermostat = None;
     2120  }
     2121  delete[](thermo);
     2122};
     2123
  • src/config.hpp

    r06f4ef6 rb6da28  
    2020#include <string>
    2121
    22 #include "bondgraph.hpp"
    23 
    2422/****************************************** forward declarations *****************************/
    2523
     24class BondGraph;
     25class ConfigFileBuffer;
    2626class molecule;
    2727class MoleculeListClass;
    2828class periodentafel;
     29class ThermoStatContainer;
    2930
    3031/********************************************** declarations *******************************/
    31 
    32 class ConfigFileBuffer {
    33   public:
    34     char **buffer;
    35     int *LineMapping;
    36     int CurrentLine;
    37     int NoLines;
    38 
    39     ConfigFileBuffer();
    40     ConfigFileBuffer(const char * const filename);
    41     ~ConfigFileBuffer();
    42 
    43     void InitMapping();
    44     void MapIonTypesInBuffer(const int NoAtoms);
    45 };
    4632
    4733/** The config file.
     
    5137  public:
    5238    class BondGraph *BG;
     39    class ThermoStatContainer *Thermostats;
    5340
    5441    int PsiType;
     
    6047    int ProcPEGamma;
    6148    int ProcPEPsi;
    62     char *configpath;
    6349    char *configname;
    6450    bool FastParsing;
     
    7056    int DoConstrainedMD;
    7157    int MaxOuterStep;
    72     int Thermostat;
    73     int *ThermostatImplemented;
    74     char **ThermostatNames;
    75     double TempFrequency;
    76     double alpha;
    77     double HooverMass;
    78     double TargetTemp;
    79     int ScaleTempStep;
    8058
    8159  private:
     
    138116  void Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList);
    139117  void LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList);
    140   void RetrieveConfigPathAndName(const string filename);
    141118  bool Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const;
    142119  bool SaveMPQC(const char * const filename, const molecule * const mol) const;
     
    152129  char *GetDefaultPath() const;
    153130  void SetDefaultPath(const char * const path);
    154   void InitThermostats();
    155131  void ParseThermostats(class ConfigFileBuffer * const fb);
    156132};
  • src/datacreator.cpp

    r06f4ef6 rb6da28  
    1212#include "helpers.hpp"
    1313#include "parser.hpp"
     14#include "verbose.hpp"
     15
     16#include <iomanip>
    1417
    1518//=========================== FUNCTIONS============================
  • src/datacreator.hpp

    r06f4ef6 rb6da28  
    1010using namespace std;
    1111
    12 #include <iostream>
     12#include <iosfwd>
    1313
    1414/****************************************** forward declarations *****************************/
  • src/defs.hpp

    r06f4ef6 rb6da28  
    8282#define STD_SEPERATOR_SPACER '-'
    8383
     84#define MOLECUILDER_NAME "Molecuilder"
     85
     86const extern unsigned int MAX_POOL_FRAGMENTATION;
     87const extern unsigned int MAX_FRAGMENTATION_SKIPS;
     88
    8489#endif /*DEFS_HPP_*/
  • src/element.cpp

    r06f4ef6 rb6da28  
    2626        next(NULL),
    2727        sort(NULL),
    28         No(-1),
    2928        Valence(0),
    3029        NoValenceOrbitals(0)
     
    7069  return string(symbol);
    7170}
     71
     72std::string element::getName() const{
     73  return string(name);
     74}
     75
     76std::ostream &operator<<(std::ostream &ost,const element &elem){
     77  ost << elem.getName() << "(" << elem.getNumber() << ")";
     78  return ost;
     79}
  • src/element.hpp

    r06f4ef6 rb6da28  
    1616#endif
    1717
    18 #include <iostream>
     18#include <iosfwd>
    1919#include <string>
    2020
     
    4141    element *next;  //!< next element in list
    4242    int *sort;      //!< sorc criteria
    43     int No;         //!< number of element set on periodentafel::Output()
    4443    double Valence;   //!< number of valence electrons for this element
    4544    int NoValenceOrbitals;  //!< number of valence orbitals, used for determining bond degree in molecule::CreateConnectmatrix()
     
    5352  atomicNumber_t getNumber() const;
    5453  std::string getSymbol() const;
     54  std::string getName() const;
    5555
    5656  //> print element entries to screen
     
    6161};
    6262
     63std::ostream &operator<<(std::ostream&,const element&);
    6364
    6465#endif /* ELEMENT_HPP_ */
  • src/ellipsoid.cpp

    r06f4ef6 rb6da28  
    2121#include "tesselation.hpp"
    2222#include "vector.hpp"
     23#include "Matrix.hpp"
    2324#include "verbose.hpp"
    2425
     
    3435  Vector helper, RefPoint;
    3536  double distance = -1.;
    36   double Matrix[NDIM*NDIM];
     37  Matrix Matrix;
    3738  double InverseLength[3];
    3839  double psi,theta,phi; // euler angles in ZX'Z'' convention
     
    5152  theta = EllipsoidAngle[1];
    5253  phi = EllipsoidAngle[2];
    53   Matrix[0] = cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi);
    54   Matrix[1] = -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi);
    55   Matrix[2] = sin(psi)*sin(theta);
    56   Matrix[3] = sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi);
    57   Matrix[4] = cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi);
    58   Matrix[5] = -cos(psi)*sin(theta);
    59   Matrix[6] = sin(theta)*sin(phi);
    60   Matrix[7] = sin(theta)*cos(phi);
    61   Matrix[8] = cos(theta);
    62   helper.MatrixMultiplication(Matrix);
     54  Matrix.set(0,0, cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi));
     55  Matrix.set(1,0, -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi));
     56  Matrix.set(2,0, sin(psi)*sin(theta));
     57  Matrix.set(0,1, sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi));
     58  Matrix.set(1,1, cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi));
     59  Matrix.set(2,1, -cos(psi)*sin(theta));
     60  Matrix.set(0,2, sin(theta)*sin(phi));
     61  Matrix.set(1,2, sin(theta)*cos(phi));
     62  Matrix.set(2,2, cos(theta));
     63  helper *= Matrix;
    6364  helper.ScaleAll(InverseLength);
    6465  //Log() << Verbose(4) << "Transformed RefPoint is at " << helper << "." << endl;
     
    7374  phi = -EllipsoidAngle[2];
    7475  helper.ScaleAll(EllipsoidLength);
    75   Matrix[0] = cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi);
    76   Matrix[1] = -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi);
    77   Matrix[2] = sin(psi)*sin(theta);
    78   Matrix[3] = sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi);
    79   Matrix[4] = cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi);
    80   Matrix[5] = -cos(psi)*sin(theta);
    81   Matrix[6] = sin(theta)*sin(phi);
    82   Matrix[7] = sin(theta)*cos(phi);
    83   Matrix[8] = cos(theta);
    84   helper.MatrixMultiplication(Matrix);
     76  Matrix.set(0,0, cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi));
     77  Matrix.set(1,0, -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi));
     78  Matrix.set(2,0, sin(psi)*sin(theta));
     79  Matrix.set(0,1, sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi));
     80  Matrix.set(1,1, cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi));
     81  Matrix.set(2,1, -cos(psi)*sin(theta));
     82  Matrix.set(0,2, sin(theta)*sin(phi));
     83  Matrix.set(1,2, sin(theta)*cos(phi));
     84  Matrix.set(2,2, cos(theta));
     85  helper *= Matrix;
    8586  //Log() << Verbose(4) << "Intersection is at " << helper << "." << endl;
    8687
  • src/errorlogger.cpp

    r06f4ef6 rb6da28  
    99
    1010#include <fstream>
     11#include <iostream>
    1112#include "errorlogger.hpp"
    1213#include "verbose.hpp"
  • src/errorlogger.hpp

    r06f4ef6 rb6da28  
    99#define ERRORLOGGER_HPP_
    1010
    11 #include <iostream>
     11#include <iosfwd>
    1212
    1313#include "Patterns/Singleton.hpp"
  • src/graph.cpp

    r06f4ef6 rb6da28  
    1313#include "config.hpp"
    1414#include "graph.hpp"
     15#include "verbose.hpp"
    1516#include "log.hpp"
    1617#include "molecule.hpp"
  • src/graph.hpp

    r06f4ef6 rb6da28  
    2727class molecule;
    2828
    29 class Graph;
    3029class SubGraph;
    3130class Node;
     
    3433/********************************************** definitions *********************************/
    3534
    36 #define NodeMap pair < int, class Node* >
    37 #define EdgeMap multimap < class Node*, class Edge* >
     35typedef std::pair < int, class Node* > NodeMap;
     36typedef std::multimap < class Node*, class Edge* > EdgeMap;
    3837
    39 #define KeyStack deque<int>
    40 #define KeySet set<int>
    41 #define NumberValuePair pair<int, double>
    42 #define Graph map <KeySet, NumberValuePair, KeyCompare >
    43 #define GraphPair pair <KeySet, NumberValuePair >
    44 #define KeySetTestPair pair<KeySet::iterator, bool>
    45 #define GraphTestPair pair<Graph::iterator, bool>
     38typedef std::deque<int> KeyStack;
     39typedef std::set<int> KeySet;
     40typedef std::pair<int, double> NumberValuePair;
    4641
    47 
    48 /******************************** Some small functions and/or structures **********************************/
    49 
     42// needed for definition of Graph and GraphTestPair
    5043struct KeyCompare
    5144{
    5245  bool operator() (const KeySet SubgraphA, const KeySet SubgraphB) const;
    5346};
     47
     48typedef std::map <KeySet, NumberValuePair, KeyCompare > Graph;
     49typedef std::pair <KeySet, NumberValuePair > GraphPair;
     50typedef std::pair<KeySet::iterator, bool> KeySetTestPair;
     51typedef std::pair<Graph::iterator, bool> GraphTestPair;
     52
     53
     54/******************************** Some small functions and/or structures **********************************/
    5455
    5556//bool operator < (KeySet SubgraphA, KeySet SubgraphB);   //note: this declaration is important, otherwise normal < is used (producing wrong order)
  • src/gslvector.cpp

    r06f4ef6 rb6da28  
    1010#include <cassert>
    1111#include <cmath>
     12#include <iostream>
    1213
    1314#include "gslvector.hpp"
    1415#include "defs.hpp"
    1516#include "vector.hpp"
     17#include "VectorContent.hpp"
    1618
    1719/** Constructor of class GSLVector.
     
    6971 */
    7072void GSLVector::SetFromVector(Vector &v){
    71   gsl_vector_memcpy (vector, v.get());
     73  gsl_vector_memcpy (vector, v.get()->content);
    7274}
    7375
  • src/gslvector.hpp

    r06f4ef6 rb6da28  
    1818#endif
    1919
    20 #include <iostream>
     20#include <iosfwd>
    2121#include <gsl/gsl_vector.h>
    2222
  • src/helpers.cpp

    r06f4ef6 rb6da28  
    88#include "helpers.hpp"
    99#include "Helpers/fast_functions.hpp"
     10#include "verbose.hpp"
    1011#include "log.hpp"
    11 #include "memoryusageobserver.hpp"
     12
     13#include <iostream>
    1214
    1315/********************************************** helpful functions *********************************/
     
    117119};
    118120
    119 /** Blows the 6-dimensional \a cell_size array up to a full NDIM by NDIM matrix.
    120  * \param *symm 6-dim array of unique symmetric matrix components
    121  * \return allocated NDIM*NDIM array with the symmetric matrix
    122  */
    123 double * ReturnFullMatrixforSymmetric(const double * const symm)
    124 {
    125   double *matrix = new double[NDIM * NDIM];
    126   matrix[0] = symm[0];
    127   matrix[1] = symm[1];
    128   matrix[2] = symm[3];
    129   matrix[3] = symm[1];
    130   matrix[4] = symm[2];
    131   matrix[5] = symm[4];
    132   matrix[6] = symm[3];
    133   matrix[7] = symm[4];
    134   matrix[8] = symm[5];
    135   return matrix;
    136 };
    137 
    138 /** Calculate the inverse of a 3x3 matrix.
    139  * \param *matrix NDIM_NDIM array
    140  */
    141 double * InverseMatrix( const double * const A)
    142 {
    143   double *B = new double[NDIM * NDIM];
    144   double detA = RDET3(A);
    145   double detAReci;
    146 
    147   for (int i=0;i<NDIM*NDIM;++i)
    148     B[i] = 0.;
    149   // calculate the inverse B
    150   if (fabs(detA) > MYEPSILON) {;  // RDET3(A) yields precisely zero if A irregular
    151     detAReci = 1./detA;
    152     B[0] =  detAReci*RDET2(A[4],A[5],A[7],A[8]);    // A_11
    153     B[1] = -detAReci*RDET2(A[1],A[2],A[7],A[8]);    // A_12
    154     B[2] =  detAReci*RDET2(A[1],A[2],A[4],A[5]);    // A_13
    155     B[3] = -detAReci*RDET2(A[3],A[5],A[6],A[8]);    // A_21
    156     B[4] =  detAReci*RDET2(A[0],A[2],A[6],A[8]);    // A_22
    157     B[5] = -detAReci*RDET2(A[0],A[2],A[3],A[5]);    // A_23
    158     B[6] =  detAReci*RDET2(A[3],A[4],A[6],A[7]);    // A_31
    159     B[7] = -detAReci*RDET2(A[0],A[1],A[6],A[7]);    // A_32
    160     B[8] =  detAReci*RDET2(A[0],A[1],A[3],A[4]);    // A_33
    161   }
    162   return B;
    163 };
    164 
    165 
    166 
    167121/** Comparison function for GSL heapsort on distances in two molecules.
    168122 * \param *a
  • src/helpers.hpp

    r06f4ef6 rb6da28  
    2020#include "defs.hpp"
    2121#include "log.hpp"
    22 #include "memoryallocator.hpp"
    2322
    2423/********************************************** definitions *********************************/
     
    5251bool IsValidNumber( const char *string);
    5352int CompareDoubles (const void * a, const void * b);
    54 double * ReturnFullMatrixforSymmetric(const double * const cell_size);
    55 double * InverseMatrix(const double * const A);
    5653void performCriticalExit();
    5754
     
    197194};
    198195
     196/************ struct to contain simple enumerations ***************/
     197template <class C>
     198struct enumeration{
     199  enumeration() : max(0) {}
     200  enumeration(unsigned int i) : max(i) {}
     201  enumeration(const enumeration &src) :
     202    there(src.there),
     203    back(src.back),
     204    max(src.max)
     205  {}
     206  enumeration &operator=(const enumeration &src){
     207    /* no self-assignment check needed */
     208    there = src.there;
     209    back = src.back;
     210    max = src.max;
     211    return *this;
     212  }
     213  void add(const C &value){
     214    if(!there.count(value)){
     215      there[value]=max;
     216      back[max++]=value;
     217    }
     218  }
     219  unsigned int getMax() const{
     220    return max;
     221  }
     222
     223  map<C,unsigned int> there;
     224  map<unsigned int,C> back;
     225private:
     226  unsigned int max;
     227};
     228
     229/***** A counter to generate sequential numbers *******************/
     230struct counter{
     231  inline counter() : count(0){};
     232  inline counter(int i) : count(i){};
     233  inline unsigned int operator()(){
     234    return count++;
     235  }
     236private:
     237  unsigned int count;
     238};
     239
     240template <class C,class ForwardIterator>
     241enumeration<C> enumerate(ForwardIterator first,ForwardIterator last){
     242  enumeration<C> res;
     243  for_each(first,last,bind1st(mem_fun(&enumeration<C>::add),&res));
     244  return res;
     245}
     246
    199247#endif /*HELPERS_HPP_*/
  • src/joiner.cpp

    r06f4ef6 rb6da28  
    1414#include "datacreator.hpp"
    1515#include "helpers.hpp"
    16 #include "memoryallocator.hpp"
    1716#include "parser.hpp"
    1817#include "periodentafel.hpp"
     18#include "verbose.hpp"
    1919
    2020//============================== MAIN =============================
  • src/linearsystemofequations.hpp

    r06f4ef6 rb6da28  
    66 */
    77
    8 using namespace std;
     8#ifndef LINEARSYSTEMSOFEQUATIONS_HPP
     9#define LINEARSYSTEMSOFEQUATIONS_HPP
    910
    1011/*********************************************** includes ***********************************/
     
    5556  bool IsSymmetric;
    5657};
     58
     59#endif /* LINEARSYSTEMSOFEQUATIONS_HPP */
  • src/linkedcell.cpp

    r06f4ef6 rb6da28  
    1010#include "helpers.hpp"
    1111#include "linkedcell.hpp"
     12#include "verbose.hpp"
    1213#include "log.hpp"
    1314#include "molecule.hpp"
     
    187188    N[i] = 0;
    188189  index = -1;
    189   max.Zero();
    190   min.Zero();
    191190};
    192191
     
    199198  for(int i=0;i<NDIM;i++)
    200199    status = status && ((n[i] >=0) && (n[i] < N[i]));
    201   if (!status)
    202   DoeLog(1) && (eLog()<< Verbose(1) << "indices are out of bounds!" << endl);
     200//  if (!status)
     201//    DoeLog(1) && (eLog()<< Verbose(1) << "indices are out of bounds!" << endl);
    203202  return status;
    204203};
     
    279278
    280279/** Calculates the interval bounds of the linked cell grid.
    281  * \param *lower lower bounds
    282  * \param *upper upper bounds
     280 * \param lower lower bounds
     281 * \param upper upper bounds
    283282 * \param step how deep to check the neighbouring cells (i.e. number of layers to check)
    284283 */
     
    286285{
    287286  for (int i=0;i<NDIM;i++) {
    288     lower[i] = n[i];
    289     for (int s=step; s>0;--s)
    290       if ((n[i]-s) >= 0) {
    291         lower[i] = n[i]-s;
    292         break;
    293       }
    294     upper[i] = n[i];
    295     for (int s=step; s>0;--s)
    296       if ((n[i]+s) < N[i]) {
    297         upper[i] = n[i]+s;
    298         break;
    299       }
     287    lower[i] = n[i]-step;
     288    if (lower[i] < 0)
     289      lower[i] = 0;
     290    if (lower[i] >= N[i])
     291      lower[i] = N[i]-1;
     292    upper[i] = n[i]+step;
     293    if (upper[i] >= N[i])
     294      upper[i] = N[i]-1;
     295    if (upper[i] < 0)
     296      upper[i] = 0;
    300297    //Log() << Verbose(0) << "axis " << i << " has bounds [" << lower[i] << "," << upper[i] << "]" << endl;
    301298  }
  • src/log.hpp

    r06f4ef6 rb6da28  
    1212#include "logger.hpp"
    1313
    14 class logger * Log();
    15 class errorLogger * eLog();
     14class logger & Log();
     15class errorLogger & eLog();
    1616void setVerbosity(int verbosityLevel);
    1717bool DoLog(int verbose);
  • src/logger.cpp

    r06f4ef6 rb6da28  
    99
    1010#include <fstream>
     11#include <iostream>
    1112#include "logger.hpp"
    1213#include "verbose.hpp"
  • src/logger.hpp

    r06f4ef6 rb6da28  
    99#define LOGGER_HPP_
    1010
    11 #include <iostream>
     11#include <iosfwd>
    1212
    1313#include "Patterns/Singleton.hpp"
  • src/molecule.cpp

    r06f4ef6 rb6da28  
    55 */
    66
     7#ifdef HAVE_CONFIG_H
     8#include <config.h>
     9#endif
     10
    711#include "Helpers/MemDebug.hpp"
    812
    913#include <cstring>
    1014#include <boost/bind.hpp>
     15#include <boost/foreach.hpp>
     16
     17#include <gsl/gsl_inline.h>
     18#include <gsl/gsl_heapsort.h>
    1119
    1220#include "World.hpp"
     
    2230#include "log.hpp"
    2331#include "molecule.hpp"
    24 #include "memoryallocator.hpp"
     32
    2533#include "periodentafel.hpp"
    2634#include "stackclass.hpp"
    2735#include "tesselation.hpp"
    2836#include "vector.hpp"
     37#include "Matrix.hpp"
    2938#include "World.hpp"
     39#include "Box.hpp"
    3040#include "Plane.hpp"
    3141#include "Exceptions/LinearDependenceException.hpp"
     
    3949molecule::molecule(const periodentafel * const teil) :
    4050  Observable("molecule"),
    41   elemente(teil),  MDSteps(0),  BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0),
     51  elemente(teil),  MDSteps(0),  BondCount(0), NoNonHydrogen(0), NoNonBonds(0),
    4252  NoCyclicBonds(0), BondDistance(0.),  ActiveFlag(false), IndexNr(-1),
    43   formula(this,boost::bind(&molecule::calcFormula,this),"formula"),
    44   AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0),  InternalPointer(begin())
    45 {
    46 
    47   // other stuff
    48   for(int i=MAX_ELEMENTS;i--;)
    49     ElementsInMolecule[i] = 0;
     53  AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0),  InternalPointer(atoms.begin())
     54{
     55
    5056  strcpy(name,World::getInstance().getDefaultName().c_str());
    5157};
     
    7985void molecule::setName(const std::string _name){
    8086  OBSERVE;
     87  cout << "Set name of molecule " << getId() << " to " << _name << endl;
    8188  strncpy(name,_name.c_str(),MAXSTRINGSIZE);
    8289}
     
    9097}
    9198
    92 const std::string molecule::getFormula(){
    93   return *formula;
    94 }
    95 
    96 std::string molecule::calcFormula(){
    97   std::map<atomicNumber_t,unsigned int> counts;
    98   stringstream sstr;
    99   periodentafel *periode = World::getInstance().getPeriode();
    100   for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    101     counts[(*iter)->type->getNumber()]++;
    102   }
    103   std::map<atomicNumber_t,unsigned int>::reverse_iterator iter;
    104   for(iter = counts.rbegin(); iter != counts.rend(); ++iter) {
    105     atomicNumber_t Z = (*iter).first;
    106     sstr << periode->FindElement(Z)->symbol << (*iter).second;
    107   }
    108   return sstr.str();
     99const Formula &molecule::getFormula(){
     100  return formula;
     101}
     102
     103unsigned int molecule::getElementCount(){
     104  return formula.getElementCount();
     105}
     106
     107bool molecule::hasElement(const element *element) const{
     108  return formula.hasElement(element);
     109}
     110
     111bool molecule::hasElement(atomicNumber_t Z) const{
     112  return formula.hasElement(Z);
     113}
     114
     115bool molecule::hasElement(const string &shorthand) const{
     116  return formula.hasElement(shorthand);
    109117}
    110118
     
    143151molecule::const_iterator molecule::erase( const_iterator loc )
    144152{
     153  OBSERVE;
    145154  molecule::const_iterator iter = loc;
    146155  iter--;
    147156  atom* atom = *loc;
    148   atoms.erase( loc );
     157  atomIds.erase( atom->getId() );
     158  atoms.remove( atom );
     159  formula-=atom->type;
    149160  atom->removeFromMolecule();
    150161  return iter;
     
    153164molecule::const_iterator molecule::erase( atom * key )
    154165{
    155   cout << "trying to erase atom" << endl;
     166  OBSERVE;
    156167  molecule::const_iterator iter = find(key);
    157168  if (iter != end()){
    158     atoms.erase( iter++ );
     169    atomIds.erase( key->getId() );
     170    atoms.remove( key );
     171    formula-=key->type;
    159172    key->removeFromMolecule();
    160173  }
     
    164177molecule::const_iterator molecule::find ( atom * key ) const
    165178{
    166   return atoms.find( key );
     179  molecule::const_iterator iter;
     180  for (molecule::const_iterator Runner = begin(); Runner != end(); ++Runner) {
     181    if (*Runner == key)
     182      return molecule::const_iterator(Runner);
     183  }
     184  return molecule::const_iterator(atoms.end());
    167185}
    168186
    169187pair<molecule::iterator,bool> molecule::insert ( atom * const key )
    170188{
    171   pair<atomSet::iterator,bool> res = atoms.insert(key);
    172   return pair<iterator,bool>(iterator(res.first,this),res.second);
     189  OBSERVE;
     190  pair<atomIdSet::iterator,bool> res = atomIds.insert(key->getId());
     191  if (res.second) { // push atom if went well
     192    atoms.push_back(key);
     193    formula+=key->type;
     194    return pair<iterator,bool>(molecule::iterator(--end()),res.second);
     195  } else {
     196    return pair<iterator,bool>(molecule::iterator(end()),res.second);
     197  }
    173198}
    174199
    175200bool molecule::containsAtom(atom* key){
    176   return atoms.count(key);
     201  return (find(key) != end());
    177202}
    178203
     
    188213    pointer->sort = &pointer->nr;
    189214    if (pointer->type != NULL) {
    190       if (ElementsInMolecule[pointer->type->Z] == 0)
    191         ElementCount++;
    192       ElementsInMolecule[pointer->type->Z]++; // increase number of elements
     215      formula += pointer->type;
    193216      if (pointer->type->Z != 1)
    194217        NoNonHydrogen++;
     
    216239  if (pointer != NULL) {
    217240    atom *walker = pointer->clone();
     241    formula += walker->type;
    218242    walker->setName(pointer->getName());
    219243    walker->nr = last_atom++;  // increase number within molecule
     
    272296  Vector Orthovector1, Orthovector2;  // temporary vectors in coordination construction
    273297  Vector InBondvector;    // vector in direction of *Bond
    274   double *matrix = NULL;
     298  const Matrix &matrix =  World::getInstance().getDomain().getM();
    275299  bond *Binder = NULL;
    276   double * const cell_size = World::getInstance().getDomain();
    277300
    278301//  Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;
     
    295318      } // (signs are correct, was tested!)
    296319    }
    297     matrix = ReturnFullMatrixforSymmetric(cell_size);
    298     Orthovector1.MatrixMultiplication(matrix);
     320    Orthovector1 *= matrix;
    299321    InBondvector -= Orthovector1; // subtract just the additional translation
    300     delete[](matrix);
    301322    bondlength = InBondvector.Norm();
    302323//    Log() << Verbose(4) << "Corrected InBondvector is now: ";
     
    529550      break;
    530551  }
    531   delete[](matrix);
    532552
    533553//  Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;
     
    606626{
    607627  molecule *copy = World::getInstance().createMolecule();
    608   atom *LeftAtom = NULL, *RightAtom = NULL;
    609628
    610629  // copy all atoms
    611   ActOnCopyWithEachAtom ( &molecule::AddCopyAtom, copy );
     630  for_each(atoms.begin(),atoms.end(),bind1st(mem_fun(&molecule::AddCopyAtom),copy));
    612631
    613632  // copy all bonds
    614   bond *Binder = NULL;
    615   bond *NewBond = NULL;
    616633  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
    617634    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
    618635      if ((*BondRunner)->leftatom == *AtomRunner) {
    619         Binder = (*BondRunner);
     636        bond *Binder = (*BondRunner);
    620637
    621638        // get the pendant atoms of current bond in the copy molecule
    622         copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->leftatom, (const atom **)&LeftAtom );
    623         copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->rightatom, (const atom **)&RightAtom );
    624 
    625         NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree);
     639        atomSet::iterator leftiter=find_if(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::isFather),Binder->leftatom));
     640        atomSet::iterator rightiter=find_if(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::isFather),Binder->rightatom));
     641        ASSERT(leftiter!=atoms.end(),"No original left atom for bondcopy found");
     642        ASSERT(leftiter!=atoms.end(),"No original right atom for bondcopy found");
     643        atom *LeftAtom = *leftiter;
     644        atom *RightAtom = *rightiter;
     645
     646        bond *NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree);
    626647        NewBond->Cyclic = Binder->Cyclic;
    627648        if (Binder->Cyclic)
     
    630651      }
    631652  // correct fathers
    632   ActOnAllAtoms( &atom::CorrectFather );
     653  for_each(atoms.begin(),atoms.end(),mem_fun(&atom::CorrectFather));
    633654
    634655  // copy values
    635   copy->CountElements();
    636656  if (hasBondStructure()) {  // if adjaceny list is present
    637657    copy->BondDistance = BondDistance;
     
    648668 * @param three vectors forming the matrix that defines the shape of the parallelpiped
    649669 */
    650 molecule* molecule::CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const {
     670molecule* molecule::CopyMoleculeFromSubRegion(const Shape &region) const {
    651671  molecule *copy = World::getInstance().createMolecule();
    652672
    653   ActOnCopyWithEachAtomIfTrue ( &molecule::AddCopyAtom, copy, &atom::IsInParallelepiped, offset, parallelepiped );
     673  BOOST_FOREACH(atom *iter,atoms){
     674    if(iter->IsInShape(region)){
     675      copy->AddCopyAtom(iter);
     676    }
     677  }
    654678
    655679  //TODO: copy->BuildInducedSubgraph(this);
     
    728752  else
    729753    length = strlen(molname) - strlen(endname);
     754  cout << "Set name of molecule " << getId() << " to " << molname << endl;
    730755  strncpy(name, molname, length);
    731756  name[length]='\0';
     
    737762void molecule::SetBoxDimension(Vector *dim)
    738763{
    739   double * const cell_size = World::getInstance().getDomain();
    740   cell_size[0] = dim->at(0);
    741   cell_size[1] = 0.;
    742   cell_size[2] = dim->at(1);
    743   cell_size[3] = 0.;
    744   cell_size[4] = 0.;
    745   cell_size[5] = dim->at(2);
     764  Matrix domain;
     765  for(int i =0; i<NDIM;++i)
     766    domain.at(i,i) = dim->at(i);
     767  World::getInstance().setDomain(domain);
    746768};
    747769
     
    754776  ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom().");
    755777  OBSERVE;
    756   if (ElementsInMolecule[pointer->type->Z] != 0)  { // this would indicate an error
    757     ElementsInMolecule[pointer->type->Z]--;  // decrease number of atom of this element
    758   } else
    759     DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->getName() << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl);
    760   if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    761     ElementCount--;
     778  formula-=pointer->type;
    762779  RemoveBonds(pointer);
    763780  erase(pointer);
     
    773790  if (pointer == NULL)
    774791    return false;
    775   if (ElementsInMolecule[pointer->type->Z] != 0)  // this would indicate an error
    776     ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element
    777   else
    778     DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->getName() << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl);
    779   if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    780     ElementCount--;
     792  formula-=pointer->type;
    781793  erase(pointer);
    782794  return true;
     
    790802  for (molecule::iterator iter = begin(); !empty(); iter = begin())
    791803      erase(iter);
     804  return empty();
    792805};
    793806
     
    835848bool molecule::CheckBounds(const Vector *x) const
    836849{
    837   double * const cell_size = World::getInstance().getDomain();
     850  const Matrix &domain = World::getInstance().getDomain().getM();
    838851  bool result = true;
    839   int j =-1;
    840852  for (int i=0;i<NDIM;i++) {
    841     j += i+1;
    842     result = result && ((x->at(i) >= 0) && (x->at(i) < cell_size[j]));
     853    result = result && ((x->at(i) >= 0) && (x->at(i) < domain.at(i,i)));
    843854  }
    844855  //return result;
     
    849860 * \param *out output stream
    850861 */
    851 bool molecule::Output(ofstream * const output)
    852 {
    853   int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
    854   CountElements();
    855 
    856   for (int i=0;i<MAX_ELEMENTS;++i) {
    857     AtomNo[i] = 0;
    858     ElementNo[i] = 0;
    859   }
     862bool molecule::Output(ostream * const output)
     863{
    860864  if (output == NULL) {
    861865    return false;
    862866  } else {
     867    int AtomNo[MAX_ELEMENTS];
     868    memset(AtomNo,0,(MAX_ELEMENTS-1)*sizeof(*AtomNo));
     869    enumeration<const element*> elementLookup = formula.enumerateElements();
     870    for(map<const element*,unsigned int>::iterator iter=elementLookup.there.begin();
     871        iter!=elementLookup.there.end();++iter){
     872      cout << "Enumerated element " << *iter->first << " with number " << iter->second << endl;
     873    }
    863874    *output << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
    864     SetIndexedArrayForEachAtomTo ( ElementNo, &element::Z, &AbsoluteValue, 1);
    865     int current=1;
    866     for (int i=0;i<MAX_ELEMENTS;++i) {
    867       if (ElementNo[i] == 1)
    868         ElementNo[i] = current++;
    869     }
    870     ActOnAllAtoms( &atom::OutputArrayIndexed, output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );
     875    for_each(atoms.begin(),atoms.end(),boost::bind(&atom::OutputArrayIndexed,_1,output,elementLookup,AtomNo,(const char*)0));
    871876    return true;
    872877  }
     
    879884{
    880885  int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
    881   CountElements();
    882886
    883887  if (output == NULL) {
     
    912916{
    913917  DoLog(2) && (Log() << Verbose(2) << endl << "From Contents of ListOfBonds, all non-hydrogen atoms:" << endl);
    914   ActOnAllAtoms (&atom::OutputBondOfAtom );
     918  for_each(atoms.begin(),atoms.end(),mem_fun(&atom::OutputBondOfAtom));
    915919  DoLog(0) && (Log() << Verbose(0) << endl);
    916920};
     
    921925bool molecule::Checkout(ofstream * const output)  const
    922926{
    923   return elemente->Checkout(output, ElementsInMolecule);
     927  return formula.checkOut(output);
    924928};
    925929
     
    935939    for (int step=0;step<MDSteps;step++) {
    936940      *output << getAtomCount() << "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now);
    937       ActOnAllAtoms( &atom::OutputTrajectoryXYZ, output, step );
     941      for_each(atoms.begin(),atoms.end(),boost::bind(&atom::OutputTrajectoryXYZ,_1,output,step));
    938942    }
    939943    return true;
     
    952956    now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
    953957    *output << getAtomCount() << "\n\tCreated by molecuilder on " << ctime(&now);
    954     ActOnAllAtoms( &atom::OutputXYZLine, output );
     958    for_each(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::OutputXYZLine),output));
    955959    return true;
    956960  } else
     
    979983};
    980984
    981 /** Brings molecule::ElementCount and molecule::ElementsInMolecule up-to-date.
    982  */
    983 void molecule::CountElements()
    984 {
    985   for(int i=MAX_ELEMENTS;i--;)
    986     ElementsInMolecule[i] = 0;
    987   ElementCount = 0;
    988 
    989   SetIndexedArrayForEachAtomTo ( ElementsInMolecule, &element::Z, &Increment, 1);
    990 
    991   for(int i=MAX_ELEMENTS;i--;)
    992     ElementCount += (ElementsInMolecule[i] != 0 ? 1 : 0);
    993 };
    994 
    995 
    996 /** Counts necessary number of valence electrons and returns number and SpinType.
    997  * \param configuration containing everything
    998  */
    999 void molecule::CalculateOrbitals(class config &configuration)
    1000 {
    1001   configuration.MaxPsiDouble = configuration.PsiMaxNoDown = configuration.PsiMaxNoUp = configuration.PsiType = 0;
    1002   for(int i=MAX_ELEMENTS;i--;) {
    1003     if (ElementsInMolecule[i] != 0) {
    1004       //Log() << Verbose(0) << "CalculateOrbitals: " << elemente->FindElement(i)->name << " has a valence of " << (int)elemente->FindElement(i)->Valence << " and there are " << ElementsInMolecule[i] << " of it." << endl;
    1005       configuration.MaxPsiDouble += ElementsInMolecule[i]*((int)elemente->FindElement(i)->Valence);
    1006     }
    1007   }
    1008   configuration.PsiMaxNoDown = configuration.MaxPsiDouble/2 + (configuration.MaxPsiDouble % 2);
    1009   configuration.PsiMaxNoUp = configuration.MaxPsiDouble/2;
    1010   configuration.MaxPsiDouble /= 2;
    1011   configuration.PsiType = (configuration.PsiMaxNoDown == configuration.PsiMaxNoUp) ? 0 : 1;
    1012   if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2)) {
    1013     configuration.ProcPEGamma /= 2;
    1014     configuration.ProcPEPsi *= 2;
    1015   } else {
    1016     configuration.ProcPEGamma *= configuration.ProcPEPsi;
    1017     configuration.ProcPEPsi = 1;
    1018   }
    1019   configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.MaxPsiDouble;
    1020 };
    1021 
    1022985/** Determines whether two molecules actually contain the same atoms and coordination.
    1023986 * \param *out output stream for debugging
     
    10381001  /// first count both their atoms and elements and update lists thereby ...
    10391002  //Log() << Verbose(0) << "Counting atoms, updating list" << endl;
    1040   CountElements();
    1041   OtherMolecule->CountElements();
    10421003
    10431004  /// ... and compare:
     
    10491010    } else Log() << Verbose(4) << "AtomCounts match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl;
    10501011  }
    1051   /// -# ElementCount
     1012  /// -# Formula
    10521013  if (result) {
    1053     if (ElementCount != OtherMolecule->ElementCount) {
    1054       DoLog(4) && (Log() << Verbose(4) << "ElementCount don't match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl);
     1014    if (formula != OtherMolecule->formula) {
     1015      DoLog(4) && (Log() << Verbose(4) << "Formulas don't match: " << formula << " == " << OtherMolecule->formula << endl);
    10551016      result = false;
    1056     } else Log() << Verbose(4) << "ElementCount match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl;
    1057   }
    1058   /// -# ElementsInMolecule
    1059   if (result) {
    1060     for (flag=MAX_ELEMENTS;flag--;) {
    1061       //Log() << Verbose(5) << "Element " <<  flag << ": " << ElementsInMolecule[flag] << " <-> " << OtherMolecule->ElementsInMolecule[flag] << "." << endl;
    1062       if (ElementsInMolecule[flag] != OtherMolecule->ElementsInMolecule[flag])
    1063         break;
    1064     }
    1065     if (flag < MAX_ELEMENTS) {
    1066       DoLog(4) && (Log() << Verbose(4) << "ElementsInMolecule don't match." << endl);
    1067       result = false;
    1068     } else Log() << Verbose(4) << "ElementsInMolecule match." << endl;
     1017    } else Log() << Verbose(4) << "Formulas match: " << formula << " == " << OtherMolecule->formula << endl;
    10691018  }
    10701019  /// then determine and compare center of gravity for each molecule ...
  • src/molecule.hpp

    r06f4ef6 rb6da28  
    77#define MOLECULES_HPP_
    88
    9 using namespace std;
    10 
    119/*********************************************** includes ***********************************/
    1210
    13 // GSL headers
    14 #include <gsl/gsl_eigen.h>
    15 #include <gsl/gsl_heapsort.h>
    16 #include <gsl/gsl_linalg.h>
    17 #include <gsl/gsl_matrix.h>
    18 #include <gsl/gsl_multimin.h>
    19 #include <gsl/gsl_vector.h>
    20 #include <gsl/gsl_randist.h>
     11#ifdef HAVE_CONFIG_H
     12#include <config.h>
     13#endif
    2114
    2215//// STL headers
     
    2922#include <string>
    3023
    31 #include "defs.hpp"
     24#include "types.hpp"
    3225#include "graph.hpp"
    33 #include "stackclass.hpp"
    3426#include "tesselation.hpp"
    3527#include "Patterns/Observer.hpp"
    3628#include "Patterns/ObservedIterator.hpp"
    3729#include "Patterns/Cacheable.hpp"
     30#include "Formula.hpp"
     31#include "AtomSet.hpp"
    3832
    3933#include "Descriptors/MoleculeDescriptor_impl.hpp"
     
    5347class periodentafel;
    5448class Vector;
     49class Shape;
     50template <class> class StackClass;
    5551
    5652/******************************** Some definitions for easier reading **********************************/
     
    8177};
    8278
    83 #define MaxThermostats 6      //!< maximum number of thermostat entries in Ions#ThermostatNames and Ions#ThermostatImplemented
    84 enum thermostats { None, Woodcock, Gaussian, Langevin, Berendsen, NoseHoover };   //!< Thermostat names for output
    85 
    86 
    8779/** The complete molecule.
    8880 * Class incorporates number of types
     
    9385
    9486  public:
    95     typedef std::set<atom*> atomSet;
     87    typedef ATOMSET(std::list) atomSet;
     88    typedef std::set<atomId_t> atomIdSet;
    9689    typedef ObservedIterator<atomSet> iterator;
    9790    typedef atomSet::const_iterator const_iterator;
     
    10699    //int AtomCount;          //!< number of atoms, brought up-to-date by CountAtoms()
    107100    int BondCount;          //!< number of atoms, brought up-to-date by CountBonds()
    108     int ElementCount;       //!< how many unique elements are therein
    109     int ElementsInMolecule[MAX_ELEMENTS]; //!< list whether element (sorted by atomic number) is alread present or not
    110101    mutable int NoNonHydrogen;  //!< number of non-hydrogen atoms in molecule
    111102    mutable int NoNonBonds;     //!< number of non-hydrogen bonds in molecule
     
    118109
    119110  private:
    120     Cacheable<string> formula;
     111    Formula formula;
    121112    Cacheable<int>    AtomCount;
    122113    moleculeId_t id;
    123     atomSet atoms; //<!set of atoms
     114    atomSet atoms; //<!list of atoms
     115    atomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms
    124116  protected:
    125117    //void CountAtoms();
     
    143135  void setId(moleculeId_t);
    144136  void setName(const std::string);
    145   const std::string getFormula();
    146   std::string calcFormula();
     137  const Formula &getFormula();
     138  unsigned int getElementCount();
     139  bool hasElement(const element*) const;
     140  bool hasElement(atomicNumber_t) const;
     141  bool hasElement(const std::string&) const;
     142
    147143
    148144  iterator begin();
     
    262258
    263259  /// Count and change present atoms' coordination.
    264   void CountElements();
    265   void CalculateOrbitals(class config &configuration);
    266260  bool CenterInBox();
    267261  bool BoundInBox();
     
    282276  void SetBoxDimension(Vector *dim);
    283277  void ScanForPeriodicCorrection();
    284   bool VerletForceIntegration(char *file, config &configuration);
     278  bool VerletForceIntegration(char *file, config &configuration, const size_t offset);
    285279  void Thermostats(config &configuration, double ActualTemp, int Thermostat);
    286280  void PrincipalAxisSystem(bool DoRotate);
     
    290284  double MinimiseConstrainedPotential(atom **&permutation, int startstep, int endstep, bool IsAngstroem);
    291285  void EvaluateConstrainedForces(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force);
    292   bool LinearInterpolationBetweenConfiguration(int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity);
     286  bool LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity);
    293287       
    294288  bool CheckBounds(const Vector *x) const;
     
    319313
    320314  molecule *CopyMolecule();
    321   molecule* CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const;
     315  molecule* CopyMoleculeFromSubRegion(const Shape&) const;
    322316
    323317  /// Fragment molecule by two different approaches:
    324   int FragmentMolecule(int Order, config *configuration);
    325   bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path = NULL);
    326   bool StoreBondsToFile(char *path, char *filename);
    327   bool StoreAdjacencyToFile(char *path, char *filename);
    328   bool CheckAdjacencyFileAgainstMolecule(char *path, atom **ListOfAtoms);
    329   bool ParseOrderAtSiteFromFile(char *path);
    330   bool StoreOrderAtSiteFile(char *path);
    331   bool StoreForcesFile(MoleculeListClass *BondFragments, char *path, int *SortIndex);
     318  int FragmentMolecule(int Order, std::string &prefix);
     319  bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, std::string path = "");
     320  bool StoreBondsToFile(std::string &filename, std::string path = "");
     321  bool StoreAdjacencyToFile(std::string &filename, std::string path = "");
     322  bool CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms);
     323  bool ParseOrderAtSiteFromFile(std::string &path);
     324  bool StoreOrderAtSiteFile(std::string &path);
     325  bool StoreForcesFile(MoleculeListClass *BondFragments, std::string &path, int *SortIndex);
    332326  bool CreateMappingLabelsToConfigSequence(int *&SortIndex);
    333327  bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
     
    347341
    348342  // Output routines.
    349   bool Output(ofstream * const output);
     343  bool Output(std::ostream * const output);
    350344  bool OutputTrajectories(ofstream * const output);
    351345  void OutputListOfBonds() const;
     
    378372  ~MoleculeListClass();
    379373
    380   bool AddHydrogenCorrection(char *path);
    381   bool StoreForcesFile(char *path, int *SortIndex);
     374  bool AddHydrogenCorrection(std::string &path);
     375  bool StoreForcesFile(std::string &path, int *SortIndex);
    382376  void insert(molecule *mol);
    383377  void erase(molecule *mol);
    384378  molecule * ReturnIndex(int index);
    385   bool OutputConfigForListOfFragments(config *configuration, int *SortIndex);
     379  bool OutputConfigForListOfFragments(std::string &prefix, int *SortIndex);
    386380  int NumberOfActiveMolecules();
    387381  void Enumerate(ostream *out);
     
    429423
    430424  bool AddLeaf(molecule *ptr, MoleculeLeafClass *Previous);
    431   bool FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList = false);
     425  bool FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList = false);
    432426  bool FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter);
    433427  bool AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList = false);
    434   bool FillListOfLocalAtoms(atom ***&ListOfLocalAtoms, const int FragmentCounter, const int GlobalAtomCount, bool &FreeList);
     428  bool FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount, bool &FreeList);
    435429  void TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph);
    436430  int Count() const;
  • src/molecule_dynamics.cpp

    r06f4ef6 rb6da28  
    1313#include "element.hpp"
    1414#include "info.hpp"
     15#include "verbose.hpp"
    1516#include "log.hpp"
    16 #include "memoryallocator.hpp"
    1717#include "molecule.hpp"
    1818#include "parser.hpp"
    1919#include "Plane.hpp"
     20#include "ThermoStatContainer.hpp"
     21
     22#include <gsl/gsl_matrix.h>
     23#include <gsl/gsl_vector.h>
     24#include <gsl/gsl_linalg.h>
    2025
    2126/************************************* Functions for class molecule *********************************/
     
    472477 * \param startstep stating initial configuration in molecule::Trajectories
    473478 * \param endstep stating final configuration in molecule::Trajectories
     479 * \param &prefix path and prefix
    474480 * \param &config configuration structure
    475481 * \param MapByIdentity if true we just use the identity to map atoms in start config to end config, if not we find mapping by \sa MinimiseConstrainedPotential()
    476482 * \return true - success in writing step files, false - error writing files or only one step in molecule::Trajectories
    477483 */
    478 bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity)
     484bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity)
    479485{
    480486  molecule *mol = NULL;
     
    524530  for (int i=getAtomCount(); i--; )
    525531    SortIndex[i] = i;
    526   status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex);
     532
     533  status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex);
    527534  delete[](SortIndex);
    528535
     
    537544 * have to transform them).
    538545 * This adds a new MD step to the config file.
    539  * \param *out output stream for debugging
    540546 * \param *file filename
    541547 * \param config structure with config::Deltat, config::IsAngstroem, config::DoConstrained
    542  * \param delta_t time step width in atomic units
    543  * \param IsAngstroem whether coordinates are in angstroem (true) or bohrradius (false)
    544  * \param DoConstrained whether we perform a constrained (>0, target step in molecule::trajectories) or unconstrained (0) molecular dynamics, \sa molecule::MinimiseConstrainedPotential()
     548 * \param offset offset in matrix file to the first force component
    545549 * \return true - file found and parsed, false - file not found or imparsable
    546550 * \todo This is not yet checked if it is correctly working with DoConstrained set to true.
    547551 */
    548 bool molecule::VerletForceIntegration(char *file, config &configuration)
     552bool molecule::VerletForceIntegration(char *file, config &configuration, const size_t offset)
    549553{
    550554  Info FunctionInfo(__func__);
     
    556560  ForceMatrix Force;
    557561
    558   CountElements();  // make sure ElementsInMolecule is up to date
    559 
     562  const int AtomCount = getAtomCount();
    560563  // check file
    561564  if (input == NULL) {
     
    568571      return false;
    569572    }
    570     if (Force.RowCounter[0] != getAtomCount()) {
     573    if (Force.RowCounter[0] != AtomCount) {
    571574      DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << getAtomCount() << "." << endl);
    572575      performCriticalExit();
     
    575578    // correct Forces
    576579    Velocity.Zero();
    577     for(int i=0;i<getAtomCount();i++)
     580    for(int i=0;i<AtomCount;i++)
    578581      for(int d=0;d<NDIM;d++) {
    579         Velocity[d] += Force.Matrix[0][i][d+5];
     582        Velocity[d] += Force.Matrix[0][i][d+offset];
    580583      }
    581     for(int i=0;i<getAtomCount();i++)
     584    for(int i=0;i<AtomCount;i++)
    582585      for(int d=0;d<NDIM;d++) {
    583         Force.Matrix[0][i][d+5] -= Velocity[d]/static_cast<double>(getAtomCount());
     586        Force.Matrix[0][i][d+offset] -= Velocity[d]/static_cast<double>(AtomCount);
    584587      }
    585588    // solve a constrained potential if we are meant to
     
    596599    //ActOnAllAtoms( &atom::ResizeTrajectory, MDSteps+10 );
    597600
    598     ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps+1, &configuration, &Force);
     601    ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps+1, &configuration, &Force, (const size_t) 0);
    599602  }
    600603  // correct velocities (rather momenta) so that center of mass remains motionless
     
    643646
    644647  // calculate scale configuration
    645   ScaleTempFactor = configuration.TargetTemp/ActualTemp;
     648  ScaleTempFactor = configuration.Thermostats->TargetTemp/ActualTemp;
    646649
    647650  // differentating between the various thermostats
     
    651654      break;
    652655     case Woodcock:
    653       if ((configuration.ScaleTempStep > 0) && ((MDSteps-1) % configuration.ScaleTempStep == 0)) {
     656      if ((configuration.Thermostats->ScaleTempStep > 0) && ((MDSteps-1) % configuration.Thermostats->ScaleTempStep == 0)) {
    654657        DoLog(2) && (Log() << Verbose(2) <<  "Applying Woodcock thermostat..." << endl);
    655658        ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin );
     
    684687      delta_alpha = 0.;
    685688      ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha );
    686       delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass);
    687       configuration.alpha += delta_alpha*configuration.Deltat;
    688       DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl);
     689      delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.Thermostats->TargetTemp)/(configuration.Thermostats->HooverMass*Units2Electronmass);
     690      configuration.Thermostats->alpha += delta_alpha*configuration.Deltat;
     691      DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.Thermostats->alpha << "." << endl);
    689692      // apply updated alpha as additional force
    690693      ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration );
  • src/molecule_fragmentation.cpp

    r06f4ef6 rb6da28  
    1717#include "helpers.hpp"
    1818#include "lists.hpp"
     19#include "verbose.hpp"
    1920#include "log.hpp"
    20 #include "memoryallocator.hpp"
    2121#include "molecule.hpp"
    2222#include "periodentafel.hpp"
    2323#include "World.hpp"
     24#include "Matrix.hpp"
     25#include "Box.hpp"
     26#include "stackclass.hpp"
    2427
    2528/************************************* Functions for class molecule *********************************/
     
    8285 * -# Scans TEFactors file and sets the TEFactor of each key set in the temporary graph accordingly
    8386 * Finally, the temporary graph is inserted into the given \a FragmentList for return.
    84  * \param *out output stream for debugging
    85  * \param *path path to file
     87 * \param &path path to file
    8688 * \param *FragmentList empty, filled on return
    8789 * \return true - parsing successfully, false - failure on parsing (FragmentList will be NULL)
    8890 */
    89 bool ParseKeySetFile(char *path, Graph *&FragmentList)
     91bool ParseKeySetFile(std::string &path, Graph *&FragmentList)
    9092{
    9193  bool status = true;
     
    9496  GraphTestPair testGraphInsert;
    9597  int NumberOfFragments = 0;
    96   char filename[MAXSTRINGSIZE];
     98  string filename;
    9799
    98100  if (FragmentList == NULL) { // check list pointer
     
    102104  // 1st pass: open file and read
    103105  DoLog(1) && (Log() << Verbose(1) << "Parsing the KeySet file ... " << endl);
    104   sprintf(filename, "%s/%s%s", path, FRAGMENTPREFIX, KEYSETFILE);
    105   InputFile.open(filename);
    106   if (InputFile != NULL) {
     106  filename = path + KEYSETFILE;
     107  InputFile.open(filename.c_str());
     108  if (InputFile.good()) {
    107109    // each line represents a new fragment
    108110    char buffer[MAXSTRINGSIZE];
     
    181183
    182184/** Stores key sets to file.
    183  * \param *out output stream for debugging
    184185 * \param KeySetList Graph with Keysets
    185  * \param *path path to file
     186 * \param &path path to file
    186187 * \return true - file written successfully, false - writing failed
    187188 */
    188 bool StoreKeySetFile(Graph &KeySetList, char *path)
    189 {
    190   ofstream output;
     189bool StoreKeySetFile(Graph &KeySetList, std::string &path)
     190{
    191191  bool status =  true;
    192   string line;
     192  string line = path + KEYSETFILE;
     193  ofstream output(line.c_str());
    193194
    194195  // open KeySet file
    195   line = path;
    196   line.append("/");
    197   line += FRAGMENTPREFIX;
    198   line += KEYSETFILE;
    199   output.open(line.c_str(), ios::out);
    200196  DoLog(1) && (Log() << Verbose(1) << "Saving key sets of the total graph ... ");
    201   if(output != NULL) {
     197  if(output.good()) {
    202198    for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++) {
    203199      for (KeySet::iterator sprinter = (*runner).first.begin();sprinter != (*runner).first.end(); sprinter++) {
     
    302298
    303299/** Scans the adaptive order file and insert (index, value) into map.
    304  * \param *out output stream for debugging
    305  * \param *path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)
     300 * \param &path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)
    306301 * \param &IndexedKeySetList list to find key set for a given index \a No
    307302 * \return adaptive criteria list from file
    308303 */
    309 map<int, pair<double,int> > * ScanAdaptiveFileIntoMap(char *path, map<int,KeySet> &IndexKeySetList)
     304map<int, pair<double,int> > * ScanAdaptiveFileIntoMap(std::string &path, map<int,KeySet> &IndexKeySetList)
    310305{
    311306  map<int, pair<double,int> > *AdaptiveCriteriaList = new map<int, pair<double,int> >;
     
    313308  double Value = 0.;
    314309  char buffer[MAXSTRINGSIZE];
    315   sprintf(buffer, "%s/%s%s.dat", path, FRAGMENTPREFIX, ENERGYPERFRAGMENT);
    316   ifstream InputFile(buffer, ios::in);
     310  string filename = path + ENERGYPERFRAGMENT;
     311  ifstream InputFile(filename.c_str());
     312
     313  if (InputFile.fail()) {
     314    DoeLog(1) && (eLog() << Verbose(1) << "Cannot find file " << filename << "." << endl);
     315    return AdaptiveCriteriaList;
     316  }
    317317
    318318  if (CountLinesinFile(InputFile) > 0) {
     
    419419
    420420/** Checks whether the OrderAtSite is still below \a Order at some site.
    421  * \param *out output stream for debugging
    422421 * \param *AtomMask defines true/false per global Atom::nr to mask in/out each nuclear site, used to activate given number of site to increment order adaptively
    423422 * \param *GlobalKeySetList list of keysets with global ids (valid in "this" molecule) needed for adaptive increase
    424423 * \param Order desired Order if positive, desired exponent in threshold criteria if negative (0 is single-step)
    425424 * \param *MinimumRingSize array of max. possible order to avoid loops
    426  * \param *path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)
     425 * \param path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)
    427426 * \return true - needs further fragmentation, false - does not need fragmentation
    428427 */
    429 bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path)
     428bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, std::string path)
    430429{
    431430  bool status = false;
     
    585584 * of vertex indices: Global always means the index in "this" molecule, whereas local refers to the molecule or
    586585 * subgraph in the MoleculeListClass.
    587  * \param *out output stream for debugging
    588586 * \param Order up to how many neighbouring bonds a fragment contains in BondOrderScheme::BottumUp scheme
    589  * \param *configuration configuration for writing config files for each fragment
     587 * \param &prefix path and prefix of the bond order configs to be written
    590588 * \return 1 - continue, 2 - stop (no fragmentation occured)
    591589 */
    592 int molecule::FragmentMolecule(int Order, config *configuration)
     590int molecule::FragmentMolecule(int Order, std::string &prefix)
    593591{
    594592  MoleculeListClass *BondFragments = NULL;
     
    624622
    625623  // === compare it with adjacency file ===
    626   FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(configuration->configpath, ListOfAtoms);
     624  FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(prefix, ListOfAtoms);
    627625  delete[](ListOfAtoms);
    628626
     
    634632    MinimumRingSize[i] = getAtomCount();
    635633  MolecularWalker = Subgraphs;
     634  const int LeafCount = Subgraphs->next->Count();
    636635  FragmentCounter = 0;
    637636  while (MolecularWalker->next != NULL) {
    638637    MolecularWalker = MolecularWalker->next;
    639638    // fill the bond structure of the individually stored subgraphs
    640     MolecularWalker->FillBondStructureFromReference(this, FragmentCounter, ListOfLocalAtoms, false);  // we want to keep the created ListOfLocalAtoms
     639    ListOfAtoms = NULL;
     640    MolecularWalker->FillBondStructureFromReference(this, ListOfAtoms, false);  // we want to keep the created ListOfLocalAtoms
    641641    DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    642642    LocalBackEdgeStack = new StackClass<bond *> (MolecularWalker->Leaf->BondCount);
     
    649649//        Log() << Verbose(0) << "\t" << ListOfLocalAtoms[FragmentCounter][i]->Name;
    650650    DoLog(0) && (Log() << Verbose(0) << "Gathering local back edges for subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    651     MolecularWalker->Leaf->PickLocalBackEdges(ListOfLocalAtoms[FragmentCounter++], BackEdgeStack, LocalBackEdgeStack);
     651    MolecularWalker->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack);
    652652    DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    653653    MolecularWalker->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
    654654    DoLog(0) && (Log() << Verbose(0) << "Done with Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    655655    delete(LocalBackEdgeStack);
     656    delete(ListOfAtoms);
     657    FragmentCounter++;
    656658  }
    657659  delete(BackEdgeStack);
    658660
    659661  // ===== 3. if structure still valid, parse key set file and others =====
    660   FragmentationToDo = FragmentationToDo && ParseKeySetFile(configuration->configpath, ParsedFragmentList);
     662  FragmentationToDo = FragmentationToDo && ParseKeySetFile(prefix, ParsedFragmentList);
    661663
    662664  // ===== 4. check globally whether there's something to do actually (first adaptivity check)
    663   FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(configuration->configpath);
     665  FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(prefix);
    664666
    665667  // =================================== Begin of FRAGMENTATION ===============================
    666668  // ===== 6a. assign each keyset to its respective subgraph =====
    667   Subgraphs->next->AssignKeySetsToFragment(this, ParsedFragmentList, ListOfLocalAtoms, FragmentList, (FragmentCounter = 0), true);
     669  ListOfLocalAtoms = new atom **[LeafCount];
     670  for (int i=0;i<LeafCount;i++)
     671    ListOfLocalAtoms[i] = NULL;
     672  FragmentCounter = 0;
     673  Subgraphs->next->AssignKeySetsToFragment(this, ParsedFragmentList, ListOfLocalAtoms, FragmentList, FragmentCounter, true);
     674  delete[](ListOfLocalAtoms);
    668675
    669676  // ===== 6b. prepare and go into the adaptive (Order<0), single-step (Order==0) or incremental (Order>0) cycle
     
    672679  AtomMask[getAtomCount()] = false;
    673680  FragmentationToDo = false;  // if CheckOrderAtSite just ones recommends fragmentation, we will save fragments afterwards
    674   while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, configuration->configpath))) {
     681  while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, prefix))) {
    675682    FragmentationToDo = FragmentationToDo || CheckOrder;
    676683    AtomMask[getAtomCount()] = true;   // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite()
     
    701708  delete[](MinimumRingSize);
    702709
    703 
    704710  // ==================================== End of FRAGMENTATION ============================================
    705711
     
    727733    KeySet test = (*runner).first;
    728734    DoLog(0) && (Log() << Verbose(0) << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl);
    729     BondFragments->insert(StoreFragmentFromKeySet(test, configuration));
     735    BondFragments->insert(StoreFragmentFromKeySet(test, World::getInstance().getConfig()));
    730736    k++;
    731737  }
     
    739745
    740746    DoLog(1) && (Log() << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl);
    741     if (BondFragments->OutputConfigForListOfFragments(configuration, SortIndex))
     747    if (BondFragments->OutputConfigForListOfFragments(prefix, SortIndex))
    742748      DoLog(1) && (Log() << Verbose(1) << "All configs written." << endl);
    743749    else
     
    745751
    746752    // store force index reference file
    747     BondFragments->StoreForcesFile(configuration->configpath, SortIndex);
     753    BondFragments->StoreForcesFile(prefix, SortIndex);
    748754
    749755    // store keysets file
    750     StoreKeySetFile(TotalGraph, configuration->configpath);
     756    StoreKeySetFile(TotalGraph, prefix);
    751757
    752758    {
    753759      // store Adjacency file
    754       char filename[MAXSTRINGSIZE];
    755       strcpy(filename, FRAGMENTPREFIX);
    756       strcat(filename, ADJACENCYFILE);
    757       StoreAdjacencyToFile(configuration->configpath, filename);
     760      std::string filename = prefix + ADJACENCYFILE;
     761      StoreAdjacencyToFile(filename);
    758762    }
    759763
    760764    // store Hydrogen saturation correction file
    761     BondFragments->AddHydrogenCorrection(configuration->configpath);
     765    BondFragments->AddHydrogenCorrection(prefix);
    762766
    763767    // store adaptive orders into file
    764     StoreOrderAtSiteFile(configuration->configpath);
     768    StoreOrderAtSiteFile(prefix);
    765769
    766770    // restore orbital and Stop values
    767     CalculateOrbitals(*configuration);
     771    //CalculateOrbitals(*configuration);
    768772
    769773    // free memory for bond part
     
    782786/** Stores pairs (Atom::nr, Atom::AdaptiveOrder) into file.
    783787 * Atoms not present in the file get "-1".
    784  * \param *out output stream for debugging
    785  * \param *path path to file ORDERATSITEFILE
     788 * \param &path path to file ORDERATSITEFILE
    786789 * \return true - file writable, false - not writable
    787790 */
    788 bool molecule::StoreOrderAtSiteFile(char *path)
    789 {
    790   stringstream line;
     791bool molecule::StoreOrderAtSiteFile(std::string &path)
     792{
     793  string line;
    791794  ofstream file;
    792795
    793   line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE;
    794   file.open(line.str().c_str());
     796  line = path + ORDERATSITEFILE;
     797  file.open(line.c_str());
    795798  DoLog(1) && (Log() << Verbose(1) << "Writing OrderAtSite " << ORDERATSITEFILE << " ... " << endl);
    796   if (file != NULL) {
     799  if (file.good()) {
    797800    ActOnAllAtoms( &atom::OutputOrder, &file );
    798801    file.close();
     
    800803    return true;
    801804  } else {
    802     DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
     805    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line << "." << endl);
    803806    return false;
    804807  }
     
    807810/** Parses pairs(Atom::nr, Atom::AdaptiveOrder) from file and stores in molecule's Atom's.
    808811 * Atoms not present in the file get "0".
    809  * \param *out output stream for debugging
    810  * \param *path path to file ORDERATSITEFILEe
     812 * \param &path path to file ORDERATSITEFILEe
    811813 * \return true - file found and scanned, false - file not found
    812814 * \sa ParseKeySetFile() and CheckAdjacencyFileAgainstMolecule() as this is meant to be used in conjunction with the two
    813815 */
    814 bool molecule::ParseOrderAtSiteFromFile(char *path)
     816bool molecule::ParseOrderAtSiteFromFile(std::string &path)
    815817{
    816818  unsigned char *OrderArray = new unsigned char[getAtomCount()];
     
    818820  bool status;
    819821  int AtomNr, value;
    820   stringstream line;
     822  string line;
    821823  ifstream file;
    822824
     
    827829
    828830  DoLog(1) && (Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl);
    829   line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE;
    830   file.open(line.str().c_str());
    831   if (file != NULL) {
     831  line = path + ORDERATSITEFILE;
     832  file.open(line.c_str());
     833  if (file.good()) {
    832834    while (!file.eof()) { // parse from file
    833835      AtomNr = -1;
     
    850852    status = true;
    851853  } else {
    852     DoLog(1) && (Log() << Verbose(1) << "\t ... failed to open file " << line.str() << "." << endl);
     854    DoLog(1) && (Log() << Verbose(1) << "\t ... failed to open file " << line << "." << endl);
    853855    status = false;
    854856  }
     
    17171719  atom *Walker = NULL;
    17181720  atom *OtherWalker = NULL;
    1719   double * const cell_size = World::getInstance().getDomain();
    1720   double *matrix = ReturnFullMatrixforSymmetric(cell_size);
     1721  Matrix matrix = World::getInstance().getDomain().getM();
    17211722  enum Shading *ColorList = NULL;
    17221723  double tmp;
     
    17581759          Translationvector[i] = (tmp < 0) ? +1. : -1.;
    17591760      }
    1760       Translationvector.MatrixMultiplication(matrix);
     1761      Translationvector *= matrix;
    17611762      //Log() << Verbose(3) << "Translation vector is ";
    17621763      Log() << Verbose(0) << Translationvector <<  endl;
     
    17891790  delete(AtomStack);
    17901791  delete[](ColorList);
    1791   delete[](matrix);
    17921792  DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl);
    17931793};
  • src/molecule_geometry.cpp

    r06f4ef6 rb6da28  
    55 *      Author: heber
    66 */
     7
     8#ifdef HAVE_CONFIG_H
     9#include <config.h>
     10#endif
    711
    812#include "Helpers/MemDebug.hpp"
     
    1418#include "helpers.hpp"
    1519#include "leastsquaremin.hpp"
     20#include "verbose.hpp"
    1621#include "log.hpp"
    17 #include "memoryallocator.hpp"
    1822#include "molecule.hpp"
    1923#include "World.hpp"
    2024#include "Plane.hpp"
     25#include "Matrix.hpp"
     26#include "Box.hpp"
    2127#include <boost/foreach.hpp>
     28
     29#include <gsl/gsl_eigen.h>
     30#include <gsl/gsl_multimin.h>
    2231
    2332
     
    3342  const Vector *Center = DetermineCenterOfAll();
    3443  const Vector *CenterBox = DetermineCenterOfBox();
    35   double * const cell_size = World::getInstance().getDomain();
    36   double *M = ReturnFullMatrixforSymmetric(cell_size);
    37   double *Minv = InverseMatrix(M);
     44  Box &domain = World::getInstance().getDomain();
    3845
    3946  // go through all atoms
    4047  ActOnAllVectors( &Vector::SubtractVector, *Center);
    4148  ActOnAllVectors( &Vector::SubtractVector, *CenterBox);
    42   ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    43 
    44   delete[](M);
    45   delete[](Minv);
     49  atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
     50
    4651  delete(Center);
     52  delete(CenterBox);
    4753  return status;
    4854};
     
    5561{
    5662  bool status = true;
    57   double * const cell_size = World::getInstance().getDomain();
    58   double *M = ReturnFullMatrixforSymmetric(cell_size);
    59   double *Minv = InverseMatrix(M);
    60 
    61   // go through all atoms
    62   ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    63 
    64   delete[](M);
    65   delete[](Minv);
     63  Box &domain = World::getInstance().getDomain();
     64
     65  atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
     66
    6667  return status;
    6768};
     
    119120      Center += (*iter)->x;
    120121    }
    121     Center.Scale(-1./Num); // divide through total number (and sign for direction)
     122    Center.Scale(-1./(double)Num); // divide through total number (and sign for direction)
    122123    Translate(&Center);
    123124    Center.Zero();
     
    141142      (*a) += (*iter)->x;
    142143    }
    143     a->Scale(1./Num); // divide through total mass (and sign for direction)
     144    a->Scale(1./(double)Num); // divide through total mass (and sign for direction)
    144145  }
    145146  return a;
     
    152153{
    153154  Vector *a = new Vector(0.5,0.5,0.5);
    154 
    155   const double *cell_size = World::getInstance().getDomain();
    156   double *M = ReturnFullMatrixforSymmetric(cell_size);
    157   a->MatrixMultiplication(M);
    158   delete[](M);
    159 
     155  const Matrix &M = World::getInstance().getDomain().getM();
     156  (*a) *= M;
    160157  return a;
    161158};
     
    180177      (*a) += tmp;
    181178    }
    182     a->Scale(1./Num); // divide through total mass (and sign for direction)
     179    a->Scale(1./Num); // divide through total mass
    183180  }
    184181//  Log() << Verbose(1) << "Resulting center of gravity: ";
     
    243240void molecule::TranslatePeriodically(const Vector *trans)
    244241{
    245   double * const cell_size = World::getInstance().getDomain();
    246   double *M = ReturnFullMatrixforSymmetric(cell_size);
    247   double *Minv = InverseMatrix(M);
     242  Box &domain = World::getInstance().getDomain();
    248243
    249244  // go through all atoms
    250245  ActOnAllVectors( &Vector::AddVector, *trans);
    251   ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    252 
    253   delete[](M);
    254   delete[](Minv);
     246  atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
     247
    255248};
    256249
     
    263256  OBSERVE;
    264257  Plane p(*n,0);
    265   BOOST_FOREACH( atom* iter, atoms ){
    266     (*iter->node) = p.mirrorVector(*iter->node);
    267   }
     258  atoms.transformNodes(boost::bind(&Plane::mirrorVector,p,_1));
    268259};
    269260
     
    273264void molecule::DeterminePeriodicCenter(Vector &center)
    274265{
    275   double * const cell_size = World::getInstance().getDomain();
    276   double *matrix = ReturnFullMatrixforSymmetric(cell_size);
    277   double *inversematrix = InverseMatrix(matrix);
     266  const Matrix &matrix = World::getInstance().getDomain().getM();
     267  const Matrix &inversematrix = World::getInstance().getDomain().getM();
    278268  double tmp;
    279269  bool flag;
     
    287277      if ((*iter)->type->Z != 1) {
    288278#endif
    289         Testvector = (*iter)->x;
    290         Testvector.MatrixMultiplication(inversematrix);
     279        Testvector = inversematrix * (*iter)->x;
    291280        Translationvector.Zero();
    292281        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     
    305294        }
    306295        Testvector += Translationvector;
    307         Testvector.MatrixMultiplication(matrix);
     296        Testvector *= matrix;
    308297        Center += Testvector;
    309298        Log() << Verbose(1) << "vector is: " << Testvector << endl;
     
    312301        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
    313302          if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) {
    314             Testvector = (*Runner)->GetOtherAtom((*iter))->x;
    315             Testvector.MatrixMultiplication(inversematrix);
     303            Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->x;
    316304            Testvector += Translationvector;
    317             Testvector.MatrixMultiplication(matrix);
     305            Testvector *= matrix;
    318306            Center += Testvector;
    319307            Log() << Verbose(1) << "Hydrogen vector is: " << Testvector << endl;
     
    324312    }
    325313  } while (!flag);
    326   delete[](matrix);
    327   delete[](inversematrix);
    328314
    329315  Center.Scale(1./static_cast<double>(getAtomCount()));
     
    387373    DoLog(1) && (Log() << Verbose(1) << "Transforming molecule into PAS ... ");
    388374    // the eigenvectors specify the transformation matrix
    389     ActOnAllVectors( &Vector::MatrixMultiplication, (const double *) evec->data );
     375    Matrix M = Matrix(evec->data);
     376
     377    BOOST_FOREACH(atom* iter, atoms){
     378      (*iter->node) *= M;
     379    }
    390380    DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    391381
  • src/molecule_graph.cpp

    r06f4ef6 rb6da28  
    66 */
    77
     8#ifdef HAVE_CONFIG_H
     9#include <config.h>
     10#endif
     11
    812#include "Helpers/MemDebug.hpp"
    913
     
    1216#include "bondgraph.hpp"
    1317#include "config.hpp"
     18#include "defs.hpp"
    1419#include "element.hpp"
    1520#include "helpers.hpp"
     
    1722#include "linkedcell.hpp"
    1823#include "lists.hpp"
     24#include "verbose.hpp"
    1925#include "log.hpp"
    20 #include "memoryallocator.hpp"
    2126#include "molecule.hpp"
    2227#include "World.hpp"
    2328#include "Helpers/fast_functions.hpp"
    2429#include "Helpers/Assert.hpp"
    25 
     30#include "Matrix.hpp"
     31#include "Box.hpp"
     32#include "stackclass.hpp"
    2633
    2734struct BFSAccounting
     
    120127  LinkedCell *LC = NULL;
    121128  bool free_BG = false;
    122   double * const cell_size = World::getInstance().getDomain();
     129  Box &domain = World::getInstance().getDomain();
    123130
    124131  if (BG == NULL) {
     
    177184                          //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
    178185                          (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
    179                           const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,cell_size);
     186                          const double distance = domain.periodicDistanceSquared(OtherWalker->x,Walker->x);
    180187                          const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance);
    181188//                          Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl;
     
    578585    // From OldGraphNr to CurrentGraphNr ranges an disconnected subgraph
    579586    DoLog(0) && (Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl);
    580     LeafWalker->Leaf->Output((ofstream *)&cout);
     587    LeafWalker->Leaf->Output((ofstream *)&(Log() << Verbose(0)));
    581588    DoLog(0) && (Log() << Verbose(0) << endl);
    582589
     
    663670  BFS.ColorList = new enum Shading[AtomCount];
    664671  BFS.BFSStack = new StackClass<atom *> (AtomCount);
     672  BFS.TouchedStack = new StackClass<atom *> (AtomCount);
    665673
    666674  for (int i = AtomCount; i--;) {
    667675    BFS.ShortestPathList[i] = -1;
    668676    BFS.PredecessorList[i] = 0;
     677    BFS.ColorList[i] = white;
    669678  }
    670679};
     
    680689  delete[](BFS.ColorList);
    681690  delete (BFS.BFSStack);
     691  delete (BFS.TouchedStack);
    682692  BFS.AtomCount = 0;
    683693};
     
    824834      MinRingSize = RingSize;
    825835  } else {
    826     DoLog(1) && (Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[Walker->GetTrueFather()->nr] << " found." << endl);
     836    DoLog(1) && (Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[BFS.Root->GetTrueFather()->nr] << " found." << endl);
    827837  }
    828838};
     
    10241034/** Storing the bond structure of a molecule to file.
    10251035 * Simply stores Atom::nr and then the Atom::nr of all bond partners per line.
    1026  * \param *path path to file
    1027  * \param *filename name of file
     1036 * \param &filename name of file
     1037 * \param path path to file, defaults to empty
    10281038 * \return true - file written successfully, false - writing failed
    10291039 */
    1030 bool molecule::StoreAdjacencyToFile(char *path, char *filename)
     1040bool molecule::StoreAdjacencyToFile(std::string &filename, std::string path)
    10311041{
    10321042  ofstream AdjacencyFile;
    1033   stringstream line;
     1043  string line;
    10341044  bool status = true;
    10351045
    1036   if (path != NULL)
    1037     line << path << "/" << filename;
     1046  if (path != "")
     1047    line = path + "/" + filename;
    10381048  else
    1039     line << filename;
    1040   AdjacencyFile.open(line.str().c_str(), ios::out);
     1049    line = filename;
     1050  AdjacencyFile.open(line.c_str(), ios::out);
    10411051  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl);
    1042   if (AdjacencyFile != NULL) {
     1052  if (AdjacencyFile.good()) {
    10431053    AdjacencyFile << "m\tn" << endl;
    10441054    ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile);
     
    10461056    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
    10471057  } else {
    1048     DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line.str() << "." << endl);
     1058    DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl);
    10491059    status = false;
    10501060  }
     
    10561066/** Storing the bond structure of a molecule to file.
    10571067 * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line.
    1058  * \param *path path to file
    1059  * \param *filename name of file
     1068 * \param &filename name of file
     1069 * \param path path to file, defaults to empty
    10601070 * \return true - file written successfully, false - writing failed
    10611071 */
    1062 bool molecule::StoreBondsToFile(char *path, char *filename)
     1072bool molecule::StoreBondsToFile(std::string &filename, std::string path)
    10631073{
    10641074  ofstream BondFile;
    1065   stringstream line;
     1075  string line;
    10661076  bool status = true;
    10671077
    1068   if (path != NULL)
    1069     line << path << "/" << filename;
     1078  if (path != "")
     1079    line = path + "/" + filename;
    10701080  else
    1071     line << filename;
    1072   BondFile.open(line.str().c_str(), ios::out);
     1081    line = filename;
     1082  BondFile.open(line.c_str(), ios::out);
    10731083  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl);
    1074   if (BondFile != NULL) {
     1084  if (BondFile.good()) {
    10751085    BondFile << "m\tn" << endl;
    10761086    ActOnAllAtoms(&atom::OutputBonds, &BondFile);
     
    10781088    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
    10791089  } else {
    1080     DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line.str() << "." << endl);
     1090    DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl);
    10811091    status = false;
    10821092  }
     
    10861096;
    10871097
    1088 bool CheckAdjacencyFileAgainstMolecule_Init(char *path, ifstream &File, int *&CurrentBonds)
    1089 {
    1090   stringstream filename;
    1091   filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
    1092   File.open(filename.str().c_str(), ios::out);
     1098bool CheckAdjacencyFileAgainstMolecule_Init(std::string &path, ifstream &File, int *&CurrentBonds)
     1099{
     1100  string filename;
     1101  filename = path + ADJACENCYFILE;
     1102  File.open(filename.c_str(), ios::out);
    10931103  DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... " << endl);
    1094   if (File == NULL)
     1104  if (File.fail())
    10951105    return false;
    10961106
     
    11461156 * \return true - structure is equal, false - not equivalence
    11471157 */
    1148 bool molecule::CheckAdjacencyFileAgainstMolecule(char *path, atom **ListOfAtoms)
     1158bool molecule::CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms)
    11491159{
    11501160  ifstream File;
  • src/molecule_pointcloud.cpp

    r06f4ef6 rb6da28  
    1111#include "config.hpp"
    1212#include "info.hpp"
    13 #include "memoryallocator.hpp"
    1413#include "molecule.hpp"
    1514
     
    5756void molecule::GoToFirst() const
    5857{
    59   InternalPointer = atoms.begin();
     58  // evil hack necessary because
     59  // -# although InternalPointer is mutable
     60  // -# only const_iterator begin() is called due to const in the function declaration above
     61  // -# and there is no cast from const_iterator to const iterator
     62  atomSet::const_iterator test = begin();
     63  InternalPointer = *(reinterpret_cast<atomSet::iterator *>(&test));
    6064};
    6165
  • src/moleculelist.cpp

    r06f4ef6 rb6da28  
    55 */
    66
     7#ifdef HAVE_CONFIG_H
     8#include <config.h>
     9#endif
     10
    711#include "Helpers/MemDebug.hpp"
    812
    913#include <cstring>
     14
     15#include <gsl/gsl_inline.h>
     16#include <gsl/gsl_heapsort.h>
    1017
    1118#include "World.hpp"
    1219#include "atom.hpp"
    1320#include "bond.hpp"
     21#include "bondgraph.hpp"
    1422#include "boundary.hpp"
    1523#include "config.hpp"
     
    1826#include "linkedcell.hpp"
    1927#include "lists.hpp"
     28#include "verbose.hpp"
    2029#include "log.hpp"
    2130#include "molecule.hpp"
    22 #include "memoryallocator.hpp"
    2331#include "periodentafel.hpp"
    2432#include "Helpers/Assert.hpp"
     33#include "Matrix.hpp"
     34#include "Box.hpp"
     35#include "stackclass.hpp"
    2536
    2637#include "Helpers/Assert.hpp"
     
    212223
    213224  // put all molecules of src into mol
    214   molecule::iterator runner;
    215   for (molecule::iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
    216     runner = iter++;
    217     srcmol->UnlinkAtom((*runner));
    218     mol->AddAtom((*runner));
     225  for (molecule::iterator iter = srcmol->begin(); !srcmol->empty(); iter=srcmol->begin()) {
     226    atom * const Walker = *iter;
     227    srcmol->UnlinkAtom(Walker);
     228    mol->AddAtom(Walker);
    219229  }
    220230
     
    259269    status = status && SimpleMerge(mol, srcmol);
    260270  }
     271  insert(mol);
    261272  return status;
    262273};
     
    379390 * bonded to the same atom, then we add for this pair a correction term constructed from a Morse
    380391 * potential function fit to QM calculations with respecting to the interatomic hydrogen distance.
    381  * \param *out output stream for debugging
    382  * \param *path path to file
    383  */
    384 bool MoleculeListClass::AddHydrogenCorrection(char *path)
     392 * \param &path path to file
     393 */
     394bool MoleculeListClass::AddHydrogenCorrection(std::string &path)
    385395{
    386396  bond *Binder = NULL;
     
    400410  // 0a. find dimension of matrices with constants
    401411  line = path;
    402   line.append("/");
    403   line += FRAGMENTPREFIX;
    404412  line += "1";
    405413  line += FITCONSTANTSUFFIX;
    406414  input.open(line.c_str());
    407   if (input == NULL) {
     415  if (input.fail()) {
    408416    DoLog(1) && (Log() << Verbose(1) << endl << "Unable to open " << line << ", is the directory correct?" << endl);
    409417    return false;
     
    569577
    570578/** Store force indices, i.e. the connection between the nuclear index in the total molecule config and the respective atom in fragment config.
    571  * \param *out output stream for debugging
    572  * \param *path path to file
     579 * \param &path path to file
    573580 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config
    574581 * \return true - file written successfully, false - writing failed
    575582 */
    576 bool MoleculeListClass::StoreForcesFile(char *path,
    577     int *SortIndex)
     583bool MoleculeListClass::StoreForcesFile(std::string &path, int *SortIndex)
    578584{
    579585  bool status = true;
    580   ofstream ForcesFile;
    581   stringstream line;
     586  string filename(path);
     587  filename += FORCESFILE;
     588  ofstream ForcesFile(filename.c_str());
    582589  periodentafel *periode=World::getInstance().getPeriode();
    583590
    584591  // open file for the force factors
    585592  DoLog(1) && (Log() << Verbose(1) << "Saving  force factors ... ");
    586   line << path << "/" << FRAGMENTPREFIX << FORCESFILE;
    587   ForcesFile.open(line.str().c_str(), ios::out);
    588   if (ForcesFile != NULL) {
     593  if (!ForcesFile.fail()) {
    589594    //Log() << Verbose(1) << "Final AtomicForcesList: ";
    590595    //output << prefix << "Forces" << endl;
     
    592597      periodentafel::const_iterator elemIter;
    593598      for(elemIter=periode->begin();elemIter!=periode->end();++elemIter){
    594         if ((*ListRunner)->ElementsInMolecule[(*elemIter).first]) { // if this element got atoms
     599        if ((*ListRunner)->hasElement((*elemIter).first)) { // if this element got atoms
    595600          for(molecule::iterator atomIter = (*ListRunner)->begin(); atomIter !=(*ListRunner)->end();++atomIter){
    596601            if ((*atomIter)->type->getNumber() == (*elemIter).first) {
     
    611616  } else {
    612617    status = false;
    613     DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
     618    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << filename << "." << endl);
    614619  }
    615620  ForcesFile.close();
     
    620625/** Writes a config file for each molecule in the given \a **FragmentList.
    621626 * \param *out output stream for debugging
    622  * \param *configuration standard configuration to attach atoms in fragment molecule to.
     627 * \param &prefix path and prefix to the fragment config files
    623628 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config
    624629 * \return true - success (each file was written), false - something went wrong.
    625630 */
    626 bool MoleculeListClass::OutputConfigForListOfFragments(config *configuration, int *SortIndex)
     631bool MoleculeListClass::OutputConfigForListOfFragments(std::string &prefix, int *SortIndex)
    627632{
    628633  ofstream outputFragment;
    629   char FragmentName[MAXSTRINGSIZE];
     634  std::string FragmentName;
    630635  char PathBackup[MAXSTRINGSIZE];
    631636  bool result = true;
     
    636641  int FragmentCounter = 0;
    637642  ofstream output;
    638   double cell_size_backup[6];
    639   double * const cell_size = World::getInstance().getDomain();
    640 
    641   // backup cell_size
    642   for (int i=0;i<6;i++)
    643     cell_size_backup[i] = cell_size[i];
     643  Matrix cell_size = World::getInstance().getDomain().getM();
     644  Matrix cell_size_backup = cell_size;
     645
    644646  // store the fragments as config and as xyz
    645647  for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
    646648    // save default path as it is changed for each fragment
    647     path = configuration->GetDefaultPath();
     649    path = World::getInstance().getConfig()->GetDefaultPath();
    648650    if (path != NULL)
    649651      strcpy(PathBackup, path);
     
    658660    // output xyz file
    659661    FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), FragmentCounter++);
    660     sprintf(FragmentName, "%s/%s%s.conf.xyz", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
    661     outputFragment.open(FragmentName, ios::out);
     662    FragmentName = prefix + FragmentNumber + ".conf.xyz";
     663    outputFragment.open(FragmentName.c_str(), ios::out);
    662664    DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as XYZ ...");
    663665    if ((intermediateResult = (*ListRunner)->OutputXYZ(&outputFragment)))
     
    679681    (*ListRunner)->CenterEdge(&BoxDimension);
    680682    (*ListRunner)->SetBoxDimension(&BoxDimension); // update Box of atoms by boundary
    681     int j = -1;
    682683    for (int k = 0; k < NDIM; k++) {
    683       j += k + 1;
    684       BoxDimension[k] = 2.5 * (configuration->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
    685       cell_size[j] = BoxDimension[k] * 2.;
    686     }
     684      BoxDimension[k] = 2.5 * (World::getInstance().getConfig()->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
     685      cell_size.at(k,k) = BoxDimension[k] * 2.;
     686    }
     687    World::getInstance().setDomain(cell_size);
    687688    (*ListRunner)->Translate(&BoxDimension);
    688689
    689690    // also calculate necessary orbitals
    690     (*ListRunner)->CountElements(); // this is a bugfix, atoms should shoulds actually be added correctly to this fragment
    691     (*ListRunner)->CalculateOrbitals(*configuration);
     691    //(*ListRunner)->CalculateOrbitals(*World::getInstance().getConfig);
    692692
    693693    // change path in config
    694     //strcpy(PathBackup, configuration->configpath);
    695     sprintf(FragmentName, "%s/%s%s/", PathBackup, FRAGMENTPREFIX, FragmentNumber);
    696     configuration->SetDefaultPath(FragmentName);
     694    FragmentName = PathBackup;
     695    FragmentName += "/";
     696    FragmentName += FRAGMENTPREFIX;
     697    FragmentName += FragmentNumber;
     698    FragmentName += "/";
     699    World::getInstance().getConfig()->SetDefaultPath(FragmentName.c_str());
    697700
    698701    // and save as config
    699     sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
     702    FragmentName = prefix + FragmentNumber + ".conf";
    700703    DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as config ...");
    701     if ((intermediateResult = configuration->Save(FragmentName, (*ListRunner)->elemente, (*ListRunner))))
     704    if ((intermediateResult = World::getInstance().getConfig()->Save(FragmentName.c_str(), (*ListRunner)->elemente, (*ListRunner))))
    702705      DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    703706    else
     
    706709
    707710    // restore old config
    708     configuration->SetDefaultPath(PathBackup);
     711    World::getInstance().getConfig()->SetDefaultPath(PathBackup);
    709712
    710713    // and save as mpqc input file
    711     sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
     714    FragmentName = prefix + FragmentNumber + ".conf";
    712715    DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as mpqc input ...");
    713     if ((intermediateResult = configuration->SaveMPQC(FragmentName, (*ListRunner))))
     716    if ((intermediateResult = World::getInstance().getConfig()->SaveMPQC(FragmentName.c_str(), (*ListRunner))))
    714717      DoLog(2) && (Log() << Verbose(2) << " done." << endl);
    715718    else
     
    727730
    728731  // restore cell_size
    729   for (int i=0;i<6;i++)
    730     cell_size[i] = cell_size_backup[i];
     732  World::getInstance().setDomain(cell_size_backup);
    731733
    732734  return result;
     
    767769
    768770  // 1. dissect the molecule into connected subgraphs
    769   if (!configuration->BG->ConstructBondGraph(mol)) {
    770     World::getInstance().destroyMolecule(mol);
    771     DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl);
     771  if (configuration->BG != NULL) {
     772    if (!configuration->BG->ConstructBondGraph(mol)) {
     773      World::getInstance().destroyMolecule(mol);
     774      DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl);
     775      return;
     776    }
     777  } else {
     778    DoeLog(1) && (eLog()<< Verbose(1) << "There is no BondGraph class present to create bonds." << endl);
    772779    return;
    773780  }
     
    884891  // center at set box dimensions
    885892  mol->CenterEdge(&center);
    886   World::getInstance().getDomain()[0] = center[0];
    887   World::getInstance().getDomain()[1] = 0;
    888   World::getInstance().getDomain()[2] = center[1];
    889   World::getInstance().getDomain()[3] = 0;
    890   World::getInstance().getDomain()[4] = 0;
    891   World::getInstance().getDomain()[5] = center[2];
     893  Matrix domain;
     894  for(int i =0;i<NDIM;++i)
     895    domain.at(i,i) = center[i];
     896  World::getInstance().setDomain(domain);
    892897  insert(mol);
    893898}
     
    10141019 * \param *out output stream for debugging
    10151020 * \param *reference reference molecule with the bond structure to be copied
    1016  * \param &FragmentCounter Counter needed to address \a **ListOfLocalAtoms
    1017  * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in \a *reference, may be NULL on start, then it is filled
     1021 * \param **&ListOfLocalAtoms Lookup table for this subgraph and index of each atom in \a *reference, may be NULL on start, then it is filled
    10181022 * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
    10191023 * \return true - success, false - faoilure
    10201024 */
    1021 bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList)
     1025bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList)
    10221026{
    10231027  atom *OtherWalker = NULL;
     
    10281032  DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl);
    10291033  // fill ListOfLocalAtoms if NULL was given
    1030   if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) {
     1034  if (!FillListOfLocalAtoms(ListOfLocalAtoms, reference->getAtomCount(), FreeList)) {
    10311035    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    10321036    return false;
     
    10451049      AtomNo = Father->nr; // global id of the current walker
    10461050      for (BondList::const_iterator Runner = Father->ListOfBonds.begin(); Runner != Father->ListOfBonds.end(); (++Runner)) {
    1047         OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker
     1051        OtherWalker = ListOfLocalAtoms[(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker
    10481052        if (OtherWalker != NULL) {
    10491053          if (OtherWalker->nr > (*iter)->nr)
    10501054            Leaf->AddBond((*iter), OtherWalker, (*Runner)->BondDegree);
    10511055        } else {
    1052           DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr << "] is NULL!" << endl);
     1056          DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << (*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr << "] is NULL!" << endl);
    10531057          status = false;
    10541058        }
     
    10591063  if ((FreeList) && (ListOfLocalAtoms != NULL)) {
    10601064    // free the index lookup list
    1061     delete[](ListOfLocalAtoms[FragmentCounter]);
    1062     if (FragmentCounter == 0) // first fragments frees the initial pointer to list
    1063       delete[](ListOfLocalAtoms);
     1065    delete[](ListOfLocalAtoms);
    10641066  }
    10651067  DoLog(1) && (Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl);
     
    11071109/** Fills a lookup list of father's Atom::nr -> atom for each subgraph.
    11081110 * \param *out output stream from debugging
    1109  * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
    1110  * \param FragmentCounter counts the fragments as we move along the list
     1111 * \param **&ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
    11111112 * \param GlobalAtomCount number of atoms in the complete molecule
    11121113 * \param &FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
    1113  * \return true - success, false - failure
    1114  */
    1115 bool MoleculeLeafClass::FillListOfLocalAtoms(atom ***&ListOfLocalAtoms, const int FragmentCounter, const int GlobalAtomCount, bool &FreeList)
     1114 * \return true - success, false - failure (ListOfLocalAtoms != NULL)
     1115 */
     1116bool MoleculeLeafClass::FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount, bool &FreeList)
    11161117{
    11171118  bool status = true;
    11181119
    1119   if (ListOfLocalAtoms == NULL) { // allocated initial pointer
    1120     // allocate and set each field to NULL
    1121     const int Counter = Count();
    1122     ASSERT(FragmentCounter < Counter, "FillListOfLocalAtoms: FragmenCounter greater than present fragments.");
    1123     ListOfLocalAtoms = new atom**[Counter];
    1124     if (ListOfLocalAtoms == NULL) {
    1125       FreeList = FreeList && false;
    1126       status = false;
    1127     }
    1128     for (int i=0;i<Counter;i++)
    1129       ListOfLocalAtoms[i] = NULL;
    1130   }
    1131 
    1132   if ((ListOfLocalAtoms != NULL) && (ListOfLocalAtoms[FragmentCounter] == NULL)) { // allocate and fill list of this fragment/subgraph
    1133     status = status && Leaf->CreateFatherLookupTable(ListOfLocalAtoms[FragmentCounter], GlobalAtomCount);
     1120  if (ListOfLocalAtoms == NULL) { // allocate and fill list of this fragment/subgraph
     1121    status = status && Leaf->CreateFatherLookupTable(ListOfLocalAtoms, GlobalAtomCount);
    11341122    FreeList = FreeList && true;
    1135   }
     1123  } else
     1124    return false;
    11361125
    11371126  return status;
     
    11551144  DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl);
    11561145  // fill ListOfLocalAtoms if NULL was given
    1157   if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) {
     1146  if (!FillListOfLocalAtoms(ListOfLocalAtoms[FragmentCounter], reference->getAtomCount(), FreeList)) {
    11581147    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    11591148    return false;
     
    12001189    // free the index lookup list
    12011190    delete[](ListOfLocalAtoms[FragmentCounter]);
    1202     if (FragmentCounter == 0) // first fragments frees the initial pointer to list
    1203       delete[](ListOfLocalAtoms);
    12041191  }
    12051192  DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl);
  • src/orbitals.db

    r06f4ef6 rb6da28  
     1# atomicnumber numberoforbitals
    121       1
    232       0
  • src/parser.cpp

    r06f4ef6 rb6da28  
    1212
    1313#include "helpers.hpp"
    14 #include "memoryallocator.hpp"
    1514#include "parser.hpp"
     15#include "verbose.hpp"
    1616
    1717// include config.h
     
    7676MatrixContainer::~MatrixContainer() {
    7777  if (Matrix != NULL) {
     78    // free Matrix[MatrixCounter]
     79    if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL))
     80      for(int j=RowCounter[MatrixCounter]+1;j--;)
     81        delete[](Matrix[MatrixCounter][j]);
     82    //if (MatrixCounter != 0)
     83    delete[](Matrix[MatrixCounter]);
     84    // free all matrices but ultimate one
    7885    for(int i=MatrixCounter;i--;) {
    7986      if ((ColumnCounter != NULL) && (RowCounter != NULL)) {
     
    8390      }
    8491    }
    85     if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL))
    86       for(int j=RowCounter[MatrixCounter]+1;j--;)
    87         delete[](Matrix[MatrixCounter][j]);
    88     if (MatrixCounter != 0)
    89       delete[](Matrix[MatrixCounter]);
    9092    delete[](Matrix);
    9193  }
     94  // free indices
    9295  if (Indices != NULL)
    9396    for(int i=MatrixCounter+1;i--;) {
     
    9699  delete[](Indices);
    97100 
     101  // free header and counters
    98102  if (Header != NULL)
    99103    for(int i=MatrixCounter+1;i--;)
     
    168172
    169173  // parse header
     174  if (Header[MatrixNr] != NULL)
     175    delete[] Header[MatrixNr];
    170176  Header[MatrixNr] = new char[1024];
    171177  for (int m=skiplines+1;m--;)
     
    207213  // allocate matrix if it's not zero dimension in one direction
    208214  if ((ColumnCounter[MatrixNr] > 0) && (RowCounter[MatrixNr] > -1)) {
     215    if (Matrix[MatrixNr] != NULL)
     216      delete[] Matrix[MatrixNr];
    209217    Matrix[MatrixNr] = new double*[RowCounter[MatrixNr] + 1];
    210  
     218    for(int j=0;j<RowCounter[MatrixNr]+1;j++)
     219      Matrix[MatrixNr][j] = 0;
     220
    211221    // parse in each entry for this matrix
    212222    input.clear();
     
    219229    strncpy(Header[MatrixNr], line.str().c_str(), 1023); 
    220230    for(int j=0;j<RowCounter[MatrixNr];j++) {
     231      if (Matrix[MatrixNr][j] != NULL)
     232        delete[] Matrix[MatrixNr][j];
    221233      Matrix[MatrixNr][j] = new double[ColumnCounter[MatrixNr]];
     234      for(int k=0;k<ColumnCounter[MatrixNr];k++)
     235        Matrix[MatrixNr][j][k] = 0;
     236
    222237      input.getline(filename, 1023);
    223238      stringstream lines(filename);
     
    229244        //Log() << Verbose(1) << " " << setprecision(2) << Matrix[MatrixNr][j][k] << endl;
    230245      }
     246      if (Matrix[MatrixNr][ RowCounter[MatrixNr] ] != NULL)
     247        delete[] Matrix[MatrixNr][ RowCounter[MatrixNr] ];
    231248      Matrix[MatrixNr][ RowCounter[MatrixNr] ] = new double[ColumnCounter[MatrixNr]];
    232249      for(int j=ColumnCounter[MatrixNr];j--;)
  • src/periodentafel.cpp

    r06f4ef6 rb6da28  
    3232periodentafel::periodentafel()
    3333{
    34   bool status = true;
    35   status = LoadElementsDatabase(new stringstream(elementsDB,ios_base::in));
    36   ASSERT(status,  "General element initialization failed");
    37   status = LoadValenceDatabase(new stringstream(valenceDB,ios_base::in));
    38   ASSERT(status, "Valence entry of element initialization failed");
    39   status = LoadOrbitalsDatabase(new stringstream(orbitalsDB,ios_base::in));
    40   ASSERT(status, "Orbitals entry of element initialization failed");
    41   status = LoadHBondAngleDatabase(new stringstream(HbondangleDB,ios_base::in));
    42   ASSERT(status, "HBond angle entry of element initialization failed");
    43   status = LoadHBondLengthsDatabase(new stringstream(HbonddistanceDB,ios_base::in));
    44   ASSERT(status, "HBond distance entry of element initialization failed");
     34  {
     35    stringstream input(elementsDB,ios_base::in);
     36    bool status = LoadElementsDatabase(&input);
     37    ASSERT(status,  "General element initialization failed");
     38  }
     39  {
     40    stringstream input(valenceDB,ios_base::in);
     41    bool status = LoadValenceDatabase(&input);
     42    ASSERT(status, "Valence entry of element initialization failed");
     43  }
     44  {
     45    stringstream input(orbitalsDB,ios_base::in);
     46    bool status = LoadOrbitalsDatabase(&input);
     47    ASSERT(status, "Orbitals entry of element initialization failed");
     48  }
     49  {
     50    stringstream input(HbondangleDB,ios_base::in);
     51    bool status = LoadHBondAngleDatabase(&input);
     52    ASSERT(status, "HBond angle entry of element initialization failed");
     53  }
     54  {
     55    stringstream input(HbonddistanceDB,ios_base::in);
     56    bool status = LoadHBondLengthsDatabase(&input);
     57    ASSERT(status, "HBond distance entry of element initialization failed");
     58  }
    4559};
    4660
     
    111125 * \return pointer to element
    112126 */
    113 element * const periodentafel::FindElement(const char * const shorthand) const
     127element * const periodentafel::FindElement(const string &shorthand) const
    114128{
    115129  element *res = 0;
     
    197211};
    198212
    199 /** Prints period table to given stream.
    200  * \param *output output stream
    201  * \param *checkliste elements table for this molecule
    202  */
    203 bool periodentafel::Checkout(ostream * const output, const int * const checkliste) const
    204 {
    205   bool result = true;
    206   int No = 1;
    207 
    208   if (output != NULL) {
    209     *output << "# Ion type data (PP = PseudoPotential, Z = atomic number)" << endl;
    210     *output << "#Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol" << endl;
    211     for(const_iterator iter=elements.begin(); iter!=elements.end();++iter){
    212       if (((*iter).first < MAX_ELEMENTS) && (checkliste[(*iter).first])) {
    213         (*iter).second->No = No;
    214         result = result && (*iter).second->Checkout(output, No++, checkliste[(*iter).first]);
    215       }
    216     }
    217     return result;
    218   } else
    219     return false;
    220 };
    221 
    222213/** Loads element list from file.
    223214 * \param *path to to standard file names
     
    333324          ASSERT(Elemental != NULL, "element should be present but is not??");
    334325          *Elemental = *neues;
     326          delete(neues);
     327          neues = Elemental;
    335328        } else {
    336329          InserterTest = elements.insert(pair <atomicNumber_t,element*> (neues->getNumber(), neues));
     
    373366      (*input) >> elements[Z]->Valence;
    374367      (*input) >> ws;
    375       //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->Valence << " valence electrons." << endl;
     368      //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->Valence << " valence electrons." << endl;
    376369    }
    377370    return true;
     
    396389      (*input) >> elements[Z]->NoValenceOrbitals;
    397390      (*input) >> ws;
    398       //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
     391      //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
    399392    }
    400393    return true;
  • src/periodentafel.hpp

    r06f4ef6 rb6da28  
    99#endif
    1010
    11 #include <iostream>
     11#include <iosfwd>
    1212#include <map>
    13 #include <iterator>
     13#include <string>
    1414
    1515#include "unittests/periodentafelTest.hpp"
     
    4848  void CleanupPeriodtable();
    4949  element * const FindElement(atomicNumber_t) const;
    50   element * const FindElement(const char * const shorthand) const;
     50  element * const FindElement(const std::string &shorthand) const;
    5151  element * const AskElement() const;
    5252  element * const EnterElement();
     
    5757  reverse_iterator rend();
    5858  bool Output(std::ostream * const output) const;
    59   bool Checkout(std::ostream * const output, const int * const checkliste) const;
    6059  bool LoadPeriodentafel(const char * const path);
    6160  bool StorePeriodentafel(const char * const path) const;
  • src/stackclass.hpp

    r06f4ef6 rb6da28  
    1212
    1313#include "verbose.hpp"
    14 #include "memoryallocator.hpp"
     14#include "log.hpp"
    1515
    1616/****************************************** forward declarations *****************************/
  • src/tesselation.cpp

    r06f4ef6 rb6da28  
    99
    1010#include <fstream>
    11 #include <assert.h>
     11#include <iomanip>
    1212
    1313#include "helpers.hpp"
     
    2424#include "Plane.hpp"
    2525#include "Exceptions/LinearDependenceException.hpp"
    26 #include "Helpers/Assert.hpp"
    27 
    2826#include "Helpers/Assert.hpp"
    2927
     
    234232{
    235233  Info FunctionInfo(__func__);
     234  double angle = CalculateConvexity();
     235  if (angle > -MYEPSILON) {
     236    DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl);
     237    return true;
     238  } else {
     239    DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl);
     240    return false;
     241  }
     242}
     243
     244
     245/** Calculates the angle between two triangles with respect to their normal vector.
     246 * We sum the two angles of each height vector with respect to the center of the baseline.
     247 * \return angle > 0 then convex, if < 0 then concave
     248 */
     249double BoundaryLineSet::CalculateConvexity() const
     250{
     251  Info FunctionInfo(__func__);
    236252  Vector BaseLineCenter, BaseLineNormal, BaseLine, helper[2], NormalCheck;
    237253  // get the two triangles
     
    282298  BaseLineNormal.Scale(-1.);
    283299  double angle = GetAngle(helper[0], helper[1], BaseLineNormal);
    284   if ((angle - M_PI) > -MYEPSILON) {
    285     DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl);
    286     return true;
    287   } else {
    288     DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl);
    289     return false;
    290   }
     300  return (angle - M_PI);
    291301}
    292302
     
    307317/** Returns other endpoint of the line.
    308318 * \param *point other endpoint
    309  * \return NULL - if endpoint not contained in BoundaryLineSet, or pointer to BoundaryPointSet otherwise
     319 * \return NULL - if endpoint not contained in BoundaryLineSet::lines, or pointer to BoundaryPointSet otherwise
    310320 */
    311321class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(const BoundaryPointSet * const point) const
     
    318328  else
    319329    return NULL;
     330}
     331;
     332
     333/** Returns other triangle of the line.
     334 * \param *point other endpoint
     335 * \return NULL - if triangle not contained in BoundaryLineSet::triangles, or pointer to BoundaryTriangleSet otherwise
     336 */
     337class BoundaryTriangleSet *BoundaryLineSet::GetOtherTriangle(const BoundaryTriangleSet * const triangle) const
     338{
     339  Info FunctionInfo(__func__);
     340  if (triangles.size() == 2) {
     341    for (TriangleMap::const_iterator TriangleRunner = triangles.begin(); TriangleRunner != triangles.end(); ++TriangleRunner)
     342      if (TriangleRunner->second != triangle)
     343        return TriangleRunner->second;
     344  }
     345  return NULL;
    320346}
    321347;
     
    664690;
    665691
     692/** Returns the baseline which does not contain the given boundary point \a *point.
     693 * \param *point endpoint which is neither endpoint of the desired line
     694 * \return pointer to desired third baseline
     695 */
     696class BoundaryLineSet *BoundaryTriangleSet::GetThirdLine(const BoundaryPointSet * const point) const
     697{
     698  Info FunctionInfo(__func__);
     699  // sanity check
     700  if (!ContainsBoundaryPoint(point))
     701    return NULL;
     702  for (int i = 0; i < 3; i++)
     703    if (!lines[i]->ContainsBoundaryPoint(point))
     704      return lines[i];
     705  // actually, that' impossible :)
     706  return NULL;
     707}
     708;
     709
    666710/** Calculates the center point of the triangle.
    667711 * Is third of the sum of all endpoints.
     
    11131157    TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, (*VRunner));
    11141158
    1115     DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << OtherOptCenter << ":" << endl);
     1159    DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << (*VRunner) << ":" << endl);
    11161160    for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
    1117       DoLog(1) && (Log() << Verbose(1) << "  " << *(*Runner) << " with distance " << (*Runner)->node->distance(OtherOptCenter) << "." << endl);
     1161      DoLog(1) && (Log() << Verbose(1) << "  " << *(*Runner) << " with distance " << (*Runner)->node->distance(*(*VRunner)) << "." << endl);
    11181162
    11191163    // remove baseline's endpoints and candidates
     
    11311175      DoeLog(1) && (eLog() << Verbose(1) << "External atoms inside of sphere at " << *(*VRunner) << ":" << endl);
    11321176      for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
    1133         DoeLog(1) && (eLog() << Verbose(1) << "  " << *(*Runner) << endl);
     1177        DoeLog(1) && (eLog() << Verbose(1) << "  " << *(*Runner) << " at distance " << setprecision(13) << (*Runner)->node->distance(*(*VRunner)) << setprecision(6) << "." << endl);
     1178
     1179      // check with animate_sphere.tcl VMD script
     1180      if (ThirdPoint != NULL) {
     1181        DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " " << ThirdPoint->Nr + 1 << " " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);
     1182      } else {
     1183        DoeLog(1) && (eLog() << Verbose(1) << "Check by: ... missing third point ..." << endl);
     1184        DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " ??? " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);
     1185      }
    11341186    }
    11351187    delete (ListofPoints);
    11361188
    1137     // check with animate_sphere.tcl VMD script
    1138     if (ThirdPoint != NULL) {
    1139       DoLog(1) && (Log() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " " << ThirdPoint->Nr + 1 << " " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);
    1140     } else {
    1141       DoLog(1) && (Log() << Verbose(1) << "Check by: ... missing third point ..." << endl);
    1142       DoLog(1) && (Log() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " ??? " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);
    1143     }
    11441189  }
    11451190  return flag;
     
    16041649  bool AddFlag = false;
    16051650  LinkedCell *BoundaryPoints = NULL;
     1651  bool SuccessFlag = true;
    16061652
    16071653  cloud->GoToFirst();
     
    16171663    // get the next triangle
    16181664    triangles = FindClosestTrianglesToVector(Walker->node, BoundaryPoints);
    1619     BTS = triangles->front();
    1620     if ((triangles == NULL) || (BTS->ContainsBoundaryPoint(Walker))) {
     1665    if (triangles != NULL)
     1666      BTS = triangles->front();
     1667    else
     1668      BTS = NULL;
     1669    delete triangles;
     1670    if ((BTS == NULL) || (BTS->ContainsBoundaryPoint(Walker))) {
    16211671      DoLog(0) && (Log() << Verbose(0) << "No triangles found, probably a tesselation point itself." << endl);
    16221672      cloud->GoToNext();
     
    16881738    } else { // something is wrong with FindClosestTriangleToPoint!
    16891739      DoeLog(1) && (eLog() << Verbose(1) << "The closest triangle did not produce an intersection!" << endl);
    1690       return false;
     1740      SuccessFlag = false;
     1741      break;
    16911742    }
    16921743    cloud->GoToNext();
     
    16951746  // exit
    16961747  delete (Center);
    1697   return true;
     1748  delete (BoundaryPoints);
     1749  return SuccessFlag;
    16981750}
    16991751;
     
    21982250  for (int i = 0; i < NDIM; i++) { // each axis
    21992251    LC->n[i] = LC->N[i] - 1; // current axis is topmost cell
    2200     for (LC->n[(i + 1) % NDIM] = 0; LC->n[(i + 1) % NDIM] < LC->N[(i + 1) % NDIM]; LC->n[(i + 1) % NDIM]++)
    2201       for (LC->n[(i + 2) % NDIM] = 0; LC->n[(i + 2) % NDIM] < LC->N[(i + 2) % NDIM]; LC->n[(i + 2) % NDIM]++) {
     2252    const int map[NDIM] = {i, (i + 1) % NDIM, (i + 2) % NDIM};
     2253    for (LC->n[map[1]] = 0; LC->n[map[1]] < LC->N[map[1]]; LC->n[map[1]]++)
     2254      for (LC->n[map[2]] = 0; LC->n[map[2]] < LC->N[map[2]]; LC->n[map[2]]++) {
    22022255        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    22032256        //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    22042257        if (List != NULL) {
    22052258          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    2206             if ((*Runner)->node->at(i) > maxCoordinate[i]) {
    2207               DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << i << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl);
    2208               maxCoordinate[i] = (*Runner)->node->at(i);
    2209               MaxPoint[i] = (*Runner);
     2259            if ((*Runner)->node->at(map[0]) > maxCoordinate[map[0]]) {
     2260              DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << map[0] << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl);
     2261              maxCoordinate[map[0]] = (*Runner)->node->at(map[0]);
     2262              MaxPoint[map[0]] = (*Runner);
    22102263            }
    22112264          }
     
    25272580    baseline = Runner->second;
    25282581    if (baseline->pointlist.empty()) {
    2529       assert((baseline->BaseLine->triangles.size() == 1) && ("Open line without exactly one attached triangle"));
     2582      ASSERT((baseline->BaseLine->triangles.size() == 1),"Open line without exactly one attached triangle");
    25302583      T = (((baseline->BaseLine->triangles.begin()))->second);
    25312584      DoLog(1) && (Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl);
     
    32933346                        }
    32943347                      } else {
    3295                         DoLog(1) && (Log() << Verbose(1) << "REJECT: Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius - otherradius) << endl);
     3348                        DoeLog(0) && (eLog() << Verbose(1) << "REJECT: Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius - otherradius) << endl);
    32963349                      }
    32973350                    } else {
     
    45934646
    45944647  DoLog(0) && (Log() << Verbose(0) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles->size() << " triangles:" << endl);
    4595   IndexToIndex::iterator it;
    4596   for (it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++)
     4648  for (IndexToIndex::iterator it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++)
    45974649    DoLog(0) && (Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl);
    45984650
     
    46124664  int count = 0;
    46134665
    4614   for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); TriangleKeyRunner != DegeneratedTriangles->end(); ++TriangleKeyRunner) {
     4666  // iterate over all degenerated triangles
     4667  for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); !DegeneratedTriangles->empty(); TriangleKeyRunner = DegeneratedTriangles->begin()) {
     4668    DoLog(0) && (Log() << Verbose(0) << "Checking presence of triangles " << TriangleKeyRunner->first << " and " << TriangleKeyRunner->second << "." << endl);
     4669    // both ways are stored in the map, only use one
     4670    if (TriangleKeyRunner->first > TriangleKeyRunner->second)
     4671      continue;
     4672
     4673    // determine from the keys in the map the two _present_ triangles
    46154674    finder = TrianglesOnBoundary.find(TriangleKeyRunner->first);
    46164675    if (finder != TrianglesOnBoundary.end())
    46174676      triangle = finder->second;
    46184677    else
    4619       break;
     4678      continue;
    46204679    finder = TrianglesOnBoundary.find(TriangleKeyRunner->second);
    46214680    if (finder != TrianglesOnBoundary.end())
    46224681      partnerTriangle = finder->second;
    46234682    else
    4624       break;
    4625 
     4683      continue;
     4684
     4685    // determine which lines are shared by the two triangles
    46264686    bool trianglesShareLine = false;
    46274687    for (int i = 0; i < 3; ++i)
  • src/tesselation.hpp

    r06f4ef6 rb6da28  
    138138    bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
    139139    bool CheckConvexityCriterion() const;
     140    double CalculateConvexity() const;
    140141    class BoundaryPointSet *GetOtherEndpoint(const BoundaryPointSet * const point) const;
     142    class BoundaryTriangleSet *GetOtherTriangle(const BoundaryTriangleSet * const triangle) const;
    141143
    142144    class BoundaryPointSet *endpoints[2];
     
    164166    bool ContainsBoundaryPoint(const TesselPoint * const point) const;
    165167    class BoundaryPointSet *GetThirdEndpoint(const BoundaryLineSet * const line) const;
     168    class BoundaryLineSet *GetThirdLine(const BoundaryPointSet * const point) const;
    166169    bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const;
    167170    bool IsPresentTupel(const BoundaryTriangleSet * const T) const;
  • src/tesselationhelpers.cpp

    r06f4ef6 rb6da28  
    1212#include "info.hpp"
    1313#include "linkedcell.hpp"
     14#include "linearsystemofequations.hpp"
    1415#include "log.hpp"
    1516#include "tesselation.hpp"
     
    2021#include "verbose.hpp"
    2122#include "Plane.hpp"
    22 
    23 double DetGet(gsl_matrix * const A, const int inPlace)
    24 {
    25         Info FunctionInfo(__func__);
    26   /*
    27   inPlace = 1 => A is replaced with the LU decomposed copy.
    28   inPlace = 0 => A is retained, and a copy is used for LU.
    29   */
    30 
    31   double det;
    32   int signum;
    33   gsl_permutation *p = gsl_permutation_alloc(A->size1);
    34   gsl_matrix *tmpA=0;
    35 
    36   if (inPlace)
    37   tmpA = A;
    38   else {
    39   gsl_matrix *tmpA = gsl_matrix_alloc(A->size1, A->size2);
    40   gsl_matrix_memcpy(tmpA , A);
    41   }
    42 
    43 
    44   gsl_linalg_LU_decomp(tmpA , p , &signum);
    45   det = gsl_linalg_LU_det(tmpA , signum);
    46   gsl_permutation_free(p);
    47   if (! inPlace)
    48   gsl_matrix_free(tmpA);
    49 
    50   return det;
    51 };
     23#include "Matrix.hpp"
    5224
    5325void GetSphere(Vector * const center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS)
    5426{
    5527        Info FunctionInfo(__func__);
    56   gsl_matrix *A = gsl_matrix_calloc(3,3);
     28  Matrix mat;
    5729  double m11, m12, m13, m14;
    5830
    5931  for(int i=0;i<3;i++) {
    60     gsl_matrix_set(A, i, 0, a[i]);
    61     gsl_matrix_set(A, i, 1, b[i]);
    62     gsl_matrix_set(A, i, 2, c[i]);
    63   }
    64   m11 = DetGet(A, 1);
     32    mat.set(i, 0, a[i]);
     33    mat.set(i, 1, b[i]);
     34    mat.set(i, 2, c[i]);
     35  }
     36  m11 = mat.determinant();
    6537
    6638  for(int i=0;i<3;i++) {
    67     gsl_matrix_set(A, i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
    68     gsl_matrix_set(A, i, 1, b[i]);
    69     gsl_matrix_set(A, i, 2, c[i]);
    70   }
    71   m12 = DetGet(A, 1);
     39    mat.set(i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
     40    mat.set(i, 1, b[i]);
     41    mat.set(i, 2, c[i]);
     42  }
     43  m12 = mat.determinant();
    7244
    7345  for(int i=0;i<3;i++) {
    74     gsl_matrix_set(A, i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
    75     gsl_matrix_set(A, i, 1, a[i]);
    76     gsl_matrix_set(A, i, 2, c[i]);
    77   }
    78   m13 = DetGet(A, 1);
     46    mat.set(i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
     47    mat.set(i, 1, a[i]);
     48    mat.set(i, 2, c[i]);
     49  }
     50  m13 = mat.determinant();
    7951
    8052  for(int i=0;i<3;i++) {
    81     gsl_matrix_set(A, i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
    82     gsl_matrix_set(A, i, 1, a[i]);
    83     gsl_matrix_set(A, i, 2, b[i]);
    84   }
    85   m14 = DetGet(A, 1);
     53    mat.set(i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
     54    mat.set(i, 1, a[i]);
     55    mat.set(i, 2, b[i]);
     56  }
     57  m14 = mat.determinant();
    8658
    8759  if (fabs(m11) < MYEPSILON)
     
    9466  if (fabs(a.distance(*center) - RADIUS) > MYEPSILON)
    9567    DoeLog(1) && (eLog()<< Verbose(1) << "The given center is further way by " << fabs(a.distance(*center) - RADIUS) << " from a than RADIUS." << endl);
    96 
    97   gsl_matrix_free(A);
    9868};
    9969
     
    178148        Info FunctionInfo(__func__);
    179149  Vector helper;
    180   double alpha, beta, gamma;
    181150  Vector SideA = b - c;
    182151  Vector SideB = c - a;
    183152  Vector SideC = a - b;
    184   alpha = M_PI - SideB.Angle(SideC);
    185   beta = M_PI - SideC.Angle(SideA);
    186   gamma = M_PI - SideA.Angle(SideB);
    187   //Log() << Verbose(1) << "INFO: alpha = " << alpha/M_PI*180. << ", beta = " << beta/M_PI*180. << ", gamma = " << gamma/M_PI*180. << "." << endl;
    188   if (fabs(M_PI - alpha - beta - gamma) > HULLEPSILON) {
    189     DoeLog(2) && (eLog()<< Verbose(2) << "GetCenterofCircumcircle: Sum of angles " << (alpha+beta+gamma)/M_PI*180. << " > 180 degrees by " << fabs(M_PI - alpha - beta - gamma)/M_PI*180. << "!" << endl);
    190   }
     153
     154  helper[0] = SideA.NormSquared()*(SideB.NormSquared()+SideC.NormSquared() - SideA.NormSquared());
     155  helper[1] = SideB.NormSquared()*(SideC.NormSquared()+SideA.NormSquared() - SideB.NormSquared());
     156  helper[2] = SideC.NormSquared()*(SideA.NormSquared()+SideB.NormSquared() - SideC.NormSquared());
    191157
    192158  Center->Zero();
    193   helper = sin(2.*alpha) * a;
    194   (*Center) += helper;
    195   helper = sin(2.*beta) * b;
    196   (*Center) += helper;
    197   helper = sin(2.*gamma) * c;
    198   (*Center) += helper;
    199   Center->Scale(1./(sin(2.*alpha) + sin(2.*beta) + sin(2.*gamma)));
     159  *Center += helper[0] * a;
     160  *Center += helper[1] * b;
     161  *Center += helper[2] * c;
     162  Center->Scale(1./(helper[0]+helper[1]+helper[2]));
     163  Log() << Verbose(1) << "INFO: Center (2nd algo) is at " << *Center << "." << endl;
    200164};
    201165
     
    255219};
    256220
    257 /**
    258  * Intersection calculation function.
    259  *
    260  * @param x to find the result for
    261  * @param function parameter
    262  */
    263 double MinIntersectDistance(const gsl_vector * x, void *params)
    264 {
    265         Info FunctionInfo(__func__);
    266   double retval = 0;
    267   struct Intersection *I = (struct Intersection *)params;
    268   Vector intersection;
    269   for (int i=0;i<NDIM;i++)
    270     intersection[i] = gsl_vector_get(x, i);
    271 
    272   Vector SideA = I->x1 -I->x2 ;
    273   Vector HeightA = intersection - I->x1;
    274   HeightA.ProjectOntoPlane(SideA);
    275 
    276   Vector SideB = I->x3 - I->x4;
    277   Vector HeightB = intersection - I->x3;
    278   HeightB.ProjectOntoPlane(SideB);
    279 
    280   retval = HeightA.ScalarProduct(HeightA) + HeightB.ScalarProduct(HeightB);
    281   //Log() << Verbose(1) << "MinIntersectDistance called, result: " << retval << endl;
    282 
    283   return retval;
    284 };
    285 
    286 
    287 /**
    288  * Calculates whether there is an intersection between two lines. The first line
    289  * always goes through point 1 and point 2 and the second line is given by the
    290  * connection between point 4 and point 5.
    291  *
    292  * @param point 1 of line 1
    293  * @param point 2 of line 1
    294  * @param point 1 of line 2
    295  * @param point 2 of line 2
    296  *
    297  * @return true if there is an intersection between the given lines, false otherwise
    298  */
    299 bool existsIntersection(const Vector &point1, const Vector &point2, const Vector &point3, const Vector &point4)
    300 {
    301         Info FunctionInfo(__func__);
    302   bool result;
    303 
    304   struct Intersection par;
    305     par.x1 = point1;
    306     par.x2 = point2;
    307     par.x3 = point3;
    308     par.x4 = point4;
    309 
    310     const gsl_multimin_fminimizer_type *T = gsl_multimin_fminimizer_nmsimplex;
    311     gsl_multimin_fminimizer *s = NULL;
    312     gsl_vector *ss, *x;
    313     gsl_multimin_function minexFunction;
    314 
    315     size_t iter = 0;
    316     int status;
    317     double size;
    318 
    319     /* Starting point */
    320     x = gsl_vector_alloc(NDIM);
    321     gsl_vector_set(x, 0, point1[0]);
    322     gsl_vector_set(x, 1, point1[1]);
    323     gsl_vector_set(x, 2, point1[2]);
    324 
    325     /* Set initial step sizes to 1 */
    326     ss = gsl_vector_alloc(NDIM);
    327     gsl_vector_set_all(ss, 1.0);
    328 
    329     /* Initialize method and iterate */
    330     minexFunction.n = NDIM;
    331     minexFunction.f = &MinIntersectDistance;
    332     minexFunction.params = (void *)&par;
    333 
    334     s = gsl_multimin_fminimizer_alloc(T, NDIM);
    335     gsl_multimin_fminimizer_set(s, &minexFunction, x, ss);
    336 
    337     do {
    338         iter++;
    339         status = gsl_multimin_fminimizer_iterate(s);
    340 
    341         if (status) {
    342           break;
    343         }
    344 
    345         size = gsl_multimin_fminimizer_size(s);
    346         status = gsl_multimin_test_size(size, 1e-2);
    347 
    348         if (status == GSL_SUCCESS) {
    349           DoLog(1) && (Log() << Verbose(1) << "converged to minimum" <<  endl);
    350         }
    351     } while (status == GSL_CONTINUE && iter < 100);
    352 
    353     // check whether intersection is in between or not
    354   Vector intersection;
    355   double t1, t2;
    356   for (int i = 0; i < NDIM; i++) {
    357     intersection[i] = gsl_vector_get(s->x, i);
    358   }
    359 
    360   Vector SideA = par.x2 - par.x1;
    361   Vector HeightA = intersection - par.x1;
    362 
    363   t1 = HeightA.ScalarProduct(SideA)/SideA.ScalarProduct(SideA);
    364 
    365   Vector SideB = par.x4 - par.x3;
    366   Vector HeightB = intersection - par.x3;
    367 
    368   t2 = HeightB.ScalarProduct(SideB)/SideB.ScalarProduct(SideB);
    369 
    370   Log() << Verbose(1) << "Intersection " << intersection << " is at "
    371     << t1 << " for (" << point1 << "," << point2 << ") and at "
    372     << t2 << " for (" << point3 << "," << point4 << "): ";
    373 
    374   if (((t1 >= 0) && (t1 <= 1)) && ((t2 >= 0) && (t2 <= 1))) {
    375     DoLog(1) && (Log() << Verbose(1) << "true intersection." << endl);
    376     result = true;
    377   } else {
    378     DoLog(1) && (Log() << Verbose(1) << "intersection out of region of interest." << endl);
    379     result = false;
    380   }
    381 
    382   // free minimizer stuff
    383     gsl_vector_free(x);
    384     gsl_vector_free(ss);
    385     gsl_multimin_fminimizer_free(s);
    386 
    387   return result;
    388 };
    389 
    390221/** Gets the angle between a point and a reference relative to the provided center.
    391222 * We have two shanks point and reference between which the angle is calculated
     
    419250/** Calculates the volume of a general tetraeder.
    420251 * \param *a first vector
    421  * \param *a first vector
    422  * \param *a first vector
    423  * \param *a first vector
     252 * \param *b second vector
     253 * \param *c third vector
     254 * \param *d fourth vector
    424255 * \return \f$ \frac{1}{6} \cdot ((a-d) \times (a-c) \cdot  (a-b)) \f$
    425256 */
     
    439270  volume = 1./6. * fabs(Point.ScalarProduct(TetraederVector[2]));
    440271  return volume;
     272};
     273
     274/** Calculates the area of a general triangle.
     275 * We use the Heron's formula of area, [Bronstein, S. 138]
     276 * \param &A first vector
     277 * \param &B second vector
     278 * \param &C third vector
     279 * \return \f$ \frac{1}{6} \cdot ((a-d) \times (a-c) \cdot  (a-b)) \f$
     280 */
     281double CalculateAreaofGeneralTriangle(const Vector &A, const Vector &B, const Vector &C)
     282{
     283  Info FunctionInfo(__func__);
     284
     285  const double sidea = B.distance(C);
     286  const double sideb = A.distance(C);
     287  const double sidec = A.distance(B);
     288  const double s = (sidea+sideb+sidec)/2.;
     289
     290  const double area = sqrt(s*(s-sidea)*(s-sideb)*(s-sidec));
     291  return area;
    441292};
    442293
     
    574425          }
    575426        } else {
    576           eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << ","
    577             << LC->n[2] << " is invalid!" << endl;
     427          DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl);
    578428        }
    579429      }
     
    630480          }
    631481        } else {
    632           eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << ","
    633             << LC->n[2] << " is invalid!" << endl;
     482          DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl);
    634483        }
    635484      }
     
    882731  class BoundaryPointSet *point = NULL;
    883732  class BoundaryLineSet *line = NULL;
    884 
    885   // calculate remaining concavity
     733  class BoundaryTriangleSet *triangle = NULL;
     734  double ConcavityPerLine = 0.;
     735  double ConcavityPerTriangle = 0.;
     736  double area = 0.;
     737  double totalarea = 0.;
     738
    886739  for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
    887740    point = PointRunner->second;
    888741    DoLog(1) && (Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl);
    889     point->value = 0;
     742
     743    // calculate mean concavity over all connected line
     744    ConcavityPerLine = 0.;
    890745    for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
    891746      line = LineRunner->second;
    892747      //Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
    893       if (!line->CheckConvexityCriterion())
    894         point->value += 1;
    895     }
    896   }
    897 };
    898 
     748      ConcavityPerLine -= line->CalculateConvexity();
     749    }
     750    ConcavityPerLine /= point->lines.size();
     751
     752    // weigh with total area of the surrounding triangles
     753    totalarea  = 0.;
     754    TriangleSet *triangles = TesselStruct->GetAllTriangles(PointRunner->second);
     755    for (TriangleSet::iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); ++TriangleRunner) {
     756      totalarea += CalculateAreaofGeneralTriangle(*(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node);
     757    }
     758    ConcavityPerLine *= totalarea;
     759
     760    // calculate mean concavity over all attached triangles
     761    ConcavityPerTriangle = 0.;
     762    for (TriangleSet::const_iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); ++TriangleRunner) {
     763      line = (*TriangleRunner)->GetThirdLine(PointRunner->second);
     764      triangle = line->GetOtherTriangle(*TriangleRunner);
     765      area = CalculateAreaofGeneralTriangle(*triangle->endpoints[0]->node->node, *triangle->endpoints[1]->node->node, *triangle->endpoints[2]->node->node);
     766      area += CalculateAreaofGeneralTriangle(*(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node);
     767      area *= -line->CalculateConvexity();
     768      if (area > 0)
     769        ConcavityPerTriangle += area;
     770//      else
     771//        ConcavityPerTriangle -= area;
     772    }
     773    ConcavityPerTriangle /= triangles->size()/totalarea;
     774    delete(triangles);
     775
     776    // add up
     777    point->value = ConcavityPerLine + ConcavityPerTriangle;
     778  }
     779};
     780
     781
     782
     783/** Calculates the concavity for each of the BoundaryPointSet's in a Tesselation.
     784 * Sets BoundaryPointSet::value equal to the nearest distance to convex envelope.
     785 * \param *out output stream for debugging
     786 * \param *TesselStruct pointer to Tesselation structure
     787 * \param *Convex pointer to convex Tesselation structure as reference
     788 */
     789void CalculateConstrictionPerBoundaryPoint(const Tesselation * const TesselStruct, const Tesselation * const Convex)
     790{
     791  Info FunctionInfo(__func__);
     792  double distance = 0.;
     793
     794  for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
     795    DoeLog(1) && (eLog() << Verbose(1) << "INFO: Current point is " << * PointRunner->second << "." << endl);
     796
     797    distance = 0.;
     798    for (TriangleMap::const_iterator TriangleRunner = Convex->TrianglesOnBoundary.begin(); TriangleRunner != Convex->TrianglesOnBoundary.end(); TriangleRunner++) {
     799      const double CurrentDistance = Convex->GetDistanceSquaredToTriangle(*PointRunner->second->node->node, TriangleRunner->second);
     800      if (CurrentDistance < distance)
     801        distance = CurrentDistance;
     802    }
     803
     804    PointRunner->second->value = distance;
     805  }
     806};
    899807
    900808/** Checks whether each BoundaryLineSet in the Tesselation has two triangles.
  • src/tesselationhelpers.hpp

    r06f4ef6 rb6da28  
    2020#endif
    2121
    22 #include <gsl/gsl_linalg.h>
    23 #include <gsl/gsl_matrix.h>
    24 #include <gsl/gsl_multimin.h>
    25 #include <gsl/gsl_permutation.h>
    26 #include <gsl/gsl_vector.h>
    27 
    28 #include <iostream>
     22#include <iosfwd>
    2923
    3024#include "defs.hpp"
     
    4337/********************************************** definitions *********************************/
    4438
    45 #define HULLEPSILON 1e-10
     39#define HULLEPSILON 1e-9 //!< TODO: Get rid of HULLEPSILON, points to numerical instabilities
    4640
    4741/********************************************** declarations *******************************/
    4842
    49 double DetGet(gsl_matrix * const A, const int inPlace);
    5043void GetSphere(Vector * const Center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS);
    5144void GetCenterOfSphere(Vector* const Center, const Vector &a, const Vector &b, const Vector &c, Vector * const NewUmkreismittelpunkt, const Vector* const Direction, const Vector* const AlternativeDirection, const double HalfplaneIndicator, const double AlternativeIndicator, const double alpha, const double beta, const double gamma, const double RADIUS, const double Umkreisradius);
    5245void GetCenterofCircumcircle(Vector * const Center, const Vector &a, const Vector &b, const Vector &c);
    5346double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection);
    54 double MinIntersectDistance(const gsl_vector * x, void *params);
    55 bool existsIntersection(const Vector &point1, const Vector &point2, const Vector &point3, const Vector &point4);
    5647double CalculateVolumeofGeneralTetraeder(const Vector &a, const Vector &b, const Vector &c, const Vector &d);
     48double CalculateAreaofGeneralTriangle(const Vector &A, const Vector &B, const Vector &C);
    5749double GetAngle(const Vector &point, const Vector &reference, const Vector &OrthogonalVector);
    5850
     
    6860void WriteVrmlFile(ofstream * const vrmlfile, const Tesselation * const Tess, const PointCloud * const cloud);
    6961void CalculateConcavityPerBoundaryPoint(const Tesselation * const TesselStruct);
     62void CalculateConstrictionPerBoundaryPoint(const Tesselation * const TesselStruct, const Tesselation * const Convex);
    7063double DistanceToTrianglePlane(const Vector *x, const BoundaryTriangleSet * const triangle);
    7164
  • src/triangleintersectionlist.cpp

    r06f4ef6 rb6da28  
    1111#include "Helpers/MemDebug.hpp"
    1212
     13#include <boost/scoped_ptr.hpp>
     14
    1315#include "triangleintersectionlist.hpp"
    1416
     
    1618#include "tesselation.hpp"
    1719#include "vector.hpp"
     20#include "verbose.hpp"
    1821
    1922/** Constructor for class TriangleIntersectionList.
     
    118121
    119122  // get closest points
    120   DistanceToPointMap * points = Tess->FindClosestBoundaryPointsToVector(Point,Vicinity);
     123  boost::scoped_ptr< DistanceToPointMap > points(Tess->FindClosestBoundaryPointsToVector(Point,Vicinity));
    121124  if (points == NULL) {
    122125    DoeLog(1) && (eLog()<< Verbose(1) << "There is no nearest point: too far away from the surface." << endl);
  • src/unittests/ActOnAllUnitTest.cpp

    r06f4ef6 rb6da28  
    1414#include "../test/ActOnAlltest.hpp"
    1515#include "ActOnAllUnitTest.hpp"
    16 #include "memoryallocator.hpp"
    1716#include "vector.hpp"
    1817
  • src/unittests/ActionSequenceTest.cpp

    r06f4ef6 rb6da28  
    1717#include "Actions/ActionRegistry.hpp"
    1818
     19#include "DummyUI.hpp"
     20
    1921#ifdef HAVE_TESTRUNNER
    2022#include "UnitTestMain.hpp"
     
    3335  virtual ~canUndoActionStub(){}
    3436
     37  virtual Dialog* fillDialog(Dialog *dialog){
     38    ASSERT(dialog,"No Dialog given when filling action dialog");
     39    return dialog;
     40  }
     41
    3542  virtual Action::state_ptr performCall(){
    3643    return Action::success;
     
    5562  cannotUndoActionStub() : Action("cannotUndoActionStub",false){}
    5663  virtual ~cannotUndoActionStub(){}
     64
     65  virtual Dialog* fillDialog(Dialog *dialog){
     66    ASSERT(dialog,"No Dialog given when filling action dialog");
     67    return dialog;
     68  }
    5769
    5870  virtual Action::state_ptr performCall(){
     
    8294  virtual ~wasCalledActionStub(){}
    8395
     96  virtual Dialog* fillDialog(Dialog *dialog){
     97    return dialog;
     98  }
    8499  virtual Action::state_ptr performCall(){
    85100    called = true;
     
    108123
    109124void ActionSequenceTest::setUp(){
     125  static bool hasDescriptor = false;
    110126  ActionHistory::init();
     127  // TODO: find a way to really reset the factory to a clean state in tear-down
     128  if(!hasDescriptor){
     129    UIFactory::registerFactory(new DummyUIFactory::description());
     130    hasDescriptor = true;
     131  }
     132  UIFactory::makeUserInterface("Dummy");
    111133  // create some necessary stubs used in this test
    112134  positive1 = new canUndoActionStub();
     
    135157  ActionHistory::purgeInstance();
    136158  ActionRegistry::purgeInstance();
     159  UIFactory::purgeInstance();
    137160}
    138161
     
    220243
    221244  CPPUNIT_ASSERT_EQUAL(true,wasCalled1->wasCalled());
    222   CPPUNIT_ASSERT_EQUAL(true,wasCalled1->wasCalled());
     245  CPPUNIT_ASSERT_EQUAL(true,wasCalled2->wasCalled());
    223246
    224247  ActionHistory::getInstance().undoLast();
    225248
    226249  CPPUNIT_ASSERT_EQUAL(false,wasCalled1->wasCalled());
    227   CPPUNIT_ASSERT_EQUAL(false,wasCalled1->wasCalled());
    228 
    229 }
    230 
    231 
     250  CPPUNIT_ASSERT_EQUAL(false,wasCalled2->wasCalled());
     251
     252}
     253
     254
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    r06f4ef6 rb6da28  
    1616#include "analysis_correlation.hpp"
    1717#include "AnalysisCorrelationToPointUnitTest.hpp"
     18
     19#include "Descriptors/MoleculeDescriptor.hpp"
    1820
    1921#include "atom.hpp"
     
    3840
    3941  // init private all pointers to zero
    40   TestList = NULL;
    4142  TestMolecule = NULL;
    4243  pointmap = NULL;
     
    7172  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    7273
    73   TestList = World::getInstance().getMolecules();
    74   TestList->insert(TestMolecule);
    7574  TestMolecule->ActiveFlag = true;
    7675
     
    7978
    8079  // init maps
    81   pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, elements, (const Vector *)point );
     80  World::getInstance().selectAllMolecules(AllMolecules());
     81  allMolecules = World::getInstance().getSelectedMolecules();
     82  CPPUNIT_ASSERT_EQUAL( (size_t) 1, allMolecules.size());
     83  pointmap = CorrelationToPoint( allMolecules, elements, (const Vector *)point );
    8284  binmap = NULL;
    8385
  • src/unittests/AnalysisCorrelationToPointUnitTest.hpp

    r06f4ef6 rb6da28  
    3535private:
    3636
    37       MoleculeListClass *TestList;
     37      std::vector<molecule *> allMolecules;
    3838      molecule *TestMolecule;
    3939      element *hydrogen;
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    r06f4ef6 rb6da28  
    1616#include "analysis_correlation.hpp"
    1717#include "AnalysisCorrelationToSurfaceUnitTest.hpp"
     18
     19#include "Descriptors/MoleculeDescriptor.hpp"
    1820
    1921#include "atom.hpp"
     
    4547
    4648  // init private all pointers to zero
    47   TestList = NULL;
    4849  TestSurfaceMolecule = NULL;
    4950  surfacemap = NULL;
     
    8384  CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 );
    8485
    85   TestList = World::getInstance().getMolecules();
    8686  TestSurfaceMolecule->ActiveFlag = true;
    87   TestList->insert(TestSurfaceMolecule);
    8887
    8988  // init tesselation and linked cell
     
    116115  TestSurfaceMolecule->AddAtom(Walker);
    117116
    118   TestSurfaceMolecule->ActiveFlag = true;
    119   TestList->insert(TestSurfaceMolecule);
     117  World::getInstance().selectAllMolecules(AllMolecules());
     118  allMolecules = World::getInstance().getSelectedMolecules();
     119  CPPUNIT_ASSERT_EQUAL( (size_t) 2, allMolecules.size());
    120120
    121121  // init maps
     
    146146{
    147147  CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() );
    148   CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() );
     148  CPPUNIT_ASSERT_EQUAL( (size_t)2, allMolecules.size() );
    149149  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
    150150  CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() );
     
    156156  // do the pair correlation
    157157  elements.push_back(hydrogen);
    158   surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
     158  surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC );
    159159//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    160160  CPPUNIT_ASSERT( surfacemap != NULL );
     
    166166  BinPairMap::iterator tester;
    167167  elements.push_back(hydrogen);
    168   surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
     168  surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC );
    169169  // put pair correlation into bins and check with no range
    170170//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
     
    182182  BinPairMap::iterator tester;
    183183  elements.push_back(hydrogen);
    184   surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
     184  surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC );
    185185//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    186186  // ... and check with [0., 2.] range
     
    201201  BinPairMap::iterator tester;
    202202  elements.push_back(carbon);
    203   surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
     203  surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC );
    204204//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    205205  // put pair correlation into bins and check with no range
     
    221221  BinPairMap::iterator tester;
    222222  elements.push_back(carbon);
    223   surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
     223  surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC );
    224224//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    225225  // ... and check with [0., 2.] range
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp

    r06f4ef6 rb6da28  
    4343private:
    4444
    45       MoleculeListClass *TestList;
     45      std::vector<molecule *> allMolecules;
    4646      molecule *TestSurfaceMolecule;
    4747      element *hydrogen;
  • src/unittests/AnalysisPairCorrelationUnitTest.cpp

    r06f4ef6 rb6da28  
    1616#include "analysis_correlation.hpp"
    1717#include "AnalysisPairCorrelationUnitTest.hpp"
     18
     19#include "Descriptors/MoleculeDescriptor.hpp"
    1820
    1921#include "World.hpp"
     
    4244
    4345  // init private all pointers to zero
    44   TestList = NULL;
    4546  TestMolecule = NULL;
    4647  correlationmap = NULL;
     
    7677  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    7778
    78   TestList = World::getInstance().getMolecules();
    79   TestMolecule->ActiveFlag = true;
    80   TestList->insert(TestMolecule);
    81 
    8279  // init maps
    83   correlationmap = PairCorrelation( TestList, elements);
     80  World::getInstance().selectAllMolecules(AllMolecules());
     81  allMolecules = World::getInstance().getSelectedMolecules();
     82  CPPUNIT_ASSERT_EQUAL( (size_t) 1, allMolecules.size());
     83  correlationmap = PairCorrelation( allMolecules, elements);
    8484  binmap = NULL;
    8585
  • src/unittests/AnalysisPairCorrelationUnitTest.hpp

    r06f4ef6 rb6da28  
    3535private:
    3636
    37       MoleculeListClass *TestList;
     37      std::vector<molecule *> allMolecules;
    3838      molecule *TestMolecule;
    3939      element *hydrogen;
  • src/unittests/CountBondsUnitTest.cpp

    r06f4ef6 rb6da28  
    154154  Translator  = Vector(3,0,0);
    155155  TestMolecule2->Translate(&Translator);
    156   CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL) );
    157   CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, oxygen) );
     156  CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
     157  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, oxygen, NULL) );
    158158  //OutputTestMolecule(TestMolecule2, "testmolecule2-1.xyz");
    159159  Translator = Vector(-3,0,0);
     
    163163  Translator = Vector(0,3,0);
    164164  TestMolecule2->Translate(&Translator);
    165   CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL) );
     165  CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    166166  //OutputTestMolecule(TestMolecule2, "testmolecule2-2.xyz");
    167167  Translator = Vector(0,-3,0);
     
    172172  TestMolecule2->Scale((const double ** const)&mirror);
    173173  TestMolecule2->Translate(&Translator);
    174   CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL) );
     174  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    175175  //OutputTestMolecule(TestMolecule2, "testmolecule2-3.xyz");
    176176  Translator = Vector(0,3,0);
     
    181181  Translator = Vector(2,1,0);
    182182  TestMolecule2->Translate(&Translator);
    183   CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL) );
     183  CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    184184  //OutputTestMolecule(TestMolecule2, "testmolecule2-4.xyz");
    185185  Translator = Vector(-2,-1,0);
     
    189189  Translator = Vector(0,0,3);
    190190  TestMolecule2->Translate(&Translator);
    191   CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL) );
     191  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    192192  //OutputTestMolecule(TestMolecule2, "testmolecule2-5.xyz");
    193193  Translator = Vector(0,0,-3);
     
    198198  TestMolecule2->Scale((const double ** const)&mirror);
    199199  TestMolecule2->Translate(&Translator);
    200   CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL) );
     200  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    201201  //OutputTestMolecule(TestMolecule2, "testmolecule2-6.xyz");
    202202  Translator = Vector(3,0,0);
     
    208208  TestMolecule2->Scale((const double ** const)&mirror);
    209209  TestMolecule2->Translate(&Translator);
    210   CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL) );
     210  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    211211  //OutputTestMolecule(TestMolecule2, "testmolecule2-7.xyz");
    212212  Translator = Vector(-3,0,0);
     
    219219  TestMolecule2->Translate(&Translator);
    220220  //OutputTestMolecule(TestMolecule2, "testmolecule2-8.xyz");
    221   CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL) );
     221  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) );
    222222  Translator = Vector(0,-3,0);
    223223  TestMolecule2->Translate(&Translator);
  • src/unittests/LineUnittest.cpp

    r06f4ef6 rb6da28  
    1717
    1818#include <iostream>
     19#include <cmath>
    1920
    2021using namespace std;
     
    352353  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
    353354}
     355
     356void LineUnittest::sphereIntersectionTest(){
     357  {
     358    std::vector<Vector> res = la1->getSphereIntersections();
     359    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
     360    CPPUNIT_ASSERT(testDirection(res[0],e1));
     361    CPPUNIT_ASSERT(testDirection(res[1],e1));
     362    CPPUNIT_ASSERT(res[0]!=res[1]);
     363  }
     364
     365  {
     366    std::vector<Vector> res = la2->getSphereIntersections();
     367    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
     368    CPPUNIT_ASSERT(testDirection(res[0],e2));
     369    CPPUNIT_ASSERT(testDirection(res[1],e2));
     370    CPPUNIT_ASSERT(res[0]!=res[1]);
     371  }
     372
     373  {
     374    std::vector<Vector> res = la3->getSphereIntersections();
     375    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
     376    CPPUNIT_ASSERT(testDirection(res[0],e3));
     377    CPPUNIT_ASSERT(testDirection(res[1],e3));
     378    CPPUNIT_ASSERT(res[0]!=res[1]);
     379  }
     380
     381  {
     382    std::vector<Vector> res = lp1->getSphereIntersections();
     383    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
     384    CPPUNIT_ASSERT((res[0]==e1) || (res[0]==e2));
     385    CPPUNIT_ASSERT((res[1]==e1) || (res[1]==e2));
     386    CPPUNIT_ASSERT(res[0]!=res[1]);
     387  }
     388
     389  {
     390    std::vector<Vector> res = lp2->getSphereIntersections();
     391    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
     392    CPPUNIT_ASSERT((res[0]==e2) || (res[0]==e3));
     393    CPPUNIT_ASSERT((res[1]==e2) || (res[1]==e3));
     394    CPPUNIT_ASSERT(res[0]!=res[1]);
     395  }
     396
     397  {
     398    std::vector<Vector> res = lp3->getSphereIntersections();
     399    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
     400    CPPUNIT_ASSERT((res[0]==e3) || (res[0]==e1));
     401    CPPUNIT_ASSERT((res[1]==e3) || (res[1]==e1));
     402    CPPUNIT_ASSERT(res[0]!=res[1]);
     403  }
     404}
  • src/unittests/LineUnittest.hpp

    r06f4ef6 rb6da28  
    2222  CPPUNIT_TEST ( intersectionTest );
    2323  CPPUNIT_TEST ( rotationTest );
     24  CPPUNIT_TEST ( sphereIntersectionTest );
    2425  CPPUNIT_TEST_SUITE_END();
    2526
     
    3334  void intersectionTest();
    3435  void rotationTest();
     36  void sphereIntersectionTest();
    3537
    3638private:
  • src/unittests/LinkedCellUnitTest.cpp

    r06f4ef6 rb6da28  
    264264  Vector tester;
    265265  LinkedCell::LinkedNodes *ListOfPoints = NULL;
    266   atom *Walker = NULL;
    267266  size_t size = 0;
    268267
     
    326325  Vector tester;
    327326  LinkedCell::LinkedNodes *ListOfPoints = NULL;
    328   atom *Walker = NULL;
    329327  size_t size = 0;
    330328
  • src/unittests/Makefile.am

    r06f4ef6 rb6da28  
    77AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
    88
    9 MENUTESTS = \
    10   ActionSequenceTest
    11 
    129TESTS = \
     10  ActionSequenceTest \
    1311  ActOnAllUnitTest \
    1412  AnalysisBondsUnitTests \
     
    1917  AtomDescriptorTest \
    2018  BondGraphUnitTest \
     19  BoxUnittest \
    2120  CacheableTest \
    2221  CountBondsUnitTest \
     22  FormulaUnittest \
    2323  GSLMatrixSymmetricUnitTest \
    2424  GSLMatrixUnitTest \
     
    3131  LogUnitTest \
    3232  manipulateAtomsTest \
    33   MemoryUsageObserverUnitTest \
    34   MemoryAllocatorUnitTest \
     33  MatrixUnittest \
    3534  MoleculeDescriptorTest \
    3635  ObserverTest \
     
    4443  Tesselation_BoundaryTriangleUnitTest \
    4544  Tesselation_InOutsideUnitTest \
    46   VectorUnitTest \
    47   ${MENUTESTS}
     45  VectorUnitTest
    4846 
    4947 
     
    5149noinst_PROGRAMS = $(TESTS) TestRunner
    5250
    53 GSLLIBS = ../libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
     51GSLLIBS = ../libgslwrapper.a ../libmolecuilderbase.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
    5452ALLLIBS = ../libmolecuilder.a ${GSLLIBS}
     53PARSERLIBS = ../libparser.a ${ALLLIBS}
     54UILIBS = ../UIElements/libMolecuilderUI.a ../Actions/libMolecuilderActions.a ${ALLLIBS} ${BOOST_PROGRAM_OPTIONS_LIB}
    5555
    5656TESTSOURCES = \
     
    6464  atomsCalculationTest.cpp \
    6565  bondgraphunittest.cpp \
     66  BoxUnittest.cpp \
    6667  CacheableTest.cpp \
    6768  CountBondsUnitTest.cpp \
     69  FormulaUnittest.cpp \
    6870  gslmatrixsymmetricunittest.cpp \
    6971  gslmatrixunittest.cpp \
     
    7577  listofbondsunittest.cpp \
    7678  logunittest.cpp \
     79  MatrixUnittest.cpp \
    7780  manipulateAtomsTest.cpp \
    78   memoryallocatorunittest.cpp  \
    79   memoryusageobserverunittest.cpp \
    8081  MoleculeDescriptorTest.cpp \
    8182  ObserverTest.cpp \
     
    101102  atomsCalculationTest.hpp \
    102103  bondgraphunittest.hpp \
     104  BoxUnittest.hpp \
    103105  CacheableTest.hpp \
    104106  CountBondsUnitTest.hpp \
     107  FormulaUnittest.hpp \
    105108  gslmatrixsymmetricunittest.hpp \
    106109  gslmatrixunittest.hpp \
     
    113116  logunittest.hpp \
    114117  manipulateAtomsTest.hpp \
    115   memoryallocatorunittest.hpp  \
    116   memoryusageobserverunittest.hpp \
     118  MatrixUnittest.hpp \
    117119  MoleculeDescriptorTest.hpp \
    118120  periodentafelTest.hpp \
     
    127129 
    128130
    129 ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp
    130 ActionSequenceTest_LDADD = ${ALLLIBS}
     131ActionSequenceTest_SOURCES = UnitTestMain.cpp ActionSequenceTest.cpp ActionSequenceTest.hpp $(srcdir)/../version.c
     132ActionSequenceTest_LDADD = ${UILIBS}
    131133
    132134ActOnAllUnitTest_SOURCES = UnitTestMain.cpp ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp
     
    154156BondGraphUnitTest_LDADD = ${ALLLIBS}
    155157
     158BoxUnittest_SOURCES = UnitTestMain.cpp BoxUnittest.cpp BoxUnittest.hpp
     159BoxUnittest_LDADD = ${ALLLIBS}
     160
    156161CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp
    157162CacheableTest_LDADD = ${ALLLIBS}
     
    160165CountBondsUnitTest_LDADD = ${ALLLIBS}
    161166
     167FormulaUnittest_SOURCES = UnitTestMain.cpp FormulaUnittest.cpp FormulaUnittest.hpp
     168FormulaUnittest_LDADD = ${ALLLIBS}
     169
    162170GSLMatrixSymmetricUnitTest_SOURCES = UnitTestMain.cpp gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp
    163171GSLMatrixSymmetricUnitTest_LDADD = ${GSLLIBS}
     
    187195LogUnitTest_LDADD = ${ALLLIBS}
    188196
    189 manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp
    190 manipulateAtomsTest_LDADD = ${ALLLIBS}
    191 
    192 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp
    193 MemoryAllocatorUnitTest_LDADD = ${ALLLIBS}
    194 
    195 MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp
    196 MemoryUsageObserverUnitTest_LDADD = ${ALLLIBS}
     197manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp $(srcdir)/../version.c
     198manipulateAtomsTest_LDADD = ${UILIBS}
     199
     200MatrixUnittest_SOURCES = UnitTestMain.cpp MatrixUnittest.cpp MatrixUnittest.hpp
     201MatrixUnittest_LDADD = ${ALLLIBS}
    197202
    198203MoleculeDescriptorTest_SOURCES = UnitTestMain.cpp MoleculeDescriptorTest.cpp MoleculeDescriptorTest.hpp
     
    203208
    204209ParserUnitTest_SOURCES = UnitTestMain.cpp ParserUnitTest.cpp ParserUnitTest.hpp
    205 ParserUnitTest_LDADD = ${ALLLIBS}
     210ParserUnitTest_LDADD = ${PARSERLIBS}
    206211
    207212periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp
     
    215220
    216221SingletonTest_SOURCES = UnitTestMain.cpp SingletonTest.cpp SingletonTest.hpp
    217 SingletonTest_LDADD = $(BOOST_LIB) ${BOOST_THREAD_LIB}
     222SingletonTest_LDADD = ${ALLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB}
    218223
    219224StackClassUnitTest_SOURCES = UnitTestMain.cpp stackclassunittest.cpp stackclassunittest.hpp
     
    229234Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS}
    230235
    231 TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp $(TESTSOURCES) $(TESTHEADERS)
    232 TestRunner_LDADD = ${ALLLIBS}
     236TestRunner_SOURCES = TestRunnerMain.cpp $(srcdir)/../version.c $(TESTSOURCES) $(TESTHEADERS)
     237TestRunner_LDADD = ../UIElements/libMolecuilderUI.a ../Actions/libMolecuilderActions.a ../libmolecuilder.a ../libparser.a ../libgslwrapper.a ../libmolecuilderbase.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}
    233238
    234239VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp
  • src/unittests/ObserverTest.cpp

    r06f4ef6 rb6da28  
    182182};
    183183
    184 class ObservableCollection : public Observable {
     184class ObservableSet : public Observable {
    185185public:
    186186  typedef std::set<SimpleObservable*> set;
     
    188188  typedef set::const_iterator const_iterator;
    189189
    190   ObservableCollection(int _num) :
     190  ObservableSet(int _num) :
    191191    Observable("ObservableCollection"),
    192192    num(_num)
     
    199199  }
    200200
    201   ~ObservableCollection(){
     201  ~ObservableSet(){
    202202    set::iterator iter;
    203203    for(iter=theSet.begin(); iter!=theSet.end(); ++iter ){
    204204      delete (*iter);
     205    }
     206  }
     207
     208  iterator begin(){
     209    return iterator(theSet.begin(),this);
     210  }
     211
     212  iterator end(){
     213    return iterator(theSet.end(),this);
     214  }
     215
     216  const int num;
     217
     218private:
     219  set theSet;
     220};
     221
     222class ObservableMap : public Observable {
     223public:
     224  typedef std::map<int,SimpleObservable*> set;
     225  typedef ObservedIterator<set> iterator;
     226  typedef set::const_iterator const_iterator;
     227
     228  ObservableMap(int _num) :
     229    Observable("ObservableCollection"),
     230    num(_num)
     231  {
     232    for(int i=0; i<num; ++i){
     233      SimpleObservable *content = new SimpleObservable();
     234      content->signOn(this);
     235      theSet.insert(make_pair(i,content));
     236    }
     237  }
     238
     239  ~ObservableMap(){
     240    set::iterator iter;
     241    for(iter=theSet.begin(); iter!=theSet.end(); ++iter ){
     242      delete iter->second;
    205243    }
    206244  }
     
    231269  blockObservable = new BlockObservable();
    232270  notificationObservable = new NotificationObservable();
    233   collection = new ObservableCollection(5);
     271  obsset = new ObservableSet(5);
     272  obsmap = new ObservableMap(5);
    234273
    235274  observer1 = new UpdateCountObserver();
     
    249288  delete blockObservable;
    250289  delete notificationObservable;
    251   delete collection;
     290  delete obsset;
     291  delete obsmap;
    252292
    253293  delete observer1;
     
    268308  simpleObservable2->signOn(observer4);
    269309
     310  CPPUNIT_ASSERT_EQUAL( 0, observer1->updates );
     311  CPPUNIT_ASSERT_EQUAL( 0, observer2->updates );
     312  CPPUNIT_ASSERT_EQUAL( 0, observer3->updates );
     313  CPPUNIT_ASSERT_EQUAL( 0, observer4->updates );
     314
     315
    270316  simpleObservable1->changeMethod();
    271317  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates );
     
    292338void ObserverTest::doesBlockUpdateTest() {
    293339  callObservable->signOn(observer1);
     340  CPPUNIT_ASSERT_EQUAL( 0, observer1->updates );
    294341
    295342  callObservable->changeMethod1();
     
    311358  CPPUNIT_ASSERT_EQUAL( 2, observer1->updates );
    312359  CPPUNIT_ASSERT_EQUAL( 2, observer2->updates );
     360}
     361
     362void ObserverTest::outsideLockTest(){
     363  callObservable->signOn(observer1);
     364  CPPUNIT_ASSERT_EQUAL( 0, observer1->updates );
     365
     366  {
     367    LOCK_OBSERVABLE(*callObservable);
     368    CPPUNIT_ASSERT_EQUAL( 0, observer1->updates );
     369  }
     370  // lock is gone now, observer should have notified
     371  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates );
    313372}
    314373
     
    341400  int i = 0;
    342401  // test the general iterator methods
    343   for(ObservableCollection::iterator iter=collection->begin(); iter!=collection->end();++iter){
    344     CPPUNIT_ASSERT(i< collection->num);
     402  for(ObservableSet::iterator iter=obsset->begin(); iter!=obsset->end();++iter){
     403    CPPUNIT_ASSERT(i< obsset->num);
    345404    i++;
    346405  }
    347406
    348407  i=0;
    349   for(ObservableCollection::const_iterator iter=collection->begin(); iter!=collection->end();++iter){
    350     CPPUNIT_ASSERT(i<collection->num);
    351     i++;
    352   }
    353 
    354   collection->signOn(observer1);
     408  for(ObservableSet::const_iterator iter=obsset->begin(); iter!=obsset->end();++iter){
     409    CPPUNIT_ASSERT(i<obsset->num);
     410    i++;
     411  }
     412
     413  obsset->signOn(observer1);
    355414  {
    356415    // we construct this out of the loop, so the iterator dies at the end of
    357416    // the scope and not the end of the loop (allows more testing)
    358     ObservableCollection::iterator iter;
    359     for(iter=collection->begin(); iter!=collection->end(); ++iter){
     417    ObservableSet::iterator iter;
     418    for(iter=obsset->begin(); iter!=obsset->end(); ++iter){
    360419      (*iter)->changeMethod();
    361420    }
     
    367426
    368427  // when using a const_iterator no changes should be propagated
    369   for(ObservableCollection::const_iterator iter = collection->begin(); iter!=collection->end();++iter);
     428  for(ObservableSet::const_iterator iter = obsset->begin(); iter!=obsset->end();++iter);
    370429  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates);
    371   collection->signOff(observer1);
     430
     431  // we need to test the operator-> as well
     432  obsmap->signOn(observer2);
     433  {
     434    // we construct this out of the loop, so the iterator dies at the end of
     435    // the scope and not the end of the loop (allows more testing)
     436    ObservableMap::iterator iter;
     437    for(iter=obsmap->begin(); iter!=obsmap->end(); ++iter){
     438      iter->second->changeMethod();
     439    }
     440    // At this point no change should have been propagated
     441    CPPUNIT_ASSERT_EQUAL( 0, observer2->updates);
     442  }
     443  // After the Iterator has died the propagation should take place
     444  CPPUNIT_ASSERT_EQUAL( 1, observer2->updates);
     445
     446
     447  obsset->signOff(observer1);
     448  obsmap->signOff(observer2);
    372449}
    373450
     
    382459  // make this Observable its own subject. NEVER DO THIS IN ACTUAL CODE
    383460  simpleObservable1->signOn(simpleObservable1);
     461#ifndef NDEBUG
    384462  CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure);
     463#else
     464  simpleObservable1->changeMethod();
     465#endif
    385466
    386467  // more complex test
     
    388469  simpleObservable1->signOn(simpleObservable2);
    389470  simpleObservable2->signOn(simpleObservable1);
     471#ifndef NDEBUG
    390472  CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure);
     473#else
     474  simpleObservable1->changeMethod();
     475#endif
     476
     477
    391478  simpleObservable1->signOff(simpleObservable2);
    392479  simpleObservable2->signOff(simpleObservable1);
  • src/unittests/ObserverTest.hpp

    r06f4ef6 rb6da28  
    1717class CallObservable;
    1818class SuperObservable;
    19 class ObservableCollection;
     19class ObservableSet;
     20class ObservableMap;
    2021class BlockObservable;
    2122class NotificationObservable;
     
    2728  CPPUNIT_TEST ( doesBlockUpdateTest );
    2829  CPPUNIT_TEST ( doesSubObservableTest );
     30  CPPUNIT_TEST ( outsideLockTest );
    2931  CPPUNIT_TEST ( doesNotifyTest );
    3032  CPPUNIT_TEST ( doesReportTest );
     
    4042  void doesBlockUpdateTest();
    4143  void doesSubObservableTest();
     44  void outsideLockTest();
    4245  void doesNotifyTest();
    4346  void doesReportTest();
     
    6063  SuperObservable *superObservable;
    6164  NotificationObservable *notificationObservable;
    62   ObservableCollection *collection;
     65  ObservableSet *obsset;
     66  ObservableMap *obsmap;
    6367
    6468};
  • src/unittests/ParserUnitTest.cpp

    r06f4ef6 rb6da28  
    1212#include <cppunit/ui/text/TestRunner.h>
    1313
     14#include "Parser/MpqcParser.hpp"
     15#include "Parser/PcpParser.hpp"
     16#include "Parser/TremoloParser.hpp"
    1417#include "Parser/XyzParser.hpp"
    15 #include "Parser/TremoloParser.hpp"
    1618#include "World.hpp"
    1719#include "atom.hpp"
     
    2931CPPUNIT_TEST_SUITE_REGISTRATION( ParserUnitTest );
    3032
     33static string waterPcp = "# ParallelCarParinello - main configuration file - created with molecuilder\n\
     34\n\
     35mainname\tpcp\t# programm name (for runtime files)\n\
     36defaultpath\not specified\t# where to put files during runtime\n\
     37pseudopotpath\not specified\t# where to find pseudopotentials\n\
     38\n\
     39ProcPEGamma\t8\t# for parallel computing: share constants\n\
     40ProcPEPsi\t1\t# for parallel computing: share wave functions\n\
     41DoOutVis\t0\t# Output data for OpenDX\n\
     42DoOutMes\t1\t# Output data for measurements\n\
     43DoOutOrbitals\t0\t# Output all Orbitals\n\
     44DoOutCurr\t0\t# Ouput current density for OpenDx\n\
     45DoOutNICS\t0\t# Output Nucleus independent current shieldings\n\
     46DoPerturbation\t0\t# Do perturbation calculate and determine susceptibility and shielding\n\
     47DoFullCurrent\t0\t# Do full perturbation\n\
     48DoConstrainedMD\t0\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD\n\
     49Thermostat\tBerendsen\t2.5\t# Which Thermostat and its parameters to use in MD case.\n\
     50CommonWannier\t0\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center\n\
     51SawtoothStart\t0.01\t# Absolute value for smooth transition at cell border \n\
     52VectorPlane\t0\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot\n\
     53VectorCut\t0\t# Cut plane axis value\n\
     54AddGramSch\t1\t# Additional GramSchmidtOrtogonalization to be safe\n\
     55Seed\t1\t# initial value for random seed for Psi coefficients\n\
     56\n\
     57MaxOuterStep\t0\t# number of MolecularDynamics/Structure optimization steps\n\
     58Deltat\t0.01\t# time per MD step\n\
     59OutVisStep\t10\t# Output visual data every ...th step\n\
     60OutSrcStep\t5\t# Output \"restart\" data every ..th step\n\
     61TargetTemp\t0.000950045\t# Target temperature\n\
     62MaxPsiStep\t3\t# number of Minimisation steps per state (0 - default)\n\
     63EpsWannier\t1e-07\t# tolerance value for spread minimisation of orbitals\n\
     64# Values specifying when to stop\n\
     65MaxMinStep\t100\t# Maximum number of steps\n\
     66RelEpsTotalE\t1e-07\t# relative change in total energy\n\
     67RelEpsKineticE\t1e-05\t# relative change in kinetic energy\n\
     68MaxMinStopStep\t2\t# check every ..th steps\n\
     69MaxMinGapStopStep\t1\t# check every ..th steps\n\
     70\n\
     71# Values specifying when to stop for INIT, otherwise same as above\n\
     72MaxInitMinStep\t100\t# Maximum number of steps\n\
     73InitRelEpsTotalE\t1e-05\t# relative change in total energy\n\
     74InitRelEpsKineticE\t0.0001\t# relative change in kinetic energy\n\
     75InitMaxMinStopStep\t2\t# check every ..th steps\n\
     76InitMaxMinGapStopStep\t1\t# check every ..th steps\n\
     77\n\
     78BoxLength\t# (Length of a unit cell)\n\
     7920\n\
     800\t20\n\
     810\t0\t20\n\
     82\n\
     83ECut\t128\t# energy cutoff for discretization in Hartrees\n\
     84MaxLevel\t5\t# number of different levels in the code, >=2\n\
     85Level0Factor\t2\t# factor by which node number increases from S to 0 level\n\
     86RiemannTensor\t0\t# (Use metric)\n\
     87PsiType\t0\t# 0 - doubly occupied, 1 - SpinUp,SpinDown\n\
     88MaxPsiDouble\t2\t# here: specifying both maximum number of SpinUp- and -Down-states\n\
     89PsiMaxNoUp\t2\t# here: specifying maximum number of SpinUp-states\n\
     90PsiMaxNoDown\t2\t# here: specifying maximum number of SpinDown-states\n\
     91AddPsis\t0\t# Additional unoccupied Psis for bandgap determination\n\
     92\n\
     93RCut\t20\t# R-cut for the ewald summation\n\
     94StructOpt\t0\t# Do structure optimization beforehand\n\
     95IsAngstroem\t1\t# 0 - Bohr, 1 - Angstroem\n\
     96RelativeCoord\t0\t# whether ion coordinates are relative (1) or absolute (0)\n\
     97MaxTypes\t2\t# maximum number of different ion types\n\
     98\n\
     99# Ion type data (PP = PseudoPotential, Z = atomic number)\n\
     100#Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol\n\
     101Ion_Type1\t2\t1\t1.0\t3\t3\t1.008\tHydrogen\tH\n\
     102Ion_Type2\t1\t8\t1.0\t3\t3\t15.999\tOxygen\tO\n\
     103#Ion_TypeNr._Nr.R[0]\tR[1]\tR[2]\tMoveType (0 MoveIon, 1 FixedIon)\n\
     104Ion_Type2_1\t0.000000000\t0.000000000\t0.000000000\t0 # molecule nr 0\n\
     105Ion_Type1_1\t0.758602\t0.000000000\t0.504284\t0 # molecule nr 1\n\
     106Ion_Type1_2\t0.758602\t0.000000000\t-0.504284\t0 # molecule nr 2\n";
     107static string waterMpqc ="% Created by MoleCuilder\n\
     108mpqc: (\n\
     109\tsavestate = no\n\
     110\tdo_gradient = yes\n\
     111\tmole<MBPT2>: (\n\
     112\t\tmaxiter = 200\n\
     113\t\tbasis = $:basis\n\
     114\t\tmolecule = $:molecule\n\
     115\t\treference<CLHF>: (\n\
     116\t\t\tbasis = $:basis\n\
     117\t\t\tmolecule = $:molecule\n\
     118\t\t)\n\
     119\t)\n\
     120)\n\
     121molecule<Molecule>: (\n\
     122\tunit = angstrom\n\
     123\t{ atoms geometry } = {\n\
     124\t\tO [ -0.505735\t0\t0 ]\n\
     125\t\tH [ 0.252867\t0\t0.504284 ]\n\
     126\t\tH [ 0.252867\t0\t-0.504284 ]\n\
     127\t}\n\
     128)\n\
     129basis<GaussianBasisSet>: (\n\
     130\tname = \"3-21G\"\n\
     131\tmolecule = $:molecule\n\
     132)\n";
     133static string waterXyz = "3\n\tH2O: water molecule\nO\t0\t0\t0\nH\t0.758602\t0\t0.504284\nH\t0.758602\t0\t-0.504284\n";
     134static string Tremolo_Atomdata1 = "# ATOMDATA\tId\tname\tType\tx=3\n";
     135static string Tremolo_Atomdata2 = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n";
     136static string Tremolo_invalidkey = "#\n#ATOMDATA Id name foo Type x=3\n\n\n";
     137static string Tremolo_velocity = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n";
     138static string Tremolo_neighbours = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n";
     139static string Tremolo_improper = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";
     140static string Tremolo_torsion = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";
     141static string Tremolo_full = "# ATOMDATA\tx=3\tu=3\tF\tstress\tId\tneighbors=5\timprData\tGroupMeasureTypeNo\tType\textType\tname\tresName\tchainID\tresSeq\toccupancy\ttempFactor\tsegID\tCharge\tcharge\tGrpTypeNo\ttorsion\n0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t-\t0\tH\t-\t-\t-\t0\t0\t0\t0\t0\t0\t0\t0\t-\t\n";
    31142
    32143void ParserUnitTest::setUp() {
    33144  World::getInstance();
     145
     146  // we need hydrogens and oxygens in the following tests
     147  CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL);
     148  CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(8) != NULL);
    34149}
    35150
    36151void ParserUnitTest::tearDown() {
     152  ChangeTracker::purgeInstance();
    37153  World::purgeInstance();
    38154}
     
    43159  cout << "Testing the XYZ parser." << endl;
    44160  XyzParser* testParser = new XyzParser();
    45   string waterXyz = "3\nH2O: water molecule\nO\t0.000000\t0.000000\t0.000000\nH\t0.758602\t0.000000\t0.504284\nH\t0.758602\t0.000000\t-0.504284\n";
    46161  stringstream input;
    47162  input << waterXyz;
     
    62177  TremoloParser* testParser = new TremoloParser();
    63178  stringstream input, output;
    64   string waterTremolo;
    65179
    66180  // Atomdata beginning with "# ATOMDATA"
    67   waterTremolo = "# ATOMDATA\tId\tname\tType\tx=3\n";
    68   input << waterTremolo;
    69   testParser->load(&input);
    70   testParser->save(&output);
    71   CPPUNIT_ASSERT(waterTremolo == output.str());
     181  input << Tremolo_Atomdata1;
     182  testParser->load(&input);
     183  testParser->save(&output);
     184  CPPUNIT_ASSERT(Tremolo_Atomdata1 == output.str());
    72185  input.clear();
    73186  output.clear();
    74187
    75188  // Atomdata beginning with "#ATOMDATA"
    76   waterTremolo = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n";
    77   input << waterTremolo;
     189  input << Tremolo_Atomdata2;
    78190  testParser->load(&input);
    79191  testParser->save(&output);
     
    83195
    84196  // Invalid key in Atomdata line
    85   waterTremolo = "#\n#ATOMDATA Id name foo Type x=3\n\n\n";
    86   input << waterTremolo;
     197  input << Tremolo_invalidkey;
    87198  testParser->load(&input);
    88199  //TODO: proove invalidity
     
    93204  TremoloParser* testParser = new TremoloParser();
    94205  stringstream input;
    95   string waterTremolo;
    96206
    97207  // One simple data line
    98   waterTremolo = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n";
    99   input << waterTremolo;
     208  input << Tremolo_Atomdata2;
    100209  testParser->load(&input);
    101210  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->x[0] == 3.0);
     
    106215  TremoloParser* testParser = new TremoloParser();
    107216  stringstream input;
    108   string waterTremolo;
    109217
    110218  // One simple data line
    111   waterTremolo = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n";
    112   input << waterTremolo;
     219  input << Tremolo_velocity;
    113220  testParser->load(&input);
    114221  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->v[0] == 3.0);
     
    119226  TremoloParser* testParser = new TremoloParser();
    120227  stringstream input;
    121   string waterTremolo;
    122228
    123229  // Neighbor data
    124   waterTremolo = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n";
    125   input << waterTremolo;
     230  input << Tremolo_neighbours;
    126231  testParser->load(&input);
    127232
     
    135240  TremoloParser* testParser = new TremoloParser();
    136241  stringstream input, output;
    137   string waterTremolo;
    138242
    139243  // Neighbor data
    140   waterTremolo = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";
    141   input << waterTremolo;
     244  input << Tremolo_improper;
    142245  testParser->load(&input);
    143246  testParser->save(&output);
     
    151254  TremoloParser* testParser = new TremoloParser();
    152255  stringstream input, output;
    153   string waterTremolo;
    154256
    155257  // Neighbor data
    156   waterTremolo = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";
    157   input << waterTremolo;
     258  input << Tremolo_torsion;
    158259  testParser->load(&input);
    159260  testParser->save(&output);
     
    173274  testParser->setFieldsForSave("x=3 u=3 F stress Id neighbors=5 imprData GroupMeasureTypeNo Type extType name resName chainID resSeq occupancy tempFactor segID Charge charge GrpTypeNo torsion");
    174275  testParser->save(&output);
    175   CPPUNIT_ASSERT(output.str() == "# ATOMDATA\tx=3\tu=3\tF\tstress\tId\tneighbors=5\timprData\tGroupMeasureTypeNo\tType\textType\tname\tresName\tchainID\tresSeq\toccupancy\ttempFactor\tsegID\tCharge\tcharge\tGrpTypeNo\ttorsion\n0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t-\t0\tH\t-\t-\t-\t0\t0\t0\t0\t0\t0\t0\t0\t-\t\n");
     276  CPPUNIT_ASSERT(output.str() == Tremolo_full);
    176277
    177278  cout << "testing the tremolo parser is done" << endl;
    178279}
     280
     281void ParserUnitTest::readwritePcpTest() {
     282  stringstream input(waterPcp);
     283  PcpParser* testParser = new PcpParser();
     284  testParser->load(&input);
     285  input.clear();
     286
     287  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
     288
     289  string newWaterPcp = "";
     290  stringstream output;
     291  testParser->save(&output);
     292
     293  input << output;
     294  PcpParser* testParser2 = new PcpParser();
     295  testParser2->load(&input);
     296
     297  CPPUNIT_ASSERT_EQUAL(6, World::getInstance().numAtoms());
     298
     299  CPPUNIT_ASSERT(*testParser == *testParser2);
     300}
     301
     302void ParserUnitTest::writeMpqcTest() {
     303  // build up water molecule
     304  atom *Walker = NULL;
     305  Walker = World::getInstance().createAtom();
     306  Walker->type = World::getInstance().getPeriode()->FindElement(8);
     307  Walker->x = Vector(0,0,0);
     308  Walker = World::getInstance().createAtom();
     309  Walker->type = World::getInstance().getPeriode()->FindElement(1);
     310  Walker->x = Vector(0.758602,0,0.504284);
     311  Walker = World::getInstance().createAtom();
     312  Walker->type = World::getInstance().getPeriode()->FindElement(1);
     313  Walker->x = Vector(0.758602,0,-0.504284);
     314  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
     315
     316  // create two stringstreams, one stored, one created
     317  stringstream input(waterMpqc);
     318  MpqcParser* testParser = new MpqcParser();
     319  stringstream output;
     320  testParser->save(&output);
     321
     322  // compare both configs
     323  string first = input.str();
     324  string second = output.str();
     325  CPPUNIT_ASSERT(first == second);
     326}
  • src/unittests/ParserUnitTest.hpp

    r06f4ef6 rb6da28  
    2222  CPPUNIT_TEST ( readAndWriteTremoloTorsionInformationTest );
    2323  CPPUNIT_TEST ( writeTremoloTest );
     24  CPPUNIT_TEST ( readwritePcpTest );
     25  CPPUNIT_TEST ( writeMpqcTest );
    2426  CPPUNIT_TEST_SUITE_END();
    2527
     
    3638  void readAndWriteTremoloTorsionInformationTest();
    3739  void writeTremoloTest();
     40  void readwritePcpTest();
     41  void writeMpqcTest();
    3842};
    3943
  • src/unittests/PlaneUnittest.cpp

    r06f4ef6 rb6da28  
    1111#include <cppunit/extensions/TestFactoryRegistry.h>
    1212#include <cppunit/ui/text/TestRunner.h>
     13
     14#include <cmath>
    1315
    1416#ifdef HAVE_TESTRUNNER
  • src/unittests/TestRunnerMain.cpp

    r06f4ef6 rb6da28  
    1717#include "../../../TestRunnerClient.h"
    1818#include "../../../TestRunnerClient.cpp"
     19
    1920#else
    20 #include "UnitTestMain.cpp"
    21 #endif
    2221
     22#include "unittests/UnitTestMain.cpp"
     23
     24#endif /* HAVE_ECUT */
  • src/unittests/UnitTestMain.cpp

    r06f4ef6 rb6da28  
    66 */
    77
    8 #include <cppunit/CompilerOutputter.h>
    9 #include <cppunit/extensions/TestFactoryRegistry.h>
    10 #include <cppunit/ui/text/TestRunner.h>
    11 
    128// include config.h
    139#ifdef HAVE_CONFIG_H
    1410#include <config.h>
    1511#endif
     12
     13#include <cppunit/CompilerOutputter.h>
     14#include <cppunit/extensions/TestFactoryRegistry.h>
     15#include <cppunit/ui/text/TestRunner.h>
    1616
    1717/********************************************** Main routine **************************************/
     
    3535  return wasSucessful ? 0 : 1;
    3636};
     37
  • src/unittests/linearsystemofequationsunittest.cpp

    r06f4ef6 rb6da28  
    1212#include <cppunit/extensions/TestFactoryRegistry.h>
    1313#include <cppunit/ui/text/TestRunner.h>
     14#include <cmath>
    1415
    1516#include "linearsystemofequationsunittest.hpp"
  • src/unittests/manipulateAtomsTest.cpp

    r06f4ef6 rb6da28  
    2222#include "World.hpp"
    2323#include "atom.hpp"
     24
     25#include "DummyUI.hpp"
    2426
    2527#ifdef HAVE_TESTRUNNER
     
    7274// set up and tear down
    7375void manipulateAtomsTest::setUp(){
     76  static bool hasDescriptor = false;
    7477  ActionHistory::init();
    7578  World::getInstance();
     79  // TODO: find a way to really reset the factory to a clean state in tear-down
     80  if(!hasDescriptor){
     81    UIFactory::registerFactory(new DummyUIFactory::description());
     82    hasDescriptor = true;
     83  }
     84  UIFactory::makeUserInterface("Dummy");
    7685  for(int i=0;i<ATOM_COUNT;++i){
    7786    atoms[i]= new AtomStub(i);
     
    8392  ActionRegistry::purgeInstance();
    8493  ActionHistory::purgeInstance();
     94  UIFactory::purgeInstance();
    8595}
    8696
    8797static void operation(atom* _atom){
    8898  AtomStub *atom = dynamic_cast<AtomStub*>(_atom);
    89   assert(atom);
     99  CPPUNIT_ASSERT(atom);
    90100  atom->doSomething();
    91101}
     
    100110    AtomStub *atom;
    101111    atom = dynamic_cast<AtomStub*>(*iter);
    102     assert(atom);
     112    CPPUNIT_ASSERT(atom);
    103113    CPPUNIT_ASSERT(atom->manipulated);
    104114  }
     
    114124    AtomStub *atom;
    115125    atom = dynamic_cast<AtomStub*>(*iter);
    116     assert(atom);
     126    CPPUNIT_ASSERT(atom);
    117127    if(atom->getId()!=(int)ATOM_COUNT/2)
    118128      CPPUNIT_ASSERT(atom->manipulated);
  • src/unittests/tesselation_insideoutsideunittest.cpp

    r06f4ef6 rb6da28  
    1717#include "tesselation.hpp"
    1818#include "tesselation_insideoutsideunittest.hpp"
     19#include "verbose.hpp"
    1920
    2021#ifdef HAVE_TESTRUNNER
  • src/unittests/vectorunittest.cpp

    r06f4ef6 rb6da28  
    1515#include "defs.hpp"
    1616#include "log.hpp"
    17 #include "memoryusageobserver.hpp"
    1817#include "vector.hpp"
    1918#include "vector_ops.hpp"
     
    2120#include "Plane.hpp"
    2221#include "Exceptions/LinearDependenceException.hpp"
     22#include "Matrix.hpp"
    2323
    2424#ifdef HAVE_TESTRUNNER
     
    214214  CPPUNIT_ASSERT(testVector.ScalarProduct(three) < MYEPSILON);
    215215}
    216 
    217 
    218 /**
    219  * UnitTest for Vector::IsInParallelepiped().
    220  */
    221 void VectorTest::IsInParallelepipedTest()
    222 {
    223   double parallelepiped[NDIM*NDIM];
    224   parallelepiped[0] = 1;
    225   parallelepiped[1] = 0;
    226   parallelepiped[2] = 0;
    227   parallelepiped[3] = 0;
    228   parallelepiped[4] = 1;
    229   parallelepiped[5] = 0;
    230   parallelepiped[6] = 0;
    231   parallelepiped[7] = 0;
    232   parallelepiped[8] = 1;
    233 
    234   fixture = zero;
    235   CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    236   fixture = Vector(2.5,2.5,2.5);
    237   CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    238   fixture = Vector(1.,1.,1.);
    239   CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    240   fixture = Vector(3.5,3.5,3.5);
    241   CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    242   fixture = Vector(2.,2.,2.);
    243   CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    244   fixture = Vector(2.,3.,2.);
    245   CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    246   fixture = Vector(-2.,2.,-1.);
    247   CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    248 }
    249 
  • src/unittests/vectorunittest.hpp

    r06f4ef6 rb6da28  
    2727    CPPUNIT_TEST ( ProjectionTest );
    2828    CPPUNIT_TEST ( NormalsTest );
    29     CPPUNIT_TEST ( IsInParallelepipedTest );
    3029    CPPUNIT_TEST_SUITE_END();
    3130
     
    4544    void LineIntersectionTest();
    4645    void VectorRotationTest();
    47     void IsInParallelepipedTest();
    4846
    4947private:
  • src/valence.db

    r06f4ef6 rb6da28  
     1#atomicnumber numberofvalenceorbitals
    121       0.10000000000000E+01
    232       0.20000000000000E+01
  • src/vector.cpp

    r06f4ef6 rb6da28  
    88
    99#include "vector.hpp"
     10#include "VectorContent.hpp"
    1011#include "verbose.hpp"
    1112#include "World.hpp"
    1213#include "Helpers/Assert.hpp"
    1314#include "Helpers/fast_functions.hpp"
     15#include "Exceptions/MathException.hpp"
    1416
    1517#include <iostream>
     18#include <gsl/gsl_blas.h>
     19
    1620
    1721using namespace std;
     
    2428Vector::Vector()
    2529{
    26   content = gsl_vector_calloc (NDIM);
     30  content = new VectorContent();
    2731};
    2832
     
    3337Vector::Vector(const Vector& src)
    3438{
    35   content = gsl_vector_alloc(NDIM);
    36   gsl_vector_set(content,0,src[0]);
    37   gsl_vector_set(content,1,src[1]);
    38   gsl_vector_set(content,2,src[2]);
     39  content = new VectorContent();
     40  gsl_vector_memcpy(content->content, src.content->content);
    3941}
    4042
     
    4345Vector::Vector(const double x1, const double x2, const double x3)
    4446{
    45   content = gsl_vector_alloc(NDIM);
    46   gsl_vector_set(content,0,x1);
    47   gsl_vector_set(content,1,x2);
    48   gsl_vector_set(content,2,x3);
    49 };
     47  content = new VectorContent();
     48  gsl_vector_set(content->content,0,x1);
     49  gsl_vector_set(content->content,1,x2);
     50  gsl_vector_set(content->content,2,x3);
     51};
     52
     53Vector::Vector(VectorContent *_content) :
     54  content(_content)
     55{}
    5056
    5157/**
     
    5561  // check for self assignment
    5662  if(&src!=this){
    57     gsl_vector_set(content,0,src[0]);
    58     gsl_vector_set(content,1,src[1]);
    59     gsl_vector_set(content,2,src[2]);
     63    gsl_vector_memcpy(content->content, src.content->content);
    6064  }
    6165  return *this;
     
    6569 */
    6670Vector::~Vector() {
    67   gsl_vector_free(content);
     71  delete content;
    6872};
    6973
     
    9498}
    9599
    96 /** Calculates distance between this and another vector in a periodic cell.
    97  * \param *y array to second vector
    98  * \param *cell_size 6-dimensional array with (xx, xy, yy, xz, yz, zz) entries specifying the periodic cell
    99  * \return \f$| x - y |\f$
    100  */
    101 double Vector::PeriodicDistance(const Vector &y, const double * const cell_size) const
    102 {
    103   double res = distance(y), tmp, matrix[NDIM*NDIM];
    104     Vector Shiftedy, TranslationVector;
    105     int N[NDIM];
    106     matrix[0] = cell_size[0];
    107     matrix[1] = cell_size[1];
    108     matrix[2] = cell_size[3];
    109     matrix[3] = cell_size[1];
    110     matrix[4] = cell_size[2];
    111     matrix[5] = cell_size[4];
    112     matrix[6] = cell_size[3];
    113     matrix[7] = cell_size[4];
    114     matrix[8] = cell_size[5];
    115     // in order to check the periodic distance, translate one of the vectors into each of the 27 neighbouring cells
    116     for (N[0]=-1;N[0]<=1;N[0]++)
    117       for (N[1]=-1;N[1]<=1;N[1]++)
    118         for (N[2]=-1;N[2]<=1;N[2]++) {
    119           // create the translation vector
    120           TranslationVector.Zero();
    121           for (int i=NDIM;i--;)
    122             TranslationVector[i] = (double)N[i];
    123           TranslationVector.MatrixMultiplication(matrix);
    124           // add onto the original vector to compare with
    125           Shiftedy = y + TranslationVector;
    126           // get distance and compare with minimum so far
    127           tmp = distance(Shiftedy);
    128           if (tmp < res) res = tmp;
    129         }
    130     return (res);
    131 };
    132 
    133 /** Calculates distance between this and another vector in a periodic cell.
    134  * \param *y array to second vector
    135  * \param *cell_size 6-dimensional array with (xx, xy, yy, xz, yz, zz) entries specifying the periodic cell
    136  * \return \f$| x - y |^2\f$
    137  */
    138 double Vector::PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const
    139 {
    140   double res = DistanceSquared(y), tmp, matrix[NDIM*NDIM];
    141     Vector Shiftedy, TranslationVector;
    142     int N[NDIM];
    143     matrix[0] = cell_size[0];
    144     matrix[1] = cell_size[1];
    145     matrix[2] = cell_size[3];
    146     matrix[3] = cell_size[1];
    147     matrix[4] = cell_size[2];
    148     matrix[5] = cell_size[4];
    149     matrix[6] = cell_size[3];
    150     matrix[7] = cell_size[4];
    151     matrix[8] = cell_size[5];
    152     // in order to check the periodic distance, translate one of the vectors into each of the 27 neighbouring cells
    153     for (N[0]=-1;N[0]<=1;N[0]++)
    154       for (N[1]=-1;N[1]<=1;N[1]++)
    155         for (N[2]=-1;N[2]<=1;N[2]++) {
    156           // create the translation vector
    157           TranslationVector.Zero();
    158           for (int i=NDIM;i--;)
    159             TranslationVector[i] = (double)N[i];
    160           TranslationVector.MatrixMultiplication(matrix);
    161           // add onto the original vector to compare with
    162           Shiftedy = y + TranslationVector;
    163           // get distance and compare with minimum so far
    164           tmp = DistanceSquared(Shiftedy);
    165           if (tmp < res) res = tmp;
    166         }
    167     return (res);
    168 };
    169 
    170 /** Keeps the vector in a periodic cell, defined by the symmetric \a *matrix.
    171  * \param *out ofstream for debugging messages
    172  * Tries to translate a vector into each adjacent neighbouring cell.
    173  */
    174 void Vector::KeepPeriodic(const double * const matrix)
    175 {
    176   //  int N[NDIM];
    177   //  bool flag = false;
    178     //vector Shifted, TranslationVector;
    179   //  Log() << Verbose(1) << "Begin of KeepPeriodic." << endl;
    180   //  Log() << Verbose(2) << "Vector is: ";
    181   //  Output(out);
    182   //  Log() << Verbose(0) << endl;
    183     InverseMatrixMultiplication(matrix);
    184     for(int i=NDIM;i--;) { // correct periodically
    185       if (at(i) < 0) {  // get every coefficient into the interval [0,1)
    186         at(i) += ceil(at(i));
    187       } else {
    188         at(i) -= floor(at(i));
    189       }
    190     }
    191     MatrixMultiplication(matrix);
    192   //  Log() << Verbose(2) << "New corrected vector is: ";
    193   //  Output(out);
    194   //  Log() << Verbose(0) << endl;
    195   //  Log() << Verbose(1) << "End of KeepPeriodic." << endl;
    196 };
    197 
    198100/** Calculates scalar product between this and another vector.
    199101 * \param *y array to second vector
     
    203105{
    204106  double res = 0.;
    205   for (int i=NDIM;i--;)
    206     res += at(i)*y[i];
     107  gsl_blas_ddot(content->content, y.content->content, &res);
    207108  return (res);
    208109};
     
    369270double& Vector::operator[](size_t i){
    370271  ASSERT(i<=NDIM && i>=0,"Vector Index out of Range");
    371   return *gsl_vector_ptr (content, i);
     272  return *gsl_vector_ptr (content->content, i);
    372273}
    373274
    374275const double& Vector::operator[](size_t i) const{
    375276  ASSERT(i<=NDIM && i>=0,"Vector Index out of Range");
    376   return *gsl_vector_ptr (content, i);
     277  return *gsl_vector_ptr (content->content, i);
    377278}
    378279
     
    385286}
    386287
    387 gsl_vector* Vector::get(){
     288VectorContent* Vector::get(){
    388289  return content;
    389290}
     
    504405};
    505406
     407void Vector::ScaleAll(const Vector &factor){
     408  gsl_vector_mul(content->content, factor.content->content);
     409}
    506410
    507411
    508412void Vector::Scale(const double factor)
    509413{
    510   for (int i=NDIM;i--;)
    511     at(i) *= factor;
    512 };
    513 
    514 /** Given a box by its matrix \a *M and its inverse *Minv the vector is made to point within that box.
    515  * \param *M matrix of box
    516  * \param *Minv inverse matrix
    517  */
    518 void Vector::WrapPeriodically(const double * const M, const double * const Minv)
    519 {
    520   MatrixMultiplication(Minv);
    521   // truncate to [0,1] for each axis
    522   for (int i=0;i<NDIM;i++) {
    523     //at(i) += 0.5;  // set to center of box
    524     while (at(i) >= 1.)
    525       at(i) -= 1.;
    526     while (at(i) < 0.)
    527       at(i) += 1.;
    528   }
    529   MatrixMultiplication(M);
     414  gsl_vector_scale(content->content,factor);
    530415};
    531416
     
    546431  return make_pair(res,helper);
    547432}
    548 
    549 /** Do a matrix multiplication.
    550  * \param *matrix NDIM_NDIM array
    551  */
    552 void Vector::MatrixMultiplication(const double * const M)
    553 {
    554   Vector tmp;
    555   // do the matrix multiplication
    556   for(int i=NDIM;i--;)
    557     tmp[i] = M[i]*at(0)+M[i+3]*at(1)+M[i+6]*at(2);
    558 
    559   (*this) = tmp;
    560 };
    561 
    562 /** Do a matrix multiplication with the \a *A' inverse.
    563  * \param *matrix NDIM_NDIM array
    564  */
    565 bool Vector::InverseMatrixMultiplication(const double * const A)
    566 {
    567   double B[NDIM*NDIM];
    568   double detA = RDET3(A);
    569   double detAReci;
    570 
    571   // calculate the inverse B
    572   if (fabs(detA) > MYEPSILON) {;  // RDET3(A) yields precisely zero if A irregular
    573     detAReci = 1./detA;
    574     B[0] =  detAReci*RDET2(A[4],A[5],A[7],A[8]);    // A_11
    575     B[1] = -detAReci*RDET2(A[1],A[2],A[7],A[8]);    // A_12
    576     B[2] =  detAReci*RDET2(A[1],A[2],A[4],A[5]);    // A_13
    577     B[3] = -detAReci*RDET2(A[3],A[5],A[6],A[8]);    // A_21
    578     B[4] =  detAReci*RDET2(A[0],A[2],A[6],A[8]);    // A_22
    579     B[5] = -detAReci*RDET2(A[0],A[2],A[3],A[5]);    // A_23
    580     B[6] =  detAReci*RDET2(A[3],A[4],A[6],A[7]);    // A_31
    581     B[7] = -detAReci*RDET2(A[0],A[1],A[6],A[7]);    // A_32
    582     B[8] =  detAReci*RDET2(A[0],A[1],A[3],A[4]);    // A_33
    583 
    584     MatrixMultiplication(B);
    585 
    586     return true;
    587   } else {
    588     return false;
    589   }
    590 };
    591 
    592433
    593434/** Creates this vector as the b y *factors' components scaled linear combination of the given three.
     
    679520void Vector::AddVector(const Vector &y)
    680521{
    681   for(int i=NDIM;i--;)
    682     at(i) += y[i];
     522  gsl_vector_add(content->content, y.content->content);
    683523}
    684524
     
    688528void Vector::SubtractVector(const Vector &y)
    689529{
    690   for(int i=NDIM;i--;)
    691     at(i) -= y[i];
    692 }
    693 
    694 /**
    695  * Checks whether this vector is within the parallelepiped defined by the given three vectors and
    696  * their offset.
    697  *
    698  * @param offest for the origin of the parallelepiped
    699  * @param three vectors forming the matrix that defines the shape of the parallelpiped
    700  */
    701 bool Vector::IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const
    702 {
    703   Vector a = (*this)-offset;
    704   a.InverseMatrixMultiplication(parallelepiped);
    705   bool isInside = true;
    706 
    707   for (int i=NDIM;i--;)
    708     isInside = isInside && ((a[i] <= 1) && (a[i] >= 0));
    709 
    710   return isInside;
     530  gsl_vector_sub(content->content, y.content->content);
    711531}
    712532
  • src/vector.hpp

    r06f4ef6 rb6da28  
    1111#endif
    1212
    13 #include <iostream>
    14 #include <gsl/gsl_vector.h>
    15 #include <gsl/gsl_multimin.h>
     13#include <iosfwd>
    1614
    1715#include <memory>
     
    2422
    2523class Vector;
     24class Matrix;
     25struct VectorContent;
    2626
    2727typedef std::vector<Vector> pointset;
     
    3131 */
    3232class Vector : public Space{
     33  friend Vector operator*(const Matrix&,const Vector&);
     34  friend class Matrix;
    3335public:
    34 
    3536  Vector();
    3637  Vector(const double x1, const double x2, const double x3);
     
    4243  double DistanceSquared(const Vector &y) const;
    4344  double DistanceToSpace(const Space& space) const;
    44   double PeriodicDistance(const Vector &y, const double * const cell_size) const;
    45   double PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const;
    4645  double ScalarProduct(const Vector &y) const;
    4746  double Angle(const Vector &y) const;
     
    5857  Vector Projection(const Vector &y) const;
    5958  void ScaleAll(const double *factor);
     59  void ScaleAll(const Vector &factor);
    6060  void Scale(const double factor);
    61   void MatrixMultiplication(const double * const M);
    62   bool InverseMatrixMultiplication(const double * const M);
    63   void KeepPeriodic(const double * const matrix);
    6461  bool GetOneNormalVector(const Vector &x1);
    6562  bool MakeNormalTo(const Vector &y1);
    66   bool IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const;
    67   void WrapPeriodically(const double * const M, const double * const Minv);
    6863  std::pair<Vector,Vector> partition(const Vector&) const;
    6964  std::pair<pointset,Vector> partition(const pointset&) const;
     
    7974
    8075  // Access to internal structure
    81   gsl_vector* get();
     76  VectorContent* get();
    8277
    8378  // Methods that are derived directly from other methods
     
    10499
    105100private:
    106   gsl_vector *content;
     101  Vector(VectorContent *);
     102  VectorContent *content;
    107103
    108104};
  • src/vector_ops.cpp

    r06f4ef6 rb6da28  
    2323#include <gsl/gsl_permutation.h>
    2424#include <gsl/gsl_vector.h>
     25#include <gsl/gsl_multimin.h>
    2526
    2627/**
  • src/verbose.cpp

    r06f4ef6 rb6da28  
    55#include "info.hpp"
    66#include "verbose.hpp"
     7#include <iostream>
    78
    89/** Prints the tabs according to verbosity stored in the temporary constructed class.
  • src/verbose.hpp

    r06f4ef6 rb6da28  
    1818#endif
    1919
    20 #include <iostream>
     20#include <iosfwd>
    2121
    2222/************************************* Class Verbose & Binary *******************************/
  • tests/Tesselations/Makefile.am

    r06f4ef6 rb6da28  
    1 TESTS = 1_2-dimethoxyethane.test \
    2 1_2-dimethylbenzene.test \
    3 2-methylcyclohexanone.test \
    4 benzene.test \
    5 cholesterol.test \
    6 cycloheptane.test \
    7 dimethyl_bromomalonate.test \
    8 glucose.test \
    9 heptan.test \
    10 isoleucine.test \
    11 neohexane.test \
    12 N_N-dimethylacetamide.test \
    13 proline.test \
    14 putrescine.test \
    15 tartaric_acid.test
     1TESTS = \
     2        1_2-dimethoxyethane.test \
     3        1_2-dimethylbenzene.test \
     4        2-methylcyclohexanone.test \
     5        benzene.test \
     6        cholesterol.test \
     7        cycloheptane.test \
     8        dimethyl_bromomalonate.test \
     9        glucose.test \
     10        isoleucine.test \
     11        neohexane.test \
     12        N_N-dimethylacetamide.test \
     13        proline.test \
     14        putrescine.test \
     15        tartaric_acid.test
     16
     17#       heptan.test
  • tests/Tesselations/defs.in

    r06f4ef6 rb6da28  
    5454        #echo "Current dir is `pwd`, calling $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS $FILENAME."
    5555        if [ -e $mol.dbond ]; then
    56                 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond -N 0 --sphere-radius $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
     56                $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond --select-molecule-by-id 0 -N $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
    5757        else
    58                 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N 0 --sphere-radius $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
     58                $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz --select-molecule-by-id 0 -N $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
    5959        fi
    6060        #echo "Molecuilder done with exitcode $exitcode."
     61        cd ../..
    6162        #cat stderr
    6263        #cat stdout
    63         grep -E "^[0-9]* [0-9]* [0-9]*$" ../../../../../molecuilder/tests/Tesselations/$mol/$2/${FILENAME}-$mol.dat | sort -n >reference-triangles.dat
    64         grep -E "^[0-9]* [0-9]* [0-9]*$" ${FILENAME}.dat | sort -n >new-triangles.dat
    65         diff reference-triangles.dat new-triangles.dat 2>diffstderr >diffstdout || exitcode=$?
     64        grep -E "^[0-9]* [0-9]* [0-9]*$" @srcdir@/$mol/$2/${FILENAME}-$mol.dat | sort -n >$testdir/$RADIUS/reference-triangles.dat
     65        grep -E "^[0-9]* [0-9]* [0-9]*$" $testdir/$RADIUS/${FILENAME}.dat | sort -n >$testdir/$RADIUS/new-triangles.dat
     66        diff $testdir/$RADIUS/reference-triangles.dat $testdir/$RADIUS/new-triangles.dat 2>$testdir/$RADIUS/diffstderr >$testdir/$RADIUS/diffstdout || exitcode=$?
    6667        #echo "Diff done with exitcode $exitcode."
    6768        #cat diffstderr
    6869        #cat diffstdout
    69         cd ../..
    7070        test $exitcode = $expected_exitcode || exit 1
    7171}
  • tests/Tesselations/heptan/1.5/NonConvexEnvelope-heptan.dat

    r06f4ef6 rb6da28  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="heptan", N=23, E=64, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 -7.27e-07 -1.22006 0.930455 3
    5 -7.27e-07 -1.22006 -0.849545 3
    6 -1.2492 0.921941 0.930455 3
    7 -1.2492 0.921941 -0.849545 3
    8 1.2492 0.921941 -0.849545 3
    9 1.2492 0.921941 0.930455 3
    10 -2.4985 -1.22006 -0.849545 4
    11 -2.4985 -1.22006 0.930455 4
    12 2.4985 -1.22006 0.930455 4
    13 2.4985 -1.22006 -0.849545 4
    14 -4.6377 -0.336759 0.0404545 6
    15 -3.7477 0.921941 0.930455 5
    16 -3.7477 0.921941 -0.849545 5
    17 4.6377 -0.336759 0.0404545 4
    18 3.7477 0.921941 -0.849545 4
    19 3.7477 0.921941 0.930455 4
    20 -7.27e-07 -0.590759 0.0404545 6
    21 -1.2492 0.292641 0.0404545 6
    22 1.2492 0.292641 0.0404545 6
    23 -2.4985 -0.590759 0.0404545 6
    24 2.4985 -0.590759 0.0404545 6
    25 -3.7477 0.292641 0.0404545 12
    26 3.7477 0.292641 0.0404545 12
     3ZONE T="none", N=23, E=64, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     4-7.27e-07 -1.22006 0.930455 18.7229
     5-7.27e-07 -1.22006 -0.849545 18.7229
     6-1.2492 0.921941 0.930455 18.7227
     7-1.2492 0.921941 -0.849545 18.7227
     81.2492 0.921941 -0.849545 18.7222
     91.2492 0.921941 0.930455 18.7222
     10-2.4985 -1.22006 -0.849545 19.9769
     11-2.4985 -1.22006 0.930455 19.9769
     122.4985 -1.22006 0.930455 27.4727
     132.4985 -1.22006 -0.849545 27.4727
     14-4.6377 -0.336759 0.0404545 21.541
     15-3.7477 0.921941 0.930455 18.8853
     16-3.7477 0.921941 -0.849545 18.8853
     174.6377 -0.336759 0.0404545 10.6618
     183.7477 0.921941 -0.849545 18.5406
     193.7477 0.921941 0.930455 18.5406
     20-7.27e-07 -0.590759 0.0404545 23.0174
     21-1.2492 0.292641 0.0404545 23.0167
     221.2492 0.292641 0.0404545 23.0172
     23-2.4985 -0.590759 0.0404545 21.8516
     242.4985 -0.590759 0.0404545 16.0669
     25-3.7477 0.292641 0.0404545 39.5267
     263.7477 0.292641 0.0404545 20.5497
    2727
    282814 15 23
     
    343415 19 23
    35355 15 19
     3616 19 23
     376 16 19
    36385 6 19
    37395 6 19
    38405 18 19
    39414 5 18
     426 18 19
     433 6 18
    40443 4 18
    41453 4 18
    42 3 18 19
    43 3 6 19
     463 18 22
     473 12 22
    44484 18 22
    45494 13 22
    46 3 18 22
    47 3 12 22
    485012 13 22
    495112 13 22
    50 16 19 23
    51 6 16 19
     5211 12 22
     5311 12 22
     548 11 22
     558 12 22
     5611 13 22
     5711 13 22
     587 11 22
     597 13 22
    526014 16 23
    536114 16 23
    54629 14 23
    55639 16 23
    56 11 13 22
    57 11 13 22
    58 7 11 22
    59 7 13 22
    60 11 12 22
    61 11 12 22
    62 8 11 22
    63 8 12 22
     643 8 12
     651 3 8
     661 3 6
     671 6 9
     686 9 16
    64694 7 13
    65702 4 7
     
    67722 5 10
    68735 10 15
    69 3 8 12
    70 1 3 8
    71 1 3 6
    72 1 6 9
    73 6 9 16
    747410 14 21
    75759 10 21
    76769 10 21
    77779 14 21
     789 17 21
     791 9 17
     801 2 17
     811 2 17
    788210 17 21
    79832 10 17
    80 1 2 17
    81 1 2 17
    82 1 17 21
    83 1 9 21
    84 2 17 20
    85 2 7 20
    86841 17 20
    87851 8 20
    88867 8 20
    89877 8 20
     888 11 20
    90897 11 20
    91 8 11 20
     902 17 20
     912 7 20
  • tests/Tesselations/heptan/2.5/NonConvexEnvelope-heptan.dat

    r06f4ef6 rb6da28  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 -7.27e-07 -1.22006 0.930455 0
    5 -7.27e-07 -1.22006 -0.849545 0
    6 -1.2492 0.921941 0.930455 0
    7 -1.2492 0.921941 -0.849545 0
    8 1.2492 0.921941 -0.849545 0
    9 1.2492 0.921941 0.930455 0
    10 -2.4985 -1.22006 -0.849545 0
    11 -2.4985 -1.22006 0.930455 0
    12 2.4985 -1.22006 0.930455 0
    13 2.4985 -1.22006 -0.849545 0
    14 -4.6377 -0.336759 0.0404545 0
    15 -3.7477 0.921941 0.930455 0
    16 -3.7477 0.921941 -0.849545 0
    17 4.6377 -0.336759 0.0404545 0
    18 3.7477 0.921941 -0.849545 0
    19 3.7477 0.921941 0.930455 0
     4-7.27e-07 -1.22006 0.930455 -17.4952
     5-7.27e-07 -1.22006 -0.849545 -17.4952
     6-1.2492 0.921941 0.930455 -19.6818
     7-1.2492 0.921941 -0.849545 -15.323
     81.2492 0.921941 -0.849545 -17.495
     91.2492 0.921941 0.930455 -17.4951
     10-2.4985 -1.22006 -0.849545 -13.1263
     11-2.4985 -1.22006 0.930455 -10.8961
     122.4985 -1.22006 0.930455 -13.1263
     132.4985 -1.22006 -0.849545 -10.8961
     14-4.6377 -0.336759 0.0404545 -9.35471
     15-3.7477 0.921941 0.930455 -9.24444
     16-3.7477 0.921941 -0.849545 -11.4805
     174.6377 -0.336759 0.0404545 -9.35473
     183.7477 0.921941 -0.849545 -11.4805
     193.7477 0.921941 0.930455 -9.24445
    2020
    212114 15 16
     
    27273 12 13
    282811 12 13
    29 8 11 12
    30 3 8 12
    31 1 3 8
    32 1 3 6
    33 1 6 9
    34 6 9 16
    35 9 14 16
     297 11 13
     304 7 13
     312 4 7
     322 4 5
     332 5 10
     345 10 15
     3510 14 15
    36369 10 14
    37372 9 10
     
    40401 7 8
    41417 8 11
    42 10 14 15
    43 5 10 15
    44 2 5 10
    45 2 4 5
    46 2 4 7
    47 4 7 13
    48 7 11 13
     429 14 16
     436 9 16
     441 6 9
     451 3 6
     461 3 8
     473 8 12
     488 11 12
  • tests/Tesselations/heptan/2/NonConvexEnvelope-heptan.dat

    r06f4ef6 rb6da28  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 -7.27e-07 -1.22006 0.930455 0
    5 -7.27e-07 -1.22006 -0.849545 0
    6 -1.2492 0.921941 0.930455 0
    7 -1.2492 0.921941 -0.849545 0
    8 1.2492 0.921941 -0.849545 0
    9 1.2492 0.921941 0.930455 0
    10 -2.4985 -1.22006 -0.849545 0
    11 -2.4985 -1.22006 0.930455 0
    12 2.4985 -1.22006 0.930455 0
    13 2.4985 -1.22006 -0.849545 0
    14 -4.6377 -0.336759 0.0404545 0
    15 -3.7477 0.921941 0.930455 0
    16 -3.7477 0.921941 -0.849545 0
    17 4.6377 -0.336759 0.0404545 0
    18 3.7477 0.921941 -0.849545 0
    19 3.7477 0.921941 0.930455 0
     4-7.27e-07 -1.22006 0.930455 -17.4952
     5-7.27e-07 -1.22006 -0.849545 -17.4952
     6-1.2492 0.921941 0.930455 -19.6818
     7-1.2492 0.921941 -0.849545 -15.323
     81.2492 0.921941 -0.849545 -17.495
     91.2492 0.921941 0.930455 -17.4951
     10-2.4985 -1.22006 -0.849545 -13.1263
     11-2.4985 -1.22006 0.930455 -10.8961
     122.4985 -1.22006 0.930455 -13.1263
     132.4985 -1.22006 -0.849545 -10.8961
     14-4.6377 -0.336759 0.0404545 -9.35471
     15-3.7477 0.921941 0.930455 -9.24444
     16-3.7477 0.921941 -0.849545 -11.4805
     174.6377 -0.336759 0.0404545 -9.35473
     183.7477 0.921941 -0.849545 -11.4805
     193.7477 0.921941 0.930455 -9.24445
    2020
    212114 15 16
     
    27273 12 13
    282811 12 13
    29 8 11 12
    30 3 8 12
    31 1 3 8
    32 1 3 6
    33 1 6 9
    34 6 9 16
    35 9 14 16
     297 11 13
     304 7 13
     312 4 7
     322 4 5
     332 5 10
     345 10 15
     3510 14 15
    36369 10 14
    37372 9 10
     
    40401 7 8
    41417 8 11
    42 10 14 15
    43 5 10 15
    44 2 5 10
    45 2 4 5
    46 2 4 7
    47 4 7 13
    48 7 11 13
     429 14 16
     436 9 16
     441 6 9
     451 3 6
     461 3 8
     473 8 12
     488 11 12
  • tests/Tesselations/heptan/25/NonConvexEnvelope-heptan.dat

    r06f4ef6 rb6da28  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 -7.27e-07 -1.22006 0.930455 0
    5 -7.27e-07 -1.22006 -0.849545 0
    6 -1.2492 0.921941 0.930455 0
    7 -1.2492 0.921941 -0.849545 0
    8 1.2492 0.921941 -0.849545 0
    9 1.2492 0.921941 0.930455 0
    10 -2.4985 -1.22006 -0.849545 0
    11 -2.4985 -1.22006 0.930455 0
    12 2.4985 -1.22006 0.930455 0
    13 2.4985 -1.22006 -0.849545 0
    14 -4.6377 -0.336759 0.0404545 0
    15 -3.7477 0.921941 0.930455 0
    16 -3.7477 0.921941 -0.849545 0
    17 4.6377 -0.336759 0.0404545 0
    18 3.7477 0.921941 -0.849545 0
    19 3.7477 0.921941 0.930455 0
     4-7.27e-07 -1.22006 0.930455 -17.4952
     5-7.27e-07 -1.22006 -0.849545 -17.4952
     6-1.2492 0.921941 0.930455 -19.6818
     7-1.2492 0.921941 -0.849545 -15.323
     81.2492 0.921941 -0.849545 -17.495
     91.2492 0.921941 0.930455 -17.4951
     10-2.4985 -1.22006 -0.849545 -13.1263
     11-2.4985 -1.22006 0.930455 -10.8961
     122.4985 -1.22006 0.930455 -13.1263
     132.4985 -1.22006 -0.849545 -10.8961
     14-4.6377 -0.336759 0.0404545 -9.35471
     15-3.7477 0.921941 0.930455 -9.24444
     16-3.7477 0.921941 -0.849545 -11.4805
     174.6377 -0.336759 0.0404545 -9.35473
     183.7477 0.921941 -0.849545 -11.4805
     193.7477 0.921941 0.930455 -9.24445
    2020
    212114 15 16
     
    27273 12 13
    282811 12 13
    29 8 11 12
    30 3 8 12
    31 1 3 8
    32 1 3 6
    33 1 6 9
    34 6 9 16
    35 9 14 16
     297 11 13
     304 7 13
     312 4 7
     322 4 5
     332 5 10
     345 10 15
     3510 14 15
    36369 10 14
    37372 9 10
     
    40401 7 8
    41417 8 11
    42 10 14 15
    43 5 10 15
    44 2 5 10
    45 2 4 5
    46 2 4 7
    47 4 7 13
    48 7 11 13
     429 14 16
     436 9 16
     441 6 9
     451 3 6
     461 3 8
     473 8 12
     488 11 12
  • tests/Tesselations/heptan/3.5/NonConvexEnvelope-heptan.dat

    r06f4ef6 rb6da28  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 -7.27e-07 -1.22006 0.930455 0
    5 -7.27e-07 -1.22006 -0.849545 0
    6 -1.2492 0.921941 0.930455 0
    7 -1.2492 0.921941 -0.849545 0
    8 1.2492 0.921941 -0.849545 0
    9 1.2492 0.921941 0.930455 0
    10 -2.4985 -1.22006 -0.849545 0
    11 -2.4985 -1.22006 0.930455 0
    12 2.4985 -1.22006 0.930455 0
    13 2.4985 -1.22006 -0.849545 0
    14 -4.6377 -0.336759 0.0404545 0
    15 -3.7477 0.921941 0.930455 0
    16 -3.7477 0.921941 -0.849545 0
    17 4.6377 -0.336759 0.0404545 0
    18 3.7477 0.921941 -0.849545 0
    19 3.7477 0.921941 0.930455 0
     4-7.27e-07 -1.22006 0.930455 -17.4952
     5-7.27e-07 -1.22006 -0.849545 -17.4952
     6-1.2492 0.921941 0.930455 -19.6818
     7-1.2492 0.921941 -0.849545 -15.323
     81.2492 0.921941 -0.849545 -17.495
     91.2492 0.921941 0.930455 -17.4951
     10-2.4985 -1.22006 -0.849545 -13.1263
     11-2.4985 -1.22006 0.930455 -10.8961
     122.4985 -1.22006 0.930455 -13.1263
     132.4985 -1.22006 -0.849545 -10.8961
     14-4.6377 -0.336759 0.0404545 -9.35471
     15-3.7477 0.921941 0.930455 -9.24444
     16-3.7477 0.921941 -0.849545 -11.4805
     174.6377 -0.336759 0.0404545 -9.35473
     183.7477 0.921941 -0.849545 -11.4805
     193.7477 0.921941 0.930455 -9.24445
    2020
    212114 15 16
     
    27273 12 13
    282811 12 13
    29 8 11 12
    30 3 8 12
    31 1 3 8
    32 1 3 6
    33 1 6 9
    34 6 9 16
    35 9 14 16
     297 11 13
     304 7 13
     312 4 7
     322 4 5
     332 5 10
     345 10 15
     3510 14 15
    36369 10 14
    37372 9 10
     
    40401 7 8
    41417 8 11
    42 10 14 15
    43 5 10 15
    44 2 5 10
    45 2 4 5
    46 2 4 7
    47 4 7 13
    48 7 11 13
     429 14 16
     436 9 16
     441 6 9
     451 3 6
     461 3 8
     473 8 12
     488 11 12
  • tests/Tesselations/heptan/3/NonConvexEnvelope-heptan.dat

    r06f4ef6 rb6da28  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 -7.27e-07 -1.22006 0.930455 0
    5 -7.27e-07 -1.22006 -0.849545 0
    6 -1.2492 0.921941 0.930455 0
    7 -1.2492 0.921941 -0.849545 0
    8 1.2492 0.921941 -0.849545 0
    9 1.2492 0.921941 0.930455 0
    10 -2.4985 -1.22006 -0.849545 0
    11 -2.4985 -1.22006 0.930455 0
    12 2.4985 -1.22006 0.930455 0
    13 2.4985 -1.22006 -0.849545 0
    14 -4.6377 -0.336759 0.0404545 0
    15 -3.7477 0.921941 0.930455 0
    16 -3.7477 0.921941 -0.849545 0
    17 4.6377 -0.336759 0.0404545 0
    18 3.7477 0.921941 -0.849545 0
    19 3.7477 0.921941 0.930455 0
     4-7.27e-07 -1.22006 0.930455 -17.4952
     5-7.27e-07 -1.22006 -0.849545 -17.4952
     6-1.2492 0.921941 0.930455 -19.6818
     7-1.2492 0.921941 -0.849545 -15.323
     81.2492 0.921941 -0.849545 -17.495
     91.2492 0.921941 0.930455 -17.4951
     10-2.4985 -1.22006 -0.849545 -13.1263
     11-2.4985 -1.22006 0.930455 -10.8961
     122.4985 -1.22006 0.930455 -13.1263
     132.4985 -1.22006 -0.849545 -10.8961
     14-4.6377 -0.336759 0.0404545 -9.35471
     15-3.7477 0.921941 0.930455 -9.24444
     16-3.7477 0.921941 -0.849545 -11.4805
     174.6377 -0.336759 0.0404545 -9.35473
     183.7477 0.921941 -0.849545 -11.4805
     193.7477 0.921941 0.930455 -9.24445
    2020
    212114 15 16
     
    27273 12 13
    282811 12 13
    29 8 11 12
    30 3 8 12
    31 1 3 8
    32 1 3 6
    33 1 6 9
    34 6 9 16
    35 9 14 16
     297 11 13
     304 7 13
     312 4 7
     322 4 5
     332 5 10
     345 10 15
     3510 14 15
    36369 10 14
    37372 9 10
     
    40401 7 8
    41417 8 11
    42 10 14 15
    43 5 10 15
    44 2 5 10
    45 2 4 5
    46 2 4 7
    47 4 7 13
    48 7 11 13
     429 14 16
     436 9 16
     441 6 9
     451 3 6
     461 3 8
     473 8 12
     488 11 12
  • tests/Tesselations/heptan/4/NonConvexEnvelope-heptan.dat

    r06f4ef6 rb6da28  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 -7.27e-07 -1.22006 0.930455 0
    5 -7.27e-07 -1.22006 -0.849545 0
    6 -1.2492 0.921941 0.930455 0
    7 -1.2492 0.921941 -0.849545 0
    8 1.2492 0.921941 -0.849545 0
    9 1.2492 0.921941 0.930455 0
    10 -2.4985 -1.22006 -0.849545 0
    11 -2.4985 -1.22006 0.930455 0
    12 2.4985 -1.22006 0.930455 0
    13 2.4985 -1.22006 -0.849545 0
    14 -4.6377 -0.336759 0.0404545 0
    15 -3.7477 0.921941 0.930455 0
    16 -3.7477 0.921941 -0.849545 0
    17 4.6377 -0.336759 0.0404545 0
    18 3.7477 0.921941 -0.849545 0
    19 3.7477 0.921941 0.930455 0
     4-7.27e-07 -1.22006 0.930455 -17.4952
     5-7.27e-07 -1.22006 -0.849545 -17.4952
     6-1.2492 0.921941 0.930455 -19.6818
     7-1.2492 0.921941 -0.849545 -15.323
     81.2492 0.921941 -0.849545 -17.495
     91.2492 0.921941 0.930455 -17.4951
     10-2.4985 -1.22006 -0.849545 -13.1263
     11-2.4985 -1.22006 0.930455 -10.8961
     122.4985 -1.22006 0.930455 -13.1263
     132.4985 -1.22006 -0.849545 -10.8961
     14-4.6377 -0.336759 0.0404545 -9.35471
     15-3.7477 0.921941 0.930455 -9.24444
     16-3.7477 0.921941 -0.849545 -11.4805
     174.6377 -0.336759 0.0404545 -9.35473
     183.7477 0.921941 -0.849545 -11.4805
     193.7477 0.921941 0.930455 -9.24445
    2020
    212114 15 16
     
    27273 12 13
    282811 12 13
    29 8 11 12
    30 3 8 12
    31 1 3 8
    32 1 3 6
    33 1 6 9
    34 6 9 16
    35 9 14 16
     297 11 13
     304 7 13
     312 4 7
     322 4 5
     332 5 10
     345 10 15
     3510 14 15
    36369 10 14
    37372 9 10
     
    40401 7 8
    41417 8 11
    42 10 14 15
    43 5 10 15
    44 2 5 10
    45 2 4 5
    46 2 4 7
    47 4 7 13
    48 7 11 13
     429 14 16
     436 9 16
     441 6 9
     451 3 6
     461 3 8
     473 8 12
     488 11 12
  • tests/regression/Domain/2/post/test.conf

    r06f4ef6 rb6da28  
    3535RelEpsTotalE    1e-07   # relative change in total energy
    3636RelEpsKineticE  1e-05   # relative change in kinetic energy
    37 MaxMinStopStep  0       # check every ..th steps
     37MaxMinStopStep  1       # check every ..th steps
    3838MaxMinGapStopStep       1       # check every ..th steps
    3939
     
    4242InitRelEpsTotalE        1e-05   # relative change in total energy
    4343InitRelEpsKineticE      0.0001  # relative change in kinetic energy
    44 InitMaxMinStopStep      0       # check every ..th steps
     44InitMaxMinStopStep      1       # check every ..th steps
    4545InitMaxMinGapStopStep   1       # check every ..th steps
    4646
     
    5555RiemannTensor   0       # (Use metric)
    5656PsiType         0       # 0 - doubly occupied, 1 - SpinUp,SpinDown
    57 MaxPsiDouble    0       # here: specifying both maximum number of SpinUp- and -Down-states
    58 PsiMaxNoUp      0       # here: specifying maximum number of SpinUp-states
    59 PsiMaxNoDown    0       # here: specifying maximum number of SpinDown-states
     57MaxPsiDouble    1       # here: specifying both maximum number of SpinUp- and -Down-states
     58PsiMaxNoUp      1       # here: specifying maximum number of SpinUp-states
     59PsiMaxNoDown    1       # here: specifying maximum number of SpinDown-states
    6060AddPsis         0       # Additional unoccupied Psis for bandgap determination
    6161
  • tests/regression/Domain/3/post/test.conf

    r06f4ef6 rb6da28  
    3535RelEpsTotalE    1e-07   # relative change in total energy
    3636RelEpsKineticE  1e-05   # relative change in kinetic energy
    37 MaxMinStopStep  0       # check every ..th steps
     37MaxMinStopStep  1       # check every ..th steps
    3838MaxMinGapStopStep       1       # check every ..th steps
    3939
     
    4242InitRelEpsTotalE        1e-05   # relative change in total energy
    4343InitRelEpsKineticE      0.0001  # relative change in kinetic energy
    44 InitMaxMinStopStep      0       # check every ..th steps
     44InitMaxMinStopStep      1       # check every ..th steps
    4545InitMaxMinGapStopStep   1       # check every ..th steps
    4646
     
    5555RiemannTensor   0       # (Use metric)
    5656PsiType         0       # 0 - doubly occupied, 1 - SpinUp,SpinDown
    57 MaxPsiDouble    0       # here: specifying both maximum number of SpinUp- and -Down-states
    58 PsiMaxNoUp      0       # here: specifying maximum number of SpinUp-states
    59 PsiMaxNoDown    0       # here: specifying maximum number of SpinDown-states
     57MaxPsiDouble    1       # here: specifying both maximum number of SpinUp- and -Down-states
     58PsiMaxNoUp      1       # here: specifying maximum number of SpinUp-states
     59PsiMaxNoDown    1       # here: specifying maximum number of SpinDown-states
    6060AddPsis         0       # Additional unoccupied Psis for bandgap determination
    6161
  • tests/regression/Domain/4/post/test.conf

    r06f4ef6 rb6da28  
    3535RelEpsTotalE    1e-07   # relative change in total energy
    3636RelEpsKineticE  1e-05   # relative change in kinetic energy
    37 MaxMinStopStep  0       # check every ..th steps
     37MaxMinStopStep  1       # check every ..th steps
    3838MaxMinGapStopStep       1       # check every ..th steps
    3939
     
    4242InitRelEpsTotalE        1e-05   # relative change in total energy
    4343InitRelEpsKineticE      0.0001  # relative change in kinetic energy
    44 InitMaxMinStopStep      0       # check every ..th steps
     44InitMaxMinStopStep      1       # check every ..th steps
    4545InitMaxMinGapStopStep   1       # check every ..th steps
    4646
    4747BoxLength                       # (Length of a unit cell)
    48481       
    49 0       0       
     490       1       
    50500       0       2       
    5151
     
    5555RiemannTensor   0       # (Use metric)
    5656PsiType         0       # 0 - doubly occupied, 1 - SpinUp,SpinDown
    57 MaxPsiDouble    0       # here: specifying both maximum number of SpinUp- and -Down-states
    58 PsiMaxNoUp      0       # here: specifying maximum number of SpinUp-states
    59 PsiMaxNoDown    0       # here: specifying maximum number of SpinDown-states
     57MaxPsiDouble    1       # here: specifying both maximum number of SpinUp- and -Down-states
     58PsiMaxNoUp      1       # here: specifying maximum number of SpinUp-states
     59PsiMaxNoDown    1       # here: specifying maximum number of SpinDown-states
    6060AddPsis         0       # Additional unoccupied Psis for bandgap determination
    6161
  • tests/regression/Domain/5/post/test.conf

    r06f4ef6 rb6da28  
    3535RelEpsTotalE    1e-07   # relative change in total energy
    3636RelEpsKineticE  1e-05   # relative change in kinetic energy
    37 MaxMinStopStep  0       # check every ..th steps
     37MaxMinStopStep  10      # check every ..th steps
    3838MaxMinGapStopStep       1       # check every ..th steps
    3939
     
    4242InitRelEpsTotalE        1e-05   # relative change in total energy
    4343InitRelEpsKineticE      0.0001  # relative change in kinetic energy
    44 InitMaxMinStopStep      0       # check every ..th steps
     44InitMaxMinStopStep      10      # check every ..th steps
    4545InitMaxMinGapStopStep   1       # check every ..th steps
    4646
     
    5555RiemannTensor   0       # (Use metric)
    5656PsiType         0       # 0 - doubly occupied, 1 - SpinUp,SpinDown
    57 MaxPsiDouble    0       # here: specifying both maximum number of SpinUp- and -Down-states
    58 PsiMaxNoUp      0       # here: specifying maximum number of SpinUp-states
    59 PsiMaxNoDown    0       # here: specifying maximum number of SpinDown-states
     57MaxPsiDouble    10      # here: specifying both maximum number of SpinUp- and -Down-states
     58PsiMaxNoUp      10      # here: specifying maximum number of SpinUp-states
     59PsiMaxNoDown    10      # here: specifying maximum number of SpinDown-states
    6060AddPsis         0       # Additional unoccupied Psis for bandgap determination
    6161
  • tests/regression/Filling/1/post/test.conf

    r06f4ef6 rb6da28  
    3535RelEpsTotalE    1e-07   # relative change in total energy
    3636RelEpsKineticE  1e-05   # relative change in kinetic energy
    37 MaxMinStopStep  0       # check every ..th steps
     37MaxMinStopStep  680     # check every ..th steps
    3838MaxMinGapStopStep       1       # check every ..th steps
    3939
     
    4242InitRelEpsTotalE        1e-05   # relative change in total energy
    4343InitRelEpsKineticE      0.0001  # relative change in kinetic energy
    44 InitMaxMinStopStep      0       # check every ..th steps
     44InitMaxMinStopStep      680     # check every ..th steps
    4545InitMaxMinGapStopStep   1       # check every ..th steps
    4646
     
    5555RiemannTensor   0       # (Use metric)
    5656PsiType         0       # 0 - doubly occupied, 1 - SpinUp,SpinDown
    57 MaxPsiDouble    0       # here: specifying both maximum number of SpinUp- and -Down-states
    58 PsiMaxNoUp      0       # here: specifying maximum number of SpinUp-states
    59 PsiMaxNoDown    0       # here: specifying maximum number of SpinDown-states
     57MaxPsiDouble    680     # here: specifying both maximum number of SpinUp- and -Down-states
     58PsiMaxNoUp      680     # here: specifying maximum number of SpinUp-states
     59PsiMaxNoDown    680     # here: specifying maximum number of SpinDown-states
    6060AddPsis         0       # Additional unoccupied Psis for bandgap determination
    6161
  • tests/regression/Filling/1/pre/test.conf

    r06f4ef6 rb6da28  
    7171Ion_Type2       3       6       1.0     3       3       12.01100000000  Carbon  C
    7272#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)
    73 Ion_Type2_1     9.782085945     3.275186040     3.535886037     0 # molecule nr 0
    74 Ion_Type2_2     8.532785963     4.158586027     3.535886037     0 # molecule nr 1
    75 Ion_Type2_3     7.283585982     3.275186040     3.535886037     0 # molecule nr 2
    76 Ion_Type1_1     9.782085945     2.645886050     2.645886050     0 # molecule nr 3
    77 Ion_Type1_2     9.782085945     2.645886050     4.425886024     0 # molecule nr 4
    78 Ion_Type1_3     10.672039608    3.904536878     3.535886037     0 # molecule nr 5
    79 Ion_Type1_4     8.532785963     4.787886018     2.645886050     0 # molecule nr 6
    80 Ion_Type1_5     8.532785963     4.787886018     4.425886024     0 # molecule nr 7
    81 Ion_Type1_6     6.393632318     3.904536877     3.535886037     0 # molecule nr 8
    82 Ion_Type1_7     7.283585982     2.645886050     2.645886050     0 # molecule nr 9
    83 Ion_Type1_8     7.283585982     2.645886050     4.425886024     0 # molecule nr 10
     73Ion_Type1_1     9.782085945     2.645886050     2.645886050     0 # molecule nr 0
     74Ion_Type1_2     9.782085945     2.645886050     4.425886024     0 # molecule nr 1
     75Ion_Type1_3     10.672039608    3.904536878     3.535886037     0 # molecule nr 2
     76Ion_Type1_4     8.532785963     4.787886018     2.645886050     0 # molecule nr 3
     77Ion_Type1_5     8.532785963     4.787886018     4.425886024     0 # molecule nr 4
     78Ion_Type1_6     6.393632318     3.904536877     3.535886037     0 # molecule nr 5
     79Ion_Type1_7     7.283585982     2.645886050     2.645886050     0 # molecule nr 6
     80Ion_Type1_8     7.283585982     2.645886050     4.425886024     0 # molecule nr 7
     81Ion_Type2_1     9.782085945     3.275186040     3.535886037     0 # molecule nr 8
     82Ion_Type2_2     8.532785963     4.158586027     3.535886037     0 # molecule nr 9
     83Ion_Type2_3     7.283585982     3.275186040     3.535886037     0 # molecule nr 10
  • tests/regression/Molecules/6/post/test.conf

    r06f4ef6 rb6da28  
    3535RelEpsTotalE    1e-07   # relative change in total energy
    3636RelEpsKineticE  1e-05   # relative change in kinetic energy
    37 MaxMinStopStep  0       # check every ..th steps
     37MaxMinStopStep  10      # check every ..th steps
    3838MaxMinGapStopStep       1       # check every ..th steps
    3939
     
    4242InitRelEpsTotalE        1e-05   # relative change in total energy
    4343InitRelEpsKineticE      0.0001  # relative change in kinetic energy
    44 InitMaxMinStopStep      0       # check every ..th steps
     44InitMaxMinStopStep      10      # check every ..th steps
    4545InitMaxMinGapStopStep   1       # check every ..th steps
    4646
     
    5555RiemannTensor   0       # (Use metric)
    5656PsiType         0       # 0 - doubly occupied, 1 - SpinUp,SpinDown
    57 MaxPsiDouble    0       # here: specifying both maximum number of SpinUp- and -Down-states
    58 PsiMaxNoUp      0       # here: specifying maximum number of SpinUp-states
    59 PsiMaxNoDown    0       # here: specifying maximum number of SpinDown-states
     57MaxPsiDouble    10      # here: specifying both maximum number of SpinUp- and -Down-states
     58PsiMaxNoUp      10      # here: specifying maximum number of SpinUp-states
     59PsiMaxNoDown    10      # here: specifying maximum number of SpinDown-states
    6060AddPsis         0       # Additional unoccupied Psis for bandgap determination
    6161
  • tests/regression/Molecules/6/pre/test.conf

    r06f4ef6 rb6da28  
    7171Ion_Type2       3       6       1.0     3       3       12.01100000000  Carbon  C
    7272#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)
    73 Ion_Type2_1     9.782085945     3.275186040     3.535886037     0 # molecule nr 0
    74 Ion_Type2_2     8.532785963     4.158586027     3.535886037     0 # molecule nr 1
    75 Ion_Type2_3     7.283585982     3.275186040     3.535886037     0 # molecule nr 2
    76 Ion_Type1_1     9.782085945     2.645886050     2.645886050     0 # molecule nr 3
    77 Ion_Type1_2     9.782085945     2.645886050     4.425886024     0 # molecule nr 4
    78 Ion_Type1_3     10.672039608    3.904536878     3.535886037     0 # molecule nr 5
    79 Ion_Type1_4     8.532785963     4.787886018     2.645886050     0 # molecule nr 6
    80 Ion_Type1_5     8.532785963     4.787886018     4.425886024     0 # molecule nr 7
    81 Ion_Type1_6     6.393632318     3.904536877     3.535886037     0 # molecule nr 8
    82 Ion_Type1_7     7.283585982     2.645886050     2.645886050     0 # molecule nr 9
    83 Ion_Type1_8     7.283585982     2.645886050     4.425886024     0 # molecule nr 10
     73Ion_Type1_1     9.782085945     2.645886050     2.645886050     0 # molecule nr 0
     74Ion_Type1_2     9.782085945     2.645886050     4.425886024     0 # molecule nr 1
     75Ion_Type1_3     10.672039608    3.904536878     3.535886037     0 # molecule nr 2
     76Ion_Type1_4     8.532785963     4.787886018     2.645886050     0 # molecule nr 3
     77Ion_Type1_5     8.532785963     4.787886018     4.425886024     0 # molecule nr 4
     78Ion_Type1_6     6.393632318     3.904536877     3.535886037     0 # molecule nr 5
     79Ion_Type1_7     7.283585982     2.645886050     2.645886050     0 # molecule nr 6
     80Ion_Type1_8     7.283585982     2.645886050     4.425886024     0 # molecule nr 7
     81Ion_Type2_1     9.782085945     3.275186040     3.535886037     0 # molecule nr 8
     82Ion_Type2_2     8.532785963     4.158586027     3.535886037     0 # molecule nr 9
     83Ion_Type2_3     7.283585982     3.275186040     3.535886037     0 # molecule nr 10
  • tests/regression/Molecules/7/post/test.conf

    r06f4ef6 rb6da28  
    3535RelEpsTotalE    1e-07   # relative change in total energy
    3636RelEpsKineticE  1e-05   # relative change in kinetic energy
    37 MaxMinStopStep  0       # check every ..th steps
     37MaxMinStopStep  10      # check every ..th steps
    3838MaxMinGapStopStep       1       # check every ..th steps
    3939
     
    4242InitRelEpsTotalE        1e-05   # relative change in total energy
    4343InitRelEpsKineticE      0.0001  # relative change in kinetic energy
    44 InitMaxMinStopStep      0       # check every ..th steps
     44InitMaxMinStopStep      10      # check every ..th steps
    4545InitMaxMinGapStopStep   1       # check every ..th steps
    4646
     
    5555RiemannTensor   0       # (Use metric)
    5656PsiType         0       # 0 - doubly occupied, 1 - SpinUp,SpinDown
    57 MaxPsiDouble    0       # here: specifying both maximum number of SpinUp- and -Down-states
    58 PsiMaxNoUp      0       # here: specifying maximum number of SpinUp-states
    59 PsiMaxNoDown    0       # here: specifying maximum number of SpinDown-states
     57MaxPsiDouble    10      # here: specifying both maximum number of SpinUp- and -Down-states
     58PsiMaxNoUp      10      # here: specifying maximum number of SpinUp-states
     59PsiMaxNoDown    10      # here: specifying maximum number of SpinDown-states
    6060AddPsis         0       # Additional unoccupied Psis for bandgap determination
    6161
  • tests/regression/Molecules/7/pre/test.conf

    r06f4ef6 rb6da28  
    7171Ion_Type2       3       6       1.0     3       3       12.01100000000  Carbon  C
    7272#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)
    73 Ion_Type2_1     9.782085945     3.275186040     3.535886037     0 # molecule nr 0
    74 Ion_Type2_2     8.532785963     4.158586027     3.535886037     0 # molecule nr 1
    75 Ion_Type2_3     7.283585982     3.275186040     3.535886037     0 # molecule nr 2
    76 Ion_Type1_1     9.782085945     2.645886050     2.645886050     0 # molecule nr 3
    77 Ion_Type1_2     9.782085945     2.645886050     4.425886024     0 # molecule nr 4
    78 Ion_Type1_3     10.672039608    3.904536878     3.535886037     0 # molecule nr 5
    79 Ion_Type1_4     8.532785963     4.787886018     2.645886050     0 # molecule nr 6
    80 Ion_Type1_5     8.532785963     4.787886018     4.425886024     0 # molecule nr 7
    81 Ion_Type1_6     6.393632318     3.904536877     3.535886037     0 # molecule nr 8
    82 Ion_Type1_7     7.283585982     2.645886050     2.645886050     0 # molecule nr 9
    83 Ion_Type1_8     7.283585982     2.645886050     4.425886024     0 # molecule nr 10
     73Ion_Type1_1     9.782085945     2.645886050     2.645886050     0 # molecule nr 0
     74Ion_Type1_2     9.782085945     2.645886050     4.425886024     0 # molecule nr 1
     75Ion_Type1_3     10.672039608    3.904536878     3.535886037     0 # molecule nr 2
     76Ion_Type1_4     8.532785963     4.787886018     2.645886050     0 # molecule nr 3
     77Ion_Type1_5     8.532785963     4.787886018     4.425886024     0 # molecule nr 4
     78Ion_Type1_6     6.393632318     3.904536877     3.535886037     0 # molecule nr 5
     79Ion_Type1_7     7.283585982     2.645886050     2.645886050     0 # molecule nr 6
     80Ion_Type1_8     7.283585982     2.645886050     4.425886024     0 # molecule nr 7
     81Ion_Type2_1     9.782085945     3.275186040     3.535886037     0 # molecule nr 8
     82Ion_Type2_2     8.532785963     4.158586027     3.535886037     0 # molecule nr 9
     83Ion_Type2_3     7.283585982     3.275186040     3.535886037     0 # molecule nr 10
  • tests/regression/Simple_configuration/2/post/test.conf

    r06f4ef6 rb6da28  
    3535RelEpsTotalE    1e-07   # relative change in total energy
    3636RelEpsKineticE  1e-05   # relative change in kinetic energy
    37 MaxMinStopStep  0       # check every ..th steps
     37MaxMinStopStep  1       # check every ..th steps
    3838MaxMinGapStopStep       0       # check every ..th steps
    3939
     
    4242InitRelEpsTotalE        1e-05   # relative change in total energy
    4343InitRelEpsKineticE      0.0001  # relative change in kinetic energy
    44 InitMaxMinStopStep      0       # check every ..th steps
     44InitMaxMinStopStep      1       # check every ..th steps
    4545InitMaxMinGapStopStep   0       # check every ..th steps
    4646
     
    5454Level0Factor    2       # factor by which node number increases from S to 0 level
    5555RiemannTensor   0       # (Use metric)
    56 PsiType         0       # 0 - doubly occupied, 1 - SpinUp,SpinDown
     56PsiType         1       # 0 - doubly occupied, 1 - SpinUp,SpinDown
    5757MaxPsiDouble    0       # here: specifying both maximum number of SpinUp- and -Down-states
    5858PsiMaxNoUp      0       # here: specifying maximum number of SpinUp-states
    59 PsiMaxNoDown    0       # here: specifying maximum number of SpinDown-states
     59PsiMaxNoDown    1       # here: specifying maximum number of SpinDown-states
    6060AddPsis         0       # Additional unoccupied Psis for bandgap determination
    6161
  • tests/regression/Simple_configuration/3/post/test.conf

    r06f4ef6 rb6da28  
    3535RelEpsTotalE    1e-07   # relative change in total energy
    3636RelEpsKineticE  1e-05   # relative change in kinetic energy
    37 MaxMinStopStep  0       # check every ..th steps
     37MaxMinStopStep  1       # check every ..th steps
    3838MaxMinGapStopStep       0       # check every ..th steps
    3939
     
    4242InitRelEpsTotalE        1e-05   # relative change in total energy
    4343InitRelEpsKineticE      0.0001  # relative change in kinetic energy
    44 InitMaxMinStopStep      0       # check every ..th steps
     44InitMaxMinStopStep      1       # check every ..th steps
    4545InitMaxMinGapStopStep   0       # check every ..th steps
    4646
     
    5454Level0Factor    2       # factor by which node number increases from S to 0 level
    5555RiemannTensor   0       # (Use metric)
    56 PsiType         0       # 0 - doubly occupied, 1 - SpinUp,SpinDown
     56PsiType         1       # 0 - doubly occupied, 1 - SpinUp,SpinDown
    5757MaxPsiDouble    0       # here: specifying both maximum number of SpinUp- and -Down-states
    5858PsiMaxNoUp      0       # here: specifying maximum number of SpinUp-states
    59 PsiMaxNoDown    0       # here: specifying maximum number of SpinDown-states
     59PsiMaxNoDown    1       # here: specifying maximum number of SpinDown-states
    6060AddPsis         0       # Additional unoccupied Psis for bandgap determination
    6161
  • tests/regression/Tesselation/1/post/NonConvexEnvelope.dat

    r06f4ef6 rb6da28  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 9.78209 2.64589 2.64589 0
    5 9.78209 2.64589 4.42589 0
    6 10.672 3.90454 3.53589 0
    7 8.53279 4.78789 2.64589 0
    8 8.53279 4.78789 4.42589 0
    9 6.39363 3.90454 3.53589 0
    10 7.28359 2.64589 2.64589 0
    11 7.28359 2.64589 4.42589 0
     49.78209 2.64589 2.64589 -9.24443
     59.78209 2.64589 4.42589 -11.4804
     610.672 3.90454 3.53589 -9.35464
     78.53279 4.78789 2.64589 -9.11459
     88.53279 4.78789 4.42589 -9.11459
     96.39363 3.90454 3.53589 -9.35431
     107.28359 2.64589 2.64589 -11.4803
     117.28359 2.64589 4.42589 -9.24433
    1212
    13131 3 4
  • tests/regression/Tesselation/2/post/ConvexEnvelope.dat

    r06f4ef6 rb6da28  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 9.78209 2.64589 2.64589 0
    5 9.78209 2.64589 4.42589 0
    6 10.672 3.90454 3.53589 0
    7 8.53279 4.78789 2.64589 0
    8 8.53279 4.78789 4.42589 0
    9 6.39363 3.90454 3.53589 0
    10 7.28359 2.64589 2.64589 0
    11 7.28359 2.64589 4.42589 0
     49.78209 2.64589 2.64589 -9.24443
     59.78209 2.64589 4.42589 -11.4804
     610.672 3.90454 3.53589 -9.35464
     78.53279 4.78789 2.64589 -9.11459
     88.53279 4.78789 4.42589 -9.11459
     96.39363 3.90454 3.53589 -9.35431
     107.28359 2.64589 2.64589 -11.4803
     117.28359 2.64589 4.42589 -9.24433
    1212
    13131 3 4
  • tests/regression/Tesselation/2/post/NonConvexEnvelope.dat

    r06f4ef6 rb6da28  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 9.78209 2.64589 2.64589 0
    5 9.78209 2.64589 4.42589 0
    6 10.672 3.90454 3.53589 0
    7 8.53279 4.78789 2.64589 0
    8 8.53279 4.78789 4.42589 0
    9 6.39363 3.90454 3.53589 0
    10 7.28359 2.64589 2.64589 0
    11 7.28359 2.64589 4.42589 0
     49.78209 2.64589 2.64589 -9.24443
     59.78209 2.64589 4.42589 -11.4804
     610.672 3.90454 3.53589 -9.35464
     78.53279 4.78789 2.64589 -9.11459
     88.53279 4.78789 4.42589 -9.11459
     96.39363 3.90454 3.53589 -9.35431
     107.28359 2.64589 2.64589 -11.4803
     117.28359 2.64589 4.42589 -9.24433
    1212
    13131 3 4
  • tests/regression/Tesselation/3/post/NonConvexEnvelope.dat

    r06f4ef6 rb6da28  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="test", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 0.3612 -3.628 1.323 1
    5 0.4884 -3.5983 -0.4521 3
    6 1.4985 -2.5112 0.5308 4
    7 -1.9534 -3.5752 0.5362 2
    8 -1.1883 -0.199 1.5176 3
    9 -0.7165 -1.6046 2.5129 1
    10 1.7627 -1.4479 -0.8349 4
    11 -1.003 -1.3584 -2.8848 2
    12 0.0217 -2.6629 -2.2008 1
    13 -2.8885 -1.5706 1.7543 2
    14 -2.0579 -3.6765 -1.7622 0
    15 -2.9259 -2.1146 -1.7672 1
    16 1.0353 0.1785 2.542 3
    17 1.6325 -1.3323 1.8306 2
    18 0.7271 1.177 0.3594 3
    19 1.3374 -0.2942 -2.961 2
    20 0.6036 1.0859 -2.1126 3
    21 -3.2034 -0.5041 -1.0881 3
    22 -5.1809 -1.8679 0.9687 1
    23 -4.6025 -2.4721 -0.6025 2
    24 -4.3385 -3.4329 0.8725 0
    25 3.191 1.3217 -2.8354 1
    26 -4.0905 0.6312 1.6028 3
    27 2.8131 1.4776 2.5103 0
    28 3.9137 2.2936 1.3739 0
    29 2.159 2.5738 1.2698 5
    30 3.6606 -0.4593 2.1396 2
    31 3.2007 -1.4419 0.7311 4
    32 -3.3002 2.3589 0.0094 8
    33 -4.377 1.6962 -1.2433 3
    34 5.2593 1.4547 -1.7445 0
    35 4.6863 2.7674 -0.6775 0
    36 5.746 -0.9031 1.204 0
    37 5.1212 -0.8867 -0.4582 4
    38 -5.2641 2.8314 1.4476 0
    39 5.2727 1.6068 1.2828 2
    40 -6.2394 4.6427 0.0632 0
    41 -4.4738 4.5591 -0.1458 3
    42 -5.5506 3.8964 -1.3985 0
    43 -6.7081 0.9923 0.6224 2
    44 -7.5442 2.5597 0.5118 0
    45 -6.8554 1.8134 -0.9499 1
    46 7.1391 2.0447 0.0264 0
    47 6.9077 1.1106 0.1214 1
     46.9077 1.1106 0.1214 -6.99715
     50.3612 -3.628 1.323 6.00416
     60.4884 -3.5983 -0.4521 11.8428
     71.4985 -2.5112 0.5308 6.07951
     8-1.9534 -3.5752 0.5362 -4.26914
     9-1.1883 -0.199 1.5176 14.2992
     10-0.7165 -1.6046 2.5129 6.2134
     111.7627 -1.4479 -0.8349 7.15053
     12-1.003 -1.3584 -2.8848 32.043
     130.0217 -2.6629 -2.2008 16.8009
     14-2.8885 -1.5706 1.7543 -1.77076
     15-2.0579 -3.6765 -1.7622 -7.05319
     16-2.9259 -2.1146 -1.7672 33.6663
     171.0353 0.1785 2.542 48.8869
     181.6325 -1.3323 1.8306 1.44108
     190.7271 1.177 0.3594 27.9872
     201.3374 -0.2942 -2.961 13.6459
     210.6036 1.0859 -2.1126 98.521
     22-3.2034 -0.5041 -1.0881 8.44805
     23-5.1809 -1.8679 0.9687 -6.07448
     24-4.6025 -2.4721 -0.6025 -6.52057
     25-4.3385 -3.4329 0.8725 -4.12716
     263.191 1.3217 -2.8354 -10.5968
     27-4.0905 0.6312 1.6028 21.8745
     282.8131 1.4776 2.5103 -0.774194
     293.9137 2.2936 1.3739 -2.51806
     302.159 2.5738 1.2698 151.494
     313.6606 -0.4593 2.1396 2.60004
     323.2007 -1.4419 0.7311 2.29272
     33-3.3002 2.3589 0.0094 461.065
     34-4.377 1.6962 -1.2433 43.4649
     355.2593 1.4547 -1.7445 -6.26082
     364.6863 2.7674 -0.6775 -8.55931
     375.746 -0.9031 1.204 -1.29544
     385.1212 -0.8867 -0.4582 31.5177
     39-5.2641 2.8314 1.4476 21.5516
     405.2727 1.6068 1.2828 -2.57271
     41-6.2394 4.6427 0.0632 -9.24392
     42-4.4738 4.5591 -0.1458 62.5211
     43-5.5506 3.8964 -1.3985 -10.3613
     44-6.7081 0.9923 0.6224 -7.08885
     45-7.5442 2.5597 0.5118 -11.4252
     46-6.8554 1.8134 -0.9499 3.80444
     477.1391 2.0447 0.0264 -7.88713
    4848
    49 31 43 44
    50 31 34 44
    51 33 34 44
    52 22 31 34
    53 16 22 34
    54 7 16 34
    55 7 9 16
    56 2 7 9
    57 2 7 34
    58 2 3 34
    59 3 28 34
    60 28 33 34
    61 1 2 3
    62 1 3 28
    63 1 14 28
    64 14 27 28
    65 27 28 33
    66 1 6 14
    67 6 13 14
    68 13 14 27
    69 13 24 27
    70 24 27 36
    71 27 33 36
    72 33 36 44
    73 36 43 44
    74 24 25 36
    75 24 25 26
    76 25 26 32
    77 25 32 43
    78 25 36 43
    79 13 24 26
    80 13 26 29
    81 5 13 29
    82 5 23 29
    83 23 29 35
    84 29 35 38
    85 26 29 38
    86 26 29 38
    87 15 26 29
    88 15 17 29
    89 15 17 26
    90 17 26 32
    91 17 22 32
    92 5 6 23
    93 5 6 13
    94 6 10 23
    95 10 19 23
    96 19 23 40
    97 23 35 40
    98 35 40 41
    99 10 19 21
    100 4 10 21
    101 4 6 10
    102 1 4 6
    103 35 37 38
    104 35 37 41
    105 17 29 30
    106 29 30 38
    107 30 38 39
    108 8 17 30
    109 8 16 17
    110 16 17 22
    111 8 18 30
    112 8 12 18
    113 12 18 30
    114 12 20 30
    115 20 30 42
    116 30 39 42
    117 8 11 12
    118 8 9 11
    119 8 9 16
    120 11 12 20
    121 11 20 21
    122 4 11 21
    123 2 4 11
    124 1 2 4
    125 2 9 11
    126 19 20 21
    127 19 20 40
    128 20 40 42
    129 40 41 42
    130 22 31 32
    131 31 32 43
    132 39 41 42
    133 37 39 41
    134 37 38 39
     491 32 44
     501 32 35
     511 34 35
     5223 32 35
     5317 23 35
     548 17 35
     558 10 17
     563 8 10
     573 8 35
     583 4 35
     594 29 35
     6029 34 35
     612 3 4
     622 4 29
     632 15 29
     6415 28 29
     6528 29 34
     662 7 15
     677 14 15
     6814 15 28
     6914 25 28
     7025 28 37
     7128 34 37
     721 34 37
     731 37 44
     7425 26 37
     7525 26 27
     7626 27 33
     7726 33 44
     7826 37 44
     7914 25 27
     8014 27 30
     816 14 30
     826 24 30
     8324 30 36
     8430 36 39
     8527 30 39
     8627 30 39
     8716 27 30
     8816 18 30
     8916 18 27
     9018 27 33
     9118 23 33
     926 7 24
     936 7 14
     947 11 24
     9511 20 24
     9620 24 41
     9724 36 41
     9836 41 42
     9911 20 22
     1005 11 22
     1015 7 11
     1022 5 7
     10336 38 39
     10436 38 42
     10518 30 31
     10630 31 39
     10731 39 40
     1089 18 31
     1099 17 18
     11017 18 23
     1119 19 31
     1129 13 19
     11313 19 31
     11413 21 31
     11521 31 43
     11631 40 43
     1179 12 13
     1189 10 12
     1199 10 17
     12012 13 21
     12112 21 22
     1225 12 22
     1233 5 12
     1242 3 5
     1253 10 12
     12620 21 22
     12720 21 41
     12821 41 43
     12941 42 43
     13023 32 33
     13132 33 44
     13240 42 43
     13338 40 42
     13438 39 40
  • tests/regression/Tesselation/3/post/NonConvexEnvelope.r3d

    r06f4ef6 rb6da28  
    33# All atoms as spheres
    442
     5  0.939662 -3.01666 0.414493    0.1     1. 1. 1.
     62
     7  -0.152738 -1.94716 0.354093   0.1     1. 1. 1.
     82
     9  0.0659622 -1.03376 -0.880907  0.1     1. 1. 1.
     102
     11  -1.50434 -2.59696 0.0723932   0.1     1. 1. 1.
     122
     13  -0.0717378 -1.05346 1.57779   0.1     1. 1. 1.
     142
     15  1.52186 -0.603155 -0.873807   0.1     1. 1. 1.
     162
     17  -0.346038 -1.95996 -2.03011   0.1     1. 1. 1.
     182
     19  -2.63434 -1.74086 0.647893    0.1     1. 1. 1.
     202
     21  -1.61364 -2.66266 -1.47131    0.1     1. 1. 1.
     222
     23  1.36626 -0.519255 1.65039     0.1     1. 1. 1.
     242
     25  1.74646 0.246745 0.389693     0.1     1. 1. 1.
     262
     27  1.78606 0.287745 -2.09451     0.1     1. 1. 1.
     282
     29  -2.65324 -0.381955 -0.0548068         0.1     1. 1. 1.
     302
     31  -3.97304 -2.44796 0.426993    0.1     1. 1. 1.
     322
     33  3.21726 0.635145 0.478793     0.1     1. 1. 1.
     342
     35  3.13516 0.931145 -1.97401     0.1     1. 1. 1.
     362
     37  -3.80794 0.459345 0.492693    0.1     1. 1. 1.
     382
     39  3.34736 1.81094 1.44919       0.1     1. 1. 1.
     402
     41  3.76986 1.05884 -0.855107     0.1     1. 1. 1.
     422
     43  4.05806 -0.522555 1.01199     0.1     1. 1. 1.
     442
     45  -3.82684 1.81824 -0.210007    0.1     1. 1. 1.
     462
     47  5.16496 1.66244 -0.848507     0.1     1. 1. 1.
     482
     49  5.48576 -0.422855 0.476393    0.1     1. 1. 1.
     502
     51  -4.98154 2.65954 0.337493     0.1     1. 1. 1.
     522
     53  5.91796 1.03174 0.331693      0.1     1. 1. 1.
     542
     55  -5.00044 4.01854 -0.365207    0.1     1. 1. 1.
     562
     57  -6.30524 1.93554 0.0833932    0.1     1. 1. 1.
     582
     59  7.32406 1.08574 0.0829932     0.1     1. 1. 1.
     602
    561  0.777562 -3.65286 1.28459     0.1     1. 1. 1.
    6622
     
    941502
    95151  7.55546 2.01984 -0.0120068    0.1     1. 1. 1.
    96 2
    97   0.939662 -3.01666 0.414493    0.1     1. 1. 1.
    98 2
    99   -0.152738 -1.94716 0.354093   0.1     1. 1. 1.
    100 2
    101   0.0659622 -1.03376 -0.880907  0.1     1. 1. 1.
    102 2
    103   -1.50434 -2.59696 0.0723932   0.1     1. 1. 1.
    104 2
    105   -0.0717378 -1.05346 1.57779   0.1     1. 1. 1.
    106 2
    107   1.52186 -0.603155 -0.873807   0.1     1. 1. 1.
    108 2
    109   -0.346038 -1.95996 -2.03011   0.1     1. 1. 1.
    110 2
    111   -2.63434 -1.74086 0.647893    0.1     1. 1. 1.
    112 2
    113   -1.61364 -2.66266 -1.47131    0.1     1. 1. 1.
    114 2
    115   1.36626 -0.519255 1.65039     0.1     1. 1. 1.
    116 2
    117   1.74646 0.246745 0.389693     0.1     1. 1. 1.
    118 2
    119   1.78606 0.287745 -2.09451     0.1     1. 1. 1.
    120 2
    121   -2.65324 -0.381955 -0.0548068         0.1     1. 1. 1.
    122 2
    123   -3.97304 -2.44796 0.426993    0.1     1. 1. 1.
    124 2
    125   3.21726 0.635145 0.478793     0.1     1. 1. 1.
    126 2
    127   3.13516 0.931145 -1.97401     0.1     1. 1. 1.
    128 2
    129   -3.80794 0.459345 0.492693    0.1     1. 1. 1.
    130 2
    131   3.34736 1.81094 1.44919       0.1     1. 1. 1.
    132 2
    133   3.76986 1.05884 -0.855107     0.1     1. 1. 1.
    134 2
    135   4.05806 -0.522555 1.01199     0.1     1. 1. 1.
    136 2
    137   -3.82684 1.81824 -0.210007    0.1     1. 1. 1.
    138 2
    139   5.16496 1.66244 -0.848507     0.1     1. 1. 1.
    140 2
    141   5.48576 -0.422855 0.476393    0.1     1. 1. 1.
    142 2
    143   -4.98154 2.65954 0.337493     0.1     1. 1. 1.
    144 2
    145   5.91796 1.03174 0.331693      0.1     1. 1. 1.
    146 2
    147   -5.00044 4.01854 -0.365207    0.1     1. 1. 1.
    148 2
    149   -6.30524 1.93554 0.0833932    0.1     1. 1. 1.
    150 2
    151   7.32406 1.08574 0.0829932     0.1     1. 1. 1.
    152152# All tesselation triangles
    1531538
     
    156156  BACKFACE  0.3 0.3 1.0   0 0
    1571571
    158   5.67566 1.42984 -1.78291      7.55546 2.01984 -0.0120068      7.32406 1.08574 0.0829932       1. 0. 0.
    159 1
    160   5.67566 1.42984 -1.78291      5.53756 -0.911555 -0.496607     7.32406 1.08574 0.0829932       1. 0. 0.
    161 1
    162   6.16236 -0.927955 1.16559     5.53756 -0.911555 -0.496607     7.32406 1.08574 0.0829932       1. 0. 0.
     158  7.32406 1.08574 0.0829932     5.67566 1.42984 -1.78291        7.55546 2.01984 -0.0120068      1. 0. 0.
     1591
     160  7.32406 1.08574 0.0829932     5.67566 1.42984 -1.78291        5.53756 -0.911555 -0.496607     1. 0. 0.
     1611
     162  7.32406 1.08574 0.0829932     6.16236 -0.927955 1.16559       5.53756 -0.911555 -0.496607     1. 0. 0.
    1631631
    164164  3.60736 1.29684 -2.87381      5.67566 1.42984 -1.78291        5.53756 -0.911555 -0.496607     1. 0. 0.
     
    202202  4.07696 -0.484155 2.10119     6.16236 -0.927955 1.16559       5.68906 1.58194 1.24439         1. 0. 0.
    2032031
    204   6.16236 -0.927955 1.16559     5.68906 1.58194 1.24439         7.32406 1.08574 0.0829932       1. 0. 0.
    205 1
    206   5.68906 1.58194 1.24439       7.55546 2.01984 -0.0120068      7.32406 1.08574 0.0829932       1. 0. 0.
     204  7.32406 1.08574 0.0829932     6.16236 -0.927955 1.16559       5.68906 1.58194 1.24439         1. 0. 0.
     2051
     206  7.32406 1.08574 0.0829932     5.68906 1.58194 1.24439         7.55546 2.01984 -0.0120068      1. 0. 0.
    2072071
    208208  3.22946 1.45274 2.47189       4.33006 2.26874 1.33549         5.68906 1.58194 1.24439         1. 0. 0.
  • tests/regression/testsuite-analysis.at

    r06f4ef6 rb6da28  
    44AT_KEYWORDS([analysis])
    55AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/1/pre/test.conf .], 0)
    6 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E --elements 1 8 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])
     6AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])
    77AT_CHECK([fgrep "Begin of PairCorrelation" stdout], 0, [ignore], [ignore])
    88#AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/1/post/$file], 0, [ignore], [ignore])
     
    1414AT_KEYWORDS([analysis])
    1515AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/pre/test.conf .], 0)
    16 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E --elements 1 8 --output-file output-5.csv --bin-output-file bin_output-5.csv --bin-start 0 --bin-end 5], 0, [stdout], [stderr])
     16AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output-5.csv --bin-output-file bin_output-5.csv --bin-start 0 --bin-end 5], 0, [stdout], [stderr])
    1717#AT_CHECK([file=output-5.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
    1818AT_CHECK([file=bin_output-5.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
    19 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E --elements 1 8 --output-file output-10.csv --bin-output-file bin_output-10.csv --bin-start 5 --bin-end 10], 0, [stdout], [stderr])
     19AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output-10.csv --bin-output-file bin_output-10.csv --bin-start 5 --bin-end 10], 0, [stdout], [stderr])
    2020#AT_CHECK([file=output-10.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
    2121AT_CHECK([file=bin_output-10.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
    22 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -C E --elements 1 8 --output-file output-20.csv --bin-output-file bin_output-20.csv --bin-start 10 --bin-end 20], 0, [stdout], [stderr])
     22AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output-20.csv --bin-output-file bin_output-20.csv --bin-start 10 --bin-end 20], 0, [stdout], [stderr])
    2323#AT_CHECK([file=output-20.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
    2424AT_CHECK([file=bin_output-20.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore])
     
    2929AT_KEYWORDS([analysis])
    3030AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/3/pre/test.conf .], 0)
    31 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 7 -C P --elements 1 --position 10. 10. 10. --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])
     31AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 7 --select-all-molecules --point-correlation --elements 1 --position "10., 10., 10." --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])
    3232AT_CHECK([fgrep "Begin of CorrelationToPoint" stdout], 0, [ignore], [ignore])
    3333#AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/3/post/$file], 0, [ignore], [ignore])
     
    3939AT_KEYWORDS([analysis])
    4040AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/4/pre/test.conf .], 0)
    41 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -I -C S --elements 1 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-width 1. --bin-end 20 --molecule-by-id 208], 0, [stdout], [stderr])
     41AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -I --select-all-molecules --unselect-molecule-by-id 207 --surface-correlation --elements 1 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-width 1. --bin-end 20 --molecule-by-id 207], 0, [stdout], [stderr])
    4242AT_CHECK([fgrep "Begin of CorrelationToSurface" stdout], 0, [ignore], [ignore])
    4343#AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/4/post/$file], 0, [ignore], [ignore])
     
    4949#AT_KEYWORDS([analysis])
    5050#AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/5/pre/test.conf .], 0)
    51 #AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -m 0], 0, [stdout], [stderr])
     51#AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -m 0], 0, [stdout], [stderr])
    5252#AT_CHECK([fgrep "eigenvalue = 4382.53," stdout], 0, [ignore], [ignore])
    5353#AT_CHECK([fgrep "eigenvalue = 4369.24," stdout], 0, [ignore], [ignore])
  • tests/regression/testsuite-domain.at

    r06f4ef6 rb6da28  
    33AT_SETUP([Domain - defining simulation domain])
    44AT_KEYWORDS([domain])
    5 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -B 10 0 10 0 0 10], 0, [stdout], [stderr])
     5AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o pcp -B "10, 0, 10, 0, 0, 10"], 0, [stdout], [stderr])
    66AT_CHECK([fgrep "BoxLength" test.conf], 0, [stdout], [stderr])
    77AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/1/post/test.conf], 0, [stdout], [stderr])
     
    1212AT_KEYWORDS([domain])
    1313AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/2/pre/test.conf .], 0)
    14 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -b 15 0 15 0 0 15], 0, [stdout], [stderr])
     14AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -b "15, 0, 15, 0, 0, 15"], 0, [stdout], [stderr])
    1515AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/2/post/test.conf], 0, [stdout], [stderr])
    1616AT_CLEANUP
     
    2020AT_KEYWORDS([domain])
    2121AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/3/pre/test.conf .], 0)
    22 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -c 5 10 15], 0, [stdout], [stderr])
     22AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -c "5, 10, 15"], 0, [stdout], [stderr])
    2323AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/3/post/test.conf], 0, [stdout], [stderr])
    2424AT_CLEANUP
     
    2828AT_KEYWORDS([domain])
    2929AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/4/pre/test.conf .], 0)
    30 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -O], 0, [stdout], [stderr])
     30AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -O], 0, [stdout], [stderr])
    3131AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/4/post/test.conf], 0, [stdout], [stderr])
    3232AT_CLEANUP
     
    3636AT_KEYWORDS([domain])
    3737AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/5/pre/test.conf .], 0)
    38 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -s 0.5 1. 0.9], 0, [stdout], [stderr])
     38AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -s "0.5, 1., 0.9"], 0, [stdout], [stderr])
    3939AT_CHECK([diff test.conf ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/5/post/test.conf], 0, [stdout], [stderr])
    4040AT_CLEANUP
     
    4444AT_KEYWORDS([domain])
    4545AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf .], 0)
    46 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -d 1 1 1], 0, [stdout], [stderr])
    47 AT_CHECK([file=test.conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
    48 AT_CHECK([file=test.conf.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
    49 AT_CHECK([file=test.conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
     46AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o xyz -d "1, 1, 1"], 0, [stdout], [stderr])
     47AT_CHECK([file=test.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
     48AT_CHECK([file=test.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
     49AT_CHECK([file=test.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
    5050AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf test-x.conf], 0)
    51 AT_CHECK([../../molecuilder test-x.conf -e ${abs_top_srcdir}/src/ -d 2 1 1], 0, [stdout], [stderr])
    52 AT_CHECK([file=test-x.conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
    53 AT_CHECK([file=test-x.conf.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
    54 AT_CHECK([file=test-x.conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
     51AT_CHECK([../../molecuilder -i test-x.conf -e ${abs_top_srcdir}/src/ -o xyz -d "2, 1, 1"], 0, [stdout], [stderr])
     52AT_CHECK([file=test-x.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
     53AT_CHECK([file=test-x.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
     54AT_CHECK([file=test-x.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
    5555AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf test-y.conf], 0)
    56 AT_CHECK([../../molecuilder test-y.conf -e ${abs_top_srcdir}/src/ -d 1 2 1], 0, [stdout], [stderr])
    57 AT_CHECK([file=test-y.conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
    58 AT_CHECK([file=test-y.conf.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
    59 AT_CHECK([file=test-y.conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
     56AT_CHECK([../../molecuilder -i test-y.conf -e ${abs_top_srcdir}/src/ -o xyz -d "1, 2, 1"], 0, [stdout], [stderr])
     57AT_CHECK([file=test-y.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
     58AT_CHECK([file=test-y.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
     59AT_CHECK([file=test-y.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
    6060AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/pre/test.conf test-z.conf], 0)
    61 AT_CHECK([../../molecuilder test-z.conf -e ${abs_top_srcdir}/src/ -d 1 1 2], 0, [stdout], [stderr])
    62 AT_CHECK([file=test-z.conf.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
    63 AT_CHECK([file=test-z.conf.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
    64 AT_CHECK([file=test-z.conf.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
     61AT_CHECK([../../molecuilder -i test-z.conf -e ${abs_top_srcdir}/src/ -o xyz -d "1, 1, 2"], 0, [stdout], [stderr])
     62AT_CHECK([file=test-z.xyz;sort -n $file | grep -v "Created by" >$file-sorted], 0, [ignore], [ignore])
     63AT_CHECK([file=test-z.xyz;sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Domain/6/post/$file  | grep -v "Created by" >$file-sorted2], 0, [ignore], [ignore])
     64AT_CHECK([file=test-z.xyz; diff $file-sorted $file-sorted2], 0, [ignore], [ignore])
    6565#AT_CHECK([/bin/false], 12, [ignore], [ignore])
    6666AT_CLEANUP
  • tests/regression/testsuite-filling.at

    r06f4ef6 rb6da28  
    1010H       0.758602 0.     -0.504284
    1111]])
    12 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -F water.xyz --MaxDistance -1 --distances 3.1 3.1 3.1  --lengths 2.1 0. 0. --DoRotate 0], 0, [stdout], [stderr])
     12AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -F water.xyz --MaxDistance -1 --distances "3.1, 3.1, 3.1"  --lengths "2.1, 0., 0." --DoRotate 0], 0, [stdout], [stderr])
    1313AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Filling/1/post/$file], 0, [ignore], [ignore])
    1414AT_CLEANUP
     
    1818AT_KEYWORDS([filling])
    1919AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Filling/2/pre/test.conf .], 0)
    20 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -u 1.3], 0, [stdout], [stderr])
     20AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-molecule-by-id 0 -u 1.3], 0, [stdout], [stderr])
    2121#AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Filling/2/post/$file], 0, [ignore], [ignore])
    2222AT_CLEANUP
  • tests/regression/testsuite-fragmentation.at

    r06f4ef6 rb6da28  
    1212AT_SETUP([Fragmentation - Fragmentation])
    1313AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/2/pre/test.conf .], 0)
    14 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -f 0 --distance 1.55 --order 2], 0, [ignore], [ignore])
     14AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], 0, [ignore], [ignore])
    1515AT_CHECK([ls -l BondFragment*.conf | wc -l], 0, [5
    1616], [ignore])
     
    2121AT_SETUP([Fragmentation - BROKEN: Fragmentation is at MaxOrder])
    2222AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/3/pre/test.conf .], 0)
    23 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -f 0 --distance 1.55 --order 2], 0, [ignore], [ignore])
    24 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -f 0 --distance 1.55 --order 2], [ignore], [ignore], [ignore])
     23AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], 0, [ignore], [ignore])
     24AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], [ignore], [ignore], [ignore])
    2525AT_CLEANUP
  • tests/regression/testsuite-graph.at

    r06f4ef6 rb6da28  
    44AT_KEYWORDS([graph])
    55AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Graph/1/pre/test.conf .], 0)
    6 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -D 2.], 0, [stdout], [stderr])
     6AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -D 2.], 0, [stdout], [stderr])
    77AT_CHECK([fgrep -c "No rings were detected in the molecular structure." stdout], 0, [1
    88], [ignore])
     
    1212AT_KEYWORDS([graph])
    1313AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Graph/2/pre/test.conf .], 0)
    14 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 3 -I], 0, [stdout], [stderr])
     14AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -I], 0, [stdout], [stderr])
    1515AT_CHECK([fgrep "I scanned 31 molecules." stdout], 0, [ignore], [ignore])
    1616AT_CLEANUP
  • tests/regression/testsuite-molecules.at

    r06f4ef6 rb6da28  
    44AT_KEYWORDS([Molecules])
    55AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/1/pre/test.* .], 0)
    6 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 4 -A test.dbond --molecule-by-id 0], 0, [stdout], [stderr])
     6AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 4 --select-molecule-by-id 0 -A test.dbond], 0, [stdout], [stderr])
    77AT_CHECK([fgrep "Looking for atoms 2 and 9." stdout], 0, [ignore], [ignore])
    88AT_CLEANUP
     
    1212AT_KEYWORDS([Molecules])
    1313AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/pre/test.conf .], 0)
    14 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -j test.dbond --molecule-by-id 0], 0, [stdout], [stderr])
     14AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -j test.dbond], 0, [stdout], [stderr])
    1515AT_CHECK([file=test.dbond; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/post/$file], 0, [ignore], [ignore])
    16 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -J test.adj --molecule-by-id 0], 0, [stdout], [stderr])
     16AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -J test.adj], 0, [stdout], [stderr])
    1717AT_CHECK([file=test.adj; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/post/$file], 0, [ignore], [ignore])
    1818AT_CLEANUP
     
    2222AT_KEYWORDS([Molecules])
    2323AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/3/pre/test.conf .], 0)
    24 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -S test.ekin --molecule-by-id 0], 0, [stdout], [stderr])
     24AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -S test.ekin], 0, [stdout], [stderr])
    2525AT_CHECK([file=test.ekin; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/3/post/$file], 0, [ignore], [ignore])
    2626AT_CLEANUP
     
    3030AT_KEYWORDS([Molecules])
    3131AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/4/pre/test.conf .], 0)
    32 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -L teststep --start-step 0 --end-step 1 --molecule-by-id 0 --id-mapping 1], 0, [stdout], [stderr])
     32AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -L teststep --start-step 0 --end-step 1 --id-mapping 1], 0, [stdout], [stderr])
    3333AT_CLEANUP
    3434
     
    3737AT_KEYWORDS([Molecules])
    3838AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/5/pre/test.* .], 0)
    39 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -P test.forces --molecule-by-id 0], 134, [stdout], [stderr])
     39AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -P test.forces], 0, [stdout], [stderr])
    4040#AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/5/post/$file], 0, [ignore], [ignore])
    4141AT_CLEANUP
     
    4545AT_KEYWORDS([Molecules])
    4646AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/pre/test.* .], 0)
    47 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -t 1. 1. 1. --molecule-by-id 0 --periodic 0], 0, [stdout], [stderr])
     47AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -t "1., 1., 1." --periodic 0], 0, [stdout], [stderr])
    4848AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/post/$file], 0, [ignore], [ignore])
     49AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/pre/test2.* .], 0)
     50AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -t "-1., -1., -1." --periodic 0], 0, [stdout], [stderr])
     51AT_CHECK([file=test2.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/post/$file], 0, [ignore], [ignore])
    4952AT_CLEANUP
    5053
     
    5356AT_KEYWORDS([Molecules])
    5457AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/7/pre/test.* .], 0)
    55 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -t 12. 12. 12. --molecule-by-id 0 --periodic 1], 0, [stdout], [stderr])
     58AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -t "12., 12., 12." --periodic 1], 0, [stdout], [stderr])
    5659AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/7/post/$file], 0, [ignore], [ignore])
    5760AT_CLEANUP
     
    6164AT_KEYWORDS([Molecules])
    6265AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/pre/test.* .], 0)
    63 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -m 1], 0, [stdout], [stderr])
     66AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m 0], 0, [stdout], [stderr])
    6467#AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore])
    6568AT_CLEANUP
  • tests/regression/testsuite-simple_configuration.at

    r06f4ef6 rb6da28  
    1414AT_KEYWORDS([configuration])
    1515AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/pre/test.xyz .], 0)
    16 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -p test.xyz], 0, [ignore], [ignore])
     16AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -p test.xyz], 0, [ignore], [ignore])
    1717AT_CHECK([fgrep "Ion_Type1_1" test.conf], 0, [Ion_Type1_1       10.000000000    10.000000000    10.000000000    0 # molecule nr 0
    1818], [ignore])
    1919AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/post/$file], 0, [ignore], [ignore])
    20 AT_CHECK([file=test.conf.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/post/$file], 0, [ignore], [ignore])
    21 AT_CHECK([file=test.conf.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/post/$file], 0, [ignore], [ignore])
     20AT_CHECK([file=test.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/post/$file], 0, [ignore], [ignore])
     21AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/2/post/$file], 0, [ignore], [ignore])
    2222AT_CLEANUP
    2323
    24 # 3. add atom
     24# 3a. add atom
    2525AT_SETUP([Simple configuration - adding atom])
    2626AT_KEYWORDS([configuration])
    27 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -a 1 --position 10. 10. 10.], 0, [ignore], [ignore])
     27AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -a 1 --position "10., 10., 10."], 0, [ignore], [ignore])
    2828AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
    29 AT_CHECK([file=test.conf.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
    30 AT_CHECK([file=test.conf.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
     29AT_CHECK([file=test.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
     30AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore])
     31AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -a 1 --position "0., 0., -1."], 134, [ignore], [ignore])
    3132AT_CLEANUP
    3233
     
    3435AT_SETUP([Simple configuration - Changing element])
    3536AT_KEYWORDS([configuration])
    36 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/pre/test.conf test.conf], 0)
    37 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -E 0 --element 6], 0, [ignore], [ignore])
    38 AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/post/$file], 0, [ignore], [ignore])
     37AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/pre/test.xyz test.xyz], 0)
     38AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-atom-by-id 0 -E 6 ], 0, [ignore], [ignore])
     39AT_CHECK([file=test.xyz; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/post/$file], 0, [ignore], [ignore])
    3940AT_CLEANUP
    4041
     
    4344AT_KEYWORDS([configuration])
    4445AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/pre/test.conf .], 0)
    45 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -r 0], 0, [ignore], [ignore])
     46AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz --select-atom-by-id 0 -r], 0, [ignore], [ignore])
    4647AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore])
    47 AT_CHECK([file=test.conf.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore])
    48 AT_CHECK([file=test.conf.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore])
     48AT_CHECK([file=test.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore])
     49AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore])
    4950AT_CLEANUP
    5051
     
    5253AT_SETUP([Simple configuration - invalid commands on empty configs])
    5354AT_KEYWORDS([configuration])
    54 AT_CHECK([../../molecuilder empty.conf -e ${abs_top_srcdir}/src/ -t -s -b -E -c -b -a -U -T -u], 255, [ignore], [stderr])
    55 AT_CHECK([fgrep -c "Not enough" stderr], 0, [1
    56 ], [ignore])
     55AT_CHECK([../../molecuilder -i empty.conf -e ${abs_top_srcdir}/src/ -t -s -b -E -c -b -a -U -T -u], 134, [ignore], [stderr])
    5756AT_CLEANUP
    5857
     
    6160AT_KEYWORDS([configuration])
    6261AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/7/pre/test.conf .], 0)
    63 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -t], 255, [ignore], [stderr])
    64 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore])
    65 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -s -b -E -c -b -a -U -T -u], 255, [ignore], [stderr])
    66 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore])
    67 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -b -E -c -b -a -U -T -u], 255, [ignore], [stderr])
    68 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore])
    69 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -E -c -b -a -U -T -u], 255, [ignore], [stderr])
    70 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore])
    71 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -c -b -a -U -T -u], 255, [ignore], [stderr])
    72 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore])
    73 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -b -a -U -T -u], 255, [ignore], [stderr])
    74 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore])
    75 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -a -U -T -u], 255, [ignore], [stderr])
    76 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore])
    77 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -U -T -u], 255, [ignore], [stderr])
    78 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore])
    79 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -T -u], 255, [ignore], [stderr])
    80 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore])
    81 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -u], 255, [ignore], [stderr])
    82 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore])
     62AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -t], 134, [ignore], [stderr])
     63AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -s -b -E -c -b -a -U -T -u], 134, [ignore], [stderr])
     64AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -b -E -c -b -a -U -T -u], 134, [ignore], [stderr])
     65AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -E -c -b -a -U -T -u], 134, [ignore], [stderr])
     66AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -c -b -a -U -T -u], 134, [ignore], [stderr])
     67AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -b -a -U -T -u], 134, [ignore], [stderr])
     68AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -a -U -T -u], 134, [ignore], [stderr])
     69AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -U -T -u], 134, [ignore], [stderr])
     70AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -T -u], 134, [ignore], [stderr])
     71AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -u], 134, [ignore], [stderr])
    8372AT_CLEANUP
    8473
     
    8776AT_KEYWORDS([configuration])
    8877AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/pre/test.* .], 0)
    89 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -R 7. --position 7.283585982 3.275186040 3.535886037], 0, [stdout], [stderr])
    90 AT_CHECK([sort -n test.conf.xyz | grep -v "Created by" >test.conf.xyz-sorted], 0, [ignore], [ignore])
    91 AT_CHECK([sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/test.conf.xyz  | grep -v "Created by" >${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/test.conf.xyz-sorted], 0, [ignore], [ignore])
    92 AT_CHECK([file=test.conf.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
     78AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o xyz -R 7. --position "7.283585982, 3.275186040, 3.535886037"], 0, [stdout], [stderr])
     79AT_CHECK([sort -n test.xyz | grep -v "Created by" >test.xyz-sorted], 0, [ignore], [ignore])
     80AT_CHECK([sort -n ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/test.xyz  | grep -v "Created by" >${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/test.xyz-sorted], 0, [ignore], [ignore])
     81AT_CHECK([file=test.xyz-sorted; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/8/post/$file], 0, [ignore], [ignore])
    9382AT_CLEANUP
  • tests/regression/testsuite-specifics.at

    r06f4ef6 rb6da28  
    44AT_KEYWORDS([options])
    55AT_CHECK([pwd],[ignore],[ignore])
    6 AT_CHECK([../../molecuilder test.conf -v 1 -M test], 0, [stdout], [ignore])
     6AT_CHECK([../../molecuilder -i test.conf -v 1 -M test], 0, [stdout], [ignore])
    77AT_CHECK([fgrep "Setting MPQC basis to test." stdout], 0, [ignore], [ignore])
    88AT_CLEANUP
  • tests/regression/testsuite-standard_options.at

    r06f4ef6 rb6da28  
    1818AT_SETUP([Standard Options - no element database])
    1919AT_KEYWORDS([options])
    20 AT_CHECK([../../molecuilder -e], 255, [ignore], [stderr])
    21 AT_CHECK([fgrep "Not enough or invalid arguments" stderr], 0, [ignore], [ignore])
     20AT_CHECK([../../molecuilder -e], 134, [ignore], [stderr])
    2221AT_CLEANUP
    2322
     
    3029Helium  He      1       18      p       2       4.003   1.5     1.4
    3130]])
    32 AT_CHECK([../../molecuilder test.conf -e ./], 0, [stdout], [stderr])
     31AT_CHECK([../../molecuilder -i test.conf -e ./], 0, [stdout], [stderr])
    3332AT_CHECK([grep -E "Using.*as elements database." stdout], 0, [ignore], [ignore])
    3433AT_CHECK([fgrep "Element list loaded successfully." stdout], 0, [ignore], [ignore])
     
    44432       0.      0.
    4544]])
    46 AT_CHECK([../../molecuilder test.conf -g bondlength.db], 0, [stdout], [stderr])
     45AT_CHECK([../../molecuilder -i test.conf -g bondlength.db], 0, [stdout], [stderr])
    4746AT_CHECK([grep -E "Using.*as bond length table." stdout], 0, [ignore], [ignore])
    4847AT_CLEANUP
     
    5150AT_SETUP([Standard Options - fast trajectories])
    5251AT_KEYWORDS([options])
    53 AT_CHECK([../../molecuilder test.conf -n 1], 0, [stdout], [stderr])
     52AT_CHECK([../../molecuilder -i test.conf -n 1], 0, [stdout], [stderr])
    5453AT_CHECK([fgrep "I won't parse trajectories" stdout], 0, [ignore], [ignore])
    5554AT_CLEANUP
     
    5857AT_SETUP([Standard Options - molecule default name])
    5958AT_KEYWORDS([options])
    60 AT_CHECK([../../molecuilder test.conf -X test], 0, [stdout], [stderr])
     59AT_CHECK([../../molecuilder -i test.conf -X test], 0, [stdout], [stderr])
    6160AT_CHECK([fgrep "Default name of new molecules set to test." stdout], 0, [ignore], [ignore])
    6261AT_CLEANUP
  • tests/regression/testsuite-tesselation.at

    r06f4ef6 rb6da28  
    44AT_KEYWORDS([Tesselation])
    55AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/pre/* .], 0)
    6 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -N 0 --sphere-radius 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
     6AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -N 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
    77AT_CHECK([file=NonConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/post/$file], 0, [ignore], [ignore])
    8 AT_CHECK([file=NonConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/post/$file], 0, [ignore], [ignore])
     8#AT_CHECK([file=NonConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/post/$file], 0, [ignore], [ignore])
    99AT_CLEANUP
    1010
     
    1212AT_SETUP([Tesselation - Convex Envelope])
    1313AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/pre/* .], 0)
    14 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -o 0 --convex-file ConvexEnvelope --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
     14AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 --convex-envelope --convex-file ConvexEnvelope --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
    1515AT_CHECK([file=ConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/post/$file], 0, [ignore], [ignore])
    16 AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/post/$file], 0, [ignore], [ignore])
     16#AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/post/$file], 0, [ignore], [ignore])
    1717AT_CHECK([fgrep "tesselated volume area is 16.4016 angstrom^3" stdout], 0, [ignore], [ignore])
    1818AT_CHECK([diff ConvexEnvelope.dat NonConvexEnvelope.dat], 0, [ignore], [ignore])
     
    2222AT_SETUP([Tesselation - Big non-Convex Envelope])
    2323AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/pre/* .], 0)
    24 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -N 0 --sphere-radius 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
     24AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -N 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])
    2525AT_CHECK([file=NonConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/post/$file], 0, [ignore], [ignore])
    26 AT_CHECK([file=NonConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/post/$file], 0, [ignore], [ignore])
     26#AT_CHECK([file=NonConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/post/$file], 0, [ignore], [ignore])
    2727AT_CLEANUP
    2828
     
    3030#AT_SETUP([Tesselation - big convex Envelope])
    3131#AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/4/pre/* .], 0)
    32 #AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -o ConvexEnvelope NonConvexEnvelope], 0, [stdout], [stderr])
     32#AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 --convex-envelope ConvexEnvelope NonConvexEnvelope], 0, [stdout], [stderr])
    3333#AT_CHECK([file=ConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/4/post/$file], 0, [ignore], [ignore])
    3434#AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/4/post/$file], 0, [ignore], [ignore])
Note: See TracChangeset for help on using the changeset viewer.