Changes in / [491876:c695c9]
- Files:
-
- 27 added
- 74 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Makefile.am
r491876 rc695c9 1 1 ATOMSOURCE = atom.cpp atom_atominfo.cpp atom_bondedparticle.cpp atom_bondedparticleinfo.cpp atom_graphnode.cpp atom_graphnodeinfo.cpp atom_particleinfo.cpp atom_trajectoryparticle.cpp atom_trajectoryparticleinfo.cpp 2 2 ATOMHEADER = atom.hpp atom_atominfo.hpp atom_bondedparticle.hpp atom_bondedparticleinfo.hpp atom_graphnode.hpp atom_graphnodeinfo.hpp atom_particleinfo.hpp atom_trajectoryparticle.hpp atom_trajectoryparticleinfo.hpp 3 4 LINALGSOURCE = gslmatrix.cpp gslvector.cpp linearsystemofequations.cpp 5 LINALGHEADER = gslmatrix.hpp gslvector.hpp linearsystemofequations.hpp 3 6 4 7 ANALYSISSOURCE = analysis_bonds.cpp analysis_correlation.cpp 5 8 ANALYSISHEADER = analysis_bonds.hpp analysis_correlation.hpp 6 9 7 SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp info.cpp leastsquaremin.cpp linkedcell.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp vector.cpp verbose.cpp8 HEADER = ${ANALYSISHEADER} ${ATOMHEADER} bond.hpp bondgraph.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp errorlogger.hpp graph.hpp helpers.hpp info.hpp leastsquaremin.hpp linkedcell.hpp lists.hpp log.hpp logger.hpp memoryallocator.hpp memoryusageobserver.hpp molecule.hpp molecule_template.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp vector.hpp verbose.hpp10 SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp info.cpp leastsquaremin.cpp linkedcell.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp triangleintersectionlist.cpp vector.cpp verbose.cpp World.cpp 11 HEADER = ${ANALYSISHEADER} ${ATOMHEADER} bond.hpp bondgraph.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp errorlogger.hpp graph.hpp helpers.hpp info.hpp leastsquaremin.hpp linkedcell.hpp lists.hpp log.hpp logger.hpp memoryallocator.hpp memoryusageobserver.hpp molecule.hpp molecule_template.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp triangleintersectionlist.cpp vector.hpp verbose.hpp World.hpp 9 12 10 13 BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB) 11 14 INCLUDES = -I$(top_srcdir)/src/unittests 12 15 13 noinst_LIBRARIES = libmolecuilder.a 16 noinst_LIBRARIES = libmolecuilder.a libgslwrapper.a 14 17 bin_PROGRAMS = molecuilder joiner analyzer 15 18 molecuilderdir = ${bindir} 16 19 libmolecuilder_a_SOURCES = ${SOURCE} ${HEADER} 20 libgslwrapper_a_SOURCES = ${LINALGSOURCE} ${LINALGHEADER} 17 21 molecuilder_DATA = elements.db valence.db orbitals.db Hbonddistance.db Hbondangle.db 18 22 molecuilder_LDFLAGS = $(BOOST_LIB) 19 23 molecuilder_SOURCES = builder.cpp 20 molecuilder_LDADD = libmolecuilder.a 24 molecuilder_LDADD = libmolecuilder.a libgslwrapper.a 21 25 joiner_SOURCES = joiner.cpp datacreator.cpp parser.cpp datacreator.hpp helpers.hpp parser.hpp periodentafel.hpp 22 26 joiner_LDADD = libmolecuilder.a … … 25 29 26 30 #EXTRA_DIST = ${molecuilder_DATA} 31 32 FORCE: 33 $(srcdir)/.git-version: FORCE 34 @if (test -d $(top_srcdir)/../.git && cd $(srcdir) && git describe HEAD) > .git-version-t 2>/dev/null \ 35 && ! diff .git-version-t $(srcdir)/.git-version >/dev/null 2>&1; then \ 36 mv -f .git-version-t $(srcdir)/.git-version; \ 37 else \ 38 rm -f .git-version-t; \ 39 fi 40 41 EXTRA_DIST = $(srcdir)/.git-version 42 43 $(srcdir)/version.c: $(srcdir)/.git-version 44 echo "const char *ESPACKVersion = \"$(PACKAGE_NAME) -- git version: "`cat $(srcdir)/.git-version`"\";" > $@ 45 46 molecuilder_SOURCES += $(srcdir)/version.c -
src/analysis_bonds.cpp
r491876 rc695c9 9 9 #include "atom.hpp" 10 10 #include "bond.hpp" 11 #include "element.hpp" 12 #include "info.hpp" 11 13 #include "log.hpp" 12 14 #include "molecule.hpp" … … 37 39 } 38 40 if (((int)Mean % 2) != 0) 39 eLog() << Verbose(1) << "Something is wrong with the bond structure, the number of bonds is not even!" << endl;41 DoeLog(1) && (eLog()<< Verbose(1) << "Something is wrong with the bond structure, the number of bonds is not even!" << endl); 40 42 Mean /= (double)AtomCount; 41 43 }; … … 79 81 } 80 82 }; 83 84 /** Calculate the angle between \a *first and \a *origin and \a *second and \a *origin. 85 * \param *first first Vector 86 * \param *origin origin of angle taking 87 * \param *second second Vector 88 * \return angle between \a *first and \a *second, both relative to origin at \a *origin. 89 */ 90 double CalculateAngle(Vector *first, Vector *central, Vector *second) 91 { 92 Vector OHBond; 93 Vector OOBond; 94 95 OHBond.CopyVector(first); 96 OHBond.SubtractVector(central); 97 OOBond.CopyVector(second); 98 OOBond.SubtractVector(central); 99 const double angle = OHBond.Angle(&OOBond); 100 return angle; 101 }; 102 103 /** Checks whether the angle between \a *Oxygen and \a *Hydrogen and \a *Oxygen and \a *OtherOxygen is less than 30 degrees. 104 * Note that distance criterion is not checked. 105 * \param *Oxygen first oxygen atom, bonded to \a *Hydrogen 106 * \param *Hydrogen hydrogen bonded to \a *Oxygen 107 * \param *OtherOxygen other oxygen atom 108 * \return true - angle criteria fulfilled, false - criteria not fulfilled, angle greater than 30 degrees. 109 */ 110 bool CheckHydrogenBridgeBondAngle(atom *Oxygen, atom *Hydrogen, atom *OtherOxygen) 111 { 112 Info FunctionInfo(__func__); 113 114 // check angle 115 if (CalculateAngle(&Hydrogen->x, &Oxygen->x, &OtherOxygen->x) < M_PI*(30./180.)) { 116 return true; 117 } else { 118 return false; 119 } 120 }; 121 122 /** Counts the number of hydrogen bridge bonds. 123 * With \a *InterfaceElement an extra element can be specified that identifies some boundary. 124 * Then, counting is for the h-bridges that connect to interface only. 125 * \param *molecules molecules to count bonds 126 * \param *InterfaceElement or NULL 127 */ 128 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, element * InterfaceElement = NULL) 129 { 130 atom *Walker = NULL; 131 atom *Runner = NULL; 132 int count = 0; 133 int OtherHydrogens = 0; 134 double Otherangle = 0.; 135 bool InterfaceFlag = false; 136 bool OtherHydrogenFlag = true; 137 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) { 138 Walker = (*MolWalker)->start; 139 while (Walker->next != (*MolWalker)->end) { 140 Walker = Walker->next; 141 for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != molecules->ListOfMolecules.end(); MolRunner++) { 142 Runner = (*MolRunner)->start; 143 while (Runner->next != (*MolRunner)->end) { 144 Runner = Runner->next; 145 if ((Walker->type->Z == 8) && (Runner->type->Z == 8)) { 146 // check distance 147 const double distance = Runner->x.DistanceSquared(&Walker->x); 148 if ((distance > MYEPSILON) && (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE)) { // distance >0 means different atoms 149 // on other atom(Runner) we check for bond to interface element and 150 // check that O-O line is not in between the shanks of the two connected hydrogens (Otherangle > 104.5) 151 OtherHydrogenFlag = true; 152 Otherangle = 0.; 153 OtherHydrogens = 0; 154 InterfaceFlag = (InterfaceElement == NULL); 155 for (BondList::const_iterator BondRunner = Runner->ListOfBonds.begin(); BondRunner != Runner->ListOfBonds.end(); BondRunner++) { 156 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Runner); 157 // if hydrogen, check angle to be greater(!) than 30 degrees 158 if (OtherAtom->type->Z == 1) { 159 const double angle = CalculateAngle(&OtherAtom->x, &Runner->x, &Walker->x); 160 OtherHydrogenFlag = OtherHydrogenFlag && (angle > M_PI*(30./180.) + MYEPSILON); 161 Otherangle += angle; 162 OtherHydrogens++; 163 } 164 InterfaceFlag = InterfaceFlag || (OtherAtom->type == InterfaceElement); 165 } 166 DoLog(1) && (Log() << Verbose(1) << "Otherangle is " << Otherangle << " for " << OtherHydrogens << " hydrogens." << endl); 167 switch (OtherHydrogens) { 168 case 0: 169 case 1: 170 break; 171 case 2: 172 OtherHydrogenFlag = OtherHydrogenFlag && (Otherangle > M_PI*(104.5/180.) + MYEPSILON); 173 break; 174 default: // 3 or more hydrogens ... 175 OtherHydrogenFlag = false; 176 break; 177 } 178 if (InterfaceFlag && OtherHydrogenFlag) { 179 // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule 180 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) { 181 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker); 182 if (OtherAtom->type->Z == 1) { 183 // check angle 184 if (CheckHydrogenBridgeBondAngle(Walker, OtherAtom, Runner)) { 185 DoLog(1) && (Log() << Verbose(1) << Walker->Name << ", " << OtherAtom->Name << " and " << Runner->Name << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle(&OtherAtom->x, &Walker->x, &Runner->x)*(180./M_PI) << "." << endl); 186 count++; 187 break; 188 } 189 } 190 } 191 } 192 } 193 } 194 } 195 } 196 } 197 } 198 return count; 199 } 200 201 /** Counts the number of bonds between two given elements. 202 * \param *molecules list of molecules with all atoms 203 * \param *first pointer to first element 204 * \param *second pointer to second element 205 * \return number of found bonds (\a *first-\a *second) 206 */ 207 int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second) 208 { 209 atom *Walker = NULL; 210 int count = 0; 211 212 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) { 213 Walker = (*MolWalker)->start; 214 while (Walker->next != (*MolWalker)->end) { 215 Walker = Walker->next; 216 if ((Walker->type == first) || (Walker->type == second)) { // first element matches 217 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) { 218 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker); 219 if (((OtherAtom->type == first) || (OtherAtom->type == second)) && (Walker->nr < OtherAtom->nr)) { 220 count++; 221 DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl); 222 } 223 } 224 } 225 } 226 } 227 return count; 228 }; 229 230 /** Counts the number of bonds between three given elements. 231 * Note that we do not look for arbitrary sequence of given bonds, but \a *second will be the central atom and we check 232 * whether it has bonds to both \a *first and \a *third. 233 * \param *molecules list of molecules with all atoms 234 * \param *first pointer to first element 235 * \param *second pointer to second element 236 * \param *third pointer to third element 237 * \return number of found bonds (\a *first-\a *second-\a *third, \a *third-\a *second-\a *first, respectively) 238 */ 239 int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third) 240 { 241 int count = 0; 242 bool MatchFlag[2]; 243 bool result = false; 244 atom *Walker = NULL; 245 const element * ElementArray[2]; 246 ElementArray[0] = first; 247 ElementArray[1] = third; 248 249 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) { 250 Walker = (*MolWalker)->start; 251 while (Walker->next != (*MolWalker)->end) { 252 Walker = Walker->next; 253 if (Walker->type == second) { // first element matches 254 for (int i=0;i<2;i++) 255 MatchFlag[i] = false; 256 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) { 257 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker); 258 for (int i=0;i<2;i++) 259 if ((!MatchFlag[i]) && (OtherAtom->type == ElementArray[i])) { 260 MatchFlag[i] = true; 261 break; // each bonding atom can match at most one element we are looking for 262 } 263 } 264 result = true; 265 for (int i=0;i<2;i++) // gather results 266 result = result && MatchFlag[i]; 267 if (result) { // check results 268 count++; 269 DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << "-" << third->name << " bond found at " << *Walker << "." << endl); 270 } 271 } 272 } 273 } 274 return count; 275 }; -
src/analysis_bonds.hpp
r491876 rc695c9 18 18 #endif 19 19 20 /*********************************************** defines ***********************************/ 21 22 #define HBRIDGEDISTANCE 3.5 //!< HBridge distance from PCCP Vol 10. 4802-4813 20 23 21 24 /****************************************** forward declarations *****************************/ 22 25 23 26 class element; 27 class MoleculeListClass; 24 28 class molecule; 25 29 … … 29 33 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, element *type1, element *type2, double &Min, double &Mean, double &Max); 30 34 35 int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, element * InterfaceElement); 36 int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second); 37 int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third); 38 31 39 #endif /* ANALYSIS_BONDS_HPP_ */ -
src/analysis_correlation.cpp
r491876 rc695c9 10 10 #include "analysis_correlation.hpp" 11 11 #include "element.hpp" 12 #include "info.hpp" 12 13 #include "log.hpp" 13 14 #include "molecule.hpp" 14 15 #include "tesselation.hpp" 15 16 #include "tesselationhelpers.hpp" 17 #include "triangleintersectionlist.hpp" 16 18 #include "vector.hpp" 17 19 #include "verbose.hpp" 20 #include "World.hpp" 18 21 19 22 … … 28 31 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2 ) 29 32 { 33 Info FunctionInfo(__func__); 30 34 PairCorrelationMap *outmap = NULL; 31 35 double distance = 0.; 32 36 33 37 if (molecules->ListOfMolecules.empty()) { 34 eLog() << Verbose(1) <<"No molecule given." << endl;38 DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl); 35 39 return outmap; 36 40 } … … 38 42 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 39 43 if ((*MolWalker)->ActiveFlag) { 40 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;41 atom *Walker = (*MolWalker)->start; 42 while (Walker->next != (*MolWalker)->end) { 43 Walker = Walker->next; 44 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;44 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 45 atom *Walker = (*MolWalker)->start; 46 while (Walker->next != (*MolWalker)->end) { 47 Walker = Walker->next; 48 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl); 45 49 if ((type1 == NULL) || (Walker->type == type1)) { 46 50 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++) 47 51 if ((*MolOtherWalker)->ActiveFlag) { 48 Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl;52 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl); 49 53 atom *OtherWalker = (*MolOtherWalker)->start; 50 54 while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker 51 55 OtherWalker = OtherWalker->next; 52 Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl;56 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl); 53 57 if (Walker->nr < OtherWalker->nr) 54 58 if ((type2 == NULL) || (OtherWalker->type == type2)) { 55 distance = Walker->node->PeriodicDistance(OtherWalker->node, (*MolWalker)->cell_size);59 distance = Walker->node->PeriodicDistance(OtherWalker->node, World::get()->cell_size); 56 60 //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl; 57 61 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) ); … … 77 81 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2, const int ranges[NDIM] ) 78 82 { 83 Info FunctionInfo(__func__); 79 84 PairCorrelationMap *outmap = NULL; 80 85 double distance = 0.; … … 87 92 88 93 if (molecules->ListOfMolecules.empty()) { 89 eLog() << Verbose(1) <<"No molecule given." << endl;94 DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl); 90 95 return outmap; 91 96 } … … 93 98 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 94 99 if ((*MolWalker)->ActiveFlag) { 95 double * FullMatrix = ReturnFullMatrixforSymmetric( (*MolWalker)->cell_size);100 double * FullMatrix = ReturnFullMatrixforSymmetric(World::get()->cell_size); 96 101 double * FullInverseMatrix = InverseMatrix(FullMatrix); 97 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;98 atom *Walker = (*MolWalker)->start; 99 while (Walker->next != (*MolWalker)->end) { 100 Walker = Walker->next; 101 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;102 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 103 atom *Walker = (*MolWalker)->start; 104 while (Walker->next != (*MolWalker)->end) { 105 Walker = Walker->next; 106 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl); 102 107 if ((type1 == NULL) || (Walker->type == type1)) { 103 108 periodicX.CopyVector(Walker->node); … … 112 117 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++) 113 118 if ((*MolOtherWalker)->ActiveFlag) { 114 Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl;119 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl); 115 120 atom *OtherWalker = (*MolOtherWalker)->start; 116 121 while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker 117 122 OtherWalker = OtherWalker->next; 118 Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl;123 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl); 119 124 if (Walker->nr < OtherWalker->nr) 120 125 if ((type2 == NULL) || (OtherWalker->type == type2)) { … … 154 159 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point ) 155 160 { 161 Info FunctionInfo(__func__); 156 162 CorrelationToPointMap *outmap = NULL; 157 163 double distance = 0.; 158 164 159 165 if (molecules->ListOfMolecules.empty()) { 160 Log() << Verbose(1) <<"No molecule given." << endl;166 DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl); 161 167 return outmap; 162 168 } … … 164 170 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 165 171 if ((*MolWalker)->ActiveFlag) { 166 Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;167 atom *Walker = (*MolWalker)->start; 168 while (Walker->next != (*MolWalker)->end) { 169 Walker = Walker->next; 170 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;172 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 173 atom *Walker = (*MolWalker)->start; 174 while (Walker->next != (*MolWalker)->end) { 175 Walker = Walker->next; 176 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl); 171 177 if ((type == NULL) || (Walker->type == type)) { 172 distance = Walker->node->PeriodicDistance(point, (*MolWalker)->cell_size);173 Log() << Verbose(4) << "Current distance is " << distance << "." << endl;178 distance = Walker->node->PeriodicDistance(point, World::get()->cell_size); 179 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 174 180 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) ); 175 181 } … … 190 196 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] ) 191 197 { 198 Info FunctionInfo(__func__); 192 199 CorrelationToPointMap *outmap = NULL; 193 200 double distance = 0.; … … 197 204 198 205 if (molecules->ListOfMolecules.empty()) { 199 Log() << Verbose(1) <<"No molecule given." << endl;206 DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl); 200 207 return outmap; 201 208 } … … 203 210 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 204 211 if ((*MolWalker)->ActiveFlag) { 205 double * FullMatrix = ReturnFullMatrixforSymmetric( (*MolWalker)->cell_size);212 double * FullMatrix = ReturnFullMatrixforSymmetric(World::get()->cell_size); 206 213 double * FullInverseMatrix = InverseMatrix(FullMatrix); 207 Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;208 atom *Walker = (*MolWalker)->start; 209 while (Walker->next != (*MolWalker)->end) { 210 Walker = Walker->next; 211 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;214 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 215 atom *Walker = (*MolWalker)->start; 216 while (Walker->next != (*MolWalker)->end) { 217 Walker = Walker->next; 218 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl); 212 219 if ((type == NULL) || (Walker->type == type)) { 213 220 periodicX.CopyVector(Walker->node); … … 221 228 checkX.MatrixMultiplication(FullMatrix); 222 229 distance = checkX.Distance(point); 223 Log() << Verbose(4) << "Current distance is " << distance << "." << endl;230 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 224 231 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) ); 225 232 } … … 243 250 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC ) 244 251 { 252 Info FunctionInfo(__func__); 245 253 CorrelationToSurfaceMap *outmap = NULL; 246 254 double distance = 0; … … 249 257 250 258 if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) { 251 Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl;259 DoeLog(1) && (eLog()<< Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl); 252 260 return outmap; 253 261 } … … 255 263 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 256 264 if ((*MolWalker)->ActiveFlag) { 257 Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;258 atom *Walker = (*MolWalker)->start; 259 while (Walker->next != (*MolWalker)->end) { 260 Walker = Walker->next; 261 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;265 DoLog(1) && (Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl); 266 atom *Walker = (*MolWalker)->start; 267 while (Walker->next != (*MolWalker)->end) { 268 Walker = Walker->next; 269 //Log() << Verbose(1) << "Current atom is " << *Walker << "." << endl; 262 270 if ((type == NULL) || (Walker->type == type)) { 263 triangle = Surface->FindClosestTriangleToPoint(Walker->node, LC ); 264 if (triangle != NULL) { 265 distance = DistanceToTrianglePlane(Walker->node, triangle); 266 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) ); 267 } 268 } 269 } 270 } 271 TriangleIntersectionList Intersections(Walker->node,Surface,LC); 272 distance = Intersections.GetSmallestDistance(); 273 triangle = Intersections.GetClosestTriangle(); 274 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) ); 275 } 276 } 277 } else 278 DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl); 279 271 280 272 281 return outmap; … … 288 297 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ) 289 298 { 299 Info FunctionInfo(__func__); 290 300 CorrelationToSurfaceMap *outmap = NULL; 291 301 double distance = 0; … … 297 307 298 308 if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) { 299 Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl;309 DoLog(1) && (Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl); 300 310 return outmap; 301 311 } 302 312 outmap = new CorrelationToSurfaceMap; 303 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 304 if ((*MolWalker)->ActiveFlag) { 305 double * FullMatrix = ReturnFullMatrixforSymmetric((*MolWalker)->cell_size); 313 double ShortestDistance = 0.; 314 BoundaryTriangleSet *ShortestTriangle = NULL; 315 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 316 if ((*MolWalker)->ActiveFlag) { 317 double * FullMatrix = ReturnFullMatrixforSymmetric(World::get()->cell_size); 306 318 double * FullInverseMatrix = InverseMatrix(FullMatrix); 307 Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;308 atom *Walker = (*MolWalker)->start; 309 while (Walker->next != (*MolWalker)->end) { 310 Walker = Walker->next; 311 Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;319 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 320 atom *Walker = (*MolWalker)->start; 321 while (Walker->next != (*MolWalker)->end) { 322 Walker = Walker->next; 323 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl); 312 324 if ((type == NULL) || (Walker->type == type)) { 313 325 periodicX.CopyVector(Walker->node); 314 326 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 315 327 // go through every range in xyz and get distance 328 ShortestDistance = -1.; 316 329 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 317 330 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) … … 320 333 checkX.AddVector(&periodicX); 321 334 checkX.MatrixMultiplication(FullMatrix); 322 triangle = Surface->FindClosestTriangleToPoint(&checkX, LC ); 323 if (triangle != NULL) { 324 distance = DistanceToTrianglePlane(&checkX, triangle); 325 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) ); 335 TriangleIntersectionList Intersections(&checkX,Surface,LC); 336 distance = Intersections.GetSmallestDistance(); 337 triangle = Intersections.GetClosestTriangle(); 338 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) { 339 ShortestDistance = distance; 340 ShortestTriangle = triangle; 326 341 } 327 } 342 } 343 // insert 344 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) ); 345 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl; 328 346 } 329 347 } … … 335 353 }; 336 354 337 /** Returns the startof the bin for a given value.355 /** Returns the index of the bin for a given value. 338 356 * \param value value whose bin to look for 339 357 * \param BinWidth width of bin 340 358 * \param BinStart first bin 341 359 */ 342 double GetBin ( const double value, const double BinWidth, const double BinStart ) 343 { 344 double bin =(double) (floor((value - BinStart)/BinWidth)); 345 return (bin*BinWidth+BinStart); 360 int GetBin ( const double value, const double BinWidth, const double BinStart ) 361 { 362 Info FunctionInfo(__func__); 363 int bin =(int) (floor((value - BinStart)/BinWidth)); 364 return (bin); 346 365 }; 347 366 … … 353 372 void OutputCorrelation( ofstream * const file, const BinPairMap * const map ) 354 373 { 355 *file << "# BinStart\tCount" << endl; 374 Info FunctionInfo(__func__); 375 *file << "BinStart\tCount" << endl; 356 376 for (BinPairMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 357 *file << runner->first << "\t" << runner->second << endl;377 *file << setprecision(8) << runner->first << "\t" << runner->second << endl; 358 378 } 359 379 }; … … 365 385 void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map ) 366 386 { 367 *file << "# BinStart\tAtom1\tAtom2" << endl; 387 Info FunctionInfo(__func__); 388 *file << "BinStart\tAtom1\tAtom2" << endl; 368 389 for (PairCorrelationMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 369 *file << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;390 *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl; 370 391 } 371 392 }; … … 377 398 void OutputCorrelationToPoint( ofstream * const file, const CorrelationToPointMap * const map ) 378 399 { 379 *file << "# BinStart\tAtom::x[i]-point.x[i]" << endl; 400 Info FunctionInfo(__func__); 401 *file << "BinStart\tAtom::x[i]-point.x[i]" << endl; 380 402 for (CorrelationToPointMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 381 403 *file << runner->first; 382 404 for (int i=0;i<NDIM;i++) 383 *file << "\t" << (runner->second.first->node->x[i] - runner->second.second->x[i]);405 *file << "\t" << setprecision(8) << (runner->second.first->node->x[i] - runner->second.second->x[i]); 384 406 *file << endl; 385 407 } … … 392 414 void OutputCorrelationToSurface( ofstream * const file, const CorrelationToSurfaceMap * const map ) 393 415 { 394 *file << "# BinStart\tTriangle" << endl; 395 for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 396 *file << runner->first << "\t" << *(runner->second.second) << endl; 397 } 398 }; 399 416 Info FunctionInfo(__func__); 417 *file << "BinStart\tTriangle" << endl; 418 if (!map->empty()) 419 for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 420 *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl; 421 } 422 }; 423 -
src/analysis_correlation.hpp
r491876 rc695c9 51 51 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] ); 52 52 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ); 53 doubleGetBin ( const double value, const double BinWidth, const double BinStart );53 int GetBin ( const double value, const double BinWidth, const double BinStart ); 54 54 void OutputCorrelation( ofstream * const file, const BinPairMap * const map ); 55 void OutputPairCorrelation( ofstream * const file, const BinPairMap * const map );56 void OutputCorrelationToPoint( ofstream * const file, const BinPairMap * const map );57 void OutputCorrelationToSurface( ofstream * const file, const BinPairMap * const map );55 void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map ); 56 void OutputCorrelationToPoint( ofstream * const file, const CorrelationToPointMap * const map ); 57 void OutputCorrelationToSurface( ofstream * const file, const CorrelationToSurfaceMap * const map ); 58 58 59 59 … … 71 71 72 72 if (map == NULL) { 73 eLog() << Verbose(0) << "Nothing to min/max, map is NULL!" << endl;73 DoeLog(0) && (eLog()<< Verbose(0) << "Nothing to min/max, map is NULL!" << endl); 74 74 performCriticalExit(); 75 75 return; … … 90 90 /** Puts given correlation data into bins of given size (histogramming). 91 91 * Note that BinStart and BinEnd are desired to fill the complete range, even where Bins are zero. If this is 92 * not desired, give equal BinStart and BinEnd and the map will contain only Bins where the count is one or greater. 92 * not desired, give equal BinStart and BinEnd and the map will contain only Bins where the count is one or greater. If a 93 * certain start value is desired, give BinStart and a BinEnd that is smaller than BinStart, then only BinEnd will be 94 * calculated automatically, i.e. BinStart = 0. and BinEnd = -1. . 93 95 * Also note that the range is given inclusive, i.e. [ BinStart, BinEnd ]. 94 96 * \param *map map of doubles to count … … 101 103 { 102 104 BinPairMap *outmap = new BinPairMap; 103 double bin = 0.;105 int bin = 0; 104 106 double start = 0.; 105 107 double end = 0.; … … 107 109 108 110 if (map == NULL) { 109 eLog() << Verbose(0) << "Nothing to bin, is NULL!" << endl;111 DoeLog(0) && (eLog()<< Verbose(0) << "Nothing to bin, is NULL!" << endl); 110 112 performCriticalExit(); 111 113 return outmap; … … 114 116 if (BinStart == BinEnd) { // if same, find range ourselves 115 117 GetMinMax( map, start, end); 116 } else { // if not, initialise range to zero 118 } else if (BinEnd < BinStart) { // if BinEnd smaller, just look for new max 119 GetMinMax( map, start, end); 120 start = BinStart; 121 } else { // else take both values 117 122 start = BinStart; 118 123 end = BinEnd; 119 for (double runner = start; runner <= end; runner += BinWidth)120 outmap->insert( pair<double, int> (runner, 0) );121 124 } 125 for (int runner = 0; runner <= ceil((end-start)/BinWidth); runner++) 126 outmap->insert( pair<double, int> ((double)runner*BinWidth+start, 0) ); 122 127 123 128 for (typename T::iterator runner = map->begin(); runner != map->end(); ++runner) { 124 129 bin = GetBin (runner->first, BinWidth, start); 125 BinPairMapInserter = outmap->insert ( pair<double, int> ( bin, 1) );130 BinPairMapInserter = outmap->insert ( pair<double, int> ((double)bin*BinWidth+start, 1) ); 126 131 if (!BinPairMapInserter.second) { // bin already present, increase 127 132 BinPairMapInserter.first->second += 1; -
src/analyzer.cpp
r491876 rc695c9 7 7 8 8 //============================ INCLUDES =========================== 9 10 #include <cstring> 9 11 10 12 #include "datacreator.hpp" … … 61 63 int counter = 0; 62 64 63 Log() << Verbose(0) << "ANOVA Analyzer" << endl;64 Log() << Verbose(0) << "==============" << endl;65 DoLog(0) && (Log() << Verbose(0) << "ANOVA Analyzer" << endl); 66 DoLog(0) && (Log() << Verbose(0) << "==============" << endl); 65 67 66 68 // Get the command line options 67 69 if (argc < 4) { 68 Log() << Verbose(0) << "Usage: " << argv[0] << " <inputdir> <prefix> <outputdir> [elementsdb]" << endl;69 Log() << Verbose(0) << "<inputdir>\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl;70 Log() << Verbose(0) << "<prefix>\tprefix of energy and forces file." << endl;71 Log() << Verbose(0) << "<outputdir>\tcreated plotfiles and datafiles are placed into this directory " << endl;72 Log() << Verbose(0) << "[elementsdb]\tpath to elements database, needed for shieldings." << endl;70 DoLog(0) && (Log() << Verbose(0) << "Usage: " << argv[0] << " <inputdir> <prefix> <outputdir> [elementsdb]" << endl); 71 DoLog(0) && (Log() << Verbose(0) << "<inputdir>\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl); 72 DoLog(0) && (Log() << Verbose(0) << "<prefix>\tprefix of energy and forces file." << endl); 73 DoLog(0) && (Log() << Verbose(0) << "<outputdir>\tcreated plotfiles and datafiles are placed into this directory " << endl); 74 DoLog(0) && (Log() << Verbose(0) << "[elementsdb]\tpath to elements database, needed for shieldings." << endl); 73 75 return 1; 74 76 } else { … … 79 81 80 82 if (argc > 4) { 81 Log() << Verbose(0) << "Loading periodentafel." << endl;83 DoLog(0) && (Log() << Verbose(0) << "Loading periodentafel." << endl); 82 84 periode = Malloc<periodentafel>(1, "main - periode"); 83 85 periode->LoadPeriodentafel(argv[4]); … … 94 96 if (!Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0)) { 95 97 NoHCorrection = true; 96 eLog() << Verbose(2) << "No HCorrection file found, skipping these." << endl;98 DoeLog(2) && (eLog()<< Verbose(2) << "No HCorrection file found, skipping these." << endl); 97 99 } 98 100 … … 100 102 if (!Hessian.ParseFragmentMatrix(argv[1], dir, HessianSuffix,0,0)) { 101 103 NoHessian = true; 102 eLog() << Verbose(2) << "No Hessian file found, skipping these." << endl;104 DoeLog(2) && (eLog()<< Verbose(2) << "No Hessian file found, skipping these." << endl); 103 105 } 104 106 if (!Time.ParseFragmentMatrix(argv[1], dir, TimeSuffix, 10,1)) { 105 107 NoTime = true; 106 eLog() << Verbose(2) << "No speed file found, skipping these." << endl;108 DoeLog(2) && (eLog()<< Verbose(2) << "No speed file found, skipping these." << endl); 107 109 } 108 110 if (periode != NULL) { // also look for PAS values … … 246 248 // +++++++++++++++ ANALYZING ++++++++++++++++++++++++++++++ 247 249 248 Log() << Verbose(0) << "Analyzing ..." << endl;250 DoLog(0) && (Log() << Verbose(0) << "Analyzing ..." << endl); 249 251 250 252 // ======================================= Creating the data files ============================================================== … … 557 559 delete(periode); 558 560 Free(&dir); 559 Log() << Verbose(0) << "done." << endl;561 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 560 562 return 0; 561 563 }; -
src/atom_bondedparticle.cpp
r491876 rc695c9 44 44 void BondedParticle::OutputBondOfAtom() const 45 45 { 46 Log() << Verbose(4) << "Atom " << Name << "/" << nr << " with " << ListOfBonds.size() << " bonds: " << endl;46 DoLog(4) && (Log() << Verbose(4) << "Atom " << Name << "/" << nr << " with " << ListOfBonds.size() << " bonds: " << endl); 47 47 int TotalDegree = 0; 48 48 for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); ++Runner) { 49 Log() << Verbose(4) << **Runner << endl;49 DoLog(4) && (Log() << Verbose(4) << **Runner << endl); 50 50 TotalDegree += (*Runner)->BondDegree; 51 51 } 52 Log() << Verbose(4) << " -- TotalDegree: " << TotalDegree << endl;52 DoLog(4) && (Log() << Verbose(4) << " -- TotalDegree: " << TotalDegree << endl); 53 53 }; 54 54 … … 56 56 * \param *AdjacencyFile output stream 57 57 */ 58 void BondedParticle::OutputAdjacency(ofstream * AdjacencyFile) const58 void BondedParticle::OutputAdjacency(ofstream * const AdjacencyFile) const 59 59 { 60 60 *AdjacencyFile << nr << "\t"; … … 62 62 *AdjacencyFile << (*Runner)->GetOtherAtom(this)->nr << "\t"; 63 63 *AdjacencyFile << endl; 64 }; 65 66 /** Output of atom::nr along each bond partner per line. 67 * Only bonds are printed where atom::nr is smaller than the one of the bond partner. 68 * \param *AdjacencyFile output stream 69 */ 70 void BondedParticle::OutputBonds(ofstream * const BondFile) const 71 { 72 for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner)) 73 if (nr < (*Runner)->GetOtherAtom(this)->nr) 74 *BondFile << nr << "\t" << (*Runner)->GetOtherAtom(this)->nr << "\n"; 64 75 }; 65 76 … … 75 86 status = true; 76 87 } else { 77 eLog() << Verbose(1) << *Binder << " does not contain " << *this << "." << endl;88 DoeLog(1) && (eLog()<< Verbose(1) << *Binder << " does not contain " << *this << "." << endl); 78 89 } 79 90 } else { 80 eLog() << Verbose(1) << "Binder is " << Binder << "." << endl;91 DoeLog(1) && (eLog()<< Verbose(1) << "Binder is " << Binder << "." << endl); 81 92 } 82 93 return status; … … 94 105 status = true; 95 106 } else { 96 eLog() << Verbose(1) << *Binder << " does not contain " << *this << "." << endl;107 DoeLog(1) && (eLog()<< Verbose(1) << *Binder << " does not contain " << *this << "." << endl); 97 108 } 98 109 } else { 99 eLog() << Verbose(1) << "Binder is " << Binder << "." << endl;110 DoeLog(1) && (eLog()<< Verbose(1) << "Binder is " << Binder << "." << endl); 100 111 } 101 112 return status; … … 139 150 //Log() << Verbose(2) << "Increased bond degree for bond " << *CandidateBond << "." << endl; 140 151 } else { 141 eLog() << Verbose(2) << "Could not find correct degree for atom " << *this << "." << endl;152 DoeLog(2) && (eLog()<< Verbose(2) << "Could not find correct degree for atom " << *this << "." << endl); 142 153 FalseBondDegree++; 143 154 } -
src/atom_bondedparticle.hpp
r491876 rc695c9 44 44 int CorrectBondDegree(); 45 45 void OutputBondOfAtom() const; 46 void OutputAdjacency(ofstream *AdjacencyFile) const; 46 void OutputAdjacency(ofstream * const AdjacencyFile) const; 47 void OutputBonds(ofstream * const BondFile) const; 47 48 void OutputOrder(ofstream *file) const; 48 49 -
src/atom_graphnode.cpp
r491876 rc695c9 27 27 void GraphNode::OutputGraphInfo() const 28 28 { 29 Log() << Verbose(2) << "Atom " << Name << " is " << ((SeparationVertex) ? "a" : "not a") << " separation vertex, components are ";29 DoLog(2) && (Log() << Verbose(2) << "Atom " << Name << " is " << ((SeparationVertex) ? "a" : "not a") << " separation vertex, components are "); 30 30 OutputComponentNumber(); 31 Log() << Verbose(3) << " with Lowpoint " << LowpointNr << " and Graph Nr. " << GraphNr << "." << endl;31 DoLog(3) && (Log() << Verbose(3) << " with Lowpoint " << LowpointNr << " and Graph Nr. " << GraphNr << "." << endl); 32 32 }; 33 33 … … 40 40 if (ComponentNr != NULL) { 41 41 for (int i=0; ComponentNr[i] != -1; i++) 42 Log() << Verbose(2) << ComponentNr[i] << " ";42 DoLog(2) && (Log() << Verbose(2) << ComponentNr[i] << " "); 43 43 } 44 44 }; -
src/atom_particleinfo.cpp
r491876 rc695c9 22 22 ostream & operator << (ostream &ost, const ParticleInfo &a) 23 23 { 24 ost << "[" << a.Name << "|" << &a << "]"; 24 if (a.Name == NULL) 25 ost << "[NULL]"; 26 else 27 ost << "[" << a.Name << "|" << &a << "]"; 25 28 return ost; 26 29 }; … … 28 31 ostream & ParticleInfo::operator << (ostream &ost) const 29 32 { 30 ost << "[" << Name << "|" << this << "]"; 33 if (Name == NULL) 34 ost << "[NULL]"; 35 else 36 ost << "[" << Name << "|" << this << "]"; 31 37 return ost; 32 38 }; -
src/atom_trajectoryparticle.cpp
r491876 rc695c9 198 198 // throw a dice to determine whether it gets hit by a heat bath particle 199 199 if (((((rand()/(double)RAND_MAX))*configuration->TempFrequency) < 1.)) { 200 Log() << Verbose(3) << "Particle " << *this << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> ";200 DoLog(3) && (Log() << Verbose(3) << "Particle " << *this << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> "); 201 201 // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis 202 202 for (int d=0; d<NDIM; d++) { 203 203 U[d] = gsl_ran_gaussian (r, sigma); 204 204 } 205 Log() << Verbose(2) << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << endl;205 DoLog(2) && (Log() << Verbose(2) << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << endl); 206 206 } 207 207 for (int d=0; d<NDIM; d++) -
src/bond.cpp
r491876 rc695c9 63 63 if(rightatom == Atom) 64 64 return leftatom; 65 eLog() << Verbose(1) << "Bond " << *this << " does not contain atom " << *Atom << "!" << endl;65 DoeLog(1) && (eLog()<< Verbose(1) << "Bond " << *this << " does not contain atom " << *Atom << "!" << endl); 66 66 return NULL; 67 67 }; … … 99 99 bool bond::MarkUsed(const enum Shading color) { 100 100 if (Used == black) { 101 eLog() << Verbose(1) << "Bond " << this << " was already marked black!." << endl;101 DoeLog(1) && (eLog()<< Verbose(1) << "Bond " << this << " was already marked black!." << endl); 102 102 return false; 103 103 } else { -
src/bondgraph.cpp
r491876 rc695c9 9 9 10 10 #include "atom.hpp" 11 #include "bond.hpp" 11 12 #include "bondgraph.hpp" 12 13 #include "element.hpp" 14 #include "info.hpp" 13 15 #include "log.hpp" 14 16 #include "molecule.hpp" … … 35 37 /** Parses the bond lengths in a given file and puts them int a matrix form. 36 38 * Allocates \a MatrixContainer for BondGraph::BondLengthMatrix, using MatrixContainer::ParseMatrix(), 37 * but only if parsing is successful l. Otherwise variable is left as NULL.39 * but only if parsing is successful. Otherwise variable is left as NULL. 38 40 * \param *out output stream for debugging 39 41 * \param filename file with bond lengths to parse … … 42 44 bool BondGraph::LoadBondLengthTable(const string &filename) 43 45 { 46 Info FunctionInfo(__func__); 44 47 bool status = true; 45 48 MatrixContainer *TempContainer = NULL; … … 47 50 // allocate MatrixContainer 48 51 if (BondLengthMatrix != NULL) { 49 Log() << Verbose(1) << "MatrixContainer for Bond length already present, removing." << endl;52 DoLog(1) && (Log() << Verbose(1) << "MatrixContainer for Bond length already present, removing." << endl); 50 53 delete(BondLengthMatrix); 51 54 } … … 53 56 54 57 // parse in matrix 55 status = TempContainer->ParseMatrix(filename.c_str(), 0, 1, 0); 58 if ((status = TempContainer->ParseMatrix(filename.c_str(), 0, 1, 0))) { 59 DoLog(1) && (Log() << Verbose(1) << "Parsing bond length matrix successful." << endl); 60 } else { 61 DoeLog(1) && (eLog()<< Verbose(1) << "Parsing bond length matrix failed." << endl); 62 } 56 63 57 64 // find greatest distance … … 80 87 bool BondGraph::ConstructBondGraph(molecule * const mol) 81 88 { 82 bool status = true; 89 Info FunctionInfo(__func__); 90 bool status = true; 83 91 84 92 if (mol->start->next == mol->end) // only construct if molecule is not empty … … 113 121 double BondGraph::SetMaxDistanceToMaxOfCovalentRadii(const molecule * const mol) 114 122 { 123 Info FunctionInfo(__func__); 115 124 max_distance = 0.; 116 125 … … 153 162 { 154 163 if (BondLengthMatrix == NULL) {// safety measure if no matrix has been parsed yet 155 eLog() << Verbose(2) << "BondLengthMatrixMinMaxDistance() called without having parsed the bond length matrix yet!" << endl;164 DoeLog(2) && (eLog()<< Verbose(2) << "BondLengthMatrixMinMaxDistance() called without having parsed the bond length matrix yet!" << endl); 156 165 CovalentMinMaxDistance(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 157 166 } else { … … 162 171 } 163 172 }; 164 -
src/bondgraph.hpp
r491876 rc695c9 19 19 20 20 #include <iostream> 21 22 /*********************************************** defines ***********************************/ 23 24 #define BONDTHRESHOLD 0.4 //!< CSD threshold in bond check which is the width of the interval whose center is the sum of the covalent radii 21 25 22 26 /****************************************** forward declarations *****************************/ -
src/boundary.cpp
-
Property mode
changed from
100755
to100644
r491876 rc695c9 17 17 #include "tesselation.hpp" 18 18 #include "tesselationhelpers.hpp" 19 #include "World.hpp" 19 20 20 21 #include<gsl/gsl_poly.h> 22 #include<time.h> 21 23 22 24 // ========================================== F U N C T I O N S ================================= … … 55 57 } else { 56 58 BoundaryPoints = BoundaryPtr; 57 Log() << Verbose(0) << "Using given boundary points set." << endl;59 DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl); 58 60 } 59 61 // determine biggest "diameter" of cluster for each axis … … 161 163 AngleReferenceNormalVector.x[(axis + 2) % NDIM] = 1.; 162 164 163 Log() << Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl;165 DoLog(1) && (Log() << Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl); 164 166 165 167 // 3b. construct set of all points, transformed into cylindrical system and with left and right neighbours … … 182 184 angle = 2. * M_PI - angle; 183 185 } 184 Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl;186 DoLog(1) && (Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl); 185 187 BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, Walker))); 186 188 if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity 187 Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl;188 Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl;189 Log() << Verbose(2) << "New vector: " << *Walker << endl;189 DoLog(2) && (Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl); 190 DoLog(2) && (Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl); 191 DoLog(2) && (Log() << Verbose(2) << "New vector: " << *Walker << endl); 190 192 const double ProjectedVectorNorm = ProjectedVector.NormSquared(); 191 193 if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) { 192 194 BoundaryTestPair.first->second.first = ProjectedVectorNorm; 193 195 BoundaryTestPair.first->second.second = Walker; 194 Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl;196 DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl); 195 197 } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) { 196 198 helper.CopyVector(&Walker->x); … … 201 203 if (helper.NormSquared() < oldhelperNorm) { 202 204 BoundaryTestPair.first->second.second = Walker; 203 Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl;205 DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl); 204 206 } else { 205 Log() << Verbose(2) << "Keeping present vector due to larger distance to molecule center " << oldhelperNorm << "." << endl;207 DoLog(2) && (Log() << Verbose(2) << "Keeping present vector due to larger distance to molecule center " << oldhelperNorm << "." << endl); 206 208 } 207 209 } else { 208 Log() << Verbose(2) << "Keeping present vector due to larger projected distance " << ProjectedVectorNorm << "." << endl;210 DoLog(2) && (Log() << Verbose(2) << "Keeping present vector due to larger projected distance " << ProjectedVectorNorm << "." << endl); 209 211 } 210 212 } … … 225 227 // 3c. throw out points whose distance is less than the mean of left and right neighbours 226 228 bool flag = false; 227 Log() << Verbose(1) << "Looking for candidates to kick out by convex condition ... " << endl;229 DoLog(1) && (Log() << Verbose(1) << "Looking for candidates to kick out by convex condition ... " << endl); 228 230 do { // do as long as we still throw one out per round 229 231 flag = false; … … 280 282 const double MinDistance = a * sin(beta) / (sin(delta)) * (((alpha < M_PI / 2.) || (gamma < M_PI / 2.)) ? 1. : -1.); 281 283 //Log() << Verbose(1) << " I calculated: a = " << a << ", h = " << h << ", beta(" << left->second.second->Name << "," << left->second.second->Name << "-" << right->second.second->Name << ") = " << beta << ", delta(" << left->second.second->Name << "," << runner->second.second->Name << ") = " << delta << ", Min = " << MinDistance << "." << endl; 282 Log() << Verbose(1) << "Checking CoG distance of runner " << *runner->second.second << " " << h << " against triangle's side length spanned by (" << *left->second.second << "," << *right->second.second << ") of " << MinDistance << "." << endl;284 DoLog(1) && (Log() << Verbose(1) << "Checking CoG distance of runner " << *runner->second.second << " " << h << " against triangle's side length spanned by (" << *left->second.second << "," << *right->second.second << ") of " << MinDistance << "." << endl); 283 285 if ((fabs(h / fabs(h) - MinDistance / fabs(MinDistance)) < MYEPSILON) && ((h - MinDistance)) < -MYEPSILON) { 284 286 // throw out point 285 Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl;287 DoLog(1) && (Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl); 286 288 BoundaryPoints[axis].erase(runner); 287 289 flag = true; … … 318 320 BoundaryPoints = GetBoundaryPoints(mol, TesselStruct); 319 321 } else { 320 Log() << Verbose(0) << "Using given boundary points set." << endl;322 DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl); 321 323 } 322 324 … … 324 326 for (int axis=0; axis < NDIM; axis++) 325 327 { 326 Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl;328 DoLog(1) && (Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl); 327 329 int i=0; 328 330 for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) { 329 331 if (runner != BoundaryPoints[axis].begin()) 330 Log() << Verbose(0) << ", " << i << ": " << *runner->second.second;332 DoLog(0) && (Log() << Verbose(0) << ", " << i << ": " << *runner->second.second); 331 333 else 332 Log() << Verbose(0) << i << ": " << *runner->second.second;334 DoLog(0) && (Log() << Verbose(0) << i << ": " << *runner->second.second); 333 335 i++; 334 336 } 335 Log() << Verbose(0) << endl;337 DoLog(0) && (Log() << Verbose(0) << endl); 336 338 } 337 339 … … 340 342 for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) 341 343 if (!TesselStruct->AddBoundaryPoint(runner->second.second, 0)) 342 eLog() << Verbose(2) << "Point " << *(runner->second.second) << " is already present!" << endl;343 344 Log() << Verbose(0) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl;344 DoeLog(2) && (eLog()<< Verbose(2) << "Point " << *(runner->second.second) << " is already present!" << endl); 345 346 DoLog(0) && (Log() << Verbose(0) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl); 345 347 // now we have the whole set of edge points in the BoundaryList 346 348 … … 360 362 // 3c. check whether all atoms lay inside the boundary, if not, add to boundary points, segment triangle into three with the new point 361 363 if (!TesselStruct->InsertStraddlingPoints(mol, LCList)) 362 eLog() << Verbose(1) << "Insertion of straddling points failed!" << endl;363 364 Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " intermediate triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl;364 DoeLog(1) && (eLog()<< Verbose(1) << "Insertion of straddling points failed!" << endl); 365 366 DoLog(0) && (Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " intermediate triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl); 365 367 366 368 // 4. Store triangles in tecplot file … … 393 395 for (LineMap::iterator LineRunner = TesselStruct->LinesOnBoundary.begin(); LineRunner != TesselStruct->LinesOnBoundary.end(); LineRunner++) { 394 396 line = LineRunner->second; 395 Log() << Verbose(1) << "INFO: Current line is " << *line << "." << endl;397 DoLog(1) && (Log() << Verbose(1) << "INFO: Current line is " << *line << "." << endl); 396 398 if (!line->CheckConvexityCriterion()) { 397 Log() << Verbose(1) << "... line " << *line << " is concave, flipping it." << endl;399 DoLog(1) && (Log() << Verbose(1) << "... line " << *line << " is concave, flipping it." << endl); 398 400 399 401 // flip the line 400 402 if (TesselStruct->PickFarthestofTwoBaselines(line) == 0.) 401 eLog() << Verbose(1) << "Correction of concave baselines failed!" << endl;403 DoeLog(1) && (eLog()<< Verbose(1) << "Correction of concave baselines failed!" << endl); 402 404 else { 403 405 TesselStruct->FlipBaseline(line); 404 Log() << Verbose(1) << "INFO: Correction of concave baselines worked." << endl;406 DoLog(1) && (Log() << Verbose(1) << "INFO: Correction of concave baselines worked." << endl); 405 407 } 406 408 } … … 412 414 // Log() << Verbose(1) << "Correction of concave tesselpoints failed!" << endl; 413 415 414 Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl;416 DoLog(0) && (Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl); 415 417 416 418 // 4. Store triangles in tecplot file … … 454 456 455 457 if ((TesselStruct == NULL) || (TesselStruct->PointsOnBoundary.empty())) { 456 eLog() << Verbose(1) << "TesselStruct is empty." << endl;458 DoeLog(1) && (eLog()<< Verbose(1) << "TesselStruct is empty." << endl); 457 459 return false; 458 460 } … … 460 462 PointMap::iterator PointRunner; 461 463 while (!TesselStruct->PointsOnBoundary.empty()) { 462 Log() << Verbose(1) << "Remaining points are: ";464 DoLog(1) && (Log() << Verbose(1) << "Remaining points are: "); 463 465 for (PointMap::iterator PointSprinter = TesselStruct->PointsOnBoundary.begin(); PointSprinter != TesselStruct->PointsOnBoundary.end(); PointSprinter++) 464 Log() << Verbose(0) << *(PointSprinter->second) << "\t";465 Log() << Verbose(0) << endl;466 DoLog(0) && (Log() << Verbose(0) << *(PointSprinter->second) << "\t"); 467 DoLog(0) && (Log() << Verbose(0) << endl); 466 468 467 469 PointRunner = TesselStruct->PointsOnBoundary.begin(); … … 519 521 // check whether there is something to work on 520 522 if (TesselStruct == NULL) { 521 eLog() << Verbose(1) << "TesselStruct is empty!" << endl;523 DoeLog(1) && (eLog()<< Verbose(1) << "TesselStruct is empty!" << endl); 522 524 return volume; 523 525 } … … 535 537 PointAdvance++; 536 538 point = PointRunner->second; 537 Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl;539 DoLog(1) && (Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl); 538 540 for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) { 539 541 line = LineRunner->second; 540 Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;542 DoLog(1) && (Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl); 541 543 if (!line->CheckConvexityCriterion()) { 542 544 // remove the point if needed 543 Log() << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl;545 DoLog(1) && (Log() << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl); 544 546 volume += TesselStruct->RemovePointFromTesselatedSurface(point); 545 547 sprintf(dummy, "-first-%d", ++run); … … 562 564 LineAdvance++; 563 565 line = LineRunner->second; 564 Log() << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl;566 DoLog(1) && (Log() << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl); 565 567 // take highest of both lines 566 568 if (TesselStruct->IsConvexRectangle(line) == NULL) { … … 603 605 604 606 // end 605 Log() << Verbose(0) << "Volume is " << volume << "." << endl;607 DoLog(0) && (Log() << Verbose(0) << "Volume is " << volume << "." << endl); 606 608 return volume; 607 609 }; … … 654 656 * \param *out output stream for debugging 655 657 * \param *mol molecule with atoms and bonds 656 * \param * &TesselStruct Tesselation with boundary triangles658 * \param *TesselStruct Tesselation with boundary triangles 657 659 * \param *filename prefix of filename 658 660 * \param *extraSuffix intermediate suffix 659 661 */ 660 void StoreTrianglesinFile(const molecule * const mol, const Tesselation * &TesselStruct, const char *filename, const char *extraSuffix)662 void StoreTrianglesinFile(const molecule * const mol, const Tesselation * const TesselStruct, const char *filename, const char *extraSuffix) 661 663 { 662 664 Info FunctionInfo(__func__); … … 732 734 totalmass += Walker->type->mass; 733 735 } 734 Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl;735 Log() << Verbose(0) << "RESULT: The average density is " << setprecision(10) << totalmass / clustervolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;736 DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl); 737 DoLog(0) && (Log() << Verbose(0) << "RESULT: The average density is " << setprecision(10) << totalmass / clustervolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl); 736 738 737 739 // solve cubic polynomial 738 Log() << Verbose(1) << "Solving equidistant suspension in water problem ..." << endl;740 DoLog(1) && (Log() << Verbose(1) << "Solving equidistant suspension in water problem ..." << endl); 739 741 if (IsAngstroem) 740 742 cellvolume = (TotalNoClusters * totalmass / SOLVENTDENSITY_A - (totalmass / clustervolume)) / (celldensity - 1); 741 743 else 742 744 cellvolume = (TotalNoClusters * totalmass / SOLVENTDENSITY_a0 - (totalmass / clustervolume)) / (celldensity - 1); 743 Log() << Verbose(1) << "Cellvolume needed for a density of " << celldensity << " g/cm^3 is " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;745 DoLog(1) && (Log() << Verbose(1) << "Cellvolume needed for a density of " << celldensity << " g/cm^3 is " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl); 744 746 745 747 double minimumvolume = TotalNoClusters * (GreatestDiameter[0] * GreatestDiameter[1] * GreatestDiameter[2]); 746 Log() << Verbose(1) << "Minimum volume of the convex envelope contained in a rectangular box is " << minimumvolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;748 DoLog(1) && (Log() << Verbose(1) << "Minimum volume of the convex envelope contained in a rectangular box is " << minimumvolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl); 747 749 if (minimumvolume > cellvolume) { 748 eLog() << Verbose(1) << "the containing box already has a greater volume than the envisaged cell volume!" << endl;749 Log() << Verbose(0) << "Setting Box dimensions to minimum possible, the greatest diameters." << endl;750 DoeLog(1) && (eLog()<< Verbose(1) << "the containing box already has a greater volume than the envisaged cell volume!" << endl); 751 DoLog(0) && (Log() << Verbose(0) << "Setting Box dimensions to minimum possible, the greatest diameters." << endl); 750 752 for (int i = 0; i < NDIM; i++) 751 753 BoxLengths.x[i] = GreatestDiameter[i]; … … 759 761 double x2 = 0.; 760 762 if (gsl_poly_solve_cubic(BoxLengths.x[0], BoxLengths.x[1], BoxLengths.x[2], &x0, &x1, &x2) == 1) // either 1 or 3 on return 761 Log() << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl;763 DoLog(0) && (Log() << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl); 762 764 else { 763 Log() << Verbose(0) << "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " ." << endl;765 DoLog(0) && (Log() << Verbose(0) << "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " ." << endl); 764 766 x0 = x2; // sorted in ascending order 765 767 } … … 772 774 773 775 // set new box dimensions 774 Log() << Verbose(0) << "Translating to box with these boundaries." << endl;776 DoLog(0) && (Log() << Verbose(0) << "Translating to box with these boundaries." << endl); 775 777 mol->SetBoxDimension(&BoxLengths); 776 778 mol->CenterInBox(); … … 778 780 // update Box of atoms by boundary 779 781 mol->SetBoxDimension(&BoxLengths); 780 Log() << Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths.x[0] << " and " << BoxLengths.x[1] << " and " << BoxLengths.x[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;782 DoLog(0) && (Log() << Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths.x[0] << " and " << BoxLengths.x[1] << " and " << BoxLengths.x[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl); 781 783 }; 782 784 … … 788 790 * \param *filler molecule which the box is to be filled with 789 791 * \param configuration contains box dimensions 792 * \param MaxDistance fills in molecules only up to this distance (set to -1 if whole of the domain) 790 793 * \param distance[NDIM] distance between filling molecules in each direction 794 * \param boundary length of boundary zone between molecule and filling mollecules 795 * \param epsilon distance to surface which is not filled 791 796 * \param RandAtomDisplacement maximum distance for random displacement per atom 792 797 * \param RandMolDisplacement maximum distance for random displacement per filler molecule … … 794 799 * \return *mol pointer to new molecule with filled atoms 795 800 */ 796 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, double distance[NDIM], double RandomAtomDisplacement, double RandomMolDisplacement,bool DoRandomRotation)801 molecule * 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) 797 802 { 798 803 Info FunctionInfo(__func__); … … 801 806 int N[NDIM]; 802 807 int n[NDIM]; 803 double *M = ReturnFullMatrixforSymmetric( filler->cell_size);808 double *M = ReturnFullMatrixforSymmetric(World::get()->cell_size); 804 809 double Rotations[NDIM*NDIM]; 810 double *MInverse = InverseMatrix(M); 805 811 Vector AtomTranslations; 806 812 Vector FillerTranslations; 807 813 Vector FillerDistance; 814 Vector Inserter; 808 815 double FillIt = false; 809 816 atom *Walker = NULL; 810 817 bond *Binder = NULL; 811 int i = 0;812 LinkedCell *LCList[List->ListOfMolecules.size()];813 818 double phi[NDIM]; 814 class Tesselation *TesselStruct[List->ListOfMolecules.size()]; 815 816 i=0; 817 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) { 818 Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl; 819 LCList[i] = new LinkedCell((*ListRunner), 5.); // get linked cell list 820 if (TesselStruct[i] == NULL) { 821 Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl; 822 FindNonConvexBorder((*ListRunner), TesselStruct[i], (const LinkedCell *&)LCList[i], 5., NULL); 823 } 824 i++; 825 } 819 map<molecule *, Tesselation *> TesselStruct; 820 map<molecule *, LinkedCell *> LCList; 821 822 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) 823 if ((*ListRunner)->AtomCount > 0) { 824 DoLog(1) && (Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl); 825 LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list 826 DoLog(1) && (Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl); 827 TesselStruct[(*ListRunner)] = NULL; 828 FindNonConvexBorder((*ListRunner), TesselStruct[(*ListRunner)], (const LinkedCell *&)LCList[(*ListRunner)], 5., NULL); 829 } 826 830 827 831 // Center filler at origin 828 filler->Center Origin();832 filler->CenterEdge(&Inserter); 829 833 filler->Center.Zero(); 834 DoLog(2) && (Log() << Verbose(2) << "INFO: Filler molecule has the following bonds:" << endl); 835 Binder = filler->first; 836 while(Binder->next != filler->last) { 837 Binder = Binder->next; 838 DoLog(2) && (Log() << Verbose(2) << " " << *Binder << endl); 839 } 830 840 831 841 filler->CountAtoms(); … … 835 845 FillerDistance.Init(distance[0], distance[1], distance[2]); 836 846 FillerDistance.InverseMatrixMultiplication(M); 837 Log() << Verbose(1) << "INFO: Grid steps are "; 838 for(int i=0;i<NDIM;i++) { 847 for(int i=0;i<NDIM;i++) 839 848 N[i] = (int) ceil(1./FillerDistance.x[i]); 840 Log() << Verbose(1) << N[i]; 841 if (i != NDIM-1) 842 Log() << Verbose(1)<< ", "; 843 else 844 Log() << Verbose(1) << "." << endl; 845 } 849 DoLog(1) && (Log() << Verbose(1) << "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << "." << endl); 850 851 // initialize seed of random number generator to current time 852 srand ( time(NULL) ); 846 853 847 854 // go over [0,1]^3 filler grid … … 852 859 CurrentPosition.Init((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]); 853 860 CurrentPosition.MatrixMultiplication(M); 854 Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "." << endl; 855 // Check whether point is in- or outside 856 FillIt = true; 857 i=0; 858 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) { 859 // get linked cell list 860 if (TesselStruct[i] == NULL) { 861 eLog() << Verbose(1) << "TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl; 862 FillIt = false; 861 // create molecule random translation vector ... 862 for (int i=0;i<NDIM;i++) 863 FillerTranslations.x[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.); 864 DoLog(2) && (Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << "." << endl); 865 866 // go through all atoms 867 for (int i=0;i<filler->AtomCount;i++) 868 CopyAtoms[i] = NULL; 869 Walker = filler->start; 870 while (Walker->next != filler->end) { 871 Walker = Walker->next; 872 873 // create atomic random translation vector ... 874 for (int i=0;i<NDIM;i++) 875 AtomTranslations.x[i] = RandomAtomDisplacement*(rand()/(RAND_MAX/2.) - 1.); 876 877 // ... and rotation matrix 878 if (DoRandomRotation) { 879 for (int i=0;i<NDIM;i++) { 880 phi[i] = rand()/(RAND_MAX/(2.*M_PI)); 881 } 882 883 Rotations[0] = cos(phi[0]) *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2])); 884 Rotations[3] = sin(phi[0]) *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2])); 885 Rotations[6] = cos(phi[1])*sin(phi[2]) ; 886 Rotations[1] = - sin(phi[0])*cos(phi[1]) ; 887 Rotations[4] = cos(phi[0])*cos(phi[1]) ; 888 Rotations[7] = sin(phi[1]) ; 889 Rotations[3] = - cos(phi[0]) *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2])); 890 Rotations[5] = - sin(phi[0]) *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2])); 891 Rotations[8] = cos(phi[1])*cos(phi[2]) ; 892 } 893 894 // ... and put at new position 895 Inserter.CopyVector(&(Walker->x)); 896 if (DoRandomRotation) 897 Inserter.MatrixMultiplication(Rotations); 898 Inserter.AddVector(&AtomTranslations); 899 Inserter.AddVector(&FillerTranslations); 900 Inserter.AddVector(&CurrentPosition); 901 902 // check whether inserter is inside box 903 Inserter.MatrixMultiplication(MInverse); 904 FillIt = true; 905 for (int i=0;i<NDIM;i++) 906 FillIt = FillIt && (Inserter.x[i] >= -MYEPSILON) && ((Inserter.x[i]-1.) <= MYEPSILON); 907 Inserter.MatrixMultiplication(M); 908 909 // Check whether point is in- or outside 910 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) { 911 // get linked cell list 912 if (TesselStruct[(*ListRunner)] != NULL) { 913 const double distance = (TesselStruct[(*ListRunner)]->GetDistanceToSurface(Inserter, LCList[(*ListRunner)])); 914 FillIt = FillIt && (distance > boundary) && ((MaxDistance < 0) || (MaxDistance > distance)); 915 } 916 } 917 // insert into Filling 918 if (FillIt) { 919 DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl); 920 // copy atom ... 921 CopyAtoms[Walker->nr] = new atom(Walker); 922 CopyAtoms[Walker->nr]->x.CopyVector(&Inserter); 923 Filling->AddAtom(CopyAtoms[Walker->nr]); 924 DoLog(4) && (Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl); 863 925 } else { 864 FillIt = FillIt && (!TesselStruct[i]->IsInnerPoint(CurrentPosition, LCList[i])); 865 i++; 926 DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl); 927 CopyAtoms[Walker->nr] = NULL; 928 continue; 866 929 } 867 930 } 868 869 if (FillIt) { 870 // fill in Filler 871 Log() << Verbose(2) << "Space at " << CurrentPosition << " is unoccupied by any molecule, filling in." << endl; 872 873 // create molecule random translation vector ... 874 for (int i=0;i<NDIM;i++) 875 FillerTranslations.x[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.); 876 Log() << Verbose(2) << "INFO: Translating this filler by " << FillerTranslations << "." << endl; 877 878 // go through all atoms 879 Walker = filler->start; 880 while (Walker->next != filler->end) { 881 Walker = Walker->next; 882 // copy atom ... 883 CopyAtoms[Walker->nr] = new atom(Walker); 884 885 // create atomic random translation vector ... 886 for (int i=0;i<NDIM;i++) 887 AtomTranslations.x[i] = RandomAtomDisplacement*(rand()/(RAND_MAX/2.) - 1.); 888 889 // ... and rotation matrix 890 if (DoRandomRotation) { 891 for (int i=0;i<NDIM;i++) { 892 phi[i] = rand()/(RAND_MAX/(2.*M_PI)); 893 } 894 895 Rotations[0] = cos(phi[0]) *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2])); 896 Rotations[3] = sin(phi[0]) *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2])); 897 Rotations[6] = cos(phi[1])*sin(phi[2]) ; 898 Rotations[1] = - sin(phi[0])*cos(phi[1]) ; 899 Rotations[4] = cos(phi[0])*cos(phi[1]) ; 900 Rotations[7] = sin(phi[1]) ; 901 Rotations[3] = - cos(phi[0]) *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2])); 902 Rotations[5] = - sin(phi[0]) *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2])); 903 Rotations[8] = cos(phi[1])*cos(phi[2]) ; 904 } 905 906 // ... and put at new position 907 if (DoRandomRotation) 908 CopyAtoms[Walker->nr]->x.MatrixMultiplication(Rotations); 909 CopyAtoms[Walker->nr]->x.AddVector(&AtomTranslations); 910 CopyAtoms[Walker->nr]->x.AddVector(&FillerTranslations); 911 CopyAtoms[Walker->nr]->x.AddVector(&CurrentPosition); 912 913 // insert into Filling 914 915 // FIXME: gives completely different results if CopyAtoms[..] used instead of Walker, why??? 916 Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl; 917 Filling->AddAtom(CopyAtoms[Walker->nr]); 918 } 919 920 // go through all bonds and add as well 921 Binder = filler->first; 922 while(Binder->next != filler->last) { 923 Binder = Binder->next; 924 Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl; 931 // go through all bonds and add as well 932 Binder = filler->first; 933 while(Binder->next != filler->last) { 934 Binder = Binder->next; 935 if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) { 936 Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl; 925 937 Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree); 926 938 } 927 } else {928 // leave empty929 Log() << Verbose(2) << "Space at " << CurrentPosition << " is occupied." << endl;930 939 } 931 940 } 932 941 Free(&M); 933 for (size_t i=0;i<List->ListOfMolecules.size();i++) { 934 delete(LCList[i]); 935 delete(TesselStruct[i]); 936 } 942 Free(&MInverse); 943 937 944 return Filling; 938 945 }; … … 953 960 bool freeLC = false; 954 961 bool status = false; 955 CandidateForTesselation *baseline; 956 LineMap::iterator testline; 962 CandidateForTesselation *baseline = NULL; 957 963 bool OneLoopWithoutSuccessFlag = true; // marks whether we went once through all baselines without finding any without two triangles 958 964 bool TesselationFailFlag = false; 959 BoundaryTriangleSet *T = NULL;960 965 961 966 if (TesselStruct == NULL) { 962 Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl;967 DoLog(1) && (Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl); 963 968 TesselStruct= new Tesselation; 964 969 } else { 965 970 delete(TesselStruct); 966 Log() << Verbose(1) << "Re-Allocating Tesselation struct ..." << endl;971 DoLog(1) && (Log() << Verbose(1) << "Re-Allocating Tesselation struct ..." << endl); 967 972 TesselStruct = new Tesselation; 968 973 } … … 975 980 976 981 // 1. get starting triangle 977 TesselStruct->FindStartingTriangle(RADIUS, LCList); 982 if (!TesselStruct->FindStartingTriangle(RADIUS, LCList)) { 983 DoeLog(0) && (eLog() << Verbose(0) << "No valid starting triangle found." << endl); 984 //performCriticalExit(); 985 } 986 if (filename != NULL) { 987 if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration 988 TesselStruct->Output(filename, mol); 989 } 990 } 978 991 979 992 // 2. expand from there 980 993 while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) { 981 // 2a. fill all new OpenLines 982 Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for candidates:" << endl; 994 (cerr << "There are " << TesselStruct->TrianglesOnBoundary.size() << " triangles and " << TesselStruct->OpenLines.size() << " open lines to scan for candidates." << endl); 995 // 2a. print OpenLines without candidates 996 DoLog(1) && (Log() << Verbose(1) << "There are the following open lines to scan for a candidates:" << endl); 983 997 for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) 984 Log() << Verbose(2) << *(Runner->second) << endl;985 986 for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) { 987 baseline = Runner->second;988 if (baseline->pointlist.empty()) {989 T = (((baseline->BaseLine->triangles.begin()))->second); 990 Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl;991 TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, RADIUS, LCList); //the line is there, so there is a triangle, but only one.992 }993 }994 995 // 2 b. search for smallest ShortestAngle among all candidates998 if (Runner->second->pointlist.empty()) 999 DoLog(1) && (Log() << Verbose(1) << " " << *(Runner->second) << endl); 1000 1001 // 2b. find best candidate for each OpenLine 1002 TesselationFailFlag = TesselStruct->FindCandidatesforOpenLines(RADIUS, LCList); 1003 1004 // 2c. print OpenLines with candidates again 1005 DoLog(1) && (Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl); 1006 for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) 1007 DoLog(1) && (Log() << Verbose(1) << " " << *(Runner->second) << endl); 1008 1009 // 2d. search for smallest ShortestAngle among all candidates 996 1010 double ShortestAngle = 4.*M_PI; 997 Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl;998 for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)999 Log() << Verbose(2) << *(Runner->second) << endl;1000 1001 1011 for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) { 1002 1012 if (Runner->second->ShortestAngle < ShortestAngle) { 1003 1013 baseline = Runner->second; 1004 1014 ShortestAngle = baseline->ShortestAngle; 1005 //Log() << Verbose(1) << "New best candidate is " << *baseline->BaseLine << " with point " << *baseline->point << " and angle " << baseline->ShortestAngle << endl;1015 DoLog(1) && (Log() << Verbose(1) << "New best candidate is " << *baseline->BaseLine << " with point " << *(*baseline->pointlist.begin()) << " and angle " << baseline->ShortestAngle << endl); 1006 1016 } 1007 1017 } 1018 // 2e. if we found one, add candidate 1008 1019 if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty())) 1009 1020 OneLoopWithoutSuccessFlag = false; 1010 1021 else { 1011 TesselStruct->AddCandidate Triangle(*baseline);1012 } 1013 1014 // write temporary envelope1022 TesselStruct->AddCandidatePolygon(*baseline, RADIUS, LCList); 1023 } 1024 1025 // 2f. write temporary envelope 1015 1026 if (filename != NULL) { 1016 1027 if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration … … 1044 1055 status = CheckListOfBaselines(TesselStruct); 1045 1056 1057 // store before correction 1058 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, ""); 1059 1060 // // correct degenerated polygons 1061 // TesselStruct->CorrectAllDegeneratedPolygons(); 1062 // 1063 // // check envelope for consistency 1064 // status = CheckListOfBaselines(TesselStruct); 1065 1046 1066 // write final envelope 1047 1067 CalculateConcavityPerBoundaryPoint(TesselStruct); -
Property mode
changed from
-
src/boundary.hpp
r491876 rc695c9 35 35 36 36 #define DEBUG 1 37 #define DoSingleStepOutput 138 #define SingleStepWidth 1 37 #define DoSingleStepOutput 0 38 #define SingleStepWidth 10 39 39 40 40 #define DistancePair pair < double, atom* > … … 49 49 50 50 double ConvexizeNonconvexEnvelope(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename); 51 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, double distance[NDIM], double RandAtomDisplacement, double RandMolDisplacement,bool DoRandomRotation);51 molecule * 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 52 void FindConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename); 53 53 Vector* FindEmbeddingHole(MoleculeListClass *mols, molecule *srcmol); … … 58 58 void PrepareClustersinWater(config *configuration, molecule *mol, double ClusterVolume, double celldensity); 59 59 bool RemoveAllBoundaryPoints(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename); 60 void StoreTrianglesinFile(const molecule * const mol, const Tesselation * &TesselStruct, const char *filename, const char *extraSuffix);60 void StoreTrianglesinFile(const molecule * const mol, const Tesselation * const TesselStruct, const char *filename, const char *extraSuffix); 61 61 double VolumeOfConvexEnvelope(class Tesselation *TesselStruct, class config *configuration); 62 62 -
src/builder.cpp
r491876 rc695c9 50 50 using namespace std; 51 51 52 #include <cstring> 53 54 #include "analysis_bonds.hpp" 52 55 #include "analysis_correlation.hpp" 53 56 #include "atom.hpp" … … 65 68 #include "molecule.hpp" 66 69 #include "periodentafel.hpp" 70 #include "version.h" 71 #include "World.hpp" 67 72 68 73 /********************************************* Subsubmenu routine ************************************/ … … 81 86 bool valid; 82 87 83 Log()<< Verbose(0) << "===========ADD ATOM============================" << endl;84 Log()<< Verbose(0) << " a - state absolute coordinates of atom" << endl;85 Log()<< Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;86 Log()<< Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;87 Log()<< Verbose(0) << " d - state two atoms, two angles and a distance" << endl;88 Log()<< Verbose(0) << " e - least square distance position to a set of atoms" << endl;89 Log()<< Verbose(0) << "all else - go back" << endl;90 Log()<< Verbose(0) << "===============================================" << endl;91 Log()<< Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;92 Log()<< Verbose(0) << "INPUT: ";88 cout << Verbose(0) << "===========ADD ATOM============================" << endl; 89 cout << Verbose(0) << " a - state absolute coordinates of atom" << endl; 90 cout << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl; 91 cout << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl; 92 cout << Verbose(0) << " d - state two atoms, two angles and a distance" << endl; 93 cout << Verbose(0) << " e - least square distance position to a set of atoms" << endl; 94 cout << Verbose(0) << "all else - go back" << endl; 95 cout << Verbose(0) << "===============================================" << endl; 96 cout << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl; 97 cout << Verbose(0) << "INPUT: "; 93 98 cin >> choice; 94 99 95 100 switch (choice) { 96 101 default: 97 eLog() << Verbose(2) << "Not a valid choice." << endl;102 DoeLog(2) && (eLog()<< Verbose(2) << "Not a valid choice." << endl); 98 103 break; 99 104 case 'a': // absolute coordinates of atom 100 Log()<< Verbose(0) << "Enter absolute coordinates." << endl;105 cout << Verbose(0) << "Enter absolute coordinates." << endl; 101 106 first = new atom; 102 first->x.AskPosition( mol->cell_size, false);107 first->x.AskPosition(World::get()->cell_size, false); 103 108 first->type = periode->AskElement(); // give type 104 109 mol->AddAtom(first); // add to molecule … … 109 114 valid = true; 110 115 do { 111 if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;112 Log()<< Verbose(0) << "Enter reference coordinates." << endl;113 x.AskPosition( mol->cell_size, true);114 Log()<< Verbose(0) << "Enter relative coordinates." << endl;115 first->x.AskPosition( mol->cell_size, false);116 if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl); 117 cout << Verbose(0) << "Enter reference coordinates." << endl; 118 x.AskPosition(World::get()->cell_size, true); 119 cout << Verbose(0) << "Enter relative coordinates." << endl; 120 first->x.AskPosition(World::get()->cell_size, false); 116 121 first->x.AddVector((const Vector *)&x); 117 Log()<< Verbose(0) << "\n";122 cout << Verbose(0) << "\n"; 118 123 } while (!(valid = mol->CheckBounds((const Vector *)&first->x))); 119 124 first->type = periode->AskElement(); // give type … … 125 130 valid = true; 126 131 do { 127 if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;132 if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl); 128 133 second = mol->AskAtom("Enter atom number: "); 129 Log() << Verbose(0) << "Enter relative coordinates." << endl;130 first->x.AskPosition( mol->cell_size, false);134 DoLog(0) && (Log() << Verbose(0) << "Enter relative coordinates." << endl); 135 first->x.AskPosition(World::get()->cell_size, false); 131 136 for (int i=NDIM;i--;) { 132 137 first->x.x[i] += second->x.x[i]; … … 142 147 do { 143 148 if (!valid) { 144 eLog() << Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl;149 DoeLog(2) && (eLog()<< Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl); 145 150 } 146 Log()<< Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;151 cout << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl; 147 152 second = mol->AskAtom("Enter central atom: "); 148 153 third = mol->AskAtom("Enter second atom (specifying the axis for first angle): "); … … 155 160 c *= M_PI/180.; 156 161 bound(&c, -M_PI, M_PI); 157 Log()<< Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;162 cout << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl; 158 163 /* 159 164 second->Output(1,1,(ofstream *)&cout); … … 167 172 168 173 if (!z.SolveSystem(&x,&y,&n, b, c, a)) { 169 Log() << Verbose(0) << "Failure solving self-dependent linear system!" << endl;174 coutg() << Verbose(0) << "Failure solving self-dependent linear system!" << endl; 170 175 continue; 171 176 } 172 Log() << Verbose(0) << "resulting relative coordinates: ";177 DoLog(0) && (Log() << Verbose(0) << "resulting relative coordinates: "); 173 178 z.Output(); 174 Log() << Verbose(0) << endl;179 DoLog(0) && (Log() << Verbose(0) << endl); 175 180 */ 176 181 // calc axis vector … … 180 185 Log() << Verbose(0) << "x: ", 181 186 x.Output(); 182 Log() << Verbose(0) << endl;187 DoLog(0) && (Log() << Verbose(0) << endl); 183 188 z.MakeNormalVector(&second->x,&third->x,&fourth->x); 184 189 Log() << Verbose(0) << "z: ", 185 190 z.Output(); 186 Log() << Verbose(0) << endl;191 DoLog(0) && (Log() << Verbose(0) << endl); 187 192 y.MakeNormalVector(&x,&z); 188 193 Log() << Verbose(0) << "y: ", 189 194 y.Output(); 190 Log() << Verbose(0) << endl;195 DoLog(0) && (Log() << Verbose(0) << endl); 191 196 192 197 // rotate vector around first angle … … 195 200 Log() << Verbose(0) << "Rotated vector: ", 196 201 first->x.Output(); 197 Log() << Verbose(0) << endl;202 DoLog(0) && (Log() << Verbose(0) << endl); 198 203 // remove the projection onto the rotation plane of the second angle 199 204 n.CopyVector(&y); … … 201 206 Log() << Verbose(0) << "N1: ", 202 207 n.Output(); 203 Log() << Verbose(0) << endl;208 DoLog(0) && (Log() << Verbose(0) << endl); 204 209 first->x.SubtractVector(&n); 205 210 Log() << Verbose(0) << "Subtracted vector: ", 206 211 first->x.Output(); 207 Log() << Verbose(0) << endl;212 DoLog(0) && (Log() << Verbose(0) << endl); 208 213 n.CopyVector(&z); 209 214 n.Scale(first->x.ScalarProduct(&z)); 210 215 Log() << Verbose(0) << "N2: ", 211 216 n.Output(); 212 Log() << Verbose(0) << endl;217 DoLog(0) && (Log() << Verbose(0) << endl); 213 218 first->x.SubtractVector(&n); 214 219 Log() << Verbose(0) << "2nd subtracted vector: ", 215 220 first->x.Output(); 216 Log() << Verbose(0) << endl;221 DoLog(0) && (Log() << Verbose(0) << endl); 217 222 218 223 // rotate another vector around second angle … … 221 226 Log() << Verbose(0) << "2nd Rotated vector: ", 222 227 n.Output(); 223 Log() << Verbose(0) << endl;228 DoLog(0) && (Log() << Verbose(0) << endl); 224 229 225 230 // add the two linear independent vectors … … 229 234 first->x.AddVector(&second->x); 230 235 231 Log() << Verbose(0) << "resulting coordinates: ";236 DoLog(0) && (Log() << Verbose(0) << "resulting coordinates: "); 232 237 first->x.Output(); 233 Log() << Verbose(0) << endl;238 DoLog(0) && (Log() << Verbose(0) << endl); 234 239 } while (!(valid = mol->CheckBounds((const Vector *)&first->x))); 235 240 first->type = periode->AskElement(); // give type … … 244 249 atoms[i] = NULL; 245 250 int i=0, j=0; 246 Log()<< Verbose(0) << "Now we need at least three molecules.\n";251 cout << Verbose(0) << "Now we need at least three molecules.\n"; 247 252 do { 248 Log()<< Verbose(0) << "Enter " << i+1 << "th atom: ";253 cout << Verbose(0) << "Enter " << i+1 << "th atom: "; 249 254 cin >> j; 250 255 if (j != -1) { … … 261 266 } else { 262 267 delete first; 263 Log()<< Verbose(0) << "Please enter at least two vectors!\n";268 cout << Verbose(0) << "Please enter at least two vectors!\n"; 264 269 } 265 270 break; … … 275 280 char choice; // menu choice char 276 281 277 Log()<< Verbose(0) << "===========CENTER ATOMS=========================" << endl;278 Log()<< Verbose(0) << " a - on origin" << endl;279 Log()<< Verbose(0) << " b - on center of gravity" << endl;280 Log()<< Verbose(0) << " c - within box with additional boundary" << endl;281 Log()<< Verbose(0) << " d - within given simulation box" << endl;282 Log()<< Verbose(0) << "all else - go back" << endl;283 Log()<< Verbose(0) << "===============================================" << endl;284 Log()<< Verbose(0) << "INPUT: ";282 cout << Verbose(0) << "===========CENTER ATOMS=========================" << endl; 283 cout << Verbose(0) << " a - on origin" << endl; 284 cout << Verbose(0) << " b - on center of gravity" << endl; 285 cout << Verbose(0) << " c - within box with additional boundary" << endl; 286 cout << Verbose(0) << " d - within given simulation box" << endl; 287 cout << Verbose(0) << "all else - go back" << endl; 288 cout << Verbose(0) << "===============================================" << endl; 289 cout << Verbose(0) << "INPUT: "; 285 290 cin >> choice; 286 291 287 292 switch (choice) { 288 293 default: 289 Log()<< Verbose(0) << "Not a valid choice." << endl;294 cout << Verbose(0) << "Not a valid choice." << endl; 290 295 break; 291 296 case 'a': 292 Log()<< Verbose(0) << "Centering atoms in config file on origin." << endl;297 cout << Verbose(0) << "Centering atoms in config file on origin." << endl; 293 298 mol->CenterOrigin(); 294 299 break; 295 300 case 'b': 296 Log()<< Verbose(0) << "Centering atoms in config file on center of gravity." << endl;301 cout << Verbose(0) << "Centering atoms in config file on center of gravity." << endl; 297 302 mol->CenterPeriodic(); 298 303 break; 299 304 case 'c': 300 Log()<< Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;305 cout << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl; 301 306 for (int i=0;i<NDIM;i++) { 302 Log()<< Verbose(0) << "Enter axis " << i << " boundary: ";307 cout << Verbose(0) << "Enter axis " << i << " boundary: "; 303 308 cin >> y.x[i]; 304 309 } … … 311 316 break; 312 317 case 'd': 313 Log()<< Verbose(1) << "Centering atoms in config file within given simulation box." << endl;318 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 314 319 for (int i=0;i<NDIM;i++) { 315 Log()<< Verbose(0) << "Enter axis " << i << " boundary: ";320 cout << Verbose(0) << "Enter axis " << i << " boundary: "; 316 321 cin >> x.x[i]; 317 322 } … … 334 339 char choice; // menu choice char 335 340 336 Log()<< Verbose(0) << "===========ALIGN ATOMS=========================" << endl;337 Log()<< Verbose(0) << " a - state three atoms defining align plane" << endl;338 Log()<< Verbose(0) << " b - state alignment vector" << endl;339 Log()<< Verbose(0) << " c - state two atoms in alignment direction" << endl;340 Log()<< Verbose(0) << " d - align automatically by least square fit" << endl;341 Log()<< Verbose(0) << "all else - go back" << endl;342 Log()<< Verbose(0) << "===============================================" << endl;343 Log()<< Verbose(0) << "INPUT: ";341 cout << Verbose(0) << "===========ALIGN ATOMS=========================" << endl; 342 cout << Verbose(0) << " a - state three atoms defining align plane" << endl; 343 cout << Verbose(0) << " b - state alignment vector" << endl; 344 cout << Verbose(0) << " c - state two atoms in alignment direction" << endl; 345 cout << Verbose(0) << " d - align automatically by least square fit" << endl; 346 cout << Verbose(0) << "all else - go back" << endl; 347 cout << Verbose(0) << "===============================================" << endl; 348 cout << Verbose(0) << "INPUT: "; 344 349 cin >> choice; 345 350 … … 354 359 break; 355 360 case 'b': // normal vector of mirror plane 356 Log()<< Verbose(0) << "Enter normal vector of mirror plane." << endl;357 n.AskPosition( mol->cell_size,0);361 cout << Verbose(0) << "Enter normal vector of mirror plane." << endl; 362 n.AskPosition(World::get()->cell_size,0); 358 363 n.Normalize(); 359 364 break; … … 374 379 fscanf(stdin, "%3s", shorthand); 375 380 } while ((param.type = periode->FindElement(shorthand)) == NULL); 376 Log()<< Verbose(0) << "Element is " << param.type->name << endl;381 cout << Verbose(0) << "Element is " << param.type->name << endl; 377 382 mol->GetAlignvector(¶m); 378 383 for (int i=NDIM;i--;) { … … 381 386 } 382 387 gsl_vector_free(param.x); 383 Log()<< Verbose(0) << "Offset vector: ";388 cout << Verbose(0) << "Offset vector: "; 384 389 x.Output(); 385 Log() << Verbose(0) << endl;390 DoLog(0) && (Log() << Verbose(0) << endl); 386 391 n.Normalize(); 387 392 break; 388 393 }; 389 Log() << Verbose(0) << "Alignment vector: ";394 DoLog(0) && (Log() << Verbose(0) << "Alignment vector: "); 390 395 n.Output(); 391 Log() << Verbose(0) << endl;396 DoLog(0) && (Log() << Verbose(0) << endl); 392 397 mol->Align(&n); 393 398 }; … … 402 407 char choice; // menu choice char 403 408 404 Log() << Verbose(0) << "===========MIRROR ATOMS=========================" << endl;405 Log() << Verbose(0) << " a - state three atoms defining mirror plane" << endl;406 Log() << Verbose(0) << " b - state normal vector of mirror plane" << endl;407 Log() << Verbose(0) << " c - state two atoms in normal direction" << endl;408 Log() << Verbose(0) << "all else - go back" << endl;409 Log() << Verbose(0) << "===============================================" << endl;410 Log() << Verbose(0) << "INPUT: ";409 DoLog(0) && (Log() << Verbose(0) << "===========MIRROR ATOMS=========================" << endl); 410 DoLog(0) && (Log() << Verbose(0) << " a - state three atoms defining mirror plane" << endl); 411 DoLog(0) && (Log() << Verbose(0) << " b - state normal vector of mirror plane" << endl); 412 DoLog(0) && (Log() << Verbose(0) << " c - state two atoms in normal direction" << endl); 413 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl); 414 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl); 415 DoLog(0) && (Log() << Verbose(0) << "INPUT: "); 411 416 cin >> choice; 412 417 … … 421 426 break; 422 427 case 'b': // normal vector of mirror plane 423 Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;424 n.AskPosition( mol->cell_size,0);428 DoLog(0) && (Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl); 429 n.AskPosition(World::get()->cell_size,0); 425 430 n.Normalize(); 426 431 break; … … 434 439 break; 435 440 }; 436 Log() << Verbose(0) << "Normal vector: ";441 DoLog(0) && (Log() << Verbose(0) << "Normal vector: "); 437 442 n.Output(); 438 Log() << Verbose(0) << endl;443 DoLog(0) && (Log() << Verbose(0) << endl); 439 444 mol->Mirror((const Vector *)&n); 440 445 }; … … 450 455 char choice; // menu choice char 451 456 452 Log() << Verbose(0) << "===========REMOVE ATOMS=========================" << endl;453 Log() << Verbose(0) << " a - state atom for removal by number" << endl;454 Log() << Verbose(0) << " b - keep only in radius around atom" << endl;455 Log() << Verbose(0) << " c - remove this with one axis greater value" << endl;456 Log() << Verbose(0) << "all else - go back" << endl;457 Log() << Verbose(0) << "===============================================" << endl;458 Log() << Verbose(0) << "INPUT: ";457 DoLog(0) && (Log() << Verbose(0) << "===========REMOVE ATOMS=========================" << endl); 458 DoLog(0) && (Log() << Verbose(0) << " a - state atom for removal by number" << endl); 459 DoLog(0) && (Log() << Verbose(0) << " b - keep only in radius around atom" << endl); 460 DoLog(0) && (Log() << Verbose(0) << " c - remove this with one axis greater value" << endl); 461 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl); 462 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl); 463 DoLog(0) && (Log() << Verbose(0) << "INPUT: "); 459 464 cin >> choice; 460 465 … … 463 468 case 'a': 464 469 if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: "))) 465 Log() << Verbose(1) << "Atom removed." << endl;470 DoLog(1) && (Log() << Verbose(1) << "Atom removed." << endl); 466 471 else 467 Log() << Verbose(1) << "Atom not found." << endl;472 DoLog(1) && (Log() << Verbose(1) << "Atom not found." << endl); 468 473 break; 469 474 case 'b': 470 475 second = mol->AskAtom("Enter number of atom as reference point: "); 471 Log() << Verbose(0) << "Enter radius: ";476 DoLog(0) && (Log() << Verbose(0) << "Enter radius: "); 472 477 cin >> tmp1; 473 478 first = mol->start; … … 481 486 break; 482 487 case 'c': 483 Log() << Verbose(0) << "Which axis is it: ";488 DoLog(0) && (Log() << Verbose(0) << "Which axis is it: "); 484 489 cin >> axis; 485 Log() << Verbose(0) << "Lower boundary: ";490 DoLog(0) && (Log() << Verbose(0) << "Lower boundary: "); 486 491 cin >> tmp1; 487 Log() << Verbose(0) << "Upper boundary: ";492 DoLog(0) && (Log() << Verbose(0) << "Upper boundary: "); 488 493 cin >> tmp2; 489 494 first = mol->start; … … 515 520 char choice; // menu choice char 516 521 517 Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl;518 Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl;519 Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl;520 Log() << Verbose(0) << " c - calculate bond angle" << endl;521 Log() << Verbose(0) << " d - calculate principal axis of the system" << endl;522 Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl;523 Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl;524 Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl;525 Log() << Verbose(0) << "all else - go back" << endl;526 Log() << Verbose(0) << "===============================================" << endl;527 Log() << Verbose(0) << "INPUT: ";522 DoLog(0) && (Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl); 523 DoLog(0) && (Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl); 524 DoLog(0) && (Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl); 525 DoLog(0) && (Log() << Verbose(0) << " c - calculate bond angle" << endl); 526 DoLog(0) && (Log() << Verbose(0) << " d - calculate principal axis of the system" << endl); 527 DoLog(0) && (Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl); 528 DoLog(0) && (Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl); 529 DoLog(0) && (Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl); 530 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl); 531 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl); 532 DoLog(0) && (Log() << Verbose(0) << "INPUT: "); 528 533 cin >> choice; 529 534 530 535 switch(choice) { 531 536 default: 532 Log() << Verbose(1) << "Not a valid choice." << endl;537 DoLog(1) && (Log() << Verbose(1) << "Not a valid choice." << endl); 533 538 break; 534 539 case 'a': … … 562 567 x.SubtractVector((const Vector *)&second->x); 563 568 tmp1 = x.Norm(); 564 Log() << Verbose(1) << "Distance vector is ";569 DoLog(1) && (Log() << Verbose(1) << "Distance vector is "); 565 570 x.Output(); 566 Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl;571 DoLog(0) && (Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl); 567 572 break; 568 573 569 574 case 'c': 570 Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl;575 DoLog(0) && (Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl); 571 576 first = mol->AskAtom("Enter first atom: "); 572 577 second = mol->AskAtom("Enter central atom: "); … … 577 582 y.CopyVector((const Vector *)&third->x); 578 583 y.SubtractVector((const Vector *)&second->x); 579 Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";580 Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;584 DoLog(0) && (Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": "); 585 DoLog(0) && (Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl); 581 586 break; 582 587 case 'd': 583 Log() << Verbose(0) << "Evaluating prinicipal axis." << endl;584 Log() << Verbose(0) << "Shall we rotate? [0/1]: ";588 DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl); 589 DoLog(0) && (Log() << Verbose(0) << "Shall we rotate? [0/1]: "); 585 590 cin >> Z; 586 591 if ((Z >=0) && (Z <=1)) … … 591 596 case 'e': 592 597 { 593 Log() << Verbose(0) << "Evaluating volume of the convex envelope.";598 DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope."); 594 599 class Tesselation *TesselStruct = NULL; 595 600 const LinkedCell *LCList = NULL; … … 597 602 FindConvexBorder(mol, TesselStruct, LCList, NULL); 598 603 double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration); 599 Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl;\604 DoLog(0) && (Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl);\ 600 605 delete(LCList); 601 606 delete(TesselStruct); … … 608 613 { 609 614 char filename[255]; 610 Log() << Verbose(0) << "Please enter filename: " << endl;615 DoLog(0) && (Log() << Verbose(0) << "Please enter filename: " << endl); 611 616 cin >> filename; 612 Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl;617 DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl); 613 618 ofstream *output = new ofstream(filename, ios::trunc); 614 619 if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps)) 615 Log() << Verbose(2) << "File could not be written." << endl;620 DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl); 616 621 else 617 Log() << Verbose(2) << "File stored." << endl;622 DoLog(2) && (Log() << Verbose(2) << "File stored." << endl); 618 623 output->close(); 619 624 delete(output); … … 632 637 clock_t start, end; 633 638 634 Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;635 Log() << Verbose(0) << "What's the desired bond order: ";639 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl); 640 DoLog(0) && (Log() << Verbose(0) << "What's the desired bond order: "); 636 641 cin >> Order1; 637 642 if (mol->first->next != mol->last) { // there are bonds … … 639 644 mol->FragmentMolecule(Order1, configuration); 640 645 end = clock(); 641 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;646 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl); 642 647 } else 643 Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl;648 DoLog(0) && (Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl); 644 649 }; 645 650 … … 652 657 static void ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration) 653 658 { 654 atom *first, *second ;659 atom *first, *second, *third; 655 660 molecule *mol = NULL; 656 661 Vector x,y,z,n; // coordinates for absolute point in cell volume … … 660 665 bool valid; 661 666 662 Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl; 663 Log() << Verbose(0) << "a - add an atom" << endl; 664 Log() << Verbose(0) << "r - remove an atom" << endl; 665 Log() << Verbose(0) << "b - scale a bond between atoms" << endl; 666 Log() << Verbose(0) << "u - change an atoms element" << endl; 667 Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl; 668 Log() << Verbose(0) << "all else - go back" << endl; 669 Log() << Verbose(0) << "===============================================" << endl; 667 DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl); 668 DoLog(0) && (Log() << Verbose(0) << "a - add an atom" << endl); 669 DoLog(0) && (Log() << Verbose(0) << "r - remove an atom" << endl); 670 DoLog(0) && (Log() << Verbose(0) << "b - scale a bond between atoms" << endl); 671 DoLog(0) && (Log() << Verbose(0) << "t - turn an atom round another bond" << endl); 672 DoLog(0) && (Log() << Verbose(0) << "u - change an atoms element" << endl); 673 DoLog(0) && (Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl); 674 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl); 675 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl); 670 676 if (molecules->NumberOfActiveMolecules() > 1) 671 eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;672 Log() << Verbose(0) << "INPUT: ";677 DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl); 678 DoLog(0) && (Log() << Verbose(0) << "INPUT: "); 673 679 cin >> choice; 674 680 675 681 switch (choice) { 676 682 default: 677 Log() << Verbose(0) << "Not a valid choice." << endl;683 DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl); 678 684 break; 679 685 … … 682 688 if ((*ListRunner)->ActiveFlag) { 683 689 mol = *ListRunner; 684 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;690 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 685 691 AddAtoms(periode, mol); 686 692 } … … 691 697 if ((*ListRunner)->ActiveFlag) { 692 698 mol = *ListRunner; 693 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;694 Log() << Verbose(0) << "Scaling bond length between two atoms." << endl;699 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 700 DoLog(0) && (Log() << Verbose(0) << "Scaling bond length between two atoms." << endl); 695 701 first = mol->AskAtom("Enter first (fixed) atom: "); 696 702 second = mol->AskAtom("Enter second (shifting) atom: "); … … 699 705 minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]); 700 706 minBond = sqrt(minBond); 701 Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;702 Log() << Verbose(0) << "Enter new bond length [a.u.]: ";707 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); 708 DoLog(0) && (Log() << Verbose(0) << "Enter new bond length [a.u.]: "); 703 709 cin >> bond; 704 710 for (int i=NDIM;i--;) { … … 714 720 if ((*ListRunner)->ActiveFlag) { 715 721 mol = *ListRunner; 716 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;717 Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl;718 Log() << Verbose(0) << "Enter three factors: ";722 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 723 DoLog(0) && (Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl); 724 DoLog(0) && (Log() << Verbose(0) << "Enter three factors: "); 719 725 factor = new double[NDIM]; 720 726 cin >> factor[0]; … … 731 737 if ((*ListRunner)->ActiveFlag) { 732 738 mol = *ListRunner; 733 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;739 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 734 740 MeasureAtoms(periode, mol, configuration); 735 741 } … … 740 746 if ((*ListRunner)->ActiveFlag) { 741 747 mol = *ListRunner; 742 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;748 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 743 749 RemoveAtoms(mol); 744 750 } 751 break; 752 753 case 't': // turn/rotate atom 754 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 755 if ((*ListRunner)->ActiveFlag) { 756 mol = *ListRunner; 757 DoLog(0) && (Log() << Verbose(0) << "Turning atom around another bond - first is atom to turn, second (central) and third specify bond" << endl); 758 first = mol->AskAtom("Enter turning atom: "); 759 second = mol->AskAtom("Enter central atom: "); 760 third = mol->AskAtom("Enter bond atom: "); 761 cout << Verbose(0) << "Enter new angle in degrees: "; 762 double tmp = 0.; 763 cin >> tmp; 764 // calculate old angle 765 x.CopyVector((const Vector *)&first->x); 766 x.SubtractVector((const Vector *)&second->x); 767 y.CopyVector((const Vector *)&third->x); 768 y.SubtractVector((const Vector *)&second->x); 769 double alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.); 770 cout << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": "; 771 cout << Verbose(0) << alpha << " degrees" << endl; 772 // rotate 773 z.MakeNormalVector(&x,&y); 774 x.RotateVector(&z,(alpha-tmp)*M_PI/180.); 775 x.AddVector(&second->x); 776 first->x.CopyVector(&x); 777 // check new angle 778 x.CopyVector((const Vector *)&first->x); 779 x.SubtractVector((const Vector *)&second->x); 780 alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.); 781 cout << Verbose(0) << "new Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": "; 782 cout << Verbose(0) << alpha << " degrees" << endl; 783 } 745 784 break; 746 785 … … 750 789 int Z; 751 790 mol = *ListRunner; 752 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;791 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 753 792 first = NULL; 754 793 do { 755 Log() << Verbose(0) << "Change the element of which atom: ";794 DoLog(0) && (Log() << Verbose(0) << "Change the element of which atom: "); 756 795 cin >> Z; 757 796 } while ((first = mol->FindAtom(Z)) == NULL); 758 Log() << Verbose(0) << "New element by atomic number Z: ";797 DoLog(0) && (Log() << Verbose(0) << "New element by atomic number Z: "); 759 798 cin >> Z; 760 799 first->type = periode->FindElement(Z); 761 Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl;800 DoLog(0) && (Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl); 762 801 } 763 802 break; … … 780 819 MoleculeLeafClass *Subgraphs = NULL; 781 820 782 Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl;783 Log() << Verbose(0) << "c - scale by unit transformation" << endl;784 Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl;785 Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl;786 Log() << Verbose(0) << "g - center atoms in box" << endl;787 Log() << Verbose(0) << "i - realign molecule" << endl;788 Log() << Verbose(0) << "m - mirror all molecules" << endl;789 Log() << Verbose(0) << "o - create connection matrix" << endl;790 Log() << Verbose(0) << "t - translate molecule by vector" << endl;791 Log() << Verbose(0) << "all else - go back" << endl;792 Log() << Verbose(0) << "===============================================" << endl;821 DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl); 822 DoLog(0) && (Log() << Verbose(0) << "c - scale by unit transformation" << endl); 823 DoLog(0) && (Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl); 824 DoLog(0) && (Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl); 825 DoLog(0) && (Log() << Verbose(0) << "g - center atoms in box" << endl); 826 DoLog(0) && (Log() << Verbose(0) << "i - realign molecule" << endl); 827 DoLog(0) && (Log() << Verbose(0) << "m - mirror all molecules" << endl); 828 DoLog(0) && (Log() << Verbose(0) << "o - create connection matrix" << endl); 829 DoLog(0) && (Log() << Verbose(0) << "t - translate molecule by vector" << endl); 830 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl); 831 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl); 793 832 if (molecules->NumberOfActiveMolecules() > 1) 794 eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;795 Log() << Verbose(0) << "INPUT: ";833 DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl); 834 DoLog(0) && (Log() << Verbose(0) << "INPUT: "); 796 835 cin >> choice; 797 836 798 837 switch (choice) { 799 838 default: 800 Log() << Verbose(0) << "Not a valid choice." << endl;839 DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl); 801 840 break; 802 841 … … 805 844 if ((*ListRunner)->ActiveFlag) { 806 845 mol = *ListRunner; 807 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;808 Log() << Verbose(0) << "State the axis [(+-)123]: ";846 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 847 DoLog(0) && (Log() << Verbose(0) << "State the axis [(+-)123]: "); 809 848 cin >> axis; 810 Log() << Verbose(0) << "State the factor: ";849 DoLog(0) && (Log() << Verbose(0) << "State the factor: "); 811 850 cin >> faktor; 812 851 … … 825 864 } 826 865 if (count != j) 827 eLog() << Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;866 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl); 828 867 x.Zero(); 829 868 y.Zero(); 830 y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude869 y.x[abs(axis)-1] = World::get()->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude 831 870 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times 832 871 x.AddVector(&y); // per factor one cell width further … … 851 890 mol->Translate(&x); 852 891 } 853 mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;892 World::get()->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor; 854 893 } 855 894 } … … 864 903 if ((*ListRunner)->ActiveFlag) { 865 904 mol = *ListRunner; 866 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;905 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 867 906 CenterAtoms(mol); 868 907 } … … 873 912 if ((*ListRunner)->ActiveFlag) { 874 913 mol = *ListRunner; 875 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;914 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 876 915 AlignAtoms(periode, mol); 877 916 } … … 882 921 if ((*ListRunner)->ActiveFlag) { 883 922 mol = *ListRunner; 884 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;923 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 885 924 MirrorAtoms(mol); 886 925 } … … 893 932 double bonddistance; 894 933 clock_t start,end; 895 Log() << Verbose(0) << "What's the maximum bond distance: ";934 DoLog(0) && (Log() << Verbose(0) << "What's the maximum bond distance: "); 896 935 cin >> bonddistance; 897 936 start = clock(); 898 937 mol->CreateAdjacencyList(bonddistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 899 938 end = clock(); 900 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;939 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl); 901 940 } 902 941 break; … … 906 945 if ((*ListRunner)->ActiveFlag) { 907 946 mol = *ListRunner; 908 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;909 Log() << Verbose(0) << "Enter translation vector." << endl;910 x.AskPosition( mol->cell_size,0);947 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 948 DoLog(0) && (Log() << Verbose(0) << "Enter translation vector." << endl); 949 x.AskPosition(World::get()->cell_size,0); 911 950 mol->Center.AddVector((const Vector *)&x); 912 951 } … … 935 974 molecule *mol = NULL; 936 975 937 Log() << Verbose(0) << "==========EDIT MOLECULES=====================" << endl;938 Log() << Verbose(0) << "c - create new molecule" << endl;939 Log() << Verbose(0) << "l - load molecule from xyz file" << endl;940 Log() << Verbose(0) << "n - change molecule's name" << endl;941 Log() << Verbose(0) << "N - give molecules filename" << endl;942 Log() << Verbose(0) << "p - parse atoms in xyz file into molecule" << endl;943 Log() << Verbose(0) << "r - remove a molecule" << endl;944 Log() << Verbose(0) << "all else - go back" << endl;945 Log() << Verbose(0) << "===============================================" << endl;946 Log() << Verbose(0) << "INPUT: ";976 DoLog(0) && (Log() << Verbose(0) << "==========EDIT MOLECULES=====================" << endl); 977 DoLog(0) && (Log() << Verbose(0) << "c - create new molecule" << endl); 978 DoLog(0) && (Log() << Verbose(0) << "l - load molecule from xyz file" << endl); 979 DoLog(0) && (Log() << Verbose(0) << "n - change molecule's name" << endl); 980 DoLog(0) && (Log() << Verbose(0) << "N - give molecules filename" << endl); 981 DoLog(0) && (Log() << Verbose(0) << "p - parse atoms in xyz file into molecule" << endl); 982 DoLog(0) && (Log() << Verbose(0) << "r - remove a molecule" << endl); 983 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl); 984 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl); 985 DoLog(0) && (Log() << Verbose(0) << "INPUT: "); 947 986 cin >> choice; 948 987 949 988 switch (choice) { 950 989 default: 951 Log() << Verbose(0) << "Not a valid choice." << endl;990 DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl); 952 991 break; 953 992 case 'c': … … 959 998 { 960 999 char filename[MAXSTRINGSIZE]; 961 Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;1000 DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl); 962 1001 mol = new molecule(periode); 963 1002 do { 964 Log() << Verbose(0) << "Enter file name: ";1003 DoLog(0) && (Log() << Verbose(0) << "Enter file name: "); 965 1004 cin >> filename; 966 1005 } while (!mol->AddXYZFile(filename)); … … 968 1007 // center at set box dimensions 969 1008 mol->CenterEdge(¢er); 970 mol->cell_size[0] = center.x[0]; 971 mol->cell_size[1] = 0; 972 mol->cell_size[2] = center.x[1]; 973 mol->cell_size[3] = 0; 974 mol->cell_size[4] = 0; 975 mol->cell_size[5] = center.x[2]; 1009 double * const cell_size = World::get()->cell_size; 1010 cell_size[0] = center.x[0]; 1011 cell_size[1] = 0; 1012 cell_size[2] = center.x[1]; 1013 cell_size[3] = 0; 1014 cell_size[4] = 0; 1015 cell_size[5] = center.x[2]; 976 1016 molecules->insert(mol); 977 1017 } … … 982 1022 char filename[MAXSTRINGSIZE]; 983 1023 do { 984 Log() << Verbose(0) << "Enter index of molecule: ";1024 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: "); 985 1025 cin >> nr; 986 1026 mol = molecules->ReturnIndex(nr); 987 1027 } while (mol == NULL); 988 Log() << Verbose(0) << "Enter name: ";1028 DoLog(0) && (Log() << Verbose(0) << "Enter name: "); 989 1029 cin >> filename; 990 1030 strcpy(mol->name, filename); … … 996 1036 char filename[MAXSTRINGSIZE]; 997 1037 do { 998 Log() << Verbose(0) << "Enter index of molecule: ";1038 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: "); 999 1039 cin >> nr; 1000 1040 mol = molecules->ReturnIndex(nr); 1001 1041 } while (mol == NULL); 1002 Log() << Verbose(0) << "Enter name: ";1042 DoLog(0) && (Log() << Verbose(0) << "Enter name: "); 1003 1043 cin >> filename; 1004 1044 mol->SetNameFromFilename(filename); … … 1011 1051 mol = NULL; 1012 1052 do { 1013 Log() << Verbose(0) << "Enter index of molecule: ";1053 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: "); 1014 1054 cin >> nr; 1015 1055 mol = molecules->ReturnIndex(nr); 1016 1056 } while (mol == NULL); 1017 Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;1057 DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl); 1018 1058 do { 1019 Log() << Verbose(0) << "Enter file name: ";1059 DoLog(0) && (Log() << Verbose(0) << "Enter file name: "); 1020 1060 cin >> filename; 1021 1061 } while (!mol->AddXYZFile(filename)); … … 1025 1065 1026 1066 case 'r': 1027 Log() << Verbose(0) << "Enter index of molecule: ";1067 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: "); 1028 1068 cin >> nr; 1029 1069 count = 1; … … 1048 1088 char choice; // menu choice char 1049 1089 1050 Log() << Verbose(0) << "===========MERGE MOLECULES=====================" << endl; 1051 Log() << Verbose(0) << "a - simple add of one molecule to another" << endl; 1052 Log() << Verbose(0) << "e - embedding merge of two molecules" << endl; 1053 Log() << Verbose(0) << "m - multi-merge of all molecules" << endl; 1054 Log() << Verbose(0) << "s - scatter merge of two molecules" << endl; 1055 Log() << Verbose(0) << "t - simple merge of two molecules" << endl; 1056 Log() << Verbose(0) << "all else - go back" << endl; 1057 Log() << Verbose(0) << "===============================================" << endl; 1058 Log() << Verbose(0) << "INPUT: "; 1090 DoLog(0) && (Log() << Verbose(0) << "===========MERGE MOLECULES=====================" << endl); 1091 DoLog(0) && (Log() << Verbose(0) << "a - simple add of one molecule to another" << endl); 1092 DoLog(0) && (Log() << Verbose(0) << "b - count the number of bonds of two elements" << endl); 1093 DoLog(0) && (Log() << Verbose(0) << "B - count the number of bonds of three elements " << endl); 1094 DoLog(0) && (Log() << Verbose(0) << "e - embedding merge of two molecules" << endl); 1095 DoLog(0) && (Log() << Verbose(0) << "h - count the number of hydrogen bonds" << endl); 1096 DoLog(0) && (Log() << Verbose(0) << "b - count the number of hydrogen bonds" << endl); 1097 DoLog(0) && (Log() << Verbose(0) << "m - multi-merge of all molecules" << endl); 1098 DoLog(0) && (Log() << Verbose(0) << "s - scatter merge of two molecules" << endl); 1099 DoLog(0) && (Log() << Verbose(0) << "t - simple merge of two molecules" << endl); 1100 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl); 1101 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl); 1102 DoLog(0) && (Log() << Verbose(0) << "INPUT: "); 1059 1103 cin >> choice; 1060 1104 1061 1105 switch (choice) { 1062 1106 default: 1063 Log() << Verbose(0) << "Not a valid choice." << endl;1107 DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl); 1064 1108 break; 1065 1109 … … 1070 1114 { 1071 1115 do { 1072 Log() << Verbose(0) << "Enter index of destination molecule: ";1116 DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: "); 1073 1117 cin >> dest; 1074 1118 destmol = molecules->ReturnIndex(dest); 1075 1119 } while ((destmol == NULL) && (dest != -1)); 1076 1120 do { 1077 Log() << Verbose(0) << "Enter index of source molecule to add from: ";1121 DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to add from: "); 1078 1122 cin >> src; 1079 1123 srcmol = molecules->ReturnIndex(src); … … 1085 1129 break; 1086 1130 1131 case 'b': 1132 { 1133 const int nr = 2; 1134 char *names[nr] = {"first", "second"}; 1135 int Z[nr]; 1136 element *elements[nr]; 1137 for (int i=0;i<nr;i++) { 1138 Z[i] = 0; 1139 do { 1140 cout << "Enter " << names[i] << " element: "; 1141 cin >> Z[i]; 1142 } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS)); 1143 elements[i] = periode->FindElement(Z[i]); 1144 } 1145 const int count = CountBondsOfTwo(molecules, elements[0], elements[1]); 1146 cout << endl << "There are " << count << " "; 1147 for (int i=0;i<nr;i++) { 1148 if (i==0) 1149 cout << elements[i]->symbol; 1150 else 1151 cout << "-" << elements[i]->symbol; 1152 } 1153 cout << " bonds." << endl; 1154 } 1155 break; 1156 1157 case 'B': 1158 { 1159 const int nr = 3; 1160 char *names[nr] = {"first", "second", "third"}; 1161 int Z[nr]; 1162 element *elements[nr]; 1163 for (int i=0;i<nr;i++) { 1164 Z[i] = 0; 1165 do { 1166 cout << "Enter " << names[i] << " element: "; 1167 cin >> Z[i]; 1168 } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS)); 1169 elements[i] = periode->FindElement(Z[i]); 1170 } 1171 const int count = CountBondsOfThree(molecules, elements[0], elements[1], elements[2]); 1172 cout << endl << "There are " << count << " "; 1173 for (int i=0;i<nr;i++) { 1174 if (i==0) 1175 cout << elements[i]->symbol; 1176 else 1177 cout << "-" << elements[i]->symbol; 1178 } 1179 cout << " bonds." << endl; 1180 } 1181 break; 1182 1087 1183 case 'e': 1088 1184 { … … 1090 1186 molecule *srcmol = NULL, *destmol = NULL; 1091 1187 do { 1092 Log() << Verbose(0) << "Enter index of matrix molecule (the variable one): ";1188 DoLog(0) && (Log() << Verbose(0) << "Enter index of matrix molecule (the variable one): "); 1093 1189 cin >> src; 1094 1190 srcmol = molecules->ReturnIndex(src); 1095 1191 } while ((srcmol == NULL) && (src != -1)); 1096 1192 do { 1097 Log() << Verbose(0) << "Enter index of molecule to merge into (the fixed one): ";1193 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into (the fixed one): "); 1098 1194 cin >> dest; 1099 1195 destmol = molecules->ReturnIndex(dest); … … 1104 1200 break; 1105 1201 1202 case 'h': 1203 { 1204 int Z; 1205 cout << "Please enter interface element: "; 1206 cin >> Z; 1207 element * const InterfaceElement = periode->FindElement(Z); 1208 cout << endl << "There are " << CountHydrogenBridgeBonds(molecules, InterfaceElement) << " hydrogen bridges with connections to " << (InterfaceElement != 0 ? InterfaceElement->name : "None") << "." << endl; 1209 } 1210 break; 1211 1106 1212 case 'm': 1107 1213 { … … 1109 1215 molecule *mol = NULL; 1110 1216 do { 1111 Log() << Verbose(0) << "Enter index of molecule to merge into: ";1217 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into: "); 1112 1218 cin >> nr; 1113 1219 mol = molecules->ReturnIndex(nr); … … 1126 1232 1127 1233 case 's': 1128 Log() << Verbose(0) << "Not implemented yet." << endl;1234 DoLog(0) && (Log() << Verbose(0) << "Not implemented yet." << endl); 1129 1235 break; 1130 1236 … … 1135 1241 { 1136 1242 do { 1137 Log() << Verbose(0) << "Enter index of destination molecule: ";1243 DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: "); 1138 1244 cin >> dest; 1139 1245 destmol = molecules->ReturnIndex(dest); 1140 1246 } while ((destmol == NULL) && (dest != -1)); 1141 1247 do { 1142 Log() << Verbose(0) << "Enter index of source molecule to merge into: ";1248 DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to merge into: "); 1143 1249 cin >> src; 1144 1250 srcmol = molecules->ReturnIndex(src); … … 1169 1275 mol = (molecules->ListOfMolecules.front())->CopyMolecule(); 1170 1276 else { 1171 eLog() << Verbose(0) << "I don't have anything to test on ... ";1277 DoeLog(0) && (eLog()<< Verbose(0) << "I don't have anything to test on ... "); 1172 1278 performCriticalExit(); 1173 1279 return; … … 1176 1282 1177 1283 // generate some KeySets 1178 Log() << Verbose(0) << "Generating KeySets." << endl;1284 DoLog(0) && (Log() << Verbose(0) << "Generating KeySets." << endl); 1179 1285 KeySet TestSets[mol->AtomCount+1]; 1180 1286 i=1; … … 1186 1292 i++; 1187 1293 } 1188 Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;1294 DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl); 1189 1295 KeySetTestPair test; 1190 1296 test = TestSets[mol->AtomCount-1].insert(Walker->nr); 1191 1297 if (test.second) { 1192 Log() << Verbose(1) << "Insertion worked?!" << endl;1298 DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl); 1193 1299 } else { 1194 Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;1300 DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl); 1195 1301 } 1196 1302 TestSets[mol->AtomCount].insert(mol->end->previous->nr); … … 1198 1304 1199 1305 // constructing Graph structure 1200 Log() << Verbose(0) << "Generating Subgraph class." << endl;1306 DoLog(0) && (Log() << Verbose(0) << "Generating Subgraph class." << endl); 1201 1307 Graph Subgraphs; 1202 1308 1203 1309 // insert KeySets into Subgraphs 1204 Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl;1310 DoLog(0) && (Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl); 1205 1311 for (int j=0;j<mol->AtomCount;j++) { 1206 1312 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.))); 1207 1313 } 1208 Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl;1314 DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl); 1209 1315 GraphTestPair test2; 1210 1316 test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.))); 1211 1317 if (test2.second) { 1212 Log() << Verbose(1) << "Insertion worked?!" << endl;1318 DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl); 1213 1319 } else { 1214 Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl;1320 DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl); 1215 1321 } 1216 1322 1217 1323 // show graphs 1218 Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl;1324 DoLog(0) && (Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl); 1219 1325 Graph::iterator A = Subgraphs.begin(); 1220 1326 while (A != Subgraphs.end()) { 1221 Log() << Verbose(0) << (*A).second.first << ": ";1327 DoLog(0) && (Log() << Verbose(0) << (*A).second.first << ": "); 1222 1328 KeySet::iterator key = (*A).first.begin(); 1223 1329 comp = -1; 1224 1330 while (key != (*A).first.end()) { 1225 1331 if ((*key) > comp) 1226 Log() << Verbose(0) << (*key) << " ";1332 DoLog(0) && (Log() << Verbose(0) << (*key) << " "); 1227 1333 else 1228 Log() << Verbose(0) << (*key) << "! ";1334 DoLog(0) && (Log() << Verbose(0) << (*key) << "! "); 1229 1335 comp = (*key); 1230 1336 key++; 1231 1337 } 1232 Log() << Verbose(0) << endl;1338 DoLog(0) && (Log() << Verbose(0) << endl); 1233 1339 A++; 1234 1340 } … … 1250 1356 1251 1357 if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) { 1252 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;1358 DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl); 1253 1359 } 1254 1360 … … 1259 1365 if (output == NULL) 1260 1366 strcpy(filename,"main_pcp_linux"); 1261 Log() << Verbose(0) << "Saving as pdb input ";1367 DoLog(0) && (Log() << Verbose(0) << "Saving as pdb input "); 1262 1368 if (configuration->SavePDB(filename, molecules)) 1263 Log() << Verbose(0) << "done." << endl;1369 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 1264 1370 else 1265 Log() << Verbose(0) << "failed." << endl;1371 DoLog(0) && (Log() << Verbose(0) << "failed." << endl); 1266 1372 1267 1373 // then save as tremolo data file … … 1270 1376 if (output == NULL) 1271 1377 strcpy(filename,"main_pcp_linux"); 1272 Log() << Verbose(0) << "Saving as tremolo data input ";1378 DoLog(0) && (Log() << Verbose(0) << "Saving as tremolo data input "); 1273 1379 if (configuration->SaveTREMOLO(filename, molecules)) 1274 Log() << Verbose(0) << "done." << endl;1380 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 1275 1381 else 1276 Log() << Verbose(0) << "failed." << endl;1382 DoLog(0) && (Log() << Verbose(0) << "failed." << endl); 1277 1383 1278 1384 // translate each to its center and merge all molecules in MoleculeListClass into this molecule … … 1294 1400 } 1295 1401 1296 Log() << Verbose(0) << "Storing configuration ... " << endl;1402 DoLog(0) && (Log() << Verbose(0) << "Storing configuration ... " << endl); 1297 1403 // get correct valence orbitals 1298 1404 mol->CalculateOrbitals(*configuration); … … 1310 1416 output.close(); 1311 1417 output.clear(); 1312 Log() << Verbose(0) << "Saving of config file ";1418 DoLog(0) && (Log() << Verbose(0) << "Saving of config file "); 1313 1419 if (configuration->Save(filename, periode, mol)) 1314 Log() << Verbose(0) << "successful." << endl;1420 DoLog(0) && (Log() << Verbose(0) << "successful." << endl); 1315 1421 else 1316 Log() << Verbose(0) << "failed." << endl;1422 DoLog(0) && (Log() << Verbose(0) << "failed." << endl); 1317 1423 1318 1424 // and save to xyz file … … 1327 1433 output.open(filename, ios::trunc); 1328 1434 } 1329 Log() << Verbose(0) << "Saving of XYZ file ";1435 DoLog(0) && (Log() << Verbose(0) << "Saving of XYZ file "); 1330 1436 if (mol->MDSteps <= 1) { 1331 1437 if (mol->OutputXYZ(&output)) 1332 Log() << Verbose(0) << "successful." << endl;1438 DoLog(0) && (Log() << Verbose(0) << "successful." << endl); 1333 1439 else 1334 Log() << Verbose(0) << "failed." << endl;1440 DoLog(0) && (Log() << Verbose(0) << "failed." << endl); 1335 1441 } else { 1336 1442 if (mol->OutputTrajectoriesXYZ(&output)) 1337 Log() << Verbose(0) << "successful." << endl;1443 DoLog(0) && (Log() << Verbose(0) << "successful." << endl); 1338 1444 else 1339 Log() << Verbose(0) << "failed." << endl;1445 DoLog(0) && (Log() << Verbose(0) << "failed." << endl); 1340 1446 } 1341 1447 output.close(); … … 1347 1453 if (output == NULL) 1348 1454 strcpy(filename,"main_pcp_linux"); 1349 Log() << Verbose(0) << "Saving as mpqc input ";1455 DoLog(0) && (Log() << Verbose(0) << "Saving as mpqc input "); 1350 1456 if (configuration->SaveMPQC(filename, mol)) 1351 Log() << Verbose(0) << "done." << endl;1457 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 1352 1458 else 1353 Log() << Verbose(0) << "failed." << endl;1459 DoLog(0) && (Log() << Verbose(0) << "failed." << endl); 1354 1460 1355 1461 if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) { 1356 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;1462 DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl); 1357 1463 } 1358 1464 … … 1384 1490 enum ConfigStatus configPresent = absent; 1385 1491 clock_t start,end; 1492 double MaxDistance = -1; 1386 1493 int argptr; 1387 1494 molecule *mol = NULL; … … 1395 1502 do { 1396 1503 if (argv[argptr][0] == '-') { 1397 Log() << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n";1504 DoLog(0) && (Log() << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n"); 1398 1505 argptr++; 1399 1506 switch(argv[argptr-1][1]) { … … 1401 1508 case 'H': 1402 1509 case '?': 1403 Log() << Verbose(0) << "MoleCuilder suite" << endl << "==================" << endl << endl; 1404 Log() << Verbose(0) << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl; 1405 Log() << Verbose(0) << "or simply " << argv[0] << " without arguments for interactive session." << endl; 1406 Log() << Verbose(0) << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl; 1407 Log() << Verbose(0) << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl; 1408 Log() << Verbose(0) << "\t-b xx xy xz yy yz zz\tCenter atoms in domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl; 1409 Log() << Verbose(0) << "\t-B xx xy xz yy yz zz\tBound atoms by domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl; 1410 Log() << Verbose(0) << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl; 1411 Log() << Verbose(0) << "\t-C\tPair Correlation analysis." << endl; 1412 Log() << Verbose(0) << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl; 1413 Log() << Verbose(0) << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl; 1414 Log() << Verbose(0) << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl; 1415 Log() << Verbose(0) << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl; 1416 Log() << Verbose(0) << "\t-f/F <dist> <order>\tFragments the molecule in BOSSANOVA manner (with/out rings compressed) and stores config files in same dir as config (return code 0 - fragmented, 2 - no fragmentation necessary)." << endl; 1417 Log() << Verbose(0) << "\t-g <file>\tParses a bond length table from the given file." << endl; 1418 Log() << Verbose(0) << "\t-h/-H/-?\tGive this help screen." << endl; 1419 Log() << Verbose(0) << "\t-L <step0> <step1> <prefix>\tStore a linear interpolation between two configurations <step0> and <step1> into single config files with prefix <prefix> and as Trajectories into the current config file." << endl; 1420 Log() << Verbose(0) << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl; 1421 Log() << Verbose(0) << "\t-M <basis>\tSetting basis to store to MPQC config files." << endl; 1422 Log() << Verbose(0) << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl; 1423 Log() << Verbose(0) << "\t-N <radius> <file>\tGet non-convex-envelope." << endl; 1424 Log() << Verbose(0) << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl; 1425 Log() << Verbose(0) << "\t-O\tCenter atoms in origin." << endl; 1426 Log() << Verbose(0) << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl; 1427 Log() << Verbose(0) << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl; 1428 Log() << Verbose(0) << "\t-r <id>\t\tRemove an atom with given id." << endl; 1429 Log() << Verbose(0) << "\t-R <id> <radius>\t\tRemove all atoms out of sphere around a given one." << endl; 1430 Log() << Verbose(0) << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl; 1431 Log() << Verbose(0) << "\t-S <file> Store temperatures from the config file in <file>." << endl; 1432 Log() << Verbose(0) << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl; 1433 Log() << Verbose(0) << "\t-T x1 x2 x3\tTranslate periodically all atoms by this vector (x1,x2,x3)." << endl; 1434 Log() << Verbose(0) << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl; 1435 Log() << Verbose(0) << "\t-v\t\tsets verbosity (more is more)." << endl; 1436 Log() << Verbose(0) << "\t-V\t\tGives version information." << endl; 1437 Log() << Verbose(0) << "Note: config files must not begin with '-' !" << endl; 1510 DoLog(0) && (Log() << Verbose(0) << "MoleCuilder suite" << endl << "==================" << endl << endl); 1511 DoLog(0) && (Log() << Verbose(0) << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl); 1512 DoLog(0) && (Log() << Verbose(0) << "or simply " << argv[0] << " without arguments for interactive session." << endl); 1513 DoLog(0) && (Log() << Verbose(0) << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl); 1514 DoLog(0) && (Log() << Verbose(0) << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl); 1515 DoLog(0) && (Log() << Verbose(0) << "\t-b xx xy xz yy yz zz\tCenter atoms in domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl); 1516 DoLog(0) && (Log() << Verbose(0) << "\t-B xx xy xz yy yz zz\tBound atoms by domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl); 1517 DoLog(0) && (Log() << Verbose(0) << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl); 1518 DoLog(0) && (Log() << Verbose(0) << "\t-C <type> [params] <output> <bin output> <BinWidth> <BinStart> <BinEnd>\tPair Correlation analysis." << endl); 1519 DoLog(0) && (Log() << Verbose(0) << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl); 1520 DoLog(0) && (Log() << Verbose(0) << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl); 1521 DoLog(0) && (Log() << Verbose(0) << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl); 1522 DoLog(0) && (Log() << Verbose(0) << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl); 1523 DoLog(0) && (Log() << Verbose(0) << "\t-f <dist> <order>\tFragments the molecule in BOSSANOVA manner (with/out rings compressed) and stores config files in same dir as config (return code 0 - fragmented, 2 - no fragmentation necessary)." << endl); 1524 DoLog(0) && (Log() << Verbose(0) << "\t-F <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl); 1525 DoLog(0) && (Log() << Verbose(0) << "\t-FF <MaxDistance> <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl); 1526 DoLog(0) && (Log() << Verbose(0) << "\t-g <file>\tParses a bond length table from the given file." << endl); 1527 DoLog(0) && (Log() << Verbose(0) << "\t-h/-H/-?\tGive this help screen." << endl); 1528 DoLog(0) && (Log() << Verbose(0) << "\t-I\t Dissect current system of molecules into a set of disconnected (subgraphs of) molecules." << endl); 1529 DoLog(0) && (Log() << Verbose(0) << "\t-j\t<path> Store all bonds to file." << endl); 1530 DoLog(0) && (Log() << Verbose(0) << "\t-J\t<path> Store adjacency per atom to file." << endl); 1531 DoLog(0) && (Log() << Verbose(0) << "\t-L <step0> <step1> <prefix>\tStore a linear interpolation between two configurations <step0> and <step1> into single config files with prefix <prefix> and as Trajectories into the current config file." << endl); 1532 DoLog(0) && (Log() << Verbose(0) << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl); 1533 DoLog(0) && (Log() << Verbose(0) << "\t-M <basis>\tSetting basis to store to MPQC config files." << endl); 1534 DoLog(0) && (Log() << Verbose(0) << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl); 1535 DoLog(0) && (Log() << Verbose(0) << "\t-N <radius> <file>\tGet non-convex-envelope." << endl); 1536 DoLog(0) && (Log() << Verbose(0) << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl); 1537 DoLog(0) && (Log() << Verbose(0) << "\t-O\tCenter atoms in origin." << endl); 1538 DoLog(0) && (Log() << Verbose(0) << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl); 1539 DoLog(0) && (Log() << Verbose(0) << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl); 1540 DoLog(0) && (Log() << Verbose(0) << "\t-r <id>\t\tRemove an atom with given id." << endl); 1541 DoLog(0) && (Log() << Verbose(0) << "\t-R <id> <radius>\t\tRemove all atoms out of sphere around a given one." << endl); 1542 DoLog(0) && (Log() << Verbose(0) << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl); 1543 DoLog(0) && (Log() << Verbose(0) << "\t-S <file> Store temperatures from the config file in <file>." << endl); 1544 DoLog(0) && (Log() << Verbose(0) << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl); 1545 DoLog(0) && (Log() << Verbose(0) << "\t-T x1 x2 x3\tTranslate periodically all atoms by this vector (x1,x2,x3)." << endl); 1546 DoLog(0) && (Log() << Verbose(0) << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl); 1547 DoLog(0) && (Log() << Verbose(0) << "\t-v\t\tsets verbosity (more is more)." << endl); 1548 DoLog(0) && (Log() << Verbose(0) << "\t-V\t\tGives version information." << endl); 1549 DoLog(0) && (Log() << Verbose(0) << "\t-X\t\tset default name of a molecule." << endl); 1550 DoLog(0) && (Log() << Verbose(0) << "Note: config files must not begin with '-' !" << endl); 1438 1551 return (1); 1439 1552 break; … … 1443 1556 } 1444 1557 setVerbosity(verbosity); 1445 Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl;1558 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl); 1446 1559 break; 1447 1560 case 'V': 1448 Log() << Verbose(0) << argv[0] << " " << VERSIONSTRING << endl;1449 Log() << Verbose(0) << "Build your own molecule position set." << endl;1561 DoLog(0) && (Log() << Verbose(0) << argv[0] << " " << VERSIONSTRING << endl); 1562 DoLog(0) && (Log() << Verbose(0) << "Build your own molecule position set." << endl); 1450 1563 return (1); 1564 break; 1565 case 'B': 1566 if (ExitFlag == 0) ExitFlag = 1; 1567 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])) ) { 1568 ExitFlag = 255; 1569 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl); 1570 performCriticalExit(); 1571 } else { 1572 SaveFlag = true; 1573 j = -1; 1574 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl); 1575 double * const cell_size = World::get()->cell_size; 1576 for (int i=0;i<6;i++) { 1577 cell_size[i] = atof(argv[argptr+i]); 1578 } 1579 argptr+=6; 1580 } 1451 1581 break; 1452 1582 case 'e': 1453 1583 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1454 eLog() << Verbose(0) << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl;1584 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl); 1455 1585 performCriticalExit(); 1456 1586 } else { 1457 Log() << Verbose(0) << "Using " << argv[argptr] << " as elements database." << endl;1587 DoLog(0) && (Log() << Verbose(0) << "Using " << argv[argptr] << " as elements database." << endl); 1458 1588 strncpy (configuration.databasepath, argv[argptr], MAXSTRINGSIZE-1); 1459 1589 argptr+=1; … … 1462 1592 case 'g': 1463 1593 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1464 eLog() << Verbose(0) << "Not enough or invalid arguments for specifying bond length table: -g <table file>" << endl;1594 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying bond length table: -g <table file>" << endl); 1465 1595 performCriticalExit(); 1466 1596 } else { 1467 1597 BondGraphFileName = argv[argptr]; 1468 Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl;1598 DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl); 1469 1599 argptr+=1; 1470 1600 } 1471 1601 break; 1472 1602 case 'n': 1473 Log() << Verbose(0) << "I won't parse trajectories." << endl;1603 DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl); 1474 1604 configuration.FastParsing = true; 1605 break; 1606 case 'X': 1607 { 1608 char **name = &(World::get()->DefaultName); 1609 delete[](*name); 1610 const int length = strlen(argv[argptr]); 1611 *name = new char[length+2]; 1612 strncpy(*name, argv[argptr], length); 1613 DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << *name << "." << endl); 1614 } 1475 1615 break; 1476 1616 default: // no match? Step on … … 1484 1624 // 3a. Parse the element database 1485 1625 if (periode->LoadPeriodentafel(configuration.databasepath)) { 1486 Log() << Verbose(0) << "Element list loaded successfully." << endl;1626 DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl); 1487 1627 //periode->Output(); 1488 1628 } else { 1489 Log() << Verbose(0) << "Element list loading failed." << endl;1629 DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl); 1490 1630 return 1; 1491 1631 } … … 1493 1633 if (argv[1][0] != '-') { 1494 1634 // simply create a new molecule, wherein the config file is loaded and the manipulation takes place 1495 Log() << Verbose(0) << "Config file given." << endl;1635 DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl); 1496 1636 test.open(argv[1], ios::in); 1497 1637 if (test == NULL) { … … 1499 1639 output.open(argv[1], ios::out); 1500 1640 if (output == NULL) { 1501 Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl;1641 DoLog(1) && (Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl); 1502 1642 configPresent = absent; 1503 1643 } else { 1504 Log() << Verbose(0) << "Empty configuration file." << endl;1644 DoLog(0) && (Log() << Verbose(0) << "Empty configuration file." << endl); 1505 1645 ConfigFileName = argv[1]; 1506 1646 configPresent = empty; … … 1510 1650 test.close(); 1511 1651 ConfigFileName = argv[1]; 1512 Log() << Verbose(1) << "Specified config file found, parsing ... ";1652 DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... "); 1513 1653 switch (configuration.TestSyntax(ConfigFileName, periode)) { 1514 1654 case 1: 1515 Log() << Verbose(0) << "new syntax." << endl;1655 DoLog(0) && (Log() << Verbose(0) << "new syntax." << endl); 1516 1656 configuration.Load(ConfigFileName, BondGraphFileName, periode, molecules); 1517 1657 configPresent = present; 1518 1658 break; 1519 1659 case 0: 1520 Log() << Verbose(0) << "old syntax." << endl;1660 DoLog(0) && (Log() << Verbose(0) << "old syntax." << endl); 1521 1661 configuration.LoadOld(ConfigFileName, BondGraphFileName, periode, molecules); 1522 1662 configPresent = present; 1523 1663 break; 1524 1664 default: 1525 Log() << Verbose(0) << "Unknown syntax or empty, yet present file." << endl;1665 DoLog(0) && (Log() << Verbose(0) << "Unknown syntax or empty, yet present file." << endl); 1526 1666 configPresent = empty; 1527 1667 } … … 1546 1686 if (configuration.BG == NULL) { 1547 1687 configuration.BG = new BondGraph(configuration.GetIsAngstroem()); 1548 if (( BondGraphFileName.empty()) && (configuration.BG->LoadBondLengthTable(BondGraphFileName))) {1549 Log() << Verbose(0) << "Bond length table loaded successfully." << endl;1688 if ((!BondGraphFileName.empty()) && (configuration.BG->LoadBondLengthTable(BondGraphFileName))) { 1689 DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl); 1550 1690 } else { 1551 eLog() << Verbose(1) << "Bond length table loading failed." << endl;1691 DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl); 1552 1692 } 1553 1693 } … … 1556 1696 argptr = 1; 1557 1697 do { 1558 Log() << Verbose(0) << "Current Command line argument: " << argv[argptr] << "." << endl;1698 DoLog(0) && (Log() << Verbose(0) << "Current Command line argument: " << argv[argptr] << "." << endl); 1559 1699 if (argv[argptr][0] == '-') { 1560 1700 argptr++; … … 1565 1705 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1566 1706 ExitFlag = 255; 1567 eLog() << Verbose(0) << "Not enough arguments for parsing: -p <xyz file>" << endl;1707 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough arguments for parsing: -p <xyz file>" << endl); 1568 1708 performCriticalExit(); 1569 1709 } else { 1570 1710 SaveFlag = true; 1571 Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl;1711 DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl); 1572 1712 if (!mol->AddXYZFile(argv[argptr])) 1573 Log() << Verbose(2) << "File not found." << endl;1713 DoLog(2) && (Log() << Verbose(2) << "File not found." << endl); 1574 1714 else { 1575 Log() << Verbose(2) << "File found and parsed." << endl; 1576 // @TODO rather do the dissection afterwards 1577 // mol->SetNameFromFilename(argv[argptr]); 1578 // molecules->ListOfMolecules.remove(mol); 1579 // molecules->DissectMoleculeIntoConnectedSubgraphs(mol,&configuration); 1580 // delete(mol); 1581 // if (molecules->ListOfMolecules.size() != 0) { 1582 // for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 1583 // if ((*ListRunner)->ActiveFlag) { 1584 // mol = *ListRunner; 1585 // break; 1586 // } 1587 // } 1715 DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl); 1588 1716 configPresent = present; 1589 1717 } … … 1594 1722 if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3]))) { 1595 1723 ExitFlag = 255; 1596 eLog() << Verbose(0) << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl;1724 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl); 1597 1725 performCriticalExit(); 1598 1726 } else { 1599 1727 SaveFlag = true; 1600 Log() << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), ";1728 DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), "); 1601 1729 first = new atom; 1602 1730 first->type = periode->FindElement(atoi(argv[argptr])); 1603 1731 if (first->type != NULL) 1604 Log() << Verbose(2) << "found element " << first->type->name << endl;1732 DoLog(2) && (Log() << Verbose(2) << "found element " << first->type->name << endl); 1605 1733 for (int i=NDIM;i--;) 1606 1734 first->x.x[i] = atof(argv[argptr+1+i]); … … 1610 1738 configPresent = present; 1611 1739 } else 1612 eLog() << Verbose(1) << "Could not find the specified element." << endl;1740 DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl); 1613 1741 argptr+=4; 1614 1742 } … … 1623 1751 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1624 1752 ExitFlag = 255; 1625 eLog() << Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl;1753 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl); 1626 1754 performCriticalExit(); 1627 1755 } else { 1628 1756 configuration.basis = argv[argptr]; 1629 Log() << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl;1757 DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl); 1630 1758 argptr+=1; 1631 1759 } … … 1634 1762 if (ExitFlag == 0) ExitFlag = 1; 1635 1763 { 1636 Log() << Verbose(1) << "Depth-First-Search Analysis." << endl;1764 DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl); 1637 1765 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 1638 1766 int *MinimumRingSize = new int[mol->AtomCount]; … … 1664 1792 //argptr+=1; 1665 1793 break; 1794 case 'I': 1795 DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl); 1796 // @TODO rather do the dissection afterwards 1797 molecules->DissectMoleculeIntoConnectedSubgraphs(periode, &configuration); 1798 mol = NULL; 1799 if (molecules->ListOfMolecules.size() != 0) { 1800 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 1801 if ((*ListRunner)->ActiveFlag) { 1802 mol = *ListRunner; 1803 break; 1804 } 1805 } 1806 if ((mol == NULL) && (!molecules->ListOfMolecules.empty())) { 1807 mol = *(molecules->ListOfMolecules.begin()); 1808 if (mol != NULL) 1809 mol->ActiveFlag = true; 1810 } 1811 break; 1666 1812 case 'C': 1667 if (ExitFlag == 0) ExitFlag = 1; 1668 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr][0] == '-') || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-')) { 1669 ExitFlag = 255; 1670 eLog() << Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C <Z> <output> <bin output>" << endl; 1671 performCriticalExit(); 1672 } else { 1673 SaveFlag = false; 1674 ofstream output(argv[argptr+1]); 1675 ofstream binoutput(argv[argptr+2]); 1676 const double radius = 5.; 1677 1678 // get the boundary 1679 class molecule *Boundary = NULL; 1680 class Tesselation *TesselStruct = NULL; 1681 const LinkedCell *LCList = NULL; 1682 // find biggest molecule 1683 int counter = 0; 1684 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 1685 if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) { 1686 Boundary = *BigFinder; 1813 { 1814 int ranges[3] = {1, 1, 1}; 1815 bool periodic = (argv[argptr-1][2] =='p'); 1816 if (ExitFlag == 0) ExitFlag = 1; 1817 if ((argptr >= argc)) { 1818 ExitFlag = 255; 1819 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); 1820 performCriticalExit(); 1821 } else { 1822 switch(argv[argptr][0]) { 1823 case 'E': 1824 { 1825 if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (!IsValidNumber(argv[argptr+2])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-')) { 1826 ExitFlag = 255; 1827 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C E <Z1> <Z2> <output> <bin output>" << endl); 1828 performCriticalExit(); 1829 } else { 1830 ofstream output(argv[argptr+3]); 1831 ofstream binoutput(argv[argptr+4]); 1832 const double BinStart = atof(argv[argptr+5]); 1833 const double BinEnd = atof(argv[argptr+6]); 1834 1835 element *elemental = periode->FindElement((const int) atoi(argv[argptr+1])); 1836 element *elemental2 = periode->FindElement((const int) atoi(argv[argptr+2])); 1837 PairCorrelationMap *correlationmap = NULL; 1838 if (periodic) 1839 correlationmap = PeriodicPairCorrelation(molecules, elemental, elemental2, ranges); 1840 else 1841 correlationmap = PairCorrelation(molecules, elemental, elemental2); 1842 //OutputCorrelationToSurface(&output, correlationmap); 1843 BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd ); 1844 OutputCorrelation ( &binoutput, binmap ); 1845 output.close(); 1846 binoutput.close(); 1847 delete(binmap); 1848 delete(correlationmap); 1849 argptr+=7; 1850 } 1851 } 1852 break; 1853 1854 case 'P': 1855 { 1856 if ((argptr+8 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+7])) || (!IsValidNumber(argv[argptr+8])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-') || (argv[argptr+5][0] == '-') || (argv[argptr+6][0] == '-')) { 1857 ExitFlag = 255; 1858 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C P <Z1> <x> <y> <z> <output> <bin output>" << endl); 1859 performCriticalExit(); 1860 } else { 1861 ofstream output(argv[argptr+5]); 1862 ofstream binoutput(argv[argptr+6]); 1863 const double BinStart = atof(argv[argptr+7]); 1864 const double BinEnd = atof(argv[argptr+8]); 1865 1866 element *elemental = periode->FindElement((const int) atoi(argv[argptr+1])); 1867 Vector *Point = new Vector((const double) atof(argv[argptr+1]),(const double) atof(argv[argptr+2]),(const double) atof(argv[argptr+3])); 1868 CorrelationToPointMap *correlationmap = NULL; 1869 if (periodic) 1870 correlationmap = PeriodicCorrelationToPoint(molecules, elemental, Point, ranges); 1871 else 1872 correlationmap = CorrelationToPoint(molecules, elemental, Point); 1873 //OutputCorrelationToSurface(&output, correlationmap); 1874 BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd ); 1875 OutputCorrelation ( &binoutput, binmap ); 1876 output.close(); 1877 binoutput.close(); 1878 delete(Point); 1879 delete(binmap); 1880 delete(correlationmap); 1881 argptr+=9; 1882 } 1883 } 1884 break; 1885 1886 case 'S': 1887 { 1888 if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-')) { 1889 ExitFlag = 255; 1890 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C S <Z> <output> <bin output> <BinWidth> <BinStart> <BinEnd>" << endl); 1891 performCriticalExit(); 1892 } else { 1893 ofstream output(argv[argptr+2]); 1894 ofstream binoutput(argv[argptr+3]); 1895 const double radius = 4.; 1896 const double BinWidth = atof(argv[argptr+4]); 1897 const double BinStart = atof(argv[argptr+5]); 1898 const double BinEnd = atof(argv[argptr+6]); 1899 double LCWidth = 20.; 1900 if (BinEnd > 0) { 1901 if (BinEnd > 2.*radius) 1902 LCWidth = BinEnd; 1903 else 1904 LCWidth = 2.*radius; 1905 } 1906 1907 // get the boundary 1908 class molecule *Boundary = NULL; 1909 class Tesselation *TesselStruct = NULL; 1910 const LinkedCell *LCList = NULL; 1911 // find biggest molecule 1912 int counter = 0; 1913 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 1914 if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) { 1915 Boundary = *BigFinder; 1916 } 1917 counter++; 1918 } 1919 bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives"); 1920 counter = 0; 1921 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 1922 Actives[counter++] = (*BigFinder)->ActiveFlag; 1923 (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true; 1924 } 1925 LCList = new LinkedCell(Boundary, LCWidth); 1926 element *elemental = periode->FindElement((const int) atoi(argv[argptr+1])); 1927 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL); 1928 CorrelationToSurfaceMap *surfacemap = NULL; 1929 if (periodic) 1930 surfacemap = PeriodicCorrelationToSurface( molecules, elemental, TesselStruct, LCList, ranges); 1931 else 1932 surfacemap = CorrelationToSurface( molecules, elemental, TesselStruct, LCList); 1933 OutputCorrelationToSurface(&output, surfacemap); 1934 // check whether radius was appropriate 1935 { 1936 double start; double end; 1937 GetMinMax( surfacemap, start, end); 1938 if (LCWidth < end) 1939 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); 1940 } 1941 BinPairMap *binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd ); 1942 OutputCorrelation ( &binoutput, binmap ); 1943 output.close(); 1944 binoutput.close(); 1945 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) 1946 (*BigFinder)->ActiveFlag = Actives[counter++]; 1947 Free(&Actives); 1948 delete(LCList); 1949 delete(TesselStruct); 1950 delete(binmap); 1951 delete(surfacemap); 1952 argptr+=7; 1953 } 1954 } 1955 break; 1956 1957 default: 1958 ExitFlag = 255; 1959 DoeLog(0) && (eLog()<< Verbose(0) << "Invalid type given for pair correlation analysis: -C <type: E/P/S> [more params] <output> <bin output>" << endl); 1960 performCriticalExit(); 1961 break; 1687 1962 } 1688 counter++;1689 1963 } 1690 bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives"); 1691 counter = 0; 1692 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 1693 Actives[counter] = (*BigFinder)->ActiveFlag; 1694 (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true; 1695 } 1696 LCList = new LinkedCell(Boundary, 2.*radius); 1697 element *elemental = periode->FindElement((const int) atoi(argv[argptr])); 1698 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL); 1699 int ranges[NDIM] = {1,1,1}; 1700 CorrelationToSurfaceMap *surfacemap = PeriodicCorrelationToSurface( molecules, elemental, TesselStruct, LCList, ranges ); 1701 BinPairMap *binmap = BinData( surfacemap, 0.5, 0., 0. ); 1702 OutputCorrelation ( &binoutput, binmap ); 1703 output.close(); 1704 binoutput.close(); 1705 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) 1706 (*BigFinder)->ActiveFlag = Actives[counter]; 1707 Free(&Actives); 1708 delete(LCList); 1709 delete(TesselStruct); 1710 argptr+=3; 1711 } 1712 break; 1964 break; 1965 } 1713 1966 case 'E': 1714 1967 if (ExitFlag == 0) ExitFlag = 1; 1715 1968 if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) { 1716 1969 ExitFlag = 255; 1717 eLog() << Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl;1970 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl); 1718 1971 performCriticalExit(); 1719 1972 } else { 1720 1973 SaveFlag = true; 1721 Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl;1974 DoLog(1) && (Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl); 1722 1975 first = mol->FindAtom(atoi(argv[argptr])); 1723 1976 first->type = periode->FindElement(atoi(argv[argptr+1])); … … 1727 1980 case 'F': 1728 1981 if (ExitFlag == 0) ExitFlag = 1; 1729 if (argptr+5 >=argc) { 1982 MaxDistance = -1; 1983 if (argv[argptr-1][2] == 'F') { // option is -FF? 1984 // fetch first argument as max distance to surface 1985 MaxDistance = atof(argv[argptr++]); 1986 DoLog(0) && (Log() << Verbose(0) << "Filling with maximum layer distance of " << MaxDistance << "." << endl); 1987 } 1988 if ((argptr+7 >=argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (!IsValidNumber(argv[argptr+7]))) { 1730 1989 ExitFlag = 255; 1731 eLog() << Verbose(0) << "Not enough or invalid arguments given for filling box with water: -F <dist_x> <dist_y> <dist_z> <randatom> <randmol> <DoRotate>" << endl;1990 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for filling box with water: -F <xyz of filler> <dist_x> <dist_y> <dist_z> <boundary> <randatom> <randmol> <DoRotate>" << endl); 1732 1991 performCriticalExit(); 1733 1992 } else { 1734 1993 SaveFlag = true; 1735 Log() << Verbose(1) << "Filling Box with water molecules." << endl;1994 DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules." << endl); 1736 1995 // construct water molecule 1737 molecule *filler = new molecule(periode);; 1996 molecule *filler = new molecule(periode); 1997 if (!filler->AddXYZFile(argv[argptr])) { 1998 DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << argv[argptr] << "." << endl); 1999 } 2000 filler->SetNameFromFilename(argv[argptr]); 2001 configuration.BG->ConstructBondGraph(filler); 1738 2002 molecule *Filling = NULL; 1739 atom *second = NULL, *third = NULL;1740 first = new atom();1741 first->type = periode->FindElement(1);1742 first->x.Init(0.441, -0.143, 0.);1743 filler->AddAtom(first);1744 second = new atom();1745 second->type = periode->FindElement(1);1746 second->x.Init(-0.464, 1.137, 0.0);1747 filler->AddAtom(second);1748 third = new atom();1749 third->type = periode->FindElement(8);1750 third->x.Init(-0.464, 0.177, 0.);1751 filler->AddAtom(third);1752 filler->AddBond(first, third, 1);1753 filler->AddBond(second, third, 1);1754 2003 // call routine 1755 2004 double distance[NDIM]; 1756 2005 for (int i=0;i<NDIM;i++) 1757 distance[i] = atof(argv[argptr+i ]);1758 Filling = FillBoxWithMolecule(molecules, filler, configuration, distance, atof(argv[argptr+3]), atof(argv[argptr+4]), atoi(argv[argptr+5]));2006 distance[i] = atof(argv[argptr+i+1]); 2007 Filling = FillBoxWithMolecule(molecules, filler, configuration, MaxDistance, distance, atof(argv[argptr+4]), atof(argv[argptr+5]), atof(argv[argptr+6]), atoi(argv[argptr+7])); 1759 2008 if (Filling != NULL) { 2009 Filling->ActiveFlag = false; 1760 2010 molecules->insert(Filling); 1761 2011 } … … 1768 2018 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1769 2019 ExitFlag =255; 1770 eLog() << Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl;2020 DoeLog(0) && (eLog()<< Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl); 1771 2021 performCriticalExit(); 1772 2022 } else { 1773 Log() << Verbose(0) << "Parsing bonds from " << argv[argptr] << "." << endl;2023 DoLog(0) && (Log() << Verbose(0) << "Parsing bonds from " << argv[argptr] << "." << endl); 1774 2024 ifstream *input = new ifstream(argv[argptr]); 1775 2025 mol->CreateAdjacencyListFromDbondFile(input); … … 1778 2028 } 1779 2029 break; 2030 2031 case 'J': 2032 if (ExitFlag == 0) ExitFlag = 1; 2033 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 2034 ExitFlag =255; 2035 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of adjacency file: -j <path>" << endl); 2036 performCriticalExit(); 2037 } else { 2038 DoLog(0) && (Log() << Verbose(0) << "Storing adjacency to path " << argv[argptr] << "." << endl); 2039 configuration.BG->ConstructBondGraph(mol); 2040 mol->StoreAdjacencyToFile(NULL, argv[argptr]); 2041 argptr+=1; 2042 } 2043 break; 2044 2045 case 'j': 2046 if (ExitFlag == 0) ExitFlag = 1; 2047 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 2048 ExitFlag =255; 2049 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of bonds file: -j <path>" << endl); 2050 performCriticalExit(); 2051 } else { 2052 DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << argv[argptr] << "." << endl); 2053 configuration.BG->ConstructBondGraph(mol); 2054 mol->StoreBondsToFile(NULL, argv[argptr]); 2055 argptr+=1; 2056 } 2057 break; 2058 1780 2059 case 'N': 1781 2060 if (ExitFlag == 0) ExitFlag = 1; 1782 2061 if ((argptr+1 >= argc) || (argv[argptr+1][0] == '-')){ 1783 2062 ExitFlag = 255; 1784 eLog() << Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl;2063 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl); 1785 2064 performCriticalExit(); 1786 2065 } else { … … 1790 2069 //string filename(argv[argptr+1]); 1791 2070 //filename.append(".csv"); 1792 Log() << Verbose(0) << "Evaluating non-convex envelope of biggest molecule.";1793 Log() << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl;2071 DoLog(0) && (Log() << Verbose(0) << "Evaluating non-convex envelope of biggest molecule."); 2072 DoLog(1) && (Log() << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl); 1794 2073 // find biggest molecule 1795 2074 int counter = 0; … … 1801 2080 counter++; 1802 2081 } 1803 Log() << Verbose(1) << "Biggest molecule has " << Boundary->AtomCount << " atoms." << endl;2082 DoLog(1) && (Log() << Verbose(1) << "Biggest molecule has " << Boundary->AtomCount << " atoms." << endl); 1804 2083 start = clock(); 1805 2084 LCList = new LinkedCell(Boundary, atof(argv[argptr])*2.); … … 1808 2087 //FindDistributionOfEllipsoids(T, &LCList, N, number, filename.c_str()); 1809 2088 end = clock(); 1810 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;2089 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl); 1811 2090 delete(LCList); 1812 2091 delete(T); … … 1818 2097 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1819 2098 ExitFlag = 255; 1820 eLog() << Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file>" << endl;2099 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file>" << endl); 1821 2100 performCriticalExit(); 1822 2101 } else { 1823 Log() << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl;2102 DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl); 1824 2103 ofstream *output = new ofstream(argv[argptr], ios::trunc); 1825 2104 if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps)) 1826 Log() << Verbose(2) << "File could not be written." << endl;2105 DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl); 1827 2106 else 1828 Log() << Verbose(2) << "File stored." << endl;2107 DoLog(2) && (Log() << Verbose(2) << "File stored." << endl); 1829 2108 output->close(); 1830 2109 delete(output); … … 1836 2115 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1837 2116 ExitFlag = 255; 1838 eLog() << Verbose(0) << "Not enough or invalid arguments given for storing tempature: -L <step0> <step1> <prefix> <identity mapping?>" << endl;2117 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -L <step0> <step1> <prefix> <identity mapping?>" << endl); 1839 2118 performCriticalExit(); 1840 2119 } else { 1841 2120 SaveFlag = true; 1842 Log() << Verbose(1) << "Linear interpolation between configuration " << argv[argptr] << " and " << argv[argptr+1] << "." << endl;2121 DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << argv[argptr] << " and " << argv[argptr+1] << "." << endl); 1843 2122 if (atoi(argv[argptr+3]) == 1) 1844 Log() << Verbose(1) << "Using Identity for the permutation map." << endl;2123 DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl); 1845 2124 if (!mol->LinearInterpolationBetweenConfiguration(atoi(argv[argptr]), atoi(argv[argptr+1]), argv[argptr+2], configuration, atoi(argv[argptr+3])) == 1 ? true : false) 1846 Log() << Verbose(2) << "Could not store " << argv[argptr+2] << " files." << endl;2125 DoLog(2) && (Log() << Verbose(2) << "Could not store " << argv[argptr+2] << " files." << endl); 1847 2126 else 1848 Log() << Verbose(2) << "Steps created and " << argv[argptr+2] << " files stored." << endl;2127 DoLog(2) && (Log() << Verbose(2) << "Steps created and " << argv[argptr+2] << " files stored." << endl); 1849 2128 argptr+=4; 1850 2129 } … … 1854 2133 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1855 2134 ExitFlag = 255; 1856 eLog() << Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl;2135 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl); 1857 2136 performCriticalExit(); 1858 2137 } else { 1859 2138 SaveFlag = true; 1860 Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl;2139 DoLog(1) && (Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl); 1861 2140 if (!mol->VerletForceIntegration(argv[argptr], configuration)) 1862 Log() << Verbose(2) << "File not found." << endl;2141 DoLog(2) && (Log() << Verbose(2) << "File not found." << endl); 1863 2142 else 1864 Log() << Verbose(2) << "File found and parsed." << endl;2143 DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl); 1865 2144 argptr+=1; 1866 2145 } … … 1870 2149 if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) { 1871 2150 ExitFlag = 255; 1872 eLog() << Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl;2151 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl); 1873 2152 performCriticalExit(); 1874 2153 } else { 1875 2154 SaveFlag = true; 1876 Log() << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl;2155 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl); 1877 2156 double tmp1 = atof(argv[argptr+1]); 1878 2157 atom *third = mol->FindAtom(atoi(argv[argptr])); … … 1887 2166 } 1888 2167 } else { 1889 eLog() << Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl;2168 DoeLog(1) && (eLog()<< Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl); 1890 2169 } 1891 2170 argptr+=2; … … 1896 2175 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 1897 2176 ExitFlag = 255; 1898 eLog() << Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl;2177 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl); 1899 2178 performCriticalExit(); 1900 2179 } else { 1901 2180 if (ExitFlag == 0) ExitFlag = 1; 1902 2181 SaveFlag = true; 1903 Log() << Verbose(1) << "Translating all ions by given vector." << endl;2182 DoLog(1) && (Log() << Verbose(1) << "Translating all ions by given vector." << endl); 1904 2183 for (int i=NDIM;i--;) 1905 2184 x.x[i] = atof(argv[argptr+i]); … … 1912 2191 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 1913 2192 ExitFlag = 255; 1914 eLog() << Verbose(0) << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl;2193 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl); 1915 2194 performCriticalExit(); 1916 2195 } else { 1917 2196 if (ExitFlag == 0) ExitFlag = 1; 1918 2197 SaveFlag = true; 1919 Log() << Verbose(1) << "Translating all ions periodically by given vector." << endl;2198 DoLog(1) && (Log() << Verbose(1) << "Translating all ions periodically by given vector." << endl); 1920 2199 for (int i=NDIM;i--;) 1921 2200 x.x[i] = atof(argv[argptr+i]); … … 1928 2207 if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 1929 2208 ExitFlag = 255; 1930 eLog() << Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl;2209 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl); 1931 2210 performCriticalExit(); 1932 2211 } else { 1933 2212 SaveFlag = true; 1934 2213 j = -1; 1935 Log() << Verbose(1) << "Scaling all ion positions by factor." << endl;2214 DoLog(1) && (Log() << Verbose(1) << "Scaling all ion positions by factor." << endl); 1936 2215 factor = new double[NDIM]; 1937 2216 factor[0] = atof(argv[argptr]); … … 1939 2218 factor[2] = atof(argv[argptr+2]); 1940 2219 mol->Scale((const double ** const)&factor); 2220 double * const cell_size = World::get()->cell_size; 1941 2221 for (int i=0;i<NDIM;i++) { 1942 2222 j += i+1; 1943 2223 x.x[i] = atof(argv[NDIM+i]); 1944 mol->cell_size[j]*=factor[i];2224 cell_size[j]*=factor[i]; 1945 2225 } 1946 2226 delete[](factor); … … 1952 2232 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])) ) { 1953 2233 ExitFlag = 255; 1954 eLog() << Verbose(0) << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl;2234 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl); 1955 2235 performCriticalExit(); 1956 2236 } else { 1957 2237 SaveFlag = true; 1958 2238 j = -1; 1959 Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 2239 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl); 2240 double * const cell_size = World::get()->cell_size; 1960 2241 for (int i=0;i<6;i++) { 1961 mol->cell_size[i] = atof(argv[argptr+i]);2242 cell_size[i] = atof(argv[argptr+i]); 1962 2243 } 1963 2244 // center … … 1970 2251 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])) ) { 1971 2252 ExitFlag = 255; 1972 eLog() << Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl;2253 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl); 1973 2254 performCriticalExit(); 1974 2255 } else { 1975 2256 SaveFlag = true; 1976 2257 j = -1; 1977 Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 2258 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl); 2259 double * const cell_size = World::get()->cell_size; 1978 2260 for (int i=0;i<6;i++) { 1979 mol->cell_size[i] = atof(argv[argptr+i]);2261 cell_size[i] = atof(argv[argptr+i]); 1980 2262 } 1981 2263 // center … … 1988 2270 if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 1989 2271 ExitFlag = 255; 1990 eLog() << Verbose(0) << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl;2272 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl); 1991 2273 performCriticalExit(); 1992 2274 } else { 1993 2275 SaveFlag = true; 1994 2276 j = -1; 1995 Log() << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl;2277 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl); 1996 2278 // make every coordinate positive 1997 2279 mol->CenterEdge(&x); … … 1999 2281 mol->SetBoxDimension(&x); 2000 2282 // translate each coordinate by boundary 2283 double * const cell_size = World::get()->cell_size; 2001 2284 j=-1; 2002 2285 for (int i=0;i<NDIM;i++) { 2003 2286 j += i+1; 2004 2287 x.x[i] = atof(argv[argptr+i]); 2005 mol->cell_size[j] += x.x[i]*2.;2288 cell_size[j] += x.x[i]*2.; 2006 2289 } 2007 2290 mol->Translate((const Vector *)&x); … … 2012 2295 if (ExitFlag == 0) ExitFlag = 1; 2013 2296 SaveFlag = true; 2014 Log() << Verbose(1) << "Centering atoms on edge and setting box dimensions." << endl;2297 DoLog(1) && (Log() << Verbose(1) << "Centering atoms on edge and setting box dimensions." << endl); 2015 2298 x.Zero(); 2016 2299 mol->CenterEdge(&x); … … 2022 2305 if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr]))) { 2023 2306 ExitFlag = 255; 2024 eLog() << Verbose(0) << "Not enough or invalid arguments given for removing atoms: -r <id>" << endl;2307 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -r <id>" << endl); 2025 2308 performCriticalExit(); 2026 2309 } else { 2027 2310 SaveFlag = true; 2028 Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl;2311 DoLog(1) && (Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl); 2029 2312 atom *first = mol->FindAtom(atoi(argv[argptr])); 2030 2313 mol->RemoveAtom(first); … … 2036 2319 if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) { 2037 2320 ExitFlag = 255; 2038 eLog() << Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl;2321 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl); 2039 2322 performCriticalExit(); 2040 2323 } else { 2041 Log() << Verbose(0) << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl;2042 Log() << Verbose(0) << "Creating connection matrix..." << endl;2324 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl); 2325 DoLog(0) && (Log() << Verbose(0) << "Creating connection matrix..." << endl); 2043 2326 start = clock(); 2044 2327 mol->CreateAdjacencyList(atof(argv[argptr++]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 2045 Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;2328 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl); 2046 2329 if (mol->first->next != mol->last) { 2047 2330 ExitFlag = mol->FragmentMolecule(atoi(argv[argptr]), &configuration); 2048 2331 } 2049 2332 end = clock(); 2050 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;2333 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl); 2051 2334 argptr+=2; 2052 2335 } … … 2056 2339 j = atoi(argv[argptr++]); 2057 2340 if ((j<0) || (j>1)) { 2058 eLog() << Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl;2341 DoeLog(1) && (eLog()<< Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl); 2059 2342 j = 0; 2060 2343 } 2061 2344 if (j) { 2062 2345 SaveFlag = true; 2063 Log() << Verbose(0) << "Converting to prinicipal axis system." << endl;2346 DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl); 2064 2347 } else 2065 Log() << Verbose(0) << "Evaluating prinicipal axis." << endl;2348 DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl); 2066 2349 mol->PrincipalAxisSystem((bool)j); 2067 2350 break; … … 2070 2353 if ((argptr+1 >= argc) || (argv[argptr][0] == '-')){ 2071 2354 ExitFlag = 255; 2072 eLog() << Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <convex output file> <non-convex output file>" << endl;2355 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <convex output file> <non-convex output file>" << endl); 2073 2356 performCriticalExit(); 2074 2357 } else { 2075 2358 class Tesselation *TesselStruct = NULL; 2076 2359 const LinkedCell *LCList = NULL; 2077 Log() << Verbose(0) << "Evaluating volume of the convex envelope.";2078 Log() << Verbose(1) << "Storing tecplot convex data in " << argv[argptr] << "." << endl;2079 Log() << Verbose(1) << "Storing tecplot non-convex data in " << argv[argptr+1] << "." << endl;2360 DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope."); 2361 DoLog(1) && (Log() << Verbose(1) << "Storing tecplot convex data in " << argv[argptr] << "." << endl); 2362 DoLog(1) && (Log() << Verbose(1) << "Storing tecplot non-convex data in " << argv[argptr+1] << "." << endl); 2080 2363 LCList = new LinkedCell(mol, 10.); 2081 2364 //FindConvexBorder(mol, LCList, argv[argptr]); … … 2084 2367 double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, argv[argptr]); 2085 2368 double clustervolume = VolumeOfConvexEnvelope(TesselStruct, &configuration); 2086 Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl;2087 Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl;2369 DoLog(0) && (Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl); 2370 DoLog(0) && (Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl); 2088 2371 delete(TesselStruct); 2089 2372 delete(LCList); … … 2095 2378 if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) { 2096 2379 ExitFlag = 255; 2097 eLog() << Verbose(0) << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl;2380 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl); 2098 2381 performCriticalExit(); 2099 2382 } else { 2100 2383 volume = atof(argv[argptr++]); 2101 Log() << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl;2384 DoLog(0) && (Log() << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl); 2102 2385 } 2103 2386 case 'u': … … 2106 2389 if (volume != -1) 2107 2390 ExitFlag = 255; 2108 eLog() << Verbose(0) << "Not enough arguments given for suspension: -u <density>" << endl;2391 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension: -u <density>" << endl); 2109 2392 performCriticalExit(); 2110 2393 } else { 2111 2394 double density; 2112 2395 SaveFlag = true; 2113 Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.";2396 DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water."); 2114 2397 density = atof(argv[argptr++]); 2115 2398 if (density < 1.0) { 2116 eLog() << Verbose(1) << "Density must be greater than 1.0g/cm^3 !" << endl;2399 DoeLog(1) && (eLog()<< Verbose(1) << "Density must be greater than 1.0g/cm^3 !" << endl); 2117 2400 density = 1.3; 2118 2401 } … … 2120 2403 // repetition[i] = atoi(argv[argptr++]); 2121 2404 // if (repetition[i] < 1) 2122 // eLog() << Verbose(1) << "repetition value must be greater 1!" << endl;2405 // DoeLog(1) && (eLog()<< Verbose(1) << "repetition value must be greater 1!" << endl); 2123 2406 // repetition[i] = 1; 2124 2407 // } … … 2130 2413 if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 2131 2414 ExitFlag = 255; 2132 eLog() << Verbose(0) << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl;2415 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl); 2133 2416 performCriticalExit(); 2134 2417 } else { 2135 2418 SaveFlag = true; 2419 double * const cell_size = World::get()->cell_size; 2136 2420 for (int axis = 1; axis <= NDIM; axis++) { 2137 2421 int faktor = atoi(argv[argptr++]); … … 2140 2424 Vector ** vectors; 2141 2425 if (faktor < 1) { 2142 eLog() << Verbose(1) << "Repetition factor mus be greater than 1!" << endl;2426 DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor mus be greater than 1!" << endl); 2143 2427 faktor = 1; 2144 2428 } … … 2157 2441 } 2158 2442 if (count != j) 2159 eLog() << Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;2443 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl); 2160 2444 x.Zero(); 2161 2445 y.Zero(); 2162 y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude2446 y.x[abs(axis)-1] = cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude 2163 2447 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times 2164 2448 x.AddVector(&y); // per factor one cell width further … … 2181 2465 mol->Translate(&x); 2182 2466 } 2183 mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;2467 cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor; 2184 2468 } 2185 2469 } … … 2198 2482 } else { // no arguments, hence scan the elements db 2199 2483 if (periode->LoadPeriodentafel(configuration.databasepath)) 2200 Log() << Verbose(0) << "Element list loaded successfully." << endl;2484 DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl); 2201 2485 else 2202 Log() << Verbose(0) << "Element list loading failed." << endl;2486 DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl); 2203 2487 configuration.RetrieveConfigPathAndName("main_pcp_linux"); 2204 2488 } … … 2221 2505 char *ConfigFileName = NULL; 2222 2506 int j; 2507 2508 cout << ESPACKVersion << endl; 2509 2510 DoLog(1) && (Log() << Verbose(1) << "test" << endl); 2511 DoLog(3) && (Log() << Verbose(1) << "test"); 2223 2512 2224 2513 setVerbosity(0); … … 2248 2537 if (molecules->ListOfMolecules.size() == 0) { 2249 2538 mol = new molecule(periode); 2250 if (mol->cell_size[0] == 0.) { 2251 Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl; 2539 double * const cell_size = World::get()->cell_size; 2540 if (cell_size[0] == 0.) { 2541 DoLog(0) && (Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl); 2252 2542 for (int i=0;i<6;i++) { 2253 Log() << Verbose(1) << "Cell size" << i << ": ";2254 cin >> mol->cell_size[i];2543 DoLog(1) && (Log() << Verbose(1) << "Cell size" << i << ": "); 2544 cin >> cell_size[i]; 2255 2545 } 2256 2546 } … … 2262 2552 2263 2553 // now the main construction loop 2264 Log() << Verbose(0) << endl << "Now comes the real construction..." << endl;2554 DoLog(0) && (Log() << Verbose(0) << endl << "Now comes the real construction..." << endl); 2265 2555 do { 2266 Log() << Verbose(0) << endl << endl;2267 Log() << Verbose(0) << "============Molecule list=======================" << endl;2556 DoLog(0) && (Log() << Verbose(0) << endl << endl); 2557 DoLog(0) && (Log() << Verbose(0) << "============Molecule list=======================" << endl); 2268 2558 molecules->Enumerate((ofstream *)&cout); 2269 Log() << Verbose(0) << "============Menu===============================" << endl;2270 Log() << Verbose(0) << "a - set molecule (in)active" << endl;2271 Log() << Verbose(0) << "e - edit molecules (load, parse, save)" << endl;2272 Log() << Verbose(0) << "g - globally manipulate atoms in molecule" << endl;2273 Log() << Verbose(0) << "M - Merge molecules" << endl;2274 Log() << Verbose(0) << "m - manipulate atoms" << endl;2275 Log() << Verbose(0) << "-----------------------------------------------" << endl;2276 Log() << Verbose(0) << "c - edit the current configuration" << endl;2277 Log() << Verbose(0) << "-----------------------------------------------" << endl;2278 Log() << Verbose(0) << "s - save current setup to config file" << endl;2279 Log() << Verbose(0) << "T - call the current test routine" << endl;2280 Log() << Verbose(0) << "q - quit" << endl;2281 Log() << Verbose(0) << "===============================================" << endl;2282 Log() << Verbose(0) << "Input: ";2559 DoLog(0) && (Log() << Verbose(0) << "============Menu===============================" << endl); 2560 DoLog(0) && (Log() << Verbose(0) << "a - set molecule (in)active" << endl); 2561 DoLog(0) && (Log() << Verbose(0) << "e - edit molecules (load, parse, save)" << endl); 2562 DoLog(0) && (Log() << Verbose(0) << "g - globally manipulate atoms in molecule" << endl); 2563 DoLog(0) && (Log() << Verbose(0) << "M - Merge molecules" << endl); 2564 DoLog(0) && (Log() << Verbose(0) << "m - manipulate atoms" << endl); 2565 DoLog(0) && (Log() << Verbose(0) << "-----------------------------------------------" << endl); 2566 DoLog(0) && (Log() << Verbose(0) << "c - edit the current configuration" << endl); 2567 DoLog(0) && (Log() << Verbose(0) << "-----------------------------------------------" << endl); 2568 DoLog(0) && (Log() << Verbose(0) << "s - save current setup to config file" << endl); 2569 DoLog(0) && (Log() << Verbose(0) << "T - call the current test routine" << endl); 2570 DoLog(0) && (Log() << Verbose(0) << "q - quit" << endl); 2571 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl); 2572 DoLog(0) && (Log() << Verbose(0) << "Input: "); 2283 2573 cin >> choice; 2284 2574 … … 2286 2576 case 'a': // (in)activate molecule 2287 2577 { 2288 Log() << Verbose(0) << "Enter index of molecule: ";2578 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: "); 2289 2579 cin >> j; 2290 2580 for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) … … 2332 2622 // save element data base 2333 2623 if (periode->StorePeriodentafel(configuration->databasepath)) //ElementsFileName 2334 Log() << Verbose(0) << "Saving of elements.db successful." << endl;2624 DoLog(0) && (Log() << Verbose(0) << "Saving of elements.db successful." << endl); 2335 2625 else 2336 Log() << Verbose(0) << "Saving of elements.db failed." << endl;2626 DoLog(0) && (Log() << Verbose(0) << "Saving of elements.db failed." << endl); 2337 2627 2338 2628 delete(molecules); // also free's all molecules contained -
src/config.cpp
r491876 rc695c9 6 6 7 7 #include <stdio.h> 8 #include <cstring> 8 9 9 10 #include "atom.hpp" … … 18 19 #include "molecule.hpp" 19 20 #include "periodentafel.hpp" 21 #include "World.hpp" 20 22 21 23 /******************************** Functions for class ConfigFileBuffer **********************/ … … 27 29 char number1[8]; 28 30 char number2[8]; 29 c har *dummy1, *dummy2;31 const char *dummy1, *dummy2; 30 32 //Log() << Verbose(0) << s1 << " " << s2 << endl; 31 33 dummy1 = strchr(s1, '_')+sizeof(char)*5; // go just after "Ion_Type" … … 72 74 file= new ifstream(filename); 73 75 if (file == NULL) { 74 eLog() << Verbose(1) << "config file " << filename << " missing!" << endl;76 DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl); 75 77 return; 76 78 } … … 83 85 file->clear(); 84 86 file->seekg(file_position, ios::beg); 85 Log() << Verbose(1) << NoLines-1 << " lines were recognized." << endl;87 DoLog(1) && (Log() << Verbose(1) << NoLines-1 << " lines were recognized." << endl); 86 88 87 89 // allocate buffer's 1st dimension 88 90 if (buffer != NULL) { 89 eLog() << Verbose(1) << "FileBuffer->buffer is not NULL!" << endl;91 DoeLog(1) && (eLog()<< Verbose(1) << "FileBuffer->buffer is not NULL!" << endl); 90 92 return; 91 93 } else … … 103 105 lines++; 104 106 } while((!file->eof()) && (lines < NoLines)); 105 Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl;107 DoLog(1) && (Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl); 106 108 107 109 // close and exit … … 140 142 void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms) 141 143 { 142 map<const char *, int, IonTypeCompare> LineList;144 map<const char *, int, IonTypeCompare> IonTypeLineMap; 143 145 if (LineMapping == NULL) { 144 eLog() << Verbose(0) << "map pointer is NULL: " << LineMapping << endl;146 DoeLog(0) && (eLog()<< Verbose(0) << "map pointer is NULL: " << LineMapping << endl); 145 147 performCriticalExit(); 146 148 return; … … 149 151 // put all into hashed map 150 152 for (int i=0; i<NoAtoms; ++i) { 151 LineList.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i));153 IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i)); 152 154 } 153 155 154 156 // fill map 155 157 int nr=0; 156 for (map<const char *, int, IonTypeCompare>::iterator runner = LineList.begin(); runner != LineList.end(); ++runner) {158 for (map<const char *, int, IonTypeCompare>::iterator runner = IonTypeLineMap.begin(); runner != IonTypeLineMap.end(); ++runner) { 157 159 if (CurrentLine+nr < NoLines) 158 160 LineMapping[CurrentLine+(nr++)] = runner->second; 159 161 else { 160 eLog() << Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl;162 DoeLog(0) && (eLog()<< Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl); 161 163 performCriticalExit(); 162 164 } … … 248 250 Thermostat = None; 249 251 } else { 250 Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;252 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 251 253 Thermostat = None; 252 254 } … … 256 258 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency 257 259 } else { 258 Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;260 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 259 261 Thermostat = None; 260 262 } … … 264 266 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate 265 267 } else { 266 Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;268 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 267 269 Thermostat = None; 268 270 } … … 272 274 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma 273 275 if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &alpha, 1, optional)) { 274 Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl;276 DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl); 275 277 } else { 276 278 alpha = 1.; 277 279 } 278 280 } else { 279 Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;281 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 280 282 Thermostat = None; 281 283 } … … 285 287 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T 286 288 } else { 287 Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;289 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 288 290 Thermostat = None; 289 291 } … … 294 296 alpha = 0.; 295 297 } else { 296 Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;298 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 297 299 Thermostat = None; 298 300 } 299 301 } else { 300 Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl;302 DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl); 301 303 Thermostat = None; 302 304 } 303 305 } else { 304 306 if ((MaxOuterStep > 0) && (TargetTemp != 0)) 305 Log() << Verbose(2) << "No thermostat chosen despite finite temperature MD, falling back to None." << endl;307 DoLog(2) && (Log() << Verbose(2) << "No thermostat chosen despite finite temperature MD, falling back to None." << endl); 306 308 Thermostat = None; 307 309 } … … 319 321 320 322 do { 321 Log() << Verbose(0) << "===========EDIT CONFIGURATION============================" << endl;322 Log() << Verbose(0) << " A - mainname (prefix for all runtime files)" << endl;323 Log() << Verbose(0) << " B - Default path (for runtime files)" << endl;324 Log() << Verbose(0) << " C - Path of pseudopotential files" << endl;325 Log() << Verbose(0) << " D - Number of coefficient sharing processes" << endl;326 Log() << Verbose(0) << " E - Number of wave function sharing processes" << endl;327 Log() << Verbose(0) << " F - 0: Don't output density for OpenDX, 1: do" << endl;328 Log() << Verbose(0) << " G - 0: Don't output physical data, 1: do" << endl;329 Log() << Verbose(0) << " H - 0: Don't output densities of each unperturbed orbital for OpenDX, 1: do" << endl;330 Log() << Verbose(0) << " I - 0: Don't output current density for OpenDX, 1: do" << endl;331 Log() << Verbose(0) << " J - 0: Don't do the full current calculation, 1: do" << endl;332 Log() << Verbose(0) << " K - 0: Don't do perturbation calculation to obtain susceptibility and shielding, 1: do" << endl;333 Log() << Verbose(0) << " L - 0: Wannier centres as calculated, 1: common centre for all, 2: unite centres according to spread, 3: cell centre, 4: shifted to nearest grid point" << endl;334 Log() << Verbose(0) << " M - Absolute begin of unphysical sawtooth transfer for position operator within cell" << endl;335 Log() << Verbose(0) << " N - (0,1,2) x,y,z-plane to do two-dimensional current vector cut" << endl;336 Log() << Verbose(0) << " O - Absolute position along vector cut axis for cut plane" << endl;337 Log() << Verbose(0) << " P - Additional Gram-Schmidt-Orthonormalization to stabilize numerics" << endl;338 Log() << Verbose(0) << " Q - Initial integer value of random number generator" << endl;339 Log() << Verbose(0) << " R - for perturbation 0, for structure optimization defines upper limit of iterations" << endl;340 Log() << Verbose(0) << " T - Output visual after ...th step" << endl;341 Log() << Verbose(0) << " U - Output source densities of wave functions after ...th step" << endl;342 Log() << Verbose(0) << " X - minimization iterations per wave function, if unsure leave at default value 0" << endl;343 Log() << Verbose(0) << " Y - tolerance value for total spread in iterative Jacobi diagonalization" << endl;344 Log() << Verbose(0) << " Z - Maximum number of minimization iterations" << endl;345 Log() << Verbose(0) << " a - Relative change in total energy to stop min. iteration" << endl;346 Log() << Verbose(0) << " b - Relative change in kinetic energy to stop min. iteration" << endl;347 Log() << Verbose(0) << " c - Check stop conditions every ..th step during min. iteration" << endl;348 Log() << Verbose(0) << " e - Maximum number of minimization iterations during initial level" << endl;349 Log() << Verbose(0) << " f - Relative change in total energy to stop min. iteration during initial level" << endl;350 Log() << Verbose(0) << " g - Relative change in kinetic energy to stop min. iteration during initial level" << endl;351 Log() << Verbose(0) << " h - Check stop conditions every ..th step during min. iteration during initial level" << endl;323 DoLog(0) && (Log() << Verbose(0) << "===========EDIT CONFIGURATION============================" << endl); 324 DoLog(0) && (Log() << Verbose(0) << " A - mainname (prefix for all runtime files)" << endl); 325 DoLog(0) && (Log() << Verbose(0) << " B - Default path (for runtime files)" << endl); 326 DoLog(0) && (Log() << Verbose(0) << " C - Path of pseudopotential files" << endl); 327 DoLog(0) && (Log() << Verbose(0) << " D - Number of coefficient sharing processes" << endl); 328 DoLog(0) && (Log() << Verbose(0) << " E - Number of wave function sharing processes" << endl); 329 DoLog(0) && (Log() << Verbose(0) << " F - 0: Don't output density for OpenDX, 1: do" << endl); 330 DoLog(0) && (Log() << Verbose(0) << " G - 0: Don't output physical data, 1: do" << endl); 331 DoLog(0) && (Log() << Verbose(0) << " H - 0: Don't output densities of each unperturbed orbital for OpenDX, 1: do" << endl); 332 DoLog(0) && (Log() << Verbose(0) << " I - 0: Don't output current density for OpenDX, 1: do" << endl); 333 DoLog(0) && (Log() << Verbose(0) << " J - 0: Don't do the full current calculation, 1: do" << endl); 334 DoLog(0) && (Log() << Verbose(0) << " K - 0: Don't do perturbation calculation to obtain susceptibility and shielding, 1: do" << endl); 335 DoLog(0) && (Log() << Verbose(0) << " L - 0: Wannier centres as calculated, 1: common centre for all, 2: unite centres according to spread, 3: cell centre, 4: shifted to nearest grid point" << endl); 336 DoLog(0) && (Log() << Verbose(0) << " M - Absolute begin of unphysical sawtooth transfer for position operator within cell" << endl); 337 DoLog(0) && (Log() << Verbose(0) << " N - (0,1,2) x,y,z-plane to do two-dimensional current vector cut" << endl); 338 DoLog(0) && (Log() << Verbose(0) << " O - Absolute position along vector cut axis for cut plane" << endl); 339 DoLog(0) && (Log() << Verbose(0) << " P - Additional Gram-Schmidt-Orthonormalization to stabilize numerics" << endl); 340 DoLog(0) && (Log() << Verbose(0) << " Q - Initial integer value of random number generator" << endl); 341 DoLog(0) && (Log() << Verbose(0) << " R - for perturbation 0, for structure optimization defines upper limit of iterations" << endl); 342 DoLog(0) && (Log() << Verbose(0) << " T - Output visual after ...th step" << endl); 343 DoLog(0) && (Log() << Verbose(0) << " U - Output source densities of wave functions after ...th step" << endl); 344 DoLog(0) && (Log() << Verbose(0) << " X - minimization iterations per wave function, if unsure leave at default value 0" << endl); 345 DoLog(0) && (Log() << Verbose(0) << " Y - tolerance value for total spread in iterative Jacobi diagonalization" << endl); 346 DoLog(0) && (Log() << Verbose(0) << " Z - Maximum number of minimization iterations" << endl); 347 DoLog(0) && (Log() << Verbose(0) << " a - Relative change in total energy to stop min. iteration" << endl); 348 DoLog(0) && (Log() << Verbose(0) << " b - Relative change in kinetic energy to stop min. iteration" << endl); 349 DoLog(0) && (Log() << Verbose(0) << " c - Check stop conditions every ..th step during min. iteration" << endl); 350 DoLog(0) && (Log() << Verbose(0) << " e - Maximum number of minimization iterations during initial level" << endl); 351 DoLog(0) && (Log() << Verbose(0) << " f - Relative change in total energy to stop min. iteration during initial level" << endl); 352 DoLog(0) && (Log() << Verbose(0) << " g - Relative change in kinetic energy to stop min. iteration during initial level" << endl); 353 DoLog(0) && (Log() << Verbose(0) << " h - Check stop conditions every ..th step during min. iteration during initial level" << endl); 352 354 // Log() << Verbose(0) << " j - six lower diagonal entries of matrix, defining the unit cell" << endl; 353 Log() << Verbose(0) << " k - Energy cutoff of plane wave basis in Hartree" << endl;354 Log() << Verbose(0) << " l - Maximum number of levels in multi-level-ansatz" << endl;355 Log() << Verbose(0) << " m - Factor by which grid nodes increase between standard and upper level" << endl;356 Log() << Verbose(0) << " n - 0: Don't use RiemannTensor, 1: Do" << endl;357 Log() << Verbose(0) << " o - Factor by which grid nodes increase between Riemann and standard(?) level" << endl;358 Log() << Verbose(0) << " p - Number of Riemann levels" << endl;359 Log() << Verbose(0) << " r - 0: Don't Use RiemannTensor, 1: Do" << endl;360 Log() << Verbose(0) << " s - 0: Doubly occupied orbitals, 1: Up-/Down-Orbitals" << endl;361 Log() << Verbose(0) << " t - Number of orbitals (depends pn SpinType)" << endl;362 Log() << Verbose(0) << " u - Number of SpinUp orbitals (depends on SpinType)" << endl;363 Log() << Verbose(0) << " v - Number of SpinDown orbitals (depends on SpinType)" << endl;364 Log() << Verbose(0) << " w - Number of additional, unoccupied orbitals" << endl;365 Log() << Verbose(0) << " x - radial cutoff for ewald summation in Bohrradii" << endl;366 Log() << Verbose(0) << " y - 0: Don't do structure optimization beforehand, 1: Do" << endl;367 Log() << Verbose(0) << " z - 0: Units are in Bohr radii, 1: units are in Aengstrom" << endl;368 Log() << Verbose(0) << " i - 0: Coordinates given in file are absolute, 1: ... are relative to unit cell" << endl;369 Log() << Verbose(0) << "=========================================================" << endl;370 Log() << Verbose(0) << "INPUT: ";355 DoLog(0) && (Log() << Verbose(0) << " k - Energy cutoff of plane wave basis in Hartree" << endl); 356 DoLog(0) && (Log() << Verbose(0) << " l - Maximum number of levels in multi-level-ansatz" << endl); 357 DoLog(0) && (Log() << Verbose(0) << " m - Factor by which grid nodes increase between standard and upper level" << endl); 358 DoLog(0) && (Log() << Verbose(0) << " n - 0: Don't use RiemannTensor, 1: Do" << endl); 359 DoLog(0) && (Log() << Verbose(0) << " o - Factor by which grid nodes increase between Riemann and standard(?) level" << endl); 360 DoLog(0) && (Log() << Verbose(0) << " p - Number of Riemann levels" << endl); 361 DoLog(0) && (Log() << Verbose(0) << " r - 0: Don't Use RiemannTensor, 1: Do" << endl); 362 DoLog(0) && (Log() << Verbose(0) << " s - 0: Doubly occupied orbitals, 1: Up-/Down-Orbitals" << endl); 363 DoLog(0) && (Log() << Verbose(0) << " t - Number of orbitals (depends pn SpinType)" << endl); 364 DoLog(0) && (Log() << Verbose(0) << " u - Number of SpinUp orbitals (depends on SpinType)" << endl); 365 DoLog(0) && (Log() << Verbose(0) << " v - Number of SpinDown orbitals (depends on SpinType)" << endl); 366 DoLog(0) && (Log() << Verbose(0) << " w - Number of additional, unoccupied orbitals" << endl); 367 DoLog(0) && (Log() << Verbose(0) << " x - radial cutoff for ewald summation in Bohrradii" << endl); 368 DoLog(0) && (Log() << Verbose(0) << " y - 0: Don't do structure optimization beforehand, 1: Do" << endl); 369 DoLog(0) && (Log() << Verbose(0) << " z - 0: Units are in Bohr radii, 1: units are in Aengstrom" << endl); 370 DoLog(0) && (Log() << Verbose(0) << " i - 0: Coordinates given in file are absolute, 1: ... are relative to unit cell" << endl); 371 DoLog(0) && (Log() << Verbose(0) << "=========================================================" << endl); 372 DoLog(0) && (Log() << Verbose(0) << "INPUT: "); 371 373 cin >> choice; 372 374 373 375 switch (choice) { 374 376 case 'A': // mainname 375 Log() << Verbose(0) << "Old: " << config::mainname << "\t new: ";377 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::mainname << "\t new: "); 376 378 cin >> config::mainname; 377 379 break; 378 380 case 'B': // defaultpath 379 Log() << Verbose(0) << "Old: " << config::defaultpath << "\t new: ";381 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::defaultpath << "\t new: "); 380 382 cin >> config::defaultpath; 381 383 break; 382 384 case 'C': // pseudopotpath 383 Log() << Verbose(0) << "Old: " << config::pseudopotpath << "\t new: ";385 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::pseudopotpath << "\t new: "); 384 386 cin >> config::pseudopotpath; 385 387 break; 386 388 387 389 case 'D': // ProcPEGamma 388 Log() << Verbose(0) << "Old: " << config::ProcPEGamma << "\t new: ";390 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::ProcPEGamma << "\t new: "); 389 391 cin >> config::ProcPEGamma; 390 392 break; 391 393 case 'E': // ProcPEPsi 392 Log() << Verbose(0) << "Old: " << config::ProcPEPsi << "\t new: ";394 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::ProcPEPsi << "\t new: "); 393 395 cin >> config::ProcPEPsi; 394 396 break; 395 397 case 'F': // DoOutVis 396 Log() << Verbose(0) << "Old: " << config::DoOutVis << "\t new: ";398 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutVis << "\t new: "); 397 399 cin >> config::DoOutVis; 398 400 break; 399 401 case 'G': // DoOutMes 400 Log() << Verbose(0) << "Old: " << config::DoOutMes << "\t new: ";402 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutMes << "\t new: "); 401 403 cin >> config::DoOutMes; 402 404 break; 403 405 case 'H': // DoOutOrbitals 404 Log() << Verbose(0) << "Old: " << config::DoOutOrbitals << "\t new: ";406 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutOrbitals << "\t new: "); 405 407 cin >> config::DoOutOrbitals; 406 408 break; 407 409 case 'I': // DoOutCurrent 408 Log() << Verbose(0) << "Old: " << config::DoOutCurrent << "\t new: ";410 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutCurrent << "\t new: "); 409 411 cin >> config::DoOutCurrent; 410 412 break; 411 413 case 'J': // DoFullCurrent 412 Log() << Verbose(0) << "Old: " << config::DoFullCurrent << "\t new: ";414 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoFullCurrent << "\t new: "); 413 415 cin >> config::DoFullCurrent; 414 416 break; 415 417 case 'K': // DoPerturbation 416 Log() << Verbose(0) << "Old: " << config::DoPerturbation << "\t new: ";418 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoPerturbation << "\t new: "); 417 419 cin >> config::DoPerturbation; 418 420 break; 419 421 case 'L': // CommonWannier 420 Log() << Verbose(0) << "Old: " << config::CommonWannier << "\t new: ";422 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::CommonWannier << "\t new: "); 421 423 cin >> config::CommonWannier; 422 424 break; 423 425 case 'M': // SawtoothStart 424 Log() << Verbose(0) << "Old: " << config::SawtoothStart << "\t new: ";426 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::SawtoothStart << "\t new: "); 425 427 cin >> config::SawtoothStart; 426 428 break; 427 429 case 'N': // VectorPlane 428 Log() << Verbose(0) << "Old: " << config::VectorPlane << "\t new: ";430 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::VectorPlane << "\t new: "); 429 431 cin >> config::VectorPlane; 430 432 break; 431 433 case 'O': // VectorCut 432 Log() << Verbose(0) << "Old: " << config::VectorCut << "\t new: ";434 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::VectorCut << "\t new: "); 433 435 cin >> config::VectorCut; 434 436 break; 435 437 case 'P': // UseAddGramSch 436 Log() << Verbose(0) << "Old: " << config::UseAddGramSch << "\t new: ";438 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::UseAddGramSch << "\t new: "); 437 439 cin >> config::UseAddGramSch; 438 440 break; 439 441 case 'Q': // Seed 440 Log() << Verbose(0) << "Old: " << config::Seed << "\t new: ";442 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::Seed << "\t new: "); 441 443 cin >> config::Seed; 442 444 break; 443 445 444 446 case 'R': // MaxOuterStep 445 Log() << Verbose(0) << "Old: " << config::MaxOuterStep << "\t new: ";447 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxOuterStep << "\t new: "); 446 448 cin >> config::MaxOuterStep; 447 449 break; 448 450 case 'T': // OutVisStep 449 Log() << Verbose(0) << "Old: " << config::OutVisStep << "\t new: ";451 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::OutVisStep << "\t new: "); 450 452 cin >> config::OutVisStep; 451 453 break; 452 454 case 'U': // OutSrcStep 453 Log() << Verbose(0) << "Old: " << config::OutSrcStep << "\t new: ";455 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::OutSrcStep << "\t new: "); 454 456 cin >> config::OutSrcStep; 455 457 break; 456 458 case 'X': // MaxPsiStep 457 Log() << Verbose(0) << "Old: " << config::MaxPsiStep << "\t new: ";459 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxPsiStep << "\t new: "); 458 460 cin >> config::MaxPsiStep; 459 461 break; 460 462 case 'Y': // EpsWannier 461 Log() << Verbose(0) << "Old: " << config::EpsWannier << "\t new: ";463 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::EpsWannier << "\t new: "); 462 464 cin >> config::EpsWannier; 463 465 break; 464 466 465 467 case 'Z': // MaxMinStep 466 Log() << Verbose(0) << "Old: " << config::MaxMinStep << "\t new: ";468 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxMinStep << "\t new: "); 467 469 cin >> config::MaxMinStep; 468 470 break; 469 471 case 'a': // RelEpsTotalEnergy 470 Log() << Verbose(0) << "Old: " << config::RelEpsTotalEnergy << "\t new: ";472 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RelEpsTotalEnergy << "\t new: "); 471 473 cin >> config::RelEpsTotalEnergy; 472 474 break; 473 475 case 'b': // RelEpsKineticEnergy 474 Log() << Verbose(0) << "Old: " << config::RelEpsKineticEnergy << "\t new: ";476 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RelEpsKineticEnergy << "\t new: "); 475 477 cin >> config::RelEpsKineticEnergy; 476 478 break; 477 479 case 'c': // MaxMinStopStep 478 Log() << Verbose(0) << "Old: " << config::MaxMinStopStep << "\t new: ";480 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxMinStopStep << "\t new: "); 479 481 cin >> config::MaxMinStopStep; 480 482 break; 481 483 case 'e': // MaxInitMinStep 482 Log() << Verbose(0) << "Old: " << config::MaxInitMinStep << "\t new: ";484 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxInitMinStep << "\t new: "); 483 485 cin >> config::MaxInitMinStep; 484 486 break; 485 487 case 'f': // InitRelEpsTotalEnergy 486 Log() << Verbose(0) << "Old: " << config::InitRelEpsTotalEnergy << "\t new: ";488 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::InitRelEpsTotalEnergy << "\t new: "); 487 489 cin >> config::InitRelEpsTotalEnergy; 488 490 break; 489 491 case 'g': // InitRelEpsKineticEnergy 490 Log() << Verbose(0) << "Old: " << config::InitRelEpsKineticEnergy << "\t new: ";492 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::InitRelEpsKineticEnergy << "\t new: "); 491 493 cin >> config::InitRelEpsKineticEnergy; 492 494 break; 493 495 case 'h': // InitMaxMinStopStep 494 Log() << Verbose(0) << "Old: " << config::InitMaxMinStopStep << "\t new: ";496 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::InitMaxMinStopStep << "\t new: "); 495 497 cin >> config::InitMaxMinStopStep; 496 498 break; … … 498 500 // case 'j': // BoxLength 499 501 // Log() << Verbose(0) << "enter lower triadiagonalo form of basis matrix" << endl << endl; 502 // double * const cell_size = World::get()->cell_size; 500 503 // for (int i=0;i<6;i++) { 501 504 // Log() << Verbose(0) << "Cell size" << i << ": "; 502 // cin >> mol->cell_size[i];505 // cin >> cell_size[i]; 503 506 // } 504 507 // break; 505 508 506 509 case 'k': // ECut 507 Log() << Verbose(0) << "Old: " << config::ECut << "\t new: ";510 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::ECut << "\t new: "); 508 511 cin >> config::ECut; 509 512 break; 510 513 case 'l': // MaxLevel 511 Log() << Verbose(0) << "Old: " << config::MaxLevel << "\t new: ";514 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxLevel << "\t new: "); 512 515 cin >> config::MaxLevel; 513 516 break; 514 517 case 'm': // RiemannTensor 515 Log() << Verbose(0) << "Old: " << config::RiemannTensor << "\t new: ";518 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RiemannTensor << "\t new: "); 516 519 cin >> config::RiemannTensor; 517 520 break; 518 521 case 'n': // LevRFactor 519 Log() << Verbose(0) << "Old: " << config::LevRFactor << "\t new: ";522 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::LevRFactor << "\t new: "); 520 523 cin >> config::LevRFactor; 521 524 break; 522 525 case 'o': // RiemannLevel 523 Log() << Verbose(0) << "Old: " << config::RiemannLevel << "\t new: ";526 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RiemannLevel << "\t new: "); 524 527 cin >> config::RiemannLevel; 525 528 break; 526 529 case 'p': // Lev0Factor 527 Log() << Verbose(0) << "Old: " << config::Lev0Factor << "\t new: ";530 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::Lev0Factor << "\t new: "); 528 531 cin >> config::Lev0Factor; 529 532 break; 530 533 case 'r': // RTActualUse 531 Log() << Verbose(0) << "Old: " << config::RTActualUse << "\t new: ";534 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RTActualUse << "\t new: "); 532 535 cin >> config::RTActualUse; 533 536 break; 534 537 case 's': // PsiType 535 Log() << Verbose(0) << "Old: " << config::PsiType << "\t new: ";538 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::PsiType << "\t new: "); 536 539 cin >> config::PsiType; 537 540 break; 538 541 case 't': // MaxPsiDouble 539 Log() << Verbose(0) << "Old: " << config::MaxPsiDouble << "\t new: ";542 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxPsiDouble << "\t new: "); 540 543 cin >> config::MaxPsiDouble; 541 544 break; 542 545 case 'u': // PsiMaxNoUp 543 Log() << Verbose(0) << "Old: " << config::PsiMaxNoUp << "\t new: ";546 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::PsiMaxNoUp << "\t new: "); 544 547 cin >> config::PsiMaxNoUp; 545 548 break; 546 549 case 'v': // PsiMaxNoDown 547 Log() << Verbose(0) << "Old: " << config::PsiMaxNoDown << "\t new: ";550 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::PsiMaxNoDown << "\t new: "); 548 551 cin >> config::PsiMaxNoDown; 549 552 break; 550 553 case 'w': // AddPsis 551 Log() << Verbose(0) << "Old: " << config::AddPsis << "\t new: ";554 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::AddPsis << "\t new: "); 552 555 cin >> config::AddPsis; 553 556 break; 554 557 555 558 case 'x': // RCut 556 Log() << Verbose(0) << "Old: " << config::RCut << "\t new: ";559 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RCut << "\t new: "); 557 560 cin >> config::RCut; 558 561 break; 559 562 case 'y': // StructOpt 560 Log() << Verbose(0) << "Old: " << config::StructOpt << "\t new: ";563 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::StructOpt << "\t new: "); 561 564 cin >> config::StructOpt; 562 565 break; 563 566 case 'z': // IsAngstroem 564 Log() << Verbose(0) << "Old: " << config::IsAngstroem << "\t new: ";567 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::IsAngstroem << "\t new: "); 565 568 cin >> config::IsAngstroem; 566 569 break; 567 570 case 'i': // RelativeCoord 568 Log() << Verbose(0) << "Old: " << config::RelativeCoord << "\t new: ";571 DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RelativeCoord << "\t new: "); 569 572 cin >> config::RelativeCoord; 570 573 break; … … 645 648 } 646 649 strcpy(configname, ptr); 647 Log() << Verbose(0) << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl;650 DoLog(0) && (Log() << Verbose(0) << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl); 648 651 delete[](buffer); 649 652 }; … … 656 659 { 657 660 if (FileBuffer != NULL) { 658 eLog() << Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl;661 DoeLog(2) && (eLog()<< Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl); 659 662 delete(FileBuffer); 660 663 } … … 682 685 683 686 if (mol == NULL) { 684 eLog() << Verbose(0) << "Molecule is not allocated in LoadMolecule(), exit.";687 DoeLog(0) && (eLog()<< Verbose(0) << "Molecule is not allocated in LoadMolecule(), exit."); 685 688 performCriticalExit(); 686 689 } … … 688 691 ParseForParameter(verbose,FileBuffer,"MaxTypes", 0, 1, 1, int_type, &(MaxTypes), 1, critical); 689 692 if (MaxTypes == 0) { 690 eLog() << Verbose(0) << "There are no atoms according to MaxTypes in this config file." << endl;691 performCriticalExit();693 DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms according to MaxTypes in this config file." << endl); 694 //performCriticalExit(); 692 695 } else { 693 696 // prescan number of ions per type 694 Log() << Verbose(0) << "Prescanning ions per type: " << endl;697 DoLog(0) && (Log() << Verbose(0) << "Prescanning ions per type: " << endl); 695 698 int NoAtoms = 0; 696 699 for (int i=0; i < MaxTypes; i++) { … … 699 702 ParseForParameter(verbose,FileBuffer, name, 0, 2, 1, int_type, &Z, 1, critical); 700 703 elementhash[i] = periode->FindElement(Z); 701 Log() << Verbose(1) << i << ". Z = " << elementhash[i]->Z << " with " << No[i] << " ions." << endl;704 DoLog(1) && (Log() << Verbose(1) << i << ". Z = " << elementhash[i]->Z << " with " << No[i] << " ions." << endl); 702 705 NoAtoms += No[i]; 703 706 } … … 707 710 sprintf(name,"Ion_Type%i",MaxTypes); 708 711 if (!ParseForParameter(verbose,FileBuffer, (const char*)name, 1, 1, 1, int_type, &value[0], 1, critical)) { 709 eLog() << Verbose(0) << "There are no atoms in the config file!" << endl;712 DoeLog(0) && (eLog()<< Verbose(0) << "There are no atoms in the config file!" << endl); 710 713 performCriticalExit(); 711 714 return; … … 725 728 bool status = true; 726 729 while (status) { 727 Log() << Verbose(0) << "Currently parsing MD step " << repetition << "." << endl;730 DoLog(0) && (Log() << Verbose(0) << "Currently parsing MD step " << repetition << "." << endl); 728 731 for (int i=0; i < MaxTypes; i++) { 729 732 sprintf(name,"Ion_Type%i",i+1); … … 791 794 } 792 795 repetition--; 793 Log() << Verbose(0) << "Found " << repetition << " trajectory steps." << endl;796 DoLog(0) && (Log() << Verbose(0) << "Found " << repetition << " trajectory steps." << endl); 794 797 if (repetition <= 1) // if onyl one step, desactivate use of trajectories 795 798 mol->MDSteps = 0; … … 803 806 ParseForParameter(verbose,FileBuffer, "Ion_Type1_1", 0, 3, 1, double_type, &value[2], repetition, (repetition == 0) ? critical : optional)) 804 807 repetition++; 805 Log() << Verbose(0) << "I found " << repetition << " times the keyword Ion_Type1_1." << endl;808 DoLog(0) && (Log() << Verbose(0) << "I found " << repetition << " times the keyword Ion_Type1_1." << endl); 806 809 // parse in molecule coordinates 807 810 for (int i=0; i < MaxTypes; i++) { … … 852 855 ifstream *file = new ifstream(filename); 853 856 if (file == NULL) { 854 eLog() << Verbose(1) << "config file " << filename << " missing!" << endl;857 DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl); 855 858 return; 856 859 } … … 964 967 // Unit cell and magnetic field 965 968 ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 966 mol->cell_size[0] = BoxLength[0]; 967 mol->cell_size[1] = BoxLength[3]; 968 mol->cell_size[2] = BoxLength[4]; 969 mol->cell_size[3] = BoxLength[6]; 970 mol->cell_size[4] = BoxLength[7]; 971 mol->cell_size[5] = BoxLength[8]; 969 double * const cell_size = World::get()->cell_size; 970 cell_size[0] = BoxLength[0]; 971 cell_size[1] = BoxLength[3]; 972 cell_size[2] = BoxLength[4]; 973 cell_size[3] = BoxLength[6]; 974 cell_size[4] = BoxLength[7]; 975 cell_size[5] = BoxLength[8]; 972 976 //if (1) fprintf(stderr,"\n"); 973 977 … … 1059 1063 BG = new BondGraph(IsAngstroem); 1060 1064 if (BG->LoadBondLengthTable(BondGraphFileName)) { 1061 Log() << Verbose(0) << "Bond length table loaded successfully." << endl;1065 DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl); 1062 1066 } else { 1063 eLog() << Verbose(1) << "Bond length table loading failed." << endl;1067 DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl); 1064 1068 } 1065 1069 } … … 1074 1078 // don't do this here ... 1075 1079 //MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this); 1076 1077 delete(mol); 1080 //delete(mol); 1081 1078 1082 delete(FileBuffer); 1079 1083 }; … … 1090 1094 ifstream *file = new ifstream(filename); 1091 1095 if (file == NULL) { 1092 eLog() << Verbose(1) << "config file " << filename << " missing!" << endl;1096 DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl); 1093 1097 return; 1094 1098 } … … 1168 1172 1169 1173 ParseForParameter(verbose,file, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 1170 mol->cell_size[0] = BoxLength[0]; 1171 mol->cell_size[1] = BoxLength[3]; 1172 mol->cell_size[2] = BoxLength[4]; 1173 mol->cell_size[3] = BoxLength[6]; 1174 mol->cell_size[4] = BoxLength[7]; 1175 mol->cell_size[5] = BoxLength[8]; 1174 double * const cell_size = World::get()->cell_size; 1175 cell_size[0] = BoxLength[0]; 1176 cell_size[1] = BoxLength[3]; 1177 cell_size[2] = BoxLength[4]; 1178 cell_size[3] = BoxLength[6]; 1179 cell_size[4] = BoxLength[7]; 1180 cell_size[5] = BoxLength[8]; 1176 1181 if (1) fprintf(stderr,"\n"); 1177 1182 config::DoPerturbation = 0; … … 1249 1254 BG = new BondGraph(IsAngstroem); 1250 1255 if (BG->LoadBondLengthTable(BondGraphFileName)) { 1251 Log() << Verbose(0) << "Bond length table loaded successfully." << endl;1256 DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl); 1252 1257 } else { 1253 Log() << Verbose(0) << "Bond length table loading failed." << endl;1258 DoLog(0) && (Log() << Verbose(0) << "Bond length table loading failed." << endl); 1254 1259 } 1255 1260 … … 1258 1263 for (i=MAX_ELEMENTS;i--;) 1259 1264 elementhash[i] = NULL; 1260 Log() << Verbose(0) << "Parsing Ions ..." << endl;1265 DoLog(0) && (Log() << Verbose(0) << "Parsing Ions ..." << endl); 1261 1266 No=0; 1262 1267 found = 0; 1263 1268 while (getline(*file,zeile,'\n')) { 1264 1269 if (zeile.find("Ions_Data") == 0) { 1265 Log() << Verbose(1) << "found Ions_Data...begin parsing" << endl;1270 DoLog(1) && (Log() << Verbose(1) << "found Ions_Data...begin parsing" << endl); 1266 1271 found ++; 1267 1272 } … … 1277 1282 input >> b; // element mass 1278 1283 elementhash[No] = periode->FindElement(Z); 1279 Log() << Verbose(1) << "AtomNo: " << AtomNo << "\tZ: " << Z << "\ta:" << a << "\tl:" << l << "\b:" << b << "\tElement:" << elementhash[No] << "\t:" << endl;1284 DoLog(1) && (Log() << Verbose(1) << "AtomNo: " << AtomNo << "\tZ: " << Z << "\ta:" << a << "\tl:" << l << "\b:" << b << "\tElement:" << elementhash[No] << "\t:" << endl); 1280 1285 for(i=0;i<AtomNo;i++) { 1281 1286 if (!getline(*file,zeile,'\n')) {// parse on and on 1282 Log() << Verbose(2) << "Error: Too few items in ionic list of element" << elementhash[No] << "." << endl << "Exiting." << endl;1287 DoLog(2) && (Log() << Verbose(2) << "Error: Too few items in ionic list of element" << elementhash[No] << "." << endl << "Exiting." << endl); 1283 1288 // return 1; 1284 1289 } else { … … 1311 1316 // bring MaxTypes up to date 1312 1317 mol->CountElements(); 1318 const double * const cell_size = World::get()->cell_size; 1313 1319 ofstream * const output = new ofstream(filename, ios::out); 1314 1320 if (output != NULL) { … … 1381 1387 *output << endl; 1382 1388 *output << "BoxLength\t\t\t# (Length of a unit cell)" << endl; 1383 *output << mol->cell_size[0] << "\t" << endl;1384 *output << mol->cell_size[1] << "\t" << mol->cell_size[2] << "\t" << endl;1385 *output << mol->cell_size[3] << "\t" << mol->cell_size[4] << "\t" << mol->cell_size[5] << "\t" << endl;1389 *output << cell_size[0] << "\t" << endl; 1390 *output << cell_size[1] << "\t" << cell_size[2] << "\t" << endl; 1391 *output << cell_size[3] << "\t" << cell_size[4] << "\t" << cell_size[5] << "\t" << endl; 1386 1392 // FIXME 1387 1393 *output << endl; … … 1427 1433 return result; 1428 1434 } else { 1429 eLog() << Verbose(1) << "Cannot open output file:" << filename << endl;1435 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open output file:" << filename << endl); 1430 1436 return false; 1431 1437 } … … 1449 1455 output = new ofstream(fname->str().c_str(), ios::out); 1450 1456 if (output == NULL) { 1451 eLog() << Verbose(1) << "Cannot open mpqc output file:" << fname << endl;1457 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file:" << fname << endl); 1452 1458 delete(fname); 1453 1459 return false; … … 1492 1498 output = new ofstream(fname->str().c_str(), ios::out); 1493 1499 if (output == NULL) { 1494 eLog() << Verbose(1) << "Cannot open mpqc hessian output file:" << fname << endl;1500 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc hessian output file:" << fname << endl); 1495 1501 delete(fname); 1496 1502 return false; … … 1548 1554 f = fopen(name, "w" ); 1549 1555 if (f == NULL) { 1550 eLog() << Verbose(1) << "Cannot open pdb output file:" << name << endl;1556 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl); 1551 1557 return false; 1552 1558 } … … 1603 1609 f = fopen(name, "w" ); 1604 1610 if (f == NULL) { 1605 eLog() << Verbose(1) << "Cannot open pdb output file:" << name << endl;1611 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl); 1606 1612 Free(&elementNo); 1607 1613 return false; … … 1640 1646 /** Stores all atoms in a TREMOLO data input file. 1641 1647 * Note that this format cannot be parsed again. 1648 * Note that TREMOLO does not like Id starting at 0, but at 1. Atoms with Id 0 are discarded! 1642 1649 * \param *filename name of file (without ".in" suffix!) 1643 1650 * \param *mol pointer to molecule … … 1652 1659 output = new ofstream(fname->str().c_str(), ios::out); 1653 1660 if (output == NULL) { 1654 eLog() << Verbose(1) << "Cannot open tremolo output file:" << fname << endl;1661 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open tremolo output file:" << fname << endl); 1655 1662 delete(fname); 1656 1663 return false; … … 1694 1701 /** Stores all atoms from all molecules in a TREMOLO data input file. 1695 1702 * Note that this format cannot be parsed again. 1703 * Note that TREMOLO does not like Id starting at 0, but at 1. Atoms with Id 0 are discarded! 1696 1704 * \param *filename name of file (without ".in" suffix!) 1697 1705 * \param *MolList pointer to MoleculeListClass containing all atoms … … 1706 1714 output = new ofstream(fname->str().c_str(), ios::out); 1707 1715 if (output == NULL) { 1708 eLog() << Verbose(1) << "Cannot open tremolo output file:" << fname << endl;1716 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open tremolo output file:" << fname << endl); 1709 1717 delete(fname); 1710 1718 return false; … … 1746 1754 while (Walker->next != (*MolWalker)->end) { 1747 1755 Walker = Walker->next; 1748 *output << AtomNo << "\t";1756 *output << AtomNo+1 << "\t"; 1749 1757 *output << Walker->Name << "\t"; 1750 1758 *output << (*MolWalker)->name << "\t"; 1751 *output << MolCounter << "\t";1759 *output << MolCounter+1 << "\t"; 1752 1760 *output << Walker->node->x[0] << "\t" << Walker->node->x[1] << "\t" << Walker->node->x[2] << "\t"; 1753 1761 *output << (double)Walker->type->Valence << "\t"; 1754 1762 *output << Walker->type->symbol << "\t"; 1755 1763 for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++) 1756 *output << LocalNotoGlobalNoMap[MolCounter][ (*runner)->GetOtherAtom(Walker)->nr ] << "\t";1764 *output << LocalNotoGlobalNoMap[MolCounter][ (*runner)->GetOtherAtom(Walker)->nr ]+1 << "\t"; 1757 1765 for(int i=Walker->ListOfBonds.size(); i < MaxNeighbours; i++) 1758 1766 *output << "-\t"; … … 2123 2131 } 2124 2132 line++; 2125 } while ( dummy1 != NULL && (dummy1[0] == '#') || (dummy1[0] == '\n'));2133 } while ((dummy1 != NULL) && ((dummy1[0] == '#') || (dummy1[0] == '\n'))); 2126 2134 dummy = dummy1; 2127 2135 } else { // simple int, strings or doubles start in the same line -
src/datacreator.cpp
r491876 rc695c9 25 25 output.open(name.str().c_str(), ios::out); 26 26 if (output == NULL) { 27 Log() << Verbose(0) << "Unable to open " << name.str() << " for writing, is directory correct?" << endl;27 DoLog(0) && (Log() << Verbose(0) << "Unable to open " << name.str() << " for writing, is directory correct?" << endl); 28 28 return false; 29 29 } … … 43 43 output.open(name.str().c_str(), ios::app); 44 44 if (output == NULL) { 45 Log() << Verbose(0) << "Unable to open " << name.str() << " for writing, is directory correct?" << endl;45 DoLog(0) && (Log() << Verbose(0) << "Unable to open " << name.str() << " for writing, is directory correct?" << endl); 46 46 return false; 47 47 } … … 63 63 filename << prefix << ".dat"; 64 64 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 65 Log() << Verbose(0) << msg << endl;65 DoLog(0) && (Log() << Verbose(0) << msg << endl); 66 66 output << "# " << msg << ", created on " << datum; 67 67 output << "#Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl; … … 96 96 filename << prefix << ".dat"; 97 97 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 98 Log() << Verbose(0) << msg << endl;98 DoLog(0) && (Log() << Verbose(0) << msg << endl); 99 99 output << "# " << msg << ", created on " << datum; 100 100 output << "#Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl; … … 133 133 filename << prefix << ".dat"; 134 134 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 135 Log() << Verbose(0) << msg << endl;135 DoLog(0) && (Log() << Verbose(0) << msg << endl); 136 136 output << "# " << msg << ", created on " << datum; 137 137 output << "# Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl; … … 165 165 filename << prefix << ".dat"; 166 166 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 167 Log() << Verbose(0) << msg << endl;167 DoLog(0) && (Log() << Verbose(0) << msg << endl); 168 168 output << "# " << msg << ", created on " << datum; 169 169 output << "# Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl; … … 198 198 filename << prefix << ".dat"; 199 199 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 200 Log() << Verbose(0) << msg << endl;200 DoLog(0) && (Log() << Verbose(0) << msg << endl); 201 201 output << "# " << msg << ", created on " << datum; 202 202 output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl; … … 244 244 filename << prefix << ".dat"; 245 245 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 246 Log() << Verbose(0) << msg << endl;246 DoLog(0) && (Log() << Verbose(0) << msg << endl); 247 247 output << "# " << msg << ", created on " << datum; 248 248 output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl; … … 281 281 filename << prefix << ".dat"; 282 282 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 283 Log() << Verbose(0) << msg << endl;283 DoLog(0) && (Log() << Verbose(0) << msg << endl); 284 284 output << "# " << msg << ", created on " << datum; 285 285 output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl; … … 321 321 filename << prefix << ".dat"; 322 322 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 323 Log() << Verbose(0) << msg << endl;323 DoLog(0) && (Log() << Verbose(0) << msg << endl); 324 324 output << "# " << msg << ", created on " << datum; 325 325 output << "# AtomNo\t"; … … 363 363 filename << prefix << ".dat"; 364 364 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 365 Log() << Verbose(0) << msg << endl;365 DoLog(0) && (Log() << Verbose(0) << msg << endl); 366 366 output << "# " << msg << ", created on " << datum; 367 367 output << "# AtomNo\t" << Fragments.Header[ Fragments.MatrixCounter ] << endl; … … 393 393 filename << prefix << ".dat"; 394 394 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 395 Log() << Verbose(0) << msg << endl;395 DoLog(0) && (Log() << Verbose(0) << msg << endl); 396 396 output << "# " << msg << ", created on " << datum << endl; 397 397 output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl; … … 458 458 filename << prefix << ".dat"; 459 459 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 460 Log() << Verbose(0) << msg << endl;460 DoLog(0) && (Log() << Verbose(0) << msg << endl); 461 461 output << "# " << msg << ", created on " << datum; 462 462 output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl; -
src/defs.hpp
r491876 rc695c9 12 12 #define MAX_ELEMENTS 128 //!< maximum number of elements for certain lookup tables 13 13 #define AtomicLengthToAngstroem 0.52917721 //!< conversion factor from atomic length/bohrradius to angstroem 14 #define BONDTHRESHOLD 0.5 //!< CSD threshold in bond check which is the width of the interval whose center is the sum of the covalent radii15 14 #define AtomicEnergyToKelvin 315774.67 //!< conversion factor from atomic energy to kelvin via boltzmann factor 16 15 #define KelvinToAtomicTemperature 3.1668152e-06 //!< conversion factor for Kelvin to atomic temperature (Hartree over k_B) -
src/ellipsoid.cpp
r491876 rc695c9 146 146 { 147 147 int status = GSL_SUCCESS; 148 Log() << Verbose(2) << "Begin of FitPointSetToEllipsoid " << endl;148 DoLog(2) && (Log() << Verbose(2) << "Begin of FitPointSetToEllipsoid " << endl); 149 149 if (N >= 3) { // check that enough points are given (9 d.o.f.) 150 150 struct EllipsoidMinimisation par; … … 199 199 EllipsoidAngle[i] = gsl_vector_get (s->x, i+6); 200 200 } 201 Log() << Verbose(4) << setprecision(3) << "Converged fit at: " << *EllipsoidCenter << ", lengths " << EllipsoidLength[0] << ", " << EllipsoidLength[1] << ", " << EllipsoidLength[2] << ", angles " << EllipsoidAngle[0] << ", " << EllipsoidAngle[1] << ", " << EllipsoidAngle[2] << " with summed distance " << s->fval << "." << endl;201 DoLog(4) && (Log() << Verbose(4) << setprecision(3) << "Converged fit at: " << *EllipsoidCenter << ", lengths " << EllipsoidLength[0] << ", " << EllipsoidLength[1] << ", " << EllipsoidLength[2] << ", angles " << EllipsoidAngle[0] << ", " << EllipsoidAngle[1] << ", " << EllipsoidAngle[2] << " with summed distance " << s->fval << "." << endl); 202 202 } 203 203 … … 209 209 210 210 } else { 211 Log() << Verbose(3) << "Not enough points provided for fit to ellipsoid." << endl;211 DoLog(3) && (Log() << Verbose(3) << "Not enough points provided for fit to ellipsoid." << endl); 212 212 return false; 213 213 } 214 Log() << Verbose(2) << "End of FitPointSetToEllipsoid" << endl;214 DoLog(2) && (Log() << Verbose(2) << "End of FitPointSetToEllipsoid" << endl); 215 215 if (status == GSL_SUCCESS) 216 216 return true; … … 235 235 int index; 236 236 TesselPoint *Candidate = NULL; 237 Log() << Verbose(2) << "Begin of PickRandomPointSet" << endl;237 DoLog(2) && (Log() << Verbose(2) << "Begin of PickRandomPointSet" << endl); 238 238 239 239 // allocate array … … 241 241 x = new Vector[PointsToPick]; 242 242 } else { 243 eLog() << Verbose(2) << "Given pointer to vector array seems already allocated." << endl;243 DoeLog(2) && (eLog()<< Verbose(2) << "Given pointer to vector array seems already allocated." << endl); 244 244 } 245 245 … … 247 247 for(int i=0;i<NDIM;i++) // pick three random indices 248 248 LC->n[i] = (rand() % LC->N[i]); 249 Log() << Verbose(2) << "INFO: Center cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " ... ";249 DoLog(2) && (Log() << Verbose(2) << "INFO: Center cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " ... "); 250 250 // get random cell 251 const Linked Nodes *List = LC->GetCurrentCell();251 const LinkedCell::LinkedNodes *List = LC->GetCurrentCell(); 252 252 if (List == NULL) { // set index to it 253 253 continue; 254 254 } 255 Log() << Verbose(2) << "with No. " << LC->index << "." << endl;256 257 Log() << Verbose(2) << "LC Intervals:";255 DoLog(2) && (Log() << Verbose(2) << "with No. " << LC->index << "." << endl); 256 257 DoLog(2) && (Log() << Verbose(2) << "LC Intervals:"); 258 258 for (int i=0;i<NDIM;i++) { 259 259 Nlower[i] = ((LC->n[i]-1) >= 0) ? LC->n[i]-1 : 0; 260 260 Nupper[i] = ((LC->n[i]+1) < LC->N[i]) ? LC->n[i]+1 : LC->N[i]-1; 261 Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] ";262 } 263 Log() << Verbose(0) << endl;261 DoLog(0) && (Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] "); 262 } 263 DoLog(0) && (Log() << Verbose(0) << endl); 264 264 265 265 // count whether there are sufficient atoms in this cell+neighbors … … 268 268 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 269 269 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 270 const Linked Nodes *List = LC->GetCurrentCell();270 const LinkedCell::LinkedNodes *List = LC->GetCurrentCell(); 271 271 PointsLeft += List->size(); 272 272 } 273 Log() << Verbose(2) << "There are " << PointsLeft << " atoms in this neighbourhood." << endl;273 DoLog(2) && (Log() << Verbose(2) << "There are " << PointsLeft << " atoms in this neighbourhood." << endl); 274 274 if (PointsLeft < PointsToPick) { // ensure that we can pick enough points in its neighbourhood at all. 275 275 continue; … … 293 293 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 294 294 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 295 const Linked Nodes *List = LC->GetCurrentCell();295 const LinkedCell::LinkedNodes *List = LC->GetCurrentCell(); 296 296 // Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl; 297 297 if (List != NULL) { … … 300 300 // else 301 301 // Log() << Verbose(2) << "Cell is empty ... " << endl; 302 for (Linked Nodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {302 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 303 303 if ((current != PickedAtomNrs.end()) && (*current == index)) { 304 304 Candidate = (*Runner); 305 Log() << Verbose(2) << "Current picked node is " << **Runner << " with index " << index << "." << endl;305 DoLog(2) && (Log() << Verbose(2) << "Current picked node is " << **Runner << " with index " << index << "." << endl); 306 306 x[PointsPicked++].CopyVector(Candidate->node); // we have one more atom picked 307 307 current++; // next pre-picked atom … … 313 313 } 314 314 } 315 Log() << Verbose(2) << "The following points were picked: " << endl;315 DoLog(2) && (Log() << Verbose(2) << "The following points were picked: " << endl); 316 316 for (size_t i=0;i<PointsPicked;i++) 317 Log() << Verbose(2) << x[i] << endl;317 DoLog(2) && (Log() << Verbose(2) << x[i] << endl); 318 318 if (PointsPicked == PointsToPick) // break out of loop if we have all 319 319 break; 320 320 } while(1); 321 321 322 Log() << Verbose(2) << "End of PickRandomPointSet" << endl;322 DoLog(2) && (Log() << Verbose(2) << "End of PickRandomPointSet" << endl); 323 323 }; 324 324 … … 335 335 double value, threshold; 336 336 PointMap *List = &T->PointsOnBoundary; 337 Log() << Verbose(2) << "Begin of PickRandomPointSet" << endl;337 DoLog(2) && (Log() << Verbose(2) << "Begin of PickRandomPointSet" << endl); 338 338 339 339 // allocate array … … 341 341 x = new Vector[PointsToPick]; 342 342 } else { 343 eLog() << Verbose(2) << "Given pointer to vector array seems already allocated." << endl;343 DoeLog(2) && (eLog()<< Verbose(2) << "Given pointer to vector array seems already allocated." << endl); 344 344 } 345 345 … … 358 358 PointsLeft--; 359 359 } 360 Log() << Verbose(2) << "The following points were picked: " << endl;360 DoLog(2) && (Log() << Verbose(2) << "The following points were picked: " << endl); 361 361 for (size_t i=0;i<PointsPicked;i++) 362 Log() << Verbose(3) << x[i] << endl;363 364 Log() << Verbose(2) << "End of PickRandomPointSet" << endl;362 DoLog(3) && (Log() << Verbose(3) << x[i] << endl); 363 364 DoLog(2) && (Log() << Verbose(2) << "End of PickRandomPointSet" << endl); 365 365 }; 366 366 … … 382 382 double EllipsoidAngle[3]; 383 383 double distance, MaxDistance, MinDistance; 384 Log() << Verbose(0) << "Begin of FindDistributionOfEllipsoids" << endl;384 DoLog(0) && (Log() << Verbose(0) << "Begin of FindDistributionOfEllipsoids" << endl); 385 385 386 386 // construct center of gravity of boundary point set for initial ellipsoid center … … 389 389 Center.AddVector(Runner->second->node->node); 390 390 Center.Scale(1./T->PointsOnBoundaryCount); 391 Log() << Verbose(1) << "Center is at " << Center << "." << endl;391 DoLog(1) && (Log() << Verbose(1) << "Center is at " << Center << "." << endl); 392 392 393 393 // Output header … … 397 397 // loop over desired number of parameter sets 398 398 for (;number >0;number--) { 399 Log() << Verbose(1) << "Determining data set " << number << " ... " << endl;399 DoLog(1) && (Log() << Verbose(1) << "Determining data set " << number << " ... " << endl); 400 400 // pick the point set 401 401 x = NULL; … … 423 423 // fit the parameters 424 424 if (FitPointSetToEllipsoid(x, N, &EllipsoidCenter, &EllipsoidLength[0], &EllipsoidAngle[0])) { 425 Log() << Verbose(1) << "Picking succeeded!" << endl;425 DoLog(1) && (Log() << Verbose(1) << "Picking succeeded!" << endl); 426 426 // output obtained parameter set 427 427 output << number << "\t"; … … 434 434 output << endl; 435 435 } else { // increase N to pick one more 436 Log() << Verbose(1) << "Picking failed!" << endl;436 DoLog(1) && (Log() << Verbose(1) << "Picking failed!" << endl); 437 437 number++; 438 438 } … … 442 442 output.close(); 443 443 444 Log() << Verbose(0) << "End of FindDistributionOfEllipsoids" << endl;445 }; 444 DoLog(0) && (Log() << Verbose(0) << "End of FindDistributionOfEllipsoids" << endl); 445 }; -
src/errorlogger.cpp
r491876 rc695c9 81 81 int verbosityLevel = l.verbosity; 82 82 l.nix->clear(); 83 if (v.Do Output(verbosityLevel)) {83 if (v.DoErrorOutput(verbosityLevel)) { 84 84 switch(v.Verbosity) { 85 85 case 0: … … 104 104 int verbosityLevel = l->verbosity; 105 105 l->nix->clear(); 106 if (v.Do Output(verbosityLevel)) {106 if (v.DoErrorOutput(verbosityLevel)) { 107 107 switch(v.Verbosity) { 108 108 case 0: … … 113 113 break; 114 114 case 2: 115 default: 115 116 cerr << "WARNING: "; 116 break;117 default:118 117 break; 119 118 } -
src/graph.cpp
r491876 rc695c9 85 85 testGraphInsert = Fragment->Leaflet->insert(GraphPair (*Fragment->FragmentSet,pair<int,double>(Fragment->FragmentCounter,Fragment->TEFactor))); // store fragment number and current factor 86 86 if (testGraphInsert.second) { 87 Log() << Verbose(2) << "KeySet " << Fragment->FragmentCounter << " successfully inserted." << endl;87 DoLog(2) && (Log() << Verbose(2) << "KeySet " << Fragment->FragmentCounter << " successfully inserted." << endl); 88 88 Fragment->FragmentCounter++; 89 89 } else { 90 Log() << Verbose(2) << "KeySet " << Fragment->FragmentCounter << " failed to insert, present fragment is " << ((*(testGraphInsert.first)).second).first << endl;90 DoLog(2) && (Log() << Verbose(2) << "KeySet " << Fragment->FragmentCounter << " failed to insert, present fragment is " << ((*(testGraphInsert.first)).second).first << endl); 91 91 ((*(testGraphInsert.first)).second).second += Fragment->TEFactor; // increase the "created" counter 92 Log() << Verbose(2) << "New factor is " << ((*(testGraphInsert.first)).second).second << "." << endl;92 DoLog(2) && (Log() << Verbose(2) << "New factor is " << ((*(testGraphInsert.first)).second).second << "." << endl); 93 93 } 94 94 }; … … 115 115 testGraphInsert = graph1.insert(GraphPair ((*runner).first,pair<int,double>((*counter)++,((*runner).second).second))); // store fragment number and current factor 116 116 if (testGraphInsert.second) { 117 Log() << Verbose(2) << "KeySet " << (*counter)-1 << " successfully inserted." << endl;117 DoLog(2) && (Log() << Verbose(2) << "KeySet " << (*counter)-1 << " successfully inserted." << endl); 118 118 } else { 119 Log() << Verbose(2) << "KeySet " << (*counter)-1 << " failed to insert, present fragment is " << ((*(testGraphInsert.first)).second).first << endl;119 DoLog(2) && (Log() << Verbose(2) << "KeySet " << (*counter)-1 << " failed to insert, present fragment is " << ((*(testGraphInsert.first)).second).first << endl); 120 120 ((*(testGraphInsert.first)).second).second += (*runner).second.second; 121 Log() << Verbose(2) << "New factor is " << (*(testGraphInsert.first)).second.second << "." << endl;121 DoLog(2) && (Log() << Verbose(2) << "New factor is " << (*(testGraphInsert.first)).second.second << "." << endl); 122 122 } 123 123 } -
src/helpers.cpp
r491876 rc695c9 19 19 double test = 0.1439851348959832147598734598273456723948652983045928346598365; 20 20 do { 21 Log() << Verbose(0) << text;21 DoLog(0) && (Log() << Verbose(0) << text); 22 22 cin >> test; 23 23 } while (test == 0.1439851348959832147598734598273456723948652983045928346598365); -
src/helpers.hpp
r491876 rc695c9 76 76 }; 77 77 78 /** returns greater of the two values. 79 * \param x first value 80 * \param y second value 81 * \return greater of the two (by operator>()) 82 */ 83 template <typename T> T Max(T x, T y) 84 { 85 if (x > y) 86 return x; 87 else return y; 88 }; 89 90 /** returns smaller of the two values. 91 * \param x first value 92 * \param y second value 93 * \return smaller of the two (by operator<()) 94 */ 95 template <typename T> T Min(T x, T y) 96 { 97 if (x < y) 98 return x; 99 else return y; 100 }; 101 78 102 /** Creates a lookup table for true father's Atom::Nr -> atom ptr. 79 103 * \param *start begin of chain list … … 90 114 91 115 if (LookupTable != NULL) { 92 Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl;116 DoLog(0) && (Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl); 93 117 return false; 94 118 } … … 103 127 } 104 128 if (count <= 0) { 105 Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl;129 DoLog(0) && (Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl); 106 130 return false; 107 131 } … … 110 134 LookupTable = Calloc<T*>(count, "CreateFatherLookupTable - **LookupTable"); 111 135 if (LookupTable == NULL) { 112 eLog() << Verbose(0) << "LookupTable memory allocation failed!" << endl;136 DoeLog(0) && (eLog()<< Verbose(0) << "LookupTable memory allocation failed!" << endl); 113 137 performCriticalExit(); 114 138 status = false; … … 122 146 LookupTable[AtomNo] = Walker; 123 147 } else { 124 Log() << Verbose(0) << "Walker " << *Walker << " exceeded range of nuclear ids [0, " << count << ")." << endl;148 DoLog(0) && (Log() << Verbose(0) << "Walker " << *Walker << " exceeded range of nuclear ids [0, " << count << ")." << endl); 125 149 status = false; 126 150 break; -
src/info.cpp
r491876 rc695c9 21 21 verbosity++; 22 22 FunctionName = msg; 23 Log() << Verbose(0) << "Begin of " << FunctionName << endl;23 DoLog(0) && (Log() << Verbose(0) << "Begin of " << FunctionName << endl); 24 24 }; 25 25 … … 28 28 */ 29 29 Info::~Info() { 30 Log() << Verbose(0) << "End of " << FunctionName << endl;30 DoLog(0) && (Log() << Verbose(0) << "End of " << FunctionName << endl); 31 31 verbosity--; 32 32 } -
src/joiner.cpp
r491876 rc695c9 7 7 8 8 //============================ INCLUDES =========================== 9 10 #include <cstring> 9 11 10 12 #include "datacreator.hpp" … … 45 47 bool NoHessian = false; 46 48 47 Log() << Verbose(0) << "Joiner" << endl;48 Log() << Verbose(0) << "======" << endl;49 DoLog(0) && (Log() << Verbose(0) << "Joiner" << endl); 50 DoLog(0) && (Log() << Verbose(0) << "======" << endl); 49 51 50 52 // Get the command line options 51 53 if (argc < 3) { 52 Log() << Verbose(0) << "Usage: " << argv[0] << " <inputdir> <prefix> [elementsdb]" << endl;53 Log() << Verbose(0) << "<inputdir>\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl;54 Log() << Verbose(0) << "<prefix>\tprefix of energy and forces file." << endl;55 Log() << Verbose(0) << "[elementsdb]\tpath to elements database, needed for shieldings." << endl;54 DoLog(0) && (Log() << Verbose(0) << "Usage: " << argv[0] << " <inputdir> <prefix> [elementsdb]" << endl); 55 DoLog(0) && (Log() << Verbose(0) << "<inputdir>\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl); 56 DoLog(0) && (Log() << Verbose(0) << "<prefix>\tprefix of energy and forces file." << endl); 57 DoLog(0) && (Log() << Verbose(0) << "[elementsdb]\tpath to elements database, needed for shieldings." << endl); 56 58 return 1; 57 59 } else { … … 75 77 if (!Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX, 0,0)) { 76 78 NoHCorrection = true; 77 Log() << Verbose(0) << "No HCorrection matrices found, skipping these." << endl;79 DoLog(0) && (Log() << Verbose(0) << "No HCorrection matrices found, skipping these." << endl); 78 80 } 79 81 if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix, 0,0)) return 1; 80 82 if (!Hessian.ParseFragmentMatrix(argv[1], dir, HessianSuffix, 0,0)) { 81 83 NoHessian = true; 82 Log() << Verbose(0) << "No hessian matrices found, skipping these." << endl;84 DoLog(0) && (Log() << Verbose(0) << "No hessian matrices found, skipping these." << endl); 83 85 } 84 86 if (periode != NULL) { // also look for PAS values … … 144 146 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 145 147 // --------- sum up energy -------------------- 146 Log() << Verbose(0) << "Summing energy of order " << BondOrder+1 << " ..." << endl;148 DoLog(0) && (Log() << Verbose(0) << "Summing energy of order " << BondOrder+1 << " ..." << endl); 147 149 if (!EnergyFragments.SumSubManyBodyTerms(Energy, KeySet, BondOrder)) return 1; 148 150 if (!NoHCorrection) { … … 153 155 if (!Energy.SumSubEnergy(EnergyFragments, NULL, KeySet, BondOrder, 1.)) return 1; 154 156 // --------- sum up Forces -------------------- 155 Log() << Verbose(0) << "Summing forces of order " << BondOrder+1 << " ..." << endl;157 DoLog(0) && (Log() << Verbose(0) << "Summing forces of order " << BondOrder+1 << " ..." << endl); 156 158 if (!ForceFragments.SumSubManyBodyTerms(Force, KeySet, BondOrder)) return 1; 157 159 if (!Force.SumSubForces(ForceFragments, KeySet, BondOrder, 1.)) return 1; 158 160 // --------- sum up Hessian -------------------- 159 161 if (!NoHessian) { 160 Log() << Verbose(0) << "Summing Hessian of order " << BondOrder+1 << " ..." << endl;162 DoLog(0) && (Log() << Verbose(0) << "Summing Hessian of order " << BondOrder+1 << " ..." << endl); 161 163 if (!HessianFragments.SumSubManyBodyTerms(Hessian, KeySet, BondOrder)) return 1; 162 164 if (!Hessian.SumSubHessians(HessianFragments, KeySet, BondOrder, 1.)) return 1; 163 165 } 164 166 if (periode != NULL) { // also look for PAS values 165 Log() << Verbose(0) << "Summing shieldings and susceptibilities of order " << BondOrder+1 << " ..." << endl;167 DoLog(0) && (Log() << Verbose(0) << "Summing shieldings and susceptibilities of order " << BondOrder+1 << " ..." << endl); 166 168 if (!ShieldingFragments.SumSubManyBodyTerms(Shielding, KeySet, BondOrder)) return 1; 167 169 if (!Shielding.SumSubForces(ShieldingFragments, KeySet, BondOrder, 1.)) return 1; … … 177 179 prefix.str(" "); 178 180 prefix << dir << OrderSuffix << (BondOrder+1); 179 Log() << Verbose(0) << "Writing files " << argv[1] << prefix.str() << ". ..." << endl;181 DoLog(0) && (Log() << Verbose(0) << "Writing files " << argv[1] << prefix.str() << ". ..." << endl); 180 182 // energy 181 183 if (!Energy.WriteLastMatrix(argv[1], (prefix.str()).c_str(), EnergySuffix)) return 1; … … 242 244 delete(periode); 243 245 Free(&dir); 244 Log() << Verbose(0) << "done." << endl;246 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 245 247 return 0; 246 248 }; -
src/linkedcell.cpp
r491876 rc695c9 45 45 max.Zero(); 46 46 min.Zero(); 47 Log() << Verbose(1) << "Begin of LinkedCell" << endl;48 if ( set->IsEmpty()) {49 eLog() << Verbose(1) << "set contains no linked cell nodes!" << endl;47 DoLog(1) && (Log() << Verbose(1) << "Begin of LinkedCell" << endl); 48 if ((set == NULL) || (set->IsEmpty())) { 49 DoeLog(1) && (eLog()<< Verbose(1) << "set is NULL or contains no linked cell nodes!" << endl); 50 50 return; 51 51 } … … 68 68 set->GoToNext(); 69 69 } 70 Log() << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl;70 DoLog(2) && (Log() << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl); 71 71 72 72 // 2. find then number of cells per axis … … 74 74 N[i] = (int)floor((max.x[i] - min.x[i])/RADIUS)+1; 75 75 } 76 Log() << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl;76 DoLog(2) && (Log() << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl); 77 77 78 78 // 3. allocate the lists 79 Log() << Verbose(2) << "Allocating cells ... ";79 DoLog(2) && (Log() << Verbose(2) << "Allocating cells ... "); 80 80 if (LC != NULL) { 81 eLog() << Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl;81 DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl); 82 82 return; 83 83 } … … 86 86 LC [index].clear(); 87 87 } 88 Log() << Verbose(0) << "done." << endl;88 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 89 89 90 90 // 4. put each atom into its respective cell 91 Log() << Verbose(2) << "Filling cells ... ";91 DoLog(2) && (Log() << Verbose(2) << "Filling cells ... "); 92 92 set->GoToFirst(); 93 93 while (!set->IsEnd()) { … … 101 101 set->GoToNext(); 102 102 } 103 Log() << Verbose(0) << "done." << endl;104 Log() << Verbose(1) << "End of LinkedCell" << endl;103 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 104 DoLog(1) && (Log() << Verbose(1) << "End of LinkedCell" << endl); 105 105 }; 106 106 … … 120 120 max.Zero(); 121 121 min.Zero(); 122 Log() << Verbose(1) << "Begin of LinkedCell" << endl;122 DoLog(1) && (Log() << Verbose(1) << "Begin of LinkedCell" << endl); 123 123 if (set->empty()) { 124 eLog() << Verbose(1) << "set contains no linked cell nodes!" << endl;124 DoeLog(1) && (eLog()<< Verbose(1) << "set contains no linked cell nodes!" << endl); 125 125 return; 126 126 } … … 140 140 } 141 141 } 142 Log() << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl;142 DoLog(2) && (Log() << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl); 143 143 144 144 // 2. find then number of cells per axis … … 146 146 N[i] = (int)floor((max.x[i] - min.x[i])/RADIUS)+1; 147 147 } 148 Log() << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl;148 DoLog(2) && (Log() << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl); 149 149 150 150 // 3. allocate the lists 151 Log() << Verbose(2) << "Allocating cells ... ";151 DoLog(2) && (Log() << Verbose(2) << "Allocating cells ... "); 152 152 if (LC != NULL) { 153 eLog() << Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl;153 DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl); 154 154 return; 155 155 } … … 158 158 LC [index].clear(); 159 159 } 160 Log() << Verbose(0) << "done." << endl;160 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 161 161 162 162 // 4. put each atom into its respective cell 163 Log() << Verbose(2) << "Filling cells ... ";163 DoLog(2) && (Log() << Verbose(2) << "Filling cells ... "); 164 164 for (LinkedNodes::iterator Runner = set->begin(); Runner != set->end(); Runner++) { 165 165 Walker = *Runner; … … 171 171 //Log() << Verbose(2) << *Walker << " goes into cell " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl; 172 172 } 173 Log() << Verbose(0) << "done." << endl;174 Log() << Verbose(1) << "End of LinkedCell" << endl;173 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 174 DoLog(1) && (Log() << Verbose(1) << "End of LinkedCell" << endl); 175 175 }; 176 176 … … 199 199 status = status && ((n[i] >=0) && (n[i] < N[i])); 200 200 if (!status) 201 eLog() << Verbose(1) << "indices are out of bounds!" << endl;201 DoeLog(1) && (eLog()<< Verbose(1) << "indices are out of bounds!" << endl); 202 202 return status; 203 203 }; … … 220 220 * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[] are out of bounds. 221 221 */ 222 const Linked Nodes* LinkedCell::GetCurrentCell() const222 const LinkedCell::LinkedNodes* LinkedCell::GetCurrentCell() const 223 223 { 224 224 if (CheckBounds()) { … … 234 234 * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[]+relative[] are out of bounds. 235 235 */ 236 const Linked Nodes* LinkedCell::GetRelativeToCurrentCell(const int relative[NDIM]) const236 const LinkedCell::LinkedNodes* LinkedCell::GetRelativeToCurrentCell(const int relative[NDIM]) const 237 237 { 238 238 if (CheckBounds(relative)) { … … 242 242 return NULL; 243 243 } 244 }; 245 246 /** Set the index to the cell containing a given Vector *x. 247 * \param *x Vector with coordinates 248 * \return Vector is inside bounding box - true, else - false 249 */ 250 bool LinkedCell::SetIndexToVector(const Vector * const x) const 251 { 252 for (int i=0;i<NDIM;i++) 253 n[i] = (int)floor((x->x[i] - min.x[i])/RADIUS); 254 255 return CheckBounds(); 244 256 }; 245 257 … … 260 272 return status; 261 273 } else { 262 eLog() << Verbose(1) << "Node at " << *Walker << " is out of bounds." << endl;274 DoeLog(1) && (eLog()<< Verbose(1) << "Node at " << *Walker << " is out of bounds." << endl); 263 275 return false; 264 276 } … … 268 280 * \param *lower lower bounds 269 281 * \param *upper upper bounds 270 */ 271 void LinkedCell::GetNeighbourBounds(int lower[NDIM], int upper[NDIM]) const 272 { 273 for (int i=0;i<NDIM;i++) { 274 lower[i] = ((n[i]-1) >= 0) ? n[i]-1 : 0; 275 upper[i] = ((n[i]+1) < N[i]) ? n[i]+1 : N[i]-1; 276 //Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] "; 277 // check for this axis whether the point is outside of our grid 282 * \param step how deep to check the neighbouring cells (i.e. number of layers to check) 283 */ 284 void LinkedCell::GetNeighbourBounds(int lower[NDIM], int upper[NDIM], int step) const 285 { 286 for (int i=0;i<NDIM;i++) { 287 lower[i] = n[i]; 288 for (int s=step; s>0;--s) 289 if ((n[i]-s) >= 0) { 290 lower[i] = n[i]-s; 291 break; 292 } 293 upper[i] = n[i]; 294 for (int s=step; s>0;--s) 295 if ((n[i]+s) < N[i]) { 296 upper[i] = n[i]+s; 297 break; 298 } 299 //Log() << Verbose(0) << "axis " << i << " has bounds [" << lower[i] << "," << upper[i] << "]" << endl; 300 } 301 }; 302 303 /** Returns a list with all neighbours from the current LinkedCell::index. 304 * \param distance (if no distance, then adjacent cells are taken) 305 * \return list of tesselpoints 306 */ 307 LinkedCell::LinkedNodes* LinkedCell::GetallNeighbours(const double distance) const 308 { 309 int Nlower[NDIM], Nupper[NDIM]; 310 TesselPoint *Walker = NULL; 311 LinkedNodes *TesselList = new LinkedNodes; 312 313 // then go through the current and all neighbouring cells and check the contained points for possible candidates 314 const int step = (distance == 0) ? 1 : (int)floor(distance/RADIUS + 1.); 315 GetNeighbourBounds(Nlower, Nupper, step); 316 317 //Log() << Verbose(0) << endl; 318 for (n[0] = Nlower[0]; n[0] <= Nupper[0]; n[0]++) 319 for (n[1] = Nlower[1]; n[1] <= Nupper[1]; n[1]++) 320 for (n[2] = Nlower[2]; n[2] <= Nupper[2]; n[2]++) { 321 const LinkedNodes *List = GetCurrentCell(); 322 //Log() << Verbose(1) << "Current cell is " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl; 323 if (List != NULL) { 324 for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 325 Walker = *Runner; 326 TesselList->push_back(Walker); 327 } 328 } 329 } 330 return TesselList; 331 }; 332 333 /** Set the index to the cell containing a given Vector *x, which is not inside the LinkedCell's domain 334 * Note that as we have to check distance from every corner of the closest cell, this function is faw more 335 * expensive and if Vector is known to be inside LinkedCell's domain, then SetIndexToVector() should be used. 336 * \param *x Vector with coordinates 337 * \return minimum squared distance of cell to given vector (if inside of domain, distance is 0) 338 */ 339 double LinkedCell::SetClosestIndexToOutsideVector(const Vector * const x) const 340 { 341 for (int i=0;i<NDIM;i++) { 342 n[i] = (int)floor((x->x[i] - min.x[i])/RADIUS); 278 343 if (n[i] < 0) 279 upper[i] = lower[i]; 280 if (n[i] > N[i]) 281 lower[i] = upper[i]; 282 283 //Log() << Verbose(0) << "axis " << i << " has bounds [" << lower[i] << "," << upper[i] << "]" << endl; 284 } 285 }; 286 287 /** Calculates the index for a given Vector *x. 288 * \param *x Vector with coordinates 289 * \return Vector is inside bounding box - true, else - false 290 */ 291 bool LinkedCell::SetIndexToVector(const Vector * const x) const 292 { 293 bool status = true; 294 for (int i=0;i<NDIM;i++) { 295 n[i] = (int)floor((x->x[i] - min.x[i])/RADIUS); 296 if (max.x[i] < x->x[i]) 297 status = false; 298 if (min.x[i] > x->x[i]) 299 status = false; 300 } 301 return status; 302 }; 303 344 n[i] = 0; 345 if (n[i] >= N[i]) 346 n[i] = N[i]-1; 347 } 348 349 // calculate distance of cell to vector 350 double distanceSquared = 0.; 351 bool outside = true; // flag whether x is found in- or outside of LinkedCell's domain/closest cell 352 Vector corner; // current corner of closest cell 353 Vector tester; // Vector pointing from corner to center of closest cell 354 Vector Distance; // Vector from corner of closest cell to x 355 356 Vector center; // center of the closest cell 357 for (int i=0;i<NDIM;i++) 358 center.x[i] = min.x[i]+((double)n[i]+.5)*RADIUS; 359 360 int c[NDIM]; 361 for (c[0]=0;c[0]<=1;c[0]++) 362 for (c[1]=0; c[1]<=1;c[1]++) 363 for (c[2]=0; c[2]<=1;c[2]++) { 364 // set up corner 365 for (int i=0;i<NDIM;i++) 366 corner.x[i] = min.x[i]+RADIUS*((double)n[i]+c[i]); 367 // set up distance vector 368 Distance.CopyVector(x); 369 Distance.SubtractVector(&corner); 370 const double dist = Distance.NormSquared(); 371 // check whether distance is smaller 372 if (dist< distanceSquared) 373 distanceSquared = dist; 374 // check whether distance vector goes inside or outside 375 tester.CopyVector(¢er); 376 tester.SubtractVector(&corner); 377 if (tester.ScalarProduct(&Distance) < 0) 378 outside = false; 379 } 380 return (outside ? distanceSquared : 0.); 381 }; 382 383 /** Returns a list of all TesselPoint with distance less than \a radius to \a *Center. 384 * \param radius radius of sphere 385 * \param *center center of sphere 386 * \return list of all points inside sphere 387 */ 388 LinkedCell::LinkedNodes* LinkedCell::GetPointsInsideSphere(const double radius, const Vector * const center) const 389 { 390 const double radiusSquared = radius*radius; 391 TesselPoint *Walker = NULL; 392 LinkedNodes *TesselList = new LinkedNodes; 393 LinkedNodes *NeighbourList = NULL; 394 395 // set index of LC to center of sphere 396 const double dist = SetClosestIndexToOutsideVector(center); 397 if (dist > 2.*radius) { 398 DoeLog(1) && (eLog()<< Verbose(1) << "Vector " << *center << " is too far away from any atom in LinkedCell's bounding box." << endl); 399 return TesselList; 400 } else 401 DoLog(1) && (Log() << Verbose(1) << "Distance of closest cell to center of sphere with radius " << radius << " is " << dist << "." << endl); 402 403 // gather all neighbours first, then look who fulfills distance criteria 404 NeighbourList = GetallNeighbours(2.*radius-dist); 405 //Log() << Verbose(1) << "I found " << NeighbourList->size() << " neighbours to check." << endl; 406 if (NeighbourList != NULL) { 407 for (LinkedNodes::const_iterator Runner = NeighbourList->begin(); Runner != NeighbourList->end(); Runner++) { 408 Walker = *Runner; 409 //Log() << Verbose(1) << "Current neighbour is at " << *Walker->node << "." << endl; 410 if ((center->DistanceSquared(Walker->node) - radiusSquared) < MYEPSILON) { 411 TesselList->push_back(Walker); 412 } 413 } 414 delete(NeighbourList); 415 } else 416 DoeLog(2) && (eLog()<< Verbose(2) << "Around vector " << *center << " there are no atoms." << endl); 417 return TesselList; 418 }; -
src/linkedcell.hpp
r491876 rc695c9 33 33 /********************************************** definitions *********************************/ 34 34 35 #define LinkedNodes list<TesselPoint *>36 35 37 36 /********************************************** declarations *******************************/ … … 40 39 */ 41 40 class LinkedCell { 42 public: 41 private: 42 43 public: 44 typedef list<TesselPoint *> LinkedNodes; 45 46 43 47 Vector max; // upper boundary 44 48 Vector min; // lower boundary … … 53 57 LinkedCell(LinkedNodes *set, const double radius); 54 58 ~LinkedCell(); 55 const Linked Nodes* GetCurrentCell()const ;56 const Linked Nodes* GetRelativeToCurrentCell(const int relative[NDIM])const ;59 const LinkedCell::LinkedNodes* GetCurrentCell()const ; 60 const LinkedCell::LinkedNodes* GetRelativeToCurrentCell(const int relative[NDIM])const ; 57 61 bool SetIndexToNode(const TesselPoint * const Walker)const ; 58 62 bool SetIndexToVector(const Vector * const x)const ; 63 double SetClosestIndexToOutsideVector(const Vector * const x) const; 59 64 bool CheckBounds()const ; 60 65 bool CheckBounds(const int relative[NDIM])const ; 61 void GetNeighbourBounds(int lower[NDIM], int upper[NDIM] )const ;66 void GetNeighbourBounds(int lower[NDIM], int upper[NDIM], int step = 1)const ; 62 67 68 LinkedCell::LinkedNodes* GetallNeighbours(const double distance = 0) const; 69 LinkedCell::LinkedNodes* GetPointsInsideSphere(const double radius, const Vector * const center) const; 63 70 // not implemented yet 64 71 bool AddNode(Vector *Walker); -
src/log.cpp
r491876 rc695c9 16 16 void setVerbosity(int verbosityLevel) { 17 17 logger::getInstance()->setVerbosity(verbosityLevel); 18 errorLogger::getInstance()->setVerbosity(verbosityLevel);19 18 } 20 19 … … 28 27 } 29 28 29 /** Checks verbosity for logger. 30 * Is supposed to be used in construct as this: 31 * DoLog(2) && (Log() << Verbose(2) << "message." << endl); 32 * If DoLog does not return true, the right-hand side is not evaluated and we save some time. 33 * \param verbose verbosity level of this message 34 * \return true - print, false - don't 35 */ 36 bool DoLog(int verbose) { 37 return (verbose <= logger::getInstance()->verbosity); 38 } 39 40 /** Checks verbosity for errorlogger. 41 * Is supposed to be used in construct as this: 42 * DoLog(2) && (Log() << Verbose(2) << "message." << endl); 43 * If DoLog does not return true, the right-hand side is not evaluated and we save some time. 44 * \param verbose verbosity level of this message 45 * \return true - print, false - don't 46 */ 47 bool DoeLog(int verbose) { 48 return (verbose <= errorLogger::getInstance()->verbosity); 49 } 50 30 51 /** 31 52 * Prints an error log entry. -
src/log.hpp
r491876 rc695c9 15 15 class errorLogger * eLog(); 16 16 void setVerbosity(int verbosityLevel); 17 bool DoLog(int verbose); 18 bool DoeLog(int verbose); 17 19 18 20 #endif /* LOG_HPP_ */ -
src/memoryallocator.hpp
r491876 rc695c9 16 16 #endif 17 17 18 #include <cstdlib> 18 19 #include <iostream> 19 20 #include <iomanip> -
src/memoryusageobserver.cpp
r491876 rc695c9 4 4 * This class represents a Singleton for observing memory usage. 5 5 */ 6 7 #include <cstdlib> 6 8 7 9 #include "log.hpp" … … 91 93 << pointer << " is not registered by MemoryUsageObserver: "; 92 94 if (msg != NULL) 93 Log() << Verbose(0) << *msg;94 Log() << Verbose(0) << endl;95 DoLog(0) && (Log() << Verbose(0) << *msg); 96 DoLog(0) && (Log() << Verbose(0) << endl); 95 97 return; 96 98 } -
src/molecule.cpp
r491876 rc695c9 4 4 * 5 5 */ 6 7 #include <cstring> 6 8 7 9 #include "atom.hpp" … … 21 23 #include "tesselation.hpp" 22 24 #include "vector.hpp" 25 #include "World.hpp" 23 26 24 27 /************************************* Functions for class molecule *********************************/ … … 43 46 for(int i=MAX_ELEMENTS;i--;) 44 47 ElementsInMolecule[i] = 0; 45 cell_size[0] = cell_size[2] = cell_size[5]= 20.; 46 cell_size[1] = cell_size[3] = cell_size[4]= 0.; 47 strcpy(name,"none"); 48 strcpy(name,World::get()->DefaultName); 48 49 }; 49 50 … … 157 158 double *matrix = NULL; 158 159 bond *Binder = NULL; 160 double * const cell_size = World::get()->cell_size; 159 161 160 162 // Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl; … … 192 194 BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1]; 193 195 if (BondRescale == -1) { 194 eLog() << Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;196 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl); 195 197 return false; 196 198 BondRescale = bondlength; … … 235 237 SecondOtherAtom = (*Runner)->GetOtherAtom(TopOrigin); 236 238 } else { 237 eLog() << Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->Name;239 DoeLog(2) && (eLog()<< Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->Name); 238 240 } 239 241 } … … 272 274 bondangle = TopOrigin->type->HBondAngle[1]; 273 275 if (bondangle == -1) { 274 eLog() << Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;276 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl); 275 277 return false; 276 278 bondangle = 0; … … 394 396 break; 395 397 default: 396 eLog() << Verbose(1) << "BondDegree does not state single, double or triple bond!" << endl;398 DoeLog(1) && (eLog()<< Verbose(1) << "BondDegree does not state single, double or triple bond!" << endl); 397 399 AllWentWell = false; 398 400 break; … … 427 429 input = new istringstream(line); 428 430 *input >> NumberOfAtoms; 429 Log() << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl;431 DoLog(0) && (Log() << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl); 430 432 getline(xyzfile,line,'\n'); // Read comment 431 Log() << Verbose(1) << "Comment: " << line << endl;433 DoLog(1) && (Log() << Verbose(1) << "Comment: " << line << endl); 432 434 433 435 if (MDSteps == 0) // no atoms yet present … … 445 447 Walker->type = elemente->FindElement(shorthand); 446 448 if (Walker->type == NULL) { 447 eLog() << Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H.";449 DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H."); 448 450 Walker->type = elemente->FindElement(1); 449 451 } … … 541 543 add(Binder, last); 542 544 } else { 543 eLog() << Verbose(1) << "Could not add bond between " << atom1->Name << " and " << atom2->Name << " as one or both are not present in the molecule." << endl;545 DoeLog(1) && (eLog()<< Verbose(1) << "Could not add bond between " << atom1->Name << " and " << atom2->Name << " as one or both are not present in the molecule." << endl); 544 546 } 545 547 return Binder; … … 553 555 bool molecule::RemoveBond(bond *pointer) 554 556 { 555 // eLog() << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;557 //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl); 556 558 pointer->leftatom->RegisterBond(pointer); 557 559 pointer->rightatom->RegisterBond(pointer); … … 567 569 bool molecule::RemoveBonds(atom *BondPartner) 568 570 { 569 // eLog() << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;571 //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl); 570 572 BondList::const_iterator ForeRunner; 571 573 while (!BondPartner->ListOfBonds.empty()) { … … 587 589 else 588 590 molname = filename; // contains no slashes 589 c har *endname = strchr(molname, '.');591 const char *endname = strchr(molname, '.'); 590 592 if ((endname == NULL) || (endname < molname)) 591 593 length = strlen(molname); … … 601 603 void molecule::SetBoxDimension(Vector *dim) 602 604 { 605 double * const cell_size = World::get()->cell_size; 603 606 cell_size[0] = dim->x[0]; 604 607 cell_size[1] = 0.; … … 619 622 AtomCount--; 620 623 } else 621 eLog() << Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl;624 DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl); 622 625 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 623 626 ElementCount--; … … 637 640 ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element 638 641 else 639 eLog() << Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl;642 DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl); 640 643 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 641 644 ElementCount--; … … 662 665 return walker; 663 666 } else { 664 Log() << Verbose(0) << "Atom not found in list." << endl;667 DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl); 665 668 return NULL; 666 669 } … … 678 681 //mol->Output((ofstream *)&cout); 679 682 //Log() << Verbose(0) << "===============================================" << endl; 680 Log() << Verbose(0) << text;683 DoLog(0) && (Log() << Verbose(0) << text); 681 684 cin >> No; 682 685 ion = this->FindAtom(No); … … 691 694 bool molecule::CheckBounds(const Vector *x) const 692 695 { 696 double * const cell_size = World::get()->cell_size; 693 697 bool result = true; 694 698 int j =-1; … … 766 770 void molecule::OutputListOfBonds() const 767 771 { 768 Log() << Verbose(2) << endl << "From Contents of ListOfBonds, all non-hydrogen atoms:" << endl;772 DoLog(2) && (Log() << Verbose(2) << endl << "From Contents of ListOfBonds, all non-hydrogen atoms:" << endl); 769 773 ActOnAllAtoms (&atom::OutputBondOfAtom ); 770 Log() << Verbose(0) << endl;774 DoLog(0) && (Log() << Verbose(0) << endl); 771 775 }; 772 776 … … 825 829 } 826 830 if ((AtomCount == 0) || (i != AtomCount)) { 827 Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl;831 DoLog(3) && (Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl); 828 832 AtomCount = i; 829 833 … … 841 845 Walker->Name = Malloc<char>(6, "molecule::CountAtoms: *walker->Name"); 842 846 sprintf(Walker->Name, "%2s%02d", Walker->type->symbol, Walker->nr+1); 843 Log() << Verbose(3) << "Naming atom nr. " << Walker->nr << " " << Walker->Name << "." << endl;847 DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << Walker->nr << " " << Walker->Name << "." << endl); 844 848 i++; 845 849 } 846 850 } else 847 Log() << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl;851 DoLog(3) && (Log() << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl); 848 852 } 849 853 }; … … 905 909 bool result = true; // status of comparison 906 910 907 Log() << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl;911 DoLog(3) && (Log() << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl); 908 912 /// first count both their atoms and elements and update lists thereby ... 909 913 //Log() << Verbose(0) << "Counting atoms, updating list" << endl; … … 917 921 if (result) { 918 922 if (AtomCount != OtherMolecule->AtomCount) { 919 Log() << Verbose(4) << "AtomCounts don't match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;923 DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl); 920 924 result = false; 921 925 } else Log() << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl; … … 924 928 if (result) { 925 929 if (ElementCount != OtherMolecule->ElementCount) { 926 Log() << Verbose(4) << "ElementCount don't match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl;930 DoLog(4) && (Log() << Verbose(4) << "ElementCount don't match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl); 927 931 result = false; 928 932 } else Log() << Verbose(4) << "ElementCount match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl; … … 936 940 } 937 941 if (flag < MAX_ELEMENTS) { 938 Log() << Verbose(4) << "ElementsInMolecule don't match." << endl;942 DoLog(4) && (Log() << Verbose(4) << "ElementsInMolecule don't match." << endl); 939 943 result = false; 940 944 } else Log() << Verbose(4) << "ElementsInMolecule match." << endl; … … 942 946 /// then determine and compare center of gravity for each molecule ... 943 947 if (result) { 944 Log() << Verbose(5) << "Calculating Centers of Gravity" << endl;948 DoLog(5) && (Log() << Verbose(5) << "Calculating Centers of Gravity" << endl); 945 949 DeterminePeriodicCenter(CenterOfGravity); 946 950 OtherMolecule->DeterminePeriodicCenter(OtherCenterOfGravity); 947 Log() << Verbose(5) << "Center of Gravity: ";951 DoLog(5) && (Log() << Verbose(5) << "Center of Gravity: "); 948 952 CenterOfGravity.Output(); 949 Log() << Verbose(0) << endl << Verbose(5) << "Other Center of Gravity: ";953 DoLog(0) && (Log() << Verbose(0) << endl << Verbose(5) << "Other Center of Gravity: "); 950 954 OtherCenterOfGravity.Output(); 951 Log() << Verbose(0) << endl;955 DoLog(0) && (Log() << Verbose(0) << endl); 952 956 if (CenterOfGravity.DistanceSquared(&OtherCenterOfGravity) > threshold*threshold) { 953 Log() << Verbose(4) << "Centers of gravity don't match." << endl;957 DoLog(4) && (Log() << Verbose(4) << "Centers of gravity don't match." << endl); 954 958 result = false; 955 959 } … … 958 962 /// ... then make a list with the euclidian distance to this center for each atom of both molecules 959 963 if (result) { 960 Log() << Verbose(5) << "Calculating distances" << endl;964 DoLog(5) && (Log() << Verbose(5) << "Calculating distances" << endl); 961 965 Distances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances"); 962 966 OtherDistances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances"); … … 965 969 966 970 /// ... sort each list (using heapsort (o(N log N)) from GSL) 967 Log() << Verbose(5) << "Sorting distances" << endl;971 DoLog(5) && (Log() << Verbose(5) << "Sorting distances" << endl); 968 972 PermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermMap"); 969 973 OtherPermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *OtherPermMap"); … … 971 975 gsl_heapsort_index (OtherPermMap, OtherDistances, AtomCount, sizeof(double), CompareDoubles); 972 976 PermutationMap = Calloc<int>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermutationMap"); 973 Log() << Verbose(5) << "Combining Permutation Maps" << endl;977 DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl); 974 978 for(int i=AtomCount;i--;) 975 979 PermutationMap[PermMap[i]] = (int) OtherPermMap[i]; 976 980 977 981 /// ... and compare them step by step, whether the difference is individually(!) below \a threshold for all 978 Log() << Verbose(4) << "Comparing distances" << endl;982 DoLog(4) && (Log() << Verbose(4) << "Comparing distances" << endl); 979 983 flag = 0; 980 984 for (int i=0;i<AtomCount;i++) { 981 Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " << threshold << endl;985 DoLog(5) && (Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " << threshold << endl); 982 986 if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold) 983 987 flag = 1; … … 995 999 } 996 1000 /// return pointer to map if all distances were below \a threshold 997 Log() << Verbose(3) << "End of IsEqualToWithinThreshold." << endl;1001 DoLog(3) && (Log() << Verbose(3) << "End of IsEqualToWithinThreshold." << endl); 998 1002 if (result) { 999 Log() << Verbose(3) << "Result: Equal." << endl;1003 DoLog(3) && (Log() << Verbose(3) << "Result: Equal." << endl); 1000 1004 return PermutationMap; 1001 1005 } else { 1002 Log() << Verbose(3) << "Result: Not equal." << endl;1006 DoLog(3) && (Log() << Verbose(3) << "Result: Not equal." << endl); 1003 1007 return NULL; 1004 1008 } … … 1015 1019 { 1016 1020 atom *Walker = NULL, *OtherWalker = NULL; 1017 Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl;1021 DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl); 1018 1022 int *AtomicMap = Malloc<int>(AtomCount, "molecule::GetAtomicMap: *AtomicMap"); 1019 1023 for (int i=AtomCount;i--;) … … 1022 1026 for (int i=AtomCount;i--;) // no need as -1 means already that there is trivial correspondence 1023 1027 AtomicMap[i] = i; 1024 Log() << Verbose(4) << "Map is trivial." << endl;1028 DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl); 1025 1029 } else { 1026 Log() << Verbose(4) << "Map is ";1030 DoLog(4) && (Log() << Verbose(4) << "Map is "); 1027 1031 Walker = start; 1028 1032 while (Walker->next != end) { … … 1041 1045 } 1042 1046 } 1043 Log() << Verbose(0) << AtomicMap[Walker->nr] << "\t";1044 } 1045 Log() << Verbose(0) << endl;1046 } 1047 Log() << Verbose(3) << "End of GetFatherAtomicMap." << endl;1047 DoLog(0) && (Log() << Verbose(0) << AtomicMap[Walker->nr] << "\t"); 1048 } 1049 DoLog(0) && (Log() << Verbose(0) << endl); 1050 } 1051 DoLog(3) && (Log() << Verbose(3) << "End of GetFatherAtomicMap." << endl); 1048 1052 return AtomicMap; 1049 1053 }; -
src/molecule.hpp
r491876 rc695c9 82 82 class molecule : public PointCloud { 83 83 public: 84 double cell_size[6];//!< cell size85 84 const periodentafel * const elemente; //!< periodic table with each element 86 85 atom *start; //!< start of atom list … … 110 109 TesselPoint *GetPoint() const ; 111 110 TesselPoint *GetTerminalPoint() const ; 111 int GetMaxId() const; 112 112 void GoToNext() const ; 113 113 void GoToPrevious() const ; … … 268 268 int FragmentMolecule(int Order, config *configuration); 269 269 bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path = NULL); 270 bool StoreAdjacencyToFile(char *path); 270 bool StoreBondsToFile(char *path, char *filename); 271 bool StoreAdjacencyToFile(char *path, char *filename); 271 272 bool CheckAdjacencyFileAgainstMolecule(char *path, atom **ListOfAtoms); 272 273 bool ParseOrderAtSiteFromFile(char *path); … … 322 323 void Enumerate(ofstream *out); 323 324 void Output(ofstream *out); 324 void DissectMoleculeIntoConnectedSubgraphs( molecule * const mol, config * const configuration);325 void DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration); 325 326 int CountAllAtoms() const; 326 327 -
src/molecule_dynamics.cpp
r491876 rc695c9 207 207 doubles++; 208 208 if (doubles >0) 209 Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl;209 DoLog(2) && (Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl); 210 210 Free(&DoubleList); 211 211 // Log() << Verbose(2) << zeile1.str() << endl << zeile2.str() << endl; … … 249 249 Params.DoubleList[Params.DistanceList[Walker->nr]->begin()->second->nr]++; // increase this target's source count (>1? not injective) 250 250 Params.DistanceIterators[Walker->nr] = Params.DistanceList[Walker->nr]->begin(); // and remember which one we picked 251 Log() << Verbose(2) << *Walker << " starts with distance " << Params.DistanceList[Walker->nr]->begin()->first << "." << endl;251 DoLog(2) && (Log() << Verbose(2) << *Walker << " starts with distance " << Params.DistanceList[Walker->nr]->begin()->first << "." << endl); 252 252 } 253 253 }; … … 277 277 Params.DistanceIterators[Walker->nr] = NewBase; 278 278 OldPotential = Potential; 279 Log() << Verbose(3) << "Found a new permutation, new potential is " << OldPotential << "." << endl;279 DoLog(3) && (Log() << Verbose(3) << "Found a new permutation, new potential is " << OldPotential << "." << endl); 280 280 } 281 281 } … … 306 306 for (int i=mol->AtomCount; i--;) // now each single entry in the DoubleList should be <=1 307 307 if (Params.DoubleList[i] > 1) { 308 eLog() << Verbose(0) << "Failed to create an injective PermutationMap!" << endl;308 DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl); 309 309 performCriticalExit(); 310 310 } 311 Log() << Verbose(1) << "done." << endl;311 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 312 312 }; 313 313 … … 358 358 Params.PenaltyConstants[2] = 1e+7; // just a huge penalty 359 359 // generate the distance list 360 Log() << Verbose(1) << "Allocating, initializting and filling the distance list ... " << endl;360 DoLog(1) && (Log() << Verbose(1) << "Allocating, initializting and filling the distance list ... " << endl); 361 361 FillDistanceList(this, Params); 362 362 … … 365 365 366 366 // make the PermutationMap injective by checking whether we have a non-zero constants[2] term in it 367 Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl;367 DoLog(1) && (Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl); 368 368 MakeInjectivePermutation(this, Params); 369 369 Free(&Params.DoubleList); 370 370 371 371 // argument minimise the constrained potential in this injective PermutationMap 372 Log() << Verbose(1) << "Argument minimising the PermutationMap, at current potential " << OldPotential << " ... " << endl;372 DoLog(1) && (Log() << Verbose(1) << "Argument minimising the PermutationMap." << endl); 373 373 OldPotential = 1e+10; 374 374 round = 0; 375 375 do { 376 Log() << Verbose(2) << "Starting round " << ++round << " ... " << endl;376 DoLog(2) && (Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl); 377 377 OlderPotential = OldPotential; 378 378 do { … … 424 424 } else { 425 425 Params.DistanceIterators[Runner->nr] = Rider; // if successful also move the pointer in the iterator list 426 Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl;426 DoLog(3) && (Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl); 427 427 OldPotential = Potential; 428 428 } 429 429 if (Potential > Params.PenaltyConstants[2]) { 430 eLog() << Verbose(1) << "The two-step permutation procedure did not maintain injectivity!" << endl;430 DoeLog(1) && (eLog()<< Verbose(1) << "The two-step permutation procedure did not maintain injectivity!" << endl); 431 431 exit(255); 432 432 } 433 433 //Log() << Verbose(0) << endl; 434 434 } else { 435 eLog() << Verbose(1) << *Runner << " was not the owner of " << *Sprinter << "!" << endl;435 DoeLog(1) && (eLog()<< Verbose(1) << *Runner << " was not the owner of " << *Sprinter << "!" << endl); 436 436 exit(255); 437 437 } … … 443 443 } while (Walker->next != end); 444 444 } while ((OlderPotential - OldPotential) > 1e-3); 445 Log() << Verbose(1) << "done." << endl;445 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 446 446 447 447 … … 466 466 { 467 467 /// evaluate forces (only the distance to target dependent part) with the final PermutationMap 468 Log() << Verbose(1) << "Calculating forces and adding onto ForceMatrix ... " << endl;468 DoLog(1) && (Log() << Verbose(1) << "Calculating forces and adding onto ForceMatrix ... " << endl); 469 469 ActOnAllAtoms( &atom::EvaluateConstrainedForce, startstep, endstep, PermutationMap, Force ); 470 Log() << Verbose(1) << "done." << endl;470 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 471 471 }; 472 472 … … 503 503 504 504 // go through all steps and add the molecular configuration to the list and to the Trajectories of \a this molecule 505 Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl;505 DoLog(1) && (Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl); 506 506 for (int step = 0; step <= MaxSteps; step++) { 507 507 mol = new molecule(elemente); … … 568 568 // parse file into ForceMatrix 569 569 if (!Force.ParseMatrix(file, 0,0,0)) { 570 eLog() << Verbose(0) << "Could not parse Force Matrix file " << file << "." << endl;570 DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse Force Matrix file " << file << "." << endl); 571 571 performCriticalExit(); 572 572 return false; 573 573 } 574 574 if (Force.RowCounter[0] != AtomCount) { 575 eLog() << Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount << "." << endl;575 DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount << "." << endl); 576 576 performCriticalExit(); 577 577 return false; … … 652 652 switch(Thermostat) { 653 653 case None: 654 Log() << Verbose(2) << "Applying no thermostat..." << endl;654 DoLog(2) && (Log() << Verbose(2) << "Applying no thermostat..." << endl); 655 655 break; 656 656 case Woodcock: 657 657 if ((configuration.ScaleTempStep > 0) && ((MDSteps-1) % configuration.ScaleTempStep == 0)) { 658 Log() << Verbose(2) << "Applying Woodcock thermostat..." << endl;658 DoLog(2) && (Log() << Verbose(2) << "Applying Woodcock thermostat..." << endl); 659 659 ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin ); 660 660 } 661 661 break; 662 662 case Gaussian: 663 Log() << Verbose(2) << "Applying Gaussian thermostat..." << endl;663 DoLog(2) && (Log() << Verbose(2) << "Applying Gaussian thermostat..." << endl); 664 664 ActOnAllAtoms( &atom::Thermostat_Gaussian_init, MDSteps, &G, &E ); 665 665 666 Log() << Verbose(1) << "Gaussian Least Constraint constant is " << G/E << "." << endl;666 DoLog(1) && (Log() << Verbose(1) << "Gaussian Least Constraint constant is " << G/E << "." << endl); 667 667 ActOnAllAtoms( &atom::Thermostat_Gaussian_least_constraint, MDSteps, G/E, &ekin, &configuration); 668 668 669 669 break; 670 670 case Langevin: 671 Log() << Verbose(2) << "Applying Langevin thermostat..." << endl;671 DoLog(2) && (Log() << Verbose(2) << "Applying Langevin thermostat..." << endl); 672 672 // init random number generator 673 673 gsl_rng_env_setup(); … … 679 679 680 680 case Berendsen: 681 Log() << Verbose(2) << "Applying Berendsen-VanGunsteren thermostat..." << endl;681 DoLog(2) && (Log() << Verbose(2) << "Applying Berendsen-VanGunsteren thermostat..." << endl); 682 682 ActOnAllAtoms( &atom::Thermostat_Berendsen, MDSteps, ScaleTempFactor, &ekin, &configuration ); 683 683 break; 684 684 685 685 case NoseHoover: 686 Log() << Verbose(2) << "Applying Nose-Hoover thermostat..." << endl;686 DoLog(2) && (Log() << Verbose(2) << "Applying Nose-Hoover thermostat..." << endl); 687 687 // dynamically evolve alpha (the additional degree of freedom) 688 688 delta_alpha = 0.; … … 690 690 delta_alpha = (delta_alpha - (3.*AtomCount+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass); 691 691 configuration.alpha += delta_alpha*configuration.Deltat; 692 Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl;692 DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl); 693 693 // apply updated alpha as additional force 694 694 ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration ); 695 695 break; 696 696 } 697 Log() << Verbose(1) << "Kinetic energy is " << ekin << "." << endl;698 }; 697 DoLog(1) && (Log() << Verbose(1) << "Kinetic energy is " << ekin << "." << endl); 698 }; -
src/molecule_fragmentation.cpp
r491876 rc695c9 5 5 * Author: heber 6 6 */ 7 8 #include <cstring> 7 9 8 10 #include "atom.hpp" … … 16 18 #include "molecule.hpp" 17 19 #include "periodentafel.hpp" 20 #include "World.hpp" 18 21 19 22 /************************************* Functions for class molecule *********************************/ … … 41 44 } 42 45 FragmentCount = NoNonHydrogen*(1 << (c*order)); 43 Log() << Verbose(1) << "Upper limit for this subgraph is " << FragmentCount << " for " << NoNonHydrogen << " non-H atoms with maximum bond degree of " << c << "." << endl;46 DoLog(1) && (Log() << Verbose(1) << "Upper limit for this subgraph is " << FragmentCount << " for " << NoNonHydrogen << " non-H atoms with maximum bond degree of " << c << "." << endl); 44 47 return FragmentCount; 45 48 }; … … 65 68 } // else it's "-1" or else and thus must not be added 66 69 } 67 Log() << Verbose(1) << "The scanned KeySet is ";70 DoLog(1) && (Log() << Verbose(1) << "The scanned KeySet is "); 68 71 for(KeySet::iterator runner = CurrentSet.begin(); runner != CurrentSet.end(); runner++) { 69 Log() << Verbose(0) << (*runner) << "\t";70 } 71 Log() << Verbose(0) << endl;72 DoLog(0) && (Log() << Verbose(0) << (*runner) << "\t"); 73 } 74 DoLog(0) && (Log() << Verbose(0) << endl); 72 75 return (status != 0); 73 76 }; … … 97 100 98 101 // 1st pass: open file and read 99 Log() << Verbose(1) << "Parsing the KeySet file ... " << endl;102 DoLog(1) && (Log() << Verbose(1) << "Parsing the KeySet file ... " << endl); 100 103 sprintf(filename, "%s/%s%s", path, FRAGMENTPREFIX, KEYSETFILE); 101 104 InputFile.open(filename); … … 110 113 testGraphInsert = FragmentList->insert(GraphPair (CurrentSet,pair<int,double>(NumberOfFragments++,1))); // store fragment number and current factor 111 114 if (!testGraphInsert.second) { 112 eLog() << Verbose(0) << "KeySet file must be corrupt as there are two equal key sets therein!" << endl;115 DoeLog(0) && (eLog()<< Verbose(0) << "KeySet file must be corrupt as there are two equal key sets therein!" << endl); 113 116 performCriticalExit(); 114 117 } … … 119 122 InputFile.clear(); 120 123 Free(&buffer); 121 Log() << Verbose(1) << "done." << endl;124 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 122 125 } else { 123 Log() << Verbose(1) << "File " << filename << " not found." << endl;126 DoLog(1) && (Log() << Verbose(1) << "File " << filename << " not found." << endl); 124 127 status = false; 125 128 } … … 151 154 152 155 // 2nd pass: open TEFactors file and read 153 Log() << Verbose(1) << "Parsing the TEFactors file ... " << endl;156 DoLog(1) && (Log() << Verbose(1) << "Parsing the TEFactors file ... " << endl); 154 157 sprintf(filename, "%s/%s%s", path, FRAGMENTPREFIX, TEFACTORSFILE); 155 158 InputFile.open(filename); … … 161 164 InputFile >> TEFactor; 162 165 (*runner).second.second = TEFactor; 163 Log() << Verbose(2) << "Setting " << ++NumberOfFragments << " fragment's TEFactor to " << (*runner).second.second << "." << endl;166 DoLog(2) && (Log() << Verbose(2) << "Setting " << ++NumberOfFragments << " fragment's TEFactor to " << (*runner).second.second << "." << endl); 164 167 } else { 165 168 status = false; … … 169 172 // 4. Free and done 170 173 InputFile.close(); 171 Log() << Verbose(1) << "done." << endl;174 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 172 175 } else { 173 Log() << Verbose(1) << "File " << filename << " not found." << endl;176 DoLog(1) && (Log() << Verbose(1) << "File " << filename << " not found." << endl); 174 177 status = false; 175 178 } … … 199 202 line += KEYSETFILE; 200 203 output.open(line.c_str(), ios::out); 201 Log() << Verbose(1) << "Saving key sets of the total graph ... ";204 DoLog(1) && (Log() << Verbose(1) << "Saving key sets of the total graph ... "); 202 205 if(output != NULL) { 203 206 for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++) { … … 209 212 output << endl; 210 213 } 211 Log() << Verbose(0) << "done." << endl;214 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 212 215 } else { 213 eLog() << Verbose(0) << "Unable to open " << line << " for writing keysets!" << endl;216 DoeLog(0) && (eLog()<< Verbose(0) << "Unable to open " << line << " for writing keysets!" << endl); 214 217 performCriticalExit(); 215 218 status = false; … … 240 243 line += TEFACTORSFILE; 241 244 output.open(line.c_str(), ios::out); 242 Log() << Verbose(1) << "Saving TEFactors of the total graph ... ";245 DoLog(1) && (Log() << Verbose(1) << "Saving TEFactors of the total graph ... "); 243 246 if(output != NULL) { 244 247 for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++) 245 248 output << (*runner).second.second << endl; 246 Log() << Verbose(1) << "done." << endl;249 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 247 250 } else { 248 Log() << Verbose(1) << "failed to open " << line << "." << endl;251 DoLog(1) && (Log() << Verbose(1) << "failed to open " << line << "." << endl); 249 252 status = false; 250 253 } … … 290 293 (*PresentItem).second.first = fabs(Value); 291 294 (*PresentItem).second.second = FragOrder; 292 Log() << Verbose(2) << "Updated element (" << (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl;295 DoLog(2) && (Log() << Verbose(2) << "Updated element (" << (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl); 293 296 } else { 294 Log() << Verbose(2) << "Did not update element " << (*PresentItem).first << " as " << FragOrder << " is less than or equal to " << (*PresentItem).second.second << "." << endl;297 DoLog(2) && (Log() << Verbose(2) << "Did not update element " << (*PresentItem).first << " as " << FragOrder << " is less than or equal to " << (*PresentItem).second.second << "." << endl); 295 298 } 296 299 } else { 297 Log() << Verbose(2) << "Inserted element (" << (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl;300 DoLog(2) && (Log() << Verbose(2) << "Inserted element (" << (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl); 298 301 } 299 302 } else { 300 Log() << Verbose(1) << "No Fragment under No. " << No << "found." << endl;303 DoLog(1) && (Log() << Verbose(1) << "No Fragment under No. " << No << "found." << endl); 301 304 } 302 305 }; … … 357 360 atom *Walker = mol->start; 358 361 map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ; 359 Log() << Verbose(1) << "Root candidate list is: " << endl;362 DoLog(1) && (Log() << Verbose(1) << "Root candidate list is: " << endl); 360 363 for(map<int, pair<double,int> >::iterator runner = AdaptiveCriteriaList->begin(); runner != AdaptiveCriteriaList->end(); runner++) { 361 364 Walker = mol->FindAtom((*runner).first); … … 363 366 //if ((*runner).second.second >= Walker->AdaptiveOrder) { // only insert if this is an "active" root site for the current order 364 367 if (!Walker->MaxOrder) { 365 Log() << Verbose(2) << "(" << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "])" << endl;368 DoLog(2) && (Log() << Verbose(2) << "(" << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "])" << endl); 366 369 FinalRootCandidates->insert( make_pair( (*runner).second.first, pair<int,int>((*runner).first, (*runner).second.second) ) ); 367 370 } else { 368 Log() << Verbose(2) << "Excluding (" << *Walker << ", " << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "]), as it has reached its maximum order." << endl;371 DoLog(2) && (Log() << Verbose(2) << "Excluding (" << *Walker << ", " << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "]), as it has reached its maximum order." << endl); 369 372 } 370 373 } else { 371 eLog() << Verbose(0) << "Atom No. " << (*runner).second.first << " was not found in this molecule." << endl;374 DoeLog(0) && (eLog()<< Verbose(0) << "Atom No. " << (*runner).second.first << " was not found in this molecule." << endl); 372 375 performCriticalExit(); 373 376 } … … 394 397 Walker = mol->FindAtom(No); 395 398 //if (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]) { 396 Log() << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", setting entry " << No << " of Atom mask to true." << endl;399 DoLog(2) && (Log() << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", setting entry " << No << " of Atom mask to true." << endl); 397 400 AtomMask[No] = true; 398 401 status = true; … … 410 413 void PrintAtomMask(bool *AtomMask, int AtomCount) 411 414 { 412 Log() << Verbose(2) << " ";415 DoLog(2) && (Log() << Verbose(2) << " "); 413 416 for(int i=0;i<AtomCount;i++) 414 Log() << Verbose(0) << (i % 10);415 Log() << Verbose(0) << endl;416 Log() << Verbose(2) << "Atom mask is: ";417 DoLog(0) && (Log() << Verbose(0) << (i % 10)); 418 DoLog(0) && (Log() << Verbose(0) << endl); 419 DoLog(2) && (Log() << Verbose(2) << "Atom mask is: "); 417 420 for(int i=0;i<AtomCount;i++) 418 Log() << Verbose(0) << (AtomMask[i] ? "t" : "f");419 Log() << Verbose(0) << endl;421 DoLog(0) && (Log() << Verbose(0) << (AtomMask[i] ? "t" : "f")); 422 DoLog(0) && (Log() << Verbose(0) << endl); 420 423 }; 421 424 … … 444 447 // transmorph graph keyset list into indexed KeySetList 445 448 if (GlobalKeySetList == NULL) { 446 eLog() << Verbose(1) << "Given global key set list (graph) is NULL!" << endl;449 DoeLog(1) && (eLog()<< Verbose(1) << "Given global key set list (graph) is NULL!" << endl); 447 450 return false; 448 451 } … … 452 455 map<int, pair<double,int> > *AdaptiveCriteriaList = ScanAdaptiveFileIntoMap(path, *IndexKeySetList); // (Root No., (Value, Order)) ! 453 456 if (AdaptiveCriteriaList->empty()) { 454 eLog() << Verbose(2) << "Unable to parse file, incrementing all." << endl;457 DoeLog(2) && (eLog()<< Verbose(2) << "Unable to parse file, incrementing all." << endl); 455 458 while (Walker->next != end) { 456 459 Walker = Walker->next; … … 490 493 if (!status) { 491 494 if (Order == 0) 492 Log() << Verbose(1) << "Single stepping done." << endl;495 DoLog(1) && (Log() << Verbose(1) << "Single stepping done." << endl); 493 496 else 494 Log() << Verbose(1) << "Order at every site is already equal or above desired order " << Order << "." << endl;497 DoLog(1) && (Log() << Verbose(1) << "Order at every site is already equal or above desired order " << Order << "." << endl); 495 498 } 496 499 } … … 509 512 { 510 513 if (SortIndex != NULL) { 511 Log() << Verbose(1) << "SortIndex is " << SortIndex << " and not NULL as expected." << endl;514 DoLog(1) && (Log() << Verbose(1) << "SortIndex is " << SortIndex << " and not NULL as expected." << endl); 512 515 return false; 513 516 } … … 560 563 bool *AtomMask = NULL; 561 564 562 Log() << Verbose(0) << endl;565 DoLog(0) && (Log() << Verbose(0) << endl); 563 566 #ifdef ADDHYDROGEN 564 Log() << Verbose(0) << "I will treat hydrogen special and saturate dangling bonds with it." << endl;567 DoLog(0) && (Log() << Verbose(0) << "I will treat hydrogen special and saturate dangling bonds with it." << endl); 565 568 #else 566 Log() << Verbose(0) << "Hydrogen is treated just like the rest of the lot." << endl;569 DoLog(0) && (Log() << Verbose(0) << "Hydrogen is treated just like the rest of the lot." << endl); 567 570 #endif 568 571 … … 590 593 // fill the bond structure of the individually stored subgraphs 591 594 MolecularWalker->FillBondStructureFromReference(this, FragmentCounter, ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms 592 Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl;595 DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl); 593 596 LocalBackEdgeStack = new StackClass<bond *> (MolecularWalker->Leaf->BondCount); 594 597 // // check the list of local atoms for debugging … … 599 602 // else 600 603 // Log() << Verbose(0) << "\t" << ListOfLocalAtoms[FragmentCounter][i]->Name; 601 Log() << Verbose(0) << "Gathering local back edges for subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl;604 DoLog(0) && (Log() << Verbose(0) << "Gathering local back edges for subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl); 602 605 MolecularWalker->Leaf->PickLocalBackEdges(ListOfLocalAtoms[FragmentCounter++], BackEdgeStack, LocalBackEdgeStack); 603 Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl;606 DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl); 604 607 MolecularWalker->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize); 605 Log() << Verbose(0) << "Done with Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl;608 DoLog(0) && (Log() << Verbose(0) << "Done with Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl); 606 609 delete(LocalBackEdgeStack); 607 610 } … … 634 637 while (MolecularWalker->next != NULL) { 635 638 MolecularWalker = MolecularWalker->next; 636 Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl;639 DoLog(1) && (Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl); 637 640 //MolecularWalker->Leaf->OutputListOfBonds(out); // output atom::ListOfBonds for debugging 638 641 if (MolecularWalker->Leaf->first->next != MolecularWalker->Leaf->last) { 639 642 // call BOSSANOVA method 640 Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl;643 DoLog(0) && (Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl); 641 644 MolecularWalker->Leaf->FragmentBOSSANOVA(FragmentList[FragmentCounter], RootStack[FragmentCounter], MinimumRingSize); 642 645 } else { 643 eLog() << Verbose(1) << "Subgraph " << MolecularWalker << " has no atoms!" << endl;646 DoeLog(1) && (eLog()<< Verbose(1) << "Subgraph " << MolecularWalker << " has no atoms!" << endl); 644 647 } 645 648 FragmentCounter++; // next fragment list 646 649 } 647 650 } 648 Log() << Verbose(2) << "CheckOrder is " << CheckOrder << "." << endl;651 DoLog(2) && (Log() << Verbose(2) << "CheckOrder is " << CheckOrder << "." << endl); 649 652 delete[](RootStack); 650 653 delete[](AtomMask); … … 677 680 for(Graph::iterator runner = TotalGraph.begin(); runner != TotalGraph.end(); runner++) { 678 681 KeySet test = (*runner).first; 679 Log() << Verbose(0) << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl;682 DoLog(0) && (Log() << Verbose(0) << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl); 680 683 BondFragments->insert(StoreFragmentFromKeySet(test, configuration)); 681 684 k++; 682 685 } 683 Log() << Verbose(0) << k << "/" << BondFragments->ListOfMolecules.size() << " fragments generated from the keysets." << endl;686 DoLog(0) && (Log() << Verbose(0) << k << "/" << BondFragments->ListOfMolecules.size() << " fragments generated from the keysets." << endl); 684 687 685 688 // ===== 9. Save fragments' configuration and keyset files et al to disk === … … 688 691 CreateMappingLabelsToConfigSequence(SortIndex); 689 692 690 Log() << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl;693 DoLog(1) && (Log() << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl); 691 694 if (BondFragments->OutputConfigForListOfFragments(configuration, SortIndex)) 692 Log() << Verbose(1) << "All configs written." << endl;695 DoLog(1) && (Log() << Verbose(1) << "All configs written." << endl); 693 696 else 694 Log() << Verbose(1) << "Some config writing failed." << endl;697 DoLog(1) && (Log() << Verbose(1) << "Some config writing failed." << endl); 695 698 696 699 // store force index reference file … … 701 704 702 705 // store Adjacency file 703 StoreAdjacencyToFile(configuration->configpath); 706 char *filename = Malloc<char> (MAXSTRINGSIZE, "molecule::FragmentMolecule - *filename"); 707 strcpy(filename, FRAGMENTPREFIX); 708 strcat(filename, ADJACENCYFILE); 709 StoreAdjacencyToFile(configuration->configpath, filename); 710 Free(&filename); 704 711 705 712 // store Hydrogen saturation correction file … … 713 720 714 721 // free memory for bond part 715 Log() << Verbose(1) << "Freeing bond memory" << endl;722 DoLog(1) && (Log() << Verbose(1) << "Freeing bond memory" << endl); 716 723 delete(FragmentList); // remove bond molecule from memory 717 724 Free(&SortIndex); 718 725 } else { 719 Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl;726 DoLog(1) && (Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl); 720 727 } 721 728 delete(BondFragments); 722 Log() << Verbose(0) << "End of bond fragmentation." << endl;729 DoLog(0) && (Log() << Verbose(0) << "End of bond fragmentation." << endl); 723 730 724 731 return ((int)(!FragmentationToDo)+1); // 1 - continue, 2 - stop (no fragmentation occured) … … 739 746 line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE; 740 747 file.open(line.str().c_str()); 741 Log() << Verbose(1) << "Writing OrderAtSite " << ORDERATSITEFILE << " ... " << endl;748 DoLog(1) && (Log() << Verbose(1) << "Writing OrderAtSite " << ORDERATSITEFILE << " ... " << endl); 742 749 if (file != NULL) { 743 750 ActOnAllAtoms( &atom::OutputOrder, &file ); 744 751 file.close(); 745 Log() << Verbose(1) << "done." << endl;752 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 746 753 return true; 747 754 } else { 748 Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;755 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl); 749 756 return false; 750 757 } … … 767 774 ifstream file; 768 775 769 Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl;776 DoLog(1) && (Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl); 770 777 line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE; 771 778 file.open(line.str().c_str()); … … 788 795 SetAtomValueToIndexedArray( MaxArray, &atom::nr, &atom::MaxOrder ); 789 796 790 Log() << Verbose(1) << "done." << endl;797 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 791 798 status = true; 792 799 } else { 793 Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;800 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl); 794 801 status = false; 795 802 } … … 797 804 Free(&MaxArray); 798 805 799 Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl;806 DoLog(1) && (Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl); 800 807 return status; 801 808 }; … … 814 821 int SP, Removal; 815 822 816 Log() << Verbose(2) << "Looking for removal candidate." << endl;823 DoLog(2) && (Log() << Verbose(2) << "Looking for removal candidate." << endl); 817 824 SP = -1; //0; // not -1, so that Root is never removed 818 825 Removal = -1; … … 841 848 842 849 Leaf->BondDistance = mol->BondDistance; 843 for(int i=NDIM*2;i--;)844 Leaf->cell_size[i] = mol->cell_size[i];845 850 846 851 // first create the minimal set of atoms from the KeySet … … 901 906 } 902 907 } else { 903 eLog() << Verbose(1) << "Son " << Runner->Name << " has father " << FatherOfRunner->Name << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl;908 DoeLog(1) && (eLog()<< Verbose(1) << "Son " << Runner->Name << " has father " << FatherOfRunner->Name << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl); 904 909 } 905 910 if ((LonelyFlag) && (Leaf->AtomCount > 1)) { 906 Log() << Verbose(0) << *Runner << "has got bonds only to hydrogens!" << endl;911 DoLog(0) && (Log() << Verbose(0) << *Runner << "has got bonds only to hydrogens!" << endl); 907 912 } 908 913 #ifdef ADDHYDROGEN … … 1051 1056 TouchedList[j] = -1; 1052 1057 } 1053 Log() << Verbose(2) << "Remaining local nr.s on snake stack are: ";1058 DoLog(2) && (Log() << Verbose(2) << "Remaining local nr.s on snake stack are: "); 1054 1059 for(KeySet::iterator runner = FragmentSet->begin(); runner != FragmentSet->end(); runner++) 1055 Log() << Verbose(0) << (*runner) << " ";1056 Log() << Verbose(0) << endl;1060 DoLog(0) && (Log() << Verbose(0) << (*runner) << " "); 1061 DoLog(0) && (Log() << Verbose(0) << endl); 1057 1062 TouchedIndex = 0; // set Index to 0 for list of atoms added on this level 1058 1063 }; … … 1131 1136 Log() << Verbose(1+verbosity) << "Enough items on stack for a fragment!" << endl; 1132 1137 // store fragment as a KeySet 1133 Log() << Verbose(2) << "Found a new fragment[" << FragmentSearch->FragmentCounter << "], local nr.s are: ";1138 DoLog(2) && (Log() << Verbose(2) << "Found a new fragment[" << FragmentSearch->FragmentCounter << "], local nr.s are: "); 1134 1139 for(KeySet::iterator runner = FragmentSearch->FragmentSet->begin(); runner != FragmentSearch->FragmentSet->end(); runner++) 1135 Log() << Verbose(0) << (*runner) << " ";1136 Log() << Verbose(0) << endl;1140 DoLog(0) && (Log() << Verbose(0) << (*runner) << " "); 1141 DoLog(0) && (Log() << Verbose(0) << endl); 1137 1142 //if (!CheckForConnectedSubgraph(FragmentSearch->FragmentSet)) 1138 // eLog() << Verbose(1) << "The found fragment is not a connected subgraph!" << endl;1143 //DoeLog(1) && (eLog()<< Verbose(1) << "The found fragment is not a connected subgraph!" << endl); 1139 1144 InsertFragmentIntoGraph(FragmentSearch); 1140 1145 } … … 1216 1221 { 1217 1222 bond *Binder = NULL; 1218 Log() << Verbose(0) << "Free'ing all found lists. and resetting index lists" << endl;1223 DoLog(0) && (Log() << Verbose(0) << "Free'ing all found lists. and resetting index lists" << endl); 1219 1224 for(int i=Order;i--;) { 1220 Log() << Verbose(1) << "Current SP level is " << i << ": ";1225 DoLog(1) && (Log() << Verbose(1) << "Current SP level is " << i << ": "); 1221 1226 Binder = FragmentSearch.BondsPerSPList[2*i]; 1222 1227 while (Binder->next != FragmentSearch.BondsPerSPList[2*i+1]) { … … 1229 1234 cleanup(FragmentSearch.BondsPerSPList[2*i], FragmentSearch.BondsPerSPList[2*i+1]); 1230 1235 // also start and end node 1231 Log() << Verbose(0) << "cleaned." << endl;1236 DoLog(0) && (Log() << Verbose(0) << "cleaned." << endl); 1232 1237 } 1233 1238 }; … … 1259 1264 int SP = -1; 1260 1265 1261 Log() << Verbose(0) << "Starting BFS analysis ..." << endl;1266 DoLog(0) && (Log() << Verbose(0) << "Starting BFS analysis ..." << endl); 1262 1267 for (SP = 0; SP < (Order-1); SP++) { 1263 Log() << Verbose(1) << "New SP level reached: " << SP << ", creating new SP list with " << FragmentSearch.BondsPerSPCount[SP] << " item(s)";1268 DoLog(1) && (Log() << Verbose(1) << "New SP level reached: " << SP << ", creating new SP list with " << FragmentSearch.BondsPerSPCount[SP] << " item(s)"); 1264 1269 if (SP > 0) { 1265 Log() << Verbose(0) << ", old level closed with " << FragmentSearch.BondsPerSPCount[SP-1] << " item(s)." << endl;1270 DoLog(0) && (Log() << Verbose(0) << ", old level closed with " << FragmentSearch.BondsPerSPCount[SP-1] << " item(s)." << endl); 1266 1271 FragmentSearch.BondsPerSPCount[SP] = 0; 1267 1272 } else 1268 Log() << Verbose(0) << "." << endl;1273 DoLog(0) && (Log() << Verbose(0) << "." << endl); 1269 1274 1270 1275 RemainingWalkers = FragmentSearch.BondsPerSPCount[SP]; … … 1276 1281 Predecessor = CurrentEdge->leftatom; // ... and leftatom is predecessor 1277 1282 AtomKeyNr = Walker->nr; 1278 Log() << Verbose(0) << "Current Walker is: " << *Walker << " with nr " << Walker->nr << " and SP of " << SP << ", with " << RemainingWalkers << " remaining walkers on this level." << endl;1283 DoLog(0) && (Log() << Verbose(0) << "Current Walker is: " << *Walker << " with nr " << Walker->nr << " and SP of " << SP << ", with " << RemainingWalkers << " remaining walkers on this level." << endl); 1279 1284 // check for new sp level 1280 1285 // go through all its bonds 1281 Log() << Verbose(1) << "Going through all bonds of Walker." << endl;1286 DoLog(1) && (Log() << Verbose(1) << "Going through all bonds of Walker." << endl); 1282 1287 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { 1283 1288 OtherWalker = (*Runner)->GetOtherAtom(Walker); … … 1287 1292 #endif 1288 1293 ) { // skip hydrogens and restrict to fragment 1289 Log() << Verbose(2) << "Current partner is " << *OtherWalker << " with nr " << OtherWalker->nr << " in bond " << *(*Runner) << "." << endl;1294 DoLog(2) && (Log() << Verbose(2) << "Current partner is " << *OtherWalker << " with nr " << OtherWalker->nr << " in bond " << *(*Runner) << "." << endl); 1290 1295 // set the label if not set (and push on root stack as well) 1291 1296 if ((OtherWalker != Predecessor) && (OtherWalker->GetTrueFather()->nr > RootKeyNr)) { // only pass through those with label bigger than Root's 1292 1297 FragmentSearch.ShortestPathList[OtherWalker->nr] = SP+1; 1293 Log() << Verbose(3) << "Set Shortest Path to " << FragmentSearch.ShortestPathList[OtherWalker->nr] << "." << endl;1298 DoLog(3) && (Log() << Verbose(3) << "Set Shortest Path to " << FragmentSearch.ShortestPathList[OtherWalker->nr] << "." << endl); 1294 1299 // add the bond in between to the SP list 1295 1300 Binder = new bond(Walker, OtherWalker); // create a new bond in such a manner, that bond::rightatom is always the one more distant 1296 1301 add(Binder, FragmentSearch.BondsPerSPList[2*(SP+1)+1]); 1297 1302 FragmentSearch.BondsPerSPCount[SP+1]++; 1298 Log() << Verbose(3) << "Added its bond to SP list, having now " << FragmentSearch.BondsPerSPCount[SP+1] << " item(s)." << endl;1303 DoLog(3) && (Log() << Verbose(3) << "Added its bond to SP list, having now " << FragmentSearch.BondsPerSPCount[SP+1] << " item(s)." << endl); 1299 1304 } else { 1300 1305 if (OtherWalker != Predecessor) 1301 Log() << Verbose(3) << "Not passing on, as index of " << *OtherWalker << " " << OtherWalker->GetTrueFather()->nr << " is smaller than that of Root " << RootKeyNr << "." << endl;1306 DoLog(3) && (Log() << Verbose(3) << "Not passing on, as index of " << *OtherWalker << " " << OtherWalker->GetTrueFather()->nr << " is smaller than that of Root " << RootKeyNr << "." << endl); 1302 1307 else 1303 Log() << Verbose(3) << "This is my predecessor " << *Predecessor << "." << endl;1308 DoLog(3) && (Log() << Verbose(3) << "This is my predecessor " << *Predecessor << "." << endl); 1304 1309 } 1305 1310 } else Log() << Verbose(2) << "Is not in the restricted keyset or skipping hydrogen " << *OtherWalker << "." << endl; … … 1317 1322 { 1318 1323 bond *Binder = NULL; 1319 Log() << Verbose(0) << "Printing all found lists." << endl;1324 DoLog(0) && (Log() << Verbose(0) << "Printing all found lists." << endl); 1320 1325 for(int i=1;i<Order;i++) { // skip the root edge in the printing 1321 1326 Binder = FragmentSearch.BondsPerSPList[2*i]; 1322 Log() << Verbose(1) << "Current SP level is " << i << "." << endl;1327 DoLog(1) && (Log() << Verbose(1) << "Current SP level is " << i << "." << endl); 1323 1328 while (Binder->next != FragmentSearch.BondsPerSPList[2*i+1]) { 1324 1329 Binder = Binder->next; 1325 Log() << Verbose(2) << *Binder << endl;1330 DoLog(2) && (Log() << Verbose(2) << *Binder << endl); 1326 1331 } 1327 1332 } … … 1367 1372 int Counter = FragmentSearch.FragmentCounter; // mark current value of counter 1368 1373 1369 Log() << Verbose(0) << endl;1370 Log() << Verbose(0) << "Begin of PowerSetGenerator with order " << Order << " at Root " << *FragmentSearch.Root << "." << endl;1374 DoLog(0) && (Log() << Verbose(0) << endl); 1375 DoLog(0) && (Log() << Verbose(0) << "Begin of PowerSetGenerator with order " << Order << " at Root " << *FragmentSearch.Root << "." << endl); 1371 1376 1372 1377 SetSPList(Order, FragmentSearch); … … 1380 1385 // creating fragments with the found edge sets (may be done in reverse order, faster) 1381 1386 int SP = CountNumbersInBondsList(Order, FragmentSearch); 1382 Log() << Verbose(0) << "Total number of edges is " << SP << "." << endl;1387 DoLog(0) && (Log() << Verbose(0) << "Total number of edges is " << SP << "." << endl); 1383 1388 if (SP >= (Order-1)) { 1384 1389 // start with root (push on fragment stack) 1385 Log() << Verbose(0) << "Starting fragment generation with " << *FragmentSearch.Root << ", local nr is " << FragmentSearch.Root->nr << "." << endl;1390 DoLog(0) && (Log() << Verbose(0) << "Starting fragment generation with " << *FragmentSearch.Root << ", local nr is " << FragmentSearch.Root->nr << "." << endl); 1386 1391 FragmentSearch.FragmentSet->clear(); 1387 Log() << Verbose(0) << "Preparing subset for this root and calling generator." << endl;1392 DoLog(0) && (Log() << Verbose(0) << "Preparing subset for this root and calling generator." << endl); 1388 1393 1389 1394 // prepare the subset and call the generator … … 1395 1400 Free(&BondsList); 1396 1401 } else { 1397 Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl;1402 DoLog(0) && (Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl); 1398 1403 } 1399 1404 1400 1405 // as FragmentSearch structure is used only once, we don't have to clean it anymore 1401 1406 // remove root from stack 1402 Log() << Verbose(0) << "Removing root again from stack." << endl;1407 DoLog(0) && (Log() << Verbose(0) << "Removing root again from stack." << endl); 1403 1408 FragmentSearch.FragmentSet->erase(FragmentSearch.Root->nr); 1404 1409 … … 1407 1412 1408 1413 // return list 1409 Log() << Verbose(0) << "End of PowerSetGenerator." << endl;1414 DoLog(0) && (Log() << Verbose(0) << "End of PowerSetGenerator." << endl); 1410 1415 return (FragmentSearch.FragmentCounter - Counter); 1411 1416 }; … … 1453 1458 atom *Walker = NULL; 1454 1459 1455 Log() << Verbose(0) << "Combining the lists of all orders per order and finally into a single one." << endl;1460 DoLog(0) && (Log() << Verbose(0) << "Combining the lists of all orders per order and finally into a single one." << endl); 1456 1461 if (FragmentList == NULL) { 1457 1462 FragmentList = new Graph; … … 1486 1491 void FreeAllOrdersList(Graph ***FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol) 1487 1492 { 1488 Log() << Verbose(1) << "Free'ing the lists of all orders per order." << endl;1493 DoLog(1) && (Log() << Verbose(1) << "Free'ing the lists of all orders per order." << endl); 1489 1494 int RootNr = 0; 1490 1495 int RootKeyNr = 0; … … 1539 1544 struct UniqueFragments FragmentSearch; 1540 1545 1541 Log() << Verbose(0) << "Begin of FragmentBOSSANOVA." << endl;1546 DoLog(0) && (Log() << Verbose(0) << "Begin of FragmentBOSSANOVA." << endl); 1542 1547 1543 1548 // FragmentLowerOrdersList is a 2D-array of pointer to MoleculeListClass objects, one dimension represents the ANOVA expansion of a single order (i.e. 5) … … 1589 1594 1590 1595 // create top order where nothing is reduced 1591 Log() << Verbose(0) << "==============================================================================================================" << endl;1592 Log() << Verbose(0) << "Creating KeySets of Bond Order " << Order << " for " << *Walker << ", " << (RootStack.size()-RootNr) << " Roots remaining." << endl; // , NumLevels is " << NumLevels << "1596 DoLog(0) && (Log() << Verbose(0) << "==============================================================================================================" << endl); 1597 DoLog(0) && (Log() << Verbose(0) << "Creating KeySets of Bond Order " << Order << " for " << *Walker << ", " << (RootStack.size()-RootNr) << " Roots remaining." << endl); // , NumLevels is " << NumLevels << " 1593 1598 1594 1599 // Create list of Graphs of current Bond Order (i.e. F_{ij}) … … 1600 1605 1601 1606 // output resulting number 1602 Log() << Verbose(1) << "Number of resulting KeySets is: " << NumMoleculesOfOrder[RootNr] << "." << endl;1607 DoLog(1) && (Log() << Verbose(1) << "Number of resulting KeySets is: " << NumMoleculesOfOrder[RootNr] << "." << endl); 1603 1608 if (NumMoleculesOfOrder[RootNr] != 0) { 1604 1609 NumMolecules = 0; … … 1617 1622 } 1618 1623 } 1619 Log() << Verbose(0) << "==============================================================================================================" << endl;1620 Log() << Verbose(1) << "Total number of resulting molecules is: " << TotalNumMolecules << "." << endl;1621 Log() << Verbose(0) << "==============================================================================================================" << endl;1624 DoLog(0) && (Log() << Verbose(0) << "==============================================================================================================" << endl); 1625 DoLog(1) && (Log() << Verbose(1) << "Total number of resulting molecules is: " << TotalNumMolecules << "." << endl); 1626 DoLog(0) && (Log() << Verbose(0) << "==============================================================================================================" << endl); 1622 1627 1623 1628 // cleanup FragmentSearch structure … … 1637 1642 Free(&NumMoleculesOfOrder); 1638 1643 1639 Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl;1644 DoLog(0) && (Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl); 1640 1645 }; 1641 1646 … … 1652 1657 atom *Walker = NULL; 1653 1658 atom *OtherWalker = NULL; 1659 double * const cell_size = World::get()->cell_size; 1654 1660 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 1655 1661 enum Shading *ColorList = NULL; … … 1660 1666 bool flag = true; 1661 1667 1662 Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl;1668 DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl); 1663 1669 1664 1670 ColorList = Calloc<enum Shading>(AtomCount, "molecule::ScanForPeriodicCorrection: *ColorList"); … … 1678 1684 OtherBinder = Binder->next; // note down binding partner for later re-insertion 1679 1685 unlink(Binder); // unlink bond 1680 Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl;1686 DoLog(2) && (Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl); 1681 1687 flag = true; 1682 1688 break; … … 1694 1700 //Log() << Verbose(3) << "Translation vector is "; 1695 1701 Translationvector.Output(); 1696 Log() << Verbose(0) << endl;1702 DoLog(0) && (Log() << Verbose(0) << endl); 1697 1703 // apply to all atoms of first component via BFS 1698 1704 for (int i=AtomCount;i--;) … … 1716 1722 link(Binder, OtherBinder); 1717 1723 } else { 1718 Log() << Verbose(3) << "No corrections for this fragment." << endl;1724 DoLog(3) && (Log() << Verbose(3) << "No corrections for this fragment." << endl); 1719 1725 } 1720 1726 //delete(CompStack); … … 1725 1731 Free(&ColorList); 1726 1732 Free(&matrix); 1727 Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl;1728 }; 1733 DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl); 1734 }; -
src/molecule_geometry.cpp
r491876 rc695c9 15 15 #include "memoryallocator.hpp" 16 16 #include "molecule.hpp" 17 #include "World.hpp" 17 18 18 19 /************************************* Functions for class molecule *********************************/ … … 26 27 bool status = true; 27 28 const Vector *Center = DetermineCenterOfAll(); 29 double * const cell_size = World::get()->cell_size; 28 30 double *M = ReturnFullMatrixforSymmetric(cell_size); 29 31 double *Minv = InverseMatrix(M); … … 46 48 { 47 49 bool status = true; 50 double * const cell_size = World::get()->cell_size; 48 51 double *M = ReturnFullMatrixforSymmetric(cell_size); 49 52 double *Minv = InverseMatrix(M); … … 101 104 { 102 105 int Num = 0; 103 atom *ptr = start ->next; // start at first in list106 atom *ptr = start; // start at first in list 104 107 105 108 Center.Zero(); 106 109 107 if (ptr != end) { //list not empty?110 if (ptr->next != end) { //list not empty? 108 111 while (ptr->next != end) { // continue with second if present 109 112 ptr = ptr->next; … … 226 229 void molecule::TranslatePeriodically(const Vector *trans) 227 230 { 231 double * const cell_size = World::get()->cell_size; 228 232 double *M = ReturnFullMatrixforSymmetric(cell_size); 229 233 double *Minv = InverseMatrix(M); … … 252 256 { 253 257 atom *Walker = start; 258 double * const cell_size = World::get()->cell_size; 254 259 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 255 260 double *inversematrix = InverseMatrix(cell_size); … … 275 280 if ((fabs(tmp)) > BondDistance) { 276 281 flag = false; 277 Log() << Verbose(0) << "Hit: atom " << Walker->Name << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl;282 DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << Walker->Name << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl); 278 283 if (tmp > 0) 279 284 Translationvector.x[j] -= 1.; … … 286 291 Testvector.MatrixMultiplication(matrix); 287 292 Center.AddVector(&Testvector); 288 Log() << Verbose(1) << "vector is: ";293 DoLog(1) && (Log() << Verbose(1) << "vector is: "); 289 294 Testvector.Output(); 290 Log() << Verbose(0) << endl;295 DoLog(0) && (Log() << Verbose(0) << endl); 291 296 #ifdef ADDHYDROGEN 292 297 // now also change all hydrogens … … 298 303 Testvector.MatrixMultiplication(matrix); 299 304 Center.AddVector(&Testvector); 300 Log() << Verbose(1) << "Hydrogen vector is: ";305 DoLog(1) && (Log() << Verbose(1) << "Hydrogen vector is: "); 301 306 Testvector.Output(); 302 Log() << Verbose(0) << endl;307 DoLog(0) && (Log() << Verbose(0) << endl); 303 308 } 304 309 } … … 347 352 } 348 353 // print InertiaTensor for debugging 349 Log() << Verbose(0) << "The inertia tensor is:" << endl;354 DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << endl); 350 355 for(int i=0;i<NDIM;i++) { 351 356 for(int j=0;j<NDIM;j++) 352 Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " ";353 Log() << Verbose(0) << endl;354 } 355 Log() << Verbose(0) << endl;357 DoLog(0) && (Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " "); 358 DoLog(0) && (Log() << Verbose(0) << endl); 359 } 360 DoLog(0) && (Log() << Verbose(0) << endl); 356 361 357 362 // diagonalize to determine principal axis system … … 365 370 366 371 for(int i=0;i<NDIM;i++) { 367 Log() << Verbose(1) << "eigenvalue = " << gsl_vector_get(eval, i);368 Log() << Verbose(0) << ", eigenvector = (" << evec->data[i * evec->tda + 0] << "," << evec->data[i * evec->tda + 1] << "," << evec->data[i * evec->tda + 2] << ")" << endl;372 DoLog(1) && (Log() << Verbose(1) << "eigenvalue = " << gsl_vector_get(eval, i)); 373 DoLog(0) && (Log() << Verbose(0) << ", eigenvector = (" << evec->data[i * evec->tda + 0] << "," << evec->data[i * evec->tda + 1] << "," << evec->data[i * evec->tda + 2] << ")" << endl); 369 374 } 370 375 371 376 // check whether we rotate or not 372 377 if (DoRotate) { 373 Log() << Verbose(1) << "Transforming molecule into PAS ... ";378 DoLog(1) && (Log() << Verbose(1) << "Transforming molecule into PAS ... "); 374 379 // the eigenvectors specify the transformation matrix 375 380 ActOnAllVectors( &Vector::MatrixMultiplication, (const double *) evec->data ); 376 Log() << Verbose(0) << "done." << endl;381 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 377 382 378 383 // summing anew for debugging (resulting matrix has to be diagonal!) … … 399 404 } 400 405 // print InertiaTensor for debugging 401 Log() << Verbose(0) << "The inertia tensor is:" << endl;406 DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << endl); 402 407 for(int i=0;i<NDIM;i++) { 403 408 for(int j=0;j<NDIM;j++) 404 Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " ";405 Log() << Verbose(0) << endl;406 } 407 Log() << Verbose(0) << endl;409 DoLog(0) && (Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " "); 410 DoLog(0) && (Log() << Verbose(0) << endl); 411 } 412 DoLog(0) && (Log() << Verbose(0) << endl); 408 413 } 409 414 … … 428 433 429 434 // rotate on z-x plane 430 Log() << Verbose(0) << "Begin of Aligning all atoms." << endl;435 DoLog(0) && (Log() << Verbose(0) << "Begin of Aligning all atoms." << endl); 431 436 alpha = atan(-n->x[0]/n->x[2]); 432 Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... ";437 DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... "); 433 438 while (ptr->next != end) { 434 439 ptr = ptr->next; … … 446 451 n->x[0] = cos(alpha) * tmp + sin(alpha) * n->x[2]; 447 452 n->x[2] = -sin(alpha) * tmp + cos(alpha) * n->x[2]; 448 Log() << Verbose(1) << "alignment vector after first rotation: ";453 DoLog(1) && (Log() << Verbose(1) << "alignment vector after first rotation: "); 449 454 n->Output(); 450 Log() << Verbose(0) << endl;455 DoLog(0) && (Log() << Verbose(0) << endl); 451 456 452 457 // rotate on z-y plane 453 458 ptr = start; 454 459 alpha = atan(-n->x[1]/n->x[2]); 455 Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... ";460 DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... "); 456 461 while (ptr->next != end) { 457 462 ptr = ptr->next; … … 470 475 n->x[2] = -sin(alpha) * tmp + cos(alpha) * n->x[2]; 471 476 472 Log() << Verbose(1) << "alignment vector after second rotation: ";477 DoLog(1) && (Log() << Verbose(1) << "alignment vector after second rotation: "); 473 478 n->Output(); 474 Log() << Verbose(1) << endl;475 Log() << Verbose(0) << "End of Aligning all atoms." << endl;479 DoLog(1) && (Log() << Verbose(1) << endl); 480 DoLog(0) && (Log() << Verbose(0) << "End of Aligning all atoms." << endl); 476 481 }; 477 482 -
src/molecule_graph.cpp
r491876 rc695c9 17 17 #include "memoryallocator.hpp" 18 18 #include "molecule.hpp" 19 #include "World.hpp" 19 20 20 21 struct BFSAccounting … … 58 59 59 60 if (!input) { 60 Log() << Verbose(1) << "Opening silica failed \n";61 DoLog(1) && (Log() << Verbose(1) << "Opening silica failed \n"); 61 62 }; 62 63 63 64 *input >> ws >> atom1; 64 65 *input >> ws >> atom2; 65 Log() << Verbose(1) << "Scanning file\n";66 DoLog(1) && (Log() << Verbose(1) << "Scanning file\n"); 66 67 while (!input->eof()) // Check whether we read everything already 67 68 { … … 106 107 LinkedCell *LC = NULL; 107 108 bool free_BG = false; 109 double * const cell_size = World::get()->cell_size; 108 110 109 111 if (BG == NULL) { … … 113 115 114 116 BondDistance = bonddistance; // * ((IsAngstroem) ? 1. : 1./AtomicLengthToAngstroem); 115 Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl;117 DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl); 116 118 // remove every bond from the list 117 119 bond *Binder = NULL; … … 126 128 // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering) 127 129 CountAtoms(); 128 Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl;130 DoLog(1) && (Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl); 129 131 130 132 if ((AtomCount > 1) && (bonddistance > 1.)) { 131 Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl;133 DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl); 132 134 LC = new LinkedCell(this, bonddistance); 133 135 134 136 // create a list to map Tesselpoint::nr to atom * 135 Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl;137 DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl); 136 138 AtomMap = Calloc<atom *> (AtomCount, "molecule::CreateAdjacencyList - **AtomCount"); 137 139 Walker = start; … … 142 144 143 145 // 3a. go through every cell 144 Log() << Verbose(2) << "Celling ... " << endl;146 DoLog(2) && (Log() << Verbose(2) << "Celling ... " << endl); 145 147 for (LC->n[0] = 0; LC->n[0] < LC->N[0]; LC->n[0]++) 146 148 for (LC->n[1] = 0; LC->n[1] < LC->N[1]; LC->n[1]++) 147 149 for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) { 148 const Linked Nodes *List = LC->GetCurrentCell();149 //Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;150 const LinkedCell::LinkedNodes *List = LC->GetCurrentCell(); 151 // Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl; 150 152 if (List != NULL) { 151 for (Linked Nodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {153 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 152 154 Walker = AtomMap[(*Runner)->nr]; 153 //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;155 // Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl; 154 156 // 3c. check for possible bond between each atom in this and every one in the 27 cells 155 157 for (n[0] = -1; n[0] <= 1; n[0]++) 156 158 for (n[1] = -1; n[1] <= 1; n[1]++) 157 159 for (n[2] = -1; n[2] <= 1; n[2]++) { 158 const Linked Nodes *OtherList = LC->GetRelativeToCurrentCell(n);159 //Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;160 const LinkedCell::LinkedNodes *OtherList = LC->GetRelativeToCurrentCell(n); 161 // Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl; 160 162 if (OtherList != NULL) { 161 for (Linked Nodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {163 for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) { 162 164 if ((*OtherRunner)->nr > Walker->nr) { 163 165 OtherWalker = AtomMap[(*OtherRunner)->nr]; 164 //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 166 // Log() << Verbose(0) << "Current other Atom is " << *OtherWalker << "." << endl; 167 const double distance = OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size); 168 // Log() << Verbose(1) << "Checking distance " << distance << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 165 169 (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 166 const double distance = OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size);167 170 const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance); 168 if ((OtherWalker->father->nr > Walker->father->nr) && (status)) { // create bond if distance is smaller 169 //Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl; 170 AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount 171 // Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl; 172 if (OtherWalker->father->nr > Walker->father->nr) { 173 if (status) { // create bond if distance is smaller 174 // Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl; 175 AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount 176 } else { 177 // Log() << Verbose(1) << "Not Adding: distance too great." << endl; 178 } 171 179 } else { 172 //Log() << Verbose(1) << "Not Adding: Wrong label order or distance too great." << endl;180 // Log() << Verbose(1) << "Not Adding: Wrong order of labels." << endl; 173 181 } 174 182 } … … 181 189 Free(&AtomMap); 182 190 delete (LC); 183 Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl;191 DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl); 184 192 185 193 // correct bond degree by comparing valence and bond degree 186 Log() << Verbose(2) << "Correcting bond degree ... " << endl;194 DoLog(2) && (Log() << Verbose(2) << "Correcting bond degree ... " << endl); 187 195 CorrectBondDegree(); 188 196 … … 190 198 ActOnAllAtoms( &atom::OutputBondOfAtom ); 191 199 } else 192 Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl;193 Log() << Verbose(0) << "End of CreateAdjacencyList." << endl;200 DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl); 201 DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl); 194 202 if (free_BG) 195 203 delete(BG); … … 202 210 void molecule::OutputBondsList() const 203 211 { 204 Log() << Verbose(1) << endl << "From contents of bond chain list:";212 DoLog(1) && (Log() << Verbose(1) << endl << "From contents of bond chain list:"); 205 213 bond *Binder = first; 206 214 while (Binder->next != last) { 207 215 Binder = Binder->next; 208 Log() << Verbose(0) << *Binder << "\t" << endl;209 } 210 Log() << Verbose(0) << endl;216 DoLog(0) && (Log() << Verbose(0) << *Binder << "\t" << endl); 217 } 218 DoLog(0) && (Log() << Verbose(0) << endl); 211 219 } 212 220 ; … … 225 233 226 234 if (BondCount != 0) { 227 Log() << Verbose(1) << "Correcting Bond degree of each bond ... " << endl;235 DoLog(1) && (Log() << Verbose(1) << "Correcting Bond degree of each bond ... " << endl); 228 236 do { 229 237 OldNo = No; 230 238 No = SumPerAtom( &atom::CorrectBondDegree ); 231 239 } while (OldNo != No); 232 Log() << Verbose(0) << " done." << endl;240 DoLog(0) && (Log() << Verbose(0) << " done." << endl); 233 241 } else { 234 Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl;235 } 236 Log() << Verbose(0) << No << " bonds could not be corrected." << endl;242 DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl); 243 } 244 DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl); 237 245 238 246 return (No); … … 253 261 bond *Binder = first; 254 262 if ((Binder->next != last) && (Binder->next->Type == Undetermined)) { 255 Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl;263 DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl); 256 264 Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack); 257 265 while (Subgraphs->next != NULL) { … … 308 316 Walker->GraphNr = DFS.CurrentGraphNr; 309 317 Walker->LowpointNr = DFS.CurrentGraphNr; 310 Log() << Verbose(1) << "Setting Walker[" << Walker->Name << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl;318 DoLog(1) && (Log() << Verbose(1) << "Setting Walker[" << Walker->Name << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl); 311 319 DFS.AtomStack->Push(Walker); 312 320 DFS.CurrentGraphNr++; … … 335 343 if (Binder == NULL) 336 344 break; 337 Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl;345 DoLog(2) && (Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl); 338 346 // (4) Mark Binder used, ... 339 347 Binder->MarkUsed(black); 340 348 OtherAtom = Binder->GetOtherAtom(Walker); 341 Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->Name << "." << endl;349 DoLog(2) && (Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->Name << "." << endl); 342 350 if (OtherAtom->GraphNr != -1) { 343 351 // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3) … … 345 353 DFS.BackEdgeStack->Push(Binder); 346 354 Walker->LowpointNr = (Walker->LowpointNr < OtherAtom->GraphNr) ? Walker->LowpointNr : OtherAtom->GraphNr; 347 Log() << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->Name << "] to " << Walker->LowpointNr << "." << endl;355 DoLog(3) && (Log() << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->Name << "] to " << Walker->LowpointNr << "." << endl); 348 356 } else { 349 357 // (4b) ... otherwise set OtherAtom as Ancestor of Walker and Walker as OtherAtom, go to (2) … … 351 359 OtherAtom->Ancestor = Walker; 352 360 Walker = OtherAtom; 353 Log() << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom->Name << "]'s Ancestor is now " << OtherAtom->Ancestor->Name << ", Walker is OtherAtom " << OtherAtom->Name << "." << endl;361 DoLog(3) && (Log() << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom->Name << "]'s Ancestor is now " << OtherAtom->Ancestor->Name << ", Walker is OtherAtom " << OtherAtom->Name << "." << endl); 354 362 break; 355 363 } … … 373 381 374 382 // (5) if Ancestor of Walker is ... 375 Log() << Verbose(1) << "(5) Number of Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "] is " << Walker->Ancestor->GraphNr << "." << endl;383 DoLog(1) && (Log() << Verbose(1) << "(5) Number of Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "] is " << Walker->Ancestor->GraphNr << "." << endl); 376 384 377 385 if (Walker->Ancestor->GraphNr != DFS.Root->GraphNr) { … … 380 388 // (6a) set Ancestor's Lowpoint number to minimum of of its Ancestor and itself, go to Step(8) 381 389 Walker->Ancestor->LowpointNr = (Walker->Ancestor->LowpointNr < Walker->LowpointNr) ? Walker->Ancestor->LowpointNr : Walker->LowpointNr; 382 Log() << Verbose(2) << "(6) Setting Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl;390 DoLog(2) && (Log() << Verbose(2) << "(6) Setting Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl); 383 391 } else { 384 392 // (7) (Ancestor of Walker is a separating vertex, remove all from stack till Walker (including), these and Ancestor form a component 385 393 Walker->Ancestor->SeparationVertex = true; 386 Log() << Verbose(2) << "(7) Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s is a separating vertex, creating component." << endl;394 DoLog(2) && (Log() << Verbose(2) << "(7) Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s is a separating vertex, creating component." << endl); 387 395 mol->SetNextComponentNumber(Walker->Ancestor, DFS.ComponentNumber); 388 Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Ancestor's Compont is " << DFS.ComponentNumber << "." << endl;396 DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Ancestor's Compont is " << DFS.ComponentNumber << "." << endl); 389 397 mol->SetNextComponentNumber(Walker, DFS.ComponentNumber); 390 Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl;398 DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl); 391 399 do { 392 400 OtherAtom = DFS.AtomStack->PopLast(); 393 401 LeafWalker->Leaf->AddCopyAtom(OtherAtom); 394 402 mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber); 395 Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl;403 DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl); 396 404 } while (OtherAtom != Walker); 397 405 DFS.ComponentNumber++; 398 406 } 399 407 // (8) Walker becomes its Ancestor, go to (3) 400 Log() << Verbose(2) << "(8) Walker[" << Walker->Name << "] is now its Ancestor " << Walker->Ancestor->Name << ", backstepping. " << endl;408 DoLog(2) && (Log() << Verbose(2) << "(8) Walker[" << Walker->Name << "] is now its Ancestor " << Walker->Ancestor->Name << ", backstepping. " << endl); 401 409 Walker = Walker->Ancestor; 402 410 DFS.BackStepping = true; … … 422 430 //DFS.AtomStack->Output(out); 423 431 mol->SetNextComponentNumber(DFS.Root, DFS.ComponentNumber); 424 Log() << Verbose(3) << "(9) Root[" << DFS.Root->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl;432 DoLog(3) && (Log() << Verbose(3) << "(9) Root[" << DFS.Root->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl); 425 433 mol->SetNextComponentNumber(Walker, DFS.ComponentNumber); 426 Log() << Verbose(3) << "(9) Walker[" << Walker->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl;434 DoLog(3) && (Log() << Verbose(3) << "(9) Walker[" << Walker->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl); 427 435 do { 428 436 OtherAtom = DFS.AtomStack->PopLast(); 429 437 LeafWalker->Leaf->AddCopyAtom(OtherAtom); 430 438 mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber); 431 Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl;439 DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl); 432 440 } while (OtherAtom != Walker); 433 441 DFS.ComponentNumber++; … … 436 444 Walker = DFS.Root; 437 445 Binder = mol->FindNextUnused(Walker); 438 Log() << Verbose(1) << "(10) Walker is Root[" << DFS.Root->Name << "], next Unused Bond is " << Binder << "." << endl;446 DoLog(1) && (Log() << Verbose(1) << "(10) Walker is Root[" << DFS.Root->Name << "], next Unused Bond is " << Binder << "." << endl); 439 447 if (Binder != NULL) { // Root is separation vertex 440 Log() << Verbose(1) << "(11) Root is a separation vertex." << endl;448 DoLog(1) && (Log() << Verbose(1) << "(11) Root is a separation vertex." << endl); 441 449 Walker->SeparationVertex = true; 442 450 } … … 493 501 bond *Binder = NULL; 494 502 495 Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl; 503 if (AtomCount == 0) 504 return SubGraphs; 505 DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl); 496 506 DepthFirstSearchAnalysis_Init(DFS, this); 497 507 … … 515 525 516 526 if (Binder == NULL) { 517 Log() << Verbose(2) << "No more Unused Bonds." << endl;527 DoLog(2) && (Log() << Verbose(2) << "No more Unused Bonds." << endl); 518 528 break; 519 529 } else … … 532 542 533 543 // From OldGraphNr to CurrentGraphNr ranges an disconnected subgraph 534 Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl;544 DoLog(0) && (Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl); 535 545 LeafWalker->Leaf->Output((ofstream *)&cout); 536 Log() << Verbose(0) << endl;546 DoLog(0) && (Log() << Verbose(0) << endl); 537 547 538 548 // step on to next root … … 552 562 // free all and exit 553 563 DepthFirstSearchAnalysis_Finalize(DFS); 554 Log() << Verbose(0) << "End of DepthFirstSearchAnalysis" << endl;564 DoLog(0) && (Log() << Verbose(0) << "End of DepthFirstSearchAnalysis" << endl); 555 565 return SubGraphs; 556 566 } … … 578 588 void molecule::OutputGraphInfoPerAtom() const 579 589 { 580 Log() << Verbose(1) << "Final graph info for each atom is:" << endl;590 DoLog(1) && (Log() << Verbose(1) << "Final graph info for each atom is:" << endl); 581 591 ActOnAllAtoms( &atom::OutputGraphInfo ); 582 592 } … … 588 598 void molecule::OutputGraphInfoPerBond() const 589 599 { 590 Log() << Verbose(1) << "Final graph info for each bond is:" << endl;600 DoLog(1) && (Log() << Verbose(1) << "Final graph info for each bond is:" << endl); 591 601 bond *Binder = first; 592 602 while (Binder->next != last) { 593 603 Binder = Binder->next; 594 Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <";595 Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.";604 DoLog(2) && (Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <"); 605 DoLog(0) && (Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp."); 596 606 Binder->leftatom->OutputComponentNumber(); 597 Log() << Verbose(0) << " === ";598 Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp.";607 DoLog(0) && (Log() << Verbose(0) << " === "); 608 DoLog(0) && (Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp."); 599 609 Binder->rightatom->OutputComponentNumber(); 600 Log() << Verbose(0) << ">." << endl;610 DoLog(0) && (Log() << Verbose(0) << ">." << endl); 601 611 if (Binder->Cyclic) // cyclic ?? 602 Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl;612 DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl); 603 613 } 604 614 } … … 674 684 do { // look for Root 675 685 Walker = BFS.BFSStack->PopFirst(); 676 Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *BFS.Root << "." << endl;686 DoLog(2) && (Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *BFS.Root << "." << endl); 677 687 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { 678 688 if ((*Runner) != BackEdge) { // only walk along DFS spanning tree (otherwise we always find SP of one being backedge Binder) … … 681 691 if (OtherAtom->type->Z != 1) { 682 692 #endif 683 Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl;693 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl); 684 694 if (BFS.ColorList[OtherAtom->nr] == white) { 685 695 BFS.TouchedStack->Push(OtherAtom); … … 687 697 BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor 688 698 BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1; 689 Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " lightgray, its predecessor is " << Walker->Name << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl;699 DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " lightgray, its predecessor is " << Walker->Name << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl); 690 700 //if (BFS.ShortestPathList[OtherAtom->nr] < MinimumRingSize[Walker->GetTrueFather()->nr]) { // Check for maximum distance 691 Log() << Verbose(3) << "Putting OtherAtom into queue." << endl;701 DoLog(3) && (Log() << Verbose(3) << "Putting OtherAtom into queue." << endl); 692 702 BFS.BFSStack->Push(OtherAtom); 693 703 //} 694 704 } else { 695 Log() << Verbose(3) << "Not Adding, has already been visited." << endl;705 DoLog(3) && (Log() << Verbose(3) << "Not Adding, has already been visited." << endl); 696 706 } 697 707 if (OtherAtom == BFS.Root) … … 699 709 #ifdef ADDHYDROGEN 700 710 } else { 701 Log() << Verbose(2) << "Skipping hydrogen atom " << *OtherAtom << "." << endl;711 DoLog(2) && (Log() << Verbose(2) << "Skipping hydrogen atom " << *OtherAtom << "." << endl); 702 712 BFS.ColorList[OtherAtom->nr] = black; 703 713 } 704 714 #endif 705 715 } else { 706 Log() << Verbose(2) << "Bond " << *(*Runner) << " not Visiting, is the back edge." << endl;716 DoLog(2) && (Log() << Verbose(2) << "Bond " << *(*Runner) << " not Visiting, is the back edge." << endl); 707 717 } 708 718 } 709 719 BFS.ColorList[Walker->nr] = black; 710 Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;720 DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl); 711 721 if (OtherAtom == BFS.Root) { // if we have found the root, check whether this cycle wasn't already found beforehand 712 722 // step through predecessor list … … 718 728 } 719 729 if (OtherAtom == BackEdge->rightatom) { // if each atom in found cycle is cyclic, loop's been found before already 720 Log() << Verbose(3) << "This cycle was already found before, skipping and removing seeker from search." << endl;730 DoLog(3) && (Log() << Verbose(3) << "This cycle was already found before, skipping and removing seeker from search." << endl); 721 731 do { 722 732 OtherAtom = BFS.TouchedStack->PopLast(); 723 733 if (BFS.PredecessorList[OtherAtom->nr] == Walker) { 724 Log() << Verbose(4) << "Removing " << *OtherAtom << " from lists and stacks." << endl;734 DoLog(4) && (Log() << Verbose(4) << "Removing " << *OtherAtom << " from lists and stacks." << endl); 725 735 BFS.PredecessorList[OtherAtom->nr] = NULL; 726 736 BFS.ShortestPathList[OtherAtom->nr] = -1; … … 756 766 RingSize = 1; 757 767 BFS.Root->GetTrueFather()->IsCyclic = true; 758 Log() << Verbose(1) << "Found ring contains: ";768 DoLog(1) && (Log() << Verbose(1) << "Found ring contains: "); 759 769 Walker = BFS.Root; 760 770 while (Walker != BackEdge->rightatom) { 761 Log() << Verbose(0) << Walker->Name << " <-> ";771 DoLog(0) && (Log() << Verbose(0) << Walker->Name << " <-> "); 762 772 Walker = BFS.PredecessorList[Walker->nr]; 763 773 Walker->GetTrueFather()->IsCyclic = true; 764 774 RingSize++; 765 775 } 766 Log() << Verbose(0) << Walker->Name << " with a length of " << RingSize << "." << endl << endl;776 DoLog(0) && (Log() << Verbose(0) << Walker->Name << " with a length of " << RingSize << "." << endl << endl); 767 777 // walk through all and set MinimumRingSize 768 778 Walker = BFS.Root; … … 776 786 MinRingSize = RingSize; 777 787 } else { 778 Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[Walker->GetTrueFather()->nr] << " found." << endl;788 DoLog(1) && (Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[Walker->GetTrueFather()->nr] << " found." << endl); 779 789 } 780 790 }; … … 854 864 855 865 } 856 Log() << Verbose(1) << "Minimum ring size of " << *Root << " is " << MinimumRingSize[Root->GetTrueFather()->nr] << "." << endl;857 } 858 Log() << Verbose(1) << "Minimum ring size is " << MinRingSize << ", over " << NumCycles << " cycles total." << endl;866 DoLog(1) && (Log() << Verbose(1) << "Minimum ring size of " << *Root << " is " << MinimumRingSize[Root->GetTrueFather()->nr] << "." << endl); 867 } 868 DoLog(1) && (Log() << Verbose(1) << "Minimum ring size is " << MinRingSize << ", over " << NumCycles << " cycles total." << endl); 859 869 } else 860 Log() << Verbose(1) << "No rings were detected in the molecular structure." << endl;870 DoLog(1) && (Log() << Verbose(1) << "No rings were detected in the molecular structure." << endl); 861 871 } 862 872 ; … … 886 896 //BackEdgeStack->Output(out); 887 897 888 Log() << Verbose(1) << "Analysing cycles ... " << endl;898 DoLog(1) && (Log() << Verbose(1) << "Analysing cycles ... " << endl); 889 899 NumCycles = 0; 890 900 while (!BackEdgeStack->IsEmpty()) { … … 897 907 ResetBFSAccounting(Walker, BFS); 898 908 899 Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl;909 DoLog(1) && (Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl); 900 910 OtherAtom = NULL; 901 911 CyclicStructureAnalysis_CyclicBFSFromRootToRoot(BackEdge, BFS); … … 927 937 } 928 938 if (i == vertex->ListOfBonds.size()) { 929 eLog() << Verbose(0) << "Error: All Component entries are already occupied!" << endl;939 DoeLog(0) && (eLog()<< Verbose(0) << "Error: All Component entries are already occupied!" << endl); 930 940 performCriticalExit(); 931 941 } 932 942 } else { 933 eLog() << Verbose(0) << "Error: Given vertex is NULL!" << endl;943 DoeLog(0) && (eLog()<< Verbose(0) << "Error: Given vertex is NULL!" << endl); 934 944 performCriticalExit(); 935 945 } … … 969 979 void OutputAlreadyVisited(int *list) 970 980 { 971 Log() << Verbose(4) << "Already Visited Bonds:\t";981 DoLog(4) && (Log() << Verbose(4) << "Already Visited Bonds:\t"); 972 982 for (int i = 1; i <= list[0]; i++) 973 Log() << Verbose(0) << list[i] << " ";974 Log() << Verbose(0) << endl;983 DoLog(0) && (Log() << Verbose(0) << list[i] << " "); 984 DoLog(0) && (Log() << Verbose(0) << endl); 975 985 } 976 986 ; … … 978 988 /** Storing the bond structure of a molecule to file. 979 989 * Simply stores Atom::nr and then the Atom::nr of all bond partners per line. 980 * \param *out output stream for debugging981 990 * \param *path path to file 991 * \param *filename name of file 982 992 * \return true - file written successfully, false - writing failed 983 993 */ 984 bool molecule::StoreAdjacencyToFile(char *path )994 bool molecule::StoreAdjacencyToFile(char *path, char *filename) 985 995 { 986 996 ofstream AdjacencyFile; … … 988 998 bool status = true; 989 999 990 line << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE; 1000 if (path != NULL) 1001 line << path << "/" << filename; 1002 else 1003 line << filename; 991 1004 AdjacencyFile.open(line.str().c_str(), ios::out); 992 Log() << Verbose(1) << "Saving adjacency list ... ";1005 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... "); 993 1006 if (AdjacencyFile != NULL) { 1007 AdjacencyFile << "m\tn" << endl; 994 1008 ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile); 995 1009 AdjacencyFile.close(); 996 Log() << Verbose(1) << "done." << endl;1010 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 997 1011 } else { 998 Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl; 1012 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl); 1013 status = false; 1014 } 1015 1016 return status; 1017 } 1018 ; 1019 1020 /** Storing the bond structure of a molecule to file. 1021 * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line. 1022 * \param *path path to file 1023 * \param *filename name of file 1024 * \return true - file written successfully, false - writing failed 1025 */ 1026 bool molecule::StoreBondsToFile(char *path, char *filename) 1027 { 1028 ofstream BondFile; 1029 stringstream line; 1030 bool status = true; 1031 1032 if (path != NULL) 1033 line << path << "/" << filename; 1034 else 1035 line << filename; 1036 BondFile.open(line.str().c_str(), ios::out); 1037 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... "); 1038 if (BondFile != NULL) { 1039 BondFile << "m\tn" << endl; 1040 ActOnAllAtoms(&atom::OutputBonds, &BondFile); 1041 BondFile.close(); 1042 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 1043 } else { 1044 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl); 999 1045 status = false; 1000 1046 } … … 1009 1055 filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE; 1010 1056 File.open(filename.str().c_str(), ios::out); 1011 Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... ";1057 DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... "); 1012 1058 if (File == NULL) 1013 1059 return false; … … 1050 1096 //Log() << Verbose(0) << endl; 1051 1097 } else { 1052 Log() << Verbose(0) << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << Walker->ListOfBonds.size() << "." << endl;1098 DoLog(0) && (Log() << Verbose(0) << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << Walker->ListOfBonds.size() << "." << endl); 1053 1099 status = false; 1054 1100 } … … 1073 1119 1074 1120 if (!CheckAdjacencyFileAgainstMolecule_Init(path, File, CurrentBonds)) { 1075 Log() << Verbose(1) << "Adjacency file not found." << endl;1121 DoLog(1) && (Log() << Verbose(1) << "Adjacency file not found." << endl); 1076 1122 return true; 1077 1123 } … … 1099 1145 1100 1146 if (status) { // if equal we parse the KeySetFile 1101 Log() << Verbose(1) << "done: Equal." << endl;1147 DoLog(1) && (Log() << Verbose(1) << "done: Equal." << endl); 1102 1148 } else 1103 Log() << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl;1149 DoLog(1) && (Log() << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl); 1104 1150 return status; 1105 1151 } … … 1117 1163 bool status = true; 1118 1164 if (ReferenceStack->IsEmpty()) { 1119 eLog() << Verbose(0) << "ReferenceStack is empty!" << endl; 1120 performCriticalExit(); 1165 DoLog(1) && (Log() << Verbose(1) << "ReferenceStack is empty!" << endl); 1121 1166 return false; 1122 1167 } … … 1133 1178 if (OtherAtom == ListOfLocalAtoms[(*Runner)->rightatom->nr]) { // found the bond 1134 1179 LocalStack->Push((*Runner)); 1135 Log() << Verbose(3) << "Found local edge " << *(*Runner) << "." << endl;1180 DoLog(3) && (Log() << Verbose(3) << "Found local edge " << *(*Runner) << "." << endl); 1136 1181 break; 1137 1182 } 1138 1183 } 1139 1184 Binder = ReferenceStack->PopFirst(); // loop the stack for next item 1140 Log() << Verbose(3) << "Current candidate edge " << Binder << "." << endl;1185 DoLog(3) && (Log() << Verbose(3) << "Current candidate edge " << Binder << "." << endl); 1141 1186 ReferenceStack->Push(Binder); 1142 1187 } while (FirstBond != Binder); … … 1187 1232 BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor 1188 1233 BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1; 1189 Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " " << ((BFS.ColorList[OtherAtom->nr] == white) ? "white" : "lightgray") << ", its predecessor is " << Walker->Name << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl;1234 DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " " << ((BFS.ColorList[OtherAtom->nr] == white) ? "white" : "lightgray") << ", its predecessor is " << Walker->Name << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl); 1190 1235 if ((((BFS.ShortestPathList[OtherAtom->nr] < BFS.BondOrder) && (Binder != Bond)))) { // Check for maximum distance 1191 Log() << Verbose(3);1236 DoLog(3) && (Log() << Verbose(3)); 1192 1237 if (AddedAtomList[OtherAtom->nr] == NULL) { // add if it's not been so far 1193 1238 AddedAtomList[OtherAtom->nr] = Mol->AddCopyAtom(OtherAtom); 1194 Log() << Verbose(0) << "Added OtherAtom " << OtherAtom->Name;1239 DoLog(0) && (Log() << Verbose(0) << "Added OtherAtom " << OtherAtom->Name); 1195 1240 AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder); 1196 Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", ";1241 DoLog(0) && (Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", "); 1197 1242 } else { // this code should actually never come into play (all white atoms are not yet present in BondMolecule, that's why they are white in the first place) 1198 Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom->Name;1243 DoLog(0) && (Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom->Name); 1199 1244 if (AddedBondList[Binder->nr] == NULL) { 1200 1245 AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder); 1201 Log() << Verbose(0) << ", added Bond " << *(AddedBondList[Binder->nr]);1246 DoLog(0) && (Log() << Verbose(0) << ", added Bond " << *(AddedBondList[Binder->nr])); 1202 1247 } else 1203 Log() << Verbose(0) << ", not added Bond ";1204 } 1205 Log() << Verbose(0) << ", putting OtherAtom into queue." << endl;1248 DoLog(0) && (Log() << Verbose(0) << ", not added Bond "); 1249 } 1250 DoLog(0) && (Log() << Verbose(0) << ", putting OtherAtom into queue." << endl); 1206 1251 BFS.BFSStack->Push(OtherAtom); 1207 1252 } else { // out of bond order, then replace … … 1209 1254 BFS.ColorList[OtherAtom->nr] = white; // unmark if it has not been queued/added, to make it available via its other bonds (cyclic) 1210 1255 if (Binder == Bond) 1211 Log() << Verbose(3) << "Not Queueing, is the Root bond";1256 DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is the Root bond"); 1212 1257 else if (BFS.ShortestPathList[OtherAtom->nr] >= BFS.BondOrder) 1213 Log() << Verbose(3) << "Not Queueing, is out of Bond Count of " << BFS.BondOrder;1258 DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is out of Bond Count of " << BFS.BondOrder); 1214 1259 if (!Binder->Cyclic) 1215 Log() << Verbose(0) << ", is not part of a cyclic bond, saturating bond with Hydrogen." << endl;1260 DoLog(0) && (Log() << Verbose(0) << ", is not part of a cyclic bond, saturating bond with Hydrogen." << endl); 1216 1261 if (AddedBondList[Binder->nr] == NULL) { 1217 1262 if ((AddedAtomList[OtherAtom->nr] != NULL)) { // .. whether we add or saturate … … 1230 1275 void BreadthFirstSearchAdd_VisitedNode(molecule *Mol, struct BFSAccounting &BFS, atom *&Walker, atom *&OtherAtom, bond *&Binder, bond *&Bond, atom **&AddedAtomList, bond **&AddedBondList, bool IsAngstroem) 1231 1276 { 1232 Log() << Verbose(3) << "Not Adding, has already been visited." << endl;1277 DoLog(3) && (Log() << Verbose(3) << "Not Adding, has already been visited." << endl); 1233 1278 // This has to be a cyclic bond, check whether it's present ... 1234 1279 if (AddedBondList[Binder->nr] == NULL) { … … 1276 1321 // followed by n+1 till top of stack. 1277 1322 Walker = BFS.BFSStack->PopFirst(); // pop oldest added 1278 Log() << Verbose(1) << "Current Walker is: " << Walker->Name << ", and has " << Walker->ListOfBonds.size() << " bonds." << endl;1323 DoLog(1) && (Log() << Verbose(1) << "Current Walker is: " << Walker->Name << ", and has " << Walker->ListOfBonds.size() << " bonds." << endl); 1279 1324 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { 1280 1325 if ((*Runner) != NULL) { // don't look at bond equal NULL 1281 1326 Binder = (*Runner); 1282 1327 OtherAtom = (*Runner)->GetOtherAtom(Walker); 1283 Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl;1328 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl); 1284 1329 if (BFS.ColorList[OtherAtom->nr] == white) { 1285 1330 BreadthFirstSearchAdd_UnvisitedNode(Mol, BFS, Walker, OtherAtom, Binder, Bond, AddedAtomList, AddedBondList, IsAngstroem); … … 1290 1335 } 1291 1336 BFS.ColorList[Walker->nr] = black; 1292 Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;1337 DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl); 1293 1338 } 1294 1339 BreadthFirstSearchAdd_Free(BFS); … … 1315 1360 // reset parent list 1316 1361 ParentList = Calloc<atom*> (AtomCount, "molecule::BuildInducedSubgraph_Init: **ParentList"); 1317 Log() << Verbose(3) << "Resetting ParentList." << endl;1362 DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl); 1318 1363 } 1319 1364 ; … … 1322 1367 { 1323 1368 // fill parent list with sons 1324 Log() << Verbose(3) << "Filling Parent List." << endl;1369 DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl); 1325 1370 atom *Walker = mol->start; 1326 1371 while (Walker->next != mol->end) { … … 1328 1373 ParentList[Walker->father->nr] = Walker; 1329 1374 // Outputting List for debugging 1330 Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl;1375 DoLog(4) && (Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl); 1331 1376 } 1332 1377 … … 1346 1391 atom *OtherAtom = NULL; 1347 1392 // check each entry of parent list and if ok (one-to-and-onto matching) create bonds 1348 Log() << Verbose(3) << "Creating bonds." << endl;1393 DoLog(3) && (Log() << Verbose(3) << "Creating bonds." << endl); 1349 1394 Walker = Father->start; 1350 1395 while (Walker->next != Father->end) { … … 1357 1402 OtherAtom = (*Runner)->GetOtherAtom(Walker); 1358 1403 if (ParentList[OtherAtom->nr] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond 1359 Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[Walker->nr]->Name << " and " << ParentList[OtherAtom->nr]->Name << "." << endl;1404 DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[Walker->nr]->Name << " and " << ParentList[OtherAtom->nr]->Name << "." << endl); 1360 1405 mol->AddBond(ParentList[Walker->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree); 1361 1406 } … … 1382 1427 atom **ParentList = NULL; 1383 1428 1384 Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl;1429 DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl); 1385 1430 BuildInducedSubgraph_Init(ParentList, Father->AtomCount); 1386 1431 BuildInducedSubgraph_FillParentList(this, Father, ParentList); 1387 1432 status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList); 1388 1433 BuildInducedSubgraph_Finalize(ParentList); 1389 Log() << Verbose(2) << "End of BuildInducedSubgraph." << endl;1434 DoLog(2) && (Log() << Verbose(2) << "End of BuildInducedSubgraph." << endl); 1390 1435 return status; 1391 1436 } … … 1404 1449 int size; 1405 1450 1406 Log() << Verbose(1) << "Begin of CheckForConnectedSubgraph" << endl;1407 Log() << Verbose(2) << "Disconnected atom: ";1451 DoLog(1) && (Log() << Verbose(1) << "Begin of CheckForConnectedSubgraph" << endl); 1452 DoLog(2) && (Log() << Verbose(2) << "Disconnected atom: "); 1408 1453 1409 1454 // count number of atoms in graph … … 1427 1472 } 1428 1473 if (!BondStatus) { 1429 Log() << Verbose(0) << (*Walker) << endl;1474 DoLog(0) && (Log() << Verbose(0) << (*Walker) << endl); 1430 1475 return false; 1431 1476 } 1432 1477 } 1433 1478 else { 1434 Log() << Verbose(0) << "none." << endl;1479 DoLog(0) && (Log() << Verbose(0) << "none." << endl); 1435 1480 return true; 1436 1481 } 1437 Log() << Verbose(0) << "none." << endl;1438 1439 Log() << Verbose(1) << "End of CheckForConnectedSubgraph" << endl;1482 DoLog(0) && (Log() << Verbose(0) << "none." << endl); 1483 1484 DoLog(1) && (Log() << Verbose(1) << "End of CheckForConnectedSubgraph" << endl); 1440 1485 1441 1486 return true; -
src/molecule_pointcloud.cpp
r491876 rc695c9 50 50 }; 51 51 52 /** Return the greatest index of all atoms in the list. 53 * \return greatest index 54 */ 55 int molecule::GetMaxId() const 56 { 57 return last_atom; 58 }; 59 52 60 /** Go to next atom. 53 61 * Stops at last one. -
src/moleculelist.cpp
r491876 rc695c9 4 4 * 5 5 */ 6 7 #include <cstring> 6 8 7 9 #include "atom.hpp" … … 17 19 #include "memoryallocator.hpp" 18 20 #include "periodentafel.hpp" 21 #include "World.hpp" 19 22 20 23 /*********************************** Functions for class MoleculeListClass *************************/ … … 33 36 MoleculeListClass::~MoleculeListClass() 34 37 { 35 Log() << Verbose(3) << this << ": Freeing ListOfMolcules." << endl;38 DoLog(3) && (Log() << Verbose(3) << this << ": Freeing ListOfMolcules." << endl); 36 39 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) { 37 Log() << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl;40 DoLog(4) && (Log() << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl); 38 41 delete (*ListRunner); 39 42 } 40 Log() << Verbose(4) << "Freeing ListOfMolecules." << endl;43 DoLog(4) && (Log() << Verbose(4) << "Freeing ListOfMolecules." << endl); 41 44 ListOfMolecules.clear(); // empty list 42 45 }; … … 142 145 143 146 // header 144 Log() << Verbose(0) << "Index\tName\t\tAtoms\tFormula\tCenter\tSize" << endl;145 Log() << Verbose(0) << "-----------------------------------------------" << endl;147 DoLog(0) && (Log() << Verbose(0) << "Index\tName\t\tAtoms\tFormula\tCenter\tSize" << endl); 148 DoLog(0) && (Log() << Verbose(0) << "-----------------------------------------------" << endl); 146 149 if (ListOfMolecules.size() == 0) 147 Log() << Verbose(0) << "\tNone" << endl;150 DoLog(0) && (Log() << Verbose(0) << "\tNone" << endl); 148 151 else { 149 152 Origin.Zero(); … … 162 165 } 163 166 // output Index, Name, number of atoms, chemical formula 164 Log() << Verbose(0) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->AtomCount << "\t";167 DoLog(0) && (Log() << Verbose(0) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->AtomCount << "\t"); 165 168 Elemental = (*ListRunner)->elemente->end; 166 169 while(Elemental->previous != (*ListRunner)->elemente->start) { 167 170 Elemental = Elemental->previous; 168 171 if (Counts[Elemental->Z] != 0) 169 Log() << Verbose(0) << Elemental->symbol << Counts[Elemental->Z];172 DoLog(0) && (Log() << Verbose(0) << Elemental->symbol << Counts[Elemental->Z]); 170 173 } 171 174 // Center and size 172 Log() << Verbose(0) << "\t" << (*ListRunner)->Center << "\t" << sqrt(size) << endl;175 DoLog(0) && (Log() << Verbose(0) << "\t" << (*ListRunner)->Center << "\t" << sqrt(size) << endl); 173 176 } 174 177 } … … 311 314 Tesselation *TesselStruct = NULL; 312 315 if ((srcmol == NULL) || (mol == NULL)) { 313 eLog() << Verbose(1) << "Either fixed or variable molecule is given as NULL." << endl;316 DoeLog(1) && (eLog()<< Verbose(1) << "Either fixed or variable molecule is given as NULL." << endl); 314 317 return false; 315 318 } … … 319 322 FindNonConvexBorder(mol, TesselStruct, (const LinkedCell *&)LCList, 4., NULL); 320 323 if (TesselStruct == NULL) { 321 eLog() << Verbose(1) << "Could not tesselate the fixed molecule." << endl;324 DoeLog(1) && (eLog()<< Verbose(1) << "Could not tesselate the fixed molecule." << endl); 322 325 return false; 323 326 } … … 336 339 while (Walker->next != srcmol->end) { 337 340 Walker = Walker->next; 338 Log() << Verbose(2) << "INFO: Current Walker is " << *Walker << "." << endl;341 DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << *Walker << "." << endl); 339 342 if (!TesselStruct->IsInnerPoint(Walker->x, LCList)) { 340 343 CopyAtoms[Walker->nr] = new atom(Walker); … … 345 348 } 346 349 } 347 Log() << Verbose(1) << nr << " of " << srcmol->AtomCount << " atoms have been merged.";350 DoLog(1) && (Log() << Verbose(1) << nr << " of " << srcmol->AtomCount << " atoms have been merged."); 348 351 349 352 // go through all bonds and add as well … … 351 354 while(Binder->next != srcmol->last) { 352 355 Binder = Binder->next; 353 Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;356 DoLog(3) && (Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl); 354 357 mol->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree); 355 358 } … … 363 366 void MoleculeListClass::Output(ofstream *out) 364 367 { 365 Log() << Verbose(1) << "MoleculeList: ";368 DoLog(1) && (Log() << Verbose(1) << "MoleculeList: "); 366 369 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) 367 Log() << Verbose(0) << *ListRunner << "\t";368 Log() << Verbose(0) << endl;370 DoLog(0) && (Log() << Verbose(0) << *ListRunner << "\t"); 371 DoLog(0) && (Log() << Verbose(0) << endl); 369 372 }; 370 373 … … 392 395 char *FragmentNumber = NULL; 393 396 394 Log() << Verbose(1) << "Saving hydrogen saturation correction ... ";397 DoLog(1) && (Log() << Verbose(1) << "Saving hydrogen saturation correction ... "); 395 398 // 0. parse in fit constant files that should have the same dimension as the final energy files 396 399 // 0a. find dimension of matrices with constants … … 402 405 input.open(line.c_str()); 403 406 if (input == NULL) { 404 eLog() << Verbose(0) << endl << "Unable to open " << line << ", is the directory correct?" << endl; 405 performCriticalExit(); 407 DoLog(1) && (Log() << Verbose(1) << endl << "Unable to open " << line << ", is the directory correct?" << endl); 406 408 return false; 407 409 } … … 420 422 b++; 421 423 } 422 Log() << Verbose(0) << "I recognized " << a << " columns and " << b << " rows, ";424 DoLog(0) && (Log() << Verbose(0) << "I recognized " << a << " columns and " << b << " rows, "); 423 425 input.close(); 424 426 … … 441 443 input.open(line.c_str()); 442 444 if (input == NULL) { 443 eLog() << Verbose(0) << endl << "Unable to open " << line << ", is the directory correct?" << endl;445 DoeLog(0) && (eLog()<< Verbose(0) << endl << "Unable to open " << line << ", is the directory correct?" << endl); 444 446 performCriticalExit(); 445 447 return false; … … 463 465 } 464 466 for (int k = 0; k < 3; k++) { 465 Log() << Verbose(0) << "Constants " << k << ":" << endl;467 DoLog(0) && (Log() << Verbose(0) << "Constants " << k << ":" << endl); 466 468 for (int j = 0; j < b; j++) { 467 469 for (int i = 0; i < a; i++) { 468 Log() << Verbose(0) << FitConstant[k][i][j] << "\t";470 DoLog(0) && (Log() << Verbose(0) << FitConstant[k][i][j] << "\t"); 469 471 } 470 Log() << Verbose(0) << endl;471 } 472 Log() << Verbose(0) << endl;472 DoLog(0) && (Log() << Verbose(0) << endl); 473 } 474 DoLog(0) && (Log() << Verbose(0) << endl); 473 475 } 474 476 … … 558 560 } 559 561 Free(&FitConstant); 560 Log() << Verbose(0) << "done." << endl;562 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 561 563 return true; 562 564 }; … … 578 580 579 581 // open file for the force factors 580 Log() << Verbose(1) << "Saving force factors ... ";582 DoLog(1) && (Log() << Verbose(1) << "Saving force factors ... "); 581 583 line << path << "/" << FRAGMENTPREFIX << FORCESFILE; 582 584 ForcesFile.open(line.str().c_str(), ios::out); … … 606 608 } 607 609 ForcesFile.close(); 608 Log() << Verbose(1) << "done." << endl;610 DoLog(1) && (Log() << Verbose(1) << "done." << endl); 609 611 } else { 610 612 status = false; 611 Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;613 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl); 612 614 } 613 615 ForcesFile.close(); … … 637 639 int FragmentCounter = 0; 638 640 ofstream output; 639 641 double cell_size_backup[6]; 642 double * const cell_size = World::get()->cell_size; 643 644 // backup cell_size 645 for (int i=0;i<6;i++) 646 cell_size_backup[i] = cell_size[i]; 640 647 // store the fragments as config and as xyz 641 648 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) { … … 645 652 strcpy(PathBackup, path); 646 653 else { 647 eLog() << Verbose(0) << "OutputConfigForListOfFragments: NULL default path obtained from config!" << endl;654 DoeLog(0) && (eLog()<< Verbose(0) << "OutputConfigForListOfFragments: NULL default path obtained from config!" << endl); 648 655 performCriticalExit(); 649 656 } … … 656 663 sprintf(FragmentName, "%s/%s%s.conf.xyz", configuration->configpath, FRAGMENTPREFIX, FragmentNumber); 657 664 outputFragment.open(FragmentName, ios::out); 658 Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as XYZ ...";665 DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as XYZ ..."); 659 666 if ((intermediateResult = (*ListRunner)->OutputXYZ(&outputFragment))) 660 Log() << Verbose(0) << " done." << endl;667 DoLog(0) && (Log() << Verbose(0) << " done." << endl); 661 668 else 662 Log() << Verbose(0) << " failed." << endl;669 DoLog(0) && (Log() << Verbose(0) << " failed." << endl); 663 670 result = result && intermediateResult; 664 671 outputFragment.close(); … … 666 673 667 674 // list atoms in fragment for debugging 668 Log() << Verbose(2) << "Contained atoms: ";675 DoLog(2) && (Log() << Verbose(2) << "Contained atoms: "); 669 676 Walker = (*ListRunner)->start; 670 677 while (Walker->next != (*ListRunner)->end) { 671 678 Walker = Walker->next; 672 Log() << Verbose(0) << Walker->Name << " ";673 } 674 Log() << Verbose(0) << endl;679 DoLog(0) && (Log() << Verbose(0) << Walker->Name << " "); 680 } 681 DoLog(0) && (Log() << Verbose(0) << endl); 675 682 676 683 // center on edge … … 681 688 j += k + 1; 682 689 BoxDimension.x[k] = 2.5 * (configuration->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem); 683 (*ListRunner)->cell_size[j] += BoxDimension.x[k] * 2.;690 cell_size[j] = BoxDimension.x[k] * 2.; 684 691 } 685 692 (*ListRunner)->Translate(&BoxDimension); … … 696 703 // and save as config 697 704 sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber); 698 Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as config ...";705 DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as config ..."); 699 706 if ((intermediateResult = configuration->Save(FragmentName, (*ListRunner)->elemente, (*ListRunner)))) 700 Log() << Verbose(0) << " done." << endl;707 DoLog(0) && (Log() << Verbose(0) << " done." << endl); 701 708 else 702 Log() << Verbose(0) << " failed." << endl;709 DoLog(0) && (Log() << Verbose(0) << " failed." << endl); 703 710 result = result && intermediateResult; 704 711 … … 708 715 // and save as mpqc input file 709 716 sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber); 710 Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as mpqc input ...";717 DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as mpqc input ..."); 711 718 if ((intermediateResult = configuration->SaveMPQC(FragmentName, (*ListRunner)))) 712 Log() << Verbose(2) << " done." << endl;719 DoLog(2) && (Log() << Verbose(2) << " done." << endl); 713 720 else 714 Log() << Verbose(0) << " failed." << endl;721 DoLog(0) && (Log() << Verbose(0) << " failed." << endl); 715 722 716 723 result = result && intermediateResult; … … 719 726 Free(&FragmentNumber); 720 727 } 721 Log() << Verbose(0) << " done." << endl;728 DoLog(0) && (Log() << Verbose(0) << " done." << endl); 722 729 723 730 // printing final number 724 Log() << Verbose(2) << "Final number of fragments: " << FragmentCounter << "." << endl; 731 DoLog(2) && (Log() << Verbose(2) << "Final number of fragments: " << FragmentCounter << "." << endl); 732 733 // restore cell_size 734 for (int i=0;i<6;i++) 735 cell_size[i] = cell_size_backup[i]; 725 736 726 737 return result; … … 740 751 /** Dissects given \a *mol into connected subgraphs and inserts them as new molecules but with old atoms into \a this. 741 752 * \param *out output stream for debugging 742 * \param * mol molecule with atoms to dissect753 * \param *periode periodentafel 743 754 * \param *configuration config with BondGraph 744 755 */ 745 void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(molecule * const mol, config * const configuration) 746 { 756 void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration) 757 { 758 molecule *mol = new molecule(periode); 759 atom *Walker = NULL; 760 atom *Advancer = NULL; 761 bond *Binder = NULL; 762 bond *Stepper = NULL; 763 // 0. gather all atoms into single molecule 764 for (MoleculeList::iterator MolRunner = ListOfMolecules.begin(); !ListOfMolecules.empty(); MolRunner = ListOfMolecules.begin()) { 765 // shift all atoms to new molecule 766 Advancer = (*MolRunner)->start->next; 767 while (Advancer != (*MolRunner)->end) { 768 Walker = Advancer; 769 Advancer = Advancer->next; 770 DoLog(3) && (Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl); 771 unlink(Walker); 772 Walker->father = Walker; 773 mol->AddAtom(Walker); // counting starts at 1 774 } 775 // remove all bonds 776 Stepper = (*MolRunner)->first->next; 777 while (Stepper != (*MolRunner)->last) { 778 Binder = Stepper; 779 Stepper = Stepper->next; 780 delete(Binder); 781 } 782 // remove the molecule 783 delete(*MolRunner); 784 ListOfMolecules.erase(MolRunner); 785 } 786 747 787 // 1. dissect the molecule into connected subgraphs 748 configuration->BG->ConstructBondGraph(mol); 788 if (!configuration->BG->ConstructBondGraph(mol)) { 789 delete (mol); 790 DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl); 791 return; 792 } 749 793 750 794 // 2. scan for connected subgraphs … … 753 797 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack); 754 798 delete(BackEdgeStack); 799 if ((Subgraphs == NULL) || (Subgraphs->next == NULL)) { 800 delete (mol); 801 DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms." << endl); 802 return; 803 } 755 804 756 805 // 3. dissect (the following construct is needed to have the atoms not in the order of the DFS, but in … … 770 819 strncat(molecules[i]->name, number, MAXSTRINGSIZE - strlen(mol->name) - 1); 771 820 } 772 cout << "MolName is " << molecules[i]->name << endl;821 DoLog(1) && (Log() << Verbose(1) << "MolName is " << molecules[i]->name << endl); 773 822 insert(molecules[i]); 774 823 } … … 778 827 int *MolMap = Calloc<int>(mol->AtomCount, "config::Load() - *MolMap"); 779 828 MoleculeLeafClass *MolecularWalker = Subgraphs; 780 atom *Walker = NULL;829 Walker = NULL; 781 830 while (MolecularWalker->next != NULL) { 782 831 MolecularWalker = MolecularWalker->next; … … 794 843 Walker = mol->start->next; 795 844 if ((Walker->nr <0) || (Walker->nr >= mol->AtomCount)) { 796 eLog() << Verbose(0) << "Index of atom " << *Walker << " is invalid!" << endl;845 DoeLog(0) && (eLog()<< Verbose(0) << "Index of atom " << *Walker << " is invalid!" << endl); 797 846 performCriticalExit(); 798 847 } 799 848 FragmentCounter = MolMap[Walker->nr]; 800 849 if (FragmentCounter != 0) { 801 Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl;850 DoLog(3) && (Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl); 802 851 unlink(Walker); 803 852 molecules[FragmentCounter-1]->AddAtom(Walker); // counting starts at 1 804 853 } else { 805 eLog() << Verbose(0) << "Atom " << *Walker << " not associated to molecule!" << endl;854 DoeLog(0) && (eLog()<< Verbose(0) << "Atom " << *Walker << " not associated to molecule!" << endl); 806 855 performCriticalExit(); 807 856 } 808 857 } 809 858 // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintain their ListOfBonds, but we have to remove them from first..last list 810 bond *Binder = mol->first;859 Binder = mol->first; 811 860 while (mol->first->next != mol->last) { 812 861 Binder = mol->first->next; … … 824 873 Free(&MolMap); 825 874 Free(&molecules); 826 Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl;875 DoLog(1) && (Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl); 827 876 }; 828 877 … … 933 982 int AtomNo; 934 983 935 Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl;984 DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl); 936 985 // fill ListOfLocalAtoms if NULL was given 937 986 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) { 938 Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl;987 DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl); 939 988 return false; 940 989 } 941 990 942 991 if (status) { 943 Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl;992 DoLog(1) && (Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl); 944 993 // remove every bond from the list 945 994 bond *Binder = NULL; … … 962 1011 Leaf->AddBond(Walker, OtherWalker, (*Runner)->BondDegree); 963 1012 } else { 964 Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom(Walker->GetTrueFather())->nr << "] is NULL!" << endl;1013 DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom(Walker->GetTrueFather())->nr << "] is NULL!" << endl); 965 1014 status = false; 966 1015 } … … 975 1024 Free(&ListOfLocalAtoms); 976 1025 } 977 Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl;1026 DoLog(1) && (Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl); 978 1027 return status; 979 1028 }; … … 1008 1057 next->FillRootStackForSubgraphs(RootStack, AtomMask, ++FragmentCounter); 1009 1058 } else { 1010 Log() << Verbose(1) << "Rootstack[" << FragmentCounter << "] is NULL." << endl;1059 DoLog(1) && (Log() << Verbose(1) << "Rootstack[" << FragmentCounter << "] is NULL." << endl); 1011 1060 return false; 1012 1061 } … … 1014 1063 return true; 1015 1064 } else { 1016 Log() << Verbose(1) << "Rootstack is NULL." << endl;1065 DoLog(1) && (Log() << Verbose(1) << "Rootstack is NULL." << endl); 1017 1066 return false; 1018 1067 } … … 1064 1113 int KeySetCounter = 0; 1065 1114 1066 Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl;1115 DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl); 1067 1116 // fill ListOfLocalAtoms if NULL was given 1068 1117 if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) { 1069 Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl;1118 DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl); 1070 1119 return false; 1071 1120 } … … 1095 1144 delete (TempSet); 1096 1145 if (KeySetCounter == 0) {// if there are no keysets, delete the list 1097 Log() << Verbose(1) << "KeySetCounter is zero, deleting FragmentList." << endl;1146 DoLog(1) && (Log() << Verbose(1) << "KeySetCounter is zero, deleting FragmentList." << endl); 1098 1147 delete (FragmentList[FragmentCounter]); 1099 1148 } else 1100 Log() << Verbose(1) << KeySetCounter << " keysets were assigned to subgraph " << FragmentCounter << "." << endl;1149 DoLog(1) && (Log() << Verbose(1) << KeySetCounter << " keysets were assigned to subgraph " << FragmentCounter << "." << endl); 1101 1150 FragmentCounter++; 1102 1151 if (next != NULL) … … 1104 1153 FragmentCounter--; 1105 1154 } else 1106 Log() << Verbose(1) << "KeySetList is NULL or empty." << endl;1155 DoLog(1) && (Log() << Verbose(1) << "KeySetList is NULL or empty." << endl); 1107 1156 1108 1157 if ((FreeList) && (ListOfLocalAtoms != NULL)) { … … 1112 1161 Free(&ListOfLocalAtoms); 1113 1162 } 1114 Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl;1163 DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl); 1115 1164 return status; 1116 1165 }; … … 1125 1174 void MoleculeLeafClass::TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph) 1126 1175 { 1127 Log() << Verbose(1) << "Begin of TranslateIndicesToGlobalIDs." << endl;1176 DoLog(1) && (Log() << Verbose(1) << "Begin of TranslateIndicesToGlobalIDs." << endl); 1128 1177 KeySet *TempSet = new KeySet; 1129 1178 if (FragmentList[FragmentCounter] != NULL) { … … 1136 1185 delete (TempSet); 1137 1186 } else { 1138 Log() << Verbose(1) << "FragmentList is NULL." << endl;1187 DoLog(1) && (Log() << Verbose(1) << "FragmentList is NULL." << endl); 1139 1188 } 1140 1189 if (next != NULL) 1141 1190 next->TranslateIndicesToGlobalIDs(FragmentList, ++FragmentCounter, TotalNumberOfKeySets, TotalGraph); 1142 1191 FragmentCounter--; 1143 Log() << Verbose(1) << "End of TranslateIndicesToGlobalIDs." << endl;1192 DoLog(1) && (Log() << Verbose(1) << "End of TranslateIndicesToGlobalIDs." << endl); 1144 1193 }; 1145 1194 -
src/parser.cpp
r491876 rc695c9 7 7 // ======================================= INCLUDES ========================================== 8 8 9 #include <cstring> 10 9 11 #include "helpers.hpp" 10 12 #include "memoryallocator.hpp" … … 30 32 if (input == NULL) { 31 33 if (!test) 32 Log() << Verbose(0) << endl << "Unable to open " << filename << ", is the directory correct?" << endl;34 DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << filename << ", is the directory correct?" << endl); 33 35 return false; 34 36 } … … 107 109 bool MatrixContainer::InitialiseIndices(class MatrixContainer *Matrix) 108 110 { 109 Log() << Verbose(0) << "Initialising indices";111 DoLog(0) && (Log() << Verbose(0) << "Initialising indices"); 110 112 if (Matrix == NULL) { 111 Log() << Verbose(0) << " with trivial mapping." << endl;113 DoLog(0) && (Log() << Verbose(0) << " with trivial mapping." << endl); 112 114 Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices"); 113 115 for(int i=MatrixCounter+1;i--;) { … … 117 119 } 118 120 } else { 119 Log() << Verbose(0) << " from other MatrixContainer." << endl;121 DoLog(0) && (Log() << Verbose(0) << " from other MatrixContainer." << endl); 120 122 if (MatrixCounter != Matrix->MatrixCounter) 121 123 return false; … … 156 158 157 159 input.open(name, ios::in); 158 //Log() << Verbose( 0) << "Opening " << name << " ... " << input << endl;160 //Log() << Verbose(1) << "Opening " << name << " ... " << input << endl; 159 161 if (input == NULL) { 160 eLog() << Verbose(0) << endl << "Unable to open " << name << ", is the directory correct?" << endl;161 performCriticalExit();162 DoeLog(1) && (eLog()<< Verbose(1) << endl << "Unable to open " << name << ", is the directory correct?" << endl); 163 //performCriticalExit(); 162 164 return false; 163 165 } … … 179 181 } 180 182 //Log() << Verbose(0) << line.str() << endl; 181 //Log() << Verbose( 0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl;183 //Log() << Verbose(1) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl; 182 184 if (ColumnCounter[MatrixNr] == 0) { 183 eLog() << Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl;185 DoeLog(0) && (eLog()<< Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl); 184 186 performCriticalExit(); 185 187 } … … 195 197 } 196 198 } 197 //Log() << Verbose( 0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl;199 //Log() << Verbose(1) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl; 198 200 if (RowCounter[MatrixNr] == 0) { 199 eLog() << Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl;201 DoeLog(0) && (eLog()<< Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl); 200 202 performCriticalExit(); 201 203 } … … 218 220 input.getline(filename, 1023); 219 221 stringstream lines(filename); 220 //Log() << Verbose( 0) << "Matrix at level " << j << ":";// << filename << endl;222 //Log() << Verbose(2) << "Matrix at level " << j << ":";// << filename << endl; 221 223 for(int k=skipcolumns;k--;) 222 224 lines >> filename; 223 225 for(int k=0;(k<ColumnCounter[MatrixNr]) && (!lines.eof());k++) { 224 226 lines >> Matrix[MatrixNr][j][k]; 225 //Log() << Verbose( 0) << " " << setprecision(2) << Matrix[MatrixNr][j][k];;227 //Log() << Verbose(1) << " " << setprecision(2) << Matrix[MatrixNr][j][k] << endl; 226 228 } 227 //Log() << Verbose(0) << endl;228 229 Matrix[MatrixNr][ RowCounter[MatrixNr] ] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[RowCounter[MatrixNr]][]"); 229 230 for(int j=ColumnCounter[MatrixNr];j--;) … … 231 232 } 232 233 } else { 233 eLog() << Verbose(1) << "Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter[MatrixNr] << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl;234 DoeLog(1) && (eLog()<< Verbose(1) << "Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter[MatrixNr] << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl); 234 235 } 235 236 input.close(); … … 268 269 input.open(file.str().c_str(), ios::in); 269 270 if (input == NULL) { 270 Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl;271 DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl); 271 272 return false; 272 273 } … … 277 278 } 278 279 input.close(); 279 Log() << Verbose(0) << "Determined " << MatrixCounter << " fragments." << endl;280 281 Log() << Verbose(0) << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl;280 DoLog(0) && (Log() << Verbose(0) << "Determined " << MatrixCounter << " fragments." << endl); 281 282 DoLog(0) && (Log() << Verbose(0) << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl); 282 283 Header = ReAlloc<char*>(Header, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: **Header"); // one more each for the total molecule 283 284 Matrix = ReAlloc<double**>(Matrix, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule … … 432 433 //Log() << Verbose(0) << "Corresponding index in CurrentFragment is " << m << "." << endl; 433 434 if (m > RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 434 eLog() << Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current force index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl;435 DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current force index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl); 435 436 performCriticalExit(); 436 437 return false; … … 468 469 char *FragmentNumber = NULL; 469 470 470 Log() << Verbose(0) << "Writing fragment files." << endl;471 DoLog(0) && (Log() << Verbose(0) << "Writing fragment files." << endl); 471 472 for(int i=0;i<MatrixCounter;i++) { 472 473 stringstream line; … … 476 477 output.open(line.str().c_str(), ios::out); 477 478 if (output == NULL) { 478 eLog() << Verbose(0) << "Unable to open output energy file " << line.str() << "!" << endl;479 DoeLog(0) && (eLog()<< Verbose(0) << "Unable to open output energy file " << line.str() << "!" << endl); 479 480 performCriticalExit(); 480 481 return false; … … 502 503 stringstream line; 503 504 504 Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl;505 DoLog(0) && (Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl); 505 506 line << name << prefix << suffix; 506 507 output.open(line.str().c_str(), ios::out); 507 508 if (output == NULL) { 508 eLog() << Verbose(0) << "Unable to open output matrix file " << line.str() << "!" << endl;509 DoeLog(0) && (eLog()<< Verbose(0) << "Unable to open output matrix file " << line.str() << "!" << endl); 509 510 performCriticalExit(); 510 511 return false; … … 528 529 bool EnergyMatrix::ParseIndices() 529 530 { 530 Log() << Verbose(0) << "Parsing energy indices." << endl;531 DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl); 531 532 Indices = Malloc<int*>(MatrixCounter + 1, "EnergyMatrix::ParseIndices: **Indices"); 532 533 for(int i=MatrixCounter+1;i--;) { … … 587 588 } 588 589 // allocate last plus one matrix 589 Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl;590 DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl); 590 591 Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 591 592 for(int j=0;j<=RowCounter[MatrixCounter];j++) … … 614 615 stringstream line; 615 616 616 Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl;617 DoLog(0) && (Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl); 617 618 Indices = Malloc<int*>(MatrixCounter + 1, "ForceMatrix::ParseIndices: **Indices"); 618 619 line << name << FRAGMENTPREFIX << FORCESFILE; … … 620 621 //Log() << Verbose(0) << "Opening " << line.str() << " ... " << input << endl; 621 622 if (input == NULL) { 622 Log() << Verbose(0) << endl << "Unable to open " << line.str() << ", is the directory correct?" << endl;623 DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << line.str() << ", is the directory correct?" << endl); 623 624 return false; 624 625 } … … 663 664 int j = Indices[ FragmentNr ][l]; 664 665 if (j > RowCounter[MatrixCounter]) { 665 eLog() << Verbose(0) << "Current force index " << j << " is greater than " << RowCounter[MatrixCounter] << "!" << endl;666 DoeLog(0) && (eLog()<< Verbose(0) << "Current force index " << j << " is greater than " << RowCounter[MatrixCounter] << "!" << endl); 666 667 performCriticalExit(); 667 668 return false; … … 699 700 input.open(file.str().c_str(), ios::in); 700 701 if (input == NULL) { 701 Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl;702 DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl); 702 703 return false; 703 704 } … … 723 724 724 725 // allocate last plus one matrix 725 Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl;726 DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl); 726 727 Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 727 728 for(int j=0;j<=RowCounter[MatrixCounter];j++) … … 752 753 stringstream line; 753 754 754 Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl;755 DoLog(0) && (Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl); 755 756 Indices = Malloc<int*>(MatrixCounter + 1, "HessianMatrix::ParseIndices: **Indices"); 756 757 line << name << FRAGMENTPREFIX << FORCESFILE; … … 758 759 //Log() << Verbose(0) << "Opening " << line.str() << " ... " << input << endl; 759 760 if (input == NULL) { 760 Log() << Verbose(0) << endl << "Unable to open " << line.str() << ", is the directory correct?" << endl;761 DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << line.str() << ", is the directory correct?" << endl); 761 762 return false; 762 763 } … … 801 802 int j = Indices[ FragmentNr ][l]; 802 803 if (j > RowCounter[MatrixCounter]) { 803 eLog() << Verbose(0) << "Current hessian index " << j << " is greater than " << RowCounter[MatrixCounter] << ", where i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl;804 DoeLog(0) && (eLog()<< Verbose(0) << "Current hessian index " << j << " is greater than " << RowCounter[MatrixCounter] << ", where i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl); 804 805 performCriticalExit(); 805 806 return false; … … 809 810 int k = Indices[ FragmentNr ][m]; 810 811 if (k > ColumnCounter[MatrixCounter]) { 811 eLog() << Verbose(0) << "Current hessian index " << k << " is greater than " << ColumnCounter[MatrixCounter] << ", where m=" << m << ", j=" << j << ", i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl;812 DoeLog(0) && (eLog()<< Verbose(0) << "Current hessian index " << k << " is greater than " << ColumnCounter[MatrixCounter] << ", where m=" << m << ", j=" << j << ", i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl); 812 813 performCriticalExit(); 813 814 return false; … … 862 863 //Log() << Verbose(0) << "Corresponding row index for " << k << " in CurrentFragment is " << m << "." << endl; 863 864 if (m > RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 864 eLog() << Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current row index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl;865 DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current row index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl); 865 866 performCriticalExit(); 866 867 return false; … … 880 881 //Log() << Verbose(0) << "Corresponding column index for " << l << " in CurrentFragment is " << n << "." << endl; 881 882 if (n > ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 882 eLog() << Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current column index " << n << " is greater than " << ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl;883 DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current column index " << n << " is greater than " << ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl); 883 884 performCriticalExit(); 884 885 return false; … … 929 930 input.open(file.str().c_str(), ios::in); 930 931 if (input == NULL) { 931 Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl;932 DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl); 932 933 return false; 933 934 } … … 951 952 952 953 // allocate last plus one matrix 953 Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl;954 DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl); 954 955 Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 955 956 for(int j=0;j<=RowCounter[MatrixCounter];j++) … … 1006 1007 1007 1008 FragmentCounter = FCounter; 1008 Log() << Verbose(0) << "Parsing key sets." << endl;1009 DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl); 1009 1010 KeySets = Malloc<int*>(FragmentCounter, "KeySetsContainer::ParseKeySets: **KeySets"); 1010 1011 for(int i=FragmentCounter;i--;) … … 1013 1014 input.open(file.str().c_str(), ios::in); 1014 1015 if (input == NULL) { 1015 Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl;1016 DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl); 1016 1017 return false; 1017 1018 } … … 1047 1048 int Counter; 1048 1049 1049 Log() << Verbose(0) << "Creating Fragment terms." << endl;1050 DoLog(0) && (Log() << Verbose(0) << "Creating Fragment terms." << endl); 1050 1051 // scan through all to determine maximum order 1051 1052 Order=0; … … 1058 1059 Order = Counter; 1059 1060 } 1060 Log() << Verbose(0) << "Found Order is " << Order << "." << endl;1061 DoLog(0) && (Log() << Verbose(0) << "Found Order is " << Order << "." << endl); 1061 1062 1062 1063 // scan through all to determine fragments per order … … 1072 1073 } 1073 1074 for(int i=0;i<Order;i++) 1074 Log() << Verbose(0) << "Found No. of Fragments of Order " << i+1 << " is " << FragmentsPerOrder[i] << "." << endl;1075 DoLog(0) && (Log() << Verbose(0) << "Found No. of Fragments of Order " << i+1 << " is " << FragmentsPerOrder[i] << "." << endl); 1075 1076 1076 1077 // scan through all to gather indices to each order set … … 1088 1089 FragmentsPerOrder[Counter-1]++; 1089 1090 } 1090 Log() << Verbose(0) << "Printing OrderSet." << endl;1091 DoLog(0) && (Log() << Verbose(0) << "Printing OrderSet." << endl); 1091 1092 for(int i=0;i<Order;i++) { 1092 1093 for (int j=0;j<FragmentsPerOrder[i];j++) { 1093 Log() << Verbose(0) << " " << OrderSet[i][j];1094 } 1095 Log() << Verbose(0) << endl;1096 } 1097 Log() << Verbose(0) << endl;1094 DoLog(0) && (Log() << Verbose(0) << " " << OrderSet[i][j]); 1095 } 1096 DoLog(0) && (Log() << Verbose(0) << endl); 1097 } 1098 DoLog(0) && (Log() << Verbose(0) << endl); 1098 1099 1099 1100 -
src/periodentafel.cpp
r491876 rc695c9 9 9 #include <iomanip> 10 10 #include <fstream> 11 #include <cstring> 11 12 12 13 #include "element.hpp" … … 48 49 pointer->sort = &pointer->Z; 49 50 if (pointer->Z < 1 && pointer->Z >= MAX_ELEMENTS) 50 Log() << Verbose(0) << "Invalid Z number!\n";51 DoLog(0) && (Log() << Verbose(0) << "Invalid Z number!\n"); 51 52 return add(pointer, end); 52 53 }; … … 103 104 int Z; 104 105 do { 105 Log() << Verbose(0) << "Atomic number Z: ";106 DoLog(0) && (Log() << Verbose(0) << "Atomic number Z: "); 106 107 cin >> Z; 107 108 walker = this->FindElement(Z); // give type … … 117 118 element *walker = NULL; 118 119 int Z = -1; 119 Log() << Verbose(0) << "Atomic number: " << Z << endl;120 DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl); 120 121 cin >> Z; 121 122 walker = FindElement(Z); 122 123 if (walker == NULL) { 123 Log() << Verbose(0) << "Element not found in database, please enter." << endl;124 DoLog(0) && (Log() << Verbose(0) << "Element not found in database, please enter." << endl); 124 125 walker = new element; 125 126 walker->Z = Z; 126 Log() << Verbose(0) << "Mass: " << endl;127 DoLog(0) && (Log() << Verbose(0) << "Mass: " << endl); 127 128 cin >> walker->mass; 128 Log() << Verbose(0) << "Name [max 64 chars]: " << endl;129 DoLog(0) && (Log() << Verbose(0) << "Name [max 64 chars]: " << endl); 129 130 cin >> walker->name; 130 Log() << Verbose(0) << "Short form [max 3 chars]: " << endl;131 DoLog(0) && (Log() << Verbose(0) << "Short form [max 3 chars]: " << endl); 131 132 cin >> walker->symbol; 132 133 periodentafel::AddElement(walker); … … 197 198 infile.getline(header1, MAXSTRINGSIZE); 198 199 infile.getline(header2, MAXSTRINGSIZE); // skip first two header lines 199 Log() << Verbose(0) << "Parsed elements:";200 DoLog(0) && (Log() << Verbose(0) << "Parsed elements:"); 200 201 while (!infile.eof()) { 201 202 element *neues = new element; … … 219 220 //infile >> ws; 220 221 infile >> ws; 221 Log() << Verbose(0) << " " << neues->symbol;222 DoLog(0) && (Log() << Verbose(0) << " " << neues->symbol); 222 223 //neues->Output((ofstream *)&cout); 223 224 if ((neues->Z > 0) && (neues->Z < MAX_ELEMENTS)) 224 225 periodentafel::AddElement(neues); 225 226 else { 226 Log() << Verbose(0) << "Could not parse element: ";227 DoLog(0) && (Log() << Verbose(0) << "Could not parse element: "); 227 228 neues->Output((ofstream *)&cout); 228 229 delete(neues); 229 230 } 230 231 } 231 Log() << Verbose(0) << endl;232 DoLog(0) && (Log() << Verbose(0) << endl); 232 233 infile.close(); 233 234 infile.clear(); … … 313 314 314 315 if (!otherstatus) 315 eLog() << Verbose(2) << "Something went wrong while parsing the other databases!" << endl;316 DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl); 316 317 317 318 return status; -
src/stackclass.hpp
r491876 rc695c9 72 72 return true; 73 73 } else { 74 eLog() << Verbose(1) << "Stack is full, " << "Stack: CurrentLastEntry " << CurrentLastEntry<< "\tCurrentFirstEntry " << CurrentFirstEntry << "\tNextFreeField " << NextFreeField << "\tEntryCount " << EntryCount << "!" << endl;74 DoeLog(1) && (eLog()<< Verbose(1) << "Stack is full, " << "Stack: CurrentLastEntry " << CurrentLastEntry<< "\tCurrentFirstEntry " << CurrentFirstEntry << "\tNextFreeField " << NextFreeField << "\tEntryCount " << EntryCount << "!" << endl); 75 75 return false; 76 76 } … … 87 87 Walker = StackList[CurrentFirstEntry]; 88 88 if (Walker == NULL) 89 eLog() << Verbose(1) << "Stack's field is empty!" << endl;89 DoeLog(1) && (eLog()<< Verbose(1) << "Stack's field is empty!" << endl); 90 90 StackList[CurrentFirstEntry] = NULL; 91 91 if (CurrentFirstEntry != CurrentLastEntry) { // hasn't last item been popped as well? … … 96 96 } 97 97 } else 98 eLog() << Verbose(1) << "Stack is empty!" << endl;98 DoeLog(1) && (eLog()<< Verbose(1) << "Stack is empty!" << endl); 99 99 return Walker; 100 100 }; … … 111 111 StackList[CurrentLastEntry] = NULL; 112 112 if (Walker == NULL) 113 eLog() << Verbose(1) << "Stack's field is empty!" << endl;113 DoeLog(1) && (eLog()<< Verbose(1) << "Stack's field is empty!" << endl); 114 114 NextFreeField = CurrentLastEntry; 115 115 if (CurrentLastEntry != CurrentFirstEntry) // has there been more than one item on stack 116 116 CurrentLastEntry = (CurrentLastEntry + (EntryCount-1)) % EntryCount; // step back from current free field to last (modulo does not work in -1, thus go EntryCount-1 instead) 117 117 } else { 118 eLog() << Verbose(1) << "Stack is empty!" << endl;118 DoeLog(1) && (eLog()<< Verbose(1) << "Stack is empty!" << endl); 119 119 } 120 120 return Walker; … … 130 130 { 131 131 bool found = false; 132 Log() << Verbose(5) << "First " << CurrentFirstEntry<< "\tLast " << CurrentLastEntry<< "\tNext " << NextFreeField<< "\tCount " << EntryCount<< "." << endl;132 DoLog(5) && (Log() << Verbose(5) << "First " << CurrentFirstEntry<< "\tLast " << CurrentLastEntry<< "\tNext " << NextFreeField<< "\tCount " << EntryCount<< "." << endl); 133 133 int i=CurrentFirstEntry; 134 134 if (!IsEmpty()) 135 135 do { 136 136 if (StackList[i] == ptr) { // if item found, remove 137 Log() << Verbose(5) << "Item " << *ptr << " was number " << i << " on stack, removing it." << endl;137 DoLog(5) && (Log() << Verbose(5) << "Item " << *ptr << " was number " << i << " on stack, removing it." << endl); 138 138 found = true; 139 139 StackList[i] = NULL; … … 141 141 if ((found) && (StackList[i] != NULL)) { // means we have to shift (and not the removed item) 142 142 if (i == 0) { // we are down to first item in stack, have to put onto last item 143 Log() << Verbose(5) << "Shifting item 0 to place " << EntryCount-1 << "." << endl;143 DoLog(5) && (Log() << Verbose(5) << "Shifting item 0 to place " << EntryCount-1 << "." << endl); 144 144 StackList[EntryCount-1] = StackList[0]; 145 145 } else { 146 Log() << Verbose(5) << "Shifting item " << i << " to place " << i-1 << "." << endl;146 DoLog(5) && (Log() << Verbose(5) << "Shifting item " << i << " to place " << i-1 << "." << endl); 147 147 StackList[i-1] = StackList[i]; 148 148 } … … 151 151 } while (i!=NextFreeField); 152 152 else 153 eLog() << Verbose(1) << "Stack is already empty!" << endl;153 DoeLog(1) && (eLog()<< Verbose(1) << "Stack is already empty!" << endl); 154 154 if (found) { 155 155 NextFreeField = CurrentLastEntry; -
src/tesselation.cpp
r491876 rc695c9 7 7 8 8 #include <fstream> 9 #include <assert.h> 9 10 10 11 #include "helpers.hpp" … … 14 15 #include "tesselation.hpp" 15 16 #include "tesselationhelpers.hpp" 17 #include "triangleintersectionlist.hpp" 16 18 #include "vector.hpp" 17 19 #include "verbose.hpp" … … 24 26 */ 25 27 BoundaryPointSet::BoundaryPointSet() : 26 LinesCount(0), 27 value(0.), 28 Nr(-1) 29 { 30 Info FunctionInfo(__func__); 31 Log() << Verbose(1) << "Adding noname." << endl; 32 }; 28 LinesCount(0), value(0.), Nr(-1) 29 { 30 Info FunctionInfo(__func__); 31 DoLog(1) && (Log() << Verbose(1) << "Adding noname." << endl); 32 } 33 ; 33 34 34 35 /** Constructor of BoundaryPointSet with Tesselpoint. 35 36 * \param *Walker TesselPoint this boundary point represents 36 37 */ 37 BoundaryPointSet::BoundaryPointSet(TesselPoint * Walker) : 38 LinesCount(0), 39 node(Walker), 40 value(0.), 41 Nr(Walker->nr) 42 { 43 Info FunctionInfo(__func__); 44 Log() << Verbose(1) << "Adding Node " << *Walker << endl; 45 }; 38 BoundaryPointSet::BoundaryPointSet(TesselPoint * const Walker) : 39 LinesCount(0), node(Walker), value(0.), Nr(Walker->nr) 40 { 41 Info FunctionInfo(__func__); 42 DoLog(1) && (Log() << Verbose(1) << "Adding Node " << *Walker << endl); 43 } 44 ; 46 45 47 46 /** Destructor of BoundaryPointSet. … … 51 50 BoundaryPointSet::~BoundaryPointSet() 52 51 { 53 52 Info FunctionInfo(__func__); 54 53 //Log() << Verbose(0) << "Erasing point nr. " << Nr << "." << endl; 55 54 if (!lines.empty()) 56 eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some lines." << endl;55 DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some lines." << endl); 57 56 node = NULL; 58 }; 57 } 58 ; 59 59 60 60 /** Add a line to the LineMap of this point. 61 61 * \param *line line to add 62 62 */ 63 void BoundaryPointSet::AddLine(class BoundaryLineSet *line) 64 { 65 Info FunctionInfo(__func__); 66 Log() << Verbose(1) << "Adding " << *this << " to line " << *line << "." 67 << endl; 68 if (line->endpoints[0] == this) 69 { 70 lines.insert(LinePair(line->endpoints[1]->Nr, line)); 71 } 72 else 73 { 74 lines.insert(LinePair(line->endpoints[0]->Nr, line)); 75 } 63 void BoundaryPointSet::AddLine(BoundaryLineSet * const line) 64 { 65 Info FunctionInfo(__func__); 66 DoLog(1) && (Log() << Verbose(1) << "Adding " << *this << " to line " << *line << "." << endl); 67 if (line->endpoints[0] == this) { 68 lines.insert(LinePair(line->endpoints[1]->Nr, line)); 69 } else { 70 lines.insert(LinePair(line->endpoints[0]->Nr, line)); 71 } 76 72 LinesCount++; 77 }; 73 } 74 ; 78 75 79 76 /** output operator for BoundaryPointSet. … … 93 90 */ 94 91 BoundaryLineSet::BoundaryLineSet() : 95 96 { 97 92 Nr(-1) 93 { 94 Info FunctionInfo(__func__); 98 95 for (int i = 0; i < 2; i++) 99 96 endpoints[i] = NULL; 100 }; 97 } 98 ; 101 99 102 100 /** Constructor of BoundaryLineSet with two endpoints. … … 105 103 * \param number number of the list 106 104 */ 107 BoundaryLineSet::BoundaryLineSet( class BoundaryPointSet *Point[2], const int number)108 { 109 105 BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point[2], const int number) 106 { 107 Info FunctionInfo(__func__); 110 108 // set number 111 109 Nr = number; … … 118 116 skipped = false; 119 117 // clear triangles list 120 Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl; 121 }; 118 DoLog(0) && (Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl); 119 } 120 ; 121 122 /** Constructor of BoundaryLineSet with two endpoints. 123 * Adds line automatically to each endpoints' LineMap 124 * \param *Point1 first boundary point 125 * \param *Point2 second boundary point 126 * \param number number of the list 127 */ 128 BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number) 129 { 130 Info FunctionInfo(__func__); 131 // set number 132 Nr = number; 133 // set endpoints in ascending order 134 SetEndpointsOrdered(endpoints, Point1, Point2); 135 // add this line to the hash maps of both endpoints 136 Point1->AddLine(this); //Taken out, to check whether we can avoid unwanted double adding. 137 Point2->AddLine(this); // 138 // set skipped to false 139 skipped = false; 140 // clear triangles list 141 DoLog(0) && (Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl); 142 } 143 ; 122 144 123 145 /** Destructor for BoundaryLineSet. … … 127 149 BoundaryLineSet::~BoundaryLineSet() 128 150 { 129 151 Info FunctionInfo(__func__); 130 152 int Numbers[2]; 131 153 … … 158 180 //Log() << Verbose(0) << *endpoints[i] << " has no more lines it's attached to, erasing." << endl; 159 181 if (endpoints[i] != NULL) { 160 delete (endpoints[i]);182 delete (endpoints[i]); 161 183 endpoints[i] = NULL; 162 184 } … … 165 187 } 166 188 if (!triangles.empty()) 167 eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some triangles." << endl; 168 }; 189 DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some triangles." << endl); 190 } 191 ; 169 192 170 193 /** Add triangle to TriangleMap of this boundary line. 171 194 * \param *triangle to add 172 195 */ 173 void BoundaryLineSet::AddTriangle( class BoundaryTriangleSet *triangle)174 { 175 176 Log() << Verbose(0) << "Add " << triangle->Nr << " to line " << *this << "." << endl;196 void BoundaryLineSet::AddTriangle(BoundaryTriangleSet * const triangle) 197 { 198 Info FunctionInfo(__func__); 199 DoLog(0) && (Log() << Verbose(0) << "Add " << triangle->Nr << " to line " << *this << "." << endl); 177 200 triangles.insert(TrianglePair(triangle->Nr, triangle)); 178 }; 201 } 202 ; 179 203 180 204 /** Checks whether we have a common endpoint with given \a *line. … … 182 206 * \return true - common endpoint present, false - not connected 183 207 */ 184 bool BoundaryLineSet::IsConnectedTo(c lass BoundaryLineSet *line)185 { 186 208 bool BoundaryLineSet::IsConnectedTo(const BoundaryLineSet * const line) const 209 { 210 Info FunctionInfo(__func__); 187 211 if ((endpoints[0] == line->endpoints[0]) || (endpoints[1] == line->endpoints[0]) || (endpoints[0] == line->endpoints[1]) || (endpoints[1] == line->endpoints[1])) 188 212 return true; 189 213 else 190 214 return false; 191 }; 215 } 216 ; 192 217 193 218 /** Checks whether the adjacent triangles of a baseline are convex or not. … … 197 222 * \return true - triangles are convex, false - concave or less than two triangles connected 198 223 */ 199 bool BoundaryLineSet::CheckConvexityCriterion() 200 { 201 224 bool BoundaryLineSet::CheckConvexityCriterion() const 225 { 226 Info FunctionInfo(__func__); 202 227 Vector BaseLineCenter, BaseLineNormal, BaseLine, helper[2], NormalCheck; 203 228 // get the two triangles 204 229 if (triangles.size() != 2) { 205 eLog() << Verbose(0) << "Baseline " << *this << " is connected to less than two triangles, Tesselation incomplete!" << endl;230 DoeLog(0) && (eLog() << Verbose(0) << "Baseline " << *this << " is connected to less than two triangles, Tesselation incomplete!" << endl); 206 231 return true; 207 232 } … … 211 236 BaseLineCenter.CopyVector(endpoints[0]->node->node); 212 237 BaseLineCenter.AddVector(endpoints[1]->node->node); 213 BaseLineCenter.Scale(1. /2.);238 BaseLineCenter.Scale(1. / 2.); 214 239 BaseLine.CopyVector(endpoints[0]->node->node); 215 240 BaseLine.SubtractVector(endpoints[1]->node->node); … … 219 244 NormalCheck.Zero(); 220 245 double sign = -1.; 221 int i =0;246 int i = 0; 222 247 class BoundaryPointSet *node = NULL; 223 for (TriangleMap::iterator runner = triangles.begin(); runner != triangles.end(); runner++) {248 for (TriangleMap::const_iterator runner = triangles.begin(); runner != triangles.end(); runner++) { 224 249 //Log() << Verbose(0) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl; 225 250 NormalCheck.AddVector(&runner->second->NormalVector); … … 227 252 sign = -sign; 228 253 if (runner->second->NormalVector.NormSquared() > MYEPSILON) 229 BaseLineNormal.CopyVector(&runner->second->NormalVector); 254 BaseLineNormal.CopyVector(&runner->second->NormalVector); // yes, copy second on top of first 230 255 else { 231 eLog() << Verbose(0) << "Triangle " << *runner->second << " has zero normal vector!" << endl;256 DoeLog(0) && (eLog() << Verbose(0) << "Triangle " << *runner->second << " has zero normal vector!" << endl); 232 257 } 233 258 node = runner->second->GetThirdEndpoint(this); … … 236 261 helper[i].CopyVector(node->node->node); 237 262 helper[i].SubtractVector(&BaseLineCenter); 238 helper[i].MakeNormalVector(&BaseLine); 263 helper[i].MakeNormalVector(&BaseLine); // we want to compare the triangle's heights' angles! 239 264 //Log() << Verbose(0) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl; 240 265 i++; 241 266 } else { 242 eLog() << Verbose(1) << "I cannot find third node in triangle, something's wrong." << endl;267 DoeLog(1) && (eLog() << Verbose(1) << "I cannot find third node in triangle, something's wrong." << endl); 243 268 return true; 244 269 } … … 246 271 //Log() << Verbose(0) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl; 247 272 if (NormalCheck.NormSquared() < MYEPSILON) { 248 Log() << Verbose(0) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl;273 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl); 249 274 return true; 250 275 } … … 252 277 double angle = GetAngle(helper[0], helper[1], BaseLineNormal); 253 278 if ((angle - M_PI) > -MYEPSILON) { 254 Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl;279 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl); 255 280 return true; 256 281 } else { 257 Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl;282 DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl); 258 283 return false; 259 284 } … … 264 289 * \return true - point is of the line, false - is not 265 290 */ 266 bool BoundaryLineSet::ContainsBoundaryPoint(c lass BoundaryPointSet *point)267 { 268 269 for (int i=0;i<2;i++)291 bool BoundaryLineSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const 292 { 293 Info FunctionInfo(__func__); 294 for (int i = 0; i < 2; i++) 270 295 if (point == endpoints[i]) 271 296 return true; 272 297 return false; 273 }; 298 } 299 ; 274 300 275 301 /** Returns other endpoint of the line. … … 277 303 * \return NULL - if endpoint not contained in BoundaryLineSet, or pointer to BoundaryPointSet otherwise 278 304 */ 279 class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(c lass BoundaryPointSet *point)280 { 281 305 class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(const BoundaryPointSet * const point) const 306 { 307 Info FunctionInfo(__func__); 282 308 if (endpoints[0] == point) 283 309 return endpoints[1]; … … 286 312 else 287 313 return NULL; 288 }; 314 } 315 ; 289 316 290 317 /** output operator for BoundaryLineSet. … … 292 319 * \param &a boundary line 293 320 */ 294 ostream & operator <<(ostream &ost, const 321 ostream & operator <<(ostream &ost, const BoundaryLineSet &a) 295 322 { 296 323 ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << "," << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "]"; 297 324 return ost; 298 }; 325 } 326 ; 299 327 300 328 // ======================================== Triangles on Boundary ================================= … … 305 333 Nr(-1) 306 334 { 307 308 for (int i = 0; i < 3; i++) 309 {310 endpoints[i] = NULL;311 lines[i] = NULL;312 313 };335 Info FunctionInfo(__func__); 336 for (int i = 0; i < 3; i++) { 337 endpoints[i] = NULL; 338 lines[i] = NULL; 339 } 340 } 341 ; 314 342 315 343 /** Constructor for BoundaryTriangleSet with three lines. … … 317 345 * \param number number of triangle 318 346 */ 319 BoundaryTriangleSet::BoundaryTriangleSet(class BoundaryLineSet * line[3],int number) :347 BoundaryTriangleSet::BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number) : 320 348 Nr(number) 321 349 { 322 350 Info FunctionInfo(__func__); 323 351 // set number 324 352 // set lines … … 332 360 // for all three lines 333 361 for (int j = 0; j < 2; j++) { // for both endpoints 334 OrderMap.insert(pair<int, class BoundaryPointSet *> ( 335 line[i]->endpoints[j]->Nr, line[i]->endpoints[j])); 362 OrderMap.insert(pair<int, class BoundaryPointSet *> (line[i]->endpoints[j]->Nr, line[i]->endpoints[j])); 336 363 // and we don't care whether insertion fails 337 364 } 338 365 // set endpoints 339 366 int Counter = 0; 340 Log() << Verbose(0) << "New triangle " << Nr << " with end points: " << endl;367 DoLog(0) && (Log() << Verbose(0) << "New triangle " << Nr << " with end points: " << endl); 341 368 for (PointMap::iterator runner = OrderMap.begin(); runner != OrderMap.end(); runner++) { 342 369 endpoints[Counter] = runner->second; 343 Log() << Verbose(0) << " " << *endpoints[Counter] << endl;370 DoLog(0) && (Log() << Verbose(0) << " " << *endpoints[Counter] << endl); 344 371 Counter++; 345 372 } 346 373 if (Counter < 3) { 347 eLog() << Verbose(0) << "We have a triangle with only two distinct endpoints!" << endl;374 DoeLog(0) && (eLog() << Verbose(0) << "We have a triangle with only two distinct endpoints!" << endl); 348 375 performCriticalExit(); 349 376 } 350 }; 377 } 378 ; 351 379 352 380 /** Destructor of BoundaryTriangleSet. … … 356 384 BoundaryTriangleSet::~BoundaryTriangleSet() 357 385 { 358 386 Info FunctionInfo(__func__); 359 387 for (int i = 0; i < 3; i++) { 360 388 if (lines[i] != NULL) { … … 363 391 } 364 392 if (lines[i]->triangles.empty()) { 365 366 367 393 //Log() << Verbose(0) << *lines[i] << " is no more attached to any triangle, erasing." << endl; 394 delete (lines[i]); 395 lines[i] = NULL; 368 396 } 369 397 } 370 398 } 371 399 //Log() << Verbose(0) << "Erasing triangle Nr." << Nr << " itself." << endl; 372 }; 400 } 401 ; 373 402 374 403 /** Calculates the normal vector for this triangle. … … 376 405 * \param &OtherVector direction vector to make normal vector unique. 377 406 */ 378 void BoundaryTriangleSet::GetNormalVector( Vector &OtherVector)379 { 380 407 void BoundaryTriangleSet::GetNormalVector(const Vector &OtherVector) 408 { 409 Info FunctionInfo(__func__); 381 410 // get normal vector 382 411 NormalVector.MakeNormalVector(endpoints[0]->node->node, endpoints[1]->node->node, endpoints[2]->node->node); … … 385 414 if (NormalVector.ScalarProduct(&OtherVector) > 0.) 386 415 NormalVector.Scale(-1.); 387 Log() << Verbose(1) << "Normal Vector is " << NormalVector << "." << endl; 388 }; 389 390 /** Finds the point on the triangle \a *BTS the line defined by \a *MolCenter and \a *x crosses through. 416 DoLog(1) && (Log() << Verbose(1) << "Normal Vector is " << NormalVector << "." << endl); 417 } 418 ; 419 420 /** Finds the point on the triangle \a *BTS through which the line defined by \a *MolCenter and \a *x crosses. 391 421 * We call Vector::GetIntersectionWithPlane() to receive the intersection point with the plane 392 * Th is we test if it's really on the plane and whether it's inside the triangle on the plane or not.422 * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not. 393 423 * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line 394 424 * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between … … 400 430 * \return true - \a *Intersection contains intersection on plane defined by triangle, false - zero vector if outside of triangle. 401 431 */ 402 bool BoundaryTriangleSet::GetIntersectionInsideTriangle( Vector *MolCenter, Vector *x, Vector *Intersection)403 { 404 432 bool BoundaryTriangleSet::GetIntersectionInsideTriangle(const Vector * const MolCenter, const Vector * const x, Vector * const Intersection) const 433 { 434 Info FunctionInfo(__func__); 405 435 Vector CrossPoint; 406 436 Vector helper; 407 437 408 438 if (!Intersection->GetIntersectionWithPlane(&NormalVector, endpoints[0]->node->node, MolCenter, x)) { 409 eLog() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl;439 DoeLog(1) && (eLog() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl); 410 440 return false; 411 441 } 412 442 443 DoLog(1) && (Log() << Verbose(1) << "INFO: Triangle is " << *this << "." << endl); 444 DoLog(1) && (Log() << Verbose(1) << "INFO: Line is from " << *MolCenter << " to " << *x << "." << endl); 445 DoLog(1) && (Log() << Verbose(1) << "INFO: Intersection is " << *Intersection << "." << endl); 446 447 if (Intersection->DistanceSquared(endpoints[0]->node->node) < MYEPSILON) { 448 DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl); 449 return true; 450 } else if (Intersection->DistanceSquared(endpoints[1]->node->node) < MYEPSILON) { 451 DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with second endpoint." << endl); 452 return true; 453 } else if (Intersection->DistanceSquared(endpoints[2]->node->node) < MYEPSILON) { 454 DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with third endpoint." << endl); 455 return true; 456 } 413 457 // Calculate cross point between one baseline and the line from the third endpoint to intersection 414 int i =0;458 int i = 0; 415 459 do { 416 if (CrossPoint.GetIntersectionOfTwoLinesOnPlane(endpoints[i%3]->node->node, endpoints[(i+1)%3]->node->node, endpoints[(i+2)%3]->node->node, Intersection, &NormalVector)) { 417 helper.CopyVector(endpoints[(i+1)%3]->node->node); 418 helper.SubtractVector(endpoints[i%3]->node->node); 419 } else 460 if (CrossPoint.GetIntersectionOfTwoLinesOnPlane(endpoints[i % 3]->node->node, endpoints[(i + 1) % 3]->node->node, endpoints[(i + 2) % 3]->node->node, Intersection, &NormalVector)) { 461 helper.CopyVector(endpoints[(i + 1) % 3]->node->node); 462 helper.SubtractVector(endpoints[i % 3]->node->node); 463 CrossPoint.SubtractVector(endpoints[i % 3]->node->node); // cross point was returned as absolute vector 464 const double s = CrossPoint.ScalarProduct(&helper) / helper.NormSquared(); 465 DoLog(1) && (Log() << Verbose(1) << "INFO: Factor s is " << s << "." << endl); 466 if ((s < -MYEPSILON) || ((s - 1.) > MYEPSILON)) { 467 DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << "outside of triangle." << endl); 468 i = 4; 469 break; 470 } 420 471 i++; 421 if (i>2)472 } else 422 473 break; 423 } while (CrossPoint.NormSquared() < MYEPSILON); 424 if (i==3) { 425 eLog() << Verbose(0) << "Could not find any cross points, something's utterly wrong here!" << endl; 426 } 427 CrossPoint.SubtractVector(endpoints[i%3]->node->node); // cross point was returned as absolute vector 428 429 // check whether intersection is inside or not by comparing length of intersection and length of cross point 430 if ((CrossPoint.NormSquared() - helper.NormSquared()) < MYEPSILON) { // inside 474 } while (i < 3); 475 if (i == 3) { 476 DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " inside of triangle." << endl); 431 477 return true; 432 } else { // outside!433 Intersection->Zero();478 } else { 479 DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " outside of triangle." << endl); 434 480 return false; 435 481 } 436 }; 482 } 483 ; 484 485 /** Finds the point on the triangle to the point \a *x. 486 * We call Vector::GetIntersectionWithPlane() with \a * and the center of the triangle to receive an intersection point. 487 * Then we check the in-plane part (the part projected down onto plane). We check whether it crosses one of the 488 * boundary lines. If it does, we return this intersection as closest point, otherwise the projected point down. 489 * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not. 490 * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line 491 * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between 492 * the first two basepoints) or not. 493 * \param *x point 494 * \param *ClosestPoint desired closest point inside triangle to \a *x, is absolute vector 495 * \return Distance squared between \a *x and closest point inside triangle 496 */ 497 double BoundaryTriangleSet::GetClosestPointInsideTriangle(const Vector * const x, Vector * const ClosestPoint) const 498 { 499 Info FunctionInfo(__func__); 500 Vector Direction; 501 502 // 1. get intersection with plane 503 DoLog(1) && (Log() << Verbose(1) << "INFO: Looking for closest point of triangle " << *this << " to " << *x << "." << endl); 504 GetCenter(&Direction); 505 if (!ClosestPoint->GetIntersectionWithPlane(&NormalVector, endpoints[0]->node->node, x, &Direction)) { 506 ClosestPoint->CopyVector(x); 507 } 508 509 // 2. Calculate in plane part of line (x, intersection) 510 Vector InPlane; 511 InPlane.CopyVector(x); 512 InPlane.SubtractVector(ClosestPoint); // points from plane intersection to straight-down point 513 InPlane.ProjectOntoPlane(&NormalVector); 514 InPlane.AddVector(ClosestPoint); 515 516 DoLog(2) && (Log() << Verbose(2) << "INFO: Triangle is " << *this << "." << endl); 517 DoLog(2) && (Log() << Verbose(2) << "INFO: Line is from " << Direction << " to " << *x << "." << endl); 518 DoLog(2) && (Log() << Verbose(2) << "INFO: In-plane part is " << InPlane << "." << endl); 519 520 // Calculate cross point between one baseline and the desired point such that distance is shortest 521 double ShortestDistance = -1.; 522 bool InsideFlag = false; 523 Vector CrossDirection[3]; 524 Vector CrossPoint[3]; 525 Vector helper; 526 for (int i = 0; i < 3; i++) { 527 // treat direction of line as normal of a (cut)plane and the desired point x as the plane offset, the intersect line with point 528 Direction.CopyVector(endpoints[(i + 1) % 3]->node->node); 529 Direction.SubtractVector(endpoints[i % 3]->node->node); 530 // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal); 531 CrossPoint[i].GetIntersectionWithPlane(&Direction, &InPlane, endpoints[i % 3]->node->node, endpoints[(i + 1) % 3]->node->node); 532 CrossDirection[i].CopyVector(&CrossPoint[i]); 533 CrossDirection[i].SubtractVector(&InPlane); 534 CrossPoint[i].SubtractVector(endpoints[i % 3]->node->node); // cross point was returned as absolute vector 535 const double s = CrossPoint[i].ScalarProduct(&Direction) / Direction.NormSquared(); 536 DoLog(2) && (Log() << Verbose(2) << "INFO: Factor s is " << s << "." << endl); 537 if ((s >= -MYEPSILON) && ((s - 1.) <= MYEPSILON)) { 538 CrossPoint[i].AddVector(endpoints[i % 3]->node->node); // make cross point absolute again 539 DoLog(2) && (Log() << Verbose(2) << "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting BoundaryLine between " << *endpoints[i % 3]->node->node << " and " << *endpoints[(i + 1) % 3]->node->node << "." << endl); 540 const double distance = CrossPoint[i].DistanceSquared(x); 541 if ((ShortestDistance < 0.) || (ShortestDistance > distance)) { 542 ShortestDistance = distance; 543 ClosestPoint->CopyVector(&CrossPoint[i]); 544 } 545 } else 546 CrossPoint[i].Zero(); 547 } 548 InsideFlag = true; 549 for (int i = 0; i < 3; i++) { 550 const double sign = CrossDirection[i].ScalarProduct(&CrossDirection[(i + 1) % 3]); 551 const double othersign = CrossDirection[i].ScalarProduct(&CrossDirection[(i + 2) % 3]); 552 ; 553 if ((sign > -MYEPSILON) && (othersign > -MYEPSILON)) // have different sign 554 InsideFlag = false; 555 } 556 if (InsideFlag) { 557 ClosestPoint->CopyVector(&InPlane); 558 ShortestDistance = InPlane.DistanceSquared(x); 559 } else { // also check endnodes 560 for (int i = 0; i < 3; i++) { 561 const double distance = x->DistanceSquared(endpoints[i]->node->node); 562 if ((ShortestDistance < 0.) || (ShortestDistance > distance)) { 563 ShortestDistance = distance; 564 ClosestPoint->CopyVector(endpoints[i]->node->node); 565 } 566 } 567 } 568 DoLog(1) && (Log() << Verbose(1) << "INFO: Closest Point is " << *ClosestPoint << " with shortest squared distance is " << ShortestDistance << "." << endl); 569 return ShortestDistance; 570 } 571 ; 437 572 438 573 /** Checks whether lines is any of the three boundary lines this triangle contains. … … 440 575 * \return true - line is of the triangle, false - is not 441 576 */ 442 bool BoundaryTriangleSet::ContainsBoundaryLine(c lass BoundaryLineSet *line)443 { 444 445 for (int i=0;i<3;i++)577 bool BoundaryTriangleSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const 578 { 579 Info FunctionInfo(__func__); 580 for (int i = 0; i < 3; i++) 446 581 if (line == lines[i]) 447 582 return true; 448 583 return false; 449 }; 584 } 585 ; 450 586 451 587 /** Checks whether point is any of the three endpoints this triangle contains. … … 453 589 * \return true - point is of the triangle, false - is not 454 590 */ 455 bool BoundaryTriangleSet::ContainsBoundaryPoint(c lass BoundaryPointSet *point)456 { 457 458 for (int i=0;i<3;i++)591 bool BoundaryTriangleSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const 592 { 593 Info FunctionInfo(__func__); 594 for (int i = 0; i < 3; i++) 459 595 if (point == endpoints[i]) 460 596 return true; 461 597 return false; 462 }; 598 } 599 ; 463 600 464 601 /** Checks whether point is any of the three endpoints this triangle contains. … … 466 603 * \return true - point is of the triangle, false - is not 467 604 */ 468 bool BoundaryTriangleSet::ContainsBoundaryPoint(c lass TesselPoint *point)469 { 470 471 for (int i=0;i<3;i++)605 bool BoundaryTriangleSet::ContainsBoundaryPoint(const TesselPoint * const point) const 606 { 607 Info FunctionInfo(__func__); 608 for (int i = 0; i < 3; i++) 472 609 if (point == endpoints[i]->node) 473 610 return true; 474 611 return false; 475 }; 612 } 613 ; 476 614 477 615 /** Checks whether three given \a *Points coincide with triangle's endpoints. … … 479 617 * \return true - is the very triangle, false - is not 480 618 */ 481 bool BoundaryTriangleSet::IsPresentTupel(class BoundaryPointSet *Points[3]) 482 { 483 Info FunctionInfo(__func__); 484 return (((endpoints[0] == Points[0]) 485 || (endpoints[0] == Points[1]) 486 || (endpoints[0] == Points[2]) 487 ) && ( 488 (endpoints[1] == Points[0]) 489 || (endpoints[1] == Points[1]) 490 || (endpoints[1] == Points[2]) 491 ) && ( 492 (endpoints[2] == Points[0]) 493 || (endpoints[2] == Points[1]) 494 || (endpoints[2] == Points[2]) 495 496 )); 497 }; 619 bool BoundaryTriangleSet::IsPresentTupel(const BoundaryPointSet * const Points[3]) const 620 { 621 Info FunctionInfo(__func__); 622 DoLog(1) && (Log() << Verbose(1) << "INFO: Checking " << Points[0] << "," << Points[1] << "," << Points[2] << " against " << endpoints[0] << "," << endpoints[1] << "," << endpoints[2] << "." << endl); 623 return (((endpoints[0] == Points[0]) || (endpoints[0] == Points[1]) || (endpoints[0] == Points[2])) && ((endpoints[1] == Points[0]) || (endpoints[1] == Points[1]) || (endpoints[1] == Points[2])) && ((endpoints[2] == Points[0]) || (endpoints[2] == Points[1]) || (endpoints[2] == Points[2]) 624 625 )); 626 } 627 ; 498 628 499 629 /** Checks whether three given \a *Points coincide with triangle's endpoints. … … 501 631 * \return true - is the very triangle, false - is not 502 632 */ 503 bool BoundaryTriangleSet::IsPresentTupel(class BoundaryTriangleSet *T) 504 { 505 Info FunctionInfo(__func__); 506 return (((endpoints[0] == T->endpoints[0]) 507 || (endpoints[0] == T->endpoints[1]) 508 || (endpoints[0] == T->endpoints[2]) 509 ) && ( 510 (endpoints[1] == T->endpoints[0]) 511 || (endpoints[1] == T->endpoints[1]) 512 || (endpoints[1] == T->endpoints[2]) 513 ) && ( 514 (endpoints[2] == T->endpoints[0]) 515 || (endpoints[2] == T->endpoints[1]) 516 || (endpoints[2] == T->endpoints[2]) 517 518 )); 519 }; 633 bool BoundaryTriangleSet::IsPresentTupel(const BoundaryTriangleSet * const T) const 634 { 635 Info FunctionInfo(__func__); 636 return (((endpoints[0] == T->endpoints[0]) || (endpoints[0] == T->endpoints[1]) || (endpoints[0] == T->endpoints[2])) && ((endpoints[1] == T->endpoints[0]) || (endpoints[1] == T->endpoints[1]) || (endpoints[1] == T->endpoints[2])) && ((endpoints[2] == T->endpoints[0]) || (endpoints[2] == T->endpoints[1]) || (endpoints[2] == T->endpoints[2]) 637 638 )); 639 } 640 ; 520 641 521 642 /** Returns the endpoint which is not contained in the given \a *line. … … 523 644 * \return pointer third endpoint or NULL if line does not belong to triangle. 524 645 */ 525 class BoundaryPointSet *BoundaryTriangleSet::GetThirdEndpoint(c lass BoundaryLineSet *line)526 { 527 646 class BoundaryPointSet *BoundaryTriangleSet::GetThirdEndpoint(const BoundaryLineSet * const line) const 647 { 648 Info FunctionInfo(__func__); 528 649 // sanity check 529 650 if (!ContainsBoundaryLine(line)) 530 651 return NULL; 531 for (int i=0;i<3;i++)652 for (int i = 0; i < 3; i++) 532 653 if (!line->ContainsBoundaryPoint(endpoints[i])) 533 654 return endpoints[i]; 534 655 // actually, that' impossible :) 535 656 return NULL; 536 }; 657 } 658 ; 537 659 538 660 /** Calculates the center point of the triangle. … … 540 662 * \param *center central point on return. 541 663 */ 542 void BoundaryTriangleSet::GetCenter(Vector * center)543 { 544 664 void BoundaryTriangleSet::GetCenter(Vector * const center) const 665 { 666 Info FunctionInfo(__func__); 545 667 center->Zero(); 546 for (int i=0;i<3;i++)668 for (int i = 0; i < 3; i++) 547 669 center->AddVector(endpoints[i]->node->node); 548 center->Scale(1./3.); 670 center->Scale(1. / 3.); 671 DoLog(1) && (Log() << Verbose(1) << "INFO: Center is at " << *center << "." << endl); 549 672 } 550 673 … … 556 679 { 557 680 ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << "," << a.endpoints[1]->node->Name << "," << a.endpoints[2]->node->Name << "]"; 558 // ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << ","559 // << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "," << a.endpoints[2]->node->Name << " at " << *a.endpoints[2]->node->node << "]";681 // ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << "," 682 // << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "," << a.endpoints[2]->node->Name << " at " << *a.endpoints[2]->node->node << "]"; 560 683 return ost; 561 }; 684 } 685 ; 686 687 // ======================================== Polygons on Boundary ================================= 688 689 /** Constructor for BoundaryPolygonSet. 690 */ 691 BoundaryPolygonSet::BoundaryPolygonSet() : 692 Nr(-1) 693 { 694 Info FunctionInfo(__func__); 695 } 696 ; 697 698 /** Destructor of BoundaryPolygonSet. 699 * Just clears endpoints. 700 * \note When removing triangles from a class Tesselation, use RemoveTesselationTriangle() 701 */ 702 BoundaryPolygonSet::~BoundaryPolygonSet() 703 { 704 Info FunctionInfo(__func__); 705 endpoints.clear(); 706 DoLog(1) && (Log() << Verbose(1) << "Erasing polygon Nr." << Nr << " itself." << endl); 707 } 708 ; 709 710 /** Calculates the normal vector for this triangle. 711 * Is made unique by comparison with \a OtherVector to point in the other direction. 712 * \param &OtherVector direction vector to make normal vector unique. 713 * \return allocated vector in normal direction 714 */ 715 Vector * BoundaryPolygonSet::GetNormalVector(const Vector &OtherVector) const 716 { 717 Info FunctionInfo(__func__); 718 // get normal vector 719 Vector TemporaryNormal; 720 Vector *TotalNormal = new Vector; 721 PointSet::const_iterator Runner[3]; 722 for (int i = 0; i < 3; i++) { 723 Runner[i] = endpoints.begin(); 724 for (int j = 0; j < i; j++) { // go as much further 725 Runner[i]++; 726 if (Runner[i] == endpoints.end()) { 727 DoeLog(0) && (eLog() << Verbose(0) << "There are less than three endpoints in the polygon!" << endl); 728 performCriticalExit(); 729 } 730 } 731 } 732 TotalNormal->Zero(); 733 int counter = 0; 734 for (; Runner[2] != endpoints.end();) { 735 TemporaryNormal.MakeNormalVector((*Runner[0])->node->node, (*Runner[1])->node->node, (*Runner[2])->node->node); 736 for (int i = 0; i < 3; i++) // increase each of them 737 Runner[i]++; 738 TotalNormal->AddVector(&TemporaryNormal); 739 } 740 TotalNormal->Scale(1. / (double) counter); 741 742 // make it always point inward (any offset vector onto plane projected onto normal vector suffices) 743 if (TotalNormal->ScalarProduct(&OtherVector) > 0.) 744 TotalNormal->Scale(-1.); 745 DoLog(1) && (Log() << Verbose(1) << "Normal Vector is " << *TotalNormal << "." << endl); 746 747 return TotalNormal; 748 } 749 ; 750 751 /** Calculates the center point of the triangle. 752 * Is third of the sum of all endpoints. 753 * \param *center central point on return. 754 */ 755 void BoundaryPolygonSet::GetCenter(Vector * const center) const 756 { 757 Info FunctionInfo(__func__); 758 center->Zero(); 759 int counter = 0; 760 for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) { 761 center->AddVector((*Runner)->node->node); 762 counter++; 763 } 764 center->Scale(1. / (double) counter); 765 DoLog(1) && (Log() << Verbose(1) << "Center is at " << *center << "." << endl); 766 } 767 768 /** Checks whether the polygons contains all three endpoints of the triangle. 769 * \param *triangle triangle to test 770 * \return true - triangle is contained polygon, false - is not 771 */ 772 bool BoundaryPolygonSet::ContainsBoundaryTriangle(const BoundaryTriangleSet * const triangle) const 773 { 774 Info FunctionInfo(__func__); 775 return ContainsPresentTupel(triangle->endpoints, 3); 776 } 777 ; 778 779 /** Checks whether the polygons contains both endpoints of the line. 780 * \param *line line to test 781 * \return true - line is of the triangle, false - is not 782 */ 783 bool BoundaryPolygonSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const 784 { 785 Info FunctionInfo(__func__); 786 return ContainsPresentTupel(line->endpoints, 2); 787 } 788 ; 789 790 /** Checks whether point is any of the three endpoints this triangle contains. 791 * \param *point point to test 792 * \return true - point is of the triangle, false - is not 793 */ 794 bool BoundaryPolygonSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const 795 { 796 Info FunctionInfo(__func__); 797 for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) { 798 DoLog(0) && (Log() << Verbose(0) << "Checking against " << **Runner << endl); 799 if (point == (*Runner)) { 800 DoLog(0) && (Log() << Verbose(0) << " Contained." << endl); 801 return true; 802 } 803 } 804 DoLog(0) && (Log() << Verbose(0) << " Not contained." << endl); 805 return false; 806 } 807 ; 808 809 /** Checks whether point is any of the three endpoints this triangle contains. 810 * \param *point TesselPoint to test 811 * \return true - point is of the triangle, false - is not 812 */ 813 bool BoundaryPolygonSet::ContainsBoundaryPoint(const TesselPoint * const point) const 814 { 815 Info FunctionInfo(__func__); 816 for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) 817 if (point == (*Runner)->node) { 818 DoLog(0) && (Log() << Verbose(0) << " Contained." << endl); 819 return true; 820 } 821 DoLog(0) && (Log() << Verbose(0) << " Not contained." << endl); 822 return false; 823 } 824 ; 825 826 /** Checks whether given array of \a *Points coincide with polygons's endpoints. 827 * \param **Points pointer to an array of BoundaryPointSet 828 * \param dim dimension of array 829 * \return true - set of points is contained in polygon, false - is not 830 */ 831 bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const 832 { 833 Info FunctionInfo(__func__); 834 int counter = 0; 835 DoLog(1) && (Log() << Verbose(1) << "Polygon is " << *this << endl); 836 for (int i = 0; i < dim; i++) { 837 DoLog(1) && (Log() << Verbose(1) << " Testing endpoint " << *Points[i] << endl); 838 if (ContainsBoundaryPoint(Points[i])) { 839 counter++; 840 } 841 } 842 843 if (counter == dim) 844 return true; 845 else 846 return false; 847 } 848 ; 849 850 /** Checks whether given PointList coincide with polygons's endpoints. 851 * \param &endpoints PointList 852 * \return true - set of points is contained in polygon, false - is not 853 */ 854 bool BoundaryPolygonSet::ContainsPresentTupel(const PointSet &endpoints) const 855 { 856 Info FunctionInfo(__func__); 857 size_t counter = 0; 858 DoLog(1) && (Log() << Verbose(1) << "Polygon is " << *this << endl); 859 for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) { 860 DoLog(1) && (Log() << Verbose(1) << " Testing endpoint " << **Runner << endl); 861 if (ContainsBoundaryPoint(*Runner)) 862 counter++; 863 } 864 865 if (counter == endpoints.size()) 866 return true; 867 else 868 return false; 869 } 870 ; 871 872 /** Checks whether given set of \a *Points coincide with polygons's endpoints. 873 * \param *P pointer to BoundaryPolygonSet 874 * \return true - is the very triangle, false - is not 875 */ 876 bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPolygonSet * const P) const 877 { 878 return ContainsPresentTupel((const PointSet) P->endpoints); 879 } 880 ; 881 882 /** Gathers all the endpoints' triangles in a unique set. 883 * \return set of all triangles 884 */ 885 TriangleSet * BoundaryPolygonSet::GetAllContainedTrianglesFromEndpoints() const 886 { 887 Info FunctionInfo(__func__); 888 pair<TriangleSet::iterator, bool> Tester; 889 TriangleSet *triangles = new TriangleSet; 890 891 for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) 892 for (LineMap::const_iterator Walker = (*Runner)->lines.begin(); Walker != (*Runner)->lines.end(); Walker++) 893 for (TriangleMap::const_iterator Sprinter = (Walker->second)->triangles.begin(); Sprinter != (Walker->second)->triangles.end(); Sprinter++) { 894 //Log() << Verbose(0) << " Testing triangle " << *(Sprinter->second) << endl; 895 if (ContainsBoundaryTriangle(Sprinter->second)) { 896 Tester = triangles->insert(Sprinter->second); 897 if (Tester.second) 898 DoLog(0) && (Log() << Verbose(0) << "Adding triangle " << *(Sprinter->second) << endl); 899 } 900 } 901 902 DoLog(1) && (Log() << Verbose(1) << "The Polygon of " << endpoints.size() << " endpoints has " << triangles->size() << " unique triangles in total." << endl); 903 return triangles; 904 } 905 ; 906 907 /** Fills the endpoints of this polygon from the triangles attached to \a *line. 908 * \param *line lines with triangles attached 909 * \return true - polygon contains endpoints, false - line was NULL 910 */ 911 bool BoundaryPolygonSet::FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line) 912 { 913 Info FunctionInfo(__func__); 914 pair<PointSet::iterator, bool> Tester; 915 if (line == NULL) 916 return false; 917 DoLog(1) && (Log() << Verbose(1) << "Filling polygon from line " << *line << endl); 918 for (TriangleMap::const_iterator Runner = line->triangles.begin(); Runner != line->triangles.end(); Runner++) { 919 for (int i = 0; i < 3; i++) { 920 Tester = endpoints.insert((Runner->second)->endpoints[i]); 921 if (Tester.second) 922 DoLog(1) && (Log() << Verbose(1) << " Inserting endpoint " << *((Runner->second)->endpoints[i]) << endl); 923 } 924 } 925 926 return true; 927 } 928 ; 929 930 /** output operator for BoundaryPolygonSet. 931 * \param &ost output stream 932 * \param &a boundary polygon 933 */ 934 ostream &operator <<(ostream &ost, const BoundaryPolygonSet &a) 935 { 936 ost << "[" << a.Nr << "|"; 937 for (PointSet::const_iterator Runner = a.endpoints.begin(); Runner != a.endpoints.end();) { 938 ost << (*Runner)->node->Name; 939 Runner++; 940 if (Runner != a.endpoints.end()) 941 ost << ","; 942 } 943 ost << "]"; 944 return ost; 945 } 946 ; 562 947 563 948 // =========================================================== class TESSELPOINT =========================================== … … 567 952 TesselPoint::TesselPoint() 568 953 { 569 Info FunctionInfo(__func__);954 //Info FunctionInfo(__func__); 570 955 node = NULL; 571 956 nr = -1; 572 Name = NULL; 573 }; 957 Name = NULL; 958 } 959 ; 574 960 575 961 /** Destructor for class TesselPoint. … … 577 963 TesselPoint::~TesselPoint() 578 964 { 579 Info FunctionInfo(__func__); 580 }; 965 //Info FunctionInfo(__func__); 966 } 967 ; 581 968 582 969 /** Prints LCNode to screen. 583 970 */ 584 ostream & operator << 971 ostream & operator <<(ostream &ost, const TesselPoint &a) 585 972 { 586 973 ost << "[" << (a.Name) << "|" << a.Name << " at " << *a.node << "]"; 587 974 return ost; 588 }; 975 } 976 ; 589 977 590 978 /** Prints LCNode to screen. 591 979 */ 592 ostream & TesselPoint::operator << 593 { 594 980 ostream & TesselPoint::operator <<(ostream &ost) 981 { 982 Info FunctionInfo(__func__); 595 983 ost << "[" << (nr) << "|" << this << "]"; 596 984 return ost; 597 } ;598 985 } 986 ; 599 987 600 988 // =========================================================== class POINTCLOUD ============================================ … … 604 992 PointCloud::PointCloud() 605 993 { 606 Info FunctionInfo(__func__); 607 }; 994 //Info FunctionInfo(__func__); 995 } 996 ; 608 997 609 998 /** Destructor for class PointCloud. … … 611 1000 PointCloud::~PointCloud() 612 1001 { 613 Info FunctionInfo(__func__); 614 }; 1002 //Info FunctionInfo(__func__); 1003 } 1004 ; 615 1005 616 1006 // ============================ CandidateForTesselation ============================= … … 618 1008 /** Constructor of class CandidateForTesselation. 619 1009 */ 620 CandidateForTesselation::CandidateForTesselation (BoundaryLineSet* line) : 621 BaseLine(line), 622 ShortestAngle(2.*M_PI), 623 OtherShortestAngle(2.*M_PI) 624 { 625 Info FunctionInfo(__func__); 626 }; 627 1010 CandidateForTesselation::CandidateForTesselation(BoundaryLineSet* line) : 1011 BaseLine(line), ThirdPoint(NULL), T(NULL), ShortestAngle(2. * M_PI), OtherShortestAngle(2. * M_PI) 1012 { 1013 Info FunctionInfo(__func__); 1014 } 1015 ; 628 1016 629 1017 /** Constructor of class CandidateForTesselation. 630 1018 */ 631 CandidateForTesselation::CandidateForTesselation (TesselPoint *candidate, BoundaryLineSet* line, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) : 632 BaseLine(line), 633 ShortestAngle(2.*M_PI), 634 OtherShortestAngle(2.*M_PI) 635 { 636 Info FunctionInfo(__func__); 1019 CandidateForTesselation::CandidateForTesselation(TesselPoint *candidate, BoundaryLineSet* line, BoundaryPointSet* point, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) : 1020 BaseLine(line), ThirdPoint(point), T(NULL), ShortestAngle(2. * M_PI), OtherShortestAngle(2. * M_PI) 1021 { 1022 Info FunctionInfo(__func__); 637 1023 OptCenter.CopyVector(&OptCandidateCenter); 638 1024 OtherOptCenter.CopyVector(&OtherOptCandidateCenter); 639 }; 1025 } 1026 ; 640 1027 641 1028 /** Destructor for class CandidateForTesselation. 642 1029 */ 643 CandidateForTesselation::~CandidateForTesselation() { 644 BaseLine = NULL; 645 }; 1030 CandidateForTesselation::~CandidateForTesselation() 1031 { 1032 } 1033 ; 1034 1035 /** Checks validity of a given sphere of a candidate line. 1036 * Sphere must touch all candidates and the baseline endpoints and there must be no other atoms inside. 1037 * \param RADIUS radius of sphere 1038 * \param *LC LinkedCell structure with other atoms 1039 * \return true - sphere is valid, false - sphere contains other points 1040 */ 1041 bool CandidateForTesselation::CheckValidity(const double RADIUS, const LinkedCell *LC) const 1042 { 1043 Info FunctionInfo(__func__); 1044 1045 const double radiusSquared = RADIUS * RADIUS; 1046 list<const Vector *> VectorList; 1047 VectorList.push_back(&OptCenter); 1048 //VectorList.push_back(&OtherOptCenter); // don't check the other (wrong) center 1049 1050 if (!pointlist.empty()) 1051 DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains candidate list and baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ..." << endl); 1052 else 1053 DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere with no candidates contains baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ..." << endl); 1054 // check baseline for OptCenter and OtherOptCenter being on sphere's surface 1055 for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) { 1056 for (int i = 0; i < 2; i++) { 1057 const double distance = fabs((*VRunner)->DistanceSquared(BaseLine->endpoints[i]->node->node) - radiusSquared); 1058 if (distance > HULLEPSILON) { 1059 DoeLog(1) && (eLog() << Verbose(1) << "Endpoint " << *BaseLine->endpoints[i] << " is out of sphere at " << *(*VRunner) << " by " << distance << "." << endl); 1060 return false; 1061 } 1062 } 1063 } 1064 1065 // check Candidates for OptCenter and OtherOptCenter being on sphere's surface 1066 for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.end(); ++Runner) { 1067 const TesselPoint *Walker = *Runner; 1068 for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) { 1069 const double distance = fabs((*VRunner)->DistanceSquared(Walker->node) - radiusSquared); 1070 if (distance > HULLEPSILON) { 1071 DoeLog(1) && (eLog() << Verbose(1) << "Candidate " << *Walker << " is out of sphere at " << *(*VRunner) << " by " << distance << "." << endl); 1072 return false; 1073 } else { 1074 DoLog(1) && (Log() << Verbose(1) << "Candidate " << *Walker << " is inside by " << distance << "." << endl); 1075 } 1076 } 1077 } 1078 1079 DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains no others points ..." << endl); 1080 bool flag = true; 1081 for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) { 1082 // get all points inside the sphere 1083 TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, (*VRunner)); 1084 1085 DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << OtherOptCenter << ":" << endl); 1086 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 1087 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)->node->Distance(&OtherOptCenter) << "." << endl); 1088 1089 // remove baseline's endpoints and candidates 1090 for (int i = 0; i < 2; i++) { 1091 DoLog(1) && (Log() << Verbose(1) << "INFO: removing baseline tesselpoint " << *BaseLine->endpoints[i]->node << "." << endl); 1092 ListofPoints->remove(BaseLine->endpoints[i]->node); 1093 } 1094 for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.end(); ++Runner) { 1095 DoLog(1) && (Log() << Verbose(1) << "INFO: removing candidate tesselpoint " << *(*Runner) << "." << endl); 1096 ListofPoints->remove(*Runner); 1097 } 1098 if (!ListofPoints->empty()) { 1099 DoeLog(1) && (eLog() << Verbose(1) << "CheckValidity: There are still " << ListofPoints->size() << " points inside the sphere." << endl); 1100 flag = false; 1101 DoeLog(1) && (eLog() << Verbose(1) << "External atoms inside of sphere at " << *(*VRunner) << ":" << endl); 1102 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 1103 DoeLog(1) && (eLog() << Verbose(1) << " " << *(*Runner) << endl); 1104 } 1105 delete (ListofPoints); 1106 1107 // check with animate_sphere.tcl VMD script 1108 if (ThirdPoint != NULL) { 1109 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.x[0] << " " << OldCenter.x[1] << " " << OldCenter.x[2] << " " << (*VRunner)->x[0] << " " << (*VRunner)->x[1] << " " << (*VRunner)->x[2] << endl); 1110 } else { 1111 DoLog(1) && (Log() << Verbose(1) << "Check by: ... missing third point ..." << endl); 1112 DoLog(1) && (Log() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " ??? " << RADIUS << " " << OldCenter.x[0] << " " << OldCenter.x[1] << " " << OldCenter.x[2] << " " << (*VRunner)->x[0] << " " << (*VRunner)->x[1] << " " << (*VRunner)->x[2] << endl); 1113 } 1114 } 1115 return flag; 1116 } 1117 ; 646 1118 647 1119 /** output operator for CandidateForTesselation. … … 649 1121 * \param &a boundary line 650 1122 */ 651 ostream & operator <<(ostream &ost, const 1123 ostream & operator <<(ostream &ost, const CandidateForTesselation &a) 652 1124 { 653 1125 ost << "[" << a.BaseLine->Nr << "|" << a.BaseLine->endpoints[0]->node->Name << "," << a.BaseLine->endpoints[1]->node->Name << "] with "; … … 662 1134 for (TesselPointList::const_iterator Runner = a.pointlist.begin(); Runner != a.pointlist.end(); Runner++) 663 1135 ost << *(*Runner) << " "; 664 ost << " at angle " << (a.ShortestAngle) << ".";1136 ost << " at angle " << (a.ShortestAngle) << "."; 665 1137 } 666 1138 667 1139 return ost; 668 } ;669 1140 } 1141 ; 670 1142 671 1143 // =========================================================== class TESSELATION =========================================== … … 674 1146 */ 675 1147 Tesselation::Tesselation() : 676 PointsOnBoundaryCount(0), 677 LinesOnBoundaryCount(0), 678 TrianglesOnBoundaryCount(0), 679 LastTriangle(NULL), 680 TriangleFilesWritten(0), 681 InternalPointer(PointsOnBoundary.begin()) 682 { 683 Info FunctionInfo(__func__); 1148 PointsOnBoundaryCount(0), LinesOnBoundaryCount(0), TrianglesOnBoundaryCount(0), LastTriangle(NULL), TriangleFilesWritten(0), InternalPointer(PointsOnBoundary.begin()) 1149 { 1150 Info FunctionInfo(__func__); 684 1151 } 685 1152 ; … … 690 1157 Tesselation::~Tesselation() 691 1158 { 692 693 Log() << Verbose(0) << "Free'ing TesselStruct ... " << endl;1159 Info FunctionInfo(__func__); 1160 DoLog(0) && (Log() << Verbose(0) << "Free'ing TesselStruct ... " << endl); 694 1161 for (TriangleMap::iterator runner = TrianglesOnBoundary.begin(); runner != TrianglesOnBoundary.end(); runner++) { 695 1162 if (runner->second != NULL) { … … 697 1164 runner->second = NULL; 698 1165 } else 699 eLog() << Verbose(1) << "The triangle " << runner->first << " has already been free'd." << endl;700 } 701 Log() << Verbose(0) << "This envelope was written to file " << TriangleFilesWritten << " times(s)." << endl;1166 DoeLog(1) && (eLog() << Verbose(1) << "The triangle " << runner->first << " has already been free'd." << endl); 1167 } 1168 DoLog(0) && (Log() << Verbose(0) << "This envelope was written to file " << TriangleFilesWritten << " times(s)." << endl); 702 1169 } 703 1170 ; … … 705 1172 /** PointCloud implementation of GetCenter 706 1173 * Uses PointsOnBoundary and STL stuff. 707 */ 1174 */ 708 1175 Vector * Tesselation::GetCenter(ofstream *out) const 709 1176 { 710 711 Vector *Center = new Vector(0., 0.,0.);712 int num =0;1177 Info FunctionInfo(__func__); 1178 Vector *Center = new Vector(0., 0., 0.); 1179 int num = 0; 713 1180 for (GoToFirst(); (!IsEnd()); GoToNext()) { 714 1181 Center->AddVector(GetPoint()->node); 715 1182 num++; 716 1183 } 717 Center->Scale(1. /num);1184 Center->Scale(1. / num); 718 1185 return Center; 719 }; 1186 } 1187 ; 720 1188 721 1189 /** PointCloud implementation of GoPoint 722 1190 * Uses PointsOnBoundary and STL stuff. 723 */ 1191 */ 724 1192 TesselPoint * Tesselation::GetPoint() const 725 1193 { 726 1194 Info FunctionInfo(__func__); 727 1195 return (InternalPointer->second->node); 728 }; 1196 } 1197 ; 729 1198 730 1199 /** PointCloud implementation of GetTerminalPoint. 731 1200 * Uses PointsOnBoundary and STL stuff. 732 */ 1201 */ 733 1202 TesselPoint * Tesselation::GetTerminalPoint() const 734 1203 { 735 1204 Info FunctionInfo(__func__); 736 1205 PointMap::const_iterator Runner = PointsOnBoundary.end(); 737 1206 Runner--; 738 1207 return (Runner->second->node); 739 }; 1208 } 1209 ; 740 1210 741 1211 /** PointCloud implementation of GoToNext. 742 1212 * Uses PointsOnBoundary and STL stuff. 743 */ 1213 */ 744 1214 void Tesselation::GoToNext() const 745 1215 { 746 1216 Info FunctionInfo(__func__); 747 1217 if (InternalPointer != PointsOnBoundary.end()) 748 1218 InternalPointer++; 749 }; 1219 } 1220 ; 750 1221 751 1222 /** PointCloud implementation of GoToPrevious. 752 1223 * Uses PointsOnBoundary and STL stuff. 753 */ 1224 */ 754 1225 void Tesselation::GoToPrevious() const 755 1226 { 756 1227 Info FunctionInfo(__func__); 757 1228 if (InternalPointer != PointsOnBoundary.begin()) 758 1229 InternalPointer--; 759 }; 1230 } 1231 ; 760 1232 761 1233 /** PointCloud implementation of GoToFirst. 762 1234 * Uses PointsOnBoundary and STL stuff. 763 */ 1235 */ 764 1236 void Tesselation::GoToFirst() const 765 1237 { 766 1238 Info FunctionInfo(__func__); 767 1239 InternalPointer = PointsOnBoundary.begin(); 768 }; 1240 } 1241 ; 769 1242 770 1243 /** PointCloud implementation of GoToLast. … … 773 1246 void Tesselation::GoToLast() const 774 1247 { 775 1248 Info FunctionInfo(__func__); 776 1249 InternalPointer = PointsOnBoundary.end(); 777 1250 InternalPointer--; 778 }; 1251 } 1252 ; 779 1253 780 1254 /** PointCloud implementation of IsEmpty. 781 1255 * Uses PointsOnBoundary and STL stuff. 782 */ 1256 */ 783 1257 bool Tesselation::IsEmpty() const 784 1258 { 785 1259 Info FunctionInfo(__func__); 786 1260 return (PointsOnBoundary.empty()); 787 }; 1261 } 1262 ; 788 1263 789 1264 /** PointCloud implementation of IsLast. 790 1265 * Uses PointsOnBoundary and STL stuff. 791 */ 1266 */ 792 1267 bool Tesselation::IsEnd() const 793 1268 { 794 1269 Info FunctionInfo(__func__); 795 1270 return (InternalPointer == PointsOnBoundary.end()); 796 } ;797 1271 } 1272 ; 798 1273 799 1274 /** Gueses first starting triangle of the convex envelope. … … 802 1277 * \param PointsOnBoundary set of boundary points defining the convex envelope of the cluster 803 1278 */ 804 void 805 Tesselation::GuessStartingTriangle() 806 { 807 Info FunctionInfo(__func__); 1279 void Tesselation::GuessStartingTriangle() 1280 { 1281 Info FunctionInfo(__func__); 808 1282 // 4b. create a starting triangle 809 1283 // 4b1. create all distances … … 815 1289 816 1290 // with A chosen, take each pair B,C and sort 817 if (A != PointsOnBoundary.end()) 818 { 819 B = A; 820 B++; 821 for (; B != PointsOnBoundary.end(); B++) 822 { 823 C = B; 824 C++; 825 for (; C != PointsOnBoundary.end(); C++) 826 { 827 tmp = A->second->node->node->DistanceSquared(B->second->node->node); 828 distance = tmp * tmp; 829 tmp = A->second->node->node->DistanceSquared(C->second->node->node); 830 distance += tmp * tmp; 831 tmp = B->second->node->node->DistanceSquared(C->second->node->node); 832 distance += tmp * tmp; 833 DistanceMMap.insert(DistanceMultiMapPair(distance, pair<PointMap::iterator, PointMap::iterator> (B, C))); 834 } 835 } 836 } 1291 if (A != PointsOnBoundary.end()) { 1292 B = A; 1293 B++; 1294 for (; B != PointsOnBoundary.end(); B++) { 1295 C = B; 1296 C++; 1297 for (; C != PointsOnBoundary.end(); C++) { 1298 tmp = A->second->node->node->DistanceSquared(B->second->node->node); 1299 distance = tmp * tmp; 1300 tmp = A->second->node->node->DistanceSquared(C->second->node->node); 1301 distance += tmp * tmp; 1302 tmp = B->second->node->node->DistanceSquared(C->second->node->node); 1303 distance += tmp * tmp; 1304 DistanceMMap.insert(DistanceMultiMapPair(distance, pair<PointMap::iterator, PointMap::iterator> (B, C))); 1305 } 1306 } 1307 } 837 1308 // // listing distances 838 1309 // Log() << Verbose(1) << "Listing DistanceMMap:"; … … 844 1315 // 1. we take from the smallest sum of squared distance as the base line BC (with peak A) onward as the triangle candidate 845 1316 DistanceMultiMap::iterator baseline = DistanceMMap.begin(); 846 for (; baseline != DistanceMMap.end(); baseline++) 847 { 848 // we take from the smallest sum of squared distance as the base line BC (with peak A) onward as the triangle candidate 849 // 2. next, we have to check whether all points reside on only one side of the triangle 850 // 3. construct plane vector 851 PlaneVector.MakeNormalVector(A->second->node->node, 852 baseline->second.first->second->node->node, 853 baseline->second.second->second->node->node); 854 Log() << Verbose(2) << "Plane vector of candidate triangle is " << PlaneVector << endl; 855 // 4. loop over all points 856 double sign = 0.; 857 PointMap::iterator checker = PointsOnBoundary.begin(); 858 for (; checker != PointsOnBoundary.end(); checker++) 859 { 860 // (neglecting A,B,C) 861 if ((checker == A) || (checker == baseline->second.first) || (checker 862 == baseline->second.second)) 863 continue; 864 // 4a. project onto plane vector 865 TrialVector.CopyVector(checker->second->node->node); 866 TrialVector.SubtractVector(A->second->node->node); 867 distance = TrialVector.ScalarProduct(&PlaneVector); 868 if (fabs(distance) < 1e-4) // we need to have a small epsilon around 0 which is still ok 869 continue; 870 Log() << Verbose(2) << "Projection of " << checker->second->node->Name << " yields distance of " << distance << "." << endl; 871 tmp = distance / fabs(distance); 872 // 4b. Any have different sign to than before? (i.e. would lie outside convex hull with this starting triangle) 873 if ((sign != 0) && (tmp != sign)) 874 { 875 // 4c. If so, break 4. loop and continue with next candidate in 1. loop 876 Log() << Verbose(2) << "Current candidates: " 877 << A->second->node->Name << "," 878 << baseline->second.first->second->node->Name << "," 879 << baseline->second.second->second->node->Name << " leaves " 880 << checker->second->node->Name << " outside the convex hull." 881 << endl; 882 break; 883 } 884 else 885 { // note the sign for later 886 Log() << Verbose(2) << "Current candidates: " 887 << A->second->node->Name << "," 888 << baseline->second.first->second->node->Name << "," 889 << baseline->second.second->second->node->Name << " leave " 890 << checker->second->node->Name << " inside the convex hull." 891 << endl; 892 sign = tmp; 893 } 894 // 4d. Check whether the point is inside the triangle (check distance to each node 895 tmp = checker->second->node->node->DistanceSquared(A->second->node->node); 896 int innerpoint = 0; 897 if ((tmp < A->second->node->node->DistanceSquared( 898 baseline->second.first->second->node->node)) && (tmp 899 < A->second->node->node->DistanceSquared( 900 baseline->second.second->second->node->node))) 901 innerpoint++; 902 tmp = checker->second->node->node->DistanceSquared( 903 baseline->second.first->second->node->node); 904 if ((tmp < baseline->second.first->second->node->node->DistanceSquared( 905 A->second->node->node)) && (tmp 906 < baseline->second.first->second->node->node->DistanceSquared( 907 baseline->second.second->second->node->node))) 908 innerpoint++; 909 tmp = checker->second->node->node->DistanceSquared( 910 baseline->second.second->second->node->node); 911 if ((tmp < baseline->second.second->second->node->node->DistanceSquared( 912 baseline->second.first->second->node->node)) && (tmp 913 < baseline->second.second->second->node->node->DistanceSquared( 914 A->second->node->node))) 915 innerpoint++; 916 // 4e. If so, break 4. loop and continue with next candidate in 1. loop 917 if (innerpoint == 3) 918 break; 919 } 920 // 5. come this far, all on same side? Then break 1. loop and construct triangle 921 if (checker == PointsOnBoundary.end()) 922 { 923 Log() << Verbose(2) << "Looks like we have a candidate!" << endl; 924 break; 925 } 926 } 927 if (baseline != DistanceMMap.end()) 928 { 929 BPS[0] = baseline->second.first->second; 930 BPS[1] = baseline->second.second->second; 931 BLS[0] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount); 932 BPS[0] = A->second; 933 BPS[1] = baseline->second.second->second; 934 BLS[1] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount); 935 BPS[0] = baseline->second.first->second; 936 BPS[1] = A->second; 937 BLS[2] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount); 938 939 // 4b3. insert created triangle 940 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 941 TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS)); 942 TrianglesOnBoundaryCount++; 943 for (int i = 0; i < NDIM; i++) 944 { 945 LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, BTS->lines[i])); 946 LinesOnBoundaryCount++; 947 } 948 949 Log() << Verbose(1) << "Starting triangle is " << *BTS << "." << endl; 950 } 951 else 952 { 953 eLog() << Verbose(0) << "No starting triangle found." << endl; 954 } 1317 for (; baseline != DistanceMMap.end(); baseline++) { 1318 // we take from the smallest sum of squared distance as the base line BC (with peak A) onward as the triangle candidate 1319 // 2. next, we have to check whether all points reside on only one side of the triangle 1320 // 3. construct plane vector 1321 PlaneVector.MakeNormalVector(A->second->node->node, baseline->second.first->second->node->node, baseline->second.second->second->node->node); 1322 DoLog(2) && (Log() << Verbose(2) << "Plane vector of candidate triangle is " << PlaneVector << endl); 1323 // 4. loop over all points 1324 double sign = 0.; 1325 PointMap::iterator checker = PointsOnBoundary.begin(); 1326 for (; checker != PointsOnBoundary.end(); checker++) { 1327 // (neglecting A,B,C) 1328 if ((checker == A) || (checker == baseline->second.first) || (checker == baseline->second.second)) 1329 continue; 1330 // 4a. project onto plane vector 1331 TrialVector.CopyVector(checker->second->node->node); 1332 TrialVector.SubtractVector(A->second->node->node); 1333 distance = TrialVector.ScalarProduct(&PlaneVector); 1334 if (fabs(distance) < 1e-4) // we need to have a small epsilon around 0 which is still ok 1335 continue; 1336 DoLog(2) && (Log() << Verbose(2) << "Projection of " << checker->second->node->Name << " yields distance of " << distance << "." << endl); 1337 tmp = distance / fabs(distance); 1338 // 4b. Any have different sign to than before? (i.e. would lie outside convex hull with this starting triangle) 1339 if ((sign != 0) && (tmp != sign)) { 1340 // 4c. If so, break 4. loop and continue with next candidate in 1. loop 1341 DoLog(2) && (Log() << Verbose(2) << "Current candidates: " << A->second->node->Name << "," << baseline->second.first->second->node->Name << "," << baseline->second.second->second->node->Name << " leaves " << checker->second->node->Name << " outside the convex hull." << endl); 1342 break; 1343 } else { // note the sign for later 1344 DoLog(2) && (Log() << Verbose(2) << "Current candidates: " << A->second->node->Name << "," << baseline->second.first->second->node->Name << "," << baseline->second.second->second->node->Name << " leave " << checker->second->node->Name << " inside the convex hull." << endl); 1345 sign = tmp; 1346 } 1347 // 4d. Check whether the point is inside the triangle (check distance to each node 1348 tmp = checker->second->node->node->DistanceSquared(A->second->node->node); 1349 int innerpoint = 0; 1350 if ((tmp < A->second->node->node->DistanceSquared(baseline->second.first->second->node->node)) && (tmp < A->second->node->node->DistanceSquared(baseline->second.second->second->node->node))) 1351 innerpoint++; 1352 tmp = checker->second->node->node->DistanceSquared(baseline->second.first->second->node->node); 1353 if ((tmp < baseline->second.first->second->node->node->DistanceSquared(A->second->node->node)) && (tmp < baseline->second.first->second->node->node->DistanceSquared(baseline->second.second->second->node->node))) 1354 innerpoint++; 1355 tmp = checker->second->node->node->DistanceSquared(baseline->second.second->second->node->node); 1356 if ((tmp < baseline->second.second->second->node->node->DistanceSquared(baseline->second.first->second->node->node)) && (tmp < baseline->second.second->second->node->node->DistanceSquared(A->second->node->node))) 1357 innerpoint++; 1358 // 4e. If so, break 4. loop and continue with next candidate in 1. loop 1359 if (innerpoint == 3) 1360 break; 1361 } 1362 // 5. come this far, all on same side? Then break 1. loop and construct triangle 1363 if (checker == PointsOnBoundary.end()) { 1364 DoLog(2) && (Log() << Verbose(2) << "Looks like we have a candidate!" << endl); 1365 break; 1366 } 1367 } 1368 if (baseline != DistanceMMap.end()) { 1369 BPS[0] = baseline->second.first->second; 1370 BPS[1] = baseline->second.second->second; 1371 BLS[0] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount); 1372 BPS[0] = A->second; 1373 BPS[1] = baseline->second.second->second; 1374 BLS[1] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount); 1375 BPS[0] = baseline->second.first->second; 1376 BPS[1] = A->second; 1377 BLS[2] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount); 1378 1379 // 4b3. insert created triangle 1380 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 1381 TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS)); 1382 TrianglesOnBoundaryCount++; 1383 for (int i = 0; i < NDIM; i++) { 1384 LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, BTS->lines[i])); 1385 LinesOnBoundaryCount++; 1386 } 1387 1388 DoLog(1) && (Log() << Verbose(1) << "Starting triangle is " << *BTS << "." << endl); 1389 } else { 1390 DoeLog(0) && (eLog() << Verbose(0) << "No starting triangle found." << endl); 1391 } 955 1392 } 956 1393 ; … … 971 1408 void Tesselation::TesselateOnBoundary(const PointCloud * const cloud) 972 1409 { 973 1410 Info FunctionInfo(__func__); 974 1411 bool flag; 975 1412 PointMap::iterator winner; … … 990 1427 // get peak point with respect to this base line's only triangle 991 1428 BTS = baseline->second->triangles.begin()->second; // there is only one triangle so far 992 Log() << Verbose(0) << "Current baseline is between " << *(baseline->second) << "." << endl;1429 DoLog(0) && (Log() << Verbose(0) << "Current baseline is between " << *(baseline->second) << "." << endl); 993 1430 for (int i = 0; i < 3; i++) 994 1431 if ((BTS->endpoints[i] != baseline->second->endpoints[0]) && (BTS->endpoints[i] != baseline->second->endpoints[1])) 995 1432 peak = BTS->endpoints[i]; 996 Log() << Verbose(1) << " and has peak " << *peak << "." << endl;1433 DoLog(1) && (Log() << Verbose(1) << " and has peak " << *peak << "." << endl); 997 1434 998 1435 // prepare some auxiliary vectors … … 1009 1446 CenterVector.AddVector(BTS->endpoints[i]->node->node); 1010 1447 CenterVector.Scale(1. / 3.); 1011 Log() << Verbose(2) << "CenterVector of base triangle is " << CenterVector << endl;1448 DoLog(2) && (Log() << Verbose(2) << "CenterVector of base triangle is " << CenterVector << endl); 1012 1449 1013 1450 // normal vector of triangle … … 1016 1453 BTS->GetNormalVector(NormalVector); 1017 1454 NormalVector.CopyVector(&BTS->NormalVector); 1018 Log() << Verbose(2) << "NormalVector of base triangle is " << NormalVector << endl;1455 DoLog(2) && (Log() << Verbose(2) << "NormalVector of base triangle is " << NormalVector << endl); 1019 1456 1020 1457 // vector in propagation direction (out of triangle) … … 1026 1463 if (PropagationVector.ScalarProduct(&TempVector) > 0) // make sure normal propagation vector points outward from baseline 1027 1464 PropagationVector.Scale(-1.); 1028 Log() << Verbose(2) << "PropagationVector of base triangle is " << PropagationVector << endl;1465 DoLog(2) && (Log() << Verbose(2) << "PropagationVector of base triangle is " << PropagationVector << endl); 1029 1466 winner = PointsOnBoundary.end(); 1030 1467 … … 1032 1469 for (PointMap::iterator target = PointsOnBoundary.begin(); target != PointsOnBoundary.end(); target++) { 1033 1470 if ((target->second != baseline->second->endpoints[0]) && (target->second != baseline->second->endpoints[1])) { // don't take the same endpoints 1034 Log() << Verbose(1) << "Target point is " << *(target->second) << ":" << endl;1471 DoLog(1) && (Log() << Verbose(1) << "Target point is " << *(target->second) << ":" << endl); 1035 1472 1036 1473 // first check direction, so that triangles don't intersect … … 1039 1476 VirtualNormalVector.ProjectOntoPlane(&NormalVector); 1040 1477 TempAngle = VirtualNormalVector.Angle(&PropagationVector); 1041 Log() << Verbose(2) << "VirtualNormalVector is " << VirtualNormalVector << " and PropagationVector is " << PropagationVector << "." << endl;1042 if (TempAngle > (M_PI /2.)) { // no bends bigger than Pi/2 (90 degrees)1043 Log() << Verbose(2) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", bad direction!" << endl;1478 DoLog(2) && (Log() << Verbose(2) << "VirtualNormalVector is " << VirtualNormalVector << " and PropagationVector is " << PropagationVector << "." << endl); 1479 if (TempAngle > (M_PI / 2.)) { // no bends bigger than Pi/2 (90 degrees) 1480 DoLog(2) && (Log() << Verbose(2) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", bad direction!" << endl); 1044 1481 continue; 1045 1482 } else 1046 Log() << Verbose(2) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", good direction!" << endl;1483 DoLog(2) && (Log() << Verbose(2) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", good direction!" << endl); 1047 1484 1048 1485 // check first and second endpoint (if any connecting line goes to target has at least not more than 1 triangle) … … 1050 1487 LineChecker[1] = baseline->second->endpoints[1]->lines.find(target->first); 1051 1488 if (((LineChecker[0] != baseline->second->endpoints[0]->lines.end()) && (LineChecker[0]->second->triangles.size() == 2))) { 1052 Log() << Verbose(2) << *(baseline->second->endpoints[0]) << " has line " << *(LineChecker[0]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[0]->second->triangles.size() << " triangles." << endl;1489 DoLog(2) && (Log() << Verbose(2) << *(baseline->second->endpoints[0]) << " has line " << *(LineChecker[0]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[0]->second->triangles.size() << " triangles." << endl); 1053 1490 continue; 1054 1491 } 1055 1492 if (((LineChecker[1] != baseline->second->endpoints[1]->lines.end()) && (LineChecker[1]->second->triangles.size() == 2))) { 1056 Log() << Verbose(2) << *(baseline->second->endpoints[1]) << " has line " << *(LineChecker[1]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[1]->second->triangles.size() << " triangles." << endl;1493 DoLog(2) && (Log() << Verbose(2) << *(baseline->second->endpoints[1]) << " has line " << *(LineChecker[1]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[1]->second->triangles.size() << " triangles." << endl); 1057 1494 continue; 1058 1495 } … … 1060 1497 // check whether the envisaged triangle does not already exist (if both lines exist and have same endpoint) 1061 1498 if ((((LineChecker[0] != baseline->second->endpoints[0]->lines.end()) && (LineChecker[1] != baseline->second->endpoints[1]->lines.end()) && (GetCommonEndpoint(LineChecker[0]->second, LineChecker[1]->second) == peak)))) { 1062 Log() << Verbose(4) << "Current target is peak!" << endl;1499 DoLog(4) && (Log() << Verbose(4) << "Current target is peak!" << endl); 1063 1500 continue; 1064 1501 } … … 1071 1508 helper.ProjectOntoPlane(&TempVector); 1072 1509 if (fabs(helper.NormSquared()) < MYEPSILON) { 1073 Log() << Verbose(2) << "Chosen set of vectors is linear dependent." << endl;1510 DoLog(2) && (Log() << Verbose(2) << "Chosen set of vectors is linear dependent." << endl); 1074 1511 continue; 1075 1512 } … … 1081 1518 TempVector.AddVector(baseline->second->endpoints[1]->node->node); 1082 1519 TempVector.AddVector(target->second->node->node); 1083 TempVector.Scale(1. /3.);1520 TempVector.Scale(1. / 3.); 1084 1521 TempVector.SubtractVector(Center); 1085 1522 // make it always point outward … … 1088 1525 // calculate angle 1089 1526 TempAngle = NormalVector.Angle(&VirtualNormalVector); 1090 Log() << Verbose(2) << "NormalVector is " << VirtualNormalVector << " and the angle is " << TempAngle << "." << endl;1527 DoLog(2) && (Log() << Verbose(2) << "NormalVector is " << VirtualNormalVector << " and the angle is " << TempAngle << "." << endl); 1091 1528 if ((SmallestAngle - TempAngle) > MYEPSILON) { // set to new possible winner 1092 1529 SmallestAngle = TempAngle; 1093 1530 winner = target; 1094 Log() << Verbose(2) << "New winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl;1531 DoLog(2) && (Log() << Verbose(2) << "New winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl); 1095 1532 } else if (fabs(SmallestAngle - TempAngle) < MYEPSILON) { // check the angle to propagation, both possible targets are in one plane! (their normals have same angle) 1096 1533 // hence, check the angles to some normal direction from our base line but in this common plane of both targets... … … 1110 1547 SmallestAngle = TempAngle; 1111 1548 winner = target; 1112 Log() << Verbose(2) << "New winner " << *winner->second->node << " due to smaller angle " << TempAngle << " to propagation direction." << endl;1549 DoLog(2) && (Log() << Verbose(2) << "New winner " << *winner->second->node << " due to smaller angle " << TempAngle << " to propagation direction." << endl); 1113 1550 } else 1114 Log() << Verbose(2) << "Keeping old winner " << *winner->second->node << " due to smaller angle to propagation direction." << endl;1551 DoLog(2) && (Log() << Verbose(2) << "Keeping old winner " << *winner->second->node << " due to smaller angle to propagation direction." << endl); 1115 1552 } else 1116 Log() << Verbose(2) << "Keeping old winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl;1553 DoLog(2) && (Log() << Verbose(2) << "Keeping old winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl); 1117 1554 } 1118 1555 } // end of loop over all boundary points … … 1120 1557 // 5b. The point of the above whose triangle has the greatest angle with the triangle the current line belongs to (it only belongs to one, remember!): New triangle 1121 1558 if (winner != PointsOnBoundary.end()) { 1122 Log() << Verbose(0) << "Winning target point is " << *(winner->second) << " with angle " << SmallestAngle << "." << endl;1559 DoLog(0) && (Log() << Verbose(0) << "Winning target point is " << *(winner->second) << " with angle " << SmallestAngle << "." << endl); 1123 1560 // create the lins of not yet present 1124 1561 BLS[0] = baseline->second; … … 1150 1587 TrianglesOnBoundaryCount++; 1151 1588 } else { 1152 eLog() << Verbose(2) << "I could not determine a winner for this baseline " << *(baseline->second) << "." << endl;1589 DoeLog(2) && (eLog() << Verbose(2) << "I could not determine a winner for this baseline " << *(baseline->second) << "." << endl); 1153 1590 } 1154 1591 1155 1592 // 5d. If the set of lines is not yet empty, go to 5. and continue 1156 1593 } else 1157 Log() << Verbose(0) << "Baseline candidate " << *(baseline->second) << " has a triangle count of " << baseline->second->triangles.size() << "." << endl;1594 DoLog(0) && (Log() << Verbose(0) << "Baseline candidate " << *(baseline->second) << " has a triangle count of " << baseline->second->triangles.size() << "." << endl); 1158 1595 } while (flag); 1159 1596 1160 1597 // exit 1161 delete(Center); 1162 }; 1598 delete (Center); 1599 } 1600 ; 1163 1601 1164 1602 /** Inserts all points outside of the tesselated surface into it by adding new triangles. … … 1170 1608 bool Tesselation::InsertStraddlingPoints(const PointCloud *cloud, const LinkedCell *LC) 1171 1609 { 1172 1610 Info FunctionInfo(__func__); 1173 1611 Vector Intersection, Normal; 1174 1612 TesselPoint *Walker = NULL; 1175 1613 Vector *Center = cloud->GetCenter(); 1176 list<BoundaryTriangleSet*>*triangles = NULL;1614 TriangleList *triangles = NULL; 1177 1615 bool AddFlag = false; 1178 1616 LinkedCell *BoundaryPoints = NULL; … … 1180 1618 cloud->GoToFirst(); 1181 1619 BoundaryPoints = new LinkedCell(this, 5.); 1182 while (!cloud->IsEnd()) { 1620 while (!cloud->IsEnd()) { // we only have to go once through all points, as boundary can become only bigger 1183 1621 if (AddFlag) { 1184 delete (BoundaryPoints);1622 delete (BoundaryPoints); 1185 1623 BoundaryPoints = new LinkedCell(this, 5.); 1186 1624 AddFlag = false; 1187 1625 } 1188 1626 Walker = cloud->GetPoint(); 1189 Log() << Verbose(0) << "Current point is " << *Walker << "." << endl;1627 DoLog(0) && (Log() << Verbose(0) << "Current point is " << *Walker << "." << endl); 1190 1628 // get the next triangle 1191 triangles = FindClosestTrianglesTo Point(Walker->node, BoundaryPoints);1629 triangles = FindClosestTrianglesToVector(Walker->node, BoundaryPoints); 1192 1630 BTS = triangles->front(); 1193 1631 if ((triangles == NULL) || (BTS->ContainsBoundaryPoint(Walker))) { 1194 Log() << Verbose(0) << "No triangles found, probably a tesselation point itself." << endl;1632 DoLog(0) && (Log() << Verbose(0) << "No triangles found, probably a tesselation point itself." << endl); 1195 1633 cloud->GoToNext(); 1196 1634 continue; 1197 1635 } else { 1198 1636 } 1199 Log() << Verbose(0) << "Closest triangle is " << *BTS << "." << endl;1637 DoLog(0) && (Log() << Verbose(0) << "Closest triangle is " << *BTS << "." << endl); 1200 1638 // get the intersection point 1201 1639 if (BTS->GetIntersectionInsideTriangle(Center, Walker->node, &Intersection)) { 1202 Log() << Verbose(0) << "We have an intersection at " << Intersection << "." << endl;1640 DoLog(0) && (Log() << Verbose(0) << "We have an intersection at " << Intersection << "." << endl); 1203 1641 // we have the intersection, check whether in- or outside of boundary 1204 1642 if ((Center->DistanceSquared(Walker->node) - Center->DistanceSquared(&Intersection)) < -MYEPSILON) { 1205 1643 // inside, next! 1206 Log() << Verbose(0) << *Walker << " is inside wrt triangle " << *BTS << "." << endl;1644 DoLog(0) && (Log() << Verbose(0) << *Walker << " is inside wrt triangle " << *BTS << "." << endl); 1207 1645 } else { 1208 1646 // outside! 1209 Log() << Verbose(0) << *Walker << " is outside wrt triangle " << *BTS << "." << endl;1647 DoLog(0) && (Log() << Verbose(0) << *Walker << " is outside wrt triangle " << *BTS << "." << endl); 1210 1648 class BoundaryLineSet *OldLines[3], *NewLines[3]; 1211 1649 class BoundaryPointSet *OldPoints[3], *NewPoint; 1212 1650 // store the three old lines and old points 1213 for (int i =0;i<3;i++) {1651 for (int i = 0; i < 3; i++) { 1214 1652 OldLines[i] = BTS->lines[i]; 1215 1653 OldPoints[i] = BTS->endpoints[i]; … … 1217 1655 Normal.CopyVector(&BTS->NormalVector); 1218 1656 // add Walker to boundary points 1219 Log() << Verbose(0) << "Adding " << *Walker << " to BoundaryPoints." << endl;1657 DoLog(0) && (Log() << Verbose(0) << "Adding " << *Walker << " to BoundaryPoints." << endl); 1220 1658 AddFlag = true; 1221 if (AddBoundaryPoint(Walker, 0))1659 if (AddBoundaryPoint(Walker, 0)) 1222 1660 NewPoint = BPS[0]; 1223 1661 else 1224 1662 continue; 1225 1663 // remove triangle 1226 Log() << Verbose(0) << "Erasing triangle " << *BTS << "." << endl;1664 DoLog(0) && (Log() << Verbose(0) << "Erasing triangle " << *BTS << "." << endl); 1227 1665 TrianglesOnBoundary.erase(BTS->Nr); 1228 delete (BTS);1666 delete (BTS); 1229 1667 // create three new boundary lines 1230 for (int i =0;i<3;i++) {1668 for (int i = 0; i < 3; i++) { 1231 1669 BPS[0] = NewPoint; 1232 1670 BPS[1] = OldPoints[i]; 1233 1671 NewLines[i] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount); 1234 Log() << Verbose(1) << "Creating new line " << *NewLines[i] << "." << endl;1672 DoLog(1) && (Log() << Verbose(1) << "Creating new line " << *NewLines[i] << "." << endl); 1235 1673 LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, NewLines[i])); // no need for check for unique insertion as BPS[0] is definitely a new one 1236 1674 LinesOnBoundaryCount++; 1237 1675 } 1238 1676 // create three new triangle with new point 1239 for (int i =0;i<3;i++) { // find all baselines1677 for (int i = 0; i < 3; i++) { // find all baselines 1240 1678 BLS[0] = OldLines[i]; 1241 1679 int n = 1; 1242 for (int j =0;j<3;j++) {1680 for (int j = 0; j < 3; j++) { 1243 1681 if (NewLines[j]->IsConnectedTo(BLS[0])) { 1244 if (n >2) {1245 eLog() << Verbose(2) << BLS[0] << " connects to all of the new lines?!" << endl;1682 if (n > 2) { 1683 DoeLog(2) && (eLog() << Verbose(2) << BLS[0] << " connects to all of the new lines?!" << endl); 1246 1684 return false; 1247 1685 } else … … 1254 1692 BTS->GetNormalVector(Normal); 1255 1693 Normal.Scale(-1.); 1256 Log() << Verbose(0) << "Created new triangle " << *BTS << "." << endl;1694 DoLog(0) && (Log() << Verbose(0) << "Created new triangle " << *BTS << "." << endl); 1257 1695 TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS)); 1258 1696 TrianglesOnBoundaryCount++; … … 1260 1698 } 1261 1699 } else { // something is wrong with FindClosestTriangleToPoint! 1262 eLog() << Verbose(1) << "The closest triangle did not produce an intersection!" << endl;1700 DoeLog(1) && (eLog() << Verbose(1) << "The closest triangle did not produce an intersection!" << endl); 1263 1701 return false; 1264 1702 } … … 1267 1705 1268 1706 // exit 1269 delete (Center);1707 delete (Center); 1270 1708 return true; 1271 }; 1709 } 1710 ; 1272 1711 1273 1712 /** Adds a point to the tesselation::PointsOnBoundary list. … … 1278 1717 bool Tesselation::AddBoundaryPoint(TesselPoint * Walker, const int n) 1279 1718 { 1280 1719 Info FunctionInfo(__func__); 1281 1720 PointTestPair InsertUnique; 1282 1721 BPS[n] = new class BoundaryPointSet(Walker); … … 1286 1725 return true; 1287 1726 } else { 1288 delete (BPS[n]);1727 delete (BPS[n]); 1289 1728 BPS[n] = InsertUnique.first->second; 1290 1729 return false; … … 1300 1739 void Tesselation::AddTesselationPoint(TesselPoint* Candidate, const int n) 1301 1740 { 1302 1741 Info FunctionInfo(__func__); 1303 1742 PointTestPair InsertUnique; 1304 1743 TPS[n] = new class BoundaryPointSet(Candidate); … … 1308 1747 } else { 1309 1748 delete TPS[n]; 1310 Log() << Verbose(0) << "Node " << *((InsertUnique.first)->second->node) << " is already present in PointsOnBoundary." << endl;1749 DoLog(0) && (Log() << Verbose(0) << "Node " << *((InsertUnique.first)->second->node) << " is already present in PointsOnBoundary." << endl); 1311 1750 TPS[n] = (InsertUnique.first)->second; 1312 1751 } … … 1321 1760 void Tesselation::SetTesselationPoint(TesselPoint* Candidate, const int n) const 1322 1761 { 1323 1762 Info FunctionInfo(__func__); 1324 1763 PointMap::const_iterator FindPoint = PointsOnBoundary.find(Candidate->nr); 1325 1764 if (FindPoint != PointsOnBoundary.end()) … … 1327 1766 else 1328 1767 TPS[n] = NULL; 1329 }; 1768 } 1769 ; 1330 1770 1331 1771 /** Function tries to add line from current Points in BPS to BoundaryLineSet. 1332 1772 * If successful it raises the line count and inserts the new line into the BLS, 1333 1773 * if unsuccessful, it writes the line which had been present into the BLS, deleting the new constructed one. 1774 * @param *OptCenter desired OptCenter if there are more than one candidate line 1775 * @param *candidate third point of the triangle to be, for checking between multiple open line candidates 1334 1776 * @param *a first endpoint 1335 1777 * @param *b second endpoint 1336 1778 * @param n index of Tesselation::BLS giving the line with both endpoints 1337 1779 */ 1338 void Tesselation::AddTesselationLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n) { 1780 void Tesselation::AddTesselationLine(const Vector * const OptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n) 1781 { 1339 1782 bool insertNewLine = true; 1340 1341 if (a->lines.find(b->node->nr) != a->lines.end()) { 1342 LineMap::iterator FindLine = a->lines.find(b->node->nr); 1343 pair<LineMap::iterator,LineMap::iterator> FindPair; 1783 LineMap::iterator FindLine = a->lines.find(b->node->nr); 1784 BoundaryLineSet *WinningLine = NULL; 1785 if (FindLine != a->lines.end()) { 1786 DoLog(1) && (Log() << Verbose(1) << "INFO: There is at least one line between " << *a << " and " << *b << ": " << *(FindLine->second) << "." << endl); 1787 1788 pair<LineMap::iterator, LineMap::iterator> FindPair; 1344 1789 FindPair = a->lines.equal_range(b->node->nr); 1345 Log() << Verbose(1) << "INFO: There is at least one line between " << *a << " and " << *b << ": " << *(FindLine->second) << "." << endl; 1346 1347 for (FindLine = FindPair.first; FindLine != FindPair.second; FindLine++) {1790 1791 for (FindLine = FindPair.first; (FindLine != FindPair.second) && (insertNewLine); FindLine++) { 1792 DoLog(1) && (Log() << Verbose(1) << "INFO: Checking line " << *(FindLine->second) << " ..." << endl); 1348 1793 // If there is a line with less than two attached triangles, we don't need a new line. 1349 if (FindLine->second->triangles.size() < 2) { 1350 insertNewLine = false; 1351 Log() << Verbose(0) << "Using existing line " << *FindLine->second << endl; 1352 1353 BPS[0] = FindLine->second->endpoints[0]; 1354 BPS[1] = FindLine->second->endpoints[1]; 1355 BLS[n] = FindLine->second; 1356 1357 // remove existing line from OpenLines 1358 CandidateMap::iterator CandidateLine = OpenLines.find(BLS[n]); 1359 delete(CandidateLine->second); 1360 OpenLines.erase(CandidateLine); 1361 1362 break; 1794 if (FindLine->second->triangles.size() == 1) { 1795 CandidateMap::iterator Finder = OpenLines.find(FindLine->second); 1796 if (!Finder->second->pointlist.empty()) 1797 DoLog(1) && (Log() << Verbose(1) << "INFO: line " << *(FindLine->second) << " is open with candidate " << **(Finder->second->pointlist.begin()) << "." << endl); 1798 else 1799 DoLog(1) && (Log() << Verbose(1) << "INFO: line " << *(FindLine->second) << " is open with no candidate." << endl); 1800 // get open line 1801 for (TesselPointList::const_iterator CandidateChecker = Finder->second->pointlist.begin(); CandidateChecker != Finder->second->pointlist.end(); ++CandidateChecker) { 1802 if ((*(CandidateChecker) == candidate->node) && (OptCenter == NULL || OptCenter->DistanceSquared(&Finder->second->OptCenter) < MYEPSILON )) { // stop searching if candidate matches 1803 DoLog(1) && (Log() << Verbose(1) << "ACCEPT: Candidate " << *(*CandidateChecker) << " has the right center " << Finder->second->OptCenter << "." << endl); 1804 insertNewLine = false; 1805 WinningLine = FindLine->second; 1806 break; 1807 } else { 1808 DoLog(1) && (Log() << Verbose(1) << "REJECT: Candidate " << *(*CandidateChecker) << "'s center " << Finder->second->OptCenter << " does not match desired on " << *OptCenter << "." << endl); 1809 } 1810 } 1363 1811 } 1364 1812 } … … 1366 1814 1367 1815 if (insertNewLine) { 1368 AlwaysAddTesselationTriangleLine(a, b, n); 1816 AddNewTesselationTriangleLine(a, b, n); 1817 } else { 1818 AddExistingTesselationTriangleLine(WinningLine, n); 1369 1819 } 1370 1820 } … … 1379 1829 * @param n index of Tesselation::BLS giving the line with both endpoints 1380 1830 */ 1381 void Tesselation::A lwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n)1382 { 1383 1384 Log() << Verbose(0) << "Adding open line [" << LinesOnBoundaryCount << "|" << *(a->node) << " and " << *(b->node) << "." << endl;1831 void Tesselation::AddNewTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n) 1832 { 1833 Info FunctionInfo(__func__); 1834 DoLog(0) && (Log() << Verbose(0) << "Adding open line [" << LinesOnBoundaryCount << "|" << *(a->node) << " and " << *(b->node) << "." << endl); 1385 1835 BPS[0] = a; 1386 1836 BPS[1] = b; 1387 BLS[n] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount); 1837 BLS[n] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount); // this also adds the line to the local maps 1388 1838 // add line to global map 1389 1839 LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, BLS[n])); … … 1392 1842 // also add to open lines 1393 1843 CandidateForTesselation *CFT = new CandidateForTesselation(BLS[n]); 1394 OpenLines.insert(pair< BoundaryLineSet *, CandidateForTesselation *> (BLS[n], CFT)); 1395 }; 1844 OpenLines.insert(pair<BoundaryLineSet *, CandidateForTesselation *> (BLS[n], CFT)); 1845 } 1846 ; 1847 1848 /** Uses an existing line for a new triangle. 1849 * Sets Tesselation::BLS[\a n] and removes the lines from Tesselation::OpenLines. 1850 * \param *FindLine the line to add 1851 * \param n index of the line to set in Tesselation::BLS 1852 */ 1853 void Tesselation::AddExistingTesselationTriangleLine(class BoundaryLineSet *Line, int n) 1854 { 1855 Info FunctionInfo(__func__); 1856 DoLog(0) && (Log() << Verbose(0) << "Using existing line " << *Line << endl); 1857 1858 // set endpoints and line 1859 BPS[0] = Line->endpoints[0]; 1860 BPS[1] = Line->endpoints[1]; 1861 BLS[n] = Line; 1862 // remove existing line from OpenLines 1863 CandidateMap::iterator CandidateLine = OpenLines.find(BLS[n]); 1864 if (CandidateLine != OpenLines.end()) { 1865 DoLog(1) && (Log() << Verbose(1) << " Removing line from OpenLines." << endl); 1866 delete (CandidateLine->second); 1867 OpenLines.erase(CandidateLine); 1868 } else { 1869 DoeLog(1) && (eLog() << Verbose(1) << "Line exists and is attached to less than two triangles, but not in OpenLines!" << endl); 1870 } 1871 } 1872 ; 1396 1873 1397 1874 /** Function adds triangle to global list. … … 1400 1877 void Tesselation::AddTesselationTriangle() 1401 1878 { 1402 1403 Log() << Verbose(1) << "Adding triangle to global TrianglesOnBoundary map." << endl;1879 Info FunctionInfo(__func__); 1880 DoLog(1) && (Log() << Verbose(1) << "Adding triangle to global TrianglesOnBoundary map." << endl); 1404 1881 1405 1882 // add triangle to global map … … 1411 1888 1412 1889 // NOTE: add triangle to local maps is done in constructor of BoundaryTriangleSet 1413 }; 1890 } 1891 ; 1414 1892 1415 1893 /** Function adds triangle to global list. … … 1419 1897 void Tesselation::AddTesselationTriangle(const int nr) 1420 1898 { 1421 1422 Log() << Verbose(0) << "Adding triangle to global TrianglesOnBoundary map." << endl;1899 Info FunctionInfo(__func__); 1900 DoLog(0) && (Log() << Verbose(0) << "Adding triangle to global TrianglesOnBoundary map." << endl); 1423 1901 1424 1902 // add triangle to global map … … 1429 1907 1430 1908 // NOTE: add triangle to local maps is done in constructor of BoundaryTriangleSet 1431 }; 1909 } 1910 ; 1432 1911 1433 1912 /** Removes a triangle from the tesselation. … … 1438 1917 void Tesselation::RemoveTesselationTriangle(class BoundaryTriangleSet *triangle) 1439 1918 { 1440 1919 Info FunctionInfo(__func__); 1441 1920 if (triangle == NULL) 1442 1921 return; 1443 1922 for (int i = 0; i < 3; i++) { 1444 1923 if (triangle->lines[i] != NULL) { 1445 Log() << Verbose(0) << "Removing triangle Nr." << triangle->Nr << " in line " << *triangle->lines[i] << "." << endl;1924 DoLog(0) && (Log() << Verbose(0) << "Removing triangle Nr." << triangle->Nr << " in line " << *triangle->lines[i] << "." << endl); 1446 1925 triangle->lines[i]->triangles.erase(triangle->Nr); 1447 1926 if (triangle->lines[i]->triangles.empty()) { 1448 Log() << Verbose(0) << *triangle->lines[i] << " is no more attached to any triangle, erasing." << endl;1449 1927 DoLog(0) && (Log() << Verbose(0) << *triangle->lines[i] << " is no more attached to any triangle, erasing." << endl); 1928 RemoveTesselationLine(triangle->lines[i]); 1450 1929 } else { 1451 Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: "; 1452 for(TriangleMap::iterator TriangleRunner = triangle->lines[i]->triangles.begin(); TriangleRunner != triangle->lines[i]->triangles.end(); TriangleRunner++) 1453 Log() << Verbose(0) << "[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t"; 1454 Log() << Verbose(0) << endl; 1455 // for (int j=0;j<2;j++) { 1456 // Log() << Verbose(0) << "Lines of endpoint " << *(triangle->lines[i]->endpoints[j]) << ": "; 1457 // for(LineMap::iterator LineRunner = triangle->lines[i]->endpoints[j]->lines.begin(); LineRunner != triangle->lines[i]->endpoints[j]->lines.end(); LineRunner++) 1458 // Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t"; 1459 // Log() << Verbose(0) << endl; 1460 // } 1930 DoLog(0) && (Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: "); 1931 OpenLines.insert(pair<BoundaryLineSet *, CandidateForTesselation *> (triangle->lines[i], NULL)); 1932 for (TriangleMap::iterator TriangleRunner = triangle->lines[i]->triangles.begin(); TriangleRunner != triangle->lines[i]->triangles.end(); TriangleRunner++) 1933 DoLog(0) && (Log() << Verbose(0) << "[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t"); 1934 DoLog(0) && (Log() << Verbose(0) << endl); 1935 // for (int j=0;j<2;j++) { 1936 // Log() << Verbose(0) << "Lines of endpoint " << *(triangle->lines[i]->endpoints[j]) << ": "; 1937 // for(LineMap::iterator LineRunner = triangle->lines[i]->endpoints[j]->lines.begin(); LineRunner != triangle->lines[i]->endpoints[j]->lines.end(); LineRunner++) 1938 // Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t"; 1939 // Log() << Verbose(0) << endl; 1940 // } 1461 1941 } 1462 triangle->lines[i] = NULL; 1942 triangle->lines[i] = NULL; // free'd or not: disconnect 1463 1943 } else 1464 eLog() << Verbose(1) << "This line " << i << " has already been free'd." << endl;1944 DoeLog(1) && (eLog() << Verbose(1) << "This line " << i << " has already been free'd." << endl); 1465 1945 } 1466 1946 1467 1947 if (TrianglesOnBoundary.erase(triangle->Nr)) 1468 Log() << Verbose(0) << "Removing triangle Nr. " << triangle->Nr << "." << endl; 1469 delete(triangle); 1470 }; 1948 DoLog(0) && (Log() << Verbose(0) << "Removing triangle Nr. " << triangle->Nr << "." << endl); 1949 delete (triangle); 1950 } 1951 ; 1471 1952 1472 1953 /** Removes a line from the tesselation. … … 1476 1957 void Tesselation::RemoveTesselationLine(class BoundaryLineSet *line) 1477 1958 { 1478 1959 Info FunctionInfo(__func__); 1479 1960 int Numbers[2]; 1480 1961 … … 1497 1978 for (LineMap::iterator Runner = erasor.first; Runner != erasor.second; Runner++) 1498 1979 if ((*Runner).second == line) { 1499 Log() << Verbose(0) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl;1980 DoLog(0) && (Log() << Verbose(0) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl); 1500 1981 line->endpoints[i]->lines.erase(Runner); 1501 1982 break; … … 1503 1984 } else { // there's just a single line left 1504 1985 if (line->endpoints[i]->lines.erase(line->Nr)) 1505 Log() << Verbose(0) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl;1986 DoLog(0) && (Log() << Verbose(0) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl); 1506 1987 } 1507 1988 if (line->endpoints[i]->lines.empty()) { 1508 Log() << Verbose(0) << *line->endpoints[i] << " has no more lines it's attached to, erasing." << endl;1989 DoLog(0) && (Log() << Verbose(0) << *line->endpoints[i] << " has no more lines it's attached to, erasing." << endl); 1509 1990 RemoveTesselationPoint(line->endpoints[i]); 1510 1991 } else { 1511 Log() << Verbose(0) << *line->endpoints[i] << " has still lines it's attached to: ";1512 for (LineMap::iterator LineRunner = line->endpoints[i]->lines.begin(); LineRunner != line->endpoints[i]->lines.end(); LineRunner++)1513 Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t";1514 Log() << Verbose(0) << endl;1992 DoLog(0) && (Log() << Verbose(0) << *line->endpoints[i] << " has still lines it's attached to: "); 1993 for (LineMap::iterator LineRunner = line->endpoints[i]->lines.begin(); LineRunner != line->endpoints[i]->lines.end(); LineRunner++) 1994 DoLog(0) && (Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t"); 1995 DoLog(0) && (Log() << Verbose(0) << endl); 1515 1996 } 1516 line->endpoints[i] = NULL; 1997 line->endpoints[i] = NULL; // free'd or not: disconnect 1517 1998 } else 1518 eLog() << Verbose(1) << "Endpoint " << i << " has already been free'd." << endl;1999 DoeLog(1) && (eLog() << Verbose(1) << "Endpoint " << i << " has already been free'd." << endl); 1519 2000 } 1520 2001 if (!line->triangles.empty()) 1521 eLog() << Verbose(2) << "Memory Leak! I " << *line << " am still connected to some triangles." << endl;2002 DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *line << " am still connected to some triangles." << endl); 1522 2003 1523 2004 if (LinesOnBoundary.erase(line->Nr)) 1524 Log() << Verbose(0) << "Removing line Nr. " << line->Nr << "." << endl; 1525 delete(line); 1526 }; 2005 DoLog(0) && (Log() << Verbose(0) << "Removing line Nr. " << line->Nr << "." << endl); 2006 delete (line); 2007 } 2008 ; 1527 2009 1528 2010 /** Removes a point from the tesselation. … … 1533 2015 void Tesselation::RemoveTesselationPoint(class BoundaryPointSet *point) 1534 2016 { 1535 2017 Info FunctionInfo(__func__); 1536 2018 if (point == NULL) 1537 2019 return; 1538 2020 if (PointsOnBoundary.erase(point->Nr)) 1539 Log() << Verbose(0) << "Removing point Nr. " << point->Nr << "." << endl; 1540 delete(point); 1541 }; 2021 DoLog(0) && (Log() << Verbose(0) << "Removing point Nr. " << point->Nr << "." << endl); 2022 delete (point); 2023 } 2024 ; 2025 2026 /** Checks validity of a given sphere of a candidate line. 2027 * \sa CandidateForTesselation::CheckValidity(), which is more evolved. 2028 * We check CandidateForTesselation::OtherOptCenter 2029 * \param &CandidateLine contains other degenerated candidates which we have to subtract as well 2030 * \param RADIUS radius of sphere 2031 * \param *LC LinkedCell structure with other atoms 2032 * \return true - candidate triangle is degenerated, false - candidate triangle is not degenerated 2033 */ 2034 bool Tesselation::CheckDegeneracy(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC) const 2035 { 2036 Info FunctionInfo(__func__); 2037 2038 DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains no others points ..." << endl); 2039 bool flag = true; 2040 2041 DoLog(1) && (Log() << Verbose(1) << "Check by: draw sphere {" << CandidateLine.OtherOptCenter.x[0] << " " << CandidateLine.OtherOptCenter.x[1] << " " << CandidateLine.OtherOptCenter.x[2] << "} radius " << RADIUS << " resolution 30" << endl); 2042 // get all points inside the sphere 2043 TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, &CandidateLine.OtherOptCenter); 2044 2045 DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << CandidateLine.OtherOptCenter << ":" << endl); 2046 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 2047 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)->node->Distance(&CandidateLine.OtherOptCenter) << "." << endl); 2048 2049 // remove triangles's endpoints 2050 for (int i = 0; i < 2; i++) 2051 ListofPoints->remove(CandidateLine.BaseLine->endpoints[i]->node); 2052 2053 // remove other candidates 2054 for (TesselPointList::const_iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); ++Runner) 2055 ListofPoints->remove(*Runner); 2056 2057 // check for other points 2058 if (!ListofPoints->empty()) { 2059 DoLog(1) && (Log() << Verbose(1) << "CheckDegeneracy: There are still " << ListofPoints->size() << " points inside the sphere." << endl); 2060 flag = false; 2061 DoLog(1) && (Log() << Verbose(1) << "External atoms inside of sphere at " << CandidateLine.OtherOptCenter << ":" << endl); 2062 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 2063 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)->node->Distance(&CandidateLine.OtherOptCenter) << "." << endl); 2064 } 2065 delete (ListofPoints); 2066 2067 return flag; 2068 } 2069 ; 1542 2070 1543 2071 /** Checks whether the triangle consisting of the three points is already present. … … 1552 2080 int Tesselation::CheckPresenceOfTriangle(TesselPoint *Candidates[3]) const 1553 2081 { 1554 2082 Info FunctionInfo(__func__); 1555 2083 int adjacentTriangleCount = 0; 1556 2084 class BoundaryPointSet *Points[3]; … … 1574 2102 for (; (FindLine != Points[i]->lines.end()) && (FindLine->first == Points[j]->node->nr); FindLine++) { 1575 2103 TriangleMap *triangles = &FindLine->second->triangles; 1576 Log() << Verbose(1) << "Current line is " << FindLine->first << ": " << *(FindLine->second) << " with triangles " << triangles << "." << endl;2104 DoLog(1) && (Log() << Verbose(1) << "Current line is " << FindLine->first << ": " << *(FindLine->second) << " with triangles " << triangles << "." << endl); 1577 2105 for (TriangleMap::const_iterator FindTriangle = triangles->begin(); FindTriangle != triangles->end(); FindTriangle++) { 1578 2106 if (FindTriangle->second->IsPresentTupel(Points)) { … … 1580 2108 } 1581 2109 } 1582 Log() << Verbose(1) << "end." << endl;2110 DoLog(1) && (Log() << Verbose(1) << "end." << endl); 1583 2111 } 1584 2112 // Only one of the triangle lines must be considered for the triangle count. … … 1590 2118 } 1591 2119 1592 Log() << Verbose(0) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl;2120 DoLog(0) && (Log() << Verbose(0) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl); 1593 2121 return adjacentTriangleCount; 1594 }; 2122 } 2123 ; 1595 2124 1596 2125 /** Checks whether the triangle consisting of the three points is already present. … … 1604 2133 class BoundaryTriangleSet * Tesselation::GetPresentTriangle(TesselPoint *Candidates[3]) 1605 2134 { 1606 2135 Info FunctionInfo(__func__); 1607 2136 class BoundaryTriangleSet *triangle = NULL; 1608 2137 class BoundaryPointSet *Points[3]; … … 1642 2171 1643 2172 return triangle; 1644 } ;1645 2173 } 2174 ; 1646 2175 1647 2176 /** Finds the starting triangle for FindNonConvexBorder(). … … 1652 2181 * \param RADIUS radius of virtual rolling sphere 1653 2182 * \param *LC LinkedCell structure with neighbouring TesselPoint's 1654 */ 1655 void Tesselation::FindStartingTriangle(const double RADIUS, const LinkedCell *LC) 1656 { 1657 Info FunctionInfo(__func__); 2183 * \return true - a starting triangle has been created, false - no valid triple of points found 2184 */ 2185 bool Tesselation::FindStartingTriangle(const double RADIUS, const LinkedCell *LC) 2186 { 2187 Info FunctionInfo(__func__); 1658 2188 int i = 0; 1659 2189 TesselPoint* MaxPoint[NDIM]; 1660 2190 TesselPoint* Temporary; 1661 2191 double maxCoordinate[NDIM]; 1662 BoundaryLineSet BaseLine; 1663 Vector Oben; 2192 BoundaryLineSet *BaseLine = NULL; 1664 2193 Vector helper; 1665 2194 Vector Chord; 1666 2195 Vector SearchDirection; 1667 1668 Oben.Zero(); 2196 Vector CircleCenter; // center of the circle, i.e. of the band of sphere's centers 2197 Vector CirclePlaneNormal; // normal vector defining the plane this circle lives in 2198 Vector SphereCenter; 2199 Vector NormalVector; 2200 2201 NormalVector.Zero(); 1669 2202 1670 2203 for (i = 0; i < 3; i++) { … … 1674 2207 1675 2208 // 1. searching topmost point with respect to each axis 1676 for (int i =0;i<NDIM;i++) { // each axis1677 LC->n[i] = LC->N[i] -1; // current axis is topmost cell1678 for (LC->n[(i +1)%NDIM]=0;LC->n[(i+1)%NDIM]<LC->N[(i+1)%NDIM];LC->n[(i+1)%NDIM]++)1679 for (LC->n[(i +2)%NDIM]=0;LC->n[(i+2)%NDIM]<LC->N[(i+2)%NDIM];LC->n[(i+2)%NDIM]++) {1680 const Linked Nodes *List = LC->GetCurrentCell();2209 for (int i = 0; i < NDIM; i++) { // each axis 2210 LC->n[i] = LC->N[i] - 1; // current axis is topmost cell 2211 for (LC->n[(i + 1) % NDIM] = 0; LC->n[(i + 1) % NDIM] < LC->N[(i + 1) % NDIM]; LC->n[(i + 1) % NDIM]++) 2212 for (LC->n[(i + 2) % NDIM] = 0; LC->n[(i + 2) % NDIM] < LC->N[(i + 2) % NDIM]; LC->n[(i + 2) % NDIM]++) { 2213 const LinkedCell::LinkedNodes *List = LC->GetCurrentCell(); 1681 2214 //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl; 1682 2215 if (List != NULL) { 1683 for (Linked Nodes::const_iterator Runner = List->begin();Runner != List->end();Runner++) {2216 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 1684 2217 if ((*Runner)->node->x[i] > maxCoordinate[i]) { 1685 Log() << Verbose(1) << "New maximal for axis " << i << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl;2218 DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << i << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl); 1686 2219 maxCoordinate[i] = (*Runner)->node->x[i]; 1687 2220 MaxPoint[i] = (*Runner); … … 1689 2222 } 1690 2223 } else { 1691 eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl;2224 DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl); 1692 2225 } 1693 2226 } 1694 2227 } 1695 2228 1696 Log() << Verbose(1) << "Found maximum coordinates: ";1697 for (int i =0;i<NDIM;i++)1698 Log() << Verbose(0) << i << ": " << *MaxPoint[i] << "\t";1699 Log() << Verbose(0) << endl;2229 DoLog(1) && (Log() << Verbose(1) << "Found maximum coordinates: "); 2230 for (int i = 0; i < NDIM; i++) 2231 DoLog(0) && (Log() << Verbose(0) << i << ": " << *MaxPoint[i] << "\t"); 2232 DoLog(0) && (Log() << Verbose(0) << endl); 1700 2233 1701 2234 BTS = NULL; 1702 for (int k=0;k<NDIM;k++) { 1703 Oben.Zero(); 1704 Oben.x[k] = 1.; 1705 BaseLine.endpoints[0] = new BoundaryPointSet(MaxPoint[k]); 1706 Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine.endpoints[0]->node << "." << endl; 2235 for (int k = 0; k < NDIM; k++) { 2236 NormalVector.Zero(); 2237 NormalVector.x[k] = 1.; 2238 BaseLine = new BoundaryLineSet(); 2239 BaseLine->endpoints[0] = new BoundaryPointSet(MaxPoint[k]); 2240 DoLog(0) && (Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine->endpoints[0]->node << "." << endl); 1707 2241 1708 2242 double ShortestAngle; 1709 2243 ShortestAngle = 999999.; // This will contain the angle, which will be always positive (when looking for second point), when looking for third point this will be the quadrant. 1710 2244 1711 FindSecondPointForTesselation(BaseLine.endpoints[0]->node, Oben, Temporary, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_... 1712 if (Temporary == NULL) // have we found a second point? 2245 Temporary = NULL; 2246 FindSecondPointForTesselation(BaseLine->endpoints[0]->node, NormalVector, Temporary, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_... 2247 if (Temporary == NULL) { 2248 // have we found a second point? 2249 delete BaseLine; 1713 2250 continue; 1714 BaseLine.endpoints[1] = new BoundaryPointSet(Temporary); 1715 1716 helper.CopyVector(BaseLine.endpoints[0]->node->node); 1717 helper.SubtractVector(BaseLine.endpoints[1]->node->node); 1718 helper.Normalize(); 1719 Oben.ProjectOntoPlane(&helper); 1720 Oben.Normalize(); 1721 helper.VectorProduct(&Oben); 1722 ShortestAngle = 2.*M_PI; // This will indicate the quadrant. 1723 1724 Chord.CopyVector(BaseLine.endpoints[0]->node->node); // bring into calling function 1725 Chord.SubtractVector(BaseLine.endpoints[1]->node->node); 1726 double radius = Chord.ScalarProduct(&Chord); 1727 double CircleRadius = sqrt(RADIUS*RADIUS - radius/4.); 1728 helper.CopyVector(&Oben); 1729 helper.Scale(CircleRadius); 1730 // Now, oben and helper are two orthonormalized vectors in the plane defined by Chord (not normalized) 2251 } 2252 BaseLine->endpoints[1] = new BoundaryPointSet(Temporary); 2253 2254 // construct center of circle 2255 CircleCenter.CopyVector(BaseLine->endpoints[0]->node->node); 2256 CircleCenter.AddVector(BaseLine->endpoints[1]->node->node); 2257 CircleCenter.Scale(0.5); 2258 2259 // construct normal vector of circle 2260 CirclePlaneNormal.CopyVector(BaseLine->endpoints[0]->node->node); 2261 CirclePlaneNormal.SubtractVector(BaseLine->endpoints[1]->node->node); 2262 2263 double radius = CirclePlaneNormal.NormSquared(); 2264 double CircleRadius = sqrt(RADIUS * RADIUS - radius / 4.); 2265 2266 NormalVector.ProjectOntoPlane(&CirclePlaneNormal); 2267 NormalVector.Normalize(); 2268 ShortestAngle = 2. * M_PI; // This will indicate the quadrant. 2269 2270 SphereCenter.CopyVector(&NormalVector); 2271 SphereCenter.Scale(CircleRadius); 2272 SphereCenter.AddVector(&CircleCenter); 2273 // Now, NormalVector and SphereCenter are two orthonormalized vectors in the plane defined by CirclePlaneNormal (not normalized) 1731 2274 1732 2275 // look in one direction of baseline for initial candidate 1733 SearchDirection.MakeNormalVector(&C hord, &Oben);// whether we look "left" first or "right" first is not important ...2276 SearchDirection.MakeNormalVector(&CirclePlaneNormal, &NormalVector); // whether we look "left" first or "right" first is not important ... 1734 2277 1735 2278 // adding point 1 and point 2 and add the line between them 1736 Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine.endpoints[0]->node << "." << endl;1737 Log() << Verbose(0) << "Found second point is at " << *BaseLine.endpoints[1]->node << ".\n";2279 DoLog(0) && (Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine->endpoints[0]->node << "." << endl); 2280 DoLog(0) && (Log() << Verbose(0) << "Found second point is at " << *BaseLine->endpoints[1]->node << ".\n"); 1738 2281 1739 2282 //Log() << Verbose(1) << "INFO: OldSphereCenter is at " << helper << ".\n"; 1740 CandidateForTesselation OptCandidates( &BaseLine);1741 FindThirdPointForTesselation( Oben, SearchDirection, helper, OptCandidates, NULL, RADIUS, LC);1742 Log() << Verbose(0) << "List of third Points is:" << endl;2283 CandidateForTesselation OptCandidates(BaseLine); 2284 FindThirdPointForTesselation(NormalVector, SearchDirection, SphereCenter, OptCandidates, NULL, RADIUS, LC); 2285 DoLog(0) && (Log() << Verbose(0) << "List of third Points is:" << endl); 1743 2286 for (TesselPointList::iterator it = OptCandidates.pointlist.begin(); it != OptCandidates.pointlist.end(); it++) { 1744 Log() << Verbose(0) << " " << *(*it) << endl; 1745 } 1746 1747 BTS = NULL; 1748 AddCandidateTriangle(OptCandidates); 1749 // delete(BaseLine.endpoints[0]); 1750 // delete(BaseLine.endpoints[1]); 1751 1752 if (BTS != NULL) // we have created one starting triangle 2287 DoLog(0) && (Log() << Verbose(0) << " " << *(*it) << endl); 2288 } 2289 if (!OptCandidates.pointlist.empty()) { 2290 BTS = NULL; 2291 AddCandidatePolygon(OptCandidates, RADIUS, LC); 2292 } else { 2293 delete BaseLine; 2294 continue; 2295 } 2296 2297 if (BTS != NULL) { // we have created one starting triangle 2298 delete BaseLine; 1753 2299 break; 1754 else {2300 } else { 1755 2301 // remove all candidates from the list and then the list itself 1756 2302 OptCandidates.pointlist.clear(); 1757 2303 } 1758 } 1759 }; 2304 delete BaseLine; 2305 } 2306 2307 return (BTS != NULL); 2308 } 2309 ; 1760 2310 1761 2311 /** Checks for a given baseline and a third point candidate whether baselines of the found triangle don't have even better candidates. … … 1828 2378 // if (fabs(OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { 1829 2379 // // rotated the wrong way! 1830 // eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl;2380 // DoeLog(1) && (eLog()<< Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl); 1831 2381 // } 1832 2382 // … … 1885 2435 // } 1886 2436 // } else { 1887 // eLog() << Verbose(2) << "Baseline is connected to two triangles already?" << endl;2437 // DoeLog(2) && (eLog()<< Verbose(2) << "Baseline is connected to two triangles already?" << endl); 1888 2438 // } 1889 2439 // } else { … … 1892 2442 // } 1893 2443 // } else { 1894 // eLog() << Verbose(1) << "Could not find the TesselPoint " << *ThirdNode << "." << endl;2444 // DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the TesselPoint " << *ThirdNode << "." << endl); 1895 2445 // } 1896 2446 // … … 1906 2456 * @param *LC LinkedCell structure with neighbouring points 1907 2457 */ 1908 bool Tesselation::FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC) 1909 { 1910 Info FunctionInfo(__func__); 1911 bool result = true; 1912 2458 bool Tesselation::FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, const BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC) 2459 { 2460 Info FunctionInfo(__func__); 1913 2461 Vector CircleCenter; 1914 2462 Vector CirclePlaneNormal; 1915 Vector OldSphereCenter;2463 Vector RelativeSphereCenter; 1916 2464 Vector SearchDirection; 1917 2465 Vector helper; 1918 TesselPoint *ThirdNode= NULL;2466 BoundaryPointSet *ThirdPoint = NULL; 1919 2467 LineMap::iterator testline; 1920 2468 double radius, CircleRadius; 1921 2469 1922 Log() << Verbose(0) << "Current baseline is " << *CandidateLine.BaseLine << " of triangle " << T << "." << endl; 1923 for (int i=0;i<3;i++) 1924 if ((T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[0]->node) && (T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[1]->node)) 1925 ThirdNode = T.endpoints[i]->node; 2470 for (int i = 0; i < 3; i++) 2471 if ((T.endpoints[i] != CandidateLine.BaseLine->endpoints[0]) && (T.endpoints[i] != CandidateLine.BaseLine->endpoints[1])) { 2472 ThirdPoint = T.endpoints[i]; 2473 break; 2474 } 2475 DoLog(0) && (Log() << Verbose(0) << "Current baseline is " << *CandidateLine.BaseLine << " with ThirdPoint " << *ThirdPoint << " of triangle " << T << "." << endl); 2476 2477 CandidateLine.T = &T; 1926 2478 1927 2479 // construct center of circle … … 1936 2488 // calculate squared radius of circle 1937 2489 radius = CirclePlaneNormal.ScalarProduct(&CirclePlaneNormal); 1938 if (radius/4. < RADIUS*RADIUS) { 1939 CircleRadius = RADIUS*RADIUS - radius/4.; 2490 if (radius / 4. < RADIUS * RADIUS) { 2491 // construct relative sphere center with now known CircleCenter 2492 RelativeSphereCenter.CopyVector(&T.SphereCenter); 2493 RelativeSphereCenter.SubtractVector(&CircleCenter); 2494 2495 CircleRadius = RADIUS * RADIUS - radius / 4.; 1940 2496 CirclePlaneNormal.Normalize(); 1941 Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl; 1942 1943 // construct old center 1944 GetCenterofCircumcircle(&OldSphereCenter, *T.endpoints[0]->node->node, *T.endpoints[1]->node->node, *T.endpoints[2]->node->node); 1945 helper.CopyVector(&T.NormalVector); // normal vector ensures that this is correct center of the two possible ones 1946 radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(&OldSphereCenter); 1947 helper.Scale(sqrt(RADIUS*RADIUS - radius)); 1948 OldSphereCenter.AddVector(&helper); 1949 OldSphereCenter.SubtractVector(&CircleCenter); 1950 Log() << Verbose(1) << "INFO: OldSphereCenter is at " << OldSphereCenter << "." << endl; 1951 1952 // construct SearchDirection 1953 SearchDirection.MakeNormalVector(&T.NormalVector, &CirclePlaneNormal); 1954 helper.CopyVector(CandidateLine.BaseLine->endpoints[0]->node->node); 1955 helper.SubtractVector(ThirdNode->node); 2497 DoLog(1) && (Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl); 2498 2499 DoLog(1) && (Log() << Verbose(1) << "INFO: OldSphereCenter is at " << T.SphereCenter << "." << endl); 2500 2501 // construct SearchDirection and an "outward pointer" 2502 SearchDirection.MakeNormalVector(&RelativeSphereCenter, &CirclePlaneNormal); 2503 helper.CopyVector(&CircleCenter); 2504 helper.SubtractVector(ThirdPoint->node->node); 1956 2505 if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards! 1957 2506 SearchDirection.Scale(-1.); 1958 SearchDirection.ProjectOntoPlane(&OldSphereCenter); 1959 SearchDirection.Normalize(); 1960 Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl; 1961 if (fabs(OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { 2507 DoLog(1) && (Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl); 2508 if (fabs(RelativeSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { 1962 2509 // rotated the wrong way! 1963 eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl;2510 DoeLog(1) && (eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl); 1964 2511 } 1965 2512 1966 2513 // add third point 1967 FindThirdPointForTesselation(T.NormalVector, SearchDirection, OldSphereCenter, CandidateLine, ThirdNode, RADIUS, LC);2514 FindThirdPointForTesselation(T.NormalVector, SearchDirection, T.SphereCenter, CandidateLine, ThirdPoint, RADIUS, LC); 1968 2515 1969 2516 } else { 1970 Log() << Verbose(0) << "Circumcircle for base line " << *CandidateLine.BaseLine << " and base triangle " << T << " is too big!" << endl;2517 DoLog(0) && (Log() << Verbose(0) << "Circumcircle for base line " << *CandidateLine.BaseLine << " and base triangle " << T << " is too big!" << endl); 1971 2518 } 1972 2519 1973 2520 if (CandidateLine.pointlist.empty()) { 1974 eLog() << Verbose(2) << "Could not find a suitable candidate." << endl;2521 DoeLog(2) && (eLog() << Verbose(2) << "Could not find a suitable candidate." << endl); 1975 2522 return false; 1976 2523 } 1977 Log() << Verbose(0) << "Third Points are: " << endl;2524 DoLog(0) && (Log() << Verbose(0) << "Third Points are: " << endl); 1978 2525 for (TesselPointList::iterator it = CandidateLine.pointlist.begin(); it != CandidateLine.pointlist.end(); ++it) { 1979 Log() << Verbose(0) << " " << *(*it) << endl;2526 DoLog(0) && (Log() << Verbose(0) << " " << *(*it) << endl); 1980 2527 } 1981 2528 1982 2529 return true; 1983 1984 // BoundaryLineSet *BaseRay = CandidateLine.BaseLine; 1985 // for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) { 1986 // Log() << Verbose(0) << "Third point candidate is " << *(*it)->point 1987 // << " with circumsphere's center at " << (*it)->OptCenter << "." << endl; 1988 // Log() << Verbose(0) << "Baseline is " << *BaseRay << endl; 1989 // 1990 // // check whether all edges of the new triangle still have space for one more triangle (i.e. TriangleCount <2) 1991 // TesselPoint *PointCandidates[3]; 1992 // PointCandidates[0] = (*it)->point; 1993 // PointCandidates[1] = BaseRay->endpoints[0]->node; 1994 // PointCandidates[2] = BaseRay->endpoints[1]->node; 1995 // int existentTrianglesCount = CheckPresenceOfTriangle(PointCandidates); 1996 // 1997 // BTS = NULL; 1998 // // check for present edges and whether we reach better candidates from them 1999 // //if (HasOtherBaselineBetterCandidate(BaseRay, (*it)->point, ShortestAngle, RADIUS, LC) ) { 2000 // if (0) { 2001 // result = false; 2002 // break; 2003 // } else { 2004 // // If there is no triangle, add it regularly. 2005 // if (existentTrianglesCount == 0) { 2006 // AddTesselationPoint((*it)->point, 0); 2007 // AddTesselationPoint(BaseRay->endpoints[0]->node, 1); 2008 // AddTesselationPoint(BaseRay->endpoints[1]->node, 2); 2009 // 2010 // if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const )TPS)) { 2011 // CandidateLine.point = (*it)->point; 2012 // CandidateLine.OptCenter.CopyVector(&((*it)->OptCenter)); 2013 // CandidateLine.OtherOptCenter.CopyVector(&((*it)->OtherOptCenter)); 2014 // CandidateLine.ShortestAngle = ShortestAngle; 2015 // } else { 2016 //// eLog() << Verbose(1) << "This triangle consisting of "; 2017 //// Log() << Verbose(0) << *(*it)->point << ", "; 2018 //// Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and "; 2019 //// Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " "; 2020 //// Log() << Verbose(0) << "exists and is not added, as it 0x80000000006fc150(does not seem helpful!" << endl; 2021 // result = false; 2022 // } 2023 // } else if ((existentTrianglesCount >= 1) && (existentTrianglesCount <= 3)) { // If there is a planar region within the structure, we need this triangle a second time. 2024 // AddTesselationPoint((*it)->point, 0); 2025 // AddTesselationPoint(BaseRay->endpoints[0]->node, 1); 2026 // AddTesselationPoint(BaseRay->endpoints[1]->node, 2); 2027 // 2028 // // We demand that at most one new degenerate line is created and that this line also already exists (which has to be the case due to existentTrianglesCount == 1) 2029 // // i.e. at least one of the three lines must be present with TriangleCount <= 1 2030 // if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const)TPS) || CandidateLine.BaseLine->skipped) { 2031 // CandidateLine.point = (*it)->point; 2032 // CandidateLine.OptCenter.CopyVector(&(*it)->OptCenter); 2033 // CandidateLine.OtherOptCenter.CopyVector(&(*it)->OtherOptCenter); 2034 // CandidateLine.ShortestAngle = ShortestAngle+2.*M_PI; 2035 // 2036 // } else { 2037 //// eLog() << Verbose(1) << "This triangle consisting of " << *(*it)->point << ", " << *BaseRay->endpoints[0]->node << " and " << *BaseRay->endpoints[1]->node << " " << "exists and is not added, as it does not seem helpful!" << endl; 2038 // result = false; 2039 // } 2040 // } else { 2041 //// Log() << Verbose(1) << "This triangle consisting of "; 2042 //// Log() << Verbose(0) << *(*it)->point << ", "; 2043 //// Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and "; 2044 //// Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " "; 2045 //// Log() << Verbose(0) << "is invalid!" << endl; 2046 // result = false; 2047 // } 2048 // } 2049 // 2050 // // set baseline to new ray from ref point (here endpoints[0]->node) to current candidate (here (*it)->point)) 2051 // BaseRay = BLS[0]; 2052 // if ((BTS != NULL) && (BTS->NormalVector.NormSquared() < MYEPSILON)) { 2053 // eLog() << Verbose(1) << "Triangle " << *BTS << " has zero normal vector!" << endl; 2054 // exit(255); 2055 // } 2056 // 2057 // } 2058 // 2059 // // remove all candidates from the list and then the list itself 2060 // class CandidateForTesselation *remover = NULL; 2061 // for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) { 2062 // remover = *it; 2063 // delete(remover); 2064 // } 2065 // delete(OptCandidates); 2066 return result; 2067 }; 2530 } 2531 ; 2532 2533 /** Walks through Tesselation::OpenLines() and finds candidates for newly created ones. 2534 * \param *&LCList atoms in LinkedCell list 2535 * \param RADIUS radius of the virtual sphere 2536 * \return true - for all open lines without candidates so far, a candidate has been found, 2537 * false - at least one open line without candidate still 2538 */ 2539 bool Tesselation::FindCandidatesforOpenLines(const double RADIUS, const LinkedCell *&LCList) 2540 { 2541 bool TesselationFailFlag = true; 2542 CandidateForTesselation *baseline = NULL; 2543 BoundaryTriangleSet *T = NULL; 2544 2545 for (CandidateMap::iterator Runner = OpenLines.begin(); Runner != OpenLines.end(); Runner++) { 2546 baseline = Runner->second; 2547 if (baseline->pointlist.empty()) { 2548 assert((baseline->BaseLine->triangles.size() == 1) && ("Open line without exactly one attached triangle")); 2549 T = (((baseline->BaseLine->triangles.begin()))->second); 2550 DoLog(1) && (Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl); 2551 TesselationFailFlag = TesselationFailFlag && FindNextSuitableTriangle(*baseline, *T, RADIUS, LCList); //the line is there, so there is a triangle, but only one. 2552 } 2553 } 2554 return TesselationFailFlag; 2555 } 2556 ; 2068 2557 2069 2558 /** Adds the present line and candidate point from \a &CandidateLine to the Tesselation. 2070 2559 * \param CandidateLine triangle to add 2071 * \NOTE we need the copy operator here as the original CandidateForTesselation is removed in AddTesselationLine() 2072 */ 2073 void Tesselation::AddCandidateTriangle(CandidateForTesselation CandidateLine) 2074 { 2075 Info FunctionInfo(__func__); 2560 * \param RADIUS Radius of sphere 2561 * \param *LC LinkedCell structure 2562 * \NOTE we need the copy operator here as the original CandidateForTesselation is removed in 2563 * AddTesselationLine() in AddCandidateTriangle() 2564 */ 2565 void Tesselation::AddCandidatePolygon(CandidateForTesselation CandidateLine, const double RADIUS, const LinkedCell *LC) 2566 { 2567 Info FunctionInfo(__func__); 2076 2568 Vector Center; 2077 2569 TesselPoint * const TurningPoint = CandidateLine.BaseLine->endpoints[0]->node; 2570 TesselPointList::iterator Runner; 2571 TesselPointList::iterator Sprinter; 2078 2572 2079 2573 // fill the set of neighbours 2080 Center.CopyVector(CandidateLine.BaseLine->endpoints[1]->node->node); 2081 Center.SubtractVector(TurningPoint->node); 2082 set<TesselPoint*> SetOfNeighbours; 2574 TesselPointSet SetOfNeighbours; 2083 2575 SetOfNeighbours.insert(CandidateLine.BaseLine->endpoints[1]->node); 2084 2576 for (TesselPointList::iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); Runner++) 2085 2577 SetOfNeighbours.insert(*Runner); 2086 TesselPointList *connectedClosestPoints = GetCircleOfSetOfPoints(&SetOfNeighbours, TurningPoint, &Center); 2578 TesselPointList *connectedClosestPoints = GetCircleOfSetOfPoints(&SetOfNeighbours, TurningPoint, CandidateLine.BaseLine->endpoints[1]->node->node); 2579 2580 DoLog(0) && (Log() << Verbose(0) << "List of Candidates for Turning Point " << *TurningPoint << ":" << endl); 2581 for (TesselPointList::iterator TesselRunner = connectedClosestPoints->begin(); TesselRunner != connectedClosestPoints->end(); ++TesselRunner) 2582 DoLog(0) && (Log() << Verbose(0) << " " << **TesselRunner << endl); 2087 2583 2088 2584 // go through all angle-sorted candidates (in degenerate n-nodes case we may have to add multiple triangles) 2089 TesselPointList::iteratorRunner = connectedClosestPoints->begin();2090 TesselPointList::iteratorSprinter = Runner;2585 Runner = connectedClosestPoints->begin(); 2586 Sprinter = Runner; 2091 2587 Sprinter++; 2092 while(Sprinter != connectedClosestPoints->end()) { 2093 // add the points 2588 while (Sprinter != connectedClosestPoints->end()) { 2589 DoLog(0) && (Log() << Verbose(0) << "Current Runner is " << *(*Runner) << " and sprinter is " << *(*Sprinter) << "." << endl); 2590 2094 2591 AddTesselationPoint(TurningPoint, 0); 2095 AddTesselationPoint((*Runner), 1); 2096 AddTesselationPoint((*Sprinter), 2); 2097 2098 Center.CopyVector(&CandidateLine.OptCenter); 2099 // add the lines 2100 AddTesselationLine(TPS[0], TPS[1], 0); 2101 AddTesselationLine(TPS[0], TPS[2], 1); 2102 AddTesselationLine(TPS[1], TPS[2], 2); 2103 2104 // add the triangles 2105 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 2106 AddTesselationTriangle(); 2107 Center.Scale(-1.); 2108 BTS->GetNormalVector(Center); 2109 2110 Log() << Verbose(0) << "--> New triangle with " << *BTS << " and normal vector " << BTS->NormalVector << "." << endl; 2592 AddTesselationPoint(*Runner, 1); 2593 AddTesselationPoint(*Sprinter, 2); 2594 2595 AddCandidateTriangle(CandidateLine, Opt); 2596 2111 2597 Runner = Sprinter; 2112 2598 Sprinter++; 2113 } 2599 if (Sprinter != connectedClosestPoints->end()) { 2600 // fill the internal open lines with its respective candidate (otherwise lines in degenerate case are not picked) 2601 FindDegeneratedCandidatesforOpenLines(*Sprinter, &CandidateLine.OptCenter); // Assume BTS contains last triangle 2602 DoLog(0) && (Log() << Verbose(0) << " There are still more triangles to add." << endl); 2603 } 2604 // pick candidates for other open lines as well 2605 FindCandidatesforOpenLines(RADIUS, LC); 2606 2607 // check whether we add a degenerate or a normal triangle 2608 if (CheckDegeneracy(CandidateLine, RADIUS, LC)) { 2609 // add normal and degenerate triangles 2610 DoLog(1) && (Log() << Verbose(1) << "Triangle of endpoints " << *TPS[0] << "," << *TPS[1] << " and " << *TPS[2] << " is degenerated, adding both sides." << endl); 2611 AddCandidateTriangle(CandidateLine, OtherOpt); 2612 2613 if (Sprinter != connectedClosestPoints->end()) { 2614 // fill the internal open lines with its respective candidate (otherwise lines in degenerate case are not picked) 2615 FindDegeneratedCandidatesforOpenLines(*Sprinter, &CandidateLine.OtherOptCenter); 2616 } 2617 // pick candidates for other open lines as well 2618 FindCandidatesforOpenLines(RADIUS, LC); 2619 } 2620 } 2621 delete (connectedClosestPoints); 2114 2622 }; 2623 2624 /** for polygons (multiple candidates for a baseline) sets internal edges to the correct next candidate. 2625 * \param *Sprinter next candidate to which internal open lines are set 2626 * \param *OptCenter OptCenter for this candidate 2627 */ 2628 void Tesselation::FindDegeneratedCandidatesforOpenLines(TesselPoint * const Sprinter, const Vector * const OptCenter) 2629 { 2630 Info FunctionInfo(__func__); 2631 2632 pair<LineMap::iterator, LineMap::iterator> FindPair = TPS[0]->lines.equal_range(TPS[2]->node->nr); 2633 for (LineMap::const_iterator FindLine = FindPair.first; FindLine != FindPair.second; FindLine++) { 2634 DoLog(1) && (Log() << Verbose(1) << "INFO: Checking line " << *(FindLine->second) << " ..." << endl); 2635 // If there is a line with less than two attached triangles, we don't need a new line. 2636 if (FindLine->second->triangles.size() == 1) { 2637 CandidateMap::iterator Finder = OpenLines.find(FindLine->second); 2638 if (!Finder->second->pointlist.empty()) 2639 DoLog(1) && (Log() << Verbose(1) << "INFO: line " << *(FindLine->second) << " is open with candidate " << **(Finder->second->pointlist.begin()) << "." << endl); 2640 else { 2641 DoLog(1) && (Log() << Verbose(1) << "INFO: line " << *(FindLine->second) << " is open with no candidate, setting to next Sprinter" << (*Sprinter) << endl); 2642 Finder->second->T = BTS; // is last triangle 2643 Finder->second->pointlist.push_back(Sprinter); 2644 Finder->second->ShortestAngle = 0.; 2645 Finder->second->OptCenter.CopyVector(OptCenter); 2646 } 2647 } 2648 } 2649 }; 2650 2651 /** If a given \a *triangle is degenerated, this adds both sides. 2652 * i.e. the triangle with same BoundaryPointSet's but NormalVector in opposite direction. 2653 * Note that endpoints are stored in Tesselation::TPS 2654 * \param CandidateLine CanddiateForTesselation structure for the desired BoundaryLine 2655 * \param RADIUS radius of sphere 2656 * \param *LC pointer to LinkedCell structure 2657 */ 2658 void Tesselation::AddDegeneratedTriangle(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC) 2659 { 2660 Info FunctionInfo(__func__); 2661 Vector Center; 2662 CandidateMap::const_iterator CandidateCheck = OpenLines.end(); 2663 BoundaryTriangleSet *triangle = NULL; 2664 2665 /// 1. Create or pick the lines for the first triangle 2666 DoLog(0) && (Log() << Verbose(0) << "INFO: Creating/Picking lines for first triangle ..." << endl); 2667 for (int i = 0; i < 3; i++) { 2668 BLS[i] = NULL; 2669 DoLog(0) && (Log() << Verbose(0) << "Current line is between " << *TPS[(i + 0) % 3] << " and " << *TPS[(i + 1) % 3] << ":" << endl); 2670 AddTesselationLine(&CandidateLine.OptCenter, TPS[(i + 2) % 3], TPS[(i + 0) % 3], TPS[(i + 1) % 3], i); 2671 } 2672 2673 /// 2. create the first triangle and NormalVector and so on 2674 DoLog(0) && (Log() << Verbose(0) << "INFO: Adding first triangle with center at " << CandidateLine.OptCenter << " ..." << endl); 2675 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 2676 AddTesselationTriangle(); 2677 2678 // create normal vector 2679 BTS->GetCenter(&Center); 2680 Center.SubtractVector(&CandidateLine.OptCenter); 2681 BTS->SphereCenter.CopyVector(&CandidateLine.OptCenter); 2682 BTS->GetNormalVector(Center); 2683 // give some verbose output about the whole procedure 2684 if (CandidateLine.T != NULL) 2685 DoLog(0) && (Log() << Verbose(0) << "--> New triangle with " << *BTS << " and normal vector " << BTS->NormalVector << ", from " << *CandidateLine.T << " and angle " << CandidateLine.ShortestAngle << "." << endl); 2686 else 2687 DoLog(0) && (Log() << Verbose(0) << "--> New starting triangle with " << *BTS << " and normal vector " << BTS->NormalVector << " and no top triangle." << endl); 2688 triangle = BTS; 2689 2690 /// 3. Gather candidates for each new line 2691 DoLog(0) && (Log() << Verbose(0) << "INFO: Adding candidates to new lines ..." << endl); 2692 for (int i = 0; i < 3; i++) { 2693 DoLog(0) && (Log() << Verbose(0) << "Current line is between " << *TPS[(i + 0) % 3] << " and " << *TPS[(i + 1) % 3] << ":" << endl); 2694 CandidateCheck = OpenLines.find(BLS[i]); 2695 if ((CandidateCheck != OpenLines.end()) && (CandidateCheck->second->pointlist.empty())) { 2696 if (CandidateCheck->second->T == NULL) 2697 CandidateCheck->second->T = triangle; 2698 FindNextSuitableTriangle(*(CandidateCheck->second), *CandidateCheck->second->T, RADIUS, LC); 2699 } 2700 } 2701 2702 /// 4. Create or pick the lines for the second triangle 2703 DoLog(0) && (Log() << Verbose(0) << "INFO: Creating/Picking lines for second triangle ..." << endl); 2704 for (int i = 0; i < 3; i++) { 2705 DoLog(0) && (Log() << Verbose(0) << "Current line is between " << *TPS[(i + 0) % 3] << " and " << *TPS[(i + 1) % 3] << ":" << endl); 2706 AddTesselationLine(&CandidateLine.OtherOptCenter, TPS[(i + 2) % 3], TPS[(i + 0) % 3], TPS[(i + 1) % 3], i); 2707 } 2708 2709 /// 5. create the second triangle and NormalVector and so on 2710 DoLog(0) && (Log() << Verbose(0) << "INFO: Adding second triangle with center at " << CandidateLine.OtherOptCenter << " ..." << endl); 2711 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 2712 AddTesselationTriangle(); 2713 2714 BTS->SphereCenter.CopyVector(&CandidateLine.OtherOptCenter); 2715 // create normal vector in other direction 2716 BTS->GetNormalVector(&triangle->NormalVector); 2717 BTS->NormalVector.Scale(-1.); 2718 // give some verbose output about the whole procedure 2719 if (CandidateLine.T != NULL) 2720 DoLog(0) && (Log() << Verbose(0) << "--> New degenerate triangle with " << *BTS << " and normal vector " << BTS->NormalVector << ", from " << *CandidateLine.T << " and angle " << CandidateLine.ShortestAngle << "." << endl); 2721 else 2722 DoLog(0) && (Log() << Verbose(0) << "--> New degenerate starting triangle with " << *BTS << " and normal vector " << BTS->NormalVector << " and no top triangle." << endl); 2723 2724 /// 6. Adding triangle to new lines 2725 DoLog(0) && (Log() << Verbose(0) << "INFO: Adding second triangles to new lines ..." << endl); 2726 for (int i = 0; i < 3; i++) { 2727 DoLog(0) && (Log() << Verbose(0) << "Current line is between " << *TPS[(i + 0) % 3] << " and " << *TPS[(i + 1) % 3] << ":" << endl); 2728 CandidateCheck = OpenLines.find(BLS[i]); 2729 if ((CandidateCheck != OpenLines.end()) && (CandidateCheck->second->pointlist.empty())) { 2730 if (CandidateCheck->second->T == NULL) 2731 CandidateCheck->second->T = BTS; 2732 } 2733 } 2734 } 2735 ; 2736 2737 /** Adds a triangle to the Tesselation structure from three given TesselPoint's. 2738 * Note that endpoints are in Tesselation::TPS. 2739 * \param CandidateLine CandidateForTesselation structure contains other information 2740 * \param type which opt center to add (i.e. which side) and thus which NormalVector to take 2741 */ 2742 void Tesselation::AddCandidateTriangle(CandidateForTesselation &CandidateLine, enum centers type) 2743 { 2744 Info FunctionInfo(__func__); 2745 Vector Center; 2746 Vector *OptCenter = (type == Opt) ? &CandidateLine.OptCenter : &CandidateLine.OtherOptCenter; 2747 2748 // add the lines 2749 AddTesselationLine(OptCenter, TPS[2], TPS[0], TPS[1], 0); 2750 AddTesselationLine(OptCenter, TPS[1], TPS[0], TPS[2], 1); 2751 AddTesselationLine(OptCenter, TPS[0], TPS[1], TPS[2], 2); 2752 2753 // add the triangles 2754 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 2755 AddTesselationTriangle(); 2756 2757 // create normal vector 2758 BTS->GetCenter(&Center); 2759 Center.SubtractVector(OptCenter); 2760 BTS->SphereCenter.CopyVector(OptCenter); 2761 BTS->GetNormalVector(Center); 2762 2763 // give some verbose output about the whole procedure 2764 if (CandidateLine.T != NULL) 2765 DoLog(0) && (Log() << Verbose(0) << "--> New" << ((type == OtherOpt) ? " degenerate " : " ") << "triangle with " << *BTS << " and normal vector " << BTS->NormalVector << ", from " << *CandidateLine.T << " and angle " << CandidateLine.ShortestAngle << "." << endl); 2766 else 2767 DoLog(0) && (Log() << Verbose(0) << "--> New" << ((type == OtherOpt) ? " degenerate " : " ") << "starting triangle with " << *BTS << " and normal vector " << BTS->NormalVector << " and no top triangle." << endl); 2768 } 2769 ; 2115 2770 2116 2771 /** Checks whether the quadragon of the two triangles connect to \a *Base is convex. … … 2123 2778 class BoundaryPointSet *Tesselation::IsConvexRectangle(class BoundaryLineSet *Base) 2124 2779 { 2125 2780 Info FunctionInfo(__func__); 2126 2781 class BoundaryPointSet *Spot = NULL; 2127 2782 class BoundaryLineSet *OtherBase; 2128 2783 Vector *ClosestPoint; 2129 2784 2130 int m =0;2131 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)2132 for (int j =0;j<3;j++) // all of their endpoints and baselines2785 int m = 0; 2786 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) 2787 for (int j = 0; j < 3; j++) // all of their endpoints and baselines 2133 2788 if (!Base->ContainsBoundaryPoint(runner->second->endpoints[j])) // and neither of its endpoints 2134 2789 BPS[m++] = runner->second->endpoints[j]; 2135 OtherBase = new class BoundaryLineSet(BPS, -1);2136 2137 Log() << Verbose(1) << "INFO: Current base line is " << *Base << "." << endl;2138 Log() << Verbose(1) << "INFO: Other base line is " << *OtherBase << "." << endl;2790 OtherBase = new class BoundaryLineSet(BPS, -1); 2791 2792 DoLog(1) && (Log() << Verbose(1) << "INFO: Current base line is " << *Base << "." << endl); 2793 DoLog(1) && (Log() << Verbose(1) << "INFO: Other base line is " << *OtherBase << "." << endl); 2139 2794 2140 2795 // get the closest point on each line to the other line … … 2142 2797 2143 2798 // delete the temporary other base line 2144 delete (OtherBase);2799 delete (OtherBase); 2145 2800 2146 2801 // get the distance vector from Base line to OtherBase line … … 2149 2804 BaseLine.CopyVector(Base->endpoints[1]->node->node); 2150 2805 BaseLine.SubtractVector(Base->endpoints[0]->node->node); 2151 for (int i =0;i<2;i++) {2806 for (int i = 0; i < 2; i++) { 2152 2807 DistanceToIntersection[i].CopyVector(ClosestPoint); 2153 2808 DistanceToIntersection[i].SubtractVector(Base->endpoints[i]->node->node); 2154 2809 distance[i] = BaseLine.ScalarProduct(&DistanceToIntersection[i]); 2155 2810 } 2156 delete (ClosestPoint);2157 if ((distance[0] * distance[1]) > 0) 2158 Log() << Verbose(1) << "REJECT: Both SKPs have same sign: " << distance[0] << " and " << distance[1] << ". " << *Base << "' rectangle is concave." << endl;2811 delete (ClosestPoint); 2812 if ((distance[0] * distance[1]) > 0) { // have same sign? 2813 DoLog(1) && (Log() << Verbose(1) << "REJECT: Both SKPs have same sign: " << distance[0] << " and " << distance[1] << ". " << *Base << "' rectangle is concave." << endl); 2159 2814 if (distance[0] < distance[1]) { 2160 2815 Spot = Base->endpoints[0]; … … 2163 2818 } 2164 2819 return Spot; 2165 } else { 2166 Log() << Verbose(0) << "ACCEPT: Rectangle of triangles of base line " << *Base << " is convex." << endl;2820 } else { // different sign, i.e. we are in between 2821 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Rectangle of triangles of base line " << *Base << " is convex." << endl); 2167 2822 return NULL; 2168 2823 } 2169 2824 2170 }; 2825 } 2826 ; 2171 2827 2172 2828 void Tesselation::PrintAllBoundaryPoints(ofstream *out) const 2173 2829 { 2174 2830 Info FunctionInfo(__func__); 2175 2831 // print all lines 2176 Log() << Verbose(0) << "Printing all boundary points for debugging:" << endl; 2177 for (PointMap::const_iterator PointRunner = PointsOnBoundary.begin();PointRunner != PointsOnBoundary.end(); PointRunner++) 2178 Log() << Verbose(0) << *(PointRunner->second) << endl; 2179 }; 2832 DoLog(0) && (Log() << Verbose(0) << "Printing all boundary points for debugging:" << endl); 2833 for (PointMap::const_iterator PointRunner = PointsOnBoundary.begin(); PointRunner != PointsOnBoundary.end(); PointRunner++) 2834 DoLog(0) && (Log() << Verbose(0) << *(PointRunner->second) << endl); 2835 } 2836 ; 2180 2837 2181 2838 void Tesselation::PrintAllBoundaryLines(ofstream *out) const 2182 2839 { 2183 2840 Info FunctionInfo(__func__); 2184 2841 // print all lines 2185 Log() << Verbose(0) << "Printing all boundary lines for debugging:" << endl;2842 DoLog(0) && (Log() << Verbose(0) << "Printing all boundary lines for debugging:" << endl); 2186 2843 for (LineMap::const_iterator LineRunner = LinesOnBoundary.begin(); LineRunner != LinesOnBoundary.end(); LineRunner++) 2187 Log() << Verbose(0) << *(LineRunner->second) << endl; 2188 }; 2844 DoLog(0) && (Log() << Verbose(0) << *(LineRunner->second) << endl); 2845 } 2846 ; 2189 2847 2190 2848 void Tesselation::PrintAllBoundaryTriangles(ofstream *out) const 2191 2849 { 2192 2850 Info FunctionInfo(__func__); 2193 2851 // print all triangles 2194 Log() << Verbose(0) << "Printing all boundary triangles for debugging:" << endl;2852 DoLog(0) && (Log() << Verbose(0) << "Printing all boundary triangles for debugging:" << endl); 2195 2853 for (TriangleMap::const_iterator TriangleRunner = TrianglesOnBoundary.begin(); TriangleRunner != TrianglesOnBoundary.end(); TriangleRunner++) 2196 Log() << Verbose(0) << *(TriangleRunner->second) << endl; 2197 }; 2854 DoLog(0) && (Log() << Verbose(0) << *(TriangleRunner->second) << endl); 2855 } 2856 ; 2198 2857 2199 2858 /** For a given boundary line \a *Base and its two triangles, picks the central baseline that is "higher". … … 2204 2863 double Tesselation::PickFarthestofTwoBaselines(class BoundaryLineSet *Base) 2205 2864 { 2206 2865 Info FunctionInfo(__func__); 2207 2866 class BoundaryLineSet *OtherBase; 2208 2867 Vector *ClosestPoint[2]; 2209 2868 double volume; 2210 2869 2211 int m =0;2212 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)2213 for (int j =0;j<3;j++) // all of their endpoints and baselines2870 int m = 0; 2871 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) 2872 for (int j = 0; j < 3; j++) // all of their endpoints and baselines 2214 2873 if (!Base->ContainsBoundaryPoint(runner->second->endpoints[j])) // and neither of its endpoints 2215 2874 BPS[m++] = runner->second->endpoints[j]; 2216 OtherBase = new class BoundaryLineSet(BPS, -1);2217 2218 Log() << Verbose(0) << "INFO: Current base line is " << *Base << "." << endl;2219 Log() << Verbose(0) << "INFO: Other base line is " << *OtherBase << "." << endl;2875 OtherBase = new class BoundaryLineSet(BPS, -1); 2876 2877 DoLog(0) && (Log() << Verbose(0) << "INFO: Current base line is " << *Base << "." << endl); 2878 DoLog(0) && (Log() << Verbose(0) << "INFO: Other base line is " << *OtherBase << "." << endl); 2220 2879 2221 2880 // get the closest point on each line to the other line … … 2232 2891 2233 2892 // delete the temporary other base line and the closest points 2234 delete (ClosestPoint[0]);2235 delete (ClosestPoint[1]);2236 delete (OtherBase);2893 delete (ClosestPoint[0]); 2894 delete (ClosestPoint[1]); 2895 delete (OtherBase); 2237 2896 2238 2897 if (Distance.NormSquared() < MYEPSILON) { // check for intersection 2239 Log() << Verbose(0) << "REJECT: Both lines have an intersection: Nothing to do." << endl;2898 DoLog(0) && (Log() << Verbose(0) << "REJECT: Both lines have an intersection: Nothing to do." << endl); 2240 2899 return false; 2241 2900 } else { // check for sign against BaseLineNormal … … 2243 2902 BaseLineNormal.Zero(); 2244 2903 if (Base->triangles.size() < 2) { 2245 eLog() << Verbose(1) << "Less than two triangles are attached to this baseline!" << endl;2904 DoeLog(1) && (eLog() << Verbose(1) << "Less than two triangles are attached to this baseline!" << endl); 2246 2905 return 0.; 2247 2906 } 2248 2907 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) { 2249 Log() << Verbose(1) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl;2908 DoLog(1) && (Log() << Verbose(1) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl); 2250 2909 BaseLineNormal.AddVector(&(runner->second->NormalVector)); 2251 2910 } 2252 BaseLineNormal.Scale(1. /2.);2911 BaseLineNormal.Scale(1. / 2.); 2253 2912 2254 2913 if (Distance.ScalarProduct(&BaseLineNormal) > MYEPSILON) { // Distance points outwards, hence OtherBase higher than Base -> flip 2255 Log() << Verbose(0) << "ACCEPT: Other base line would be higher: Flipping baseline." << endl;2914 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Other base line would be higher: Flipping baseline." << endl); 2256 2915 // calculate volume summand as a general tetraeder 2257 2916 return volume; 2258 } else { 2259 Log() << Verbose(0) << "REJECT: Base line is higher: Nothing to do." << endl;2917 } else { // Base higher than OtherBase -> do nothing 2918 DoLog(0) && (Log() << Verbose(0) << "REJECT: Base line is higher: Nothing to do." << endl); 2260 2919 return 0.; 2261 2920 } 2262 2921 } 2263 }; 2922 } 2923 ; 2264 2924 2265 2925 /** For a given baseline and its two connected triangles, flips the baseline. … … 2272 2932 class BoundaryLineSet * Tesselation::FlipBaseline(class BoundaryLineSet *Base) 2273 2933 { 2274 2934 Info FunctionInfo(__func__); 2275 2935 class BoundaryLineSet *OldLines[4], *NewLine; 2276 2936 class BoundaryPointSet *OldPoints[2]; 2277 2937 Vector BaseLineNormal; 2278 2938 int OldTriangleNrs[2], OldBaseLineNr; 2279 int i, m;2939 int i, m; 2280 2940 2281 2941 // calculate NormalVector for later use 2282 2942 BaseLineNormal.Zero(); 2283 2943 if (Base->triangles.size() < 2) { 2284 eLog() << Verbose(1) << "Less than two triangles are attached to this baseline!" << endl;2944 DoeLog(1) && (eLog() << Verbose(1) << "Less than two triangles are attached to this baseline!" << endl); 2285 2945 return NULL; 2286 2946 } 2287 2947 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) { 2288 Log() << Verbose(1) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl;2948 DoLog(1) && (Log() << Verbose(1) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl); 2289 2949 BaseLineNormal.AddVector(&(runner->second->NormalVector)); 2290 2950 } 2291 BaseLineNormal.Scale(-1. /2.); // has to point inside for BoundaryTriangleSet::GetNormalVector()2951 BaseLineNormal.Scale(-1. / 2.); // has to point inside for BoundaryTriangleSet::GetNormalVector() 2292 2952 2293 2953 // get the two triangles 2294 2954 // gather four endpoints and four lines 2295 for (int j =0;j<4;j++)2955 for (int j = 0; j < 4; j++) 2296 2956 OldLines[j] = NULL; 2297 for (int j =0;j<2;j++)2957 for (int j = 0; j < 2; j++) 2298 2958 OldPoints[j] = NULL; 2299 i =0;2300 m =0;2301 Log() << Verbose(0) << "The four old lines are: ";2302 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)2303 for (int j =0;j<3;j++) // all of their endpoints and baselines2959 i = 0; 2960 m = 0; 2961 DoLog(0) && (Log() << Verbose(0) << "The four old lines are: "); 2962 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) 2963 for (int j = 0; j < 3; j++) // all of their endpoints and baselines 2304 2964 if (runner->second->lines[j] != Base) { // pick not the central baseline 2305 2965 OldLines[i++] = runner->second->lines[j]; 2306 Log() << Verbose(0) << *runner->second->lines[j] << "\t";2966 DoLog(0) && (Log() << Verbose(0) << *runner->second->lines[j] << "\t"); 2307 2967 } 2308 Log() << Verbose(0) << endl;2309 Log() << Verbose(0) << "The two old points are: ";2310 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)2311 for (int j =0;j<3;j++) // all of their endpoints and baselines2968 DoLog(0) && (Log() << Verbose(0) << endl); 2969 DoLog(0) && (Log() << Verbose(0) << "The two old points are: "); 2970 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) 2971 for (int j = 0; j < 3; j++) // all of their endpoints and baselines 2312 2972 if (!Base->ContainsBoundaryPoint(runner->second->endpoints[j])) { // and neither of its endpoints 2313 2973 OldPoints[m++] = runner->second->endpoints[j]; 2314 Log() << Verbose(0) << *runner->second->endpoints[j] << "\t";2974 DoLog(0) && (Log() << Verbose(0) << *runner->second->endpoints[j] << "\t"); 2315 2975 } 2316 Log() << Verbose(0) << endl;2976 DoLog(0) && (Log() << Verbose(0) << endl); 2317 2977 2318 2978 // check whether everything is in place to create new lines and triangles 2319 if (i <4) {2320 eLog() << Verbose(1) << "We have not gathered enough baselines!" << endl;2979 if (i < 4) { 2980 DoeLog(1) && (eLog() << Verbose(1) << "We have not gathered enough baselines!" << endl); 2321 2981 return NULL; 2322 2982 } 2323 for (int j =0;j<4;j++)2983 for (int j = 0; j < 4; j++) 2324 2984 if (OldLines[j] == NULL) { 2325 eLog() << Verbose(1) << "We have not gathered enough baselines!" << endl;2985 DoeLog(1) && (eLog() << Verbose(1) << "We have not gathered enough baselines!" << endl); 2326 2986 return NULL; 2327 2987 } 2328 for (int j =0;j<2;j++)2988 for (int j = 0; j < 2; j++) 2329 2989 if (OldPoints[j] == NULL) { 2330 eLog() << Verbose(1) << "We have not gathered enough endpoints!" << endl;2990 DoeLog(1) && (eLog() << Verbose(1) << "We have not gathered enough endpoints!" << endl); 2331 2991 return NULL; 2332 2992 } 2333 2993 2334 2994 // remove triangles and baseline removes itself 2335 Log() << Verbose(0) << "INFO: Deleting baseline " << *Base << " from global list." << endl;2995 DoLog(0) && (Log() << Verbose(0) << "INFO: Deleting baseline " << *Base << " from global list." << endl); 2336 2996 OldBaseLineNr = Base->Nr; 2337 m =0;2338 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {2339 Log() << Verbose(0) << "INFO: Deleting triangle " << *(runner->second) << "." << endl;2997 m = 0; 2998 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) { 2999 DoLog(0) && (Log() << Verbose(0) << "INFO: Deleting triangle " << *(runner->second) << "." << endl); 2340 3000 OldTriangleNrs[m++] = runner->second->Nr; 2341 3001 RemoveTesselationTriangle(runner->second); … … 2347 3007 NewLine = new class BoundaryLineSet(BPS, OldBaseLineNr); 2348 3008 LinesOnBoundary.insert(LinePair(OldBaseLineNr, NewLine)); // no need for check for unique insertion as NewLine is definitely a new one 2349 Log() << Verbose(0) << "INFO: Created new baseline " << *NewLine << "." << endl;3009 DoLog(0) && (Log() << Verbose(0) << "INFO: Created new baseline " << *NewLine << "." << endl); 2350 3010 2351 3011 // construct new triangles with flipped baseline 2352 i =-1;3012 i = -1; 2353 3013 if (OldLines[0]->IsConnectedTo(OldLines[2])) 2354 i =2;3014 i = 2; 2355 3015 if (OldLines[0]->IsConnectedTo(OldLines[3])) 2356 i =3;2357 if (i !=-1) {3016 i = 3; 3017 if (i != -1) { 2358 3018 BLS[0] = OldLines[0]; 2359 3019 BLS[1] = OldLines[i]; … … 2362 3022 BTS->GetNormalVector(BaseLineNormal); 2363 3023 AddTesselationTriangle(OldTriangleNrs[0]); 2364 Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl;2365 2366 BLS[0] = (i ==2 ? OldLines[3] : OldLines[2]);3024 DoLog(0) && (Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl); 3025 3026 BLS[0] = (i == 2 ? OldLines[3] : OldLines[2]); 2367 3027 BLS[1] = OldLines[1]; 2368 3028 BLS[2] = NewLine; … … 2370 3030 BTS->GetNormalVector(BaseLineNormal); 2371 3031 AddTesselationTriangle(OldTriangleNrs[1]); 2372 Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl;3032 DoLog(0) && (Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl); 2373 3033 } else { 2374 eLog() << Verbose(0) << "The four old lines do not connect, something's utterly wrong here!" << endl;3034 DoeLog(0) && (eLog() << Verbose(0) << "The four old lines do not connect, something's utterly wrong here!" << endl); 2375 3035 return NULL; 2376 3036 } 2377 3037 2378 3038 return NewLine; 2379 } ;2380 3039 } 3040 ; 2381 3041 2382 3042 /** Finds the second point of starting triangle. … … 2390 3050 void Tesselation::FindSecondPointForTesselation(TesselPoint* a, Vector Oben, TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC) 2391 3051 { 2392 3052 Info FunctionInfo(__func__); 2393 3053 Vector AngleCheck; 2394 3054 class TesselPoint* Candidate = NULL; … … 2399 3059 int Nupper[NDIM]; 2400 3060 2401 if (LC->SetIndexToNode(a)) { 2402 for (int i=0;i<NDIM;i++) // store indices of this cell3061 if (LC->SetIndexToNode(a)) { // get cell for the starting point 3062 for (int i = 0; i < NDIM; i++) // store indices of this cell 2403 3063 N[i] = LC->n[i]; 2404 3064 } else { 2405 eLog() << Verbose(1) << "Point " << *a << " is not found in cell " << LC->index << "." << endl;3065 DoeLog(1) && (eLog() << Verbose(1) << "Point " << *a << " is not found in cell " << LC->index << "." << endl); 2406 3066 return; 2407 3067 } 2408 3068 // then go through the current and all neighbouring cells and check the contained points for possible candidates 2409 for (int i=0;i<NDIM;i++) { 2410 Nlower[i] = ((N[i]-1) >= 0) ? N[i]-1 : 0; 2411 Nupper[i] = ((N[i]+1) < LC->N[i]) ? N[i]+1 : LC->N[i]-1; 2412 } 2413 Log() << Verbose(0) << "LC Intervals from [" << N[0] << "<->" << LC->N[0] << ", " << N[1] << "<->" << LC->N[1] << ", " << N[2] << "<->" << LC->N[2] << "] :" 2414 << " [" << Nlower[0] << "," << Nupper[0] << "], " << " [" << Nlower[1] << "," << Nupper[1] << "], " << " [" << Nlower[2] << "," << Nupper[2] << "], " << endl; 3069 for (int i = 0; i < NDIM; i++) { 3070 Nlower[i] = ((N[i] - 1) >= 0) ? N[i] - 1 : 0; 3071 Nupper[i] = ((N[i] + 1) < LC->N[i]) ? N[i] + 1 : LC->N[i] - 1; 3072 } 3073 DoLog(0) && (Log() << Verbose(0) << "LC Intervals from [" << N[0] << "<->" << LC->N[0] << ", " << N[1] << "<->" << LC->N[1] << ", " << N[2] << "<->" << LC->N[2] << "] :" << " [" << Nlower[0] << "," << Nupper[0] << "], " << " [" << Nlower[1] << "," << Nupper[1] << "], " << " [" << Nlower[2] << "," << Nupper[2] << "], " << endl); 2415 3074 2416 3075 for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++) 2417 3076 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 2418 3077 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 2419 const Linked Nodes *List = LC->GetCurrentCell();3078 const LinkedCell::LinkedNodes *List = LC->GetCurrentCell(); 2420 3079 //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl; 2421 3080 if (List != NULL) { 2422 for (Linked Nodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {3081 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 2423 3082 Candidate = (*Runner); 2424 3083 // check if we only have one unique point yet ... … … 2446 3105 norm = aCandidate.Norm(); 2447 3106 // second point shall have smallest angle with respect to Oben vector 2448 if (norm < RADIUS *2.) {3107 if (norm < RADIUS * 2.) { 2449 3108 angle = AngleCheck.Angle(&Oben); 2450 3109 if (angle < Storage[0]) { 2451 3110 //Log() << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]); 2452 Log() << Verbose(1) << "Current candidate is " << *Candidate << ": Is a better candidate with distance " << norm << " and angle " << angle << " to oben " << Oben << ".\n";3111 DoLog(1) && (Log() << Verbose(1) << "Current candidate is " << *Candidate << ": Is a better candidate with distance " << norm << " and angle " << angle << " to oben " << Oben << ".\n"); 2453 3112 OptCandidate = Candidate; 2454 3113 Storage[0] = angle; … … 2465 3124 } 2466 3125 } else { 2467 Log() << Verbose(0) << "Linked cell list is empty." << endl;3126 DoLog(0) && (Log() << Verbose(0) << "Linked cell list is empty." << endl); 2468 3127 } 2469 3128 } 2470 } ;2471 3129 } 3130 ; 2472 3131 2473 3132 /** This recursive function finds a third point, to form a triangle with two given ones. … … 2497 3156 * @param OldSphereCenter center of sphere for base triangle, relative to center of BaseLine, giving null angle for the parameter circle 2498 3157 * @param CandidateLine CandidateForTesselation with the current base line and list of candidates and ShortestAngle 2499 * @param Third Nodethird point to avoid in search3158 * @param ThirdPoint third point to avoid in search 2500 3159 * @param RADIUS radius of sphere 2501 3160 * @param *LC LinkedCell structure with neighbouring points 2502 3161 */ 2503 void Tesselation::FindThirdPointForTesselation( Vector &NormalVector, Vector &SearchDirection, Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class TesselPoint * const ThirdNode, const double RADIUS, const LinkedCell *LC) const2504 { 2505 2506 Vector CircleCenter; 3162 void Tesselation::FindThirdPointForTesselation(const Vector &NormalVector, const Vector &SearchDirection, const Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class BoundaryPointSet * const ThirdPoint, const double RADIUS, const LinkedCell *LC) const 3163 { 3164 Info FunctionInfo(__func__); 3165 Vector CircleCenter; // center of the circle, i.e. of the band of sphere's centers 2507 3166 Vector CirclePlaneNormal; // normal vector defining the plane this circle lives in 2508 3167 Vector SphereCenter; 2509 Vector NewSphereCenter; 2510 Vector OtherNewSphereCenter; 2511 Vector NewNormalVector; 3168 Vector NewSphereCenter; // center of the sphere defined by the two points of BaseLine and the one of Candidate, first possibility 3169 Vector OtherNewSphereCenter; // center of the sphere defined by the two points of BaseLine and the one of Candidate, second possibility 3170 Vector NewNormalVector; // normal vector of the Candidate's triangle 2512 3171 Vector helper, OptCandidateCenter, OtherOptCandidateCenter; 3172 Vector RelativeOldSphereCenter; 3173 Vector NewPlaneCenter; 2513 3174 double CircleRadius; // radius of this circle 2514 3175 double radius; 3176 double otherradius; 2515 3177 double alpha, Otheralpha; // angles (i.e. parameter for the circle). 2516 3178 int N[NDIM], Nlower[NDIM], Nupper[NDIM]; 2517 3179 TesselPoint *Candidate = NULL; 2518 3180 2519 Log() << Verbose(1) << "INFO: NormalVector of BaseTriangle is " << NormalVector << "." << endl; 3181 DoLog(1) && (Log() << Verbose(1) << "INFO: NormalVector of BaseTriangle is " << NormalVector << "." << endl); 3182 3183 // copy old center 3184 CandidateLine.OldCenter.CopyVector(&OldSphereCenter); 3185 CandidateLine.ThirdPoint = ThirdPoint; 3186 CandidateLine.pointlist.clear(); 2520 3187 2521 3188 // construct center of circle … … 2528 3195 CirclePlaneNormal.SubtractVector(CandidateLine.BaseLine->endpoints[1]->node->node); 2529 3196 2530 // calculate squared radius TesselPoint *ThirdNode,f circle 2531 radius = CirclePlaneNormal.ScalarProduct(&CirclePlaneNormal); 2532 if (radius/4. < RADIUS*RADIUS) { 2533 CircleRadius = RADIUS*RADIUS - radius/4.; 3197 RelativeOldSphereCenter.CopyVector(&OldSphereCenter); 3198 RelativeOldSphereCenter.SubtractVector(&CircleCenter); 3199 3200 // calculate squared radius TesselPoint *ThirdPoint,f circle 3201 radius = CirclePlaneNormal.NormSquared() / 4.; 3202 if (radius < RADIUS * RADIUS) { 3203 CircleRadius = RADIUS * RADIUS - radius; 2534 3204 CirclePlaneNormal.Normalize(); 2535 //Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;3205 DoLog(1) && (Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl); 2536 3206 2537 3207 // test whether old center is on the band's plane 2538 if (fabs( OldSphereCenter.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) {2539 eLog() << Verbose(1) << "Something's very wrong here: OldSphereCenter is not on the band's plane as desired by " << fabs(OldSphereCenter.ScalarProduct(&CirclePlaneNormal)) << "!" << endl;2540 OldSphereCenter.ProjectOntoPlane(&CirclePlaneNormal);2541 } 2542 radius = OldSphereCenter.ScalarProduct(&OldSphereCenter);3208 if (fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) { 3209 DoeLog(1) && (eLog() << Verbose(1) << "Something's very wrong here: RelativeOldSphereCenter is not on the band's plane as desired by " << fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) << "!" << endl); 3210 RelativeOldSphereCenter.ProjectOntoPlane(&CirclePlaneNormal); 3211 } 3212 radius = RelativeOldSphereCenter.NormSquared(); 2543 3213 if (fabs(radius - CircleRadius) < HULLEPSILON) { 2544 //Log() << Verbose(1) << "INFO: OldSphereCenter is at " << OldSphereCenter << "." << endl;3214 DoLog(1) && (Log() << Verbose(1) << "INFO: RelativeOldSphereCenter is at " << RelativeOldSphereCenter << "." << endl); 2545 3215 2546 3216 // check SearchDirection 2547 //Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;2548 if (fabs( OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {// rotated the wrong way!2549 eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are not orthogonal!" << endl;3217 DoLog(1) && (Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl); 3218 if (fabs(RelativeOldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { // rotated the wrong way! 3219 DoeLog(1) && (eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are not orthogonal!" << endl); 2550 3220 } 2551 3221 2552 3222 // get cell for the starting point 2553 3223 if (LC->SetIndexToVector(&CircleCenter)) { 2554 for (int i=0;i<NDIM;i++) // store indices of this cell2555 N[i] = LC->n[i];3224 for (int i = 0; i < NDIM; i++) // store indices of this cell 3225 N[i] = LC->n[i]; 2556 3226 //Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl; 2557 3227 } else { 2558 eLog() << Verbose(1) << "Vector " << CircleCenter << " is outside of LinkedCell's bounding box." << endl;3228 DoeLog(1) && (eLog() << Verbose(1) << "Vector " << CircleCenter << " is outside of LinkedCell's bounding box." << endl); 2559 3229 return; 2560 3230 } 2561 3231 // then go through the current and all neighbouring cells and check the contained points for possible candidates 2562 3232 //Log() << Verbose(1) << "LC Intervals:"; 2563 for (int i =0;i<NDIM;i++) {2564 Nlower[i] = ((N[i] -1) >= 0) ? N[i]-1 : 0;2565 Nupper[i] = ((N[i] +1) < LC->N[i]) ? N[i]+1 : LC->N[i]-1;3233 for (int i = 0; i < NDIM; i++) { 3234 Nlower[i] = ((N[i] - 1) >= 0) ? N[i] - 1 : 0; 3235 Nupper[i] = ((N[i] + 1) < LC->N[i]) ? N[i] + 1 : LC->N[i] - 1; 2566 3236 //Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] "; 2567 3237 } … … 2570 3240 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 2571 3241 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 2572 const Linked Nodes *List = LC->GetCurrentCell();3242 const LinkedCell::LinkedNodes *List = LC->GetCurrentCell(); 2573 3243 //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl; 2574 3244 if (List != NULL) { 2575 for (Linked Nodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {3245 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 2576 3246 Candidate = (*Runner); 2577 3247 2578 3248 // check for three unique points 2579 Log() << Verbose(2) << "INFO: Current Candidate is " << *Candidate << " at " << *(Candidate->node) << "." << endl; 2580 if ((Candidate != CandidateLine.BaseLine->endpoints[0]->node) && (Candidate != CandidateLine.BaseLine->endpoints[1]->node) ){ 2581 2582 // construct both new centers 2583 GetCenterofCircumcircle(&NewSphereCenter, *CandidateLine.BaseLine->endpoints[0]->node->node, *CandidateLine.BaseLine->endpoints[1]->node->node, *Candidate->node); 2584 OtherNewSphereCenter.CopyVector(&NewSphereCenter); 2585 2586 if ((NewNormalVector.MakeNormalVector(CandidateLine.BaseLine->endpoints[0]->node->node, CandidateLine.BaseLine->endpoints[1]->node->node, Candidate->node)) 2587 && (fabs(NewNormalVector.ScalarProduct(&NewNormalVector)) > HULLEPSILON) 2588 ) { 2589 helper.CopyVector(&NewNormalVector); 2590 Log() << Verbose(1) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl; 2591 radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(&NewSphereCenter); 2592 if (radius < RADIUS*RADIUS) { 2593 helper.Scale(sqrt(RADIUS*RADIUS - radius)); 2594 Log() << Verbose(2) << "INFO: Distance of NewCircleCenter to NewSphereCenter is " << helper.Norm() << " with sphere radius " << RADIUS << "." << endl; 2595 NewSphereCenter.AddVector(&helper); 2596 NewSphereCenter.SubtractVector(&CircleCenter); 2597 Log() << Verbose(2) << "INFO: NewSphereCenter is at " << NewSphereCenter << "." << endl; 2598 2599 // OtherNewSphereCenter is created by the same vector just in the other direction 2600 helper.Scale(-1.); 2601 OtherNewSphereCenter.AddVector(&helper); 2602 OtherNewSphereCenter.SubtractVector(&CircleCenter); 2603 Log() << Verbose(2) << "INFO: OtherNewSphereCenter is at " << OtherNewSphereCenter << "." << endl; 2604 2605 alpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, NewSphereCenter, OldSphereCenter, NormalVector, SearchDirection); 2606 Otheralpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, OtherNewSphereCenter, OldSphereCenter, NormalVector, SearchDirection); 2607 alpha = min(alpha, Otheralpha); 2608 // if there is a better candidate, drop the current list and add the new candidate 2609 // otherwise ignore the new candidate and keep the list 2610 if (CandidateLine.ShortestAngle > (alpha - HULLEPSILON)) { 2611 if (fabs(alpha - Otheralpha) > MYEPSILON) { 2612 CandidateLine.OptCenter.CopyVector(&NewSphereCenter); 2613 CandidateLine.OtherOptCenter.CopyVector(&OtherNewSphereCenter); 3249 DoLog(2) && (Log() << Verbose(2) << "INFO: Current Candidate is " << *Candidate << " for BaseLine " << *CandidateLine.BaseLine << " with OldSphereCenter " << OldSphereCenter << "." << endl); 3250 if ((Candidate != CandidateLine.BaseLine->endpoints[0]->node) && (Candidate != CandidateLine.BaseLine->endpoints[1]->node)) { 3251 3252 // find center on the plane 3253 GetCenterofCircumcircle(&NewPlaneCenter, *CandidateLine.BaseLine->endpoints[0]->node->node, *CandidateLine.BaseLine->endpoints[1]->node->node, *Candidate->node); 3254 DoLog(1) && (Log() << Verbose(1) << "INFO: NewPlaneCenter is " << NewPlaneCenter << "." << endl); 3255 3256 if (NewNormalVector.MakeNormalVector(CandidateLine.BaseLine->endpoints[0]->node->node, CandidateLine.BaseLine->endpoints[1]->node->node, Candidate->node) && (fabs(NewNormalVector.NormSquared()) > HULLEPSILON)) { 3257 DoLog(1) && (Log() << Verbose(1) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl); 3258 radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(&NewPlaneCenter); 3259 DoLog(1) && (Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl); 3260 DoLog(1) && (Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl); 3261 DoLog(1) && (Log() << Verbose(1) << "INFO: Radius of CircumCenterCircle is " << radius << "." << endl); 3262 if (radius < RADIUS * RADIUS) { 3263 otherradius = CandidateLine.BaseLine->endpoints[1]->node->node->DistanceSquared(&NewPlaneCenter); 3264 if (fabs(radius - otherradius) < HULLEPSILON) { 3265 // construct both new centers 3266 NewSphereCenter.CopyVector(&NewPlaneCenter); 3267 OtherNewSphereCenter.CopyVector(&NewPlaneCenter); 3268 helper.CopyVector(&NewNormalVector); 3269 helper.Scale(sqrt(RADIUS * RADIUS - radius)); 3270 DoLog(2) && (Log() << Verbose(2) << "INFO: Distance of NewPlaneCenter " << NewPlaneCenter << " to either NewSphereCenter is " << helper.Norm() << " of vector " << helper << " with sphere radius " << RADIUS << "." << endl); 3271 NewSphereCenter.AddVector(&helper); 3272 DoLog(2) && (Log() << Verbose(2) << "INFO: NewSphereCenter is at " << NewSphereCenter << "." << endl); 3273 // OtherNewSphereCenter is created by the same vector just in the other direction 3274 helper.Scale(-1.); 3275 OtherNewSphereCenter.AddVector(&helper); 3276 DoLog(2) && (Log() << Verbose(2) << "INFO: OtherNewSphereCenter is at " << OtherNewSphereCenter << "." << endl); 3277 3278 alpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, NewSphereCenter, OldSphereCenter, NormalVector, SearchDirection); 3279 Otheralpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, OtherNewSphereCenter, OldSphereCenter, NormalVector, SearchDirection); 3280 if ((ThirdPoint != NULL) && (Candidate == ThirdPoint->node)) { // in that case only the other circlecenter is valid 3281 if (OldSphereCenter.DistanceSquared(&NewSphereCenter) < OldSphereCenter.DistanceSquared(&OtherNewSphereCenter)) 3282 alpha = Otheralpha; 3283 } else 3284 alpha = min(alpha, Otheralpha); 3285 3286 // if there is a better candidate, drop the current list and add the new candidate 3287 // otherwise ignore the new candidate and keep the list 3288 if (CandidateLine.ShortestAngle > (alpha - HULLEPSILON)) { 3289 if (fabs(alpha - Otheralpha) > MYEPSILON) { 3290 CandidateLine.OptCenter.CopyVector(&NewSphereCenter); 3291 CandidateLine.OtherOptCenter.CopyVector(&OtherNewSphereCenter); 3292 } else { 3293 CandidateLine.OptCenter.CopyVector(&OtherNewSphereCenter); 3294 CandidateLine.OtherOptCenter.CopyVector(&NewSphereCenter); 3295 } 3296 // if there is an equal candidate, add it to the list without clearing the list 3297 if ((CandidateLine.ShortestAngle - HULLEPSILON) < alpha) { 3298 CandidateLine.pointlist.push_back(Candidate); 3299 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: We have found an equally good candidate: " << *(Candidate) << " with " << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl); 3300 } else { 3301 // remove all candidates from the list and then the list itself 3302 CandidateLine.pointlist.clear(); 3303 CandidateLine.pointlist.push_back(Candidate); 3304 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: We have found a better candidate: " << *(Candidate) << " with " << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl); 3305 } 3306 CandidateLine.ShortestAngle = alpha; 3307 DoLog(0) && (Log() << Verbose(0) << "INFO: There are " << CandidateLine.pointlist.size() << " candidates in the list now." << endl); 2614 3308 } else { 2615 CandidateLine.OptCenter.CopyVector(&OtherNewSphereCenter); 2616 CandidateLine.OtherOptCenter.CopyVector(&NewSphereCenter); 3309 if ((Candidate != NULL) && (CandidateLine.pointlist.begin() != CandidateLine.pointlist.end())) { 3310 DoLog(1) && (Log() << Verbose(1) << "REJECT: Old candidate " << *(*CandidateLine.pointlist.begin()) << " with " << CandidateLine.ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl); 3311 } else { 3312 DoLog(1) && (Log() << Verbose(1) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl); 3313 } 2617 3314 } 2618 // if there is an equal candidate, add it to the list without clearing the list2619 if ((CandidateLine.ShortestAngle - HULLEPSILON) < alpha) {2620 CandidateLine.pointlist.push_back(Candidate);2621 Log() << Verbose(0) << "ACCEPT: We have found an equally good candidate: " << *(Candidate) << " with "2622 << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl;2623 } else {2624 // remove all candidates from the list and then the list itself2625 CandidateLine.pointlist.clear();2626 CandidateLine.pointlist.push_back(Candidate);2627 Log() << Verbose(0) << "ACCEPT: We have found a better candidate: " << *(Candidate) << " with "2628 << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl;2629 }2630 CandidateLine.ShortestAngle = alpha;2631 Log() << Verbose(0) << "INFO: There are " << CandidateLine.pointlist.size() << " candidates in the list now." << endl;2632 3315 } else { 2633 if ((Candidate != NULL) && (CandidateLine.pointlist.begin() != CandidateLine.pointlist.end())) { 2634 Log() << Verbose(1) << "REJECT: Old candidate " << *(Candidate) << " with " << CandidateLine.ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl; 2635 } else { 2636 Log() << Verbose(1) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl; 2637 } 3316 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); 2638 3317 } 2639 2640 3318 } else { 2641 Log() << Verbose(1) << "REJECT: NewSphereCenter " << NewSphereCenter << " for " << *Candidate << " is too far away: " << radius << "." << endl;3319 DoLog(1) && (Log() << Verbose(1) << "REJECT: NewSphereCenter " << NewSphereCenter << " for " << *Candidate << " is too far away: " << radius << "." << endl); 2642 3320 } 2643 3321 } else { 2644 Log() << Verbose(1) << "REJECT: Three points from " << *CandidateLine.BaseLine << " and Candidate " << *Candidate << " are linear-dependent." << endl;3322 DoLog(1) && (Log() << Verbose(1) << "REJECT: Three points from " << *CandidateLine.BaseLine << " and Candidate " << *Candidate << " are linear-dependent." << endl); 2645 3323 } 2646 3324 } else { 2647 if (Third Node!= NULL) {2648 Log() << Verbose(1) << "REJECT: Base triangle " << *CandidateLine.BaseLine << " and " << *ThirdNode << " contains Candidate " << *Candidate << "." << endl;3325 if (ThirdPoint != NULL) { 3326 DoLog(1) && (Log() << Verbose(1) << "REJECT: Base triangle " << *CandidateLine.BaseLine << " and " << *ThirdPoint << " contains Candidate " << *Candidate << "." << endl); 2649 3327 } else { 2650 Log() << Verbose(1) << "REJECT: Base triangle " << *CandidateLine.BaseLine << " contains Candidate " << *Candidate << "." << endl;3328 DoLog(1) && (Log() << Verbose(1) << "REJECT: Base triangle " << *CandidateLine.BaseLine << " contains Candidate " << *Candidate << "." << endl); 2651 3329 } 2652 3330 } … … 2655 3333 } 2656 3334 } else { 2657 eLog() << Verbose(1) << "The projected center of the old sphere has radius " << radius << " instead of " << CircleRadius << "." << endl;3335 DoeLog(1) && (eLog() << Verbose(1) << "The projected center of the old sphere has radius " << radius << " instead of " << CircleRadius << "." << endl); 2658 3336 } 2659 3337 } else { 2660 if (Third Node!= NULL)2661 Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " and third node " << *ThirdNode << " is too big!" << endl;3338 if (ThirdPoint != NULL) 3339 DoLog(1) && (Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " and third node " << *ThirdPoint << " is too big!" << endl); 2662 3340 else 2663 Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " is too big!" << endl;2664 } 2665 2666 Log() << Verbose(1) << "INFO: Sorting candidate list ..." << endl;3341 DoLog(1) && (Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " is too big!" << endl); 3342 } 3343 3344 DoLog(1) && (Log() << Verbose(1) << "INFO: Sorting candidate list ..." << endl); 2667 3345 if (CandidateLine.pointlist.size() > 1) { 2668 3346 CandidateLine.pointlist.unique(); 2669 3347 CandidateLine.pointlist.sort(); //SortCandidates); 2670 3348 } 2671 }; 3349 3350 if ((!CandidateLine.pointlist.empty()) && (!CandidateLine.CheckValidity(RADIUS, LC))) { 3351 DoeLog(0) && (eLog() << Verbose(0) << "There were other points contained in the rolling sphere as well!" << endl); 3352 performCriticalExit(); 3353 } 3354 } 3355 ; 2672 3356 2673 3357 /** Finds the endpoint two lines are sharing. … … 2678 3362 class BoundaryPointSet *Tesselation::GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const 2679 3363 { 2680 3364 Info FunctionInfo(__func__); 2681 3365 const BoundaryLineSet * lines[2] = { line1, line2 }; 2682 3366 class BoundaryPointSet *node = NULL; 2683 map<int, class BoundaryPointSet *>OrderMap;2684 pair<map<int, class BoundaryPointSet *>::iterator, bool>OrderTest;3367 PointMap OrderMap; 3368 PointTestPair OrderTest; 2685 3369 for (int i = 0; i < 2; i++) 2686 3370 // for both lines 2687 for (int j = 0; j < 2; j++) 2688 { // for both endpoints 2689 OrderTest = OrderMap.insert(pair<int, class BoundaryPointSet *> ( 2690 lines[i]->endpoints[j]->Nr, lines[i]->endpoints[j])); 2691 if (!OrderTest.second) 2692 { // if insertion fails, we have common endpoint 2693 node = OrderTest.first->second; 2694 Log() << Verbose(1) << "Common endpoint of lines " << *line1 2695 << " and " << *line2 << " is: " << *node << "." << endl; 2696 j = 2; 2697 i = 2; 2698 break; 3371 for (int j = 0; j < 2; j++) { // for both endpoints 3372 OrderTest = OrderMap.insert(pair<int, class BoundaryPointSet *> (lines[i]->endpoints[j]->Nr, lines[i]->endpoints[j])); 3373 if (!OrderTest.second) { // if insertion fails, we have common endpoint 3374 node = OrderTest.first->second; 3375 DoLog(1) && (Log() << Verbose(1) << "Common endpoint of lines " << *line1 << " and " << *line2 << " is: " << *node << "." << endl); 3376 j = 2; 3377 i = 2; 3378 break; 3379 } 3380 } 3381 return node; 3382 } 3383 ; 3384 3385 /** Finds the boundary points that are closest to a given Vector \a *x. 3386 * \param *out output stream for debugging 3387 * \param *x Vector to look from 3388 * \return map of BoundaryPointSet of closest points sorted by squared distance or NULL. 3389 */ 3390 DistanceToPointMap * Tesselation::FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const 3391 { 3392 Info FunctionInfo(__func__); 3393 PointMap::const_iterator FindPoint; 3394 int N[NDIM], Nlower[NDIM], Nupper[NDIM]; 3395 3396 if (LinesOnBoundary.empty()) { 3397 DoeLog(1) && (eLog() << Verbose(1) << "There is no tesselation structure to compare the point with, please create one first." << endl); 3398 return NULL; 3399 } 3400 3401 // gather all points close to the desired one 3402 LC->SetIndexToVector(x); // ignore status as we calculate bounds below sensibly 3403 for (int i = 0; i < NDIM; i++) // store indices of this cell 3404 N[i] = LC->n[i]; 3405 DoLog(1) && (Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl); 3406 DistanceToPointMap * points = new DistanceToPointMap; 3407 LC->GetNeighbourBounds(Nlower, Nupper); 3408 //Log() << Verbose(1) << endl; 3409 for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++) 3410 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 3411 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 3412 const LinkedCell::LinkedNodes *List = LC->GetCurrentCell(); 3413 //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl; 3414 if (List != NULL) { 3415 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 3416 FindPoint = PointsOnBoundary.find((*Runner)->nr); 3417 if (FindPoint != PointsOnBoundary.end()) { 3418 points->insert(DistanceToPointPair(FindPoint->second->node->node->DistanceSquared(x), FindPoint->second)); 3419 DoLog(1) && (Log() << Verbose(1) << "INFO: Putting " << *FindPoint->second << " into the list." << endl); 3420 } 2699 3421 } 3422 } else { 3423 DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl); 3424 } 2700 3425 } 2701 return node; 2702 }; 3426 3427 // check whether we found some points 3428 if (points->empty()) { 3429 DoeLog(1) && (eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl); 3430 delete (points); 3431 return NULL; 3432 } 3433 return points; 3434 } 3435 ; 3436 3437 /** Finds the boundary line that is closest to a given Vector \a *x. 3438 * \param *out output stream for debugging 3439 * \param *x Vector to look from 3440 * \return closest BoundaryLineSet or NULL in degenerate case. 3441 */ 3442 BoundaryLineSet * Tesselation::FindClosestBoundaryLineToVector(const Vector *x, const LinkedCell* LC) const 3443 { 3444 Info FunctionInfo(__func__); 3445 // get closest points 3446 DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x, LC); 3447 if (points == NULL) { 3448 DoeLog(1) && (eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl); 3449 return NULL; 3450 } 3451 3452 // for each point, check its lines, remember closest 3453 DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryLine to " << *x << " ... " << endl); 3454 BoundaryLineSet *ClosestLine = NULL; 3455 double MinDistance = -1.; 3456 Vector helper; 3457 Vector Center; 3458 Vector BaseLine; 3459 for (DistanceToPointMap::iterator Runner = points->begin(); Runner != points->end(); Runner++) { 3460 for (LineMap::iterator LineRunner = Runner->second->lines.begin(); LineRunner != Runner->second->lines.end(); LineRunner++) { 3461 // calculate closest point on line to desired point 3462 helper.CopyVector((LineRunner->second)->endpoints[0]->node->node); 3463 helper.AddVector((LineRunner->second)->endpoints[1]->node->node); 3464 helper.Scale(0.5); 3465 Center.CopyVector(x); 3466 Center.SubtractVector(&helper); 3467 BaseLine.CopyVector((LineRunner->second)->endpoints[0]->node->node); 3468 BaseLine.SubtractVector((LineRunner->second)->endpoints[1]->node->node); 3469 Center.ProjectOntoPlane(&BaseLine); 3470 const double distance = Center.NormSquared(); 3471 if ((ClosestLine == NULL) || (distance < MinDistance)) { 3472 // additionally calculate intersection on line (whether it's on the line section or not) 3473 helper.CopyVector(x); 3474 helper.SubtractVector((LineRunner->second)->endpoints[0]->node->node); 3475 helper.SubtractVector(&Center); 3476 const double lengthA = helper.ScalarProduct(&BaseLine); 3477 helper.CopyVector(x); 3478 helper.SubtractVector((LineRunner->second)->endpoints[1]->node->node); 3479 helper.SubtractVector(&Center); 3480 const double lengthB = helper.ScalarProduct(&BaseLine); 3481 if (lengthB * lengthA < 0) { // if have different sign 3482 ClosestLine = LineRunner->second; 3483 MinDistance = distance; 3484 DoLog(1) && (Log() << Verbose(1) << "ACCEPT: New closest line is " << *ClosestLine << " with projected distance " << MinDistance << "." << endl); 3485 } else { 3486 DoLog(1) && (Log() << Verbose(1) << "REJECT: Intersection is outside of the line section: " << lengthA << " and " << lengthB << "." << endl); 3487 } 3488 } else { 3489 DoLog(1) && (Log() << Verbose(1) << "REJECT: Point is too further away than present line: " << distance << " >> " << MinDistance << "." << endl); 3490 } 3491 } 3492 } 3493 delete (points); 3494 // check whether closest line is "too close" :), then it's inside 3495 if (ClosestLine == NULL) { 3496 DoLog(0) && (Log() << Verbose(0) << "Is the only point, no one else is closeby." << endl); 3497 return NULL; 3498 } 3499 return ClosestLine; 3500 } 3501 ; 2703 3502 2704 3503 /** Finds the triangle that is closest to a given Vector \a *x. 2705 3504 * \param *out output stream for debugging 2706 3505 * \param *x Vector to look from 2707 * \return list of BoundaryTriangleSet of nearest triangles or NULL in degenerate case. 2708 */ 2709 list<BoundaryTriangleSet*> * Tesselation::FindClosestTrianglesToPoint(const Vector *x, const LinkedCell* LC) const 2710 { 2711 Info FunctionInfo(__func__); 2712 TesselPoint *trianglePoints[3]; 2713 TesselPoint *SecondPoint = NULL; 2714 list<BoundaryTriangleSet*> *triangles = NULL; 2715 2716 if (LinesOnBoundary.empty()) { 2717 eLog() << Verbose(1) << "Error: There is no tesselation structure to compare the point with, please create one first."; 3506 * \return BoundaryTriangleSet of nearest triangle or NULL. 3507 */ 3508 TriangleList * Tesselation::FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const 3509 { 3510 Info FunctionInfo(__func__); 3511 // get closest points 3512 DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x, LC); 3513 if (points == NULL) { 3514 DoeLog(1) && (eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl); 2718 3515 return NULL; 2719 3516 } 2720 Log() << Verbose(1) << "Finding closest Tesselpoint to " << *x << " ... " << endl; 2721 trianglePoints[0] = FindClosestPoint(x, SecondPoint, LC); 2722 2723 // check whether closest point is "too close" :), then it's inside 2724 if (trianglePoints[0] == NULL) { 2725 Log() << Verbose(0) << "Is the only point, no one else is closeby." << endl; 3517 3518 // for each point, check its lines, remember closest 3519 DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << *x << " ... " << endl); 3520 LineSet ClosestLines; 3521 double MinDistance = 1e+16; 3522 Vector BaseLineIntersection; 3523 Vector Center; 3524 Vector BaseLine; 3525 Vector BaseLineCenter; 3526 for (DistanceToPointMap::iterator Runner = points->begin(); Runner != points->end(); Runner++) { 3527 for (LineMap::iterator LineRunner = Runner->second->lines.begin(); LineRunner != Runner->second->lines.end(); LineRunner++) { 3528 3529 BaseLine.CopyVector((LineRunner->second)->endpoints[0]->node->node); 3530 BaseLine.SubtractVector((LineRunner->second)->endpoints[1]->node->node); 3531 const double lengthBase = BaseLine.NormSquared(); 3532 3533 BaseLineIntersection.CopyVector(x); 3534 BaseLineIntersection.SubtractVector((LineRunner->second)->endpoints[0]->node->node); 3535 const double lengthEndA = BaseLineIntersection.NormSquared(); 3536 3537 BaseLineIntersection.CopyVector(x); 3538 BaseLineIntersection.SubtractVector((LineRunner->second)->endpoints[1]->node->node); 3539 const double lengthEndB = BaseLineIntersection.NormSquared(); 3540 3541 if ((lengthEndA > lengthBase) || (lengthEndB > lengthBase) || ((lengthEndA < MYEPSILON) || (lengthEndB < MYEPSILON))) { // intersection would be outside, take closer endpoint 3542 const double lengthEnd = Min(lengthEndA, lengthEndB); 3543 if (lengthEnd - MinDistance < -MYEPSILON) { // new best line 3544 ClosestLines.clear(); 3545 ClosestLines.insert(LineRunner->second); 3546 MinDistance = lengthEnd; 3547 DoLog(1) && (Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[0]->node << " is closer with " << lengthEnd << "." << endl); 3548 } else if (fabs(lengthEnd - MinDistance) < MYEPSILON) { // additional best candidate 3549 ClosestLines.insert(LineRunner->second); 3550 DoLog(1) && (Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[1]->node << " is equally good with " << lengthEnd << "." << endl); 3551 } else { // line is worse 3552 DoLog(1) && (Log() << Verbose(1) << "REJECT: Line " << *LineRunner->second << " to either endpoints is further away than present closest line candidate: " << lengthEndA << ", " << lengthEndB << ", and distance is longer than baseline:" << lengthBase << "." << endl); 3553 } 3554 } else { // intersection is closer, calculate 3555 // calculate closest point on line to desired point 3556 BaseLineIntersection.CopyVector(x); 3557 BaseLineIntersection.SubtractVector((LineRunner->second)->endpoints[1]->node->node); 3558 Center.CopyVector(&BaseLineIntersection); 3559 Center.ProjectOntoPlane(&BaseLine); 3560 BaseLineIntersection.SubtractVector(&Center); 3561 const double distance = BaseLineIntersection.NormSquared(); 3562 if (Center.NormSquared() > BaseLine.NormSquared()) { 3563 DoeLog(0) && (eLog() << Verbose(0) << "Algorithmic error: In second case we have intersection outside of baseline!" << endl); 3564 } 3565 if ((ClosestLines.empty()) || (distance < MinDistance)) { 3566 ClosestLines.insert(LineRunner->second); 3567 MinDistance = distance; 3568 DoLog(1) && (Log() << Verbose(1) << "ACCEPT: Intersection in between endpoints, new closest line " << *LineRunner->second << " is " << *ClosestLines.begin() << " with projected distance " << MinDistance << "." << endl); 3569 } else { 3570 DoLog(2) && (Log() << Verbose(2) << "REJECT: Point is further away from line " << *LineRunner->second << " than present closest line: " << distance << " >> " << MinDistance << "." << endl); 3571 } 3572 } 3573 } 3574 } 3575 delete (points); 3576 3577 // check whether closest line is "too close" :), then it's inside 3578 if (ClosestLines.empty()) { 3579 DoLog(0) && (Log() << Verbose(0) << "Is the only point, no one else is closeby." << endl); 2726 3580 return NULL; 2727 3581 } 2728 if (trianglePoints[0]->node->DistanceSquared(x) < MYEPSILON) { 2729 Log() << Verbose(1) << "Point is right on a tesselation point, no nearest triangle." << endl; 2730 PointMap::const_iterator PointRunner = PointsOnBoundary.find(trianglePoints[0]->nr); 2731 triangles = new list<BoundaryTriangleSet*>; 2732 if (PointRunner != PointsOnBoundary.end()) { 2733 for(LineMap::iterator LineRunner = PointRunner->second->lines.begin(); LineRunner != PointRunner->second->lines.end(); LineRunner++) 2734 for(TriangleMap::iterator TriangleRunner = LineRunner->second->triangles.begin(); TriangleRunner != LineRunner->second->triangles.end(); TriangleRunner++) 2735 triangles->push_back(TriangleRunner->second); 2736 triangles->sort(); 2737 triangles->unique(); 2738 } else { 2739 PointRunner = PointsOnBoundary.find(SecondPoint->nr); 2740 trianglePoints[0] = SecondPoint; 2741 if (PointRunner != PointsOnBoundary.end()) { 2742 for(LineMap::iterator LineRunner = PointRunner->second->lines.begin(); LineRunner != PointRunner->second->lines.end(); LineRunner++) 2743 for(TriangleMap::iterator TriangleRunner = LineRunner->second->triangles.begin(); TriangleRunner != LineRunner->second->triangles.end(); TriangleRunner++) 2744 triangles->push_back(TriangleRunner->second); 2745 triangles->sort(); 2746 triangles->unique(); 2747 } else { 2748 eLog() << Verbose(1) << "I cannot find a boundary point to the tessel point " << *trianglePoints[0] << "." << endl; 2749 return NULL; 2750 } 2751 } 2752 } else { 2753 set<TesselPoint*> *connectedPoints = GetAllConnectedPoints(trianglePoints[0]); 2754 TesselPointList *connectedClosestPoints = GetCircleOfSetOfPoints(connectedPoints, trianglePoints[0], x); 2755 delete(connectedPoints); 2756 if (connectedClosestPoints != NULL) { 2757 trianglePoints[1] = connectedClosestPoints->front(); 2758 trianglePoints[2] = connectedClosestPoints->back(); 2759 for (int i=0;i<3;i++) { 2760 if (trianglePoints[i] == NULL) { 2761 eLog() << Verbose(1) << "IsInnerPoint encounters serious error, point " << i << " not found." << endl; 2762 } 2763 //Log() << Verbose(1) << "List of triangle points:" << endl; 2764 //Log() << Verbose(2) << *trianglePoints[i] << endl; 2765 } 2766 2767 triangles = FindTriangles(trianglePoints); 2768 Log() << Verbose(1) << "List of possible triangles:" << endl; 2769 for(list<BoundaryTriangleSet*>::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) 2770 Log() << Verbose(2) << **Runner << endl; 2771 2772 delete(connectedClosestPoints); 2773 } else { 2774 triangles = NULL; 2775 eLog() << Verbose(2) << "There is no circle of connected points!" << endl; 2776 } 2777 } 2778 2779 if ((triangles == NULL) || (triangles->empty())) { 2780 eLog() << Verbose(1) << "There is no nearest triangle. Please check the tesselation structure."; 2781 delete(triangles); 2782 return NULL; 2783 } else 2784 return triangles; 2785 }; 3582 TriangleList * candidates = new TriangleList; 3583 for (LineSet::iterator LineRunner = ClosestLines.begin(); LineRunner != ClosestLines.end(); LineRunner++) 3584 for (TriangleMap::iterator Runner = (*LineRunner)->triangles.begin(); Runner != (*LineRunner)->triangles.end(); Runner++) { 3585 candidates->push_back(Runner->second); 3586 } 3587 return candidates; 3588 } 3589 ; 2786 3590 2787 3591 /** Finds closest triangle to a point. … … 2789 3593 * \param *out output stream for debugging 2790 3594 * \param *x Vector to look from 3595 * \param &distance contains found distance on return 2791 3596 * \return list of BoundaryTriangleSet of nearest triangles or NULL. 2792 3597 */ 2793 class BoundaryTriangleSet * Tesselation::FindClosestTriangleTo Point(const Vector *x, const LinkedCell* LC) const2794 { 2795 3598 class BoundaryTriangleSet * Tesselation::FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const 3599 { 3600 Info FunctionInfo(__func__); 2796 3601 class BoundaryTriangleSet *result = NULL; 2797 list<BoundaryTriangleSet*> *triangles = FindClosestTrianglesToPoint(x, LC); 3602 TriangleList *triangles = FindClosestTrianglesToVector(x, LC); 3603 TriangleList candidates; 2798 3604 Vector Center; 2799 2800 if (triangles == NULL) 3605 Vector helper; 3606 3607 if ((triangles == NULL) || (triangles->empty())) 2801 3608 return NULL; 2802 3609 2803 if (triangles->size() == 1) { // there is no degenerate case2804 result = triangles->front();2805 Log() << Verbose(1) << "Normal Vector of this triangle is " << result->NormalVector << "." << endl;2806 } else {2807 result = triangles->front();2808 result->GetCenter(&Center);2809 Center.SubtractVector(x);2810 Log() << Verbose(1) << "Normal Vector of this front side is " << result->NormalVector << "." << endl;2811 if (Center.ScalarProduct(&result->NormalVector) < 0) {2812 result = triangles->back();2813 Log() << Verbose(1) << "Normal Vector of this back side is " << result->NormalVector << "." << endl;2814 if (Center.ScalarProduct(&result->NormalVector) < 0){2815 eLog() << Verbose(1) << "Front and back side yield NormalVector in wrong direction!" << endl;2816 2817 2818 }2819 delete(triangles); 3610 // go through all and pick the one with the best alignment to x 3611 double MinAlignment = 2. * M_PI; 3612 for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) { 3613 (*Runner)->GetCenter(&Center); 3614 helper.CopyVector(x); 3615 helper.SubtractVector(&Center); 3616 const double Alignment = helper.Angle(&(*Runner)->NormalVector); 3617 if (Alignment < MinAlignment) { 3618 result = *Runner; 3619 MinAlignment = Alignment; 3620 DoLog(1) && (Log() << Verbose(1) << "ACCEPT: Triangle " << *result << " is better aligned with " << MinAlignment << "." << endl); 3621 } else { 3622 DoLog(1) && (Log() << Verbose(1) << "REJECT: Triangle " << *result << " is worse aligned with " << MinAlignment << "." << endl); 3623 } 3624 } 3625 delete (triangles); 3626 2820 3627 return result; 2821 }; 2822 2823 /** Checks whether the provided Vector is within the tesselation structure. 3628 } 3629 ; 3630 3631 /** Checks whether the provided Vector is within the Tesselation structure. 3632 * Basically calls Tesselation::GetDistanceToSurface() and checks the sign of the return value. 3633 * @param point of which to check the position 3634 * @param *LC LinkedCell structure 3635 * 3636 * @return true if the point is inside the Tesselation structure, false otherwise 3637 */ 3638 bool Tesselation::IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const 3639 { 3640 Info FunctionInfo(__func__); 3641 TriangleIntersectionList Intersections(&Point, this, LC); 3642 3643 return Intersections.IsInside(); 3644 } 3645 ; 3646 3647 /** Returns the distance to the surface given by the tesselation. 3648 * Calls FindClosestTriangleToVector() and checks whether the resulting triangle's BoundaryTriangleSet#NormalVector points 3649 * towards or away from the given \a &Point. Additionally, we check whether it's normal to the normal vector, i.e. on the 3650 * closest triangle's plane. Then, we have to check whether \a Point is inside the triangle or not to determine whether it's 3651 * an inside or outside point. This is done by calling BoundaryTriangleSet::GetIntersectionInsideTriangle(). 3652 * In the end we additionally find the point on the triangle who was smallest distance to \a Point: 3653 * -# Separate distance from point to center in vector in NormalDirection and on the triangle plane. 3654 * -# Check whether vector on triangle plane points inside the triangle or crosses triangle bounds. 3655 * -# If inside, take it to calculate closest distance 3656 * -# If not, take intersection with BoundaryLine as distance 3657 * 3658 * @note distance is squared despite it still contains a sign to determine in-/outside! 2824 3659 * 2825 3660 * @param point of which to check the position 2826 3661 * @param *LC LinkedCell structure 2827 3662 * 2828 * @return true if the point is inside the tesselation structure, false otherwise 2829 */ 2830 bool Tesselation::IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const 2831 { 2832 Info FunctionInfo(__func__); 2833 class BoundaryTriangleSet *result = FindClosestTriangleToPoint(&Point, LC); 3663 * @return >0 if outside, ==0 if on surface, <0 if inside 3664 */ 3665 double Tesselation::GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const 3666 { 3667 Info FunctionInfo(__func__); 2834 3668 Vector Center; 2835 2836 if (result == NULL) {// is boundary point or only point in point cloud? 2837 Log() << Verbose(1) << Point << " is the only point in vicinity." << endl; 2838 return false; 2839 } 2840 2841 result->GetCenter(&Center); 2842 Log() << Verbose(2) << "INFO: Central point of the triangle is " << Center << "." << endl; 2843 Center.SubtractVector(&Point); 2844 Log() << Verbose(2) << "INFO: Vector from center to point to test is " << Center << "." << endl; 2845 if (Center.ScalarProduct(&result->NormalVector) > -MYEPSILON) { 2846 Log() << Verbose(1) << Point << " is an inner point." << endl; 2847 return true; 3669 Vector helper; 3670 Vector DistanceToCenter; 3671 Vector Intersection; 3672 double distance = 0.; 3673 3674 if (triangle == NULL) {// is boundary point or only point in point cloud? 3675 DoLog(1) && (Log() << Verbose(1) << "No triangle given!" << endl); 3676 return -1.; 2848 3677 } else { 2849 Log() << Verbose(1) << Point << " is NOT an inner point." << endl; 2850 return false; 2851 } 2852 } 2853 2854 /** Checks whether the provided TesselPoint is within the tesselation structure. 2855 * 2856 * @param *Point of which to check the position 2857 * @param *LC Linked Cell structure 2858 * 2859 * @return true if the point is inside the tesselation structure, false otherwise 2860 */ 2861 bool Tesselation::IsInnerPoint(const TesselPoint * const Point, const LinkedCell* const LC) const 2862 { 2863 Info FunctionInfo(__func__); 2864 return IsInnerPoint(*(Point->node), LC); 2865 } 3678 DoLog(1) && (Log() << Verbose(1) << "INFO: Closest triangle found is " << *triangle << " with normal vector " << triangle->NormalVector << "." << endl); 3679 } 3680 3681 triangle->GetCenter(&Center); 3682 DoLog(2) && (Log() << Verbose(2) << "INFO: Central point of the triangle is " << Center << "." << endl); 3683 DistanceToCenter.CopyVector(&Center); 3684 DistanceToCenter.SubtractVector(&Point); 3685 DoLog(2) && (Log() << Verbose(2) << "INFO: Vector from point to test to center is " << DistanceToCenter << "." << endl); 3686 3687 // check whether we are on boundary 3688 if (fabs(DistanceToCenter.ScalarProduct(&triangle->NormalVector)) < MYEPSILON) { 3689 // calculate whether inside of triangle 3690 DistanceToCenter.CopyVector(&Point); 3691 Center.CopyVector(&Point); 3692 Center.SubtractVector(&triangle->NormalVector); // points towards MolCenter 3693 DistanceToCenter.AddVector(&triangle->NormalVector); // points outside 3694 DoLog(1) && (Log() << Verbose(1) << "INFO: Calling Intersection with " << Center << " and " << DistanceToCenter << "." << endl); 3695 if (triangle->GetIntersectionInsideTriangle(&Center, &DistanceToCenter, &Intersection)) { 3696 DoLog(1) && (Log() << Verbose(1) << Point << " is inner point: sufficiently close to boundary, " << Intersection << "." << endl); 3697 return 0.; 3698 } else { 3699 DoLog(1) && (Log() << Verbose(1) << Point << " is NOT an inner point: on triangle plane but outside of triangle bounds." << endl); 3700 return false; 3701 } 3702 } else { 3703 // calculate smallest distance 3704 distance = triangle->GetClosestPointInsideTriangle(&Point, &Intersection); 3705 DoLog(1) && (Log() << Verbose(1) << "Closest point on triangle is " << Intersection << "." << endl); 3706 3707 // then check direction to boundary 3708 if (DistanceToCenter.ScalarProduct(&triangle->NormalVector) > MYEPSILON) { 3709 DoLog(1) && (Log() << Verbose(1) << Point << " is an inner point, " << distance << " below surface." << endl); 3710 return -distance; 3711 } else { 3712 DoLog(1) && (Log() << Verbose(1) << Point << " is NOT an inner point, " << distance << " above surface." << endl); 3713 return +distance; 3714 } 3715 } 3716 } 3717 ; 3718 3719 /** Calculates minimum distance from \a&Point to a tesselated surface. 3720 * Combines \sa FindClosestTrianglesToVector() and \sa GetDistanceSquaredToTriangle(). 3721 * \param &Point point to calculate distance from 3722 * \param *LC needed for finding closest points fast 3723 * \return distance squared to closest point on surface 3724 */ 3725 double Tesselation::GetDistanceToSurface(const Vector &Point, const LinkedCell* const LC) const 3726 { 3727 Info FunctionInfo(__func__); 3728 TriangleIntersectionList Intersections(&Point, this, LC); 3729 3730 return Intersections.GetSmallestDistance(); 3731 } 3732 ; 3733 3734 /** Calculates minimum distance from \a&Point to a tesselated surface. 3735 * Combines \sa FindClosestTrianglesToVector() and \sa GetDistanceSquaredToTriangle(). 3736 * \param &Point point to calculate distance from 3737 * \param *LC needed for finding closest points fast 3738 * \return distance squared to closest point on surface 3739 */ 3740 BoundaryTriangleSet * Tesselation::GetClosestTriangleOnSurface(const Vector &Point, const LinkedCell* const LC) const 3741 { 3742 Info FunctionInfo(__func__); 3743 TriangleIntersectionList Intersections(&Point, this, LC); 3744 3745 return Intersections.GetClosestTriangle(); 3746 } 3747 ; 2866 3748 2867 3749 /** Gets all points connected to the provided point by triangulation lines. … … 2871 3753 * @return set of the all points linked to the provided one 2872 3754 */ 2873 set<TesselPoint*>* Tesselation::GetAllConnectedPoints(const TesselPoint* const Point) const2874 { 2875 2876 set<TesselPoint*> *connectedPoints = new set<TesselPoint*>;3755 TesselPointSet * Tesselation::GetAllConnectedPoints(const TesselPoint* const Point) const 3756 { 3757 Info FunctionInfo(__func__); 3758 TesselPointSet *connectedPoints = new TesselPointSet; 2877 3759 class BoundaryPointSet *ReferencePoint = NULL; 2878 3760 TesselPoint* current; 2879 3761 bool takePoint = false; 2880 2881 3762 // find the respective boundary point 2882 3763 PointMap::const_iterator PointRunner = PointsOnBoundary.find(Point->nr); … … 2884 3765 ReferencePoint = PointRunner->second; 2885 3766 } else { 2886 eLog() << Verbose(2) << "GetAllConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl;3767 DoeLog(2) && (eLog() << Verbose(2) << "GetAllConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl); 2887 3768 ReferencePoint = NULL; 2888 3769 } … … 2890 3771 // little trick so that we look just through lines connect to the BoundaryPoint 2891 3772 // OR fall-back to look through all lines if there is no such BoundaryPoint 2892 const LineMap *Lines;; 3773 const LineMap *Lines; 3774 ; 2893 3775 if (ReferencePoint != NULL) 2894 3776 Lines = &(ReferencePoint->lines); … … 2897 3779 LineMap::const_iterator findLines = Lines->begin(); 2898 3780 while (findLines != Lines->end()) { 2899 takePoint = false;2900 2901 if (findLines->second->endpoints[0]->Nr == Point->nr) {2902 takePoint = true;2903 current = findLines->second->endpoints[1]->node;2904 } else if (findLines->second->endpoints[1]->Nr == Point->nr) {2905 takePoint = true;2906 current = findLines->second->endpoints[0]->node;2907 }2908 2909 if (takePoint) {2910 Log() << Verbose(1) << "INFO: Endpoint " << *current << " of line " << *(findLines->second) << " is enlisted." << endl;2911 connectedPoints->insert(current);2912 }2913 2914 findLines++;2915 } 2916 2917 if (connectedPoints-> size() == 0) { // if have not found any points2918 eLog() << Verbose(1) << "We have not found any connected points to " << *Point<< "." << endl;3781 takePoint = false; 3782 3783 if (findLines->second->endpoints[0]->Nr == Point->nr) { 3784 takePoint = true; 3785 current = findLines->second->endpoints[1]->node; 3786 } else if (findLines->second->endpoints[1]->Nr == Point->nr) { 3787 takePoint = true; 3788 current = findLines->second->endpoints[0]->node; 3789 } 3790 3791 if (takePoint) { 3792 DoLog(1) && (Log() << Verbose(1) << "INFO: Endpoint " << *current << " of line " << *(findLines->second) << " is enlisted." << endl); 3793 connectedPoints->insert(current); 3794 } 3795 3796 findLines++; 3797 } 3798 3799 if (connectedPoints->empty()) { // if have not found any points 3800 DoeLog(1) && (eLog() << Verbose(1) << "We have not found any connected points to " << *Point << "." << endl); 2919 3801 return NULL; 2920 3802 } 2921 3803 2922 3804 return connectedPoints; 2923 } ;2924 3805 } 3806 ; 2925 3807 2926 3808 /** Gets all points connected to the provided point by triangulation lines, ordered such that we have the circle round the point. … … 2936 3818 * @return list of the all points linked to the provided one 2937 3819 */ 2938 list<TesselPoint*> * Tesselation::GetCircleOfSetOfPoints(set<TesselPoint*>*SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const2939 { 2940 3820 TesselPointList * Tesselation::GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const 3821 { 3822 Info FunctionInfo(__func__); 2941 3823 map<double, TesselPoint*> anglesOfPoints; 2942 list<TesselPoint*> *connectedCircle = new list<TesselPoint*>; 3824 TesselPointList *connectedCircle = new TesselPointList; 3825 Vector PlaneNormal; 3826 Vector AngleZero; 3827 Vector OrthogonalVector; 3828 Vector helper; 3829 const TesselPoint * const TrianglePoints[3] = { Point, NULL, NULL }; 3830 TriangleList *triangles = NULL; 3831 3832 if (SetOfNeighbours == NULL) { 3833 DoeLog(2) && (eLog() << Verbose(2) << "Could not find any connected points!" << endl); 3834 delete (connectedCircle); 3835 return NULL; 3836 } 3837 3838 // calculate central point 3839 triangles = FindTriangles(TrianglePoints); 3840 if ((triangles != NULL) && (!triangles->empty())) { 3841 for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) 3842 PlaneNormal.AddVector(&(*Runner)->NormalVector); 3843 } else { 3844 DoeLog(0) && (eLog() << Verbose(0) << "Could not find any triangles for point " << *Point << "." << endl); 3845 performCriticalExit(); 3846 } 3847 PlaneNormal.Scale(1.0 / triangles->size()); 3848 DoLog(1) && (Log() << Verbose(1) << "INFO: Calculated PlaneNormal of all circle points is " << PlaneNormal << "." << endl); 3849 PlaneNormal.Normalize(); 3850 3851 // construct one orthogonal vector 3852 if (Reference != NULL) { 3853 AngleZero.CopyVector(Reference); 3854 AngleZero.SubtractVector(Point->node); 3855 AngleZero.ProjectOntoPlane(&PlaneNormal); 3856 } 3857 if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON)) { 3858 DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node << " as angle 0 referencer." << endl); 3859 AngleZero.CopyVector((*SetOfNeighbours->begin())->node); 3860 AngleZero.SubtractVector(Point->node); 3861 AngleZero.ProjectOntoPlane(&PlaneNormal); 3862 if (AngleZero.NormSquared() < MYEPSILON) { 3863 DoeLog(0) && (eLog() << Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl); 3864 performCriticalExit(); 3865 } 3866 } 3867 DoLog(1) && (Log() << Verbose(1) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl); 3868 if (AngleZero.NormSquared() > MYEPSILON) 3869 OrthogonalVector.MakeNormalVector(&PlaneNormal, &AngleZero); 3870 else 3871 OrthogonalVector.MakeNormalVector(&PlaneNormal); 3872 DoLog(1) && (Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl); 3873 3874 // go through all connected points and calculate angle 3875 for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) { 3876 helper.CopyVector((*listRunner)->node); 3877 helper.SubtractVector(Point->node); 3878 helper.ProjectOntoPlane(&PlaneNormal); 3879 double angle = GetAngle(helper, AngleZero, OrthogonalVector); 3880 DoLog(0) && (Log() << Verbose(0) << "INFO: Calculated angle is " << angle << " for point " << **listRunner << "." << endl); 3881 anglesOfPoints.insert(pair<double, TesselPoint*> (angle, (*listRunner))); 3882 } 3883 3884 for (map<double, TesselPoint*>::iterator AngleRunner = anglesOfPoints.begin(); AngleRunner != anglesOfPoints.end(); AngleRunner++) { 3885 connectedCircle->push_back(AngleRunner->second); 3886 } 3887 3888 return connectedCircle; 3889 } 3890 3891 /** Gets all points connected to the provided point by triangulation lines, ordered such that we have the circle round the point. 3892 * Maps them down onto the plane designated by the axis \a *Point and \a *Reference. The center of all points 3893 * connected in the tesselation to \a *Point is mapped to spherical coordinates with the zero angle being given 3894 * by the mapped down \a *Reference. Hence, the biggest and the smallest angles are those of the two shanks of the 3895 * triangle we are looking for. 3896 * 3897 * @param *SetOfNeighbours all points for which the angle should be calculated 3898 * @param *Point of which get all connected points 3899 * @param *Reference Reference vector for zero angle or NULL for no preference 3900 * @return list of the all points linked to the provided one 3901 */ 3902 TesselPointList * Tesselation::GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const 3903 { 3904 Info FunctionInfo(__func__); 3905 map<double, TesselPoint*> anglesOfPoints; 3906 TesselPointList *connectedCircle = new TesselPointList; 2943 3907 Vector center; 2944 3908 Vector PlaneNormal; … … 2948 3912 2949 3913 if (SetOfNeighbours == NULL) { 2950 eLog() << Verbose(2) << "Could not find any connected points!" << endl;2951 delete (connectedCircle);3914 DoeLog(2) && (eLog() << Verbose(2) << "Could not find any connected points!" << endl); 3915 delete (connectedCircle); 2952 3916 return NULL; 2953 3917 } 2954 3918 3919 // check whether there's something to do 3920 if (SetOfNeighbours->size() < 3) { 3921 for (TesselPointSet::iterator TesselRunner = SetOfNeighbours->begin(); TesselRunner != SetOfNeighbours->end(); TesselRunner++) 3922 connectedCircle->push_back(*TesselRunner); 3923 return connectedCircle; 3924 } 3925 3926 DoLog(1) && (Log() << Verbose(1) << "INFO: Point is " << *Point << " and Reference is " << *Reference << "." << endl); 2955 3927 // calculate central point 2956 for (set<TesselPoint*>::const_iterator TesselRunner = SetOfNeighbours->begin(); TesselRunner != SetOfNeighbours->end(); TesselRunner++) 2957 center.AddVector((*TesselRunner)->node); 3928 TesselPointSet::const_iterator TesselA = SetOfNeighbours->begin(); 3929 TesselPointSet::const_iterator TesselB = SetOfNeighbours->begin(); 3930 TesselPointSet::const_iterator TesselC = SetOfNeighbours->begin(); 3931 TesselB++; 3932 TesselC++; 3933 TesselC++; 3934 int counter = 0; 3935 while (TesselC != SetOfNeighbours->end()) { 3936 helper.MakeNormalVector((*TesselA)->node, (*TesselB)->node, (*TesselC)->node); 3937 DoLog(0) && (Log() << Verbose(0) << "Making normal vector out of " << *(*TesselA) << ", " << *(*TesselB) << " and " << *(*TesselC) << ":" << helper << endl); 3938 counter++; 3939 TesselA++; 3940 TesselB++; 3941 TesselC++; 3942 PlaneNormal.AddVector(&helper); 3943 } 2958 3944 //Log() << Verbose(0) << "Summed vectors " << center << "; number of points " << connectedPoints.size() 2959 // << "; scale factor " << 1.0/connectedPoints.size();2960 center.Scale(1.0/SetOfNeighbours->size());2961 Log() << Verbose(1) << "INFO: Calculated center of all circle points is " << center << "." << endl;2962 2963 // projection plane of the circle is at the closes Point and normal is pointing away from center of all circle points2964 PlaneNormal.CopyVector(Point->node);2965 PlaneNormal.SubtractVector(¢er);2966 PlaneNormal.Normalize();2967 Log() << Verbose(1) << "INFO: Calculated plane normal of circle is " << PlaneNormal << "." << endl;3945 // << "; scale factor " << counter; 3946 PlaneNormal.Scale(1.0 / (double) counter); 3947 // Log() << Verbose(1) << "INFO: Calculated center of all circle points is " << center << "." << endl; 3948 // 3949 // // projection plane of the circle is at the closes Point and normal is pointing away from center of all circle points 3950 // PlaneNormal.CopyVector(Point->node); 3951 // PlaneNormal.SubtractVector(¢er); 3952 // PlaneNormal.Normalize(); 3953 DoLog(1) && (Log() << Verbose(1) << "INFO: Calculated plane normal of circle is " << PlaneNormal << "." << endl); 2968 3954 2969 3955 // construct one orthogonal vector … … 2973 3959 AngleZero.ProjectOntoPlane(&PlaneNormal); 2974 3960 } 2975 if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON 2976 Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node << " as angle 0 referencer." << endl;3961 if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON)) { 3962 DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node << " as angle 0 referencer." << endl); 2977 3963 AngleZero.CopyVector((*SetOfNeighbours->begin())->node); 2978 3964 AngleZero.SubtractVector(Point->node); 2979 3965 AngleZero.ProjectOntoPlane(&PlaneNormal); 2980 3966 if (AngleZero.NormSquared() < MYEPSILON) { 2981 eLog() << Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl;3967 DoeLog(0) && (eLog() << Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl); 2982 3968 performCriticalExit(); 2983 3969 } 2984 3970 } 2985 Log() << Verbose(1) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl;3971 DoLog(1) && (Log() << Verbose(1) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl); 2986 3972 if (AngleZero.NormSquared() > MYEPSILON) 2987 3973 OrthogonalVector.MakeNormalVector(&PlaneNormal, &AngleZero); 2988 3974 else 2989 3975 OrthogonalVector.MakeNormalVector(&PlaneNormal); 2990 Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl;3976 DoLog(1) && (Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl); 2991 3977 2992 3978 // go through all connected points and calculate angle 2993 for (set<TesselPoint*>::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) { 3979 pair<map<double, TesselPoint*>::iterator, bool> InserterTest; 3980 for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) { 2994 3981 helper.CopyVector((*listRunner)->node); 2995 3982 helper.SubtractVector(Point->node); 2996 3983 helper.ProjectOntoPlane(&PlaneNormal); 2997 3984 double angle = GetAngle(helper, AngleZero, OrthogonalVector); 2998 Log() << Verbose(0) << "INFO: Calculated angle is " << angle << " for point " << **listRunner << "." << endl; 2999 anglesOfPoints.insert(pair<double, TesselPoint*>(angle, (*listRunner))); 3000 } 3001 3002 for(map<double, TesselPoint*>::iterator AngleRunner = anglesOfPoints.begin(); AngleRunner != anglesOfPoints.end(); AngleRunner++) { 3985 if (angle > M_PI) // the correction is of no use here (and not desired) 3986 angle = 2. * M_PI - angle; 3987 DoLog(0) && (Log() << Verbose(0) << "INFO: Calculated angle between " << helper << " and " << AngleZero << " is " << angle << " for point " << **listRunner << "." << endl); 3988 InserterTest = anglesOfPoints.insert(pair<double, TesselPoint*> (angle, (*listRunner))); 3989 if (!InserterTest.second) { 3990 DoeLog(0) && (eLog() << Verbose(0) << "GetCircleOfSetOfPoints() got two atoms with same angle: " << *((InserterTest.first)->second) << " and " << (*listRunner) << endl); 3991 performCriticalExit(); 3992 } 3993 } 3994 3995 for (map<double, TesselPoint*>::iterator AngleRunner = anglesOfPoints.begin(); AngleRunner != anglesOfPoints.end(); AngleRunner++) { 3003 3996 connectedCircle->push_back(AngleRunner->second); 3004 3997 } … … 3013 4006 * @return list of the all points linked to the provided one 3014 4007 */ 3015 list<list<TesselPoint*> *>* Tesselation::GetPathsOfConnectedPoints(const TesselPoint* const Point) const3016 { 3017 4008 ListOfTesselPointList * Tesselation::GetPathsOfConnectedPoints(const TesselPoint* const Point) const 4009 { 4010 Info FunctionInfo(__func__); 3018 4011 map<double, TesselPoint*> anglesOfPoints; 3019 list< list<TesselPoint*> *> *ListOfPaths = new list<list<TesselPoint*> *>;3020 list<TesselPoint*>*connectedPath = NULL;4012 list<TesselPointList *> *ListOfPaths = new list<TesselPointList *> ; 4013 TesselPointList *connectedPath = NULL; 3021 4014 Vector center; 3022 4015 Vector PlaneNormal; … … 3029 4022 class BoundaryLineSet *CurrentLine = NULL; 3030 4023 class BoundaryLineSet *StartLine = NULL; 3031 3032 4024 // find the respective boundary point 3033 4025 PointMap::const_iterator PointRunner = PointsOnBoundary.find(Point->nr); … … 3035 4027 ReferencePoint = PointRunner->second; 3036 4028 } else { 3037 eLog() << Verbose(1) << "GetPathOfConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl;4029 DoeLog(1) && (eLog() << Verbose(1) << "GetPathOfConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl); 3038 4030 return NULL; 3039 4031 } 3040 4032 3041 map 3042 map 3043 map 3044 map 4033 map<class BoundaryLineSet *, bool> TouchedLine; 4034 map<class BoundaryTriangleSet *, bool> TouchedTriangle; 4035 map<class BoundaryLineSet *, bool>::iterator LineRunner; 4036 map<class BoundaryTriangleSet *, bool>::iterator TriangleRunner; 3045 4037 for (LineMap::iterator Runner = ReferencePoint->lines.begin(); Runner != ReferencePoint->lines.end(); Runner++) { 3046 TouchedLine.insert( pair <class BoundaryLineSet *, bool>(Runner->second, false));4038 TouchedLine.insert(pair<class BoundaryLineSet *, bool> (Runner->second, false)); 3047 4039 for (TriangleMap::iterator Sprinter = Runner->second->triangles.begin(); Sprinter != Runner->second->triangles.end(); Sprinter++) 3048 TouchedTriangle.insert( pair <class BoundaryTriangleSet *, bool>(Sprinter->second, false));4040 TouchedTriangle.insert(pair<class BoundaryTriangleSet *, bool> (Sprinter->second, false)); 3049 4041 } 3050 4042 if (!ReferencePoint->lines.empty()) { … … 3052 4044 LineRunner = TouchedLine.find(runner->second); 3053 4045 if (LineRunner == TouchedLine.end()) { 3054 eLog() << Verbose(1) << "I could not find " << *runner->second << " in the touched list." << endl;4046 DoeLog(1) && (eLog() << Verbose(1) << "I could not find " << *runner->second << " in the touched list." << endl); 3055 4047 } else if (!LineRunner->second) { 3056 4048 LineRunner->second = true; 3057 connectedPath = new list<TesselPoint*>;4049 connectedPath = new TesselPointList; 3058 4050 triangle = NULL; 3059 4051 CurrentLine = runner->second; 3060 4052 StartLine = CurrentLine; 3061 4053 CurrentPoint = CurrentLine->GetOtherEndpoint(ReferencePoint); 3062 Log() << Verbose(1)<< "INFO: Beginning path retrieval at " << *CurrentPoint << " of line " << *CurrentLine << "." << endl;4054 DoLog(1) && (Log() << Verbose(1) << "INFO: Beginning path retrieval at " << *CurrentPoint << " of line " << *CurrentLine << "." << endl); 3063 4055 do { 3064 4056 // push current one 3065 Log() << Verbose(1) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl;4057 DoLog(1) && (Log() << Verbose(1) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl); 3066 4058 connectedPath->push_back(CurrentPoint->node); 3067 4059 3068 4060 // find next triangle 3069 4061 for (TriangleMap::iterator Runner = CurrentLine->triangles.begin(); Runner != CurrentLine->triangles.end(); Runner++) { 3070 Log() << Verbose(1) << "INFO: Inspecting triangle " << *Runner->second << "." << endl;4062 DoLog(1) && (Log() << Verbose(1) << "INFO: Inspecting triangle " << *Runner->second << "." << endl); 3071 4063 if ((Runner->second != triangle)) { // look for first triangle not equal to old one 3072 4064 triangle = Runner->second; … … 3075 4067 if (!TriangleRunner->second) { 3076 4068 TriangleRunner->second = true; 3077 Log() << Verbose(1) << "INFO: Connecting triangle is " << *triangle << "." << endl;4069 DoLog(1) && (Log() << Verbose(1) << "INFO: Connecting triangle is " << *triangle << "." << endl); 3078 4070 break; 3079 4071 } else { 3080 Log() << Verbose(1) << "INFO: Skipping " << *triangle << ", as we have already visited it." << endl;4072 DoLog(1) && (Log() << Verbose(1) << "INFO: Skipping " << *triangle << ", as we have already visited it." << endl); 3081 4073 triangle = NULL; 3082 4074 } 3083 4075 } else { 3084 eLog() << Verbose(1) << "I could not find " << *triangle << " in the touched list." << endl;4076 DoeLog(1) && (eLog() << Verbose(1) << "I could not find " << *triangle << " in the touched list." << endl); 3085 4077 triangle = NULL; 3086 4078 } … … 3090 4082 break; 3091 4083 // find next line 3092 for (int i =0;i<3;i++) {4084 for (int i = 0; i < 3; i++) { 3093 4085 if ((triangle->lines[i] != CurrentLine) && (triangle->lines[i]->ContainsBoundaryPoint(ReferencePoint))) { // not the current line and still containing Point 3094 4086 CurrentLine = triangle->lines[i]; 3095 Log() << Verbose(1) << "INFO: Connecting line is " << *CurrentLine << "." << endl;4087 DoLog(1) && (Log() << Verbose(1) << "INFO: Connecting line is " << *CurrentLine << "." << endl); 3096 4088 break; 3097 4089 } … … 3099 4091 LineRunner = TouchedLine.find(CurrentLine); 3100 4092 if (LineRunner == TouchedLine.end()) 3101 eLog() << Verbose(1) << "I could not find " << *CurrentLine << " in the touched list." << endl;4093 DoeLog(1) && (eLog() << Verbose(1) << "I could not find " << *CurrentLine << " in the touched list." << endl); 3102 4094 else 3103 4095 LineRunner->second = true; … … 3107 4099 } while (CurrentLine != StartLine); 3108 4100 // last point is missing, as it's on start line 3109 Log() << Verbose(1) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl;4101 DoLog(1) && (Log() << Verbose(1) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl); 3110 4102 if (StartLine->GetOtherEndpoint(ReferencePoint)->node != connectedPath->back()) 3111 4103 connectedPath->push_back(StartLine->GetOtherEndpoint(ReferencePoint)->node); … … 3113 4105 ListOfPaths->push_back(connectedPath); 3114 4106 } else { 3115 Log() << Verbose(1) << "INFO: Skipping " << *runner->second << ", as we have already visited it." << endl;4107 DoLog(1) && (Log() << Verbose(1) << "INFO: Skipping " << *runner->second << ", as we have already visited it." << endl); 3116 4108 } 3117 4109 } 3118 4110 } else { 3119 eLog() << Verbose(1) << "There are no lines attached to " << *ReferencePoint << "." << endl;4111 DoeLog(1) && (eLog() << Verbose(1) << "There are no lines attached to " << *ReferencePoint << "." << endl); 3120 4112 } 3121 4113 … … 3129 4121 * @return list of the closed paths 3130 4122 */ 3131 list<list<TesselPoint*> *>* Tesselation::GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const3132 { 3133 3134 list< list<TesselPoint*>*> *ListofPaths = GetPathsOfConnectedPoints(Point);3135 list< list<TesselPoint*> *> *ListofClosedPaths = new list<list<TesselPoint*> *>;3136 list<TesselPoint*>*connectedPath = NULL;3137 list<TesselPoint*>*newPath = NULL;4123 ListOfTesselPointList * Tesselation::GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const 4124 { 4125 Info FunctionInfo(__func__); 4126 list<TesselPointList *> *ListofPaths = GetPathsOfConnectedPoints(Point); 4127 list<TesselPointList *> *ListofClosedPaths = new list<TesselPointList *> ; 4128 TesselPointList *connectedPath = NULL; 4129 TesselPointList *newPath = NULL; 3138 4130 int count = 0; 3139 3140 3141 list<TesselPoint*>::iterator CircleRunner; 3142 list<TesselPoint*>::iterator CircleStart; 3143 3144 for(list<list<TesselPoint*> *>::iterator ListRunner = ListofPaths->begin(); ListRunner != ListofPaths->end(); ListRunner++) { 4131 TesselPointList::iterator CircleRunner; 4132 TesselPointList::iterator CircleStart; 4133 4134 for (list<TesselPointList *>::iterator ListRunner = ListofPaths->begin(); ListRunner != ListofPaths->end(); ListRunner++) { 3145 4135 connectedPath = *ListRunner; 3146 4136 3147 Log() << Verbose(1) << "INFO: Current path is " << connectedPath << "." << endl;4137 DoLog(1) && (Log() << Verbose(1) << "INFO: Current path is " << connectedPath << "." << endl); 3148 4138 3149 4139 // go through list, look for reappearance of starting Point and count 3150 4140 CircleStart = connectedPath->begin(); 3151 3152 4141 // go through list, look for reappearance of starting Point and create list 3153 list<TesselPoint*>::iterator Marker = CircleStart;4142 TesselPointList::iterator Marker = CircleStart; 3154 4143 for (CircleRunner = CircleStart; CircleRunner != connectedPath->end(); CircleRunner++) { 3155 4144 if ((*CircleRunner == *CircleStart) && (CircleRunner != CircleStart)) { // is not the very first point 3156 4145 // we have a closed circle from Marker to new Marker 3157 Log() << Verbose(1) << count+1 << ". closed path consists of: ";3158 newPath = new list<TesselPoint*>;3159 list<TesselPoint*>::iterator CircleSprinter = Marker;4146 DoLog(1) && (Log() << Verbose(1) << count + 1 << ". closed path consists of: "); 4147 newPath = new TesselPointList; 4148 TesselPointList::iterator CircleSprinter = Marker; 3160 4149 for (; CircleSprinter != CircleRunner; CircleSprinter++) { 3161 4150 newPath->push_back(*CircleSprinter); 3162 Log() << Verbose(0) << (**CircleSprinter) << " <-> ";4151 DoLog(0) && (Log() << Verbose(0) << (**CircleSprinter) << " <-> "); 3163 4152 } 3164 Log() << Verbose(0) << ".." << endl;4153 DoLog(0) && (Log() << Verbose(0) << ".." << endl); 3165 4154 count++; 3166 4155 Marker = CircleRunner; … … 3171 4160 } 3172 4161 } 3173 Log() << Verbose(1) << "INFO: " << count << " closed additional path(s) have been created." << endl;4162 DoLog(1) && (Log() << Verbose(1) << "INFO: " << count << " closed additional path(s) have been created." << endl); 3174 4163 3175 4164 // delete list of paths … … 3177 4166 connectedPath = *(ListofPaths->begin()); 3178 4167 ListofPaths->remove(connectedPath); 3179 delete (connectedPath);3180 } 3181 delete (ListofPaths);4168 delete (connectedPath); 4169 } 4170 delete (ListofPaths); 3182 4171 3183 4172 // exit 3184 4173 return ListofClosedPaths; 3185 } ;3186 4174 } 4175 ; 3187 4176 3188 4177 /** Gets all belonging triangles for a given BoundaryPointSet. … … 3191 4180 * \return pointer to allocated list of triangles 3192 4181 */ 3193 set<BoundaryTriangleSet*>*Tesselation::GetAllTriangles(const BoundaryPointSet * const Point) const3194 { 3195 3196 set<BoundaryTriangleSet*> *connectedTriangles = new set<BoundaryTriangleSet*>;4182 TriangleSet *Tesselation::GetAllTriangles(const BoundaryPointSet * const Point) const 4183 { 4184 Info FunctionInfo(__func__); 4185 TriangleSet *connectedTriangles = new TriangleSet; 3197 4186 3198 4187 if (Point == NULL) { 3199 eLog() << Verbose(1) << "Point given is NULL." << endl;4188 DoeLog(1) && (eLog() << Verbose(1) << "Point given is NULL." << endl); 3200 4189 } else { 3201 4190 // go through its lines and insert all triangles 3202 4191 for (LineMap::const_iterator LineRunner = Point->lines.begin(); LineRunner != Point->lines.end(); LineRunner++) 3203 4192 for (TriangleMap::iterator TriangleRunner = (LineRunner->second)->triangles.begin(); TriangleRunner != (LineRunner->second)->triangles.end(); TriangleRunner++) { 3204 connectedTriangles->insert(TriangleRunner->second);3205 }4193 connectedTriangles->insert(TriangleRunner->second); 4194 } 3206 4195 } 3207 4196 3208 4197 return connectedTriangles; 3209 } ;3210 4198 } 4199 ; 3211 4200 3212 4201 /** Removes a boundary point from the envelope while keeping it closed. … … 3221 4210 * \return volume added to the volume inside the tesselated surface by the removal 3222 4211 */ 3223 double Tesselation::RemovePointFromTesselatedSurface(class BoundaryPointSet *point) { 4212 double Tesselation::RemovePointFromTesselatedSurface(class BoundaryPointSet *point) 4213 { 3224 4214 class BoundaryLineSet *line = NULL; 3225 4215 class BoundaryTriangleSet *triangle = NULL; … … 3229 4219 3230 4220 if (point == NULL) { 3231 eLog() << Verbose(1) << "Cannot remove the point " << point << ", it's NULL!" << endl;4221 DoeLog(1) && (eLog() << Verbose(1) << "Cannot remove the point " << point << ", it's NULL!" << endl); 3232 4222 return 0.; 3233 4223 } else 3234 Log() << Verbose(0) << "Removing point " << *point << " from tesselated boundary ..." << endl;4224 DoLog(0) && (Log() << Verbose(0) << "Removing point " << *point << " from tesselated boundary ..." << endl); 3235 4225 3236 4226 // copy old location for the volume … … 3239 4229 // get list of connected points 3240 4230 if (point->lines.empty()) { 3241 eLog() << Verbose(1) << "Cannot remove the point " << *point << ", it's connected to no lines!" << endl;4231 DoeLog(1) && (eLog() << Verbose(1) << "Cannot remove the point " << *point << ", it's connected to no lines!" << endl); 3242 4232 return 0.; 3243 4233 } 3244 4234 3245 list< list<TesselPoint*>*> *ListOfClosedPaths = GetClosedPathsOfConnectedPoints(point->node);3246 list<TesselPoint*>*connectedPath = NULL;4235 list<TesselPointList *> *ListOfClosedPaths = GetClosedPathsOfConnectedPoints(point->node); 4236 TesselPointList *connectedPath = NULL; 3247 4237 3248 4238 // gather all triangles 3249 4239 for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) 3250 count +=LineRunner->second->triangles.size();3251 map<class BoundaryTriangleSet *, int>Candidates;4240 count += LineRunner->second->triangles.size(); 4241 TriangleMap Candidates; 3252 4242 for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) { 3253 4243 line = LineRunner->second; 3254 4244 for (TriangleMap::iterator TriangleRunner = line->triangles.begin(); TriangleRunner != line->triangles.end(); TriangleRunner++) { 3255 4245 triangle = TriangleRunner->second; 3256 Candidates.insert( pair<class BoundaryTriangleSet *, int> (triangle, triangle->Nr));4246 Candidates.insert(TrianglePair(triangle->Nr, triangle)); 3257 4247 } 3258 4248 } 3259 4249 3260 4250 // remove all triangles 3261 count =0;4251 count = 0; 3262 4252 NormalVector.Zero(); 3263 for ( map<class BoundaryTriangleSet *, int>::iterator Runner = Candidates.begin(); Runner != Candidates.end(); Runner++) {3264 Log() << Verbose(1) << "INFO: Removing triangle " << *(Runner->first) << "." << endl;3265 NormalVector.SubtractVector(&Runner-> first->NormalVector); // has to point inward3266 RemoveTesselationTriangle(Runner-> first);4253 for (TriangleMap::iterator Runner = Candidates.begin(); Runner != Candidates.end(); Runner++) { 4254 DoLog(1) && (Log() << Verbose(1) << "INFO: Removing triangle " << *(Runner->second) << "." << endl); 4255 NormalVector.SubtractVector(&Runner->second->NormalVector); // has to point inward 4256 RemoveTesselationTriangle(Runner->second); 3267 4257 count++; 3268 4258 } 3269 Log() << Verbose(1) << count << " triangles were removed." << endl;3270 3271 list< list<TesselPoint*>*>::iterator ListAdvance = ListOfClosedPaths->begin();3272 list< list<TesselPoint*>*>::iterator ListRunner = ListAdvance;3273 map<class BoundaryTriangleSet *, int>::iterator NumberRunner = Candidates.begin();3274 list<TesselPoint*>::iterator StartNode, MiddleNode, EndNode;4259 DoLog(1) && (Log() << Verbose(1) << count << " triangles were removed." << endl); 4260 4261 list<TesselPointList *>::iterator ListAdvance = ListOfClosedPaths->begin(); 4262 list<TesselPointList *>::iterator ListRunner = ListAdvance; 4263 TriangleMap::iterator NumberRunner = Candidates.begin(); 4264 TesselPointList::iterator StartNode, MiddleNode, EndNode; 3275 4265 double angle; 3276 4266 double smallestangle; 3277 4267 Vector Point, Reference, OrthogonalVector; 3278 if (count > 2) { 4268 if (count > 2) { // less than three triangles, then nothing will be created 3279 4269 class TesselPoint *TriangleCandidates[3]; 3280 4270 count = 0; 3281 for ( ; ListRunner != ListOfClosedPaths->end(); ListRunner = ListAdvance) {// go through all closed paths4271 for (; ListRunner != ListOfClosedPaths->end(); ListRunner = ListAdvance) { // go through all closed paths 3282 4272 if (ListAdvance != ListOfClosedPaths->end()) 3283 4273 ListAdvance++; 3284 4274 3285 4275 connectedPath = *ListRunner; 3286 3287 4276 // re-create all triangles by going through connected points list 3288 list<class BoundaryLineSet *>NewLines;3289 for (; !connectedPath->empty();) {4277 LineList NewLines; 4278 for (; !connectedPath->empty();) { 3290 4279 // search middle node with widest angle to next neighbours 3291 4280 EndNode = connectedPath->end(); 3292 4281 smallestangle = 0.; 3293 4282 for (MiddleNode = connectedPath->begin(); MiddleNode != connectedPath->end(); MiddleNode++) { 3294 Log() << Verbose(1) << "INFO: MiddleNode is " << **MiddleNode << "." << endl;4283 DoLog(1) && (Log() << Verbose(1) << "INFO: MiddleNode is " << **MiddleNode << "." << endl); 3295 4284 // construct vectors to next and previous neighbour 3296 4285 StartNode = MiddleNode; … … 3313 4302 angle = GetAngle(Point, Reference, OrthogonalVector); 3314 4303 //if (angle < M_PI) // no wrong-sided triangles, please? 3315 if(fabs(angle - M_PI) < fabs(smallestangle - M_PI)) {// get straightest angle (i.e. construct those triangles with smallest area first)3316 3317 3318 4304 if (fabs(angle - M_PI) < fabs(smallestangle - M_PI)) { // get straightest angle (i.e. construct those triangles with smallest area first) 4305 smallestangle = angle; 4306 EndNode = MiddleNode; 4307 } 3319 4308 } 3320 4309 MiddleNode = EndNode; 3321 4310 if (MiddleNode == connectedPath->end()) { 3322 eLog() << Verbose(0) << "CRITICAL: Could not find a smallest angle!" << endl;4311 DoeLog(0) && (eLog() << Verbose(0) << "CRITICAL: Could not find a smallest angle!" << endl); 3323 4312 performCriticalExit(); 3324 4313 } … … 3330 4319 if (EndNode == connectedPath->end()) 3331 4320 EndNode = connectedPath->begin(); 3332 Log() << Verbose(2) << "INFO: StartNode is " << **StartNode << "." << endl;3333 Log() << Verbose(2) << "INFO: MiddleNode is " << **MiddleNode << "." << endl;3334 Log() << Verbose(2) << "INFO: EndNode is " << **EndNode << "." << endl;3335 Log() << Verbose(1) << "INFO: Attempting to create triangle " << (*StartNode)->Name << ", " << (*MiddleNode)->Name << " and " << (*EndNode)->Name << "." << endl;4321 DoLog(2) && (Log() << Verbose(2) << "INFO: StartNode is " << **StartNode << "." << endl); 4322 DoLog(2) && (Log() << Verbose(2) << "INFO: MiddleNode is " << **MiddleNode << "." << endl); 4323 DoLog(2) && (Log() << Verbose(2) << "INFO: EndNode is " << **EndNode << "." << endl); 4324 DoLog(1) && (Log() << Verbose(1) << "INFO: Attempting to create triangle " << (*StartNode)->Name << ", " << (*MiddleNode)->Name << " and " << (*EndNode)->Name << "." << endl); 3336 4325 TriangleCandidates[0] = *StartNode; 3337 4326 TriangleCandidates[1] = *MiddleNode; … … 3339 4328 triangle = GetPresentTriangle(TriangleCandidates); 3340 4329 if (triangle != NULL) { 3341 eLog() << Verbose(0) << "New triangle already present, skipping!" << endl;4330 DoeLog(0) && (eLog() << Verbose(0) << "New triangle already present, skipping!" << endl); 3342 4331 StartNode++; 3343 4332 MiddleNode++; … … 3351 4340 continue; 3352 4341 } 3353 Log() << Verbose(3) << "Adding new triangle points."<< endl;4342 DoLog(3) && (Log() << Verbose(3) << "Adding new triangle points." << endl); 3354 4343 AddTesselationPoint(*StartNode, 0); 3355 4344 AddTesselationPoint(*MiddleNode, 1); 3356 4345 AddTesselationPoint(*EndNode, 2); 3357 Log() << Verbose(3) << "Adding new triangle lines."<< endl;3358 AddTesselationLine( TPS[0], TPS[1], 0);3359 AddTesselationLine( TPS[0], TPS[2], 1);4346 DoLog(3) && (Log() << Verbose(3) << "Adding new triangle lines." << endl); 4347 AddTesselationLine(NULL, NULL, TPS[0], TPS[1], 0); 4348 AddTesselationLine(NULL, NULL, TPS[0], TPS[2], 1); 3360 4349 NewLines.push_back(BLS[1]); 3361 AddTesselationLine( TPS[1], TPS[2], 2);4350 AddTesselationLine(NULL, NULL, TPS[1], TPS[2], 2); 3362 4351 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 3363 4352 BTS->GetNormalVector(NormalVector); … … 3370 4359 // prepare nodes for next triangle 3371 4360 StartNode = EndNode; 3372 Log() << Verbose(2) << "Removing " << **MiddleNode << " from closed path, remaining points: " << connectedPath->size() << "." << endl;4361 DoLog(2) && (Log() << Verbose(2) << "Removing " << **MiddleNode << " from closed path, remaining points: " << connectedPath->size() << "." << endl); 3373 4362 connectedPath->remove(*MiddleNode); // remove the middle node (it is surrounded by triangles) 3374 4363 if (connectedPath->size() == 2) { // we are done … … 3377 4366 break; 3378 4367 } else if (connectedPath->size() < 2) { // something's gone wrong! 3379 eLog() << Verbose(0) << "CRITICAL: There are only two endpoints left!" << endl;4368 DoeLog(0) && (eLog() << Verbose(0) << "CRITICAL: There are only two endpoints left!" << endl); 3380 4369 performCriticalExit(); 3381 4370 } else { … … 3392 4381 // maximize the inner lines (we preferentially created lines with a huge angle, which is for the tesselation not wanted though useful for the closing) 3393 4382 if (NewLines.size() > 1) { 3394 list<class BoundaryLineSet *>::iterator Candidate;4383 LineList::iterator Candidate; 3395 4384 class BoundaryLineSet *OtherBase = NULL; 3396 4385 double tmp, maxgain; 3397 4386 do { 3398 4387 maxgain = 0; 3399 for (list<class BoundaryLineSet *>::iterator Runner = NewLines.begin(); Runner != NewLines.end(); Runner++) {4388 for (LineList::iterator Runner = NewLines.begin(); Runner != NewLines.end(); Runner++) { 3400 4389 tmp = PickFarthestofTwoBaselines(*Runner); 3401 4390 if (maxgain < tmp) { … … 3406 4395 if (maxgain != 0) { 3407 4396 volume += maxgain; 3408 Log() << Verbose(1) << "Flipping baseline with highest volume" << **Candidate << "." << endl;4397 DoLog(1) && (Log() << Verbose(1) << "Flipping baseline with highest volume" << **Candidate << "." << endl); 3409 4398 OtherBase = FlipBaseline(*Candidate); 3410 4399 NewLines.erase(Candidate); … … 3415 4404 3416 4405 ListOfClosedPaths->remove(connectedPath); 3417 delete (connectedPath);3418 } 3419 Log() << Verbose(0) << count << " triangles were created." << endl;4406 delete (connectedPath); 4407 } 4408 DoLog(0) && (Log() << Verbose(0) << count << " triangles were created." << endl); 3420 4409 } else { 3421 4410 while (!ListOfClosedPaths->empty()) { … … 3423 4412 connectedPath = *ListRunner; 3424 4413 ListOfClosedPaths->remove(connectedPath); 3425 delete (connectedPath);3426 } 3427 Log() << Verbose(0) << "No need to create any triangles." << endl;3428 } 3429 delete (ListOfClosedPaths);3430 3431 Log() << Verbose(0) << "Removed volume is " << volume << "." << endl;4414 delete (connectedPath); 4415 } 4416 DoLog(0) && (Log() << Verbose(0) << "No need to create any triangles." << endl); 4417 } 4418 delete (ListOfClosedPaths); 4419 4420 DoLog(0) && (Log() << Verbose(0) << "Removed volume is " << volume << "." << endl); 3432 4421 3433 4422 return volume; 3434 }; 3435 3436 4423 } 4424 ; 3437 4425 3438 4426 /** 3439 4427 * Finds triangles belonging to the three provided points. 3440 4428 * 3441 * @param *Points[3] list, is expected to contain three points 4429 * @param *Points[3] list, is expected to contain three points (NULL means wildcard) 3442 4430 * 3443 4431 * @return triangles which belong to the provided points, will be empty if there are none, 3444 4432 * will usually be one, in case of degeneration, there will be two 3445 4433 */ 3446 list<BoundaryTriangleSet*>*Tesselation::FindTriangles(const TesselPoint* const Points[3]) const3447 { 3448 3449 list<BoundaryTriangleSet*> *result = new list<BoundaryTriangleSet*>;4434 TriangleList *Tesselation::FindTriangles(const TesselPoint* const Points[3]) const 4435 { 4436 Info FunctionInfo(__func__); 4437 TriangleList *result = new TriangleList; 3450 4438 LineMap::const_iterator FindLine; 3451 4439 TriangleMap::const_iterator FindTriangle; 3452 4440 class BoundaryPointSet *TrianglePoints[3]; 4441 size_t NoOfWildcards = 0; 3453 4442 3454 4443 for (int i = 0; i < 3; i++) { 3455 PointMap::const_iterator FindPoint = PointsOnBoundary.find(Points[i]->nr);3456 if (FindPoint != PointsOnBoundary.end()) {3457 TrianglePoints[i] = FindPoint->second;4444 if (Points[i] == NULL) { 4445 NoOfWildcards++; 4446 TrianglePoints[i] = NULL; 3458 4447 } else { 3459 TrianglePoints[i] = NULL; 3460 } 3461 } 3462 3463 // checks lines between the points in the Points for their adjacent triangles 3464 for (int i = 0; i < 3; i++) { 3465 if (TrianglePoints[i] != NULL) { 3466 for (int j = i+1; j < 3; j++) { 3467 if (TrianglePoints[j] != NULL) { 3468 for (FindLine = TrianglePoints[i]->lines.find(TrianglePoints[j]->node->nr); // is a multimap! 3469 (FindLine != TrianglePoints[i]->lines.end()) && (FindLine->first == TrianglePoints[j]->node->nr); 3470 FindLine++) { 3471 for (FindTriangle = FindLine->second->triangles.begin(); 3472 FindTriangle != FindLine->second->triangles.end(); 3473 FindTriangle++) { 3474 if (FindTriangle->second->IsPresentTupel(TrianglePoints)) { 3475 result->push_back(FindTriangle->second); 4448 PointMap::const_iterator FindPoint = PointsOnBoundary.find(Points[i]->nr); 4449 if (FindPoint != PointsOnBoundary.end()) { 4450 TrianglePoints[i] = FindPoint->second; 4451 } else { 4452 TrianglePoints[i] = NULL; 4453 } 4454 } 4455 } 4456 4457 switch (NoOfWildcards) { 4458 case 0: // checks lines between the points in the Points for their adjacent triangles 4459 for (int i = 0; i < 3; i++) { 4460 if (TrianglePoints[i] != NULL) { 4461 for (int j = i + 1; j < 3; j++) { 4462 if (TrianglePoints[j] != NULL) { 4463 for (FindLine = TrianglePoints[i]->lines.find(TrianglePoints[j]->node->nr); // is a multimap! 4464 (FindLine != TrianglePoints[i]->lines.end()) && (FindLine->first == TrianglePoints[j]->node->nr); FindLine++) { 4465 for (FindTriangle = FindLine->second->triangles.begin(); FindTriangle != FindLine->second->triangles.end(); FindTriangle++) { 4466 if (FindTriangle->second->IsPresentTupel(TrianglePoints)) { 4467 result->push_back(FindTriangle->second); 4468 } 4469 } 3476 4470 } 4471 // Is it sufficient to consider one of the triangle lines for this. 4472 return result; 3477 4473 } 3478 4474 } 3479 // Is it sufficient to consider one of the triangle lines for this.3480 return result;3481 4475 } 3482 4476 } 3483 } 4477 break; 4478 case 1: // copy all triangles of the respective line 4479 { 4480 int i = 0; 4481 for (; i < 3; i++) 4482 if (TrianglePoints[i] == NULL) 4483 break; 4484 for (FindLine = TrianglePoints[(i + 1) % 3]->lines.find(TrianglePoints[(i + 2) % 3]->node->nr); // is a multimap! 4485 (FindLine != TrianglePoints[(i + 1) % 3]->lines.end()) && (FindLine->first == TrianglePoints[(i + 2) % 3]->node->nr); FindLine++) { 4486 for (FindTriangle = FindLine->second->triangles.begin(); FindTriangle != FindLine->second->triangles.end(); FindTriangle++) { 4487 if (FindTriangle->second->IsPresentTupel(TrianglePoints)) { 4488 result->push_back(FindTriangle->second); 4489 } 4490 } 4491 } 4492 break; 4493 } 4494 case 2: // copy all triangles of the respective point 4495 { 4496 int i = 0; 4497 for (; i < 3; i++) 4498 if (TrianglePoints[i] != NULL) 4499 break; 4500 for (LineMap::const_iterator line = TrianglePoints[i]->lines.begin(); line != TrianglePoints[i]->lines.end(); line++) 4501 for (TriangleMap::const_iterator triangle = line->second->triangles.begin(); triangle != line->second->triangles.end(); triangle++) 4502 result->push_back(triangle->second); 4503 result->sort(); 4504 result->unique(); 4505 break; 4506 } 4507 case 3: // copy all triangles 4508 { 4509 for (TriangleMap::const_iterator triangle = TrianglesOnBoundary.begin(); triangle != TrianglesOnBoundary.end(); triangle++) 4510 result->push_back(triangle->second); 4511 break; 4512 } 4513 default: 4514 DoeLog(0) && (eLog() << Verbose(0) << "Number of wildcards is greater than 3, cannot happen!" << endl); 4515 performCriticalExit(); 4516 break; 3484 4517 } 3485 4518 3486 4519 return result; 3487 4520 } 4521 4522 struct BoundaryLineSetCompare 4523 { 4524 bool operator()(const BoundaryLineSet * const a, const BoundaryLineSet * const b) 4525 { 4526 int lowerNra = -1; 4527 int lowerNrb = -1; 4528 4529 if (a->endpoints[0] < a->endpoints[1]) 4530 lowerNra = 0; 4531 else 4532 lowerNra = 1; 4533 4534 if (b->endpoints[0] < b->endpoints[1]) 4535 lowerNrb = 0; 4536 else 4537 lowerNrb = 1; 4538 4539 if (a->endpoints[lowerNra] < b->endpoints[lowerNrb]) 4540 return true; 4541 else if (a->endpoints[lowerNra] > b->endpoints[lowerNrb]) 4542 return false; 4543 else { // both lower-numbered endpoints are the same ... 4544 if (a->endpoints[(lowerNra + 1) % 2] < b->endpoints[(lowerNrb + 1) % 2]) 4545 return true; 4546 else if (a->endpoints[(lowerNra + 1) % 2] > b->endpoints[(lowerNrb + 1) % 2]) 4547 return false; 4548 } 4549 return false; 4550 } 4551 ; 4552 }; 4553 4554 #define UniqueLines set < class BoundaryLineSet *, BoundaryLineSetCompare> 3488 4555 3489 4556 /** … … 3493 4560 * in the list, once as key and once as value 3494 4561 */ 3495 map<int, int>* Tesselation::FindAllDegeneratedLines()3496 { 3497 3498 map<int, class BoundaryLineSet *>AllLines;3499 map<int, int> * DegeneratedLines = new map<int, int>;4562 IndexToIndex * Tesselation::FindAllDegeneratedLines() 4563 { 4564 Info FunctionInfo(__func__); 4565 UniqueLines AllLines; 4566 IndexToIndex * DegeneratedLines = new IndexToIndex; 3500 4567 3501 4568 // sanity check 3502 4569 if (LinesOnBoundary.empty()) { 3503 eLog() << Verbose(2) << "FindAllDegeneratedTriangles() was called without any tesselation structure.";4570 DoeLog(2) && (eLog() << Verbose(2) << "FindAllDegeneratedTriangles() was called without any tesselation structure."); 3504 4571 return DegeneratedLines; 3505 4572 } 3506 3507 4573 LineMap::iterator LineRunner1; 3508 pair< LineMap::iterator, bool> tester;4574 pair<UniqueLines::iterator, bool> tester; 3509 4575 for (LineRunner1 = LinesOnBoundary.begin(); LineRunner1 != LinesOnBoundary.end(); ++LineRunner1) { 3510 tester = AllLines.insert( pair<int,BoundaryLineSet *> (LineRunner1->second->endpoints[0]->Nr, LineRunner1->second));3511 if ( (!tester.second) && (tester.first->second->endpoints[1]->Nr == LineRunner1->second->endpoints[1]->Nr)) { // found degenerated line3512 DegeneratedLines->insert ( pair<int, int> (LineRunner1->second->Nr, tester.first->second->Nr));3513 DegeneratedLines->insert ( pair<int, int> (tester.first->second->Nr, LineRunner1->second->Nr));4576 tester = AllLines.insert(LineRunner1->second); 4577 if (!tester.second) { // found degenerated line 4578 DegeneratedLines->insert(pair<int, int> (LineRunner1->second->Nr, (*tester.first)->Nr)); 4579 DegeneratedLines->insert(pair<int, int> ((*tester.first)->Nr, LineRunner1->second->Nr)); 3514 4580 } 3515 4581 } … … 3517 4583 AllLines.clear(); 3518 4584 3519 Log() << Verbose(0) << "FindAllDegeneratedLines() found " << DegeneratedLines->size() << " lines." << endl; 3520 map<int,int>::iterator it; 3521 for (it = DegeneratedLines->begin(); it != DegeneratedLines->end(); it++) 3522 Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl; 4585 DoLog(0) && (Log() << Verbose(0) << "FindAllDegeneratedLines() found " << DegeneratedLines->size() << " lines." << endl); 4586 IndexToIndex::iterator it; 4587 for (it = DegeneratedLines->begin(); it != DegeneratedLines->end(); it++) { 4588 const LineMap::const_iterator Line1 = LinesOnBoundary.find((*it).first); 4589 const LineMap::const_iterator Line2 = LinesOnBoundary.find((*it).second); 4590 if (Line1 != LinesOnBoundary.end() && Line2 != LinesOnBoundary.end()) 4591 DoLog(0) && (Log() << Verbose(0) << *Line1->second << " => " << *Line2->second << endl); 4592 else 4593 DoeLog(1) && (eLog() << Verbose(1) << "Either " << (*it).first << " or " << (*it).second << " are not in LinesOnBoundary!" << endl); 4594 } 3523 4595 3524 4596 return DegeneratedLines; … … 3531 4603 * in the list, once as key and once as value 3532 4604 */ 3533 map<int, int> * Tesselation::FindAllDegeneratedTriangles() 3534 { 3535 Info FunctionInfo(__func__); 3536 map<int, int> * DegeneratedLines = FindAllDegeneratedLines(); 3537 map<int, int> * DegeneratedTriangles = new map<int, int>; 3538 4605 IndexToIndex * Tesselation::FindAllDegeneratedTriangles() 4606 { 4607 Info FunctionInfo(__func__); 4608 IndexToIndex * DegeneratedLines = FindAllDegeneratedLines(); 4609 IndexToIndex * DegeneratedTriangles = new IndexToIndex; 3539 4610 TriangleMap::iterator TriangleRunner1, TriangleRunner2; 3540 4611 LineMap::iterator Liner; 3541 4612 class BoundaryLineSet *line1 = NULL, *line2 = NULL; 3542 4613 3543 for ( map<int, int>::iterator LineRunner = DegeneratedLines->begin(); LineRunner != DegeneratedLines->end(); ++LineRunner) {4614 for (IndexToIndex::iterator LineRunner = DegeneratedLines->begin(); LineRunner != DegeneratedLines->end(); ++LineRunner) { 3544 4615 // run over both lines' triangles 3545 4616 Liner = LinesOnBoundary.find(LineRunner->first); … … 3551 4622 for (TriangleRunner1 = line1->triangles.begin(); TriangleRunner1 != line1->triangles.end(); ++TriangleRunner1) { 3552 4623 for (TriangleRunner2 = line2->triangles.begin(); TriangleRunner2 != line2->triangles.end(); ++TriangleRunner2) { 3553 if ((TriangleRunner1->second != TriangleRunner2->second) 3554 && (TriangleRunner1->second->IsPresentTupel(TriangleRunner2->second))) { 3555 DegeneratedTriangles->insert( pair<int, int> (TriangleRunner1->second->Nr, TriangleRunner2->second->Nr) ); 3556 DegeneratedTriangles->insert( pair<int, int> (TriangleRunner2->second->Nr, TriangleRunner1->second->Nr) ); 4624 if ((TriangleRunner1->second != TriangleRunner2->second) && (TriangleRunner1->second->IsPresentTupel(TriangleRunner2->second))) { 4625 DegeneratedTriangles->insert(pair<int, int> (TriangleRunner1->second->Nr, TriangleRunner2->second->Nr)); 4626 DegeneratedTriangles->insert(pair<int, int> (TriangleRunner2->second->Nr, TriangleRunner1->second->Nr)); 3557 4627 } 3558 4628 } 3559 4629 } 3560 4630 } 3561 delete (DegeneratedLines);3562 3563 Log() << Verbose(0) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles->size() << " triangles:" << endl;3564 map<int,int>::iterator it;4631 delete (DegeneratedLines); 4632 4633 DoLog(0) && (Log() << Verbose(0) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles->size() << " triangles:" << endl); 4634 IndexToIndex::iterator it; 3565 4635 for (it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++) 3566 Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl;4636 DoLog(0) && (Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl); 3567 4637 3568 4638 return DegeneratedTriangles; … … 3575 4645 void Tesselation::RemoveDegeneratedTriangles() 3576 4646 { 3577 3578 map<int, int>* DegeneratedTriangles = FindAllDegeneratedTriangles();4647 Info FunctionInfo(__func__); 4648 IndexToIndex * DegeneratedTriangles = FindAllDegeneratedTriangles(); 3579 4649 TriangleMap::iterator finder; 3580 4650 BoundaryTriangleSet *triangle = NULL, *partnerTriangle = NULL; 3581 int count = 0; 3582 3583 for (map<int, int>::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); 3584 TriangleKeyRunner != DegeneratedTriangles->end(); ++TriangleKeyRunner 3585 ) { 4651 int count = 0; 4652 4653 for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); TriangleKeyRunner != DegeneratedTriangles->end(); ++TriangleKeyRunner) { 3586 4654 finder = TrianglesOnBoundary.find(TriangleKeyRunner->first); 3587 4655 if (finder != TrianglesOnBoundary.end()) … … 3600 4668 trianglesShareLine = trianglesShareLine || triangle->lines[i] == partnerTriangle->lines[j]; 3601 4669 3602 if (trianglesShareLine 3603 && (triangle->endpoints[1]->LinesCount > 2) 3604 && (triangle->endpoints[2]->LinesCount > 2) 3605 && (triangle->endpoints[0]->LinesCount > 2) 3606 ) { 4670 if (trianglesShareLine && (triangle->endpoints[1]->LinesCount > 2) && (triangle->endpoints[2]->LinesCount > 2) && (triangle->endpoints[0]->LinesCount > 2)) { 3607 4671 // check whether we have to fix lines 3608 4672 BoundaryTriangleSet *Othertriangle = NULL; … … 3624 4688 // the line of triangle receives the degenerated ones 3625 4689 triangle->lines[i]->triangles.erase(Othertriangle->Nr); 3626 triangle->lines[i]->triangles.insert( TrianglePair( partnerTriangle->Nr, partnerTriangle));3627 for (int k =0;k<3;k++)4690 triangle->lines[i]->triangles.insert(TrianglePair(partnerTriangle->Nr, partnerTriangle)); 4691 for (int k = 0; k < 3; k++) 3628 4692 if (triangle->lines[i] == Othertriangle->lines[k]) { 3629 4693 Othertriangle->lines[k] = partnerTriangle->lines[j]; … … 3631 4695 } 3632 4696 // the line of partnerTriangle receives the non-degenerated ones 3633 partnerTriangle->lines[j]->triangles.erase( 3634 partnerTriangle->lines[j]->triangles.insert( TrianglePair( Othertriangle->Nr, Othertriangle));4697 partnerTriangle->lines[j]->triangles.erase(partnerTriangle->Nr); 4698 partnerTriangle->lines[j]->triangles.insert(TrianglePair(Othertriangle->Nr, Othertriangle)); 3635 4699 partnerTriangle->lines[j] = triangle->lines[i]; 3636 4700 } … … 3638 4702 // erase the pair 3639 4703 count += (int) DegeneratedTriangles->erase(triangle->Nr); 3640 Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *triangle << "." << endl;4704 DoLog(0) && (Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *triangle << "." << endl); 3641 4705 RemoveTesselationTriangle(triangle); 3642 4706 count += (int) DegeneratedTriangles->erase(partnerTriangle->Nr); 3643 Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *partnerTriangle << "." << endl;4707 DoLog(0) && (Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *partnerTriangle << "." << endl); 3644 4708 RemoveTesselationTriangle(partnerTriangle); 3645 4709 } else { 3646 Log() << Verbose(0) << "RemoveDegeneratedTriangles() does not remove triangle " << *triangle 3647 << " and its partner " << *partnerTriangle << " because it is essential for at" 3648 << " least one of the endpoints to be kept in the tesselation structure." << endl; 3649 } 3650 } 3651 delete(DegeneratedTriangles); 4710 DoLog(0) && (Log() << Verbose(0) << "RemoveDegeneratedTriangles() does not remove triangle " << *triangle << " and its partner " << *partnerTriangle << " because it is essential for at" << " least one of the endpoints to be kept in the tesselation structure." << endl); 4711 } 4712 } 4713 delete (DegeneratedTriangles); 3652 4714 if (count > 0) 3653 4715 LastTriangle = NULL; 3654 4716 3655 Log() << Verbose(0) << "RemoveDegeneratedTriangles() removed " << count << " triangles:" << endl;4717 DoLog(0) && (Log() << Verbose(0) << "RemoveDegeneratedTriangles() removed " << count << " triangles:" << endl); 3656 4718 } 3657 4719 … … 3666 4728 void Tesselation::AddBoundaryPointByDegeneratedTriangle(class TesselPoint *point, LinkedCell *LC) 3667 4729 { 3668 4730 Info FunctionInfo(__func__); 3669 4731 // find nearest boundary point 3670 4732 class TesselPoint *BackupPoint = NULL; 3671 class TesselPoint *NearestPoint = FindClosest Point(point->node, BackupPoint, LC);4733 class TesselPoint *NearestPoint = FindClosestTesselPoint(point->node, BackupPoint, LC); 3672 4734 class BoundaryPointSet *NearestBoundaryPoint = NULL; 3673 4735 PointMap::iterator PointRunner; … … 3679 4741 NearestBoundaryPoint = PointRunner->second; 3680 4742 } else { 3681 eLog() << Verbose(1) << "I cannot find the boundary point." << endl;4743 DoeLog(1) && (eLog() << Verbose(1) << "I cannot find the boundary point." << endl); 3682 4744 return; 3683 4745 } 3684 Log() << Verbose(0) << "Nearest point on boundary is " << NearestPoint->Name << "." << endl;4746 DoLog(0) && (Log() << Verbose(0) << "Nearest point on boundary is " << NearestPoint->Name << "." << endl); 3685 4747 3686 4748 // go through its lines and find the best one to split … … 3697 4759 CenterToPoint.SubtractVector(point->node); 3698 4760 angle = CenterToPoint.Angle(&BaseLine); 3699 if (fabs(angle - M_PI /2.) < fabs(BestAngle - M_PI/2.)) {4761 if (fabs(angle - M_PI / 2.) < fabs(BestAngle - M_PI / 2.)) { 3700 4762 BestAngle = angle; 3701 4763 BestLine = Runner->second; … … 3707 4769 BestLine->triangles.erase(TempTriangle->Nr); 3708 4770 int nr = -1; 3709 for (int i =0;i<3; i++) {4771 for (int i = 0; i < 3; i++) { 3710 4772 if (TempTriangle->lines[i] == BestLine) { 3711 4773 nr = i; … … 3715 4777 3716 4778 // create new triangle to connect point (connects automatically with the missing spot of the chosen line) 3717 Log() << Verbose(2) << "Adding new triangle points."<< endl;4779 DoLog(2) && (Log() << Verbose(2) << "Adding new triangle points." << endl); 3718 4780 AddTesselationPoint((BestLine->endpoints[0]->node), 0); 3719 4781 AddTesselationPoint((BestLine->endpoints[1]->node), 1); 3720 4782 AddTesselationPoint(point, 2); 3721 Log() << Verbose(2) << "Adding new triangle lines."<< endl;3722 AddTesselationLine( TPS[0], TPS[1], 0);3723 AddTesselationLine( TPS[0], TPS[2], 1);3724 AddTesselationLine( TPS[1], TPS[2], 2);4783 DoLog(2) && (Log() << Verbose(2) << "Adding new triangle lines." << endl); 4784 AddTesselationLine(NULL, NULL, TPS[0], TPS[1], 0); 4785 AddTesselationLine(NULL, NULL, TPS[0], TPS[2], 1); 4786 AddTesselationLine(NULL, NULL, TPS[1], TPS[2], 2); 3725 4787 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 3726 4788 BTS->GetNormalVector(TempTriangle->NormalVector); 3727 4789 BTS->NormalVector.Scale(-1.); 3728 Log() << Verbose(1) << "INFO: NormalVector of new triangle is " << BTS->NormalVector << "." << endl;4790 DoLog(1) && (Log() << Verbose(1) << "INFO: NormalVector of new triangle is " << BTS->NormalVector << "." << endl); 3729 4791 AddTesselationTriangle(); 3730 4792 3731 4793 // create other side of this triangle and close both new sides of the first created triangle 3732 Log() << Verbose(2) << "Adding new triangle points."<< endl;4794 DoLog(2) && (Log() << Verbose(2) << "Adding new triangle points." << endl); 3733 4795 AddTesselationPoint((BestLine->endpoints[0]->node), 0); 3734 4796 AddTesselationPoint((BestLine->endpoints[1]->node), 1); 3735 4797 AddTesselationPoint(point, 2); 3736 Log() << Verbose(2) << "Adding new triangle lines."<< endl;3737 AddTesselationLine( TPS[0], TPS[1], 0);3738 AddTesselationLine( TPS[0], TPS[2], 1);3739 AddTesselationLine( TPS[1], TPS[2], 2);4798 DoLog(2) && (Log() << Verbose(2) << "Adding new triangle lines." << endl); 4799 AddTesselationLine(NULL, NULL, TPS[0], TPS[1], 0); 4800 AddTesselationLine(NULL, NULL, TPS[0], TPS[2], 1); 4801 AddTesselationLine(NULL, NULL, TPS[1], TPS[2], 2); 3740 4802 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 3741 4803 BTS->GetNormalVector(TempTriangle->NormalVector); 3742 Log() << Verbose(1) << "INFO: NormalVector of other new triangle is " << BTS->NormalVector << "." << endl;4804 DoLog(1) && (Log() << Verbose(1) << "INFO: NormalVector of other new triangle is " << BTS->NormalVector << "." << endl); 3743 4805 AddTesselationTriangle(); 3744 4806 3745 4807 // add removed triangle to the last open line of the second triangle 3746 for (int i =0;i<3;i++) { // look for the same line as BestLine (only it's its degenerated companion)4808 for (int i = 0; i < 3; i++) { // look for the same line as BestLine (only it's its degenerated companion) 3747 4809 if ((BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[0])) && (BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[1]))) { 3748 if (BestLine == BTS->lines[i]) {3749 eLog() << Verbose(0) << "BestLine is same as found line, something's wrong here!" << endl;4810 if (BestLine == BTS->lines[i]) { 4811 DoeLog(0) && (eLog() << Verbose(0) << "BestLine is same as found line, something's wrong here!" << endl); 3750 4812 performCriticalExit(); 3751 4813 } 3752 BTS->lines[i]->triangles.insert( pair<int, class BoundaryTriangleSet *> (TempTriangle->Nr, TempTriangle));4814 BTS->lines[i]->triangles.insert(pair<int, class BoundaryTriangleSet *> (TempTriangle->Nr, TempTriangle)); 3753 4815 TempTriangle->lines[nr] = BTS->lines[i]; 3754 4816 break; 3755 4817 } 3756 4818 } 3757 }; 4819 } 4820 ; 3758 4821 3759 4822 /** Writes the envelope to file. … … 3764 4827 void Tesselation::Output(const char *filename, const PointCloud * const cloud) 3765 4828 { 3766 4829 Info FunctionInfo(__func__); 3767 4830 ofstream *tempstream = NULL; 3768 4831 string NameofTempFile; … … 3770 4833 3771 4834 if (LastTriangle != NULL) { 3772 sprintf(NumberName, "-%04d-%s_%s_%s", (int) TrianglesOnBoundary.size(), LastTriangle->endpoints[0]->node->Name, LastTriangle->endpoints[1]->node->Name, LastTriangle->endpoints[2]->node->Name);4835 sprintf(NumberName, "-%04d-%s_%s_%s", (int) TrianglesOnBoundary.size(), LastTriangle->endpoints[0]->node->Name, LastTriangle->endpoints[1]->node->Name, LastTriangle->endpoints[2]->node->Name); 3773 4836 if (DoTecplotOutput) { 3774 4837 string NameofTempFile(filename); 3775 4838 NameofTempFile.append(NumberName); 3776 for (size_t npos = NameofTempFile.find_first_of(' '); npos != string::npos; npos = NameofTempFile.find(' ', npos))3777 NameofTempFile.erase(npos, 1);4839 for (size_t npos = NameofTempFile.find_first_of(' '); npos != string::npos; npos = NameofTempFile.find(' ', npos)) 4840 NameofTempFile.erase(npos, 1); 3778 4841 NameofTempFile.append(TecplotSuffix); 3779 Log() << Verbose(0) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";4842 DoLog(0) && (Log() << Verbose(0) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n"); 3780 4843 tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc); 3781 4844 WriteTecplotFile(tempstream, this, cloud, TriangleFilesWritten); 3782 4845 tempstream->close(); 3783 4846 tempstream->flush(); 3784 delete (tempstream);4847 delete (tempstream); 3785 4848 } 3786 4849 … … 3788 4851 string NameofTempFile(filename); 3789 4852 NameofTempFile.append(NumberName); 3790 for (size_t npos = NameofTempFile.find_first_of(' '); npos != string::npos; npos = NameofTempFile.find(' ', npos))3791 NameofTempFile.erase(npos, 1);4853 for (size_t npos = NameofTempFile.find_first_of(' '); npos != string::npos; npos = NameofTempFile.find(' ', npos)) 4854 NameofTempFile.erase(npos, 1); 3792 4855 NameofTempFile.append(Raster3DSuffix); 3793 Log() << Verbose(0) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";4856 DoLog(0) && (Log() << Verbose(0) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n"); 3794 4857 tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc); 3795 4858 WriteRaster3dFile(tempstream, this, cloud); … … 3797 4860 tempstream->close(); 3798 4861 tempstream->flush(); 3799 delete (tempstream);4862 delete (tempstream); 3800 4863 } 3801 4864 } 3802 4865 if (DoTecplotOutput || DoRaster3DOutput) 3803 4866 TriangleFilesWritten++; 4867 } 4868 ; 4869 4870 struct BoundaryPolygonSetCompare 4871 { 4872 bool operator()(const BoundaryPolygonSet * s1, const BoundaryPolygonSet * s2) const 4873 { 4874 if (s1->endpoints.size() < s2->endpoints.size()) 4875 return true; 4876 else if (s1->endpoints.size() > s2->endpoints.size()) 4877 return false; 4878 else { // equality of number of endpoints 4879 PointSet::const_iterator Walker1 = s1->endpoints.begin(); 4880 PointSet::const_iterator Walker2 = s2->endpoints.begin(); 4881 while ((Walker1 != s1->endpoints.end()) || (Walker2 != s2->endpoints.end())) { 4882 if ((*Walker1)->Nr < (*Walker2)->Nr) 4883 return true; 4884 else if ((*Walker1)->Nr > (*Walker2)->Nr) 4885 return false; 4886 Walker1++; 4887 Walker2++; 4888 } 4889 return false; 4890 } 4891 } 3804 4892 }; 4893 4894 #define UniquePolygonSet set < BoundaryPolygonSet *, BoundaryPolygonSetCompare> 4895 4896 /** Finds all degenerated polygons and calls ReTesselateDegeneratedPolygon()/ 4897 * \return number of polygons found 4898 */ 4899 int Tesselation::CorrectAllDegeneratedPolygons() 4900 { 4901 Info FunctionInfo(__func__); 4902 /// 2. Go through all BoundaryPointSet's, check their triangles' NormalVector 4903 IndexToIndex *DegeneratedTriangles = FindAllDegeneratedTriangles(); 4904 set<BoundaryPointSet *> EndpointCandidateList; 4905 pair<set<BoundaryPointSet *>::iterator, bool> InsertionTester; 4906 pair<map<int, Vector *>::iterator, bool> TriangleInsertionTester; 4907 for (PointMap::const_iterator Runner = PointsOnBoundary.begin(); Runner != PointsOnBoundary.end(); Runner++) { 4908 DoLog(0) && (Log() << Verbose(0) << "Current point is " << *Runner->second << "." << endl); 4909 map<int, Vector *> TriangleVectors; 4910 // gather all NormalVectors 4911 DoLog(1) && (Log() << Verbose(1) << "Gathering triangles ..." << endl); 4912 for (LineMap::const_iterator LineRunner = (Runner->second)->lines.begin(); LineRunner != (Runner->second)->lines.end(); LineRunner++) 4913 for (TriangleMap::const_iterator TriangleRunner = (LineRunner->second)->triangles.begin(); TriangleRunner != (LineRunner->second)->triangles.end(); TriangleRunner++) { 4914 if (DegeneratedTriangles->find(TriangleRunner->second->Nr) == DegeneratedTriangles->end()) { 4915 TriangleInsertionTester = TriangleVectors.insert(pair<int, Vector *> ((TriangleRunner->second)->Nr, &((TriangleRunner->second)->NormalVector))); 4916 if (TriangleInsertionTester.second) 4917 DoLog(1) && (Log() << Verbose(1) << " Adding triangle " << *(TriangleRunner->second) << " to triangles to check-list." << endl); 4918 } else { 4919 DoLog(1) && (Log() << Verbose(1) << " NOT adding triangle " << *(TriangleRunner->second) << " as it's a simply degenerated one." << endl); 4920 } 4921 } 4922 // check whether there are two that are parallel 4923 DoLog(1) && (Log() << Verbose(1) << "Finding two parallel triangles ..." << endl); 4924 for (map<int, Vector *>::iterator VectorWalker = TriangleVectors.begin(); VectorWalker != TriangleVectors.end(); VectorWalker++) 4925 for (map<int, Vector *>::iterator VectorRunner = VectorWalker; VectorRunner != TriangleVectors.end(); VectorRunner++) 4926 if (VectorWalker != VectorRunner) { // skip equals 4927 const double SCP = VectorWalker->second->ScalarProduct(VectorRunner->second); // ScalarProduct should result in -1. for degenerated triangles 4928 DoLog(1) && (Log() << Verbose(1) << "Checking " << *VectorWalker->second << " against " << *VectorRunner->second << ": " << SCP << endl); 4929 if (fabs(SCP + 1.) < ParallelEpsilon) { 4930 InsertionTester = EndpointCandidateList.insert((Runner->second)); 4931 if (InsertionTester.second) 4932 DoLog(0) && (Log() << Verbose(0) << " Adding " << *Runner->second << " to endpoint candidate list." << endl); 4933 // and break out of both loops 4934 VectorWalker = TriangleVectors.end(); 4935 VectorRunner = TriangleVectors.end(); 4936 break; 4937 } 4938 } 4939 } 4940 delete (DegeneratedTriangles); 4941 /// 3. Find connected endpoint candidates and put them into a polygon 4942 UniquePolygonSet ListofDegeneratedPolygons; 4943 BoundaryPointSet *Walker = NULL; 4944 BoundaryPointSet *OtherWalker = NULL; 4945 BoundaryPolygonSet *Current = NULL; 4946 stack<BoundaryPointSet*> ToCheckConnecteds; 4947 while (!EndpointCandidateList.empty()) { 4948 Walker = *(EndpointCandidateList.begin()); 4949 if (Current == NULL) { // create a new polygon with current candidate 4950 DoLog(0) && (Log() << Verbose(0) << "Starting new polygon set at point " << *Walker << endl); 4951 Current = new BoundaryPolygonSet; 4952 Current->endpoints.insert(Walker); 4953 EndpointCandidateList.erase(Walker); 4954 ToCheckConnecteds.push(Walker); 4955 } 4956 4957 // go through to-check stack 4958 while (!ToCheckConnecteds.empty()) { 4959 Walker = ToCheckConnecteds.top(); // fetch ... 4960 ToCheckConnecteds.pop(); // ... and remove 4961 for (LineMap::const_iterator LineWalker = Walker->lines.begin(); LineWalker != Walker->lines.end(); LineWalker++) { 4962 OtherWalker = (LineWalker->second)->GetOtherEndpoint(Walker); 4963 DoLog(1) && (Log() << Verbose(1) << "Checking " << *OtherWalker << endl); 4964 set<BoundaryPointSet *>::iterator Finder = EndpointCandidateList.find(OtherWalker); 4965 if (Finder != EndpointCandidateList.end()) { // found a connected partner 4966 DoLog(1) && (Log() << Verbose(1) << " Adding to polygon." << endl); 4967 Current->endpoints.insert(OtherWalker); 4968 EndpointCandidateList.erase(Finder); // remove from candidates 4969 ToCheckConnecteds.push(OtherWalker); // but check its partners too 4970 } else { 4971 DoLog(1) && (Log() << Verbose(1) << " is not connected to " << *Walker << endl); 4972 } 4973 } 4974 } 4975 4976 DoLog(0) && (Log() << Verbose(0) << "Final polygon is " << *Current << endl); 4977 ListofDegeneratedPolygons.insert(Current); 4978 Current = NULL; 4979 } 4980 4981 const int counter = ListofDegeneratedPolygons.size(); 4982 4983 DoLog(0) && (Log() << Verbose(0) << "The following " << counter << " degenerated polygons have been found: " << endl); 4984 for (UniquePolygonSet::iterator PolygonRunner = ListofDegeneratedPolygons.begin(); PolygonRunner != ListofDegeneratedPolygons.end(); PolygonRunner++) 4985 DoLog(0) && (Log() << Verbose(0) << " " << **PolygonRunner << endl); 4986 4987 /// 4. Go through all these degenerated polygons 4988 for (UniquePolygonSet::iterator PolygonRunner = ListofDegeneratedPolygons.begin(); PolygonRunner != ListofDegeneratedPolygons.end(); PolygonRunner++) { 4989 stack<int> TriangleNrs; 4990 Vector NormalVector; 4991 /// 4a. Gather all triangles of this polygon 4992 TriangleSet *T = (*PolygonRunner)->GetAllContainedTrianglesFromEndpoints(); 4993 4994 // check whether number is bigger than 2, otherwise it's just a simply degenerated one and nothing to do. 4995 if (T->size() == 2) { 4996 DoLog(1) && (Log() << Verbose(1) << " Skipping degenerated polygon, is just a (already simply degenerated) triangle." << endl); 4997 delete (T); 4998 continue; 4999 } 5000 5001 // check whether number is even 5002 // If this case occurs, we have to think about it! 5003 // The Problem is probably due to two degenerated polygons being connected by a bridging, non-degenerated polygon, as somehow one node has 5004 // connections to either polygon ... 5005 if (T->size() % 2 != 0) { 5006 DoeLog(0) && (eLog() << Verbose(0) << " degenerated polygon contains an odd number of triangles, probably contains bridging non-degenerated ones, too!" << endl); 5007 performCriticalExit(); 5008 } 5009 TriangleSet::iterator TriangleWalker = T->begin(); // is the inner iterator 5010 /// 4a. Get NormalVector for one side (this is "front") 5011 NormalVector.CopyVector(&(*TriangleWalker)->NormalVector); 5012 DoLog(1) && (Log() << Verbose(1) << "\"front\" defining triangle is " << **TriangleWalker << " and Normal vector of \"front\" side is " << NormalVector << endl); 5013 TriangleWalker++; 5014 TriangleSet::iterator TriangleSprinter = TriangleWalker; // is the inner advanced iterator 5015 /// 4b. Remove all triangles whose NormalVector is in opposite direction (i.e. "back") 5016 BoundaryTriangleSet *triangle = NULL; 5017 while (TriangleSprinter != T->end()) { 5018 TriangleWalker = TriangleSprinter; 5019 triangle = *TriangleWalker; 5020 TriangleSprinter++; 5021 DoLog(1) && (Log() << Verbose(1) << "Current triangle to test for removal: " << *triangle << endl); 5022 if (triangle->NormalVector.ScalarProduct(&NormalVector) < 0) { // if from other side, then delete and remove from list 5023 DoLog(1) && (Log() << Verbose(1) << " Removing ... " << endl); 5024 TriangleNrs.push(triangle->Nr); 5025 T->erase(TriangleWalker); 5026 RemoveTesselationTriangle(triangle); 5027 } else 5028 DoLog(1) && (Log() << Verbose(1) << " Keeping ... " << endl); 5029 } 5030 /// 4c. Copy all "front" triangles but with inverse NormalVector 5031 TriangleWalker = T->begin(); 5032 while (TriangleWalker != T->end()) { // go through all front triangles 5033 DoLog(1) && (Log() << Verbose(1) << " Re-creating triangle " << **TriangleWalker << " with NormalVector " << (*TriangleWalker)->NormalVector << endl); 5034 for (int i = 0; i < 3; i++) 5035 AddTesselationPoint((*TriangleWalker)->endpoints[i]->node, i); 5036 AddTesselationLine(NULL, NULL, TPS[0], TPS[1], 0); 5037 AddTesselationLine(NULL, NULL, TPS[0], TPS[2], 1); 5038 AddTesselationLine(NULL, NULL, TPS[1], TPS[2], 2); 5039 if (TriangleNrs.empty()) 5040 DoeLog(0) && (eLog() << Verbose(0) << "No more free triangle numbers!" << endl); 5041 BTS = new BoundaryTriangleSet(BLS, TriangleNrs.top()); // copy triangle ... 5042 AddTesselationTriangle(); // ... and add 5043 TriangleNrs.pop(); 5044 BTS->NormalVector.CopyVector(&(*TriangleWalker)->NormalVector); 5045 BTS->NormalVector.Scale(-1.); 5046 TriangleWalker++; 5047 } 5048 if (!TriangleNrs.empty()) { 5049 DoeLog(0) && (eLog() << Verbose(0) << "There have been less triangles created than removed!" << endl); 5050 } 5051 delete (T); // remove the triangleset 5052 } 5053 IndexToIndex * SimplyDegeneratedTriangles = FindAllDegeneratedTriangles(); 5054 DoLog(0) && (Log() << Verbose(0) << "Final list of simply degenerated triangles found, containing " << SimplyDegeneratedTriangles->size() << " triangles:" << endl); 5055 IndexToIndex::iterator it; 5056 for (it = SimplyDegeneratedTriangles->begin(); it != SimplyDegeneratedTriangles->end(); it++) 5057 DoLog(0) && (Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl); 5058 delete (SimplyDegeneratedTriangles); 5059 /// 5. exit 5060 UniquePolygonSet::iterator PolygonRunner; 5061 while (!ListofDegeneratedPolygons.empty()) { 5062 PolygonRunner = ListofDegeneratedPolygons.begin(); 5063 delete (*PolygonRunner); 5064 ListofDegeneratedPolygons.erase(PolygonRunner); 5065 } 5066 5067 return counter; 5068 } 5069 ; -
src/tesselation.hpp
r491876 rc695c9 23 23 #include <list> 24 24 #include <set> 25 #include <stack> 25 26 26 27 #include "atom_particleinfo.hpp" … … 42 43 #define DoTecplotOutput 1 43 44 #define DoRaster3DOutput 1 44 #define DoVRMLOutput 145 #define DoVRMLOutput 0 45 46 #define TecplotSuffix ".dat" 46 47 #define Raster3DSuffix ".r3d" 47 48 #define VRMLSUffix ".wrl" 48 49 50 #define ParallelEpsilon 1e-3 51 49 52 // ======================================================= some template functions ========================================= 50 53 54 #define IndexToIndex map <int, int> 55 51 56 #define PointMap map < int, class BoundaryPointSet * > 57 #define PointSet set < class BoundaryPointSet * > 58 #define PointList list < class BoundaryPointSet * > 52 59 #define PointPair pair < int, class BoundaryPointSet * > 53 60 #define PointTestPair pair < PointMap::iterator, bool > 61 54 62 #define CandidateList list <class CandidateForTesselation *> 55 63 #define CandidateMap map <class BoundaryLineSet *, class CandidateForTesselation *> 56 64 57 65 #define LineMap multimap < int, class BoundaryLineSet * > 66 #define LineSet set < class BoundaryLineSet * > 67 #define LineList list < class BoundaryLineSet * > 58 68 #define LinePair pair < int, class BoundaryLineSet * > 59 69 #define LineTestPair pair < LineMap::iterator, bool > 60 70 61 71 #define TriangleMap map < int, class BoundaryTriangleSet * > 72 #define TriangleSet set < class BoundaryTriangleSet * > 73 #define TriangleList list < class BoundaryTriangleSet * > 62 74 #define TrianglePair pair < int, class BoundaryTriangleSet * > 63 75 #define TriangleTestPair pair < TrianglePair::iterator, bool > 64 76 77 #define PolygonMap map < int, class BoundaryPolygonSet * > 78 #define PolygonSet set < class BoundaryPolygonSet * > 79 #define PolygonList list < class BoundaryPolygonSet * > 80 81 #define DistanceToPointMap multimap <double, class BoundaryPointSet * > 82 #define DistanceToPointPair pair <double, class BoundaryPointSet * > 83 65 84 #define DistanceMultiMap multimap <double, pair < PointMap::iterator, PointMap::iterator> > 66 85 #define DistanceMultiMapPair pair <double, pair < PointMap::iterator, PointMap::iterator> > 67 86 68 87 #define TesselPointList list <TesselPoint *> 88 #define TesselPointSet set <TesselPoint *> 89 90 #define ListOfTesselPointList list<list <TesselPoint *> *> 91 92 enum centers {Opt, OtherOpt}; 69 93 70 94 /********************************************** declarations *******************************/ … … 86 110 public: 87 111 BoundaryPointSet(); 88 BoundaryPointSet(TesselPoint * Walker);112 BoundaryPointSet(TesselPoint * const Walker); 89 113 ~BoundaryPointSet(); 90 114 91 void AddLine( class BoundaryLineSet *line);115 void AddLine(BoundaryLineSet * const line); 92 116 93 117 LineMap lines; … … 105 129 public: 106 130 BoundaryLineSet(); 107 BoundaryLineSet(class BoundaryPointSet *Point[2], const int number); 131 BoundaryLineSet(BoundaryPointSet * const Point[2], const int number); 132 BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number); 108 133 ~BoundaryLineSet(); 109 134 110 void AddTriangle( class BoundaryTriangleSet *triangle);111 bool IsConnectedTo(c lass BoundaryLineSet *line);112 bool ContainsBoundaryPoint(c lass BoundaryPointSet *point);113 bool CheckConvexityCriterion() ;114 class BoundaryPointSet *GetOtherEndpoint(c lass BoundaryPointSet *);135 void AddTriangle(BoundaryTriangleSet * const triangle); 136 bool IsConnectedTo(const BoundaryLineSet * const line) const; 137 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const; 138 bool CheckConvexityCriterion() const; 139 class BoundaryPointSet *GetOtherEndpoint(const BoundaryPointSet * const point) const; 115 140 116 141 class BoundaryPointSet *endpoints[2]; … … 127 152 public: 128 153 BoundaryTriangleSet(); 129 BoundaryTriangleSet(class BoundaryLineSet * line[3],int number);154 BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number); 130 155 ~BoundaryTriangleSet(); 131 156 132 void GetNormalVector(Vector &NormalVector); 133 void GetCenter(Vector *center); 134 bool GetIntersectionInsideTriangle(Vector *MolCenter, Vector *x, Vector *Intersection); 135 bool ContainsBoundaryLine(class BoundaryLineSet *line); 136 bool ContainsBoundaryPoint(class BoundaryPointSet *point); 137 bool ContainsBoundaryPoint(class TesselPoint *point); 138 class BoundaryPointSet *GetThirdEndpoint(class BoundaryLineSet *line); 139 bool IsPresentTupel(class BoundaryPointSet *Points[3]); 140 bool IsPresentTupel(class BoundaryTriangleSet *T); 157 void GetNormalVector(const Vector &NormalVector); 158 void GetCenter(Vector * const center) const; 159 bool GetIntersectionInsideTriangle(const Vector * const MolCenter, const Vector * const x, Vector * const Intersection) const; 160 double GetClosestPointInsideTriangle(const Vector * const x, Vector * const ClosestPoint) const; 161 bool ContainsBoundaryLine(const BoundaryLineSet * const line) const; 162 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const; 163 bool ContainsBoundaryPoint(const TesselPoint * const point) const; 164 class BoundaryPointSet *GetThirdEndpoint(const BoundaryLineSet * const line) const; 165 bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const; 166 bool IsPresentTupel(const BoundaryTriangleSet * const T) const; 141 167 142 168 class BoundaryPointSet *endpoints[3]; 143 169 class BoundaryLineSet *lines[3]; 144 170 Vector NormalVector; 171 Vector SphereCenter; 145 172 int Nr; 146 173 }; 147 174 148 175 ostream & operator << (ostream &ost, const BoundaryTriangleSet &a); 176 177 178 // ======================================================== class BoundaryTriangleSet ======================================= 179 180 /** Set of BoundaryPointSet. 181 * This is just meant as a container for a group of endpoints, extending the node, line, triangle concept. However, this has 182 * only marginally something to do with the tesselation. Hence, there is no incorporation into the bookkeeping of the Tesselation 183 * class (i.e. no allocation, no deletion). 184 * \note we assume that the set of endpoints reside (more or less) on a plane. 185 */ 186 class BoundaryPolygonSet { 187 public: 188 BoundaryPolygonSet(); 189 ~BoundaryPolygonSet(); 190 191 Vector * GetNormalVector(const Vector &NormalVector) const; 192 void GetCenter(Vector *center) const; 193 bool ContainsBoundaryLine(const BoundaryLineSet * const line) const; 194 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const; 195 bool ContainsBoundaryPoint(const TesselPoint * const point) const; 196 bool ContainsBoundaryTriangle(const BoundaryTriangleSet * const point) const; 197 bool ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const; 198 bool ContainsPresentTupel(const BoundaryPolygonSet * const P) const; 199 bool ContainsPresentTupel(const PointSet &endpoints) const; 200 TriangleSet * GetAllContainedTrianglesFromEndpoints() const; 201 bool FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line); 202 203 PointSet endpoints; 204 int Nr; 205 }; 206 207 ostream & operator << (ostream &ost, const BoundaryPolygonSet &a); 149 208 150 209 // =========================================================== class TESSELPOINT =========================================== … … 178 237 virtual TesselPoint *GetPoint() const { return NULL; }; 179 238 virtual TesselPoint *GetTerminalPoint() const { return NULL; }; 239 virtual int GetMaxId() const { return 0; }; 180 240 virtual void GoToNext() const {}; 181 241 virtual void GoToPrevious() const {}; … … 191 251 public : 192 252 CandidateForTesselation(BoundaryLineSet* currentBaseLine); 193 CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);253 CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, BoundaryPointSet *point, Vector OptCandidateCenter, Vector OtherOptCandidateCenter); 194 254 ~CandidateForTesselation(); 195 255 256 bool CheckValidity(const double RADIUS, const LinkedCell *LC) const; 257 196 258 TesselPointList pointlist; 197 BoundaryLineSet *BaseLine; 259 const BoundaryLineSet * BaseLine; 260 const BoundaryPointSet * ThirdPoint; 261 const BoundaryTriangleSet *T; 262 Vector OldCenter; 198 263 Vector OptCenter; 199 264 Vector OtherOptCenter; … … 216 281 void AddTesselationPoint(TesselPoint* Candidate, const int n); 217 282 void SetTesselationPoint(TesselPoint* Candidate, const int n) const; 218 void AddTesselationLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n); 219 void AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n); 283 void AddTesselationLine(const Vector * const OptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n); 284 void AddNewTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n); 285 void AddExistingTesselationTriangleLine(class BoundaryLineSet *FindLine, int n); 220 286 void AddTesselationTriangle(); 221 287 void AddTesselationTriangle(const int nr); 222 void AddCandidateTriangle(CandidateForTesselation CandidateLine); 288 void AddCandidateTriangle(CandidateForTesselation &CandidateLine, enum centers type); 289 void AddDegeneratedTriangle(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC); 290 void AddCandidatePolygon(CandidateForTesselation CandidateLine, const double RADIUS, const LinkedCell *LC); 223 291 void RemoveTesselationTriangle(class BoundaryTriangleSet *triangle); 224 292 void RemoveTesselationLine(class BoundaryLineSet *line); 225 293 void RemoveTesselationPoint(class BoundaryPointSet *point); 294 bool CheckDegeneracy(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC) const; 226 295 227 296 228 297 // concave envelope 229 voidFindStartingTriangle(const double RADIUS, const LinkedCell *LC);298 bool FindStartingTriangle(const double RADIUS, const LinkedCell *LC); 230 299 void FindSecondPointForTesselation(class TesselPoint* a, Vector Oben, class TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC); 231 void FindThirdPointForTesselation(Vector &NormalVector, Vector &SearchDirection, Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class TesselPoint * const ThirdNode, const double RADIUS, const LinkedCell *LC) const; 232 bool FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC); 300 void FindThirdPointForTesselation(const Vector &NormalVector, const Vector &SearchDirection, const Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class BoundaryPointSet * const ThirdNode, const double RADIUS, const LinkedCell *LC) const; 301 bool FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, const BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC); 302 bool FindCandidatesforOpenLines(const double RADIUS, const LinkedCell *&LCList); 233 303 int CheckPresenceOfTriangle(class TesselPoint *Candidates[3]) const; 234 304 class BoundaryTriangleSet * GetPresentTriangle(TesselPoint *Candidates[3]); … … 242 312 double PickFarthestofTwoBaselines(class BoundaryLineSet *Base); 243 313 class BoundaryPointSet *IsConvexRectangle(class BoundaryLineSet *Base); 244 map<int, int>* FindAllDegeneratedTriangles();245 map<int, int>* FindAllDegeneratedLines();314 IndexToIndex * FindAllDegeneratedTriangles(); 315 IndexToIndex * FindAllDegeneratedLines(); 246 316 void RemoveDegeneratedTriangles(); 247 317 void AddBoundaryPointByDegeneratedTriangle(class TesselPoint *point, LinkedCell *LC); 248 249 set<TesselPoint*> * GetAllConnectedPoints(const TesselPoint* const Point) const; 250 set<BoundaryTriangleSet*> *GetAllTriangles(const BoundaryPointSet * const Point) const; 251 list<list<TesselPoint*> *> * GetPathsOfConnectedPoints(const TesselPoint* const Point) const; 252 list<list<TesselPoint*> *> * GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const; 253 list<TesselPoint*> * GetCircleOfSetOfPoints(set<TesselPoint*> *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference = NULL) const; 254 class BoundaryPointSet *GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const; 255 list<BoundaryTriangleSet*> *FindTriangles(const TesselPoint* const Points[3]) const; 256 list<BoundaryTriangleSet*> * FindClosestTrianglesToPoint(const Vector *x, const LinkedCell* LC) const; 257 class BoundaryTriangleSet * FindClosestTriangleToPoint(const Vector *x, const LinkedCell* LC) const; 318 int CorrectAllDegeneratedPolygons(); 319 320 TesselPointSet * GetAllConnectedPoints(const TesselPoint* const Point) const; 321 TriangleSet * GetAllTriangles(const BoundaryPointSet * const Point) const; 322 ListOfTesselPointList * GetPathsOfConnectedPoints(const TesselPoint* const Point) const; 323 ListOfTesselPointList * GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const; 324 TesselPointList * GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference = NULL) const; 325 TesselPointList * GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const; 326 class BoundaryPointSet * GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const; 327 TriangleList * FindTriangles(const TesselPoint* const Points[3]) const; 328 TriangleList * FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const; 329 BoundaryTriangleSet * FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const; 258 330 bool IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const; 259 bool IsInnerPoint(const TesselPoint * const Point, const LinkedCell* const LC) const; 331 double GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const; 332 double GetDistanceToSurface(const Vector &Point, const LinkedCell* const LC) const; 333 BoundaryTriangleSet * GetClosestTriangleOnSurface(const Vector &Point, const LinkedCell* const LC) const; 260 334 bool AddBoundaryPoint(TesselPoint * Walker, const int n); 335 DistanceToPointMap * FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const; 336 BoundaryLineSet * FindClosestBoundaryLineToVector(const Vector *x, const LinkedCell* LC) const; 261 337 262 338 // print for debugging … … 299 375 300 376 //bool HasOtherBaselineBetterCandidate(const BoundaryLineSet * const BaseRay, const TesselPoint * const OptCandidate, double ShortestAngle, double RADIUS, const LinkedCell * const LC) const; 377 void FindDegeneratedCandidatesforOpenLines(TesselPoint * const Sprinter, const Vector * const OptCenter); 301 378 }; 302 379 -
src/tesselationhelpers.cpp
r491876 rc695c9 81 81 82 82 if (fabs(m11) < MYEPSILON) 83 eLog() << Verbose(1) << "three points are colinear." << endl;83 DoeLog(1) && (eLog()<< Verbose(1) << "three points are colinear." << endl); 84 84 85 85 center->x[0] = 0.5 * m12/ m11; … … 88 88 89 89 if (fabs(a.Distance(center) - RADIUS) > MYEPSILON) 90 eLog() << Verbose(1) << "The given center is further way by " << fabs(a.Distance(center) - RADIUS) << " from a than RADIUS." << endl;90 DoeLog(1) && (eLog()<< Verbose(1) << "The given center is further way by " << fabs(a.Distance(center) - RADIUS) << " from a than RADIUS." << endl); 91 91 92 92 gsl_matrix_free(A); … … 132 132 Center->Scale(1./(sin(2.*alpha) + sin(2.*beta) + sin(2.*gamma))); 133 133 NewUmkreismittelpunkt->CopyVector(Center); 134 Log() << Verbose(1) << "Center of new circumference is " << *NewUmkreismittelpunkt << ".\n";134 DoLog(1) && (Log() << Verbose(1) << "Center of new circumference is " << *NewUmkreismittelpunkt << ".\n"); 135 135 // Here we calculated center of circumscribing circle, using barycentric coordinates 136 Log() << Verbose(1) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n";136 DoLog(1) && (Log() << Verbose(1) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n"); 137 137 138 138 TempNormal.CopyVector(&a); … … 143 143 if (fabs(HalfplaneIndicator) < MYEPSILON) 144 144 { 145 if ((TempNormal.ScalarProduct(AlternativeDirection) <0 and AlternativeIndicator >0) or (TempNormal.ScalarProduct(AlternativeDirection) >0 andAlternativeIndicator <0))145 if ((TempNormal.ScalarProduct(AlternativeDirection) <0 && AlternativeIndicator >0) || (TempNormal.ScalarProduct(AlternativeDirection) >0 && AlternativeIndicator <0)) 146 146 { 147 147 TempNormal.Scale(-1); … … 150 150 else 151 151 { 152 if ( TempNormal.ScalarProduct(Direction)<0 && HalfplaneIndicator >0 || TempNormal.ScalarProduct(Direction)>0 && HalfplaneIndicator<0)152 if (((TempNormal.ScalarProduct(Direction)<0) && (HalfplaneIndicator >0)) || ((TempNormal.ScalarProduct(Direction)>0) && (HalfplaneIndicator<0))) 153 153 { 154 154 TempNormal.Scale(-1); … … 158 158 TempNormal.Normalize(); 159 159 Restradius = sqrt(RADIUS*RADIUS - Umkreisradius*Umkreisradius); 160 Log() << Verbose(1) << "Height of center of circumference to center of sphere is " << Restradius << ".\n";160 DoLog(1) && (Log() << Verbose(1) << "Height of center of circumference to center of sphere is " << Restradius << ".\n"); 161 161 TempNormal.Scale(Restradius); 162 Log() << Verbose(1) << "Shift vector to sphere of circumference is " << TempNormal << ".\n";162 DoLog(1) && (Log() << Verbose(1) << "Shift vector to sphere of circumference is " << TempNormal << ".\n"); 163 163 164 164 Center->AddVector(&TempNormal); 165 Log() << Verbose(1) << "Center of sphere of circumference is " << *Center << ".\n";165 DoLog(1) && (Log() << Verbose(1) << "Center of sphere of circumference is " << *Center << ".\n"); 166 166 GetSphere(&OtherCenter, a, b, c, RADIUS); 167 Log() << Verbose(1) << "OtherCenter of sphere of circumference is " << OtherCenter << ".\n";167 DoLog(1) && (Log() << Verbose(1) << "OtherCenter of sphere of circumference is " << OtherCenter << ".\n"); 168 168 }; 169 169 … … 192 192 //Log() << Verbose(1) << "INFO: alpha = " << alpha/M_PI*180. << ", beta = " << beta/M_PI*180. << ", gamma = " << gamma/M_PI*180. << "." << endl; 193 193 if (fabs(M_PI - alpha - beta - gamma) > HULLEPSILON) { 194 eLog() << Verbose(1) << "GetCenterofCircumcircle: Sum of angles " << (alpha+beta+gamma)/M_PI*180. << " > 180 degrees by " << fabs(M_PI - alpha - beta - gamma)/M_PI*180. << "!" << endl;194 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); 195 195 } 196 196 … … 226 226 Vector helper; 227 227 double radius, alpha; 228 229 helper.CopyVector(&NewSphereCenter); 228 Vector RelativeOldSphereCenter; 229 Vector RelativeNewSphereCenter; 230 231 RelativeOldSphereCenter.CopyVector(&OldSphereCenter); 232 RelativeOldSphereCenter.SubtractVector(&CircleCenter); 233 RelativeNewSphereCenter.CopyVector(&NewSphereCenter); 234 RelativeNewSphereCenter.SubtractVector(&CircleCenter); 235 helper.CopyVector(&RelativeNewSphereCenter); 230 236 // test whether new center is on the parameter circle's plane 231 237 if (fabs(helper.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) { 232 eLog() << Verbose(1) << "Something's very wrong here: NewSphereCenter is not on the band's plane as desired by " <<fabs(helper.ScalarProduct(&CirclePlaneNormal)) << "!" << endl;238 DoeLog(1) && (eLog()<< Verbose(1) << "Something's very wrong here: NewSphereCenter is not on the band's plane as desired by " <<fabs(helper.ScalarProduct(&CirclePlaneNormal)) << "!" << endl); 233 239 helper.ProjectOntoPlane(&CirclePlaneNormal); 234 240 } 235 radius = helper. ScalarProduct(&helper);241 radius = helper.NormSquared(); 236 242 // test whether the new center vector has length of CircleRadius 237 243 if (fabs(radius - CircleRadius) > HULLEPSILON) 238 eLog() << Verbose(1) << "The projected center of the new sphere has radius " << radius << " instead of " << CircleRadius << "." << endl;239 alpha = helper.Angle(& OldSphereCenter);244 DoeLog(1) && (eLog()<< Verbose(1) << "The projected center of the new sphere has radius " << radius << " instead of " << CircleRadius << "." << endl); 245 alpha = helper.Angle(&RelativeOldSphereCenter); 240 246 // make the angle unique by checking the halfplanes/search direction 241 247 if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON) // acos is not unique on [0, 2.*M_PI), hence extra check to decide between two half intervals 242 248 alpha = 2.*M_PI - alpha; 243 //Log() << Verbose(1) << "INFO: RelativeNewSphereCenter is " << helper << ", RelativeOldSphereCenter is " << OldSphereCenter << " and resulting angle is " << alpha << "." << endl;244 radius = helper.Distance(& OldSphereCenter);249 DoLog(1) && (Log() << Verbose(1) << "INFO: RelativeNewSphereCenter is " << helper << ", RelativeOldSphereCenter is " << RelativeOldSphereCenter << " and resulting angle is " << alpha << "." << endl); 250 radius = helper.Distance(&RelativeOldSphereCenter); 245 251 helper.ProjectOntoPlane(&NormalVector); 246 252 // check whether new center is somewhat away or at least right over the current baseline to prevent intersecting triangles 247 253 if ((radius > HULLEPSILON) || (helper.Norm() < HULLEPSILON)) { 248 //Log() << Verbose(1) << "INFO: Distance between old and new center is " << radius << " and between new center and baseline center is " << helper.Norm() << "." << endl;254 DoLog(1) && (Log() << Verbose(1) << "INFO: Distance between old and new center is " << radius << " and between new center and baseline center is " << helper.Norm() << "." << endl); 249 255 return alpha; 250 256 } else { 251 //Log() << Verbose(1) << "INFO: NewSphereCenter " << helper << " is too close to OldSphereCenter" << OldSphereCenter << "." << endl;257 DoLog(1) && (Log() << Verbose(1) << "INFO: NewSphereCenter " << RelativeNewSphereCenter << " is too close to RelativeOldSphereCenter" << RelativeOldSphereCenter << "." << endl); 252 258 return 2.*M_PI; 253 259 } … … 358 364 359 365 if (status == GSL_SUCCESS) { 360 Log() << Verbose(1) << "converged to minimum" << endl;366 DoLog(1) && (Log() << Verbose(1) << "converged to minimum" << endl); 361 367 } 362 368 } while (status == GSL_CONTINUE && iter < 100); … … 388 394 389 395 if (((t1 >= 0) && (t1 <= 1)) && ((t2 >= 0) && (t2 <= 1))) { 390 Log() << Verbose(1) << "true intersection." << endl;396 DoLog(1) && (Log() << Verbose(1) << "true intersection." << endl); 391 397 result = true; 392 398 } else { 393 Log() << Verbose(1) << "intersection out of region of interest." << endl;399 DoLog(1) && (Log() << Verbose(1) << "intersection out of region of interest." << endl); 394 400 result = false; 395 401 } … … 426 432 } 427 433 428 Log() << Verbose(1) << "INFO: " << point << " has angle " << phi << " with respect to reference " << reference << "." << endl;434 DoLog(1) && (Log() << Verbose(1) << "INFO: " << point << " has angle " << phi << " with respect to reference " << reference << "." << endl); 429 435 430 436 return phi; … … 473 479 for (int j=i+1; j<3; j++) { 474 480 if (nodes[i] == NULL) { 475 Log() << Verbose(1) << "Node nr. " << i << " is not yet present." << endl;481 DoLog(1) && (Log() << Verbose(1) << "Node nr. " << i << " is not yet present." << endl); 476 482 result = true; 477 483 } else if (nodes[i]->lines.find(nodes[j]->node->nr) != nodes[i]->lines.end()) { // there already is a line … … 487 493 } 488 494 } else { // no line 489 Log() << Verbose(1) << "The line between " << *nodes[i] << " and " << *nodes[j] << " is not yet present, hence no need for a degenerate triangle." << endl;495 DoLog(1) && (Log() << Verbose(1) << "The line between " << *nodes[i] << " and " << *nodes[j] << " is not yet present, hence no need for a degenerate triangle." << endl); 490 496 result = true; 491 497 } 492 498 } 493 499 if ((!result) && (counter > 1)) { 494 Log() << Verbose(1) << "INFO: Degenerate triangle is ok, at least two, here " << counter << ", existing lines are used." << endl;500 DoLog(1) && (Log() << Verbose(1) << "INFO: Degenerate triangle is ok, at least two, here " << counter << ", existing lines are used." << endl); 495 501 result = true; 496 502 } … … 506 512 // Vector BaseLineVector, OrthogonalVector, helper; 507 513 // if (candidate1->BaseLine != candidate2->BaseLine) { // sanity check 508 // eLog() << Verbose(1) << "sortCandidates was called for two different baselines: " << candidate1->BaseLine << " and " << candidate2->BaseLine << "." << endl;514 // DoeLog(1) && (eLog()<< Verbose(1) << "sortCandidates was called for two different baselines: " << candidate1->BaseLine << " and " << candidate2->BaseLine << "." << endl); 509 515 // //return false; 510 516 // exit(1); … … 552 558 * @return point which is second closest to the provided one 553 559 */ 554 TesselPoint* FindSecondClosest Point(const Vector* Point, const LinkedCell* const LC)560 TesselPoint* FindSecondClosestTesselPoint(const Vector* Point, const LinkedCell* const LC) 555 561 { 556 562 Info FunctionInfo(__func__); … … 565 571 for(int i=0;i<NDIM;i++) // store indices of this cell 566 572 N[i] = LC->n[i]; 567 Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;573 DoLog(1) && (Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl); 568 574 569 575 LC->GetNeighbourBounds(Nlower, Nupper); … … 572 578 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 573 579 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 574 const Linked Nodes *List = LC->GetCurrentCell();580 const LinkedCell::LinkedNodes *List = LC->GetCurrentCell(); 575 581 //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl; 576 582 if (List != NULL) { 577 for (Linked Nodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {583 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 578 584 helper.CopyVector(Point); 579 585 helper.SubtractVector((*Runner)->node); … … 607 613 * @return point which is closest to the provided one, NULL if none found 608 614 */ 609 TesselPoint* FindClosest Point(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC)615 TesselPoint* FindClosestTesselPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC) 610 616 { 611 617 Info FunctionInfo(__func__); … … 620 626 for(int i=0;i<NDIM;i++) // store indices of this cell 621 627 N[i] = LC->n[i]; 622 Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;628 DoLog(1) && (Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl); 623 629 624 630 LC->GetNeighbourBounds(Nlower, Nupper); … … 627 633 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 628 634 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 629 const Linked Nodes *List = LC->GetCurrentCell();635 const LinkedCell::LinkedNodes *List = LC->GetCurrentCell(); 630 636 //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl; 631 637 if (List != NULL) { 632 for (Linked Nodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {638 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 633 639 helper.CopyVector(Point); 634 640 helper.SubtractVector((*Runner)->node); 635 double currentNorm = helper. Norm();641 double currentNorm = helper.NormSquared(); 636 642 if (currentNorm < distance) { 637 643 secondDistance = distance; … … 653 659 // output 654 660 if (closestPoint != NULL) { 655 Log() << Verbose(1) << "Closest point is " << *closestPoint;661 DoLog(1) && (Log() << Verbose(1) << "Closest point is " << *closestPoint); 656 662 if (SecondPoint != NULL) 657 Log() << Verbose(0) << " and second closest is " << *SecondPoint;658 Log() << Verbose(0) << "." << endl;663 DoLog(0) && (Log() << Verbose(0) << " and second closest is " << *SecondPoint); 664 DoLog(0) && (Log() << Verbose(0) << "." << endl); 659 665 } 660 666 return closestPoint; … … 680 686 Normal.VectorProduct(&OtherBaseline); 681 687 Normal.Normalize(); 682 Log() << Verbose(1) << "First direction is " << Baseline << ", second direction is " << OtherBaseline << ", normal of intersection plane is " << Normal << "." << endl;688 DoLog(1) && (Log() << Verbose(1) << "First direction is " << Baseline << ", second direction is " << OtherBaseline << ", normal of intersection plane is " << Normal << "." << endl); 683 689 684 690 // project one offset point of OtherBase onto this plane (and add plane offset vector) … … 697 703 Normal.CopyVector(Intersection); 698 704 Normal.SubtractVector(Base->endpoints[0]->node->node); 699 Log() << Verbose(1) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(&Baseline)/Baseline.NormSquared()) << "." << endl;705 DoLog(1) && (Log() << Verbose(1) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(&Baseline)/Baseline.NormSquared()) << "." << endl); 700 706 701 707 return Intersection; … … 758 764 } 759 765 } else { 760 eLog() << Verbose(1) << "Given vrmlfile is " << vrmlfile << "." << endl;766 DoeLog(1) && (eLog()<< Verbose(1) << "Given vrmlfile is " << vrmlfile << "." << endl); 761 767 } 762 768 delete(center); … … 833 839 *rasterfile << "9\n# terminating special property\n"; 834 840 } else { 835 eLog() << Verbose(1) << "Given rasterfile is " << rasterfile << "." << endl;841 DoeLog(1) && (eLog()<< Verbose(1) << "Given rasterfile is " << rasterfile << "." << endl); 836 842 } 837 843 IncludeSphereinRaster3D(rasterfile, Tess, cloud); … … 856 862 } else { 857 863 *tecplot << N << "-"; 858 for (int i=0;i<3;i++) 859 *tecplot << (i==0 ? "" : "_") << TesselStruct->LastTriangle->endpoints[i]->node->Name; 864 if (TesselStruct->LastTriangle != NULL) { 865 for (int i=0;i<3;i++) 866 *tecplot << (i==0 ? "" : "_") << TesselStruct->LastTriangle->endpoints[i]->node->Name; 867 } else { 868 *tecplot << "none"; 869 } 860 870 } 861 871 *tecplot << "\", N=" << TesselStruct->PointsOnBoundary.size() << ", E=" << TesselStruct->TrianglesOnBoundary.size() << ", DATAPACKING=POINT, ZONETYPE=FETRIANGLE" << endl; 862 int i=0; 863 for (cloud->GoToFirst(); !cloud->IsEnd(); cloud->GoToNext(), i++); 872 int i=cloud->GetMaxId(); 864 873 int *LookupList = new int[i]; 865 874 for (cloud->GoToFirst(), i=0; !cloud->IsEnd(); cloud->GoToNext(), i++) … … 876 885 *tecplot << endl; 877 886 // print connectivity 878 Log() << Verbose(1) << "The following triangles were created:" << endl;887 DoLog(1) && (Log() << Verbose(1) << "The following triangles were created:" << endl); 879 888 for (TriangleMap::const_iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++) { 880 Log() << Verbose(1) << " " << runner->second->endpoints[0]->node->Name << "<->" << runner->second->endpoints[1]->node->Name << "<->" << runner->second->endpoints[2]->node->Name << endl;889 DoLog(1) && (Log() << Verbose(1) << " " << runner->second->endpoints[0]->node->Name << "<->" << runner->second->endpoints[1]->node->Name << "<->" << runner->second->endpoints[2]->node->Name << endl); 881 890 *tecplot << LookupList[runner->second->endpoints[0]->node->nr] << " " << LookupList[runner->second->endpoints[1]->node->nr] << " " << LookupList[runner->second->endpoints[2]->node->nr] << endl; 882 891 } … … 899 908 for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) { 900 909 point = PointRunner->second; 901 Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl;910 DoLog(1) && (Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl); 902 911 point->value = 0; 903 912 for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) { … … 923 932 int counter = 0; 924 933 925 Log() << Verbose(1) << "Check: List of Baselines with not two connected triangles:" << endl;934 DoLog(1) && (Log() << Verbose(1) << "Check: List of Baselines with not two connected triangles:" << endl); 926 935 for (testline = TesselStruct->LinesOnBoundary.begin(); testline != TesselStruct->LinesOnBoundary.end(); testline++) { 927 936 if (testline->second->triangles.size() != 2) { 928 Log() << Verbose(2) << *testline->second << "\t" << testline->second->triangles.size() << endl;937 DoLog(2) && (Log() << Verbose(2) << *testline->second << "\t" << testline->second->triangles.size() << endl); 929 938 counter++; 930 939 } 931 940 } 932 941 if (counter == 0) { 933 Log() << Verbose(1) << "None." << endl;942 DoLog(1) && (Log() << Verbose(1) << "None." << endl); 934 943 result = true; 935 944 } … … 937 946 } 938 947 948 /** Counts the number of triangle pairs that contain the given polygon. 949 * \param *P polygon with endpoints to look for 950 * \param *T set of triangles to create pairs from containing \a *P 951 */ 952 int CountTrianglePairContainingPolygon(const BoundaryPolygonSet * const P, const TriangleSet * const T) 953 { 954 Info FunctionInfo(__func__); 955 // check number of endpoints in *P 956 if (P->endpoints.size() != 4) { 957 DoeLog(1) && (eLog()<< Verbose(1) << "CountTrianglePairContainingPolygon works only on polygons with 4 nodes!" << endl); 958 return 0; 959 } 960 961 // check number of triangles in *T 962 if (T->size() < 2) { 963 DoeLog(1) && (eLog()<< Verbose(1) << "Not enough triangles to have pairs!" << endl); 964 return 0; 965 } 966 967 DoLog(0) && (Log() << Verbose(0) << "Polygon is " << *P << endl); 968 // create each pair, get the endpoints and check whether *P is contained. 969 int counter = 0; 970 PointSet Trianglenodes; 971 class BoundaryPolygonSet PairTrianglenodes; 972 for(TriangleSet::iterator Walker = T->begin(); Walker != T->end(); Walker++) { 973 for (int i=0;i<3;i++) 974 Trianglenodes.insert((*Walker)->endpoints[i]); 975 976 for(TriangleSet::iterator PairWalker = Walker; PairWalker != T->end(); PairWalker++) { 977 if (Walker != PairWalker) { // skip first 978 PairTrianglenodes.endpoints = Trianglenodes; 979 for (int i=0;i<3;i++) 980 PairTrianglenodes.endpoints.insert((*PairWalker)->endpoints[i]); 981 const int size = PairTrianglenodes.endpoints.size(); 982 if (size == 4) { 983 DoLog(0) && (Log() << Verbose(0) << " Current pair of triangles: " << **Walker << "," << **PairWalker << " with " << size << " distinct endpoints:" << PairTrianglenodes << endl); 984 // now check 985 if (PairTrianglenodes.ContainsPresentTupel(P)) { 986 counter++; 987 DoLog(0) && (Log() << Verbose(0) << " ACCEPT: Matches with " << *P << endl); 988 } else { 989 DoLog(0) && (Log() << Verbose(0) << " REJECT: No match with " << *P << endl); 990 } 991 } else { 992 DoLog(0) && (Log() << Verbose(0) << " REJECT: Less than four endpoints." << endl); 993 } 994 } 995 } 996 Trianglenodes.clear(); 997 } 998 return counter; 999 }; 1000 1001 /** Checks whether two give polygons have two or more points in common. 1002 * \param *P1 first polygon 1003 * \param *P2 second polygon 1004 * \return true - are connected, false = are note 1005 */ 1006 bool ArePolygonsEdgeConnected(const BoundaryPolygonSet * const P1, const BoundaryPolygonSet * const P2) 1007 { 1008 Info FunctionInfo(__func__); 1009 int counter = 0; 1010 for(PointSet::const_iterator Runner = P1->endpoints.begin(); Runner != P1->endpoints.end(); Runner++) { 1011 if (P2->ContainsBoundaryPoint((*Runner))) { 1012 counter++; 1013 DoLog(1) && (Log() << Verbose(1) << *(*Runner) << " of second polygon is found in the first one." << endl); 1014 return true; 1015 } 1016 } 1017 return false; 1018 }; 1019 1020 /** Combines second into the first and deletes the second. 1021 * \param *P1 first polygon, contains all nodes on return 1022 * \param *&P2 second polygon, is deleted. 1023 */ 1024 void CombinePolygons(BoundaryPolygonSet * const P1, BoundaryPolygonSet * &P2) 1025 { 1026 Info FunctionInfo(__func__); 1027 pair <PointSet::iterator, bool> Tester; 1028 for(PointSet::iterator Runner = P2->endpoints.begin(); Runner != P2->endpoints.end(); Runner++) { 1029 Tester = P1->endpoints.insert((*Runner)); 1030 if (Tester.second) 1031 DoLog(0) && (Log() << Verbose(0) << "Inserting endpoint " << *(*Runner) << " into first polygon." << endl); 1032 } 1033 P2->endpoints.clear(); 1034 delete(P2); 1035 }; 1036 -
src/tesselationhelpers.hpp
r491876 rc695c9 59 59 bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet * const nodes[3]); 60 60 bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation *candidate2); 61 TesselPoint* FindClosest Point(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC);62 TesselPoint* FindSecondClosest Point(const Vector*, const LinkedCell* const LC);61 TesselPoint* FindClosestTesselPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC); 62 TesselPoint* FindSecondClosestTesselPoint(const Vector*, const LinkedCell* const LC); 63 63 Vector * GetClosestPointBetweenLine(const BoundaryLineSet * const Base, const BoundaryLineSet * const OtherBase); 64 64 … … 72 72 bool CheckListOfBaselines(const Tesselation * const TesselStruct); 73 73 74 int CountTrianglePairContainingPolygon(const BoundaryPolygonSet * const P, const TriangleSet * const T); 75 bool ArePolygonsEdgeConnected(const BoundaryPolygonSet * const P1, const BoundaryPolygonSet * const P2); 76 void CombinePolygons(BoundaryPolygonSet * const P1, BoundaryPolygonSet * &P2); 77 74 78 75 79 #endif /* TESSELATIONHELPERS_HPP_ */ -
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
r491876 rc695c9 11 11 #include <cppunit/extensions/TestFactoryRegistry.h> 12 12 #include <cppunit/ui/text/TestRunner.h> 13 14 #include <cstring> 13 15 14 16 #include "analysis_correlation.hpp" … … 116 118 // put pair correlation into bins and check with no range 117 119 binmap = BinData( pointmap, 0.5, 0., 0. ); 118 CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size());119 //OutputCorrelation ( binmap);120 OutputCorrelation ( (ofstream *)&cout, binmap ); 121 CPPUNIT_ASSERT_EQUAL( (size_t)3, binmap->size() ); 120 122 tester = binmap->begin(); 121 123 CPPUNIT_ASSERT_EQUAL( 1., tester->first ); … … 129 131 // ... and check with [0., 2.] range 130 132 binmap = BinData( pointmap, 0.5, 0., 2. ); 133 OutputCorrelation ( (ofstream *)&cout, binmap ); 131 134 CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() ); 132 //OutputCorrelation ( binmap );133 135 tester = binmap->begin(); 134 136 CPPUNIT_ASSERT_EQUAL( 0., tester->first ); -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
r491876 rc695c9 11 11 #include <cppunit/extensions/TestFactoryRegistry.h> 12 12 #include <cppunit/ui/text/TestRunner.h> 13 14 #include <cstring> 13 15 14 16 #include "analysis_correlation.hpp" … … 58 60 59 61 // construct molecule (tetraeder of hydrogens) base 62 TestSurfaceMolecule = new molecule(tafel); 63 Walker = new atom(); 64 Walker->type = hydrogen; 65 Walker->node->Init(1., 0., 1. ); 66 TestSurfaceMolecule->AddAtom(Walker); 67 Walker = new atom(); 68 Walker->type = hydrogen; 69 Walker->node->Init(0., 1., 1. ); 70 TestSurfaceMolecule->AddAtom(Walker); 71 Walker = new atom(); 72 Walker->type = hydrogen; 73 Walker->node->Init(1., 1., 0. ); 74 TestSurfaceMolecule->AddAtom(Walker); 75 Walker = new atom(); 76 Walker->type = hydrogen; 77 Walker->node->Init(0., 0., 0. ); 78 TestSurfaceMolecule->AddAtom(Walker); 79 80 // check that TestMolecule was correctly constructed 81 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->AtomCount, 4 ); 82 83 TestList = new MoleculeListClass; 84 TestSurfaceMolecule->ActiveFlag = true; 85 TestList->insert(TestSurfaceMolecule); 86 87 // init tesselation and linked cell 88 Surface = new Tesselation; 89 LC = new LinkedCell(TestSurfaceMolecule, 5.); 90 FindNonConvexBorder(TestSurfaceMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL); 91 92 // add outer atoms 60 93 TestMolecule = new molecule(tafel); 61 94 Walker = new atom(); 62 Walker->type = hydrogen; 63 Walker->node->Init(1., 0., 1. ); 64 TestMolecule->AddAtom(Walker); 65 Walker = new atom(); 66 Walker->type = hydrogen; 67 Walker->node->Init(0., 1., 1. ); 68 TestMolecule->AddAtom(Walker); 69 Walker = new atom(); 70 Walker->type = hydrogen; 71 Walker->node->Init(1., 1., 0. ); 72 TestMolecule->AddAtom(Walker); 73 Walker = new atom(); 74 Walker->type = hydrogen; 75 Walker->node->Init(0., 0., 0. ); 76 TestMolecule->AddAtom(Walker); 77 78 // check that TestMolecule was correctly constructed 79 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 ); 80 81 TestList = new MoleculeListClass; 95 Walker->type = carbon; 96 Walker->node->Init(4., 0., 4. ); 97 TestMolecule->AddAtom(Walker); 98 Walker = new atom(); 99 Walker->type = carbon; 100 Walker->node->Init(0., 4., 4. ); 101 TestMolecule->AddAtom(Walker); 102 Walker = new atom(); 103 Walker->type = carbon; 104 Walker->node->Init(4., 4., 0. ); 105 TestMolecule->AddAtom(Walker); 106 // add inner atoms 107 Walker = new atom(); 108 Walker->type = carbon; 109 Walker->node->Init(0.5, 0.5, 0.5 ); 110 TestMolecule->AddAtom(Walker); 82 111 TestMolecule->ActiveFlag = true; 83 112 TestList->insert(TestMolecule); 84 85 // init tesselation and linked cell86 Surface = new Tesselation;87 FindNonConvexBorder(TestMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL);88 LC = new LinkedCell(TestMolecule, 5.);89 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );90 CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() );91 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() );92 93 // add outer atoms94 Walker = new atom();95 Walker->type = carbon;96 Walker->node->Init(4., 0., 4. );97 TestMolecule->AddAtom(Walker);98 Walker = new atom();99 Walker->type = carbon;100 Walker->node->Init(0., 4., 4. );101 TestMolecule->AddAtom(Walker);102 Walker = new atom();103 Walker->type = carbon;104 Walker->node->Init(4., 4., 0. );105 TestMolecule->AddAtom(Walker);106 // add inner atoms107 Walker = new atom();108 Walker->type = carbon;109 Walker->node->Init(0.5, 0.5, 0.5 );110 TestMolecule->AddAtom(Walker);111 113 112 114 // init maps … … 134 136 135 137 138 /** Checks whether setup() does the right thing. 139 */ 140 void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest() 141 { 142 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->AtomCount ); 143 CPPUNIT_ASSERT_EQUAL( 4, TestMolecule->AtomCount ); 144 CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() ); 145 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() ); 146 CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() ); 147 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() ); 148 }; 149 136 150 void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceTest() 137 151 { 138 152 // do the pair correlation 139 153 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 154 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 140 155 CPPUNIT_ASSERT( surfacemap != NULL ); 141 156 CPPUNIT_ASSERT_EQUAL( (size_t)4, surfacemap->size() ); … … 147 162 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 148 163 // put pair correlation into bins and check with no range 164 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 149 165 binmap = BinData( surfacemap, 0.5, 0., 0. ); 150 166 CPPUNIT_ASSERT_EQUAL( (size_t)1, binmap->size() ); 151 //OutputCorrelation (binmap );167 OutputCorrelation ( (ofstream *)&cout, binmap ); 152 168 tester = binmap->begin(); 153 169 CPPUNIT_ASSERT_EQUAL( 0., tester->first ); … … 160 176 BinPairMap::iterator tester; 161 177 surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC ); 178 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 162 179 // ... and check with [0., 2.] range 163 180 binmap = BinData( surfacemap, 0.5, 0., 2. ); 164 181 CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() ); 165 //OutputCorrelation (binmap );182 // OutputCorrelation ( (ofstream *)&cout, binmap ); 166 183 tester = binmap->begin(); 167 184 CPPUNIT_ASSERT_EQUAL( 0., tester->first ); … … 177 194 BinPairMap::iterator tester; 178 195 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 196 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 179 197 // put pair correlation into bins and check with no range 180 198 binmap = BinData( surfacemap, 0.5, 0., 0. ); 181 CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size());182 OutputCorrelation ( (ofstream *)&cout, binmap);199 //OutputCorrelation ( (ofstream *)&cout, binmap ); 200 CPPUNIT_ASSERT_EQUAL( (size_t)9, binmap->size() ); 183 201 // inside point is first and must have negative value 184 tester = binmap->lower_bound( 2.95); // start depends on the min value and202 tester = binmap->lower_bound(4.25-0.5); // start depends on the min value and 185 203 CPPUNIT_ASSERT( tester != binmap->end() ); 186 204 CPPUNIT_ASSERT_EQUAL( 3, tester->second ); 187 205 // inner point 188 tester = binmap->lower_bound( -0.5);206 tester = binmap->lower_bound(0.); 189 207 CPPUNIT_ASSERT( tester != binmap->end() ); 190 208 CPPUNIT_ASSERT_EQUAL( 1, tester->second ); … … 195 213 BinPairMap::iterator tester; 196 214 surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC ); 215 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 197 216 // ... and check with [0., 2.] range 198 217 binmap = BinData( surfacemap, 0.5, -2., 4. ); 218 //OutputCorrelation ( (ofstream *)&cout, binmap ); 199 219 CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() ); 200 OutputCorrelation ( (ofstream *)&cout, binmap );201 220 // three outside points 202 tester = binmap->lower_bound( 3.);221 tester = binmap->lower_bound(4.25-0.5); 203 222 CPPUNIT_ASSERT( tester != binmap->end() ); 204 223 CPPUNIT_ASSERT_EQUAL( 3, tester->second ); 205 224 // inner point 206 tester = binmap->lower_bound( -0.5);225 tester = binmap->lower_bound(0.); 207 226 CPPUNIT_ASSERT( tester != binmap->end() ); 208 227 CPPUNIT_ASSERT_EQUAL( 1, tester->second ); 209 210 228 }; 211 229 -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp
r491876 rc695c9 23 23 { 24 24 CPPUNIT_TEST_SUITE( AnalysisCorrelationToSurfaceUnitTest ) ; 25 CPPUNIT_TEST ( SurfaceTest ); 25 26 CPPUNIT_TEST ( CorrelationToSurfaceTest ); 26 27 CPPUNIT_TEST ( CorrelationToSurfaceHydrogenBinNoRangeTest ); … … 33 34 void setUp(); 34 35 void tearDown(); 36 void SurfaceTest(); 35 37 void CorrelationToSurfaceTest(); 36 38 void CorrelationToSurfaceHydrogenBinNoRangeTest(); … … 43 45 MoleculeListClass *TestList; 44 46 molecule *TestMolecule; 47 molecule *TestSurfaceMolecule; 45 48 element *hydrogen; 46 49 element *carbon; -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
r491876 rc695c9 11 11 #include <cppunit/extensions/TestFactoryRegistry.h> 12 12 #include <cppunit/ui/text/TestRunner.h> 13 14 #include <cstring> 13 15 14 16 #include "analysis_correlation.hpp" -
src/unittests/Makefile.am
r491876 rc695c9 4 4 AM_CXXFLAGS = $(CPPUNIT_CFLAGS) 5 5 6 TESTS = ActOnAllUnitTest AnalysisBondsUnitTests AnalysisCorrelationToPointUnitTest AnalysisCorrelationToSurfaceUnitTest AnalysisPairCorrelationUnitTest BondGraphUnitTest InfoUnitTest ListOfBondsUnitTest LogUnitTest MemoryUsageObserverUnitTest MemoryAllocatorUnitTest StackClassUnitTest VectorUnitTest 6 TESTS = \ 7 ActOnAllUnitTest \ 8 AnalysisBondsUnitTests \ 9 AnalysisCorrelationToPointUnitTest \ 10 AnalysisCorrelationToSurfaceUnitTest \ 11 AnalysisPairCorrelationUnitTest \ 12 BondGraphUnitTest \ 13 CountBondsUnitTest \ 14 GSLMatrixSymmetricUnitTest \ 15 GSLMatrixUnitTest \ 16 GSLVectorUnitTest \ 17 InfoUnitTest \ 18 LinearSystemOfEquationsUnitTest \ 19 LinkedCellUnitTest \ 20 ListOfBondsUnitTest \ 21 LogUnitTest \ 22 MemoryUsageObserverUnitTest \ 23 MemoryAllocatorUnitTest \ 24 StackClassUnitTest \ 25 TesselationUnitTest \ 26 Tesselation_BoundaryTriangleUnitTest \ 27 Tesselation_InOutsideUnitTest \ 28 VectorUnitTest 29 7 30 check_PROGRAMS = $(TESTS) 8 31 noinst_PROGRAMS = $(TESTS) 9 32 10 33 ActOnAllUnitTest_SOURCES = ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp 11 ActOnAllUnitTest_LDADD = ../libmolecuilder.a 34 ActOnAllUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 12 35 13 36 AnalysisBondsUnitTests_SOURCES = analysisbondsunittest.cpp analysisbondsunittest.hpp 14 AnalysisBondsUnitTests_LDADD = ../libmolecuilder.a 37 AnalysisBondsUnitTests_LDADD = ../libmolecuilder.a ../libgslwrapper.a 15 38 16 39 AnalysisCorrelationToPointUnitTest_SOURCES = analysis_correlation.hpp AnalysisCorrelationToPointUnitTest.cpp AnalysisCorrelationToPointUnitTest.hpp 17 AnalysisCorrelationToPointUnitTest_LDADD = ../libmolecuilder.a 40 AnalysisCorrelationToPointUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 18 41 19 42 AnalysisCorrelationToSurfaceUnitTest_SOURCES = analysis_correlation.hpp AnalysisCorrelationToSurfaceUnitTest.cpp AnalysisCorrelationToSurfaceUnitTest.hpp 20 AnalysisCorrelationToSurfaceUnitTest_LDADD = ../libmolecuilder.a 43 AnalysisCorrelationToSurfaceUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 21 44 22 45 AnalysisPairCorrelationUnitTest_SOURCES = analysis_correlation.hpp AnalysisPairCorrelationUnitTest.cpp AnalysisPairCorrelationUnitTest.hpp 23 AnalysisPairCorrelationUnitTest_LDADD = ../libmolecuilder.a 46 AnalysisPairCorrelationUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 24 47 25 48 BondGraphUnitTest_SOURCES = bondgraphunittest.cpp bondgraphunittest.hpp 26 BondGraphUnitTest_LDADD = ../libmolecuilder.a 49 BondGraphUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 50 51 CountBondsUnitTest_SOURCES = CountBondsUnitTest.cpp CountBondsUnitTest.hpp 52 CountBondsUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 53 54 GSLMatrixSymmetricUnitTest_SOURCES = gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp 55 GSLMatrixSymmetricUnitTest_LDADD = ../libgslwrapper.a 56 57 GSLMatrixUnitTest_SOURCES = gslmatrixunittest.cpp gslmatrixunittest.hpp 58 GSLMatrixUnitTest_LDADD = ../libgslwrapper.a 59 60 GSLVectorUnitTest_SOURCES = gslvectorunittest.cpp gslvectorunittest.hpp 61 GSLVectorUnitTest_LDADD = ../libgslwrapper.a 27 62 28 63 InfoUnitTest_SOURCES = infounittest.cpp infounittest.hpp 29 InfoUnitTest_LDADD = ../libmolecuilder.a 64 InfoUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 65 66 LinearSystemOfEquationsUnitTest_SOURCES = linearsystemofequationsunittest.cpp linearsystemofequationsunittest.hpp 67 LinearSystemOfEquationsUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 68 69 LinkedCellUnitTest_SOURCES = LinkedCellUnitTest.cpp LinkedCellUnitTest.hpp 70 LinkedCellUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 30 71 31 72 ListOfBondsUnitTest_SOURCES = listofbondsunittest.cpp listofbondsunittest.hpp 32 ListOfBondsUnitTest_LDADD = ../libmolecuilder.a 73 ListOfBondsUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 33 74 34 75 LogUnitTest_SOURCES = logunittest.cpp logunittest.hpp 35 LogUnitTest_LDADD = ../libmolecuilder.a 76 LogUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 36 77 37 78 MemoryAllocatorUnitTest_SOURCES = memoryallocatorunittest.cpp memoryallocatorunittest.hpp 38 MemoryAllocatorUnitTest_LDADD = ../libmolecuilder.a 79 MemoryAllocatorUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 39 80 40 81 MemoryUsageObserverUnitTest_SOURCES = memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp 41 MemoryUsageObserverUnitTest_LDADD = ../libmolecuilder.a 82 MemoryUsageObserverUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 42 83 43 84 StackClassUnitTest_SOURCES = stackclassunittest.cpp stackclassunittest.hpp 44 StackClassUnitTest_LDADD = ../libmolecuilder.a 85 StackClassUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 86 87 TesselationUnitTest_SOURCES = tesselationunittest.cpp tesselationunittest.hpp 88 TesselationUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 89 90 Tesselation_BoundaryTriangleUnitTest_SOURCES = tesselation_boundarytriangleunittest.cpp tesselation_boundarytriangleunittest.hpp 91 Tesselation_BoundaryTriangleUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 92 93 Tesselation_InOutsideUnitTest_SOURCES = tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp 94 Tesselation_InOutsideUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 45 95 46 96 VectorUnitTest_SOURCES = vectorunittest.cpp vectorunittest.hpp 47 VectorUnitTest_LDADD = ../libmolecuilder.a 97 VectorUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 48 98 49 99 -
src/unittests/analysisbondsunittest.cpp
r491876 rc695c9 14 14 #include <iostream> 15 15 #include <stdio.h> 16 #include <cstring> 16 17 17 18 #include "analysis_bonds.hpp" … … 47 48 strcpy(hydrogen->symbol, "H"); 48 49 carbon = new element; 49 carbon->Z = 1;50 carbon->Z = 2; 50 51 carbon->Valence = 4; 51 52 carbon->NoValenceOrbitals = 4; -
src/unittests/bondgraphunittest.cpp
r491876 rc695c9 14 14 #include <iostream> 15 15 #include <stdio.h> 16 #include <cstring> 16 17 17 18 #include "atom.hpp" … … 19 20 #include "bondgraph.hpp" 20 21 #include "element.hpp" 22 #include "log.hpp" 21 23 #include "molecule.hpp" 22 24 #include "periodentafel.hpp" … … 41 43 hydrogen = new element; 42 44 hydrogen->Z = 1; 45 hydrogen->CovalentRadius = 0.23; 46 hydrogen->VanDerWaalsRadius = 1.09; 43 47 strcpy(hydrogen->name, "hydrogen"); 44 48 strcpy(hydrogen->symbol, "H"); 45 49 carbon = new element; 46 carbon->Z = 1; 50 carbon->Z = 2; 51 carbon->CovalentRadius = 0.68; 52 carbon->VanDerWaalsRadius = 1.7; 47 53 strcpy(carbon->name, "carbon"); 48 54 strcpy(carbon->symbol, "C"); … … 57 63 TestMolecule = new molecule(tafel); 58 64 Walker = new atom(); 59 Walker->type = hydrogen;65 Walker->type = carbon; 60 66 Walker->node->Init(1., 0., 1. ); 61 67 TestMolecule->AddAtom(Walker); 62 68 Walker = new atom(); 63 Walker->type = hydrogen;69 Walker->type = carbon; 64 70 Walker->node->Init(0., 1., 1. ); 65 71 TestMolecule->AddAtom(Walker); 66 72 Walker = new atom(); 67 Walker->type = hydrogen;73 Walker->type = carbon; 68 74 Walker->node->Init(1., 1., 0. ); 69 75 TestMolecule->AddAtom(Walker); 70 76 Walker = new atom(); 71 Walker->type = hydrogen;77 Walker->type = carbon; 72 78 Walker->node->Init(0., 0., 0. ); 73 79 TestMolecule->AddAtom(Walker); … … 77 83 78 84 // create a small file with table 85 dummyname = new string("dummy.dat"); 79 86 filename = new string("test.dat"); 80 87 ofstream test(filename->c_str()); … … 92 99 remove(filename->c_str()); 93 100 delete(filename); 101 delete(dummyname); 94 102 delete(BG); 95 103 … … 113 121 /** UnitTest for BondGraphTest::ConstructBondGraph(). 114 122 */ 115 void BondGraphTest::ConstructGraph Test()123 void BondGraphTest::ConstructGraphFromTableTest() 116 124 { 117 125 atom *Walker = TestMolecule->start->next; … … 119 127 CPPUNIT_ASSERT( TestMolecule->end != Walker ); 120 128 CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) ); 129 CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) ); 130 CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) ); 131 }; 132 133 /** UnitTest for BondGraphTest::ConstructBondGraph(). 134 */ 135 void BondGraphTest::ConstructGraphFromCovalentRadiiTest() 136 { 137 atom *Walker = TestMolecule->start->next; 138 atom *Runner = TestMolecule->end->previous; 139 CPPUNIT_ASSERT( TestMolecule->end != Walker ); 140 CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) ); 121 141 CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) ); 122 142 CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) ); -
src/unittests/bondgraphunittest.hpp
r491876 rc695c9 23 23 CPPUNIT_TEST_SUITE( BondGraphTest) ; 24 24 CPPUNIT_TEST ( LoadTableTest ); 25 CPPUNIT_TEST ( ConstructGraphTest ); 25 CPPUNIT_TEST ( ConstructGraphFromTableTest ); 26 CPPUNIT_TEST ( ConstructGraphFromCovalentRadiiTest ); 26 27 CPPUNIT_TEST_SUITE_END(); 27 28 … … 30 31 void tearDown(); 31 32 void LoadTableTest(); 32 void ConstructGraphTest(); 33 void ConstructGraphFromTableTest(); 34 void ConstructGraphFromCovalentRadiiTest(); 33 35 34 36 private: … … 41 43 BondGraph *BG; 42 44 string *filename; 45 string *dummyname; 43 46 }; 44 47 -
src/unittests/listofbondsunittest.cpp
r491876 rc695c9 11 11 #include <cppunit/extensions/TestFactoryRegistry.h> 12 12 #include <cppunit/ui/text/TestRunner.h> 13 14 #include <cstring> 13 15 14 16 #include "listofbondsunittest.hpp" -
src/unittests/logunittest.cpp
r491876 rc695c9 35 35 { 36 36 logger::getInstance()->setVerbosity(2); 37 Log() << Verbose(0) << "Verbosity level is set to 2." << endl;38 Log() << Verbose(0) << "Test level 0" << endl;39 Log() << Verbose(1) << "Test level 1" << endl;40 Log() << Verbose(2) << "Test level 2" << endl;41 Log() << Verbose(3) << "Test level 3" << endl;42 Log() << Verbose(4) << "Test level 4" << endl;37 DoLog(0) && (Log() << Verbose(0) << "Verbosity level is set to 2." << endl); 38 DoLog(0) && (Log() << Verbose(0) << "Test level 0" << endl); 39 DoLog(1) && (Log() << Verbose(1) << "Test level 1" << endl); 40 DoLog(2) && (Log() << Verbose(2) << "Test level 2" << endl); 41 DoLog(3) && (Log() << Verbose(3) << "Test level 3" << endl); 42 DoLog(4) && (Log() << Verbose(4) << "Test level 4" << endl); 43 43 44 Log() << Verbose(0) << "Output a log message." << endl;45 eLog() << Verbose(0) << "Output an error message." << endl;44 DoLog(0) && (Log() << Verbose(0) << "Output a log message." << endl); 45 DoeLog(0) && (eLog()<< Verbose(0) << "Output an error message." << endl); 46 46 setVerbosity(3); 47 Log() << Verbose(4) << "This should not be printed." << endl;48 eLog() << Verbose(4) << "This should not be printed." << endl;47 DoLog(4) && (Log() << Verbose(4) << "This should not be printed." << endl); 48 DoeLog(4) && (eLog()<< Verbose(4) << "This should not be printed." << endl); 49 49 }; 50 50 -
src/unittests/memoryallocatorunittest.cpp
r491876 rc695c9 46 46 char* buffer3 = NULL; 47 47 buffer3 = Malloc<char>(4, ""); 48 Log() << Verbose(0) << buffer3 << endl;48 DoLog(0) && (Log() << Verbose(0) << buffer3 << endl); 49 49 Free(&buffer3); 50 50 -
src/unittests/tesselationunittest.cpp
r491876 rc695c9 12 12 #include <cppunit/extensions/TestFactoryRegistry.h> 13 13 #include <cppunit/ui/text/TestRunner.h> 14 15 #include <cstring> 14 16 15 17 #include "defs.hpp" … … 30 32 class TesselPoint *Walker; 31 33 Walker = new TesselPoint; 32 Walker->node = new Vector(1., 0., 0.);33 Walker->Name = new char[3];34 Walker->node = new Vector(1., 0., -1.); 35 Walker->Name = Malloc<char>(3, "TesselationTest::setUp"); 34 36 strcpy(Walker->Name, "1"); 35 37 Walker->nr = 1; 36 38 Corners.push_back(Walker); 37 39 Walker = new TesselPoint; 38 Walker->node = new Vector(-1., 1., 0.);39 Walker->Name = new char[3];40 Walker->node = new Vector(-1., 1., -1.); 41 Walker->Name = Malloc<char>(3, "TesselationTest::setUp"); 40 42 strcpy(Walker->Name, "2"); 41 43 Walker->nr = 2; 42 44 Corners.push_back(Walker); 43 45 Walker = new TesselPoint; 44 Walker->node = new Vector(-1., -1., 0.);45 Walker->Name = new char[3];46 Walker->node = new Vector(-1., -1., -1.); 47 Walker->Name = Malloc<char>(3, "TesselationTest::setUp"); 46 48 strcpy(Walker->Name, "3"); 47 49 Walker->nr = 3; … … 49 51 Walker = new TesselPoint; 50 52 Walker->node = new Vector(-1., 0., 1.); 51 Walker->Name = new char[3];53 Walker->Name = Malloc<char>(3, "TesselationTest::setUp"); 52 54 strcpy(Walker->Name, "4"); 53 55 Walker->nr = 4; … … 59 61 // create tesselation 60 62 TesselStruct = new Tesselation; 61 TesselStruct->PointsOnBoundary.clear();62 TesselStruct->LinesOnBoundary.clear();63 TesselStruct->TrianglesOnBoundary.clear();63 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->PointsOnBoundary.empty() ); 64 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->LinesOnBoundary.empty() ); 65 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->TrianglesOnBoundary.empty() ); 64 66 TesselStruct->FindStartingTriangle(SPHERERADIUS, LinkedList); 65 bool flag = false;66 67 67 LineMap::iterator baseline = TesselStruct->LinesOnBoundary.begin(); 68 while (baseline != TesselStruct->LinesOnBoundary.end()) { 69 if (baseline->second->triangles.size() == 1) { 70 flag = TesselStruct->FindNextSuitableTriangle(*(baseline->second), *(((baseline->second->triangles.begin()))->second), SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one. 68 CandidateForTesselation *baseline = NULL; 69 BoundaryTriangleSet *T = NULL; 70 bool OneLoopWithoutSuccessFlag = true; 71 bool TesselationFailFlag = false; 72 while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) { 73 // 2a. fill all new OpenLines 74 for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) { 75 baseline = Runner->second; 76 if (baseline->pointlist.empty()) { 77 T = (((baseline->BaseLine->triangles.begin()))->second); 78 TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one. 79 } 71 80 } 72 baseline++; 73 if ((baseline == TesselStruct->LinesOnBoundary.end()) && (flag)) { 74 baseline = TesselStruct->LinesOnBoundary.begin(); // restart if we reach end due to newly inserted lines 75 flag = false; 81 82 // 2b. search for smallest ShortestAngle among all candidates 83 double ShortestAngle = 4.*M_PI; 84 for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) { 85 if (Runner->second->ShortestAngle < ShortestAngle) { 86 baseline = Runner->second; 87 ShortestAngle = baseline->ShortestAngle; 88 } 89 } 90 if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty())) 91 OneLoopWithoutSuccessFlag = false; 92 else { 93 TesselStruct->AddCandidatePolygon(*baseline, SPHERERADIUS, LinkedList); 76 94 } 77 95 } … … 83 101 delete(LinkedList); 84 102 delete(TesselStruct); 85 for (LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) { 86 delete[]((*Runner)->Name); 103 for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) { 87 104 delete((*Runner)->node); 88 105 delete(*Runner); 89 106 } 90 107 Corners.clear(); 91 }; 92 93 /** UnitTest for Tesselation::IsInnerPoint() 94 */ 95 void TesselationTest::IsInnerPointTest() 96 { 97 // true inside points 98 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.,0.,0.), LinkedList) ); 99 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.5,0.,0.), LinkedList) ); 100 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.,0.5,0.), LinkedList) ); 101 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.,0.,0.5), LinkedList) ); 102 103 // corners 104 for (LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) 105 CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint((*Runner), LinkedList) ); 106 107 // true outside points 108 CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(0.,5.,0.), LinkedList) ); 109 CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(0.,0.,5.), LinkedList) ); 110 CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(1.,1.,1.), LinkedList) ); 111 112 // tricky point, there are three equally close triangles 113 CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(5.,0.,0.), LinkedList) ); 114 108 MemoryUsageObserver::purgeInstance(); 109 logger::purgeInstance(); 110 errorLogger::purgeInstance(); 115 111 }; 116 112 -
src/unittests/tesselationunittest.hpp
r491876 rc695c9 21 21 { 22 22 CPPUNIT_TEST_SUITE( TesselationTest) ; 23 CPPUNIT_TEST ( IsInnerPointTest );24 23 CPPUNIT_TEST ( GetAllTrianglesTest ); 25 24 CPPUNIT_TEST ( ContainmentTest ); … … 29 28 void setUp(); 30 29 void tearDown(); 31 void IsInnerPointTest();32 30 void GetAllTrianglesTest(); 33 31 void ContainmentTest(); … … 36 34 private: 37 35 class Tesselation *TesselStruct; 38 Linked Nodes Corners;36 LinkedCell::LinkedNodes Corners; 39 37 class LinkedCell *LinkedList; 40 38 }; -
src/vector.cpp
r491876 rc695c9 8 8 #include "defs.hpp" 9 9 #include "helpers.hpp" 10 #include "memoryallocator.hpp" 10 #include "info.hpp" 11 #include "gslmatrix.hpp" 11 12 #include "leastsquaremin.hpp" 12 13 #include "log.hpp" 14 #include "memoryallocator.hpp" 13 15 #include "vector.hpp" 14 16 #include "verbose.hpp" 17 #include "World.hpp" 18 19 #include <gsl/gsl_linalg.h> 20 #include <gsl/gsl_matrix.h> 21 #include <gsl/gsl_permutation.h> 22 #include <gsl/gsl_vector.h> 15 23 16 24 /************************************ Functions for class vector ************************************/ … … 19 27 */ 20 28 Vector::Vector() { x[0] = x[1] = x[2] = 0.; }; 29 30 /** Constructor of class vector. 31 */ 32 Vector::Vector(const Vector * const a) 33 { 34 x[0] = a->x[0]; 35 x[1] = a->x[1]; 36 x[2] = a->x[2]; 37 }; 38 39 /** Constructor of class vector. 40 */ 41 Vector::Vector(const Vector &a) 42 { 43 x[0] = a.x[0]; 44 x[1] = a.x[1]; 45 x[2] = a.x[2]; 46 }; 21 47 22 48 /** Constructor of class vector. … … 215 241 * \param *Origin first vector of line 216 242 * \param *LineVector second vector of line 217 * \return true - \a this contains intersection point on return, false - line is parallel to plane 243 * \return true - \a this contains intersection point on return, false - line is parallel to plane (even if in-plane) 218 244 */ 219 245 bool Vector::GetIntersectionWithPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset, const Vector * const Origin, const Vector * const LineVector) 220 246 { 247 Info FunctionInfo(__func__); 221 248 double factor; 222 249 Vector Direction, helper; … … 226 253 Direction.SubtractVector(Origin); 227 254 Direction.Normalize(); 228 //Log() << Verbose(4) << "INFO: Direction is " << Direction << "." << endl; 255 DoLog(1) && (Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl); 256 //Log() << Verbose(1) << "INFO: PlaneNormal is " << *PlaneNormal << " and PlaneOffset is " << *PlaneOffset << "." << endl; 229 257 factor = Direction.ScalarProduct(PlaneNormal); 230 if (fa ctor< MYEPSILON) { // Uniqueness: line parallel to plane?231 eLog() << Verbose(2) << "Line is parallel to plane, no intersection." << endl;258 if (fabs(factor) < MYEPSILON) { // Uniqueness: line parallel to plane? 259 DoLog(1) && (Log() << Verbose(1) << "BAD: Line is parallel to plane, no intersection." << endl); 232 260 return false; 233 261 } … … 235 263 helper.SubtractVector(Origin); 236 264 factor = helper.ScalarProduct(PlaneNormal)/factor; 237 if (fa ctor< MYEPSILON) { // Origin is in-plane238 //Log() << Verbose(2) << "Origin of line is in-plane, simple." << endl;265 if (fabs(factor) < MYEPSILON) { // Origin is in-plane 266 DoLog(1) && (Log() << Verbose(1) << "GOOD: Origin of line is in-plane." << endl); 239 267 CopyVector(Origin); 240 268 return true; … … 243 271 Direction.Scale(factor); 244 272 CopyVector(Origin); 245 //Log() << Verbose(4) << "INFO: Scaled direction is " << Direction << "." << endl;273 DoLog(1) && (Log() << Verbose(1) << "INFO: Scaled direction is " << Direction << "." << endl); 246 274 AddVector(&Direction); 247 275 … … 250 278 helper.SubtractVector(PlaneOffset); 251 279 if (helper.ScalarProduct(PlaneNormal) < MYEPSILON) { 252 //Log() << Verbose(2) << "INFO: Intersection at " << *this << " is good." << endl;280 DoLog(1) && (Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl); 253 281 return true; 254 282 } else { 255 eLog() << Verbose(2) << "Intersection point " << *this << " is not on plane." << endl;283 DoeLog(2) && (eLog()<< Verbose(2) << "Intersection point " << *this << " is not on plane." << endl); 256 284 return false; 257 285 } 258 286 }; 259 287 260 /** Calculates the minimum distance of this vector to the plane.288 /** Calculates the minimum distance vector of this vector to the plane. 261 289 * \param *out output stream for debugging 262 290 * \param *PlaneNormal normal of plane 263 291 * \param *PlaneOffset offset of plane 264 * \return distance to plane265 */ 266 double Vector::DistanceToPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset) const292 * \return distance vector onto to plane 293 */ 294 Vector Vector::GetDistanceVectorToPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset) const 267 295 { 268 296 Vector temp; … … 282 310 sign = 0.; 283 311 284 return (temp.Norm()*sign); 312 temp.Normalize(); 313 temp.Scale(sign); 314 return temp; 315 }; 316 317 /** Calculates the minimum distance of this vector to the plane. 318 * \sa Vector::GetDistanceVectorToPlane() 319 * \param *out output stream for debugging 320 * \param *PlaneNormal normal of plane 321 * \param *PlaneOffset offset of plane 322 * \return distance to plane 323 */ 324 double Vector::DistanceToPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset) const 325 { 326 return GetDistanceVectorToPlane(PlaneNormal,PlaneOffset).Norm(); 285 327 }; 286 328 287 329 /** Calculates the intersection of the two lines that are both on the same plane. 288 * We construct auxiliary plane with its vector normal to one line direction and the PlaneNormal, then a vector 289 * from the first line's offset onto the plane. Finally, scale by factor is 1/cos(angle(line1,line2..)) = 1/SP(...), and 290 * project onto the first line's direction and add its offset. 330 * This is taken from Weisstein, Eric W. "Line-Line Intersection." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/Line-LineIntersection.html 291 331 * \param *out output stream for debugging 292 332 * \param *Line1a first vector of first line … … 299 339 bool Vector::GetIntersectionOfTwoLinesOnPlane(const Vector * const Line1a, const Vector * const Line1b, const Vector * const Line2a, const Vector * const Line2b, const Vector *PlaneNormal) 300 340 { 301 bool result = true; 302 Vector Direction, OtherDirection; 303 Vector AuxiliaryNormal; 304 Vector Distance; 305 const Vector *Normal = NULL; 306 Vector *ConstructedNormal = NULL; 307 bool FreeNormal = false; 308 309 // construct both direction vectors 310 Zero(); 311 Direction.CopyVector(Line1b); 312 Direction.SubtractVector(Line1a); 313 if (Direction.IsZero()) 341 Info FunctionInfo(__func__); 342 343 GSLMatrix *M = new GSLMatrix(4,4); 344 345 M->SetAll(1.); 346 for (int i=0;i<3;i++) { 347 M->Set(0, i, Line1a->x[i]); 348 M->Set(1, i, Line1b->x[i]); 349 M->Set(2, i, Line2a->x[i]); 350 M->Set(3, i, Line2b->x[i]); 351 } 352 353 //Log() << Verbose(1) << "Coefficent matrix is:" << endl; 354 //ostream &output = Log() << Verbose(1); 355 //for (int i=0;i<4;i++) { 356 // for (int j=0;j<4;j++) 357 // output << "\t" << M->Get(i,j); 358 // output << endl; 359 //} 360 if (fabs(M->Determinant()) > MYEPSILON) { 361 DoLog(1) && (Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl); 314 362 return false; 315 OtherDirection.CopyVector(Line2b); 316 OtherDirection.SubtractVector(Line2a); 317 if (OtherDirection.IsZero()) 363 } 364 DoLog(1) && (Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl); 365 366 367 // constuct a,b,c 368 Vector a; 369 Vector b; 370 Vector c; 371 Vector d; 372 a.CopyVector(Line1b); 373 a.SubtractVector(Line1a); 374 b.CopyVector(Line2b); 375 b.SubtractVector(Line2a); 376 c.CopyVector(Line2a); 377 c.SubtractVector(Line1a); 378 d.CopyVector(Line2b); 379 d.SubtractVector(Line1b); 380 DoLog(1) && (Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl); 381 if ((a.NormSquared() < MYEPSILON) || (b.NormSquared() < MYEPSILON)) { 382 Zero(); 383 DoLog(1) && (Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl); 384 return false; 385 } 386 387 // check for parallelity 388 Vector parallel; 389 double factor = 0.; 390 if (fabs(a.ScalarProduct(&b)*a.ScalarProduct(&b)/a.NormSquared()/b.NormSquared() - 1.) < MYEPSILON) { 391 parallel.CopyVector(Line1a); 392 parallel.SubtractVector(Line2a); 393 factor = parallel.ScalarProduct(&a)/a.Norm(); 394 if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) { 395 CopyVector(Line2a); 396 DoLog(1) && (Log() << Verbose(1) << "Lines conincide." << endl); 397 return true; 398 } else { 399 parallel.CopyVector(Line1a); 400 parallel.SubtractVector(Line2b); 401 factor = parallel.ScalarProduct(&a)/a.Norm(); 402 if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) { 403 CopyVector(Line2b); 404 DoLog(1) && (Log() << Verbose(1) << "Lines conincide." << endl); 405 return true; 406 } 407 } 408 DoLog(1) && (Log() << Verbose(1) << "Lines are parallel." << endl); 409 Zero(); 318 410 return false; 319 320 Direction.Normalize(); 321 OtherDirection.Normalize(); 322 323 //Log() << Verbose(4) << "INFO: Normalized Direction " << Direction << " and OtherDirection " << OtherDirection << "." << endl; 324 325 if (fabs(OtherDirection.ScalarProduct(&Direction) - 1.) < MYEPSILON) { // lines are parallel 326 if ((Line1a == Line2a) || (Line1a == Line2b)) 327 CopyVector(Line1a); 328 else if ((Line1b == Line2b) || (Line1b == Line2b)) 329 CopyVector(Line1b); 330 else 331 return false; 332 Log() << Verbose(4) << "INFO: Intersection is " << *this << "." << endl; 333 return true; 334 } else { 335 // check whether we have a plane normal vector 336 if (PlaneNormal == NULL) { 337 ConstructedNormal = new Vector; 338 ConstructedNormal->MakeNormalVector(&Direction, &OtherDirection); 339 Normal = ConstructedNormal; 340 FreeNormal = true; 341 } else 342 Normal = PlaneNormal; 343 344 AuxiliaryNormal.MakeNormalVector(&OtherDirection, Normal); 345 //Log() << Verbose(4) << "INFO: PlaneNormal is " << *Normal << " and AuxiliaryNormal " << AuxiliaryNormal << "." << endl; 346 347 Distance.CopyVector(Line2a); 348 Distance.SubtractVector(Line1a); 349 //Log() << Verbose(4) << "INFO: Distance is " << Distance << "." << endl; 350 if (Distance.IsZero()) { 351 // offsets are equal, match found 352 CopyVector(Line1a); 353 result = true; 354 } else { 355 CopyVector(Distance.Projection(&AuxiliaryNormal)); 356 //Log() << Verbose(4) << "INFO: Projected Distance is " << *this << "." << endl; 357 double factor = Direction.ScalarProduct(&AuxiliaryNormal); 358 //Log() << Verbose(4) << "INFO: Scaling factor is " << factor << "." << endl; 359 Scale(1./(factor*factor)); 360 //Log() << Verbose(4) << "INFO: Scaled Distance is " << *this << "." << endl; 361 CopyVector(Projection(&Direction)); 362 //Log() << Verbose(4) << "INFO: Distance, projected into Direction, is " << *this << "." << endl; 363 if (this->IsZero()) 364 result = false; 365 else 366 result = true; 367 AddVector(Line1a); 368 } 369 370 if (FreeNormal) 371 delete(ConstructedNormal); 372 } 373 if (result) 374 Log() << Verbose(4) << "INFO: Intersection is " << *this << "." << endl; 375 376 return result; 411 } 412 413 // obtain s 414 double s; 415 Vector temp1, temp2; 416 temp1.CopyVector(&c); 417 temp1.VectorProduct(&b); 418 temp2.CopyVector(&a); 419 temp2.VectorProduct(&b); 420 DoLog(1) && (Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl); 421 if (fabs(temp2.NormSquared()) > MYEPSILON) 422 s = temp1.ScalarProduct(&temp2)/temp2.NormSquared(); 423 else 424 s = 0.; 425 DoLog(1) && (Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl); 426 427 // construct intersection 428 CopyVector(&a); 429 Scale(s); 430 AddVector(Line1a); 431 DoLog(1) && (Log() << Verbose(1) << "Intersection is at " << *this << "." << endl); 432 433 return true; 377 434 }; 378 435 … … 480 537 else 481 538 return false; 539 }; 540 541 /** Checks whether vector is normal to \a *normal. 542 * @return true - vector is normalized, false - vector is not 543 */ 544 bool Vector::IsEqualTo(const Vector * const a) const 545 { 546 bool status = true; 547 for (int i=0;i<NDIM;i++) { 548 if (fabs(x[i] - a->x[i]) > MYEPSILON) 549 status = false; 550 } 551 return status; 482 552 }; 483 553 … … 632 702 void Vector::Output() const 633 703 { 634 Log() << Verbose(0) << "(";704 DoLog(0) && (Log() << Verbose(0) << "("); 635 705 for (int i=0;i<NDIM;i++) { 636 Log() << Verbose(0) << x[i];706 DoLog(0) && (Log() << Verbose(0) << x[i]); 637 707 if (i != 2) 638 Log() << Verbose(0) << ",";639 } 640 Log() << Verbose(0) << ")";708 DoLog(0) && (Log() << Verbose(0) << ","); 709 } 710 DoLog(0) && (Log() << Verbose(0) << ")"); 641 711 }; 642 712 … … 747 817 x[i] = C.x[i]; 748 818 } else { 749 eLog() << Verbose(1) << "inverse of matrix does not exists: det A = " << detA << "." << endl;819 DoeLog(1) && (eLog()<< Verbose(1) << "inverse of matrix does not exists: det A = " << detA << "." << endl); 750 820 } 751 821 }; … … 773 843 projection = ScalarProduct(n)/n->ScalarProduct(n); // remove constancy from n (keep as logical one) 774 844 // withdraw projected vector twice from original one 775 Log() << Verbose(1) << "Vector: ";845 DoLog(1) && (Log() << Verbose(1) << "Vector: "); 776 846 Output(); 777 Log() << Verbose(0) << "\t";847 DoLog(0) && (Log() << Verbose(0) << "\t"); 778 848 for (int i=NDIM;i--;) 779 849 x[i] -= 2.*projection*n->x[i]; 780 Log() << Verbose(0) << "Projected vector: ";850 DoLog(0) && (Log() << Verbose(0) << "Projected vector: "); 781 851 Output(); 782 Log() << Verbose(0) << endl;852 DoLog(0) && (Log() << Verbose(0) << endl); 783 853 }; 784 854 … … 799 869 x2.SubtractVector(y2); 800 870 if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) { 801 eLog() << Verbose(2) << "Given vectors are linear dependent." << endl;871 DoeLog(2) && (eLog()<< Verbose(2) << "Given vectors are linear dependent." << endl); 802 872 return false; 803 873 } … … 833 903 Zero(); 834 904 if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) { 835 eLog() << Verbose(2) << "Given vectors are linear dependent." << endl;905 DoeLog(2) && (eLog()<< Verbose(2) << "Given vectors are linear dependent." << endl); 836 906 return false; 837 907 } … … 884 954 double norm; 885 955 886 Log() << Verbose(4);956 DoLog(4) && (Log() << Verbose(4)); 887 957 GivenVector->Output(); 888 Log() << Verbose(0) << endl;958 DoLog(0) && (Log() << Verbose(0) << endl); 889 959 for (j=NDIM;j--;) 890 960 Components[j] = -1; … … 893 963 if (fabs(GivenVector->x[j]) > MYEPSILON) 894 964 Components[Last++] = j; 895 Log() << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl;965 DoLog(4) && (Log() << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl); 896 966 897 967 switch(Last) { … … 943 1013 944 1014 for (j=0;j<num;j++) { 945 Log() << Verbose(1) << j << "th atom's vector: ";1015 DoLog(1) && (Log() << Verbose(1) << j << "th atom's vector: "); 946 1016 (vectors[j])->Output(); 947 Log() << Verbose(0) << endl;1017 DoLog(0) && (Log() << Verbose(0) << endl); 948 1018 } 949 1019 … … 1065 1135 j += i+1; 1066 1136 do { 1067 Log() << Verbose(0) << coords[i] << "[0.." << cell_size[j] << "]: ";1137 DoLog(0) && (Log() << Verbose(0) << coords[i] << "[0.." << cell_size[j] << "]: "); 1068 1138 cin >> x[i]; 1069 1139 } while (((x[i] < 0) || (x[i] >= cell_size[j])) && (check)); … … 1096 1166 B2 = cos(beta) * x2->Norm() * c; 1097 1167 C = c * c; 1098 Log() << Verbose(2) << "A " << A << "\tB " << B1 << "\tC " << C << endl;1168 DoLog(2) && (Log() << Verbose(2) << "A " << A << "\tB " << B1 << "\tC " << C << endl); 1099 1169 int flag = 0; 1100 1170 if (fabs(x1->x[0]) < MYEPSILON) { // check for zero components for the later flipping and back-flipping … … 1135 1205 D2 = -y->x[0]/x1->x[0]*x1->x[2]+y->x[2]; 1136 1206 D3 = y->x[0]/x1->x[0]*A-B1; 1137 Log() << Verbose(2) << "D1 " << D1 << "\tD2 " << D2 << "\tD3 " << D3 << "\n";1207 DoLog(2) && (Log() << Verbose(2) << "D1 " << D1 << "\tD2 " << D2 << "\tD3 " << D3 << "\n"); 1138 1208 if (fabs(D1) < MYEPSILON) { 1139 Log() << Verbose(2) << "D1 == 0!\n";1209 DoLog(2) && (Log() << Verbose(2) << "D1 == 0!\n"); 1140 1210 if (fabs(D2) > MYEPSILON) { 1141 Log() << Verbose(3) << "D2 != 0!\n";1211 DoLog(3) && (Log() << Verbose(3) << "D2 != 0!\n"); 1142 1212 x[2] = -D3/D2; 1143 1213 E1 = A/x1->x[0] + x1->x[2]/x1->x[0]*D3/D2; 1144 1214 E2 = -x1->x[1]/x1->x[0]; 1145 Log() << Verbose(3) << "E1 " << E1 << "\tE2 " << E2 << "\n";1215 DoLog(3) && (Log() << Verbose(3) << "E1 " << E1 << "\tE2 " << E2 << "\n"); 1146 1216 F1 = E1*E1 + 1.; 1147 1217 F2 = -E1*E2; 1148 1218 F3 = E1*E1 + D3*D3/(D2*D2) - C; 1149 Log() << Verbose(3) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n";1219 DoLog(3) && (Log() << Verbose(3) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n"); 1150 1220 if (fabs(F1) < MYEPSILON) { 1151 Log() << Verbose(4) << "F1 == 0!\n";1152 Log() << Verbose(4) << "Gleichungssystem linear\n";1221 DoLog(4) && (Log() << Verbose(4) << "F1 == 0!\n"); 1222 DoLog(4) && (Log() << Verbose(4) << "Gleichungssystem linear\n"); 1153 1223 x[1] = F3/(2.*F2); 1154 1224 } else { 1155 1225 p = F2/F1; 1156 1226 q = p*p - F3/F1; 1157 Log() << Verbose(4) << "p " << p << "\tq " << q << endl;1227 DoLog(4) && (Log() << Verbose(4) << "p " << p << "\tq " << q << endl); 1158 1228 if (q < 0) { 1159 Log() << Verbose(4) << "q < 0" << endl;1229 DoLog(4) && (Log() << Verbose(4) << "q < 0" << endl); 1160 1230 return false; 1161 1231 } … … 1164 1234 x[0] = A/x1->x[0] - x1->x[1]/x1->x[0]*x[1] + x1->x[2]/x1->x[0]*x[2]; 1165 1235 } else { 1166 Log() << Verbose(2) << "Gleichungssystem unterbestimmt\n";1236 DoLog(2) && (Log() << Verbose(2) << "Gleichungssystem unterbestimmt\n"); 1167 1237 return false; 1168 1238 } … … 1170 1240 E1 = A/x1->x[0]+x1->x[1]/x1->x[0]*D3/D1; 1171 1241 E2 = x1->x[1]/x1->x[0]*D2/D1 - x1->x[2]; 1172 Log() << Verbose(2) << "E1 " << E1 << "\tE2 " << E2 << "\n";1242 DoLog(2) && (Log() << Verbose(2) << "E1 " << E1 << "\tE2 " << E2 << "\n"); 1173 1243 F1 = E2*E2 + D2*D2/(D1*D1) + 1.; 1174 1244 F2 = -(E1*E2 + D2*D3/(D1*D1)); 1175 1245 F3 = E1*E1 + D3*D3/(D1*D1) - C; 1176 Log() << Verbose(2) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n";1246 DoLog(2) && (Log() << Verbose(2) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n"); 1177 1247 if (fabs(F1) < MYEPSILON) { 1178 Log() << Verbose(3) << "F1 == 0!\n";1179 Log() << Verbose(3) << "Gleichungssystem linear\n";1248 DoLog(3) && (Log() << Verbose(3) << "F1 == 0!\n"); 1249 DoLog(3) && (Log() << Verbose(3) << "Gleichungssystem linear\n"); 1180 1250 x[2] = F3/(2.*F2); 1181 1251 } else { 1182 1252 p = F2/F1; 1183 1253 q = p*p - F3/F1; 1184 Log() << Verbose(3) << "p " << p << "\tq " << q << endl;1254 DoLog(3) && (Log() << Verbose(3) << "p " << p << "\tq " << q << endl); 1185 1255 if (q < 0) { 1186 Log() << Verbose(3) << "q < 0" << endl;1256 DoLog(3) && (Log() << Verbose(3) << "q < 0" << endl); 1187 1257 return false; 1188 1258 } … … 1222 1292 for (j=2;j>=0;j--) { 1223 1293 k = (i & pot(2,j)) << j; 1224 Log() << Verbose(2) << "k " << k << "\tpot(2,j) " << pot(2,j) << endl;1294 DoLog(2) && (Log() << Verbose(2) << "k " << k << "\tpot(2,j) " << pot(2,j) << endl); 1225 1295 sign[j] = (k == 0) ? 1. : -1.; 1226 1296 } 1227 Log() << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n";1297 DoLog(2) && (Log() << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n"); 1228 1298 // apply sign matrix 1229 1299 for (j=NDIM;j--;) … … 1231 1301 // calculate angle and check 1232 1302 ang = x2->Angle (this); 1233 Log() << Verbose(1) << i << "th angle " << ang << "\tbeta " << cos(beta) << " :\t";1303 DoLog(1) && (Log() << Verbose(1) << i << "th angle " << ang << "\tbeta " << cos(beta) << " :\t"); 1234 1304 if (fabs(ang - cos(beta)) < MYEPSILON) { 1235 1305 break; -
src/vector.hpp
r491876 rc695c9 27 27 28 28 Vector(); 29 Vector(const Vector * const a); 30 Vector(const Vector &a); 29 31 Vector(const double x1, const double x2, const double x3); 30 32 ~Vector(); … … 42 44 bool IsOne() const; 43 45 bool IsNormalTo(const Vector * const normal) const; 46 bool IsEqualTo(const Vector * const a) const; 44 47 45 48 void AddVector(const Vector * const y); … … 66 69 void LinearCombinationOfVectors(const Vector * const x1, const Vector * const x2, const Vector * const x3, const double * const factors); 67 70 double CutsPlaneAt(const Vector * const A, const Vector * const B, const Vector * const C) const; 71 Vector GetDistanceVectorToPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset) const; 68 72 bool GetIntersectionWithPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset, const Vector * const Origin, const Vector * const LineVector); 69 73 bool GetIntersectionOfTwoLinesOnPlane(const Vector * const Line1a, const Vector * const Line1b, const Vector * const Line2a, const Vector * const Line2b, const Vector *Normal = NULL); -
src/verbose.cpp
r491876 rc695c9 17 17 18 18 /** States whether current output message should be print or not. 19 * Compares Verbose::Verbosity against \a verbosityLevel.19 * Compares Verbose::Verbosity plus Info::verbosity against \a verbosityLevel. 20 20 * \param verbosityLevel given global level of verbosity 21 21 * \return true - do output, false - don't … … 26 26 }; 27 27 28 /** States whether current error output message should be print or not. 29 * Compares Verbose::Verbosity against \a verbosityLevel. 30 * \param verbosityLevel given global level of verbosity 31 * \return true - do output, false - don't 32 */ 33 bool Verbose::DoErrorOutput(int verbosityLevel) const 34 { 35 return (verbosityLevel >= Verbosity); 36 }; 28 37 29 38 /** Operator for the Verbose(arg) call. -
src/verbose.hpp
r491876 rc695c9 37 37 ostream& print (ostream &ost) const; 38 38 bool DoOutput(int verbosityLevel) const; 39 bool DoErrorOutput(int verbosityLevel) const; 39 40 private: 40 41 int Verbosity; -
tests/regression/Tesselation/1/post/NonConvexEnvelope.dat
r491876 rc695c9 1 1 TITLE = "3D CONVEX SHELL" 2 2 VARIABLES = "X" "Y" "Z" "U" 3 ZONE T=" 0- H08_ H09_ H11", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE3 ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 4 9.78209 2.64589 2.64589 0 5 5 9.78209 2.64589 4.42589 0 … … 13 13 1 3 4 14 14 1 4 7 15 4 6 7 15 16 3 4 5 16 1 7 8 17 1 2 8 18 4 6 7 17 4 5 6 19 18 2 3 5 20 4 5 621 6 7 822 1 2 323 19 2 5 8 24 20 5 6 8 21 6 7 8 22 2 7 8 23 1 2 7 24 1 2 3 -
tests/regression/Tesselation/1/post/NonConvexEnvelope.r3d
r491876 rc695c9 34 34 1.37419 -0.89433 -0.89 0.12489 1.24767 -0.89 -1.12431 -0.89433 -0.89 1. 0. 0. 35 35 1 36 2.26414 0.364321 -4.44089e-16 0.12489 1.24767 -0.89 0.12489 1.24767 0.89 1. 0. 0.37 138 1.37419 -0.89433 -0.89 -1.12431 -0.89433 -0.89 -1.12431 -0.89433 0.89 1. 0. 0.39 140 1.37419 -0.89433 -0.89 1.37419 -0.89433 0.89 -1.12431 -0.89433 0.89 1. 0. 0.41 142 36 0.12489 1.24767 -0.89 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.89433 -0.89 1. 0. 0. 43 37 1 44 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-160.12489 1.24767 0.89 1. 0. 0.38 2.26414 0.364321 -4.44089e-16 0.12489 1.24767 -0.89 0.12489 1.24767 0.89 1. 0. 0. 45 39 1 46 40 0.12489 1.24767 -0.89 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-16 1. 0. 0. 47 41 1 48 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.89433 -0.89 -1.12431 -0.89433 0.89 1. 0. 0. 49 1 50 1.37419 -0.89433 -0.89 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-16 1. 0. 0. 42 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-16 0.12489 1.24767 0.89 1. 0. 0. 51 43 1 52 44 1.37419 -0.89433 0.89 0.12489 1.24767 0.89 -1.12431 -0.89433 0.89 1. 0. 0. 53 45 1 54 46 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.89433 0.89 1. 0. 0. 47 1 48 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.89433 -0.89 -1.12431 -0.89433 0.89 1. 0. 0. 49 1 50 1.37419 -0.89433 0.89 -1.12431 -0.89433 -0.89 -1.12431 -0.89433 0.89 1. 0. 0. 51 1 52 1.37419 -0.89433 -0.89 1.37419 -0.89433 0.89 -1.12431 -0.89433 -0.89 1. 0. 0. 53 1 54 1.37419 -0.89433 -0.89 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-16 1. 0. 0. 55 55 9 56 56 # terminating special property … … 59 59 25.0 0.6 -1.0 -1.0 -1.0 0.2 0 0 0 0 60 60 2 61 -1.00456 0.23922 0.5933335 1 0 061 1.67084 -0.47478 -8.88178e-16 5 1 0 0 62 62 9 63 63 terminating special property -
tests/regression/Tesselation/2/post/ConvexEnvelope.dat
r491876 rc695c9 1 1 TITLE = "3D CONVEX SHELL" 2 2 VARIABLES = "X" "Y" "Z" "U" 3 ZONE T=" 0- H08_ H09_ H11", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE3 ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 4 9.78209 2.64589 2.64589 0 5 5 9.78209 2.64589 4.42589 0 … … 13 13 1 3 4 14 14 1 4 7 15 4 6 7 15 16 3 4 5 16 1 7 8 17 1 2 8 18 4 6 7 17 4 5 6 19 18 2 3 5 20 4 5 621 6 7 822 1 2 323 19 2 5 8 24 20 5 6 8 21 6 7 8 22 2 7 8 23 1 2 7 24 1 2 3 -
tests/regression/Tesselation/2/post/ConvexEnvelope.r3d
r491876 rc695c9 34 34 1.37419 -0.89433 -0.89 0.12489 1.24767 -0.89 -1.12431 -0.89433 -0.89 1. 0. 0. 35 35 1 36 2.26414 0.364321 -4.44089e-16 0.12489 1.24767 -0.89 0.12489 1.24767 0.89 1. 0. 0.37 138 1.37419 -0.89433 -0.89 -1.12431 -0.89433 -0.89 -1.12431 -0.89433 0.89 1. 0. 0.39 140 1.37419 -0.89433 -0.89 1.37419 -0.89433 0.89 -1.12431 -0.89433 0.89 1. 0. 0.41 142 36 0.12489 1.24767 -0.89 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.89433 -0.89 1. 0. 0. 43 37 1 44 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-160.12489 1.24767 0.89 1. 0. 0.38 2.26414 0.364321 -4.44089e-16 0.12489 1.24767 -0.89 0.12489 1.24767 0.89 1. 0. 0. 45 39 1 46 40 0.12489 1.24767 -0.89 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-16 1. 0. 0. 47 41 1 48 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.89433 -0.89 -1.12431 -0.89433 0.89 1. 0. 0. 49 1 50 1.37419 -0.89433 -0.89 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-16 1. 0. 0. 42 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-16 0.12489 1.24767 0.89 1. 0. 0. 51 43 1 52 44 1.37419 -0.89433 0.89 0.12489 1.24767 0.89 -1.12431 -0.89433 0.89 1. 0. 0. 53 45 1 54 46 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.89433 0.89 1. 0. 0. 47 1 48 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.89433 -0.89 -1.12431 -0.89433 0.89 1. 0. 0. 49 1 50 1.37419 -0.89433 0.89 -1.12431 -0.89433 -0.89 -1.12431 -0.89433 0.89 1. 0. 0. 51 1 52 1.37419 -0.89433 -0.89 1.37419 -0.89433 0.89 -1.12431 -0.89433 -0.89 1. 0. 0. 53 1 54 1.37419 -0.89433 -0.89 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-16 1. 0. 0. 55 55 9 56 56 # terminating special property … … 59 59 25.0 0.6 -1.0 -1.0 -1.0 0.2 0 0 0 0 60 60 2 61 -1.00456 0.23922 0.5933335 1 0 061 1.67084 -0.47478 -8.88178e-16 5 1 0 0 62 62 9 63 63 terminating special property -
tests/regression/Tesselation/2/post/NonConvexEnvelope.dat
r491876 rc695c9 1 1 TITLE = "3D CONVEX SHELL" 2 2 VARIABLES = "X" "Y" "Z" "U" 3 ZONE T=" 0- H08_ H09_ H11", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE3 ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 4 9.78209 2.64589 2.64589 0 5 5 9.78209 2.64589 4.42589 0 … … 13 13 1 3 4 14 14 1 4 7 15 4 6 7 15 16 3 4 5 16 1 7 8 17 1 2 8 18 4 6 7 17 4 5 6 19 18 2 3 5 20 4 5 621 6 7 822 1 2 323 19 2 5 8 24 20 5 6 8 21 6 7 8 22 2 7 8 23 1 2 7 24 1 2 3 -
tests/regression/Tesselation/2/post/NonConvexEnvelope.r3d
r491876 rc695c9 34 34 1.37419 -0.89433 -0.89 0.12489 1.24767 -0.89 -1.12431 -0.89433 -0.89 1. 0. 0. 35 35 1 36 2.26414 0.364321 -4.44089e-16 0.12489 1.24767 -0.89 0.12489 1.24767 0.89 1. 0. 0.37 138 1.37419 -0.89433 -0.89 -1.12431 -0.89433 -0.89 -1.12431 -0.89433 0.89 1. 0. 0.39 140 1.37419 -0.89433 -0.89 1.37419 -0.89433 0.89 -1.12431 -0.89433 0.89 1. 0. 0.41 142 36 0.12489 1.24767 -0.89 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.89433 -0.89 1. 0. 0. 43 37 1 44 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-160.12489 1.24767 0.89 1. 0. 0.38 2.26414 0.364321 -4.44089e-16 0.12489 1.24767 -0.89 0.12489 1.24767 0.89 1. 0. 0. 45 39 1 46 40 0.12489 1.24767 -0.89 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-16 1. 0. 0. 47 41 1 48 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.89433 -0.89 -1.12431 -0.89433 0.89 1. 0. 0. 49 1 50 1.37419 -0.89433 -0.89 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-16 1. 0. 0. 42 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-16 0.12489 1.24767 0.89 1. 0. 0. 51 43 1 52 44 1.37419 -0.89433 0.89 0.12489 1.24767 0.89 -1.12431 -0.89433 0.89 1. 0. 0. 53 45 1 54 46 0.12489 1.24767 0.89 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.89433 0.89 1. 0. 0. 47 1 48 -2.01426 0.364321 -4.44089e-16 -1.12431 -0.89433 -0.89 -1.12431 -0.89433 0.89 1. 0. 0. 49 1 50 1.37419 -0.89433 0.89 -1.12431 -0.89433 -0.89 -1.12431 -0.89433 0.89 1. 0. 0. 51 1 52 1.37419 -0.89433 -0.89 1.37419 -0.89433 0.89 -1.12431 -0.89433 -0.89 1. 0. 0. 53 1 54 1.37419 -0.89433 -0.89 1.37419 -0.89433 0.89 2.26414 0.364321 -4.44089e-16 1. 0. 0. 55 55 9 56 56 # terminating special property … … 59 59 25.0 0.6 -1.0 -1.0 -1.0 0.2 0 0 0 0 60 60 2 61 -1.00456 0.23922 0.5933335 1 0 061 1.67084 -0.47478 -8.88178e-16 5 1 0 0 62 62 9 63 63 terminating special property -
tests/regression/Tesselation/3/post/NonConvexEnvelope.dat
r491876 rc695c9 1 1 TITLE = "3D CONVEX SHELL" 2 2 VARIABLES = "X" "Y" "Z" "U" 3 ZONE T=" 0- H49_ H50_ H51", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE3 ZONE T="test", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE 4 4 6.9077 1.1106 0.1214 1 5 5 0.3612 -3.628 1.323 1 … … 28 28 2.8131 1.4776 2.5103 0 29 29 3.9137 2.2936 1.3739 0 30 2.159 2.5738 1.2698 230 2.159 2.5738 1.2698 5 31 31 3.6606 -0.4593 2.1396 2 32 32 3.2007 -1.4419 0.7311 4 33 -3.3002 2.3589 0.0094 533 -3.3002 2.3589 0.0094 8 34 34 -4.377 1.6962 -1.2433 3 35 35 5.2593 1.4547 -1.7445 0 … … 40 40 5.2727 1.6068 1.2828 2 41 41 -6.2394 4.6427 0.0632 0 42 -4.4738 4.5591 -0.1458 142 -4.4738 4.5591 -0.1458 3 43 43 -5.5506 3.8964 -1.3985 0 44 44 -6.7081 0.9923 0.6224 2 … … 49 49 1 32 44 50 50 1 32 35 51 32 33 4452 51 1 34 35 53 52 23 32 35 54 23 32 33 53 17 23 35 54 8 17 35 55 8 10 17 56 3 8 10 57 3 8 35 58 3 4 35 59 4 29 35 60 29 34 35 61 2 3 4 62 2 4 29 63 2 15 29 64 15 28 29 65 28 29 34 66 2 7 15 67 7 14 15 68 14 15 28 69 14 25 28 70 25 28 37 71 28 34 37 72 1 34 37 73 1 37 44 74 25 26 37 75 25 26 27 76 26 27 33 55 77 26 33 44 56 1 34 37 57 29 34 35 58 17 23 35 78 26 37 44 79 14 25 27 80 14 27 30 81 6 14 30 82 6 24 30 83 24 30 36 84 30 36 39 85 27 30 39 86 27 30 39 87 16 27 30 88 16 18 30 89 16 18 27 90 18 27 33 59 91 18 23 33 60 26 27 33 61 26 37 44 62 1 37 44 63 28 34 37 64 28 29 34 65 4 29 35 66 17 18 23 67 8 17 35 68 18 27 33 69 25 26 27 70 25 26 37 71 25 28 37 72 15 28 29 73 2 4 29 74 3 4 35 75 9 17 18 76 8 10 17 77 3 8 35 78 16 18 27 79 14 25 27 80 14 25 28 81 14 15 28 82 2 15 29 83 2 3 4 84 9 10 17 85 9 18 31 86 3 8 10 87 16 18 30 88 16 27 30 89 14 27 30 90 7 14 15 91 2 7 15 92 2 3 5 93 9 10 12 94 9 19 31 95 18 30 31 96 3 10 12 97 6 14 30 92 6 7 24 98 93 6 7 14 99 2 5 7100 3 5 12101 9 12 13102 9 13 19103 13 19 31104 30 31 39105 6 24 30106 6 7 24107 5 7 11108 5 12 22109 12 13 21110 13 21 31111 27 30 39112 31 39 40113 24 30 36114 94 7 11 24 115 5 11 22 116 12 21 22 117 21 31 43 118 31 40 43 119 40 42 43 120 41 42 43 121 21 41 43 122 20 21 41 95 11 20 24 123 96 20 24 41 124 97 24 36 41 125 98 36 41 42 99 11 20 22 100 5 11 22 101 5 7 11 102 2 5 7 103 36 38 39 126 104 36 38 42 105 18 30 31 106 30 31 39 107 31 39 40 108 9 18 31 109 9 17 18 110 17 18 23 111 9 19 31 112 9 13 19 113 13 19 31 114 13 21 31 115 21 31 43 116 31 40 43 117 9 12 13 118 9 10 12 119 9 10 17 120 12 13 21 121 12 21 22 122 5 12 22 123 3 5 12 124 2 3 5 125 3 10 12 126 20 21 22 127 20 21 41 128 21 41 43 129 41 42 43 130 23 32 33 131 32 33 44 132 40 42 43 127 133 38 40 42 128 134 38 39 40 129 36 38 39130 30 36 39131 27 30 39132 11 20 24133 11 20 22134 20 21 22 -
tests/regression/Tesselation/3/post/NonConvexEnvelope.r3d
r491876 rc695c9 160 160 7.33693 1.04442 0.0886712 5.68853 1.38852 -1.77723 5.55043 -0.952879 -0.490929 1. 0. 0. 161 161 1 162 7.33693 1.04442 0.0886712 6.17523 -0.969279 1.17127 5.55043 -0.952879 -0.490929 1. 0. 0. 163 1 164 3.62023 1.25552 -2.86813 5.68853 1.38852 -1.77723 5.55043 -0.952879 -0.490929 1. 0. 0. 165 1 166 1.76663 -0.360379 -2.99373 3.62023 1.25552 -2.86813 5.55043 -0.952879 -0.490929 1. 0. 0. 167 1 168 2.19193 -1.51408 -0.867629 1.76663 -0.360379 -2.99373 5.55043 -0.952879 -0.490929 1. 0. 0. 169 1 170 2.19193 -1.51408 -0.867629 0.450934 -2.72908 -2.23353 1.76663 -0.360379 -2.99373 1. 0. 0. 171 1 172 0.917634 -3.66448 -0.484829 2.19193 -1.51408 -0.867629 0.450934 -2.72908 -2.23353 1. 0. 0. 173 1 174 0.917634 -3.66448 -0.484829 2.19193 -1.51408 -0.867629 5.55043 -0.952879 -0.490929 1. 0. 0. 175 1 176 0.917634 -3.66448 -0.484829 1.92773 -2.57738 0.498071 5.55043 -0.952879 -0.490929 1. 0. 0. 177 1 178 1.92773 -2.57738 0.498071 3.62993 -1.50808 0.698371 5.55043 -0.952879 -0.490929 1. 0. 0. 179 1 180 3.62993 -1.50808 0.698371 6.17523 -0.969279 1.17127 5.55043 -0.952879 -0.490929 1. 0. 0. 181 1 182 0.790434 -3.69418 1.29027 0.917634 -3.66448 -0.484829 1.92773 -2.57738 0.498071 1. 0. 0. 183 1 184 0.790434 -3.69418 1.29027 1.92773 -2.57738 0.498071 3.62993 -1.50808 0.698371 1. 0. 0. 185 1 186 0.790434 -3.69418 1.29027 2.06173 -1.39848 1.79787 3.62993 -1.50808 0.698371 1. 0. 0. 187 1 188 2.06173 -1.39848 1.79787 4.08983 -0.525479 2.10687 3.62993 -1.50808 0.698371 1. 0. 0. 189 1 190 4.08983 -0.525479 2.10687 3.62993 -1.50808 0.698371 6.17523 -0.969279 1.17127 1. 0. 0. 191 1 192 0.790434 -3.69418 1.29027 -0.287266 -1.67078 2.48017 2.06173 -1.39848 1.79787 1. 0. 0. 193 1 194 -0.287266 -1.67078 2.48017 1.46453 0.112321 2.50927 2.06173 -1.39848 1.79787 1. 0. 0. 195 1 196 1.46453 0.112321 2.50927 2.06173 -1.39848 1.79787 4.08983 -0.525479 2.10687 1. 0. 0. 197 1 198 1.46453 0.112321 2.50927 3.24233 1.41142 2.47757 4.08983 -0.525479 2.10687 1. 0. 0. 199 1 200 3.24233 1.41142 2.47757 4.08983 -0.525479 2.10687 5.70193 1.54062 1.25007 1. 0. 0. 201 1 202 4.08983 -0.525479 2.10687 6.17523 -0.969279 1.17127 5.70193 1.54062 1.25007 1. 0. 0. 203 1 204 7.33693 1.04442 0.0886712 6.17523 -0.969279 1.17127 5.70193 1.54062 1.25007 1. 0. 0. 205 1 206 7.33693 1.04442 0.0886712 5.70193 1.54062 1.25007 7.56833 1.97852 -0.00632877 1. 0. 0. 207 1 208 3.24233 1.41142 2.47757 4.34293 2.22742 1.34117 5.70193 1.54062 1.25007 1. 0. 0. 209 1 210 3.24233 1.41142 2.47757 4.34293 2.22742 1.34117 2.58823 2.50762 1.23707 1. 0. 0. 211 1 212 4.34293 2.22742 1.34117 2.58823 2.50762 1.23707 5.11553 2.70122 -0.710229 1. 0. 0. 213 1 214 4.34293 2.22742 1.34117 5.11553 2.70122 -0.710229 7.56833 1.97852 -0.00632877 1. 0. 0. 215 1 216 4.34293 2.22742 1.34117 5.70193 1.54062 1.25007 7.56833 1.97852 -0.00632877 1. 0. 0. 217 1 218 1.46453 0.112321 2.50927 3.24233 1.41142 2.47757 2.58823 2.50762 1.23707 1. 0. 0. 219 1 220 1.46453 0.112321 2.50927 2.58823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 1. 0. 0. 221 1 222 -0.759066 -0.265179 1.48487 1.46453 0.112321 2.50927 -2.87097 2.29272 -0.0233288 1. 0. 0. 223 1 224 -0.759066 -0.265179 1.48487 -3.66127 0.565021 1.57007 -2.87097 2.29272 -0.0233288 1. 0. 0. 225 1 226 -3.66127 0.565021 1.57007 -2.87097 2.29272 -0.0233288 -4.83487 2.76522 1.41487 1. 0. 0. 227 1 228 -2.87097 2.29272 -0.0233288 -4.83487 2.76522 1.41487 -4.04457 4.49292 -0.178529 1. 0. 0. 229 1 230 2.58823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 -4.04457 4.49292 -0.178529 1. 0. 0. 231 1 232 2.58823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 -4.04457 4.49292 -0.178529 1. 0. 0. 233 1 234 1.15633 1.11082 0.326671 2.58823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 1. 0. 0. 235 1 236 1.15633 1.11082 0.326671 1.03283 1.01972 -2.14533 -2.87097 2.29272 -0.0233288 1. 0. 0. 237 1 238 1.15633 1.11082 0.326671 1.03283 1.01972 -2.14533 2.58823 2.50762 1.23707 1. 0. 0. 239 1 240 1.03283 1.01972 -2.14533 2.58823 2.50762 1.23707 5.11553 2.70122 -0.710229 1. 0. 0. 241 1 242 1.03283 1.01972 -2.14533 3.62023 1.25552 -2.86813 5.11553 2.70122 -0.710229 1. 0. 0. 243 1 244 -0.759066 -0.265179 1.48487 -0.287266 -1.67078 2.48017 -3.66127 0.565021 1.57007 1. 0. 0. 245 1 246 -0.759066 -0.265179 1.48487 -0.287266 -1.67078 2.48017 1.46453 0.112321 2.50927 1. 0. 0. 247 1 248 -0.287266 -1.67078 2.48017 -2.45927 -1.63678 1.72157 -3.66127 0.565021 1.57007 1. 0. 0. 249 1 250 -2.45927 -1.63678 1.72157 -4.75167 -1.93408 0.935971 -3.66127 0.565021 1.57007 1. 0. 0. 251 1 252 -4.75167 -1.93408 0.935971 -3.66127 0.565021 1.57007 -6.27887 0.926121 0.589671 1. 0. 0. 253 1 254 -3.66127 0.565021 1.57007 -4.83487 2.76522 1.41487 -6.27887 0.926121 0.589671 1. 0. 0. 255 1 256 -4.83487 2.76522 1.41487 -6.27887 0.926121 0.589671 -7.11497 2.49352 0.479071 1. 0. 0. 257 1 258 -2.45927 -1.63678 1.72157 -4.75167 -1.93408 0.935971 -3.90927 -3.49908 0.839771 1. 0. 0. 259 1 260 -1.52417 -3.64138 0.503471 -2.45927 -1.63678 1.72157 -3.90927 -3.49908 0.839771 1. 0. 0. 261 1 262 -1.52417 -3.64138 0.503471 -0.287266 -1.67078 2.48017 -2.45927 -1.63678 1.72157 1. 0. 0. 263 1 264 0.790434 -3.69418 1.29027 -1.52417 -3.64138 0.503471 -0.287266 -1.67078 2.48017 1. 0. 0. 265 1 266 -4.83487 2.76522 1.41487 -5.81017 4.57652 0.0304712 -4.04457 4.49292 -0.178529 1. 0. 0. 267 1 268 -4.83487 2.76522 1.41487 -5.81017 4.57652 0.0304712 -7.11497 2.49352 0.479071 1. 0. 0. 269 1 270 1.03283 1.01972 -2.14533 -2.87097 2.29272 -0.0233288 -3.94777 1.63002 -1.27603 1. 0. 0. 271 1 272 -2.87097 2.29272 -0.0233288 -3.94777 1.63002 -1.27603 -4.04457 4.49292 -0.178529 1. 0. 0. 273 1 274 -3.94777 1.63002 -1.27603 -4.04457 4.49292 -0.178529 -5.12137 3.83022 -1.43123 1. 0. 0. 275 1 276 -0.573766 -1.42458 -2.91753 1.03283 1.01972 -2.14533 -3.94777 1.63002 -1.27603 1. 0. 0. 277 1 278 -0.573766 -1.42458 -2.91753 1.76663 -0.360379 -2.99373 1.03283 1.01972 -2.14533 1. 0. 0. 279 1 280 1.76663 -0.360379 -2.99373 1.03283 1.01972 -2.14533 3.62023 1.25552 -2.86813 1. 0. 0. 281 1 282 -0.573766 -1.42458 -2.91753 -2.77417 -0.570279 -1.12083 -3.94777 1.63002 -1.27603 1. 0. 0. 283 1 284 -0.573766 -1.42458 -2.91753 -2.49667 -2.18078 -1.79993 -2.77417 -0.570279 -1.12083 1. 0. 0. 285 1 286 -2.49667 -2.18078 -1.79993 -2.77417 -0.570279 -1.12083 -3.94777 1.63002 -1.27603 1. 0. 0. 287 1 288 -2.49667 -2.18078 -1.79993 -4.17327 -2.53828 -0.635229 -3.94777 1.63002 -1.27603 1. 0. 0. 289 1 290 -4.17327 -2.53828 -0.635229 -3.94777 1.63002 -1.27603 -6.42617 1.74722 -0.982629 1. 0. 0. 291 1 292 -3.94777 1.63002 -1.27603 -5.12137 3.83022 -1.43123 -6.42617 1.74722 -0.982629 1. 0. 0. 293 1 294 -0.573766 -1.42458 -2.91753 -1.62867 -3.74268 -1.79493 -2.49667 -2.18078 -1.79993 1. 0. 0. 295 1 296 -0.573766 -1.42458 -2.91753 0.450934 -2.72908 -2.23353 -1.62867 -3.74268 -1.79493 1. 0. 0. 297 1 298 -0.573766 -1.42458 -2.91753 0.450934 -2.72908 -2.23353 1.76663 -0.360379 -2.99373 1. 0. 0. 299 1 300 -1.62867 -3.74268 -1.79493 -2.49667 -2.18078 -1.79993 -4.17327 -2.53828 -0.635229 1. 0. 0. 301 1 302 -1.62867 -3.74268 -1.79493 -4.17327 -2.53828 -0.635229 -3.90927 -3.49908 0.839771 1. 0. 0. 303 1 304 -1.52417 -3.64138 0.503471 -1.62867 -3.74268 -1.79493 -3.90927 -3.49908 0.839771 1. 0. 0. 305 1 306 0.917634 -3.66448 -0.484829 -1.52417 -3.64138 0.503471 -1.62867 -3.74268 -1.79493 1. 0. 0. 307 1 308 0.790434 -3.69418 1.29027 0.917634 -3.66448 -0.484829 -1.52417 -3.64138 0.503471 1. 0. 0. 309 1 310 0.917634 -3.66448 -0.484829 0.450934 -2.72908 -2.23353 -1.62867 -3.74268 -1.79493 1. 0. 0. 311 1 312 -4.75167 -1.93408 0.935971 -4.17327 -2.53828 -0.635229 -3.90927 -3.49908 0.839771 1. 0. 0. 313 1 314 -4.75167 -1.93408 0.935971 -4.17327 -2.53828 -0.635229 -6.27887 0.926121 0.589671 1. 0. 0. 315 1 316 -4.17327 -2.53828 -0.635229 -6.27887 0.926121 0.589671 -6.42617 1.74722 -0.982629 1. 0. 0. 317 1 318 -6.27887 0.926121 0.589671 -7.11497 2.49352 0.479071 -6.42617 1.74722 -0.982629 1. 0. 0. 319 1 320 3.62023 1.25552 -2.86813 5.68853 1.38852 -1.77723 5.11553 2.70122 -0.710229 1. 0. 0. 321 1 162 322 5.68853 1.38852 -1.77723 5.11553 2.70122 -0.710229 7.56833 1.97852 -0.00632877 1. 0. 0. 163 323 1 164 7.33693 1.04442 0.0886712 6.17523 -0.969279 1.17127 5.55043 -0.952879 -0.490929 1. 0. 0.165 1166 3.62023 1.25552 -2.86813 5.68853 1.38852 -1.77723 5.55043 -0.952879 -0.490929 1. 0. 0.167 1168 3.62023 1.25552 -2.86813 5.68853 1.38852 -1.77723 5.11553 2.70122 -0.710229 1. 0. 0.169 1170 4.34293 2.22742 1.34117 5.11553 2.70122 -0.710229 7.56833 1.97852 -0.00632877 1. 0. 0.171 1172 7.33693 1.04442 0.0886712 6.17523 -0.969279 1.17127 5.70193 1.54062 1.25007 1. 0. 0.173 1174 3.62993 -1.50808 0.698371 6.17523 -0.969279 1.17127 5.55043 -0.952879 -0.490929 1. 0. 0.175 1176 1.76663 -0.360379 -2.99373 3.62023 1.25552 -2.86813 5.55043 -0.952879 -0.490929 1. 0. 0.177 1178 1.03283 1.01972 -2.14533 3.62023 1.25552 -2.86813 5.11553 2.70122 -0.710229 1. 0. 0.179 1180 4.34293 2.22742 1.34117 2.58823 2.50762 1.23707 5.11553 2.70122 -0.710229 1. 0. 0.181 1182 4.34293 2.22742 1.34117 5.70193 1.54062 1.25007 7.56833 1.97852 -0.00632877 1. 0. 0.183 1184 7.33693 1.04442 0.0886712 5.70193 1.54062 1.25007 7.56833 1.97852 -0.00632877 1. 0. 0.185 1186 4.08983 -0.525479 2.10687 6.17523 -0.969279 1.17127 5.70193 1.54062 1.25007 1. 0. 0.187 1188 4.08983 -0.525479 2.10687 3.62993 -1.50808 0.698371 6.17523 -0.969279 1.17127 1. 0. 0.189 1190 1.92773 -2.57738 0.498071 3.62993 -1.50808 0.698371 5.55043 -0.952879 -0.490929 1. 0. 0.191 1192 1.76663 -0.360379 -2.99373 1.03283 1.01972 -2.14533 3.62023 1.25552 -2.86813 1. 0. 0.193 1194 2.19193 -1.51408 -0.867629 1.76663 -0.360379 -2.99373 5.55043 -0.952879 -0.490929 1. 0. 0.195 1196 1.03283 1.01972 -2.14533 2.58823 2.50762 1.23707 5.11553 2.70122 -0.710229 1. 0. 0.197 1198 3.24233 1.41142 2.47757 4.34293 2.22742 1.34117 2.58823 2.50762 1.23707 1. 0. 0.199 1200 3.24233 1.41142 2.47757 4.34293 2.22742 1.34117 5.70193 1.54062 1.25007 1. 0. 0.201 1202 3.24233 1.41142 2.47757 4.08983 -0.525479 2.10687 5.70193 1.54062 1.25007 1. 0. 0.203 1204 2.06173 -1.39848 1.79787 4.08983 -0.525479 2.10687 3.62993 -1.50808 0.698371 1. 0. 0.205 1206 0.790434 -3.69418 1.29027 1.92773 -2.57738 0.498071 3.62993 -1.50808 0.698371 1. 0. 0.207 1208 0.917634 -3.66448 -0.484829 1.92773 -2.57738 0.498071 5.55043 -0.952879 -0.490929 1. 0. 0.209 1210 -0.573766 -1.42458 -2.91753 1.76663 -0.360379 -2.99373 1.03283 1.01972 -2.14533 1. 0. 0.211 1212 2.19193 -1.51408 -0.867629 0.450934 -2.72908 -2.23353 1.76663 -0.360379 -2.99373 1. 0. 0.213 1214 0.917634 -3.66448 -0.484829 2.19193 -1.51408 -0.867629 5.55043 -0.952879 -0.490929 1. 0. 0.215 1216 1.15633 1.11082 0.326671 1.03283 1.01972 -2.14533 2.58823 2.50762 1.23707 1. 0. 0.217 1218 1.46453 0.112321 2.50927 3.24233 1.41142 2.47757 2.58823 2.50762 1.23707 1. 0. 0.219 1220 1.46453 0.112321 2.50927 3.24233 1.41142 2.47757 4.08983 -0.525479 2.10687 1. 0. 0.221 1222 1.46453 0.112321 2.50927 2.06173 -1.39848 1.79787 4.08983 -0.525479 2.10687 1. 0. 0.223 1224 0.790434 -3.69418 1.29027 2.06173 -1.39848 1.79787 3.62993 -1.50808 0.698371 1. 0. 0.225 1226 0.790434 -3.69418 1.29027 0.917634 -3.66448 -0.484829 1.92773 -2.57738 0.498071 1. 0. 0.227 1228 -0.573766 -1.42458 -2.91753 0.450934 -2.72908 -2.23353 1.76663 -0.360379 -2.99373 1. 0. 0.229 1230 -0.573766 -1.42458 -2.91753 1.03283 1.01972 -2.14533 -3.94777 1.63002 -1.27603 1. 0. 0.231 1232 0.917634 -3.66448 -0.484829 2.19193 -1.51408 -0.867629 0.450934 -2.72908 -2.23353 1. 0. 0.233 1234 1.15633 1.11082 0.326671 1.03283 1.01972 -2.14533 -2.87097 2.29272 -0.0233288 1. 0. 0.235 1236 1.15633 1.11082 0.326671 2.58823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 1. 0. 0.237 1238 1.46453 0.112321 2.50927 2.58823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 1. 0. 0.239 1240 -0.287266 -1.67078 2.48017 1.46453 0.112321 2.50927 2.06173 -1.39848 1.79787 1. 0. 0.241 1242 0.790434 -3.69418 1.29027 -0.287266 -1.67078 2.48017 2.06173 -1.39848 1.79787 1. 0. 0.243 1244 0.790434 -3.69418 1.29027 0.917634 -3.66448 -0.484829 -1.52417 -3.64138 0.503471 1. 0. 0.245 1246 -0.573766 -1.42458 -2.91753 0.450934 -2.72908 -2.23353 -1.62867 -3.74268 -1.79493 1. 0. 0.247 1248 -0.573766 -1.42458 -2.91753 -2.77417 -0.570279 -1.12083 -3.94777 1.63002 -1.27603 1. 0. 0.249 1250 1.03283 1.01972 -2.14533 -2.87097 2.29272 -0.0233288 -3.94777 1.63002 -1.27603 1. 0. 0.251 1252 0.917634 -3.66448 -0.484829 0.450934 -2.72908 -2.23353 -1.62867 -3.74268 -1.79493 1. 0. 0.253 1254 -0.759066 -0.265179 1.48487 1.46453 0.112321 2.50927 -2.87097 2.29272 -0.0233288 1. 0. 0.255 1256 -0.759066 -0.265179 1.48487 -0.287266 -1.67078 2.48017 1.46453 0.112321 2.50927 1. 0. 0.257 1258 0.790434 -3.69418 1.29027 -1.52417 -3.64138 0.503471 -0.287266 -1.67078 2.48017 1. 0. 0.259 1260 0.917634 -3.66448 -0.484829 -1.52417 -3.64138 0.503471 -1.62867 -3.74268 -1.79493 1. 0. 0.261 1262 -0.573766 -1.42458 -2.91753 -1.62867 -3.74268 -1.79493 -2.49667 -2.18078 -1.79993 1. 0. 0.263 1264 -0.573766 -1.42458 -2.91753 -2.49667 -2.18078 -1.79993 -2.77417 -0.570279 -1.12083 1. 0. 0.265 1266 -2.49667 -2.18078 -1.79993 -2.77417 -0.570279 -1.12083 -3.94777 1.63002 -1.27603 1. 0. 0.267 1268 -2.87097 2.29272 -0.0233288 -3.94777 1.63002 -1.27603 -4.04457 4.49292 -0.178529 1. 0. 0.269 1270 -0.759066 -0.265179 1.48487 -3.66127 0.565021 1.57007 -2.87097 2.29272 -0.0233288 1. 0. 0.271 1272 -0.759066 -0.265179 1.48487 -0.287266 -1.67078 2.48017 -3.66127 0.565021 1.57007 1. 0. 0.273 1274 -1.52417 -3.64138 0.503471 -0.287266 -1.67078 2.48017 -2.45927 -1.63678 1.72157 1. 0. 0.275 1276 -1.52417 -3.64138 0.503471 -1.62867 -3.74268 -1.79493 -3.90927 -3.49908 0.839771 1. 0. 0.277 1278 -1.62867 -3.74268 -1.79493 -2.49667 -2.18078 -1.79993 -4.17327 -2.53828 -0.635229 1. 0. 0.279 1280 -2.49667 -2.18078 -1.79993 -4.17327 -2.53828 -0.635229 -3.94777 1.63002 -1.27603 1. 0. 0.281 1282 2.58823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 -4.04457 4.49292 -0.178529 1. 0. 0.283 1284 -3.94777 1.63002 -1.27603 -4.04457 4.49292 -0.178529 -5.12137 3.83022 -1.43123 1. 0. 0.285 1286 -3.66127 0.565021 1.57007 -2.87097 2.29272 -0.0233288 -4.83487 2.76522 1.41487 1. 0. 0.287 1288 -0.287266 -1.67078 2.48017 -2.45927 -1.63678 1.72157 -3.66127 0.565021 1.57007 1. 0. 0.289 1290 -1.52417 -3.64138 0.503471 -2.45927 -1.63678 1.72157 -3.90927 -3.49908 0.839771 1. 0. 0.291 1292 -1.62867 -3.74268 -1.79493 -4.17327 -2.53828 -0.635229 -3.90927 -3.49908 0.839771 1. 0. 0.293 1294 -4.17327 -2.53828 -0.635229 -3.94777 1.63002 -1.27603 -6.42617 1.74722 -0.982629 1. 0. 0.295 1296 -3.94777 1.63002 -1.27603 -5.12137 3.83022 -1.43123 -6.42617 1.74722 -0.982629 1. 0. 0.297 1298 324 -5.12137 3.83022 -1.43123 -7.11497 2.49352 0.479071 -6.42617 1.74722 -0.982629 1. 0. 0. 299 325 1 300 -6.27887 0.926121 0.589671 -7.11497 2.49352 0.479071 -6.42617 1.74722 -0.982629 1. 0. 0.301 1302 -4.17327 -2.53828 -0.635229 -6.27887 0.926121 0.589671 -6.42617 1.74722 -0.982629 1. 0. 0.303 1304 -4.75167 -1.93408 0.935971 -4.17327 -2.53828 -0.635229 -6.27887 0.926121 0.589671 1. 0. 0.305 1306 -4.75167 -1.93408 0.935971 -3.66127 0.565021 1.57007 -6.27887 0.926121 0.589671 1. 0. 0.307 1308 -3.66127 0.565021 1.57007 -4.83487 2.76522 1.41487 -6.27887 0.926121 0.589671 1. 0. 0.309 1310 -4.83487 2.76522 1.41487 -6.27887 0.926121 0.589671 -7.11497 2.49352 0.479071 1. 0. 0.311 1312 -4.83487 2.76522 1.41487 -5.81017 4.57652 0.0304712 -7.11497 2.49352 0.479071 1. 0. 0.313 1314 326 -5.81017 4.57652 0.0304712 -5.12137 3.83022 -1.43123 -7.11497 2.49352 0.479071 1. 0. 0. 315 327 1 316 328 -5.81017 4.57652 0.0304712 -4.04457 4.49292 -0.178529 -5.12137 3.83022 -1.43123 1. 0. 0. 317 1318 -4.83487 2.76522 1.41487 -5.81017 4.57652 0.0304712 -4.04457 4.49292 -0.178529 1. 0. 0.319 1320 -2.87097 2.29272 -0.0233288 -4.83487 2.76522 1.41487 -4.04457 4.49292 -0.178529 1. 0. 0.321 1322 2.58823 2.50762 1.23707 -2.87097 2.29272 -0.0233288 -4.04457 4.49292 -0.178529 1. 0. 0.323 1324 -2.45927 -1.63678 1.72157 -4.75167 -1.93408 0.935971 -3.66127 0.565021 1.57007 1. 0. 0.325 1326 -2.45927 -1.63678 1.72157 -4.75167 -1.93408 0.935971 -3.90927 -3.49908 0.839771 1. 0. 0.327 1328 -4.75167 -1.93408 0.935971 -4.17327 -2.53828 -0.635229 -3.90927 -3.49908 0.839771 1. 0. 0.329 329 9 330 330 # terminating special property … … 333 333 25.0 0.6 -1.0 -1.0 -1.0 0.2 0 0 0 0 334 334 2 335 -4. 27807 -2.65715 0.3801715 1 0 0335 -4.99203 4.29989 -0.526429 5 1 0 0 336 336 9 337 337 terminating special property -
tests/testsuite.at
r491876 rc695c9 12 12 AT_CHECK([pwd],[ignore],[ignore]) 13 13 AT_CHECK([../../molecuilder -v], 0, [stdout], [ignore]) 14 AT_CHECK([fgrep molecuilder stdout], 0, [ignore], [ignore])14 AT_CHECK([fgrep olecuilder stdout], 0, [ignore], [ignore]) 15 15 AT_CHECK([../../molecuilder -h], 0, [stdout], [ignore]) 16 16 AT_CHECK([fgrep "Give this help screen" stdout], 0, [ignore], [ignore]) 17 AT_CHECK([../../molecuilder -e], 0, [ignore], [stderr])17 AT_CHECK([../../molecuilder -e], 255, [ignore], [stderr]) 18 18 AT_CHECK([fgrep "Not enough or invalid arguments" stderr], 0, [ignore], [ignore]) 19 19 AT_CHECK([../../molecuilder test.conf], 0, [stdout], [stderr]) … … 78 78 AT_SETUP([Simple configuration - invalid commands on present configs]) 79 79 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/regression/Simple_configuration/7/pre/test.conf .], 0) 80 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -t -s -b -E -c -b -a -U -T -u], 255, [ignore], [stderr]) 81 AT_CHECK([fgrep -c "Not enough or invalid" stderr], 0, [9 82 ], [ignore]) 80 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -t], 255, [ignore], [stderr]) 81 AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore]) 82 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -s -b -E -c -b -a -U -T -u], 255, [ignore], [stderr]) 83 AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore]) 84 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -b -E -c -b -a -U -T -u], 255, [ignore], [stderr]) 85 AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore]) 86 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -E -c -b -a -U -T -u], 255, [ignore], [stderr]) 87 AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore]) 88 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -c -b -a -U -T -u], 255, [ignore], [stderr]) 89 AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore]) 90 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -b -a -U -T -u], 255, [ignore], [stderr]) 91 AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore]) 92 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -a -U -T -u], 255, [ignore], [stderr]) 93 AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore]) 94 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -U -T -u], 255, [ignore], [stderr]) 95 AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore]) 96 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -T -u], 255, [ignore], [stderr]) 97 AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore]) 98 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -u], 255, [ignore], [stderr]) 99 AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore]) 83 100 AT_CLEANUP 84 101 … … 88 105 AT_SETUP([Graph - DFS analysis]) 89 106 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/regression/Graph/1/pre/test.conf .], 0) 90 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ - D 2.], 0, [stdout], [stderr])107 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -vvv -D 2.], 0, [stdout], [stderr]) 91 108 AT_CHECK([fgrep -c "No rings were detected in the molecular structure." stdout], 0, [1 92 109 ], [ignore]) … … 134 151 AT_CHECK([file=ConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/regression/Tesselation/2/post/$file], 0, [ignore], [ignore]) 135 152 AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/regression/Tesselation/2/post/$file], 0, [ignore], [ignore]) 136 AT_CHECK([fgrep " RESULT: The summed volume is 16.401577angstrom^3" stdout], 0, [ignore], [ignore])153 AT_CHECK([fgrep "tesselated volume area is 16.4016 angstrom^3" stdout], 0, [ignore], [ignore]) 137 154 AT_CHECK([diff ConvexEnvelope.dat NonConvexEnvelope.dat], 0, [ignore], [ignore]) 138 155 AT_CLEANUP … … 152 169 #AT_CHECK([file=ConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/regression/Tesselation/4/post/$file], 0, [ignore], [ignore]) 153 170 #AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/regression/Tesselation/4/post/$file], 0, [ignore], [ignore]) 154 #AT_CHECK([fgrep " RESULT: The summed volume is 16.401577angstrom^3" stdout], 0, [ignore], [ignore])171 #AT_CHECK([fgrep "tesselated volume area is 16.4016 angstrom^3" stdout], 0, [ignore], [ignore]) 155 172 #AT_CLEANUP 156 173
Note:
See TracChangeset
for help on using the changeset viewer.