Changes in / [8d6d31:8f4df1]
- Location:
- src
- Files:
-
- 19 added
- 2 deleted
- 80 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/AnalysisAction/MolecularVolumeAction.cpp
r8d6d31 r8f4df1 60 60 LCList = new LinkedCell(mol, 10.); 61 61 config * const configuration = World::getInstance().getConfig(); 62 Boundaries *BoundaryPoints = NULL;63 62 //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]); 64 63 FindNonConvexBorder(mol, TesselStruct, LCList, 5., NULL); -
src/Actions/AnalysisAction/PairCorrelationAction.cpp
r8d6d31 r8f4df1 70 70 double BinStart = 0.; 71 71 double BinWidth = 0.; 72 molecule *Boundary = NULL;73 72 string outputname; 74 73 string binoutputname; -
src/Actions/AnalysisAction/PointCorrelationAction.cpp
r8d6d31 r8f4df1 71 71 double BinStart = 0.; 72 72 double BinWidth = 0.; 73 molecule *Boundary = NULL;74 73 string outputname; 75 74 string binoutputname; -
src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp
r8d6d31 r8f4df1 62 62 // sum up inertia tensor 63 63 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 64 Vector x = (*iter)-> x;64 Vector x = (*iter)->getPosition(); 65 65 x -= *CenterOfGravity; 66 InertiaTensor.at(0,0) += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]); 67 InertiaTensor.at(0,1) += (*iter)->type->mass*(-x[0]*x[1]); 68 InertiaTensor.at(0,2) += (*iter)->type->mass*(-x[0]*x[2]); 69 InertiaTensor.at(1,0) += (*iter)->type->mass*(-x[1]*x[0]); 70 InertiaTensor.at(1,1) += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]); 71 InertiaTensor.at(1,2) += (*iter)->type->mass*(-x[1]*x[2]); 72 InertiaTensor.at(2,0) += (*iter)->type->mass*(-x[2]*x[0]); 73 InertiaTensor.at(2,1) += (*iter)->type->mass*(-x[2]*x[1]); 74 InertiaTensor.at(2,2) += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]); 66 const double mass = (*iter)->getType()->mass; 67 InertiaTensor.at(0,0) += mass*(x[1]*x[1] + x[2]*x[2]); 68 InertiaTensor.at(0,1) += mass*(-x[0]*x[1]); 69 InertiaTensor.at(0,2) += mass*(-x[0]*x[2]); 70 InertiaTensor.at(1,0) += mass*(-x[1]*x[0]); 71 InertiaTensor.at(1,1) += mass*(x[0]*x[0] + x[2]*x[2]); 72 InertiaTensor.at(1,2) += mass*(-x[1]*x[2]); 73 InertiaTensor.at(2,0) += mass*(-x[2]*x[0]); 74 InertiaTensor.at(2,1) += mass*(-x[2]*x[1]); 75 InertiaTensor.at(2,2) += mass*(x[0]*x[0] + x[1]*x[1]); 75 76 } 76 77 // print InertiaTensor for debugging -
src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp
r8d6d31 r8f4df1 111 111 // find biggest molecule 112 112 std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules(); 113 int counter = molecules.size();114 113 LCList = new LinkedCell(Boundary, LCWidth); 115 114 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL); -
src/Actions/AtomAction/AddAction.cpp
r8d6d31 r8f4df1 61 61 // execute action 62 62 atom * first = World::getInstance().createAtom(); 63 first-> type = elemental;64 first-> x = position;65 DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first-> type->name << " at " << (first->x) << "." << endl);63 first->setType(elemental); 64 first->setPosition(position); 65 DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->getType()->name << " at " << (first->getPosition()) << "." << endl); 66 66 // TODO: remove when all of World's atoms are stored. 67 67 std::vector<molecule *> molecules = World::getInstance().getAllMolecules(); -
src/Actions/AtomAction/ChangeElementAction.cpp
r8d6d31 r8f4df1 61 61 mol = first->getMolecule(); 62 62 first->removeFromMolecule(); // remove atom 63 first-> type = elemental;63 first->setType(elemental); 64 64 mol->AddAtom(first); // add atom to ensure correctness of formula 65 65 } -
src/Actions/FragmentationAction/SubgraphDissectionAction.cpp
r8d6d31 r8f4df1 10 10 #include "Actions/FragmentationAction/SubgraphDissectionAction.hpp" 11 11 #include "Actions/ActionRegistry.hpp" 12 #include "Descriptors/MoleculeDescriptor.hpp" 13 12 14 #include "atom.hpp" 15 #include "bond.hpp" 16 #include "bondgraph.hpp" 13 17 #include "config.hpp" 14 18 #include "Helpers/Log.hpp" 15 19 #include "molecule.hpp" 16 #include "Descriptors/MoleculeDescriptor.hpp"17 20 #include "stackclass.hpp" 18 21 #include "World.hpp" … … 53 56 // @TODO rather do the dissection afterwards 54 57 MoleculeListClass *molecules = World::getInstance().getMolecules(); 55 molecules->DissectMoleculeIntoConnectedSubgraphs(World::getInstance().getPeriode(), World::getInstance().getConfig()); 58 config * const configuration = World::getInstance().getConfig(); 59 60 // 0a. remove all present molecules 61 vector<molecule *> allmolecules = World::getInstance().getAllMolecules(); 62 for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) { 63 molecules->erase(*MolRunner); 64 World::getInstance().destroyMolecule(*MolRunner); 65 } 66 67 // 0b. remove all bonds and construct a molecule with all atoms 68 molecule *mol = World::getInstance().createMolecule(); 69 vector <atom *> allatoms = World::getInstance().getAllAtoms(); 70 for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) { 71 for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin()) 72 delete(*BondRunner); 73 mol->AddAtom(*AtomRunner); 74 } 75 76 // 1. create the bond structure of the single molecule 77 if (configuration->BG != NULL) { 78 if (!configuration->BG->ConstructBondGraph(mol)) { 79 World::getInstance().destroyMolecule(mol); 80 DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl); 81 return Action::failure; 82 } 83 } else { 84 DoeLog(1) && (eLog()<< Verbose(1) << "There is no BondGraph class present to create bonds." << endl); 85 return Action::failure; 86 } 87 88 // 2. scan for connected subgraphs 89 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 90 class StackClass<bond *> *BackEdgeStack = NULL; 91 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack); 92 delete(BackEdgeStack); 93 if ((Subgraphs == NULL) || (Subgraphs->next == NULL)) { 94 World::getInstance().destroyMolecule(mol); 95 DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms." << endl); 96 return Action::failure; 97 } 98 99 // 3. dissect (the following construct is needed to have the atoms not in the order of the DFS, but in 100 // the original one as parsed in) 101 // TODO: Optimize this, when molecules just contain pointer list of global atoms! 102 103 // 4a. create array of molecules to fill 104 const int MolCount = Subgraphs->next->Count(); 105 char number[MAXSTRINGSIZE]; 106 molecule **moleculelist = new molecule *[MolCount]; 107 MoleculeLeafClass *MolecularWalker = Subgraphs; 108 for (int i=0;i<MolCount;i++) { 109 MolecularWalker = MolecularWalker->next; 110 moleculelist[i] = World::getInstance().createMolecule(); 111 moleculelist[i]->ActiveFlag = true; 112 strncpy(moleculelist[i]->name, mol->name, MAXSTRINGSIZE); 113 if (MolCount > 1) { 114 sprintf(number, "-%d", i+1); 115 strncat(moleculelist[i]->name, number, MAXSTRINGSIZE - strlen(mol->name) - 1); 116 } 117 DoLog(1) && (Log() << Verbose(1) << "MolName is " << moleculelist[i]->name << ", id is " << moleculelist[i]->getId() << endl); 118 for (molecule::iterator iter = MolecularWalker->Leaf->begin(); iter != MolecularWalker->Leaf->end(); ++iter) { 119 DoLog(1) && (Log() << Verbose(1) << **iter << endl); 120 } 121 molecules->insert(moleculelist[i]); 122 } 123 124 // 4b. create and fill map of which atom is associated to which connected molecule (note, counting starts at 1) 125 int FragmentCounter = 0; 126 map<int, atom *> AtomToFragmentMap; 127 MolecularWalker = Subgraphs; 128 while (MolecularWalker->next != NULL) { 129 MolecularWalker = MolecularWalker->next; 130 for (molecule::iterator iter = MolecularWalker->Leaf->begin(); !MolecularWalker->Leaf->empty(); iter = MolecularWalker->Leaf->begin()) { 131 atom * Walker = *iter; 132 DoLog(1) && (Log() << Verbose(1) << "Re-linking " << Walker << "..." << endl); 133 MolecularWalker->Leaf->erase(iter); 134 moleculelist[FragmentCounter]->AddAtom(Walker); // counting starts at 1 135 } 136 FragmentCounter++; 137 } 138 // TODO: When DepthFirstSearchAnalysis does not use AddCopyAtom() anymore, we don't need to delete all original atoms. 139 // 4d. destroy the original molecule 140 for (molecule::iterator AtomRunner = mol->begin(); !mol->empty(); AtomRunner = mol->begin()) 141 World::getInstance().destroyAtom(*AtomRunner); 142 World::getInstance().destroyMolecule(mol); 143 144 // 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 145 // TODO: check whether this is really not needed anymore 146 // 4e. free Leafs 147 MolecularWalker = Subgraphs; 148 while (MolecularWalker->next != NULL) { 149 MolecularWalker = MolecularWalker->next; 150 delete(MolecularWalker->previous); 151 } 152 delete(MolecularWalker); 153 delete[](moleculelist); 154 DoLog(1) && (Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl); 155 56 156 return Action::success; 57 157 } -
src/Actions/MoleculeAction/RotateAroundOriginByAngleAction.cpp
r8d6d31 r8f4df1 91 91 92 92 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) { 93 *((*iter)->node) = RotationAxis.rotateVector(*((*iter)->node), alpha);93 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), alpha)); 94 94 } 95 95 } … … 109 109 110 110 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) { 111 *((*iter)->node) = RotationAxis.rotateVector(*((*iter)->node), -state->alpha);111 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), -state->alpha)); 112 112 } 113 113 } … … 127 127 128 128 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) { 129 *((*iter)->node) = RotationAxis.rotateVector(*((*iter)->node), state->alpha);129 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), state->alpha)); 130 130 } 131 131 } -
src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp
r8d6d31 r8f4df1 96 96 97 97 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) { 98 *((*iter)->node) = RotationAxis.rotateVector(*((*iter)->node), alpha);98 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), alpha)); 99 99 } 100 100 DoLog(0) && (Log() << Verbose(0) << "done." << endl); … … 111 111 112 112 for (molecule::iterator iter = state->mol->begin(); iter != state->mol->end(); ++iter) { 113 *((*iter)->node) = RotationAxis.rotateVector(*((*iter)->node), -state->alpha);113 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), -state->alpha)); 114 114 } 115 115 … … 125 125 126 126 for (molecule::iterator iter = state->mol->begin(); iter != state->mol->end(); ++iter) { 127 *((*iter)->node) = RotationAxis.rotateVector(*((*iter)->node), state->alpha);127 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), state->alpha)); 128 128 } 129 129 -
src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp
r8d6d31 r8f4df1 83 83 // sum up inertia tensor 84 84 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 85 Vector x = (*iter)-> x;85 Vector x = (*iter)->getPosition(); 86 86 x -= *CenterOfGravity; 87 InertiaTensor.at(0,0) += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]); 88 InertiaTensor.at(0,1) += (*iter)->type->mass*(-x[0]*x[1]); 89 InertiaTensor.at(0,2) += (*iter)->type->mass*(-x[0]*x[2]); 90 InertiaTensor.at(1,0) += (*iter)->type->mass*(-x[1]*x[0]); 91 InertiaTensor.at(1,1) += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]); 92 InertiaTensor.at(1,2) += (*iter)->type->mass*(-x[1]*x[2]); 93 InertiaTensor.at(2,0) += (*iter)->type->mass*(-x[2]*x[0]); 94 InertiaTensor.at(2,1) += (*iter)->type->mass*(-x[2]*x[1]); 95 InertiaTensor.at(2,2) += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]); 87 const double mass = (*iter)->getType()->mass; 88 InertiaTensor.at(0,0) += mass*(x[1]*x[1] + x[2]*x[2]); 89 InertiaTensor.at(0,1) += mass*(-x[0]*x[1]); 90 InertiaTensor.at(0,2) += mass*(-x[0]*x[2]); 91 InertiaTensor.at(1,0) += mass*(-x[1]*x[0]); 92 InertiaTensor.at(1,1) += mass*(x[0]*x[0] + x[2]*x[2]); 93 InertiaTensor.at(1,2) += mass*(-x[1]*x[2]); 94 InertiaTensor.at(2,0) += mass*(-x[2]*x[0]); 95 InertiaTensor.at(2,1) += mass*(-x[2]*x[1]); 96 InertiaTensor.at(2,2) += mass*(x[0]*x[0] + x[1]*x[1]); 96 97 } 97 98 // print InertiaTensor for debugging … … 121 122 122 123 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) { 123 *( (*iter)->node) -= *CenterOfGravity;124 *((*iter)->node) = RotationAxis.rotateVector(*((*iter)->node), alpha);125 *( (*iter)->node) += *CenterOfGravity;124 *(*iter) -= *CenterOfGravity; 125 (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), alpha)); 126 *(*iter) += *CenterOfGravity; 126 127 } 127 128 DoLog(0) && (Log() << Verbose(0) << "done." << endl); … … 133 134 // sum up inertia tensor 134 135 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 135 Vector x = (*iter)-> x;136 Vector x = (*iter)->getPosition(); 136 137 x -= *CenterOfGravity; 137 InertiaTensor.at(0,0) += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]); 138 InertiaTensor.at(0,1) += (*iter)->type->mass*(-x[0]*x[1]); 139 InertiaTensor.at(0,2) += (*iter)->type->mass*(-x[0]*x[2]); 140 InertiaTensor.at(1,0) += (*iter)->type->mass*(-x[1]*x[0]); 141 InertiaTensor.at(1,1) += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]); 142 InertiaTensor.at(1,2) += (*iter)->type->mass*(-x[1]*x[2]); 143 InertiaTensor.at(2,0) += (*iter)->type->mass*(-x[2]*x[0]); 144 InertiaTensor.at(2,1) += (*iter)->type->mass*(-x[2]*x[1]); 145 InertiaTensor.at(2,2) += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]); 138 const double mass = (*iter)->getType()->mass; 139 InertiaTensor.at(0,0) += mass*(x[1]*x[1] + x[2]*x[2]); 140 InertiaTensor.at(0,1) += mass*(-x[0]*x[1]); 141 InertiaTensor.at(0,2) += mass*(-x[0]*x[2]); 142 InertiaTensor.at(1,0) += mass*(-x[1]*x[0]); 143 InertiaTensor.at(1,1) += mass*(x[0]*x[0] + x[2]*x[2]); 144 InertiaTensor.at(1,2) += mass*(-x[1]*x[2]); 145 InertiaTensor.at(2,0) += mass*(-x[2]*x[0]); 146 InertiaTensor.at(2,1) += mass*(-x[2]*x[1]); 147 InertiaTensor.at(2,2) += mass*(x[0]*x[0] + x[1]*x[1]); 146 148 // print InertiaTensor for debugging 147 149 DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << InertiaTensor << endl); -
src/Actions/TesselationAction/ConvexEnvelopeAction.cpp
r8d6d31 r8f4df1 84 84 DoLog(1) && (Log() << Verbose(1) << "Storing tecplot non-convex data in " << filenameNonConvex << "." << endl); 85 85 LCList = new LinkedCell(mol, 100.); 86 Boundaries *BoundaryPoints = NULL;87 86 //FindConvexBorder(mol, BoundaryPoints, TesselStruct, LCList, argv[argptr]); 88 87 // TODO: Beide Funktionen sollten streams anstelle des Filenamen benutzen, besser fuer unit tests -
src/Actions/WorldAction/AddEmptyBoundaryAction.cpp
r8d6d31 r8f4df1 60 60 ASSERT(AllAtoms.size() > 0, "There must be atoms present for AddingEmptyBoundary."); 61 61 vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 62 Min = (*AtomRunner)-> x;63 Max = (*AtomRunner)-> x;62 Min = (*AtomRunner)->getPosition(); 63 Max = (*AtomRunner)->getPosition(); 64 64 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) { 65 65 for (int i=0;i<NDIM;i++) { 66 if ((*AtomRunner)-> x[i]> Max[i])67 Max[i] = (*AtomRunner)-> x[i];68 if ((*AtomRunner)-> x[i]< Min[i])69 Min[i] = (*AtomRunner)-> x[i];66 if ((*AtomRunner)->at(i) > Max[i]) 67 Max[i] = (*AtomRunner)->at(i); 68 if ((*AtomRunner)->at(i) < Min[i]) 69 Min[i] = (*AtomRunner)->at(i); 70 70 } 71 71 } … … 84 84 AtomRunner = AllAtoms.begin(); 85 85 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) 86 (*AtomRunner)->x-= Min - boundary;86 *(*AtomRunner) -= Min - boundary; 87 87 return Action::success; 88 88 } -
src/Actions/WorldAction/CenterOnEdgeAction.cpp
r8d6d31 r8f4df1 55 55 ASSERT(AllAtoms.size() > 0, "For CenteronEdge atoms must be present."); 56 56 vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 57 Min = (*AtomRunner)-> x;58 Max = (*AtomRunner)-> x;57 Min = (*AtomRunner)->getPosition(); 58 Max = (*AtomRunner)->getPosition(); 59 59 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) { 60 60 for (int i=0;i<NDIM;i++) { 61 if ((*AtomRunner)-> x[i]> Max[i])62 Max[i] = (*AtomRunner)-> x[i];63 if ((*AtomRunner)-> x[i]< Min[i])64 Min[i] = (*AtomRunner)-> x[i];61 if ((*AtomRunner)->at(i) > Max[i]) 62 Max[i] = (*AtomRunner)->at(i); 63 if ((*AtomRunner)->at(i) < Min[i]) 64 Min[i] = (*AtomRunner)->at(i); 65 65 } 66 66 } … … 75 75 // translate all atoms, such that Min is aty (0,0,0) 76 76 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) 77 (*AtomRunner)->x-= Min;77 *(*AtomRunner) -= Min; 78 78 79 79 return Action::success; -
src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp
r8d6d31 r8f4df1 62 62 vector<molecule *> molecules = World::getInstance().getAllMolecules(); 63 63 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) { 64 if (point.DistanceSquared((*AtomRunner)->x) > radius*radius) { // distance to first above radius ... 64 if ((*AtomRunner)->DistanceSquared(point) > radius*radius) { // distance to first above radius ... 65 // cout << "Removing " << (*AtomRunner)->getType()->symbol << (*AtomRunner)->getId() << " at " << (*AtomRunner)->getPosition() << " as distance is " << sqrt((*AtomRunner)->DistanceSquared(point)) << endl; 65 66 // TODO: This is not necessary anymore when atoms are completely handled by World (create/destroy and load/save) 66 67 for (vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end();++iter) … … 68 69 World::getInstance().destroyAtom(*AtomRunner); 69 70 } 71 // else { 72 // cout << "Keeping" << (*AtomRunner)->getType()->symbol << (*AtomRunner)->getId() << " at " << (*AtomRunner)->getPosition() << " as distance is " << sqrt((*AtomRunner)->DistanceSquared(point)) << endl; 73 // } 70 74 } 71 75 return Action::success; -
src/Actions/WorldAction/RepeatBoxAction.cpp
r8d6d31 r8f4df1 21 21 #include <iostream> 22 22 #include <string> 23 #include <vector> 23 24 24 25 using namespace std; … … 90 91 91 92 molecule *newmol = NULL; 92 Vector ** vectors = NULL;93 std::vector<Vector> vectors; 93 94 for (n[0] = 0; n[0] < Repeater[0]; n[0]++) { 94 95 y[0] = n[0]; … … 105 106 if (count != 0) { // if there is more than none 106 107 Elements = new const element *[count]; 107 vectors = new Vector *[count];108 vectors.resize(count); 108 109 j = 0; 109 110 for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) { 110 Elements[j] = (*AtomRunner)-> type;111 vectors[j] = &(*AtomRunner)->x;111 Elements[j] = (*AtomRunner)->getType(); 112 vectors[j] = (*AtomRunner)->getPosition(); 112 113 j++; 113 114 } … … 120 121 for (int k=count;k--;) { // go through every atom of the original cell 121 122 Walker = World::getInstance().createAtom(); // create a new body 122 Walker-> x = (*vectors[k]) + x;123 Walker-> type = Elements[k]; // insert original element123 Walker->setPosition((vectors[k]) + x); 124 Walker->setType(Elements[k]); // insert original element 124 125 cout << "new atom is " << *Walker << endl; 125 126 newmol->AddAtom(Walker); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) … … 127 128 // free memory 128 129 delete[](Elements); 129 delete[](vectors);130 130 } else { 131 131 DoLog(1) && (Log() << Verbose(1) << "\t ... is empty." << endl); -
src/Actions/WorldAction/ScaleBoxAction.cpp
r8d6d31 r8f4df1 60 60 vector<atom*> AllAtoms = World::getInstance().getAllAtoms(); 61 61 for(vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) { 62 (*AtomRunner)-> x.ScaleAll(x);62 (*AtomRunner)->ScaleAll(x); 63 63 } 64 64 -
src/AtomSet.hpp
r8d6d31 r8f4df1 65 65 workOnNodePointer(Function &_f) : f(_f){} 66 66 void operator()(atom *atom){ 67 if(atom->node) 68 *atom->node = f(*atom->node); 67 atom->setPosition(f(atom->getPosition())); 69 68 } 70 69 Function &f; … … 75 74 inline void AtomSetMixin<Set>::translate(const Vector &translater){ 76 75 BOOST_FOREACH(atom *atom,*this){ 77 if(atom->node){ 78 *(atom->node) += translater; 79 } 76 *(atom) += translater; 80 77 } 81 78 } -
src/Legacy/oldmenu.cpp
r8d6d31 r8f4df1 89 89 first = World::getInstance().createAtom(); 90 90 std::vector<element *> elements; 91 dialog->queryVector("Please enter coordinates: ",&first-> x,World::getInstance().getDomain(), false);91 dialog->queryVector("Please enter coordinates: ",&first->AtomicPosition,World::getInstance().getDomain(), false); 92 92 dialog->queryElement("Please choose element: ",&elements); 93 93 if(dialog->display()){ 94 94 if (elements.size() == 1) { 95 first-> type = elements.at(0);95 first->setType(elements.at(0)); 96 96 mol->AddAtom(first); // add to molecule 97 97 } else { … … 113 113 auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog()); 114 114 dialog->queryVector("Enter reference coordinates.",&x,World::getInstance().getDomain(), true); 115 dialog->queryVector("Enter relative coordinates.",&first-> x,World::getInstance().getDomain(), false);115 dialog->queryVector("Enter relative coordinates.",&first->AtomicPosition,World::getInstance().getDomain(), false); 116 116 if((aborted = !dialog->display())){ 117 117 continue; 118 118 } 119 first-> x+= x;120 } while (!aborted && !(valid = mol->CheckBounds((const Vector *)&first-> x)));119 first->AtomicPosition += x; 120 } while (!aborted && !(valid = mol->CheckBounds((const Vector *)&first->AtomicPosition))); 121 121 if(!aborted){ 122 first-> type= periode->AskElement(); // give type122 first->AtomicElement = periode->AskElement(); // give type 123 123 mol->AddAtom(first); // add to molecule 124 124 } … … 136 136 auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog()); 137 137 second = mol->AskAtom("Enter atom number: "); 138 dialog->queryVector("Enter relative coordinates.",&first-> x,World::getInstance().getDomain(), false);138 dialog->queryVector("Enter relative coordinates.",&first->AtomicPosition,World::getInstance().getDomain(), false); 139 139 dialog->display(); 140 140 for (int i=NDIM;i--;) { 141 first-> x[i] += second->x[i];141 first->AtomicPosition[i] += second->AtomicPosition[i]; 142 142 } 143 } while (!(valid = mol->CheckBounds((const Vector *)&first-> x)));144 first-> type= periode->AskElement(); // give type143 } while (!(valid = mol->CheckBounds((const Vector *)&first->AtomicPosition))); 144 first->AtomicElement = periode->AskElement(); // give type 145 145 mol->AddAtom(first); // add to molecule 146 146 } … … 152 152 do { 153 153 if (!valid) { 154 eLog() << Verbose(2) << "Resulting coordinates out of cell - " << first-> x<< endl;154 eLog() << Verbose(2) << "Resulting coordinates out of cell - " << first->AtomicPosition << endl; 155 155 } 156 156 Log() << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl; … … 185 185 */ 186 186 // calc axis vector 187 x= second-> x - third->x;187 x= second->AtomicPosition - third->AtomicPosition; 188 188 x.Normalize(); 189 189 Log() << Verbose(0) << "x: " << x << endl; 190 z = Plane(second-> x,third->x,fourth->x).getNormal();190 z = Plane(second->AtomicPosition,third->AtomicPosition,fourth->AtomicPosition).getNormal(); 191 191 Log() << Verbose(0) << "z: " << z << endl; 192 192 y = Plane(x,z,0).getNormal(); … … 194 194 195 195 // rotate vector around first angle 196 first-> x= x;197 first-> x = Line(zeroVec,z).rotateVector(first->x,b - M_PI);198 Log() << Verbose(0) << "Rotated vector: " << first-> x<< endl,196 first->AtomicPosition = x; 197 first->AtomicPosition = Line(zeroVec,z).rotateVector(first->AtomicPosition,b - M_PI); 198 Log() << Verbose(0) << "Rotated vector: " << first->AtomicPosition << endl, 199 199 // remove the projection onto the rotation plane of the second angle 200 200 n = y; 201 n.Scale(first-> x.ScalarProduct(y));201 n.Scale(first->AtomicPosition.ScalarProduct(y)); 202 202 Log() << Verbose(0) << "N1: " << n << endl; 203 first-> x-= n;204 Log() << Verbose(0) << "Subtracted vector: " << first-> x<< endl;203 first->AtomicPosition -= n; 204 Log() << Verbose(0) << "Subtracted vector: " << first->AtomicPosition << endl; 205 205 n = z; 206 n.Scale(first-> x.ScalarProduct(z));206 n.Scale(first->AtomicPosition.ScalarProduct(z)); 207 207 Log() << Verbose(0) << "N2: " << n << endl; 208 first-> x-= n;209 Log() << Verbose(0) << "2nd subtracted vector: " << first-> x<< endl;208 first->AtomicPosition -= n; 209 Log() << Verbose(0) << "2nd subtracted vector: " << first->AtomicPosition << endl; 210 210 211 211 // rotate another vector around second angle … … 215 215 216 216 // add the two linear independent vectors 217 first-> x+= n;218 first-> x.Normalize();219 first-> x.Scale(a);220 first-> x += second->x;221 222 Log() << Verbose(0) << "resulting coordinates: " << first-> x<< endl;223 } while (!(valid = mol->CheckBounds((const Vector *)&first-> x)));224 first-> type= periode->AskElement(); // give type217 first->AtomicPosition += n; 218 first->AtomicPosition.Normalize(); 219 first->AtomicPosition.Scale(a); 220 first->AtomicPosition += second->AtomicPosition; 221 222 Log() << Verbose(0) << "resulting coordinates: " << first->AtomicPosition << endl; 223 } while (!(valid = mol->CheckBounds((const Vector *)&first->AtomicPosition))); 224 first->AtomicElement = periode->AskElement(); // give type 225 225 mol->AddAtom(first); // add to molecule 226 226 break; … … 239 239 if (j != -1) { 240 240 second = mol->FindAtom(j); 241 atoms[i++] = &(second-> x);241 atoms[i++] = &(second->AtomicPosition); 242 242 } 243 243 } while ((j != -1) && (i<128)); 244 244 if (i >= 2) { 245 LSQdistance(first-> x,(const Vector **)atoms, i);246 247 Log() << Verbose(0) << first-> x;248 first-> type= periode->AskElement(); // give type245 LSQdistance(first->AtomicPosition,(const Vector **)atoms, i); 246 247 Log() << Verbose(0) << first->AtomicPosition; 248 first->AtomicElement = periode->AskElement(); // give type 249 249 mol->AddAtom(first); // add to molecule 250 250 } else { … … 338 338 third = mol->AskAtom("Enter third atom: "); 339 339 340 n = Plane(first-> x,second->x,third->x).getNormal();340 n = Plane(first->AtomicPosition,second->AtomicPosition,third->AtomicPosition).getNormal(); 341 341 break; 342 342 case 'b': // normal vector of mirror plane … … 354 354 second = mol->AskAtom("Enter second atom: "); 355 355 356 n = first-> x - second->x;356 n = first->AtomicPosition - second->AtomicPosition; 357 357 n.Normalize(); 358 358 break; … … 405 405 third = mol->AskAtom("Enter third atom: "); 406 406 407 n = Plane(first-> x,second->x,third->x).getNormal();407 n = Plane(first->AtomicPosition,second->AtomicPosition,third->AtomicPosition).getNormal(); 408 408 break; 409 409 case 'b': // normal vector of mirror plane … … 421 421 second = mol->AskAtom("Enter second atom: "); 422 422 423 n = first-> x - second->x;423 n = first->AtomicPosition - second->AtomicPosition; 424 424 n.Normalize(); 425 425 break; … … 464 464 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) { 465 465 runner = iter++; 466 if ((*runner)-> x.DistanceSquared((*runner)->x) > tmp1*tmp1) // distance to first above radius ...466 if ((*runner)->AtomicPosition.DistanceSquared((*runner)->AtomicPosition) > tmp1*tmp1) // distance to first above radius ... 467 467 mol->RemoveAtom((*runner)); 468 468 } … … 479 479 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) { 480 480 runner = iter++; 481 if (((*runner)-> x[axis] < tmp1) || ((*runner)->x[axis] > tmp2)) {// out of boundary ...481 if (((*runner)->AtomicPosition[axis] < tmp1) || ((*runner)->AtomicPosition[axis] > tmp2)) {// out of boundary ... 482 482 //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl; 483 483 mol->RemoveAtom((*runner)); … … 526 526 527 527 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 528 Z = (*iter)-> type->Z;528 Z = (*iter)->getType()->Z; 529 529 tmp1 = 0.; 530 530 if (first != (*iter)) { 531 x = first-> x - (*iter)->x;531 x = first->AtomicPosition - (*iter)->AtomicPosition; 532 532 tmp1 = x.Norm(); 533 533 } … … 536 536 } 537 537 for (int i=MAX_ELEMENTS;i--;) 538 if (min[i] != 0.) Log() << Verbose(0) << "Minimum Bond length between " << first-> type->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl;538 if (min[i] != 0.) Log() << Verbose(0) << "Minimum Bond length between " << first->getType()->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl; 539 539 break; 540 540 … … 544 544 for (int i=NDIM;i--;) 545 545 min[i] = 0.; 546 x = first-> x - second->x;546 x = first->AtomicPosition - second->AtomicPosition; 547 547 tmp1 = x.Norm(); 548 548 Log() << Verbose(1) << "Distance vector is " << x << "." << "/n" … … 556 556 third = mol->AskAtom("Enter last atom: "); 557 557 tmp1 = tmp2 = tmp3 = 0.; 558 x = first-> x - second->x;559 y = third-> x - second->x;558 x = first->AtomicPosition - second->AtomicPosition; 559 y = third->AtomicPosition - second->AtomicPosition; 560 560 Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": "; 561 561 Log() << Verbose(0) << (acos(x.ScalarProduct(y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl; … … 695 695 minBond = 0.; 696 696 for (int i=NDIM;i--;) 697 minBond += (first-> x[i]-second->x[i])*(first->x[i] - second->x[i]);697 minBond += (first->AtomicPosition[i]-second->AtomicPosition[i])*(first->AtomicPosition[i] - second->AtomicPosition[i]); 698 698 minBond = sqrt(minBond); 699 Log() << Verbose(0) << "Current Bond length between " << first-> type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;699 Log() << Verbose(0) << "Current Bond length between " << first->getType()->name << " Atom " << first->nr << " and " << second->getType()->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl; 700 700 Log() << Verbose(0) << "Enter new bond length [a.u.]: "; 701 701 cin >> bond; 702 702 for (int i=NDIM;i--;) { 703 second-> x[i] -= (second->x[i]-first->x[i])/minBond*(minBond-bond);703 second->AtomicPosition[i] -= (second->AtomicPosition[i]-first->AtomicPosition[i])/minBond*(minBond-bond); 704 704 } 705 705 //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: "; … … 757 757 cin >> Z; 758 758 first->setType(Z); 759 Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first-> type->name << "." << endl;759 Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->getType()->name << "." << endl; 760 760 } 761 761 break; … … 785 785 j = 0; 786 786 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 787 Elements[j] = (*iter)-> type;788 vectors[j] = &(*iter)-> x;787 Elements[j] = (*iter)->AtomicElement; 788 vectors[j] = &(*iter)->AtomicPosition; 789 789 j++; 790 790 } … … 798 798 for (int k=count;k--;) { // go through every atom of the original cell 799 799 first = World::getInstance().createAtom(); // create a new body 800 first-> x= (*vectors[k]) + x; // use coordinate of original atom801 first-> type= Elements[k]; // insert original element800 first->AtomicPosition = (*vectors[k]) + x; // use coordinate of original atom 801 first->AtomicElement = Elements[k]; // insert original element 802 802 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) 803 803 } -
src/LinearAlgebra/Makefile.am
r8d6d31 r8f4df1 17 17 Plane.cpp \ 18 18 Space.cpp \ 19 Vector.cpp 19 vector_ops.cpp \ 20 Vector.cpp \ 21 VectorInterface.cpp 20 22 21 23 LINALGHEADER = \ … … 27 29 Plane.hpp \ 28 30 Space.hpp \ 29 Vector.hpp 31 vector_ops.hpp \ 32 Vector.hpp \ 33 VectorInterface.hpp 30 34 31 35 -
src/LinearAlgebra/Vector.cpp
r8d6d31 r8f4df1 50 50 gsl_vector_set(content->content,1,x2); 51 51 gsl_vector_set(content->content,2,x3); 52 }; 53 54 /** Constructor of class vector. 55 */ 56 Vector::Vector(const double x[3]) 57 { 58 content = new VectorContent(); 59 gsl_vector_set(content->content,0,x[0]); 60 gsl_vector_set(content->content,1,x[1]); 61 gsl_vector_set(content->content,2,x[2]); 52 62 }; 53 63 -
src/LinearAlgebra/Vector.hpp
r8d6d31 r8f4df1 36 36 Vector(); 37 37 Vector(const double x1, const double x2, const double x3); 38 Vector(const double x[3]); 38 39 Vector(const Vector& src); 39 40 virtual ~Vector(); -
src/Makefile.am
r8d6d31 r8f4df1 120 120 QTUI_DEFS = 121 121 122 TESSELATIONSOURCE = \ 123 BoundaryLineSet.cpp \ 124 BoundaryPointSet.cpp \ 125 BoundaryPolygonSet.cpp \ 126 BoundaryTriangleSet.cpp \ 127 CandidateForTesselation.cpp \ 128 PointCloud.cpp \ 129 tesselation.cpp \ 130 tesselationhelpers.cpp \ 131 TesselPoint.cpp 132 133 TESSELATIONHEADER = \ 134 BoundaryLineSet.hpp \ 135 BoundaryPointSet.hpp \ 136 BoundaryPolygonSet.hpp \ 137 BoundaryTriangleSet.hpp \ 138 CandidateForTesselation.hpp \ 139 PointCloud.hpp \ 140 tesselation.hpp \ 141 tesselationhelpers.hpp \ 142 TesselPoint.hpp 143 122 144 MOLECUILDERSOURCE = \ 123 145 ${ANALYSISSOURCE} \ … … 125 147 ${ATOMSOURCE} \ 126 148 ${PATTERNSOURCE} \ 127 ${PARSERSOURCE} \128 149 ${SHAPESOURCE} \ 129 150 ${DESCRIPTORSOURCE} \ 151 ${TESSELATIONSOURCE} \ 130 152 bond.cpp \ 131 153 bondgraph.cpp \ … … 151 173 parser.cpp \ 152 174 periodentafel.cpp \ 153 tesselation.cpp \154 tesselationhelpers.cpp \155 175 ThermoStatContainer.cpp \ 156 176 triangleintersectionlist.cpp \ 157 177 UIElements/UIFactory.cpp \ 158 vector_ops.cpp \159 178 World.cpp 160 179 … … 163 182 ${ACTIONSHEADER} \ 164 183 ${ATOMHEADER} \ 165 ${PARSERHEADER} \166 184 ${PATTERNHEADER} \ 167 185 ${SHAPEHEADER} \ 168 186 ${DESCRIPTORHEADER} \ 187 ${TESSELATIONHEADER} \ 169 188 bond.hpp \ 170 189 bondgraph.hpp \ … … 188 207 periodentafel.hpp \ 189 208 stackclass.hpp \ 190 tesselation.hpp \191 tesselationhelpers.hpp \192 209 ThermoStatContainer.hpp \ 193 210 triangleintersectionlist.hpp \ 194 211 UIElements/UIFactory.hpp \ 195 vector_ops.hpp \196 212 World.hpp 197 213 -
src/Parser/MpqcParser.cpp
r8d6d31 r8f4df1 62 62 // calculate center 63 63 for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner) 64 center += (*runner)-> x;64 center += (*runner)->getPosition(); 65 65 center.Scale(1./allatoms.size()); 66 66 … … 110 110 // calculate center 111 111 for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner) 112 center += (*runner)-> x;112 center += (*runner)->getPosition(); 113 113 center.Scale(1./allatoms.size()); 114 114 -
src/Parser/PcpParser.cpp
r8d6d31 r8f4df1 462 462 PlaneWaveSpecifics.MaxPsiDouble = PlaneWaveSpecifics.PsiMaxNoDown = PlaneWaveSpecifics.PsiMaxNoUp = PlaneWaveSpecifics.PsiType = 0; 463 463 for (vector<atom *>::iterator runner = allatoms.begin(); runner != allatoms.end(); ++runner) { 464 PlaneWaveSpecifics.MaxPsiDouble += (*runner)-> type->NoValenceOrbitals;464 PlaneWaveSpecifics.MaxPsiDouble += (*runner)->getType()->NoValenceOrbitals; 465 465 } 466 466 cout << PlaneWaveSpecifics.MaxPsiDouble << endl; … … 497 497 // insert all found elements into the map 498 498 for (vector<atom *>::iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) { 499 Inserter = PresentElements.insert(pair<int, int>((*AtomRunner)-> type->Z, 1));499 Inserter = PresentElements.insert(pair<int, int>((*AtomRunner)->getType()->Z, 1)); 500 500 if (!Inserter.second) // increase if present 501 501 Inserter.first->second += 1; … … 528 528 int nr = 0; 529 529 for (vector<atom *>::iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) { 530 Inserter = ZtoCountMap.insert( pair<int, int>((*AtomRunner)-> type->Z, 1) );530 Inserter = ZtoCountMap.insert( pair<int, int>((*AtomRunner)->getType()->Z, 1) ); 531 531 if (!Inserter.second) 532 532 Inserter.first->second += 1; 533 const int Z = (*AtomRunner)-> type->Z;533 const int Z = (*AtomRunner)->getType()->Z; 534 534 *file << "Ion_Type" << ZtoIndexMap[Z] << "_" << ZtoCountMap[Z] << "\t" << fixed << setprecision(9) << showpoint; 535 *file << (*AtomRunner)-> x[0] << "\t" << (*AtomRunner)->x[1] << "\t" << (*AtomRunner)->x[2];535 *file << (*AtomRunner)->at(0) << "\t" << (*AtomRunner)->at(1) << "\t" << (*AtomRunner)->at(2); 536 536 *file << "\t" << (*AtomRunner)->FixedIon; 537 if ((*AtomRunner)-> v.Norm() > MYEPSILON)538 *file << "\t" << scientific << setprecision(6) << (*AtomRunner)-> v[0] << "\t" << (*AtomRunner)->v[1] << "\t" << (*AtomRunner)->v[2] << "\t";537 if ((*AtomRunner)->AtomicVelocity.Norm() > MYEPSILON) 538 *file << "\t" << scientific << setprecision(6) << (*AtomRunner)->AtomicVelocity[0] << "\t" << (*AtomRunner)->AtomicVelocity[1] << "\t" << (*AtomRunner)->AtomicVelocity[2] << "\t"; 539 539 *file << " # molecule nr " << nr++ << endl; 540 540 } -
src/Parser/TremoloParser.cpp
r8d6d31 r8f4df1 143 143 case TremoloKey::x : 144 144 // for the moment, assume there are always three dimensions 145 *file << currentAtom-> x[0]<< "\t";146 *file << currentAtom-> x[1]<< "\t";147 *file << currentAtom-> x[2]<< "\t";145 *file << currentAtom->at(0) << "\t"; 146 *file << currentAtom->at(1) << "\t"; 147 *file << currentAtom->at(2) << "\t"; 148 148 break; 149 149 case TremoloKey::u : 150 150 // for the moment, assume there are always three dimensions 151 *file << currentAtom-> v[0] << "\t";152 *file << currentAtom-> v[1] << "\t";153 *file << currentAtom-> v[2] << "\t";151 *file << currentAtom->AtomicVelocity[0] << "\t"; 152 *file << currentAtom->AtomicVelocity[1] << "\t"; 153 *file << currentAtom->AtomicVelocity[2] << "\t"; 154 154 break; 155 155 case TremoloKey::Type : … … 228 228 string word; 229 229 int oldId; 230 double tmp; 230 231 231 232 lineStream << line; … … 235 236 case TremoloKey::x : 236 237 // for the moment, assume there are always three dimensions 237 lineStream >> newAtom->x[0]; 238 lineStream >> newAtom->x[1]; 239 lineStream >> newAtom->x[2]; 238 for (int i=0;i<NDIM;i++) { 239 lineStream >> tmp; 240 newAtom->set(i, tmp); 241 } 240 242 break; 241 243 case TremoloKey::u : 242 244 // for the moment, assume there are always three dimensions 243 lineStream >> newAtom-> v[0];244 lineStream >> newAtom-> v[1];245 lineStream >> newAtom-> v[2];245 lineStream >> newAtom->AtomicVelocity[0]; 246 lineStream >> newAtom->AtomicVelocity[1]; 247 lineStream >> newAtom->AtomicVelocity[2]; 246 248 break; 247 249 case TremoloKey::Type : -
src/Parser/XyzParser.cpp
r8d6d31 r8f4df1 42 42 int numberOfAtoms; 43 43 char commentBuffer[512], type[3]; 44 double tmp; 44 45 45 46 // the first line tells number of atoms, the second line is always a comment … … 53 54 for (int i = 0; i < numberOfAtoms; i++) { 54 55 newAtom = World::getInstance().createAtom(); 55 *file >> type >> ws >> newAtom->x[0] >> ws >> newAtom->x[1] >> ws >> newAtom->x[2]; 56 *file >> type; 57 for (int j=0;j<NDIM;j++) { 58 *file >> tmp; 59 newAtom->set(j, tmp); 60 } 56 61 newAtom->setType(World::getInstance().getPeriode()->FindElement(type)); 57 62 newmol->AddAtom(newAtom); … … 81 86 vector<atom*> atoms = World::getInstance().getAllAtoms(); 82 87 for(vector<atom*>::iterator it = atoms.begin(); it != atoms.end(); it++) { 83 *file << noshowpoint << (*it)->getType()->symbol << "\t" << (*it)-> x[0] << "\t" << (*it)->x[1] << "\t" << (*it)->x[2]<< endl;88 *file << noshowpoint << (*it)->getType()->symbol << "\t" << (*it)->at(0) << "\t" << (*it)->at(1) << "\t" << (*it)->at(2) << endl; 84 89 } 85 90 } -
src/UIElements/QT4/QTDialog.cpp
r8d6d31 r8f4df1 481 481 parent(_parent) 482 482 { 483 const Matrix& M = World::getInstance().getDomain().getM();484 const char *coords[3] = {"x:","y:","z:"};485 483 mainLayout= new QHBoxLayout(); 486 484 titleLabel = new QLabel(QString(getTitle().c_str())); … … 515 513 parent(_parent) 516 514 { 517 const Matrix& M = World::getInstance().getDomain().getM();518 const char *coords[3] = {"x:","y:","z:"};519 515 mainLayout= new QHBoxLayout(); 520 516 titleLabel = new QLabel(QString(getTitle().c_str())); -
src/UIElements/TextUI/TextDialog.cpp
r8d6d31 r8f4df1 525 525 } 526 526 } 527 527 528 return true; 528 529 } -
src/analysis_bonds.cpp
r8d6d31 r8f4df1 60 60 int AtomNo = 0; 61 61 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 62 if ((*iter)-> type== type1)62 if ((*iter)->getType() == type1) 63 63 for (BondList::const_iterator BondRunner = (*iter)->ListOfBonds.begin(); BondRunner != (*iter)->ListOfBonds.end(); BondRunner++) 64 if ((*BondRunner)->GetOtherAtom((*iter))-> type== type2) {64 if ((*BondRunner)->GetOtherAtom((*iter))->getType() == type2) { 65 65 const double distance = (*BondRunner)->GetDistanceSquared(); 66 66 if (Min > distance) … … 87 87 * \return angle between \a *first and \a *second, both relative to origin at \a *origin. 88 88 */ 89 double CalculateAngle( Vector *first, Vector *central, Vector *second)89 double CalculateAngle(const Vector &first, const Vector ¢ral, const Vector &second) 90 90 { 91 91 Vector OHBond; 92 92 Vector OOBond; 93 93 94 OHBond = (*first) - (*central);95 OOBond = (*second) - (*central);94 OHBond = first - central; 95 OOBond = second - central; 96 96 const double angle = OHBond.Angle(OOBond); 97 97 return angle; … … 110 110 111 111 // check angle 112 if (CalculateAngle( &Hydrogen->x, &Oxygen->x, &OtherOxygen->x) < M_PI*(30./180.)) {112 if (CalculateAngle(Hydrogen->getPosition(), Oxygen->getPosition(), OtherOxygen->getPosition()) < M_PI*(30./180.)) { 113 113 return true; 114 114 } else { … … 138 138 molecule::iterator Runner = (*MolRunner)->begin(); 139 139 for(;Runner!=(*MolRunner)->end();++Runner){ 140 if (((*Walker)-> type->Z == 8) && ((*Runner)->type->Z == 8)) {140 if (((*Walker)->getType()->Z == 8) && ((*Runner)->getType()->Z == 8)) { 141 141 // check distance 142 const double distance = (*Runner)-> x.DistanceSquared((*Walker)->x);142 const double distance = (*Runner)->DistanceSquared(*(*Walker)); 143 143 if ((distance > MYEPSILON) && (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE)) { // distance >0 means different atoms 144 144 // on other atom(Runner) we check for bond to interface element and … … 152 152 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Runner); 153 153 // if hydrogen, check angle to be greater(!) than 30 degrees 154 if (OtherAtom-> type->Z == 1) {155 const double angle = CalculateAngle( &OtherAtom->x, &(*Runner)->x, &(*Walker)->x);154 if (OtherAtom->getType()->Z == 1) { 155 const double angle = CalculateAngle(OtherAtom->getPosition(), (*Runner)->getPosition(), (*Walker)->getPosition()); 156 156 OtherHydrogenFlag = OtherHydrogenFlag && (angle > M_PI*(30./180.) + MYEPSILON); 157 157 Otherangle += angle; 158 158 OtherHydrogens++; 159 159 } 160 InterfaceFlag = InterfaceFlag || (OtherAtom-> type== InterfaceElement);161 Interface2Flag = Interface2Flag || (OtherAtom-> type== Interface2Element);160 InterfaceFlag = InterfaceFlag || (OtherAtom->getType() == InterfaceElement); 161 Interface2Flag = Interface2Flag || (OtherAtom->getType() == Interface2Element); 162 162 } 163 163 DoLog(1) && (Log() << Verbose(1) << "Otherangle is " << Otherangle << " for " << OtherHydrogens << " hydrogens." << endl); … … 177 177 for (BondList::const_iterator BondRunner = (*Walker)->ListOfBonds.begin(); BondRunner != (*Walker)->ListOfBonds.end(); BondRunner++) { 178 178 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Walker); 179 if (OtherAtom-> type->Z == 1) {179 if (OtherAtom->getType()->Z == 1) { 180 180 // check angle 181 181 if (CheckHydrogenBridgeBondAngle(*Walker, OtherAtom, *Runner)) { 182 DoLog(1) && (Log() << Verbose(1) << (*Walker)->getName() << ", " << OtherAtom->getName() << " and " << (*Runner)->getName() << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle( &OtherAtom->x, &(*Walker)->x, &(*Runner)->x)*(180./M_PI) << "." << endl);182 DoLog(1) && (Log() << Verbose(1) << (*Walker)->getName() << ", " << OtherAtom->getName() << " and " << (*Runner)->getName() << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle(OtherAtom->getPosition(), (*Walker)->getPosition(), (*Runner)->getPosition())*(180./M_PI) << "." << endl); 183 183 count++; 184 184 break; … … 210 210 for(;Walker!=(*MolWalker)->end();++Walker){ 211 211 atom * theAtom = *Walker; 212 if ((theAtom-> type == first) || (theAtom->type== second)) { // first element matches212 if ((theAtom->getType() == first) || (theAtom->getType() == second)) { // first element matches 213 213 for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) { 214 214 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom); 215 if (((OtherAtom-> type == first) || (OtherAtom->type== second)) && (theAtom->nr < OtherAtom->nr)) {215 if (((OtherAtom->getType() == first) || (OtherAtom->getType() == second)) && (theAtom->nr < OtherAtom->nr)) { 216 216 count++; 217 217 DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl); … … 246 246 for(;Walker!=(*MolWalker)->end();++Walker){ 247 247 atom *theAtom = *Walker; 248 if (theAtom-> type== second) { // first element matches248 if (theAtom->getType() == second) { // first element matches 249 249 for (int i=0;i<2;i++) 250 250 MatchFlag[i] = false; … … 252 252 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom); 253 253 for (int i=0;i<2;i++) 254 if ((!MatchFlag[i]) && (OtherAtom-> type== ElementArray[i])) {254 if ((!MatchFlag[i]) && (OtherAtom->getType() == ElementArray[i])) { 255 255 MatchFlag[i] = true; 256 256 break; // each bonding atom can match at most one element we are looking for -
src/analysis_correlation.cpp
r8d6d31 r8f4df1 11 11 #include <iomanip> 12 12 13 #include "BoundaryTriangleSet.hpp" 13 14 #include "analysis_correlation.hpp" 14 15 #include "element.hpp" … … 74 75 if ((*iter)->getId() < (*runner)->getId()){ 75 76 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 76 if ((PairRunner->first == (**iter). type) && (PairRunner->second == (**runner).type)) {77 distance = domain.periodicDistance( *(*iter)->node,*(*runner)->node);77 if ((PairRunner->first == (**iter).getType()) && (PairRunner->second == (**runner).getType())) { 78 distance = domain.periodicDistance((*iter)->getPosition(),(*runner)->getPosition()); 78 79 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 79 80 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); … … 137 138 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 138 139 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 139 periodicX = FullInverseMatrix * ( *(*iter)->node); // x now in [0,1)^3140 periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3 140 141 // go through every range in xyz and get distance 141 142 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) … … 149 150 if ((*iter)->getId() < (*runner)->getId()){ 150 151 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 151 if ((PairRunner->first == (**iter). type) && (PairRunner->second == (**runner).type)) {152 periodicOtherX = FullInverseMatrix * ( *(*runner)->node); // x now in [0,1)^3152 if ((PairRunner->first == (**iter).getType()) && (PairRunner->second == (**runner).getType())) { 153 periodicOtherX = FullInverseMatrix * ((*runner)->getPosition()); // x now in [0,1)^3 153 154 // go through every range in xyz and get distance 154 155 for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++) … … 196 197 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 197 198 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 198 if ((*type == NULL) || ((*iter)-> type== *type)) {199 distance = domain.periodicDistance( *(*iter)->node,*point);199 if ((*type == NULL) || ((*iter)->getType() == *type)) { 200 distance = domain.periodicDistance((*iter)->getPosition(),*point); 200 201 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 201 202 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) ); … … 237 238 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 238 239 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 239 if ((*type == NULL) || ((*iter)-> type== *type)) {240 periodicX = FullInverseMatrix * ( *(*iter)->node); // x now in [0,1)^3240 if ((*type == NULL) || ((*iter)->getType() == *type)) { 241 periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3 241 242 // go through every range in xyz and get distance 242 243 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) … … 284 285 DoLog(3) && (Log() << Verbose(3) << "\tCurrent atom is " << *(*iter) << "." << endl); 285 286 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 286 if ((*type == NULL) || ((*iter)-> type== *type)) {287 TriangleIntersectionList Intersections((*iter)-> node,Surface,LC);287 if ((*type == NULL) || ((*iter)->getType() == *type)) { 288 TriangleIntersectionList Intersections((*iter)->getPosition(),Surface,LC); 288 289 distance = Intersections.GetSmallestDistance(); 289 290 triangle = Intersections.GetClosestTriangle(); … … 335 336 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 336 337 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 337 if ((*type == NULL) || ((*iter)-> type== *type)) {338 periodicX = FullInverseMatrix * ( *(*iter)->node); // x now in [0,1)^3338 if ((*type == NULL) || ((*iter)->getType() == *type)) { 339 periodicX = FullInverseMatrix * ((*iter)->getPosition()); // x now in [0,1)^3 339 340 // go through every range in xyz and get distance 340 341 ShortestDistance = -1.; … … 343 344 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 344 345 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 345 TriangleIntersectionList Intersections( &checkX,Surface,LC);346 TriangleIntersectionList Intersections(checkX,Surface,LC); 346 347 distance = Intersections.GetSmallestDistance(); 347 348 triangle = Intersections.GetClosestTriangle(); … … 411 412 *file << runner->first; 412 413 for (int i=0;i<NDIM;i++) 413 *file << "\t" << setprecision(8) << (runner->second.first-> node->at(i) - runner->second.second->at(i));414 *file << "\t" << setprecision(8) << (runner->second.first->at(i) - runner->second.second->at(i)); 414 415 *file << endl; 415 416 } … … 426 427 if (!map->empty()) 427 428 for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 428 *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl; 429 } 430 }; 431 429 *file << setprecision(8) << runner->first << "\t"; 430 *file << *(runner->second.first) << "\t"; 431 *file << *(runner->second.second) << endl; 432 } 433 }; 434 -
src/atom.cpp
r8d6d31 r8f4df1 28 28 atom::atom() : 29 29 father(this), sort(&nr), mol(0) 30 { 31 node = &x; // TesselPoint::x can only be referenced from here 32 }; 30 {}; 33 31 34 32 /** Constructor of class atom. … … 37 35 ParticleInfo(pointer),father(pointer), sort(&nr) 38 36 { 39 type = pointer->type; // copy element of atom40 x = pointer->x; // copy coordination41 v = pointer->v; // copy velocity37 setType(pointer->getType()); // copy element of atom 38 setPosition(pointer->getPosition()); // copy coordination 39 AtomicVelocity = pointer->AtomicVelocity; // copy velocity 42 40 FixedIon = pointer->FixedIon; 43 node = &x;44 41 mol = 0; 45 42 }; … … 49 46 res->father = this; 50 47 res->sort = &res->nr; 51 res-> type = type;52 res-> x = this->x;53 res-> v = this->v;48 res->setType(getType()); 49 res->setPosition(this->getPosition()); 50 res->AtomicVelocity = this->AtomicVelocity; 54 51 res->FixedIon = FixedIon; 55 res->node = &x;56 52 res->mol = 0; 57 53 World::getInstance().registerAtom(res); … … 121 117 bool atom::IsInShape(const Shape& shape) const 122 118 { 123 return shape.isInside( *node);119 return shape.isInside(getPosition()); 124 120 }; 125 121 … … 146 142 if (out != NULL) { 147 143 *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t" << fixed << setprecision(9) << showpoint; 148 *out << x[0] << "\t" << x[1] << "\t" << x[2];144 *out << at(0) << "\t" << at(1) << "\t" << at(2); 149 145 *out << "\t" << FixedIon; 150 if ( v.Norm() > MYEPSILON)151 *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";146 if (AtomicVelocity.Norm() > MYEPSILON) 147 *out << "\t" << scientific << setprecision(6) << AtomicVelocity[0] << "\t" << AtomicVelocity[1] << "\t" << AtomicVelocity[2] << "\t"; 152 148 if (comment != NULL) 153 149 *out << " # " << comment << endl; … … 168 164 bool atom::OutputArrayIndexed(ostream * const out,const enumeration<const element*> &elementLookup, int *AtomNo, const char *comment) const 169 165 { 170 AtomNo[type->Z]++; // increment number 171 if (out != NULL) { 172 cout << "Looking for atom with element " << *type << endl; 173 ASSERT(elementLookup.there.find(type)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration"); 174 *out << "Ion_Type" << elementLookup.there.find(type)->second << "_" << AtomNo[type->Z] << "\t" << fixed << setprecision(9) << showpoint; 175 *out << x[0] << "\t" << x[1] << "\t" << x[2]; 166 AtomNo[getType()->Z]++; // increment number 167 if (out != NULL) { 168 const element *elemental = getType(); 169 cout << "Looking for atom with element " << *elemental << endl; 170 ASSERT(elementLookup.there.find(elemental)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration"); 171 *out << "Ion_Type" << elementLookup.there.find(elemental)->second << "_" << AtomNo[elemental->Z] << "\t" << fixed << setprecision(9) << showpoint; 172 *out << at(0) << "\t" << at(1) << "\t" << at(2); 176 173 *out << "\t" << FixedIon; 177 if ( v.Norm() > MYEPSILON)178 *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";174 if (AtomicVelocity.Norm() > MYEPSILON) 175 *out << "\t" << scientific << setprecision(6) << AtomicVelocity[0] << "\t" << AtomicVelocity[1] << "\t" << AtomicVelocity[2] << "\t"; 179 176 if (comment != NULL) 180 177 *out << " # " << comment << endl; … … 193 190 { 194 191 if (out != NULL) { 195 *out << type->symbol << "\t" << x[0] << "\t" << x[1] << "\t" << x[2]<< "\t" << endl;192 *out << getType()->symbol << "\t" << at(0) << "\t" << at(1) << "\t" << at(2) << "\t" << endl; 196 193 return true; 197 194 } else … … 208 205 bool atom::OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const 209 206 { 210 AtomNo[ type->Z]++;211 if (out != NULL) { 212 *out << "Ion_Type" << ElementNo[ type->Z] << "_" << AtomNo[type->Z] << "\t" << fixed << setprecision(9) << showpoint;207 AtomNo[getType()->Z]++; 208 if (out != NULL) { 209 *out << "Ion_Type" << ElementNo[getType()->Z] << "_" << AtomNo[getType()->Z] << "\t" << fixed << setprecision(9) << showpoint; 213 210 *out << Trajectory.R.at(step)[0] << "\t" << Trajectory.R.at(step)[1] << "\t" << Trajectory.R.at(step)[2]; 214 211 *out << "\t" << FixedIon; … … 231 228 { 232 229 if (out != NULL) { 233 *out << type->symbol << "\t";230 *out << getType()->symbol << "\t"; 234 231 *out << Trajectory.R.at(step)[0] << "\t"; 235 232 *out << Trajectory.R.at(step)[1] << "\t"; … … 247 244 void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const 248 245 { 249 *out << "\t\t" << type->symbol << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl; 246 Vector recentered(getPosition()); 247 recentered -= *center; 248 *out << "\t\t" << getType()->symbol << " [ " << recentered[0] << "\t" << recentered[1] << "\t" << recentered[2] << " ]" << endl; 250 249 if (AtomNo != NULL) 251 250 *AtomNo++; … … 270 269 double atom::DistanceSquaredToVector(const Vector &origin) const 271 270 { 272 return origin.DistanceSquared(x);271 return DistanceSquared(origin); 273 272 }; 274 273 … … 279 278 double atom::DistanceToVector(const Vector &origin) const 280 279 { 281 return origin.distance(x);280 return distance(origin); 282 281 }; 283 282 … … 294 293 }; 295 294 295 std::ostream & atom::operator << (std::ostream &ost) const 296 { 297 ParticleInfo::operator<<(ost); 298 ost << "," << getPosition(); 299 return ost; 300 } 301 302 std::ostream & operator << (std::ostream &ost, const atom &a) 303 { 304 a.ParticleInfo::operator<<(ost); 305 ost << "," << a.getPosition(); 306 return ost; 307 } 296 308 297 309 bool operator < (atom &a, atom &b) -
src/atom.hpp
r8d6d31 r8f4df1 22 22 #include <vector> 23 23 24 #include "Helpers/helpers.hpp" 24 25 #include "atom_atominfo.hpp" 25 26 #include "atom_bondedparticle.hpp" … … 27 28 #include "atom_particleinfo.hpp" 28 29 #include "atom_trajectoryparticle.hpp" 29 #include " tesselation.hpp"30 #include "TesselPoint.hpp" 30 31 #include "types.hpp" 31 32 … … 42 43 * Class incorporates position, type 43 44 */ 44 class atom : public T esselPoint, public TrajectoryParticle, public GraphNode, public BondedParticle, public virtual ParticleInfo, public virtual AtomInfo{45 class atom : public TrajectoryParticle, public GraphNode, public BondedParticle, public TesselPoint { 45 46 friend atom* NewAtom(atomId_t); 46 47 friend void DeleteAtom(atom*); … … 94 95 void removeFromMolecule(); 95 96 97 // Output operator 98 std::ostream & operator << (std::ostream &ost) const; 99 96 100 protected: 97 101 … … 120 124 121 125 /** 126 * Global output operator for class atom. 127 */ 128 std::ostream & operator << (std::ostream &ost, const atom &_atom); 129 130 /** 122 131 * internal method used by the world. Do not use if you don't know what you are doing. 123 132 * You might get burned... -
src/atom_atominfo.cpp
r8d6d31 r8f4df1 10 10 #include "periodentafel.hpp" 11 11 #include "World.hpp" 12 #include "element.hpp" 12 13 #include "atom_atominfo.hpp" 13 14 14 15 /** Constructor of class AtomInfo. 15 16 */ 16 AtomInfo::AtomInfo() : type(NULL) {}; 17 AtomInfo::AtomInfo() : AtomicElement(NULL) {}; 18 19 /** Copy constructor of class AtomInfo. 20 */ 21 AtomInfo::AtomInfo(const AtomInfo &_atom) : AtomicPosition(_atom.AtomicPosition), AtomicElement(_atom.AtomicElement) {}; 22 23 AtomInfo::AtomInfo(const VectorInterface &_v) : AtomicPosition(_v.getPosition()), AtomicElement(NULL) 24 {}; 17 25 18 26 /** Destructor of class AtomInfo. … … 22 30 }; 23 31 24 const element *AtomInfo::getType(){ 25 return type; 32 const element *AtomInfo::getType() const 33 { 34 return AtomicElement; 35 } 36 37 const double& AtomInfo::operator[](size_t i) const 38 { 39 return AtomicPosition[i]; 40 } 41 42 const double& AtomInfo::at(size_t i) const 43 { 44 return AtomicPosition.at(i); 45 } 46 47 void AtomInfo::set(size_t i, const double value) 48 { 49 AtomicPosition.at(i) = value; 50 } 51 52 const Vector& AtomInfo::getPosition() const 53 { 54 return AtomicPosition; 26 55 } 27 56 28 57 void AtomInfo::setType(const element* _type) { 29 type= _type;58 AtomicElement = _type; 30 59 } 31 60 32 void AtomInfo::setType( int Z) {61 void AtomInfo::setType(const int Z) { 33 62 const element *elem = World::getInstance().getPeriode()->FindElement(Z); 34 63 setType(elem); 35 64 } 65 66 void AtomInfo::setPosition(const Vector& _vector) 67 { 68 AtomicPosition = _vector; 69 //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl; 70 } 71 72 const VectorInterface& AtomInfo::operator+=(const Vector& b) 73 { 74 AtomicPosition += b; 75 return *this; 76 } 77 78 const VectorInterface& AtomInfo::operator-=(const Vector& b) 79 { 80 AtomicPosition -= b; 81 return *this; 82 } 83 84 Vector const AtomInfo::operator+(const Vector& b) const 85 { 86 Vector a(AtomicPosition); 87 a += b; 88 return a; 89 } 90 91 Vector const AtomInfo::operator-(const Vector& b) const 92 { 93 Vector a(AtomicPosition); 94 a -= b; 95 return a; 96 } 97 98 double AtomInfo::distance(const Vector &point) const 99 { 100 return AtomicPosition.distance(point); 101 } 102 103 double AtomInfo::DistanceSquared(const Vector &y) const 104 { 105 return AtomicPosition.DistanceSquared(y); 106 } 107 108 double AtomInfo::distance(const VectorInterface &_atom) const 109 { 110 return _atom.distance(AtomicPosition); 111 } 112 113 double AtomInfo::DistanceSquared(const VectorInterface &_atom) const 114 { 115 return _atom.DistanceSquared(AtomicPosition); 116 } 117 118 VectorInterface &AtomInfo::operator=(const Vector& _vector) 119 { 120 AtomicPosition = _vector; 121 return *this; 122 } 123 124 void AtomInfo::ScaleAll(const double *factor) 125 { 126 AtomicPosition.ScaleAll(factor); 127 } 128 129 void AtomInfo::ScaleAll(const Vector &factor) 130 { 131 AtomicPosition.ScaleAll(factor); 132 } 133 134 void AtomInfo::Scale(const double factor) 135 { 136 AtomicPosition.Scale(factor); 137 } 138 139 void AtomInfo::Zero() 140 { 141 AtomicPosition.Zero(); 142 } 143 144 void AtomInfo::One(const double one) 145 { 146 AtomicPosition.One(one); 147 } 148 149 void AtomInfo::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors) 150 { 151 AtomicPosition.LinearCombinationOfVectors(x1,x2,x3,factors); 152 } 153 154 const AtomInfo& operator*=(AtomInfo& a, const double m) 155 { 156 a.Scale(m); 157 return a; 158 } 159 160 AtomInfo const operator*(const AtomInfo& a, const double m) 161 { 162 AtomInfo copy(a); 163 copy *= m; 164 return copy; 165 } 166 167 AtomInfo const operator*(const double m, const AtomInfo& a) 168 { 169 AtomInfo copy(a); 170 copy *= m; 171 return copy; 172 } 173 174 std::ostream & AtomInfo::operator << (std::ostream &ost) const 175 { 176 return (ost << getPosition()); 177 } 178 179 std::ostream & operator << (std::ostream &ost, const AtomInfo &a) 180 { 181 ost << a; 182 return ost; 183 } 184 -
src/atom_atominfo.hpp
r8d6d31 r8f4df1 20 20 21 21 #include "LinearAlgebra/Vector.hpp" 22 #include "LinearAlgebra/VectorInterface.hpp" 22 23 23 24 /****************************************** forward declarations *****************************/ 24 25 26 class AtomInfo; 25 27 class element; 28 class Matrix; 26 29 27 30 /********************************************** declarations *******************************/ 28 31 29 class AtomInfo { 32 class AtomInfo : public VectorInterface { 33 30 34 public: 31 Vector x; //!< coordinate vector of atom, giving last position within cell 32 Vector v; //!< velocity vector of atom, giving last velocity within cell 33 Vector F; //!< Force vector of atom, giving last force within cell 34 const element *type; //!< pointing to element 35 Vector AtomicVelocity; //!< velocity vector of atom, giving last velocity within cell 36 Vector AtomicForce; //!< Force vector of atom, giving last force within cell 35 37 36 38 AtomInfo(); 37 ~AtomInfo(); 39 AtomInfo(const AtomInfo &_atom); 40 AtomInfo(const VectorInterface &_v); 41 virtual ~AtomInfo(); 38 42 39 const element *getType() ;43 const element *getType() const; 40 44 void setType(const element *); 41 void setType(int); 45 void setType(const int); 46 47 ///// manipulation of the atomic position 48 49 // Accessors ussually come in pairs... and sometimes even more than that 50 const double& operator[](size_t i) const; 51 const double& at(size_t i) const; 52 void set(size_t i, const double value); 53 const Vector& getPosition() const; 54 55 // Assignment operator 56 void setPosition(const Vector& _vector); 57 class VectorInterface &operator=(const Vector& _vector); 58 59 // operators for mathematical operations 60 const VectorInterface& operator+=(const Vector& b); 61 const VectorInterface& operator-=(const Vector& b); 62 Vector const operator+(const Vector& b) const; 63 Vector const operator-(const Vector& b) const; 64 65 void Zero(); 66 void One(const double one); 67 void LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors); 68 69 double distance(const Vector &point) const; 70 double DistanceSquared(const Vector &y) const; 71 double distance(const VectorInterface &_atom) const; 72 double DistanceSquared(const VectorInterface &_atom) const; 73 74 void ScaleAll(const double *factor); 75 void ScaleAll(const Vector &factor); 76 void Scale(const double factor); 77 78 std::ostream & operator << (std::ostream &ost) const; 42 79 43 80 private: 81 Vector AtomicPosition; //!< coordinate vector of atom, giving last position within cell 82 const element *AtomicElement; //!< pointing to element 44 83 }; 45 84 85 std::ostream & operator << (std::ostream &ost, const AtomInfo &a); 86 87 const AtomInfo& operator*=(AtomInfo& a, const double m); 88 AtomInfo const operator*(const AtomInfo& a, const double m); 89 AtomInfo const operator*(const double m, const AtomInfo& a); 90 46 91 #endif /* ATOM_ATOMINFO_HPP_ */ -
src/atom_bondedparticle.cpp
r8d6d31 r8f4df1 152 152 NoBonds = CountBonds(); 153 153 //Log() << Verbose(3) << "Walker " << *this << ": " << (int)this->type->NoValenceOrbitals << " > " << NoBonds << "?" << endl; 154 if ((int)( type->NoValenceOrbitals) > NoBonds) { // we have a mismatch, check all bonding partners for mismatch154 if ((int)(getType()->NoValenceOrbitals) > NoBonds) { // we have a mismatch, check all bonding partners for mismatch 155 155 for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner)) { 156 156 OtherWalker = (*Runner)->GetOtherAtom(this); 157 157 OtherNoBonds = OtherWalker->CountBonds(); 158 158 //Log() << Verbose(3) << "OtherWalker " << *OtherWalker << ": " << (int)OtherWalker->type->NoValenceOrbitals << " > " << OtherNoBonds << "?" << endl; 159 if ((int)(OtherWalker-> type->NoValenceOrbitals) > OtherNoBonds) { // check if possible candidate159 if ((int)(OtherWalker->getType()->NoValenceOrbitals) > OtherNoBonds) { // check if possible candidate 160 160 if ((CandidateBond == NULL) || (ListOfBonds.size() > OtherWalker->ListOfBonds.size())) { // pick the one with fewer number of bonds first 161 161 CandidateBond = (*Runner); … … 189 189 }; 190 190 191 std::ostream & BondedParticle::operator << (std::ostream &ost) const 192 { 193 ParticleInfo::operator<<(ost); 194 ost << "," << getPosition(); 195 return ost; 196 } 197 198 std::ostream & operator << (std::ostream &ost, const BondedParticle &a) 199 { 200 a.ParticleInfo::operator<<(ost); 201 ost << "," << a.getPosition(); 202 return ost; 203 } 204 -
src/atom_bondedparticle.hpp
r8d6d31 r8f4df1 49 49 void OutputOrder(ofstream *file) const; 50 50 51 std::ostream & operator << (std::ostream &ost) const; 52 51 53 private: 52 54 53 55 }; 54 56 57 std::ostream & operator << (std::ostream &ost, const BondedParticle &a); 55 58 56 59 #endif /* ATOM_BONDEDPARTICLE_HPP_ */ -
src/atom_bondedparticleinfo.hpp
r8d6d31 r8f4df1 36 36 37 37 BondedParticleInfo(); 38 ~BondedParticleInfo();38 virtual ~BondedParticleInfo(); 39 39 40 40 private: -
src/atom_graphnodeinfo.hpp
r8d6d31 r8f4df1 37 37 38 38 GraphNodeInfo(); 39 ~GraphNodeInfo();39 virtual ~GraphNodeInfo(); 40 40 private: 41 41 -
src/atom_particleinfo.cpp
r8d6d31 r8f4df1 38 38 ostream & operator << (ostream &ost, const ParticleInfo &a) 39 39 { 40 ost << "[" << a.getName() << "|" << &a << "]";40 ost << a.getName(); 41 41 return ost; 42 42 }; … … 44 44 ostream & ParticleInfo::operator << (ostream &ost) const 45 45 { 46 ost << "[" << name << "|" << this << "]";46 ost << getName(); 47 47 return ost; 48 48 }; -
src/atom_particleinfo.hpp
r8d6d31 r8f4df1 32 32 ParticleInfo(); 33 33 ParticleInfo(ParticleInfo*); 34 ~ParticleInfo();34 virtual ~ParticleInfo(); 35 35 36 36 const std::string& getName() const; -
src/atom_trajectoryparticle.cpp
r8d6d31 r8f4df1 38 38 { 39 39 for (int i=NDIM;i--;) 40 *temperature += type->mass * Trajectory.U.at(step)[i]* Trajectory.U.at(step)[i];40 *temperature += getType()->mass * Trajectory.U.at(step)[i]* Trajectory.U.at(step)[i]; 41 41 }; 42 42 … … 65 65 for(int d=0;d<NDIM;d++) { 66 66 Trajectory.U.at(Step)[d] -= CoGVelocity->at(d); 67 *ActualTemp += 0.5 * type->mass * Trajectory.U.at(Step)[d] * Trajectory.U.at(Step)[d];67 *ActualTemp += 0.5 * getType()->mass * Trajectory.U.at(Step)[d] * Trajectory.U.at(Step)[d]; 68 68 } 69 69 }; … … 113 113 Trajectory.R.at(NextStep)[d] = Trajectory.R.at(NextStep-1)[d]; 114 114 Trajectory.R.at(NextStep)[d] += configuration->Deltat*(Trajectory.U.at(NextStep-1)[d]); // s(t) = s(0) + v * deltat + 1/2 a * deltat^2 115 Trajectory.R.at(NextStep)[d] += 0.5*configuration->Deltat*configuration->Deltat*(Trajectory.F.at(NextStep)[d]/ type->mass); // F = m * a and s =115 Trajectory.R.at(NextStep)[d] += 0.5*configuration->Deltat*configuration->Deltat*(Trajectory.F.at(NextStep)[d]/getType()->mass); // F = m * a and s = 116 116 } 117 117 // Update U 118 118 for (int d=0; d<NDIM; d++) { 119 119 Trajectory.U.at(NextStep)[d] = Trajectory.U.at(NextStep-1)[d]; 120 Trajectory.U.at(NextStep)[d] += configuration->Deltat * (Trajectory.F.at(NextStep)[d]+Trajectory.F.at(NextStep-1)[d]/ type->mass); // v = F/m * t120 Trajectory.U.at(NextStep)[d] += configuration->Deltat * (Trajectory.F.at(NextStep)[d]+Trajectory.F.at(NextStep-1)[d]/getType()->mass); // v = F/m * t 121 121 } 122 122 // Update R (and F) … … 137 137 void TrajectoryParticle::SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) const 138 138 { 139 *TotalMass += type->mass; // sum up total mass139 *TotalMass += getType()->mass; // sum up total mass 140 140 for(int d=0;d<NDIM;d++) { 141 TotalVelocity->at(d) += Trajectory.U.at(Step)[d]* type->mass;141 TotalVelocity->at(d) += Trajectory.U.at(Step)[d]*getType()->mass; 142 142 } 143 143 }; … … 154 154 for (int d=0; d<NDIM; d++) { 155 155 U[d] *= ScaleTempFactor; 156 *ekin += 0.5* type->mass * U[d]*U[d];156 *ekin += 0.5*getType()->mass * U[d]*U[d]; 157 157 } 158 158 }; … … 170 170 for (int d=0; d<NDIM; d++) { 171 171 *G += U[d] * F[d]; 172 *E += U[d]*U[d]* type->mass;172 *E += U[d]*U[d]*getType()->mass; 173 173 } 174 174 }; … … 185 185 if (FixedIon == 0) // even FixedIon moves, only not by other's forces 186 186 for (int d=0; d<NDIM; d++) { 187 U[d] += configuration->Deltat/ type->mass * ( (G_over_E) * (U[d]*type->mass) );188 *ekin += type->mass * U[d]*U[d];187 U[d] += configuration->Deltat/getType()->mass * ( (G_over_E) * (U[d]*getType()->mass) ); 188 *ekin += getType()->mass * U[d]*U[d]; 189 189 } 190 190 }; … … 198 198 void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration) 199 199 { 200 double sigma = sqrt(configuration->Thermostats->TargetTemp/ type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)200 double sigma = sqrt(configuration->Thermostats->TargetTemp/getType()->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime) 201 201 Vector &U = Trajectory.U.at(Step); 202 202 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces … … 211 211 } 212 212 for (int d=0; d<NDIM; d++) 213 *ekin += 0.5* type->mass * U[d]*U[d];213 *ekin += 0.5*getType()->mass * U[d]*U[d]; 214 214 } 215 215 }; … … 227 227 for (int d=0; d<NDIM; d++) { 228 228 U[d] *= sqrt(1+(configuration->Deltat/configuration->Thermostats->TempFrequency)*(ScaleTempFactor-1)); 229 *ekin += 0.5* type->mass * U[d]*U[d];229 *ekin += 0.5*getType()->mass * U[d]*U[d]; 230 230 } 231 231 } … … 241 241 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 242 242 for (int d=0; d<NDIM; d++) { 243 *delta_alpha += U[d]*U[d]* type->mass;243 *delta_alpha += U[d]*U[d]*getType()->mass; 244 244 } 245 245 } … … 256 256 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 257 257 for (int d=0; d<NDIM; d++) { 258 U[d] += configuration->Deltat/ type->mass * (configuration->Thermostats->alpha * (U[d] * type->mass));259 *ekin += (0.5* type->mass) * U[d]*U[d];258 U[d] += configuration->Deltat/getType()->mass * (configuration->Thermostats->alpha * (U[d] * getType()->mass)); 259 *ekin += (0.5*getType()->mass) * U[d]*U[d]; 260 260 } 261 261 } 262 262 }; 263 264 265 std::ostream & TrajectoryParticle::operator << (std::ostream &ost) const 266 { 267 ParticleInfo::operator<<(ost); 268 ost << "," << getPosition(); 269 return ost; 270 } 271 272 std::ostream & operator << (std::ostream &ost, const TrajectoryParticle &a) 273 { 274 a.ParticleInfo::operator<<(ost); 275 ost << "," << a.getPosition(); 276 return ost; 277 } 278 -
src/atom_trajectoryparticle.hpp
r8d6d31 r8f4df1 63 63 void Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration); 64 64 65 std::ostream & operator << (std::ostream &ost) const; 66 65 67 private: 66 67 68 }; 68 69 70 ostream & operator << (ostream &ost, const TrajectoryParticle &a); 69 71 70 72 #endif /* ATOM_TRAJECTORYPARTICLE_HPP_ */ -
src/atom_trajectoryparticleinfo.hpp
r8d6d31 r8f4df1 36 36 37 37 TrajectoryParticleInfo(); 38 ~TrajectoryParticleInfo();38 virtual ~TrajectoryParticleInfo(); 39 39 40 40 private: -
src/bond.cpp
r8d6d31 r8f4df1 7 7 #include "Helpers/MemDebug.hpp" 8 8 9 #include "Helpers/Log.hpp" 9 10 #include "Helpers/Verbose.hpp" 10 11 #include "atom.hpp" … … 35 36 { 36 37 if ((left != NULL) && (right != NULL)) { 37 if ((left-> type != NULL) && (left->type->Z == 1))38 if ((left->getType() != NULL) && (left->getType()->Z == 1)) 38 39 HydrogenBond++; 39 if ((right-> type != NULL) && (right->type->Z == 1))40 if ((right->getType() != NULL) && (right->getType()->Z == 1)) 40 41 HydrogenBond++; 41 42 } … … 126 127 double bond::GetDistance() const 127 128 { 128 return (leftatom-> node->distance(*rightatom->node));129 return (leftatom->distance(*rightatom)); 129 130 }; 130 131 … … 134 135 double bond::GetDistanceSquared() const 135 136 { 136 return (leftatom-> node->DistanceSquared(*rightatom->node));137 return (leftatom->DistanceSquared(*rightatom)); 137 138 }; -
src/bondgraph.cpp
r8d6d31 r8f4df1 128 128 129 129 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 130 if ((*iter)-> type->CovalentRadius > max_distance)131 max_distance = (*iter)-> type->CovalentRadius;130 if ((*iter)->getType()->CovalentRadius > max_distance) 131 max_distance = (*iter)->getType()->CovalentRadius; 132 132 } 133 133 max_distance *= 2.; … … 145 145 void BondGraph::CovalentMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker, double &MinDistance, double &MaxDistance, bool IsAngstroem) 146 146 { 147 MinDistance = OtherWalker-> type->CovalentRadius + Walker->type->CovalentRadius;147 MinDistance = OtherWalker->getType()->CovalentRadius + Walker->getType()->CovalentRadius; 148 148 MinDistance *= (IsAngstroem) ? 1. : 1. / AtomicLengthToAngstroem; 149 149 MaxDistance = MinDistance + BONDTHRESHOLD; … … 166 166 CovalentMinMaxDistance(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 167 167 } else { 168 MinDistance = GetBondLength(Walker-> type->Z-1, OtherWalker->type->Z-1);168 MinDistance = GetBondLength(Walker->getType()->Z-1, OtherWalker->getType()->Z-1); 169 169 MinDistance *= (IsAngstroem) ? 1. : 1. / AtomicLengthToAngstroem; 170 170 MaxDistance = MinDistance + BONDTHRESHOLD; -
src/boundary.cpp
r8d6d31 r8f4df1 7 7 8 8 #include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp" 9 #include "BoundaryPointSet.hpp" 10 #include "BoundaryLineSet.hpp" 11 #include "BoundaryTriangleSet.hpp" 12 #include "CandidateForTesselation.hpp" 13 //#include "TesselPoint.hpp" 9 14 #include "World.hpp" 10 15 #include "atom.hpp" … … 87 92 if (Neighbour == BoundaryPoints[axis].end()) // make it wrap around 88 93 Neighbour = BoundaryPoints[axis].begin(); 89 DistanceVector = runner->second.second->x - Neighbour->second.second->x;94 DistanceVector = (runner->second.second->getPosition()) - (Neighbour->second.second->getPosition()); 90 95 do { // seek for neighbour pair where it flips 91 96 OldComponent = DistanceVector[Othercomponent]; … … 93 98 if (Neighbour == BoundaryPoints[axis].end()) // make it wrap around 94 99 Neighbour = BoundaryPoints[axis].begin(); 95 DistanceVector = runner->second.second->x - Neighbour->second.second->x;100 DistanceVector = (runner->second.second->getPosition()) - (Neighbour->second.second->getPosition()); 96 101 //Log() << Verbose(2) << "OldComponent is " << OldComponent << ", new one is " << DistanceVector.x[Othercomponent] << "." << endl; 97 102 } while ((runner != Neighbour) && (fabs(OldComponent / fabs( … … 105 110 //Log() << Verbose(1) << "The pair, where the sign of OtherComponent flips, is: " << *(Neighbour->second.second) << " and " << *(OtherNeighbour->second.second) << "." << endl; 106 111 // now we have found the pair: Neighbour and OtherNeighbour 107 OtherVector = runner->second.second->x - OtherNeighbour->second.second->x;112 OtherVector = (runner->second.second->getPosition()) - (OtherNeighbour->second.second->getPosition()); 108 113 //Log() << Verbose(1) << "Distances to Neighbour and OtherNeighbour are " << DistanceVector.x[component] << " and " << OtherVector.x[component] << "." << endl; 109 114 //Log() << Verbose(1) << "OtherComponents to Neighbour and OtherNeighbour are " << DistanceVector.x[Othercomponent] << " and " << OtherVector.x[Othercomponent] << "." << endl; … … 173 178 // 3b. construct set of all points, transformed into cylindrical system and with left and right neighbours 174 179 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 175 ProjectedVector = (*iter)-> x- (*MolCenter);180 ProjectedVector = (*iter)->getPosition() - (*MolCenter); 176 181 ProjectedVector.ProjectOntoPlane(AxisVector); 177 182 … … 199 204 DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl); 200 205 } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) { 201 helper = (*iter)->x; 202 helper -= *MolCenter; 206 helper = (*iter)->getPosition() - (*MolCenter); 203 207 const double oldhelperNorm = helper.NormSquared(); 204 helper = BoundaryTestPair.first->second.second-> x- (*MolCenter);208 helper = BoundaryTestPair.first->second.second->getPosition() - (*MolCenter); 205 209 if (helper.NormSquared() < oldhelperNorm) { 206 210 BoundaryTestPair.first->second.second = (*iter); … … 255 259 { 256 260 Vector SideA, SideB, SideC, SideH; 257 SideA = left->second.second-> x- (*MolCenter);261 SideA = left->second.second->getPosition() - (*MolCenter); 258 262 SideA.ProjectOntoPlane(AxisVector); 259 263 // Log() << Verbose(1) << "SideA: " << SideA << endl; 260 264 261 SideB = right->second.second-> x-(*MolCenter);265 SideB = right->second.second->getPosition() -(*MolCenter); 262 266 SideB.ProjectOntoPlane(AxisVector); 263 267 // Log() << Verbose(1) << "SideB: " << SideB << endl; 264 268 265 SideC = left->second.second-> x - right->second.second->x;269 SideC = left->second.second->getPosition() - right->second.second->getPosition(); 266 270 SideC.ProjectOntoPlane(AxisVector); 267 271 // Log() << Verbose(1) << "SideC: " << SideC << endl; 268 272 269 SideH = runner->second.second-> x-(*MolCenter);273 SideH = runner->second.second->getPosition() -(*MolCenter); 270 274 SideH.ProjectOntoPlane(AxisVector); 271 275 // Log() << Verbose(1) << "SideH: " << SideH << endl; … … 701 705 // sum up the atomic masses 702 706 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 703 totalmass += (*iter)-> type->mass;707 totalmass += (*iter)->getType()->mass; 704 708 } 705 709 DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl); … … 857 861 858 862 // ... and put at new position 859 Inserter = (*iter)-> x;863 Inserter = (*iter)->getPosition(); 860 864 if (DoRandomRotation) 861 865 Inserter *= Rotations; … … 882 886 // copy atom ... 883 887 CopyAtoms[(*iter)->nr] = (*iter)->clone(); 884 CopyAtoms[(*iter)->nr]->x = Inserter;888 (*CopyAtoms[(*iter)->nr]).setPosition(Inserter); 885 889 Filling->AddAtom(CopyAtoms[(*iter)->nr]); 886 DoLog( 4) && (Log() << Verbose(4) << "Filling atom " << **iter << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[(*iter)->nr]->x) << "." << endl);890 DoLog(1) && (Log() << Verbose(1) << "Filling atom " << **iter << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[(*iter)->nr]->getPosition()) << "." << endl); 887 891 } else { 888 892 DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl); -
src/config.cpp
r8d6d31 r8f4df1 439 439 map<int, atom *> LinearList; 440 440 atom *neues = NULL; 441 Vector position; 441 442 if (!FastParsing) { 442 443 // parse in trajectories … … 452 453 AtomList[i][j] = neues; 453 454 LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues; 454 neues-> type = elementhash[i]; // find element type455 neues->setType(elementhash[i]); // find element type 455 456 } else 456 457 neues = AtomList[i][j]; 457 458 status = (status && 458 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, & neues->x[0], 1, (repetition == 0) ? critical : optional) &&459 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, & neues->x[1], 1, (repetition == 0) ? critical : optional) &&460 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, & neues->x[2], 1, (repetition == 0) ? critical : optional) &&459 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &position[0], 1, (repetition == 0) ? critical : optional) && 460 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &position[1], 1, (repetition == 0) ? critical : optional) && 461 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &position[2], 1, (repetition == 0) ? critical : optional) && 461 462 ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &neues->FixedIon, 1, (repetition == 0) ? critical : optional)); 462 if (!status) break; 463 if (!status) 464 break; 465 neues ->setPosition(position); 463 466 464 467 // check size of vectors … … 472 475 // put into trajectories list 473 476 for (int d=0;d<NDIM;d++) 474 neues->Trajectory.R.at(repetition)[d] = neues-> x[d];477 neues->Trajectory.R.at(repetition)[d] = neues->at(d); 475 478 476 479 // parse velocities if present 477 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues-> v[0], 1,optional))478 neues-> v[0] = 0.;479 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues-> v[1], 1,optional))480 neues-> v[1] = 0.;481 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues-> v[2], 1,optional))482 neues-> v[2] = 0.;480 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->AtomicVelocity[0], 1,optional)) 481 neues->AtomicVelocity[0] = 0.; 482 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->AtomicVelocity[1], 1,optional)) 483 neues->AtomicVelocity[1] = 0.; 484 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->AtomicVelocity[2], 1,optional)) 485 neues->AtomicVelocity[2] = 0.; 483 486 for (int d=0;d<NDIM;d++) 484 neues->Trajectory.U.at(repetition)[d] = neues-> v[d];487 neues->Trajectory.U.at(repetition)[d] = neues->AtomicVelocity[d]; 485 488 486 489 // parse forces if present … … 531 534 AtomList[i][j] = neues; 532 535 LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues; 533 neues-> type = elementhash[i]; // find element type536 neues->setType(elementhash[i]); // find element type 534 537 } else 535 538 neues = AtomList[i][j]; 536 539 // then parse for each atom the coordinates as often as present 537 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &neues->x[0], repetition,critical); 538 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &neues->x[1], repetition,critical); 539 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &neues->x[2], repetition,critical); 540 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &position[0], repetition,critical); 541 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &position[1], repetition,critical); 542 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &position[2], repetition,critical); 543 neues->setPosition(position); 540 544 ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &neues->FixedIon, repetition,critical); 541 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues-> v[0], repetition,optional))542 neues-> v[0] = 0.;543 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues-> v[1], repetition,optional))544 neues-> v[1] = 0.;545 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues-> v[2], repetition,optional))546 neues-> v[2] = 0.;545 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->AtomicVelocity[0], repetition,optional)) 546 neues->AtomicVelocity[0] = 0.; 547 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->AtomicVelocity[1], repetition,optional)) 548 neues->AtomicVelocity[1] = 0.; 549 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->AtomicVelocity[2], repetition,optional)) 550 neues->AtomicVelocity[2] = 0.; 547 551 // here we don't care if forces are present (last in trajectories is always equal to current position) 548 neues-> type = elementhash[i]; // find element type552 neues->setType(elementhash[i]); // find element type 549 553 mol->AddAtom(neues); 550 554 } … … 1009 1013 istringstream input2(zeile); 1010 1014 atom *neues = World::getInstance().createAtom(); 1011 input2 >> neues->x[0]; // x 1012 input2 >> neues->x[1]; // y 1013 input2 >> neues->x[2]; // z 1015 double tmp; 1016 for (int j=0;j<NDIM;j++) { 1017 input2 >> tmp; 1018 neues->set(j,tmp); 1019 } 1014 1020 input2 >> l; 1015 neues-> type = elementhash[No]; // find element type1021 neues->setType(elementhash[No]); // find element type 1016 1022 mol->AddAtom(neues); 1017 1023 } … … 1279 1285 AtomNo = 0; 1280 1286 for (molecule::const_iterator iter = (*MolRunner)->begin(); iter != (*MolRunner)->end(); ++iter) { 1281 sprintf(name, "%2s%2d",(*iter)-> type->symbol, elementNo[(*iter)->type->Z]);1282 elementNo[(*iter)-> type->Z] = (elementNo[(*iter)->type->Z]+1) % 100; // confine to two digits1287 sprintf(name, "%2s%2d",(*iter)->getType()->symbol, elementNo[(*iter)->getType()->Z]); 1288 elementNo[(*iter)->getType()->Z] = (elementNo[(*iter)->getType()->Z]+1) % 100; // confine to two digits 1283 1289 fprintf(f, 1284 1290 "ATOM %6u %-4s %4s%c%4u %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%2s\n", … … 1288 1294 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1289 1295 MolNo, /* residue sequence number */ 1290 (*iter)-> node->at(0), /* position X in Angstroem */1291 (*iter)-> node->at(1), /* position Y in Angstroem */1292 (*iter)-> node->at(2), /* position Z in Angstroem */1293 (double)(*iter)-> type->Valence, /* occupancy */1294 (double)(*iter)-> type->NoValenceOrbitals, /* temperature factor */1296 (*iter)->at(0), /* position X in Angstroem */ 1297 (*iter)->at(1), /* position Y in Angstroem */ 1298 (*iter)->at(2), /* position Z in Angstroem */ 1299 (double)(*iter)->getType()->Valence, /* occupancy */ 1300 (double)(*iter)->getType()->NoValenceOrbitals, /* temperature factor */ 1295 1301 "0", /* segment identifier */ 1296 (*iter)-> type->symbol, /* element symbol */1302 (*iter)->getType()->symbol, /* element symbol */ 1297 1303 "0"); /* charge */ 1298 1304 AtomNo++; … … 1332 1338 AtomNo = 0; 1333 1339 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1334 sprintf(name, "%2s%2d",(*iter)-> type->symbol, elementNo[(*iter)->type->Z]);1335 elementNo[(*iter)-> type->Z] = (elementNo[(*iter)->type->Z]+1) % 100; // confine to two digits1340 sprintf(name, "%2s%2d",(*iter)->getType()->symbol, elementNo[(*iter)->getType()->Z]); 1341 elementNo[(*iter)->getType()->Z] = (elementNo[(*iter)->getType()->Z]+1) % 100; // confine to two digits 1336 1342 fprintf(f, 1337 1343 "ATOM %6u %-4s %4s%c%4u %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%2s\n", … … 1341 1347 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1342 1348 0, /* residue sequence number */ 1343 (*iter)-> node->at(0), /* position X in Angstroem */1344 (*iter)-> node->at(1), /* position Y in Angstroem */1345 (*iter)-> node->at(2), /* position Z in Angstroem */1346 (double)(*iter)-> type->Valence, /* occupancy */1347 (double)(*iter)-> type->NoValenceOrbitals, /* temperature factor */1349 (*iter)->at(0), /* position X in Angstroem */ 1350 (*iter)->at(1), /* position Y in Angstroem */ 1351 (*iter)->at(2), /* position Z in Angstroem */ 1352 (double)(*iter)->getType()->Valence, /* occupancy */ 1353 (double)(*iter)->getType()->NoValenceOrbitals, /* temperature factor */ 1348 1354 "0", /* segment identifier */ 1349 (*iter)-> type->symbol, /* element symbol */1355 (*iter)->getType()->symbol, /* element symbol */ 1350 1356 "0"); /* charge */ 1351 1357 AtomNo++; … … 1390 1396 *output << mol->name << "\t"; 1391 1397 *output << 0 << "\t"; 1392 *output << (*iter)-> node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t";1393 *output << static_cast<double>((*iter)-> type->Valence) << "\t";1394 *output << (*iter)-> type->symbol << "\t";1398 *output << (*iter)->at(0) << "\t" << (*iter)->at(1) << "\t" << (*iter)->at(2) << "\t"; 1399 *output << static_cast<double>((*iter)->getType()->Valence) << "\t"; 1400 *output << (*iter)->getType()->symbol << "\t"; 1395 1401 for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++) 1396 1402 *output << (*runner)->GetOtherAtom(*iter)->nr << "\t"; … … 1462 1468 *output << (*MolWalker)->name << "\t"; 1463 1469 *output << MolCounter+1 << "\t"; 1464 *output << (*iter)-> node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t";1465 *output << (double)(*iter)-> type->Valence << "\t";1466 *output << (*iter)-> type->symbol << "\t";1470 *output << (*iter)->at(0) << "\t" << (*iter)->at(1) << "\t" << (*iter)->at(2) << "\t"; 1471 *output << (double)(*iter)->getType()->Valence << "\t"; 1472 *output << (*iter)->getType()->symbol << "\t"; 1467 1473 for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++) 1468 1474 *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom((*iter))->getId() ] << "\t"; -
src/ellipsoid.cpp
r8d6d31 r8f4df1 15 15 #include <set> 16 16 17 #include "BoundaryPointSet.hpp" 17 18 #include "boundary.hpp" 18 19 #include "ellipsoid.hpp" … … 304 305 if ((current != PickedAtomNrs.end()) && (*current == index)) { 305 306 Candidate = (*Runner); 306 DoLog(2) && (Log() << Verbose(2) << "Current picked node is " << **Runner<< " with index " << index << "." << endl);307 x[PointsPicked++] = *Candidate->node; // we have one more atom picked307 DoLog(2) && (Log() << Verbose(2) << "Current picked node is " << (*Runner)->getName() << " with index " << index << "." << endl); 308 x[PointsPicked++] = Candidate->getPosition(); // we have one more atom picked 308 309 current++; // next pre-picked atom 309 310 } … … 351 352 //Log() << Verbose(3) << "Current node is " << *Runner->second->node << " with " << value << " ... " << threshold << ": "; 352 353 if (value > threshold) { 353 x[PointsPicked] = ( *Runner->second->node->node);354 x[PointsPicked] = (Runner->second->node->getPosition()); 354 355 PointsPicked++; 355 356 //Log() << Verbose(0) << "IN." << endl; … … 388 389 Center.Zero(); 389 390 for (PointMap::iterator Runner = T->PointsOnBoundary.begin(); Runner != T->PointsOnBoundary.end(); Runner++) 390 Center += ( *Runner->second->node->node);391 Center += (Runner->second->node->getPosition()); 391 392 Center.Scale(1./T->PointsOnBoundaryCount); 392 393 DoLog(1) && (Log() << Verbose(1) << "Center is at " << Center << "." << endl); -
src/linkedcell.cpp
r8d6d31 r8f4df1 56 56 Walker = set->GetPoint(); 57 57 for (int i=0;i<NDIM;i++) { 58 max[i] = Walker-> node->at(i);59 min[i] = Walker-> node->at(i);58 max[i] = Walker->at(i); 59 min[i] = Walker->at(i); 60 60 } 61 61 set->GoToFirst(); … … 63 63 Walker = set->GetPoint(); 64 64 for (int i=0;i<NDIM;i++) { 65 if (max[i] < Walker-> node->at(i))66 max[i] = Walker-> node->at(i);67 if (min[i] > Walker-> node->at(i))68 min[i] = Walker-> node->at(i);65 if (max[i] < Walker->at(i)) 66 max[i] = Walker->at(i); 67 if (min[i] > Walker->at(i)) 68 min[i] = Walker->at(i); 69 69 } 70 70 set->GoToNext(); … … 96 96 Walker = set->GetPoint(); 97 97 for (int i=0;i<NDIM;i++) { 98 n[i] = static_cast<int>(floor((Walker-> node->at(i) - min[i])/RADIUS));98 n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS)); 99 99 } 100 100 index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2]; … … 130 130 LinkedNodes::iterator Runner = set->begin(); 131 131 for (int i=0;i<NDIM;i++) { 132 max[i] = (*Runner)-> node->at(i);133 min[i] = (*Runner)-> node->at(i);132 max[i] = (*Runner)->at(i); 133 min[i] = (*Runner)->at(i); 134 134 } 135 135 for (LinkedNodes::iterator Runner = set->begin(); Runner != set->end(); Runner++) { 136 136 Walker = *Runner; 137 137 for (int i=0;i<NDIM;i++) { 138 if (max[i] < Walker-> node->at(i))139 max[i] = Walker-> node->at(i);140 if (min[i] > Walker-> node->at(i))141 min[i] = Walker-> node->at(i);138 if (max[i] < Walker->at(i)) 139 max[i] = Walker->at(i); 140 if (min[i] > Walker->at(i)) 141 min[i] = Walker->at(i); 142 142 } 143 143 } … … 167 167 Walker = *Runner; 168 168 for (int i=0;i<NDIM;i++) { 169 n[i] = static_cast<int>(floor((Walker-> node->at(i) - min[i])/RADIUS));169 n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS)); 170 170 } 171 171 index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2]; … … 248 248 * \return Vector is inside bounding box - true, else - false 249 249 */ 250 bool LinkedCell::SetIndexToVector(const Vector * constx) const250 bool LinkedCell::SetIndexToVector(const Vector & x) const 251 251 { 252 252 for (int i=0;i<NDIM;i++) 253 n[i] = (int)floor((x ->at(i) - min[i])/RADIUS);253 n[i] = (int)floor((x.at(i) - min[i])/RADIUS); 254 254 255 255 return CheckBounds(); … … 264 264 bool status = false; 265 265 for (int i=0;i<NDIM;i++) { 266 n[i] = static_cast<int>(floor((Walker-> node->at(i) - min[i])/RADIUS));266 n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS)); 267 267 } 268 268 index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2]; … … 404 404 Walker = *Runner; 405 405 //Log() << Verbose(1) << "Current neighbour is at " << *Walker->node << "." << endl; 406 if (( center->DistanceSquared(*Walker->node) - radiusSquared) < MYEPSILON) {406 if ((Walker->DistanceSquared(*center) - radiusSquared) < MYEPSILON) { 407 407 TesselList->push_back(Walker); 408 408 } -
src/linkedcell.hpp
r8d6d31 r8f4df1 60 60 const LinkedCell::LinkedNodes* GetRelativeToCurrentCell(const int relative[NDIM])const ; 61 61 bool SetIndexToNode(const TesselPoint * const Walker)const ; 62 bool SetIndexToVector(const Vector * constx)const ;62 bool SetIndexToVector(const Vector &x)const ; 63 63 double SetClosestIndexToOutsideVector(const Vector * const x) const; 64 64 bool CheckBounds()const ; -
src/molecule.cpp
r8d6d31 r8f4df1 157 157 atomIds.erase( atom->getId() ); 158 158 atoms.remove( atom ); 159 formula-=atom-> type;159 formula-=atom->getType(); 160 160 atom->removeFromMolecule(); 161 161 return iter; … … 169 169 atomIds.erase( key->getId() ); 170 170 atoms.remove( key ); 171 formula-=key-> type;171 formula-=key->getType(); 172 172 key->removeFromMolecule(); 173 173 } … … 191 191 if (res.second) { // push atom if went well 192 192 atoms.push_back(key); 193 formula+=key-> type;193 formula+=key->getType(); 194 194 return pair<iterator,bool>(molecule::iterator(--end()),res.second); 195 195 } else { … … 212 212 if (pointer != NULL) { 213 213 pointer->sort = &pointer->nr; 214 if (pointer-> type!= NULL) {215 formula += pointer-> type;216 if (pointer-> type->Z != 1)214 if (pointer->getType() != NULL) { 215 formula += pointer->getType(); 216 if (pointer->getType()->Z != 1) 217 217 NoNonHydrogen++; 218 218 if(pointer->getName() == "Unknown"){ 219 219 stringstream sstr; 220 sstr << pointer-> type->symbol << pointer->nr+1;220 sstr << pointer->getType()->symbol << pointer->nr+1; 221 221 pointer->setName(sstr.str()); 222 222 } … … 239 239 if (pointer != NULL) { 240 240 atom *walker = pointer->clone(); 241 formula += walker-> type;241 formula += walker->getType(); 242 242 walker->setName(pointer->getName()); 243 243 walker->nr = last_atom++; // increase number within molecule 244 244 insert(walker); 245 if ((pointer-> type != NULL) && (pointer->type->Z != 1))245 if ((pointer->getType() != NULL) && (pointer->getType()->Z != 1)) 246 246 NoNonHydrogen++; 247 247 retval=walker; … … 301 301 // Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl; 302 302 // create vector in direction of bond 303 InBondvector = TopReplacement-> x - TopOrigin->x;303 InBondvector = TopReplacement->getPosition() - TopOrigin->getPosition(); 304 304 bondlength = InBondvector.Norm(); 305 305 … … 313 313 Orthovector1.Zero(); 314 314 for (int i=NDIM;i--;) { 315 l = TopReplacement-> x[i] - TopOrigin->x[i];315 l = TopReplacement->at(i) - TopOrigin->at(i); 316 316 if (fabs(l) > BondDistance) { // is component greater than bond distance 317 317 Orthovector1[i] = (l < 0) ? -1. : +1.; … … 328 328 InBondvector.Normalize(); 329 329 // get typical bond length and store as scale factor for later 330 ASSERT(TopOrigin-> type!= NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");331 BondRescale = TopOrigin-> type->HBondDistance[TopBond->BondDegree-1];330 ASSERT(TopOrigin->getType() != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given."); 331 BondRescale = TopOrigin->getType()->HBondDistance[TopBond->BondDegree-1]; 332 332 if (BondRescale == -1) { 333 333 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl); … … 343 343 case 1: 344 344 FirstOtherAtom = World::getInstance().createAtom(); // new atom 345 FirstOtherAtom-> type = elemente->FindElement(1); // element is Hydrogen346 FirstOtherAtom-> v = TopReplacement->v; // copy velocity345 FirstOtherAtom->setType(1); // element is Hydrogen 346 FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 347 347 FirstOtherAtom->FixedIon = TopReplacement->FixedIon; 348 if (TopReplacement-> type->Z == 1) { // neither rescale nor replace if it's already hydrogen348 if (TopReplacement->getType()->Z == 1) { // neither rescale nor replace if it's already hydrogen 349 349 FirstOtherAtom->father = TopReplacement; 350 350 BondRescale = bondlength; … … 353 353 } 354 354 InBondvector *= BondRescale; // rescale the distance vector to Hydrogen bond length 355 FirstOtherAtom->x = TopOrigin->x; // set coordination to origin ... 356 FirstOtherAtom->x += InBondvector; // ... and add distance vector to replacement atom 355 FirstOtherAtom->setPosition(TopOrigin->getPosition() + InBondvector); // set coordination to origin and add distance vector to replacement atom 357 356 AllWentWell = AllWentWell && AddAtom(FirstOtherAtom); 358 357 // Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: "; … … 387 386 // determine the plane of these two with the *origin 388 387 try { 389 Orthovector1 =Plane(TopOrigin-> x, FirstOtherAtom->x, SecondOtherAtom->x).getNormal();388 Orthovector1 =Plane(TopOrigin->getPosition(), FirstOtherAtom->getPosition(), SecondOtherAtom->getPosition()).getNormal(); 390 389 } 391 390 catch(LinearDependenceException &excp){ … … 408 407 FirstOtherAtom = World::getInstance().createAtom(); 409 408 SecondOtherAtom = World::getInstance().createAtom(); 410 FirstOtherAtom-> type = elemente->FindElement(1);411 SecondOtherAtom-> type = elemente->FindElement(1);412 FirstOtherAtom-> v = TopReplacement->v; // copy velocity409 FirstOtherAtom->setType(1); 410 SecondOtherAtom->setType(1); 411 FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 413 412 FirstOtherAtom->FixedIon = TopReplacement->FixedIon; 414 SecondOtherAtom-> v = TopReplacement->v; // copy velocity413 SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 415 414 SecondOtherAtom->FixedIon = TopReplacement->FixedIon; 416 415 FirstOtherAtom->father = NULL; // we are just an added hydrogen with no father 417 416 SecondOtherAtom->father = NULL; // we are just an added hydrogen with no father 418 bondangle = TopOrigin-> type->HBondAngle[1];417 bondangle = TopOrigin->getType()->HBondAngle[1]; 419 418 if (bondangle == -1) { 420 419 DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl); … … 430 429 // Log() << Verbose(0) << endl; 431 430 // Log() << Verbose(3) << "Half the bond angle is " << bondangle << ", sin and cos of it: " << sin(bondangle) << ", " << cos(bondangle) << endl; 432 FirstOtherAtom-> x.Zero();433 SecondOtherAtom-> x.Zero();431 FirstOtherAtom->Zero(); 432 SecondOtherAtom->Zero(); 434 433 for(int i=NDIM;i--;) { // rotate by half the bond angle in both directions (InBondvector is bondangle = 0 direction) 435 FirstOtherAtom-> x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle));436 SecondOtherAtom-> x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle));437 } 438 FirstOtherAtom-> x *= BondRescale; // rescale by correct BondDistance439 SecondOtherAtom-> x *= BondRescale;434 FirstOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle))); 435 SecondOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle))); 436 } 437 FirstOtherAtom->Scale(BondRescale); // rescale by correct BondDistance 438 SecondOtherAtom->Scale(BondRescale); 440 439 //Log() << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl; 441 for(int i=NDIM;i--;) { // and make relative to origin atom 442 FirstOtherAtom->x[i] += TopOrigin->x[i]; 443 SecondOtherAtom->x[i] += TopOrigin->x[i]; 444 } 440 *FirstOtherAtom += TopOrigin->getPosition(); 441 *SecondOtherAtom += TopOrigin->getPosition(); 445 442 // ... and add to molecule 446 443 AllWentWell = AllWentWell && AddAtom(FirstOtherAtom); … … 464 461 SecondOtherAtom = World::getInstance().createAtom(); 465 462 ThirdOtherAtom = World::getInstance().createAtom(); 466 FirstOtherAtom-> type = elemente->FindElement(1);467 SecondOtherAtom-> type = elemente->FindElement(1);468 ThirdOtherAtom-> type = elemente->FindElement(1);469 FirstOtherAtom-> v = TopReplacement->v; // copy velocity463 FirstOtherAtom->setType(1); 464 SecondOtherAtom->setType(1); 465 ThirdOtherAtom->setType(1); 466 FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 470 467 FirstOtherAtom->FixedIon = TopReplacement->FixedIon; 471 SecondOtherAtom-> v = TopReplacement->v; // copy velocity468 SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 472 469 SecondOtherAtom->FixedIon = TopReplacement->FixedIon; 473 ThirdOtherAtom-> v = TopReplacement->v; // copy velocity470 ThirdOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity 474 471 ThirdOtherAtom->FixedIon = TopReplacement->FixedIon; 475 472 FirstOtherAtom->father = NULL; // we are just an added hydrogen with no father … … 494 491 495 492 // create correct coordination for the three atoms 496 alpha = (TopOrigin-> type->HBondAngle[2])/180.*M_PI/2.; // retrieve triple bond angle from database493 alpha = (TopOrigin->getType()->HBondAngle[2])/180.*M_PI/2.; // retrieve triple bond angle from database 497 494 l = BondRescale; // desired bond length 498 495 b = 2.*l*sin(alpha); // base length of isosceles triangle … … 505 502 factors[1] = f; 506 503 factors[2] = 0.; 507 FirstOtherAtom-> x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);504 FirstOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors); 508 505 factors[1] = -0.5*f; 509 506 factors[2] = g; 510 SecondOtherAtom-> x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);507 SecondOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors); 511 508 factors[2] = -g; 512 ThirdOtherAtom-> x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);509 ThirdOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors); 513 510 514 511 // rescale each to correct BondDistance … … 518 515 519 516 // and relative to *origin atom 520 FirstOtherAtom->x += TopOrigin->x;521 SecondOtherAtom->x += TopOrigin->x;522 ThirdOtherAtom->x += TopOrigin->x;517 *FirstOtherAtom += TopOrigin->getPosition(); 518 *SecondOtherAtom += TopOrigin->getPosition(); 519 *ThirdOtherAtom += TopOrigin->getPosition(); 523 520 524 521 // ... and add to molecule … … 596 593 *item >> x[1]; 597 594 *item >> x[2]; 598 Walker-> type = elemente->FindElement(shorthand);599 if (Walker-> type== NULL) {595 Walker->setType(elemente->FindElement(shorthand)); 596 if (Walker->getType() == NULL) { 600 597 DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H."); 601 Walker-> type = elemente->FindElement(1);598 Walker->setType(1); 602 599 } 603 600 if (Walker->Trajectory.R.size() <= (unsigned int)MDSteps) { … … 606 603 Walker->Trajectory.F.resize(MDSteps+10); 607 604 } 605 Walker->setPosition(Vector(x)); 608 606 for(j=NDIM;j--;) { 609 Walker->x[j] = x[j];610 607 Walker->Trajectory.R.at(MDSteps-1)[j] = x[j]; 611 608 Walker->Trajectory.U.at(MDSteps-1)[j] = 0; … … 702 699 atom1->RegisterBond(Binder); 703 700 atom2->RegisterBond(Binder); 704 if ((atom1-> type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))701 if ((atom1->getType() != NULL) && (atom1->getType()->Z != 1) && (atom2->getType() != NULL) && (atom2->getType()->Z != 1)) 705 702 NoNonBonds++; 706 703 … … 776 773 ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom()."); 777 774 OBSERVE; 778 formula-=pointer-> type;775 formula-=pointer->getType(); 779 776 RemoveBonds(pointer); 780 777 erase(pointer); … … 790 787 if (pointer == NULL) 791 788 return false; 792 formula-=pointer-> type;789 formula-=pointer->getType(); 793 790 erase(pointer); 794 791 return true; … … 972 969 for (molecule::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) { 973 970 (*iter)->nr = i; // update number in molecule (for easier referencing in FragmentMolecule lateron) 974 if ((*iter)-> type->Z != 1) // count non-hydrogen atoms whilst at it971 if ((*iter)->getType()->Z != 1) // count non-hydrogen atoms whilst at it 975 972 NoNonHydrogen++; 976 973 stringstream sstr; 977 sstr << (*iter)-> type->symbol << (*iter)->nr+1;974 sstr << (*iter)->getType()->symbol << (*iter)->nr+1; 978 975 (*iter)->setName(sstr.str()); 979 976 DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl); -
src/molecule.hpp
r8d6d31 r8f4df1 164 164 bool IsEmpty() const ; 165 165 bool IsEnd() const ; 166 167 // templates for allowing global manipulation of all vectors168 template <typename res> void ActOnAllVectors( res (Vector::*f)() ) const;169 template <typename res> void ActOnAllVectors( res (Vector::*f)() const) const;170 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T), T t ) const;171 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T) const, T t ) const;172 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T&), T &t ) const;173 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const;174 template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const;175 template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const;176 template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const;177 template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const;178 166 179 167 // templates for allowing global manipulation of molecule with each atom as single argument -
src/molecule_dynamics.cpp
r8d6d31 r8f4df1 513 513 Sprinter = mol->AddCopyAtom((*iter)); 514 514 for (int n=NDIM;n--;) { 515 Sprinter-> x[n] = (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);515 Sprinter->set(n, (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps)); 516 516 // add to Trajectories 517 517 //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl; -
src/molecule_fragmentation.cpp
r8d6d31 r8f4df1 451 451 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 452 452 #ifdef ADDHYDROGEN 453 if ((*iter)-> type->Z != 1) // skip hydrogen453 if ((*iter)->getType()->Z != 1) // skip hydrogen 454 454 #endif 455 455 { … … 471 471 for(molecule::const_iterator iter = begin(); iter != end(); ++iter) { 472 472 #ifdef ADDHYDROGEN 473 if ((*iter)-> type->Z != 1) // skip hydrogen473 if ((*iter)->getType()->Z != 1) // skip hydrogen 474 474 #endif 475 475 { … … 880 880 for (KeySet::iterator runner = Leaf->begin(); runner != Leaf->end(); runner++) { 881 881 Runner = FindAtom((*runner)); 882 if (Runner-> type->Z != 1) { // skip all those added hydrogens when re-filling snake stack882 if (Runner->getType()->Z != 1) { // skip all those added hydrogens when re-filling snake stack 883 883 if (ShortestPathList[(*runner)] > SP) { // remove the oldest one with longest shortest path 884 884 SP = ShortestPathList[(*runner)]; … … 969 969 ++iter; 970 970 #ifdef ADDHYDROGEN 971 while ((iter != Leaf->end()) && ((*iter)-> type->Z == 1)){ // skip added hydrogen971 while ((iter != Leaf->end()) && ((*iter)->getType()->Z == 1)){ // skip added hydrogen 972 972 iter++; 973 973 } … … 1347 1347 if ((RestrictedKeySet.find(OtherWalker->nr) != RestrictedKeySet.end()) 1348 1348 #ifdef ADDHYDROGEN 1349 && (OtherWalker-> type->Z != 1)1349 && (OtherWalker->getType()->Z != 1) 1350 1350 #endif 1351 1351 ) { // skip hydrogens and restrict to fragment … … 1741 1741 Binder = (*BondRunner); 1742 1742 for (int i=NDIM;i--;) { 1743 tmp = fabs(Binder->leftatom-> x[i] - Binder->rightatom->x[i]);1743 tmp = fabs(Binder->leftatom->at(i) - Binder->rightatom->at(i)); 1744 1744 //Log() << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl; 1745 1745 if (tmp > BondDistance) { … … 1755 1755 // create translation vector from their periodically modified distance 1756 1756 for (int i=NDIM;i--;) { 1757 tmp = Binder->leftatom-> x[i] - Binder->rightatom->x[i];1757 tmp = Binder->leftatom->at(i) - Binder->rightatom->at(i); 1758 1758 if (fabs(tmp) > BondDistance) 1759 1759 Translationvector[i] = (tmp < 0) ? +1. : -1.; … … 1770 1770 //Log() << Verbose (3) << "Current Walker is: " << *Walker << "." << endl; 1771 1771 ColorList[Walker->nr] = black; // mark as explored 1772 Walker->x+= Translationvector; // translate1772 *Walker += Translationvector; // translate 1773 1773 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { 1774 1774 if ((*Runner) != Binder) { -
src/molecule_geometry.cpp
r8d6d31 r8f4df1 48 48 49 49 // go through all atoms 50 ActOnAllVectors( &Vector::SubtractVector, *Center); 51 ActOnAllVectors( &Vector::SubtractVector, *CenterBox); 50 BOOST_FOREACH(atom* iter, atoms){ 51 *iter -= *Center; 52 *iter -= *CenterBox; 53 } 52 54 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 53 55 … … 66 68 Box &domain = World::getInstance().getDomain(); 67 69 70 // go through all atoms 68 71 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 69 72 … … 83 86 if (iter != end()) { //list not empty? 84 87 for (int i=NDIM;i--;) { 85 max->at(i) = (*iter)-> x[i];86 min->at(i) = (*iter)-> x[i];88 max->at(i) = (*iter)->at(i); 89 min->at(i) = (*iter)->at(i); 87 90 } 88 91 for (; iter != end(); ++iter) {// continue with second if present 89 92 //(*iter)->Output(1,1,out); 90 93 for (int i=NDIM;i--;) { 91 max->at(i) = (max->at(i) < (*iter)-> x[i]) ? (*iter)->x[i]: max->at(i);92 min->at(i) = (min->at(i) > (*iter)-> x[i]) ? (*iter)->x[i]: min->at(i);94 max->at(i) = (max->at(i) < (*iter)->at(i)) ? (*iter)->at(i) : max->at(i); 95 min->at(i) = (min->at(i) > (*iter)->at(i)) ? (*iter)->at(i) : min->at(i); 93 96 } 94 97 } … … 121 124 for (; iter != end(); ++iter) { // continue with second if present 122 125 Num++; 123 Center += (*iter)-> x;126 Center += (*iter)->getPosition(); 124 127 } 125 128 Center.Scale(-1./(double)Num); // divide through total number (and sign for direction) … … 143 146 for (; iter != end(); ++iter) { // continue with second if present 144 147 Num++; 145 (*a) += (*iter)-> x;148 (*a) += (*iter)->getPosition(); 146 149 } 147 150 a->Scale(1./(double)Num); // divide through total mass (and sign for direction) … … 176 179 if (iter != end()) { //list not empty? 177 180 for (; iter != end(); ++iter) { // continue with second if present 178 Num += (*iter)-> type->mass;179 tmp = (*iter)-> type->mass * (*iter)->x;181 Num += (*iter)->getType()->mass; 182 tmp = (*iter)->getType()->mass * (*iter)->getPosition(); 180 183 (*a) += tmp; 181 184 } … … 221 224 for (int j=0;j<MDSteps;j++) 222 225 (*iter)->Trajectory.R.at(j).ScaleAll(*factor); 223 (*iter)-> x.ScaleAll(*factor);226 (*iter)->ScaleAll(*factor); 224 227 } 225 228 }; … … 233 236 for (int j=0;j<MDSteps;j++) 234 237 (*iter)->Trajectory.R.at(j) += (*trans); 235 (*iter)->x+= (*trans);238 *(*iter) += (*trans); 236 239 } 237 240 }; … … 246 249 247 250 // go through all atoms 248 ActOnAllVectors( &Vector::AddVector, *trans); 251 BOOST_FOREACH(atom* iter, atoms){ 252 *iter += *trans; 253 } 249 254 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); 250 255 … … 278 283 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 279 284 #ifdef ADDHYDROGEN 280 if ((*iter)-> type->Z != 1) {285 if ((*iter)->getType()->Z != 1) { 281 286 #endif 282 Testvector = inversematrix * (*iter)-> x;287 Testvector = inversematrix * (*iter)->getPosition(); 283 288 Translationvector.Zero(); 284 289 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 285 290 if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing 286 291 for (int j=0;j<NDIM;j++) { 287 tmp = (*iter)-> x[j] - (*Runner)->GetOtherAtom(*iter)->x[j];292 tmp = (*iter)->at(j) - (*Runner)->GetOtherAtom(*iter)->at(j); 288 293 if ((fabs(tmp)) > BondDistance) { 289 294 flag = false; … … 303 308 // now also change all hydrogens 304 309 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 305 if ((*Runner)->GetOtherAtom((*iter))-> type->Z == 1) {306 Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))-> x;310 if ((*Runner)->GetOtherAtom((*iter))->getType()->Z == 1) { 311 Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->getPosition(); 307 312 Testvector += Translationvector; 308 313 Testvector *= matrix; … … 335 340 DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... "); 336 341 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 337 tmp = (*iter)-> x[0];338 (*iter)-> x[0] = cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];339 (*iter)-> x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];342 tmp = (*iter)->at(0); 343 (*iter)->set(0, cos(alpha) * tmp + sin(alpha) * (*iter)->at(2)); 344 (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2)); 340 345 for (int j=0;j<MDSteps;j++) { 341 346 tmp = (*iter)->Trajectory.R.at(j)[0]; … … 354 359 DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... "); 355 360 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 356 tmp = (*iter)-> x[1];357 (*iter)-> x[1] = cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];358 (*iter)-> x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];361 tmp = (*iter)->at(1); 362 (*iter)->set(1, cos(alpha) * tmp + sin(alpha) * (*iter)->at(2)); 363 (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2)); 359 364 for (int j=0;j<MDSteps;j++) { 360 365 tmp = (*iter)->Trajectory.R.at(j)[1]; … … 394 399 // go through all atoms 395 400 for (molecule::const_iterator iter = par->mol->begin(); iter != par->mol->end(); ++iter) { 396 if ((*iter)-> type== ((struct lsq_params *)params)->type) { // for specific type397 c = (*iter)-> x- a;401 if ((*iter)->getType() == ((struct lsq_params *)params)->type) { // for specific type 402 c = (*iter)->getPosition() - a; 398 403 t = c.ScalarProduct(b); // get direction parameter 399 404 d = t*b; // and create vector -
src/molecule_graph.cpp
r8d6d31 r8f4df1 184 184 //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl; 185 185 (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem); 186 const double distance = domain.periodicDistanceSquared(OtherWalker-> x,Walker->x);186 const double distance = domain.periodicDistanceSquared(OtherWalker->getPosition(),Walker->getPosition()); 187 187 const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance); 188 188 // Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl; … … 737 737 OtherAtom = (*Runner)->GetOtherAtom(Walker); 738 738 #ifdef ADDHYDROGEN 739 if (OtherAtom-> type->Z != 1) {739 if (OtherAtom->getType()->Z != 1) { 740 740 #endif 741 741 DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->getName() << " for bond " << *(*Runner) << "." << endl); -
src/molecule_template.hpp
r8d6d31 r8f4df1 19 19 /********************************************** declarations *******************************/ 20 20 21 // ================== Acting on all Vectors ========================== //22 23 // zero arguments24 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const25 {26 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {27 (((*iter)->node)->*f)();28 }29 };30 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const31 {32 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {33 (((*iter)->node)->*f)();34 }35 };36 // one argument37 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const38 {39 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {40 (((*iter)->node)->*f)(t);41 }42 };43 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const44 {45 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {46 (((*iter)->node)->*f)(t);47 }48 };49 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&), T &t ) const50 {51 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {52 (((*iter)->node)->*f)(t);53 }54 };55 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const56 {57 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {58 (((*iter)->node)->*f)(t);59 }60 };61 // two arguments62 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const63 {64 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {65 (((*iter)->node)->*f)(t, u);66 }67 };68 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const69 {70 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {71 (((*iter)->node)->*f)(t, u);72 }73 };74 // three arguments75 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const76 {77 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {78 (((*iter)->node)->*f)(t, u, v);79 }80 };81 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const82 {83 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {84 (((*iter)->node)->*f)(t, u, v);85 }86 };87 21 88 22 // ========================= Summing over each Atoms =================================== // … … 370 304 int inc = 1; 371 305 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 372 (*Setor) (&array[((*iter)-> type->*index)], &inc);306 (*Setor) (&array[((*iter)->getType()->*index)], &inc); 373 307 } 374 308 }; … … 376 310 { 377 311 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 378 (*Setor) (&array[((*iter)-> type->*index)], &value);312 (*Setor) (&array[((*iter)->getType()->*index)], &value); 379 313 } 380 314 }; … … 382 316 { 383 317 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 384 (*Setor) (&array[((*iter)-> type->*index)], value);318 (*Setor) (&array[((*iter)->getType()->*index)], value); 385 319 } 386 320 }; -
src/moleculelist.cpp
r8d6d31 r8f4df1 182 182 size=0.; 183 183 for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) { 184 counts[(*iter)-> type->getNumber()]++;185 if ((*iter)-> x.DistanceSquared(Origin) > size)186 size = (*iter)-> x.DistanceSquared(Origin);184 counts[(*iter)->getType()->getNumber()]++; 185 if ((*iter)->DistanceSquared(Origin) > size) 186 size = (*iter)->DistanceSquared(Origin); 187 187 } 188 188 // output Index, Name, number of atoms, chemical formula … … 354 354 for (molecule::const_iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) { 355 355 DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << **iter << "." << endl); 356 if (!TesselStruct->IsInnerPoint((*iter)-> x, LCList)) {356 if (!TesselStruct->IsInnerPoint((*iter)->getPosition(), LCList)) { 357 357 CopyAtoms[(*iter)->nr] = (*iter)->clone(); 358 358 mol->AddAtom(CopyAtoms[(*iter)->nr]); … … 501 501 for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) { 502 502 //Log() << Verbose(1) << "(*iter): " << *(*iter) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl; 503 if (((*iter)-> type->Z == 1) && (((*iter)->father == NULL)504 || ((*iter)->father-> type->Z != 1))) { // if it's a hydrogen503 if (((*iter)->getType()->Z == 1) && (((*iter)->father == NULL) 504 || ((*iter)->father->getType()->Z != 1))) { // if it's a hydrogen 505 505 for (molecule::const_iterator runner = (*ListRunner)->begin(); runner != (*ListRunner)->end(); ++runner) { 506 506 //Log() << Verbose(2) << "Runner: " << *(*runner) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl; 507 507 // 3. take every other hydrogen that is the not the first and not bound to same bonding partner 508 508 Binder = *((*runner)->ListOfBonds.begin()); 509 if (((*runner)-> type->Z == 1) && ((*runner)->nr > (*iter)->nr) && (Binder->GetOtherAtom((*runner)) != Binder->GetOtherAtom((*iter)))) { // (hydrogens have only one bonding partner!)509 if (((*runner)->getType()->Z == 1) && ((*runner)->nr > (*iter)->nr) && (Binder->GetOtherAtom((*runner)) != Binder->GetOtherAtom((*iter)))) { // (hydrogens have only one bonding partner!) 510 510 // 4. evaluate the morse potential for each matrix component and add up 511 distance = (*runner)-> x.distance((*iter)->x);511 distance = (*runner)->distance(*(*iter)); 512 512 //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << *(*runner) << "<= " << distance << "=>" << *(*iter) << ":" << endl; 513 513 for (int k = 0; k < a; k++) { … … 599 599 if ((*ListRunner)->hasElement((*elemIter).first)) { // if this element got atoms 600 600 for(molecule::iterator atomIter = (*ListRunner)->begin(); atomIter !=(*ListRunner)->end();++atomIter){ 601 if ((*atomIter)-> type->getNumber() == (*elemIter).first) {601 if ((*atomIter)->getType()->getNumber() == (*elemIter).first) { 602 602 if (((*atomIter)->GetTrueFather() != NULL) && ((*atomIter)->GetTrueFather() != (*atomIter))) {// if there is a rea 603 603 //Log() << Verbose(0) << "Walker is " << *Walker << " with true father " << *( Walker->GetTrueFather()) << ", it … … 1089 1089 if (AtomMask[Father->nr]) // apply mask 1090 1090 #ifdef ADDHYDROGEN 1091 if ((*iter)-> type->Z != 1) // skip hydrogen1091 if ((*iter)->getType()->Z != 1) // skip hydrogen 1092 1092 #endif 1093 1093 RootStack[FragmentCounter].push_front((*iter)->nr); -
src/tesselation.cpp
r8d6d31 r8f4df1 13 13 #include "Helpers/helpers.hpp" 14 14 #include "Helpers/Info.hpp" 15 #include "BoundaryPointSet.hpp" 16 #include "BoundaryLineSet.hpp" 17 #include "BoundaryTriangleSet.hpp" 18 #include "BoundaryPolygonSet.hpp" 19 #include "TesselPoint.hpp" 20 #include "CandidateForTesselation.hpp" 21 #include "PointCloud.hpp" 15 22 #include "linkedcell.hpp" 16 23 #include "Helpers/Log.hpp" … … 20 27 #include "LinearAlgebra/Vector.hpp" 21 28 #include "LinearAlgebra/Line.hpp" 22 #include " vector_ops.hpp"29 #include "LinearAlgebra/vector_ops.hpp" 23 30 #include "Helpers/Verbose.hpp" 24 31 #include "LinearAlgebra/Plane.hpp" … … 27 34 28 35 class molecule; 29 30 // ======================================== Points on Boundary =================================31 32 /** Constructor of BoundaryPointSet.33 */34 BoundaryPointSet::BoundaryPointSet() :35 LinesCount(0), value(0.), Nr(-1)36 {37 Info FunctionInfo(__func__);38 DoLog(1) && (Log() << Verbose(1) << "Adding noname." << endl);39 }40 ;41 42 /** Constructor of BoundaryPointSet with Tesselpoint.43 * \param *Walker TesselPoint this boundary point represents44 */45 BoundaryPointSet::BoundaryPointSet(TesselPoint * const Walker) :46 LinesCount(0), node(Walker), value(0.), Nr(Walker->nr)47 {48 Info FunctionInfo(__func__);49 DoLog(1) && (Log() << Verbose(1) << "Adding Node " << *Walker << endl);50 }51 ;52 53 /** Destructor of BoundaryPointSet.54 * Sets node to NULL to avoid removing the original, represented TesselPoint.55 * \note When removing point from a class Tesselation, use RemoveTesselationPoint()56 */57 BoundaryPointSet::~BoundaryPointSet()58 {59 Info FunctionInfo(__func__);60 //Log() << Verbose(0) << "Erasing point nr. " << Nr << "." << endl;61 if (!lines.empty())62 DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some lines." << endl);63 node = NULL;64 }65 ;66 67 /** Add a line to the LineMap of this point.68 * \param *line line to add69 */70 void BoundaryPointSet::AddLine(BoundaryLineSet * const line)71 {72 Info FunctionInfo(__func__);73 DoLog(1) && (Log() << Verbose(1) << "Adding " << *this << " to line " << *line << "." << endl);74 if (line->endpoints[0] == this) {75 lines.insert(LinePair(line->endpoints[1]->Nr, line));76 } else {77 lines.insert(LinePair(line->endpoints[0]->Nr, line));78 }79 LinesCount++;80 }81 ;82 83 /** output operator for BoundaryPointSet.84 * \param &ost output stream85 * \param &a boundary point86 */87 ostream & operator <<(ostream &ost, const BoundaryPointSet &a)88 {89 ost << "[" << a.Nr << "|" << a.node->getName() << " at " << *a.node->node << "]";90 return ost;91 }92 ;93 94 // ======================================== Lines on Boundary =================================95 96 /** Constructor of BoundaryLineSet.97 */98 BoundaryLineSet::BoundaryLineSet() :99 Nr(-1)100 {101 Info FunctionInfo(__func__);102 for (int i = 0; i < 2; i++)103 endpoints[i] = NULL;104 }105 ;106 107 /** Constructor of BoundaryLineSet with two endpoints.108 * Adds line automatically to each endpoints' LineMap109 * \param *Point[2] array of two boundary points110 * \param number number of the list111 */112 BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point[2], const int number)113 {114 Info FunctionInfo(__func__);115 // set number116 Nr = number;117 // set endpoints in ascending order118 SetEndpointsOrdered(endpoints, Point[0], Point[1]);119 // add this line to the hash maps of both endpoints120 Point[0]->AddLine(this); //Taken out, to check whether we can avoid unwanted double adding.121 Point[1]->AddLine(this); //122 // set skipped to false123 skipped = false;124 // clear triangles list125 DoLog(0) && (Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl);126 }127 ;128 129 /** Constructor of BoundaryLineSet with two endpoints.130 * Adds line automatically to each endpoints' LineMap131 * \param *Point1 first boundary point132 * \param *Point2 second boundary point133 * \param number number of the list134 */135 BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number)136 {137 Info FunctionInfo(__func__);138 // set number139 Nr = number;140 // set endpoints in ascending order141 SetEndpointsOrdered(endpoints, Point1, Point2);142 // add this line to the hash maps of both endpoints143 Point1->AddLine(this); //Taken out, to check whether we can avoid unwanted double adding.144 Point2->AddLine(this); //145 // set skipped to false146 skipped = false;147 // clear triangles list148 DoLog(0) && (Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl);149 }150 ;151 152 /** Destructor for BoundaryLineSet.153 * Removes itself from each endpoints' LineMap, calling RemoveTrianglePoint() when point not connected anymore.154 * \note When removing lines from a class Tesselation, use RemoveTesselationLine()155 */156 BoundaryLineSet::~BoundaryLineSet()157 {158 Info FunctionInfo(__func__);159 int Numbers[2];160 161 // get other endpoint number of finding copies of same line162 if (endpoints[1] != NULL)163 Numbers[0] = endpoints[1]->Nr;164 else165 Numbers[0] = -1;166 if (endpoints[0] != NULL)167 Numbers[1] = endpoints[0]->Nr;168 else169 Numbers[1] = -1;170 171 for (int i = 0; i < 2; i++) {172 if (endpoints[i] != NULL) {173 if (Numbers[i] != -1) { // as there may be multiple lines with same endpoints, we have to go through each and find in the endpoint's line list this line set174 pair<LineMap::iterator, LineMap::iterator> erasor = endpoints[i]->lines.equal_range(Numbers[i]);175 for (LineMap::iterator Runner = erasor.first; Runner != erasor.second; Runner++)176 if ((*Runner).second == this) {177 //Log() << Verbose(0) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl;178 endpoints[i]->lines.erase(Runner);179 break;180 }181 } else { // there's just a single line left182 if (endpoints[i]->lines.erase(Nr)) {183 //Log() << Verbose(0) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl;184 }185 }186 if (endpoints[i]->lines.empty()) {187 //Log() << Verbose(0) << *endpoints[i] << " has no more lines it's attached to, erasing." << endl;188 if (endpoints[i] != NULL) {189 delete (endpoints[i]);190 endpoints[i] = NULL;191 }192 }193 }194 }195 if (!triangles.empty())196 DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some triangles." << endl);197 }198 ;199 200 /** Add triangle to TriangleMap of this boundary line.201 * \param *triangle to add202 */203 void BoundaryLineSet::AddTriangle(BoundaryTriangleSet * const triangle)204 {205 Info FunctionInfo(__func__);206 DoLog(0) && (Log() << Verbose(0) << "Add " << triangle->Nr << " to line " << *this << "." << endl);207 triangles.insert(TrianglePair(triangle->Nr, triangle));208 }209 ;210 211 /** Checks whether we have a common endpoint with given \a *line.212 * \param *line other line to test213 * \return true - common endpoint present, false - not connected214 */215 bool BoundaryLineSet::IsConnectedTo(const BoundaryLineSet * const line) const216 {217 Info FunctionInfo(__func__);218 if ((endpoints[0] == line->endpoints[0]) || (endpoints[1] == line->endpoints[0]) || (endpoints[0] == line->endpoints[1]) || (endpoints[1] == line->endpoints[1]))219 return true;220 else221 return false;222 }223 ;224 225 /** Checks whether the adjacent triangles of a baseline are convex or not.226 * We sum the two angles of each height vector with respect to the center of the baseline.227 * If greater/equal M_PI than we are convex.228 * \param *out output stream for debugging229 * \return true - triangles are convex, false - concave or less than two triangles connected230 */231 bool BoundaryLineSet::CheckConvexityCriterion() const232 {233 Info FunctionInfo(__func__);234 double angle = CalculateConvexity();235 if (angle > -MYEPSILON) {236 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl);237 return true;238 } else {239 DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl);240 return false;241 }242 }243 244 245 /** Calculates the angle between two triangles with respect to their normal vector.246 * We sum the two angles of each height vector with respect to the center of the baseline.247 * \return angle > 0 then convex, if < 0 then concave248 */249 double BoundaryLineSet::CalculateConvexity() const250 {251 Info FunctionInfo(__func__);252 Vector BaseLineCenter, BaseLineNormal, BaseLine, helper[2], NormalCheck;253 // get the two triangles254 if (triangles.size() != 2) {255 DoeLog(0) && (eLog() << Verbose(0) << "Baseline " << *this << " is connected to less than two triangles, Tesselation incomplete!" << endl);256 return true;257 }258 // check normal vectors259 // have a normal vector on the base line pointing outwards260 //Log() << Verbose(0) << "INFO: " << *this << " has vectors at " << *(endpoints[0]->node->node) << " and at " << *(endpoints[1]->node->node) << "." << endl;261 BaseLineCenter = (1./2.)*((*endpoints[0]->node->node) + (*endpoints[1]->node->node));262 BaseLine = (*endpoints[0]->node->node) - (*endpoints[1]->node->node);263 264 //Log() << Verbose(0) << "INFO: Baseline is " << BaseLine << " and its center is at " << BaseLineCenter << "." << endl;265 266 BaseLineNormal.Zero();267 NormalCheck.Zero();268 double sign = -1.;269 int i = 0;270 class BoundaryPointSet *node = NULL;271 for (TriangleMap::const_iterator runner = triangles.begin(); runner != triangles.end(); runner++) {272 //Log() << Verbose(0) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl;273 NormalCheck += runner->second->NormalVector;274 NormalCheck *= sign;275 sign = -sign;276 if (runner->second->NormalVector.NormSquared() > MYEPSILON)277 BaseLineNormal = runner->second->NormalVector; // yes, copy second on top of first278 else {279 DoeLog(0) && (eLog() << Verbose(0) << "Triangle " << *runner->second << " has zero normal vector!" << endl);280 }281 node = runner->second->GetThirdEndpoint(this);282 if (node != NULL) {283 //Log() << Verbose(0) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl;284 helper[i] = (*node->node->node) - BaseLineCenter;285 helper[i].MakeNormalTo(BaseLine); // we want to compare the triangle's heights' angles!286 //Log() << Verbose(0) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl;287 i++;288 } else {289 DoeLog(1) && (eLog() << Verbose(1) << "I cannot find third node in triangle, something's wrong." << endl);290 return true;291 }292 }293 //Log() << Verbose(0) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl;294 if (NormalCheck.NormSquared() < MYEPSILON) {295 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl);296 return true;297 }298 BaseLineNormal.Scale(-1.);299 double angle = GetAngle(helper[0], helper[1], BaseLineNormal);300 return (angle - M_PI);301 }302 303 /** Checks whether point is any of the two endpoints this line contains.304 * \param *point point to test305 * \return true - point is of the line, false - is not306 */307 bool BoundaryLineSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const308 {309 Info FunctionInfo(__func__);310 for (int i = 0; i < 2; i++)311 if (point == endpoints[i])312 return true;313 return false;314 }315 ;316 317 /** Returns other endpoint of the line.318 * \param *point other endpoint319 * \return NULL - if endpoint not contained in BoundaryLineSet::lines, or pointer to BoundaryPointSet otherwise320 */321 class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(const BoundaryPointSet * const point) const322 {323 Info FunctionInfo(__func__);324 if (endpoints[0] == point)325 return endpoints[1];326 else if (endpoints[1] == point)327 return endpoints[0];328 else329 return NULL;330 }331 ;332 333 /** Returns other triangle of the line.334 * \param *point other endpoint335 * \return NULL - if triangle not contained in BoundaryLineSet::triangles, or pointer to BoundaryTriangleSet otherwise336 */337 class BoundaryTriangleSet *BoundaryLineSet::GetOtherTriangle(const BoundaryTriangleSet * const triangle) const338 {339 Info FunctionInfo(__func__);340 if (triangles.size() == 2) {341 for (TriangleMap::const_iterator TriangleRunner = triangles.begin(); TriangleRunner != triangles.end(); ++TriangleRunner)342 if (TriangleRunner->second != triangle)343 return TriangleRunner->second;344 }345 return NULL;346 }347 ;348 349 /** output operator for BoundaryLineSet.350 * \param &ost output stream351 * \param &a boundary line352 */353 ostream & operator <<(ostream &ost, const BoundaryLineSet &a)354 {355 ost << "[" << a.Nr << "|" << a.endpoints[0]->node->getName() << " at " << *a.endpoints[0]->node->node << "," << a.endpoints[1]->node->getName() << " at " << *a.endpoints[1]->node->node << "]";356 return ost;357 }358 ;359 360 // ======================================== Triangles on Boundary =================================361 362 /** Constructor for BoundaryTriangleSet.363 */364 BoundaryTriangleSet::BoundaryTriangleSet() :365 Nr(-1)366 {367 Info FunctionInfo(__func__);368 for (int i = 0; i < 3; i++) {369 endpoints[i] = NULL;370 lines[i] = NULL;371 }372 }373 ;374 375 /** Constructor for BoundaryTriangleSet with three lines.376 * \param *line[3] lines that make up the triangle377 * \param number number of triangle378 */379 BoundaryTriangleSet::BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number) :380 Nr(number)381 {382 Info FunctionInfo(__func__);383 // set number384 // set lines385 for (int i = 0; i < 3; i++) {386 lines[i] = line[i];387 lines[i]->AddTriangle(this);388 }389 // get ascending order of endpoints390 PointMap OrderMap;391 for (int i = 0; i < 3; i++) {392 // for all three lines393 for (int j = 0; j < 2; j++) { // for both endpoints394 OrderMap.insert(pair<int, class BoundaryPointSet *> (line[i]->endpoints[j]->Nr, line[i]->endpoints[j]));395 // and we don't care whether insertion fails396 }397 }398 // set endpoints399 int Counter = 0;400 DoLog(0) && (Log() << Verbose(0) << "New triangle " << Nr << " with end points: " << endl);401 for (PointMap::iterator runner = OrderMap.begin(); runner != OrderMap.end(); runner++) {402 endpoints[Counter] = runner->second;403 DoLog(0) && (Log() << Verbose(0) << " " << *endpoints[Counter] << endl);404 Counter++;405 }406 ASSERT(Counter >= 3,"We have a triangle with only two distinct endpoints!");407 };408 409 410 /** Destructor of BoundaryTriangleSet.411 * Removes itself from each of its lines' LineMap and removes them if necessary.412 * \note When removing triangles from a class Tesselation, use RemoveTesselationTriangle()413 */414 BoundaryTriangleSet::~BoundaryTriangleSet()415 {416 Info FunctionInfo(__func__);417 for (int i = 0; i < 3; i++) {418 if (lines[i] != NULL) {419 if (lines[i]->triangles.erase(Nr)) {420 //Log() << Verbose(0) << "Triangle Nr." << Nr << " erased in line " << *lines[i] << "." << endl;421 }422 if (lines[i]->triangles.empty()) {423 //Log() << Verbose(0) << *lines[i] << " is no more attached to any triangle, erasing." << endl;424 delete (lines[i]);425 lines[i] = NULL;426 }427 }428 }429 //Log() << Verbose(0) << "Erasing triangle Nr." << Nr << " itself." << endl;430 }431 ;432 433 /** Calculates the normal vector for this triangle.434 * Is made unique by comparison with \a OtherVector to point in the other direction.435 * \param &OtherVector direction vector to make normal vector unique.436 */437 void BoundaryTriangleSet::GetNormalVector(const Vector &OtherVector)438 {439 Info FunctionInfo(__func__);440 // get normal vector441 NormalVector = Plane(*(endpoints[0]->node->node),442 *(endpoints[1]->node->node),443 *(endpoints[2]->node->node)).getNormal();444 445 // make it always point inward (any offset vector onto plane projected onto normal vector suffices)446 if (NormalVector.ScalarProduct(OtherVector) > 0.)447 NormalVector.Scale(-1.);448 DoLog(1) && (Log() << Verbose(1) << "Normal Vector is " << NormalVector << "." << endl);449 }450 ;451 452 /** Finds the point on the triangle \a *BTS through which the line defined by \a *MolCenter and \a *x crosses.453 * We call Vector::GetIntersectionWithPlane() to receive the intersection point with the plane454 * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not.455 * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line456 * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between457 * the first two basepoints) or not.458 * \param *out output stream for debugging459 * \param *MolCenter offset vector of line460 * \param *x second endpoint of line, minus \a *MolCenter is directional vector of line461 * \param *Intersection intersection on plane on return462 * \return true - \a *Intersection contains intersection on plane defined by triangle, false - zero vector if outside of triangle.463 */464 465 bool BoundaryTriangleSet::GetIntersectionInsideTriangle(const Vector * const MolCenter, const Vector * const x, Vector * const Intersection) const466 {467 Info FunctionInfo(__func__);468 Vector CrossPoint;469 Vector helper;470 471 try {472 Line centerLine = makeLineThrough(*MolCenter, *x);473 *Intersection = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(centerLine);474 475 DoLog(1) && (Log() << Verbose(1) << "INFO: Triangle is " << *this << "." << endl);476 DoLog(1) && (Log() << Verbose(1) << "INFO: Line is from " << *MolCenter << " to " << *x << "." << endl);477 DoLog(1) && (Log() << Verbose(1) << "INFO: Intersection is " << *Intersection << "." << endl);478 479 if (Intersection->DistanceSquared(*endpoints[0]->node->node) < MYEPSILON) {480 DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl);481 return true;482 } else if (Intersection->DistanceSquared(*endpoints[1]->node->node) < MYEPSILON) {483 DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with second endpoint." << endl);484 return true;485 } else if (Intersection->DistanceSquared(*endpoints[2]->node->node) < MYEPSILON) {486 DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with third endpoint." << endl);487 return true;488 }489 // Calculate cross point between one baseline and the line from the third endpoint to intersection490 int i = 0;491 do {492 Line line1 = makeLineThrough(*(endpoints[i%3]->node->node),*(endpoints[(i+1)%3]->node->node));493 Line line2 = makeLineThrough(*(endpoints[(i+2)%3]->node->node),*Intersection);494 CrossPoint = line1.getIntersection(line2);495 helper = (*endpoints[(i+1)%3]->node->node) - (*endpoints[i%3]->node->node);496 CrossPoint -= (*endpoints[i%3]->node->node); // cross point was returned as absolute vector497 const double s = CrossPoint.ScalarProduct(helper)/helper.NormSquared();498 DoLog(1) && (Log() << Verbose(1) << "INFO: Factor s is " << s << "." << endl);499 if ((s < -MYEPSILON) || ((s-1.) > MYEPSILON)) {500 DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << "outside of triangle." << endl);501 return false;502 }503 i++;504 } while (i < 3);505 DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " inside of triangle." << endl);506 return true;507 }508 catch (MathException &excp) {509 Log() << Verbose(1) << excp;510 DoeLog(1) && (eLog() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl);511 return false;512 }513 }514 ;515 516 /** Finds the point on the triangle to the point \a *x.517 * We call Vector::GetIntersectionWithPlane() with \a * and the center of the triangle to receive an intersection point.518 * Then we check the in-plane part (the part projected down onto plane). We check whether it crosses one of the519 * boundary lines. If it does, we return this intersection as closest point, otherwise the projected point down.520 * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not.521 * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line522 * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between523 * the first two basepoints) or not.524 * \param *x point525 * \param *ClosestPoint desired closest point inside triangle to \a *x, is absolute vector526 * \return Distance squared between \a *x and closest point inside triangle527 */528 double BoundaryTriangleSet::GetClosestPointInsideTriangle(const Vector * const x, Vector * const ClosestPoint) const529 {530 Info FunctionInfo(__func__);531 Vector Direction;532 533 // 1. get intersection with plane534 DoLog(1) && (Log() << Verbose(1) << "INFO: Looking for closest point of triangle " << *this << " to " << *x << "." << endl);535 GetCenter(&Direction);536 try {537 Line l = makeLineThrough(*x, Direction);538 *ClosestPoint = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(l);539 }540 catch (MathException &excp) {541 (*ClosestPoint) = (*x);542 }543 544 // 2. Calculate in plane part of line (x, intersection)545 Vector InPlane = (*x) - (*ClosestPoint); // points from plane intersection to straight-down point546 InPlane.ProjectOntoPlane(NormalVector);547 InPlane += *ClosestPoint;548 549 DoLog(2) && (Log() << Verbose(2) << "INFO: Triangle is " << *this << "." << endl);550 DoLog(2) && (Log() << Verbose(2) << "INFO: Line is from " << Direction << " to " << *x << "." << endl);551 DoLog(2) && (Log() << Verbose(2) << "INFO: In-plane part is " << InPlane << "." << endl);552 553 // Calculate cross point between one baseline and the desired point such that distance is shortest554 double ShortestDistance = -1.;555 bool InsideFlag = false;556 Vector CrossDirection[3];557 Vector CrossPoint[3];558 Vector helper;559 for (int i = 0; i < 3; i++) {560 // treat direction of line as normal of a (cut)plane and the desired point x as the plane offset, the intersect line with point561 Direction = (*endpoints[(i+1)%3]->node->node) - (*endpoints[i%3]->node->node);562 // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal);563 Line l = makeLineThrough(*(endpoints[i%3]->node->node), *(endpoints[(i+1)%3]->node->node));564 CrossPoint[i] = Plane(Direction, InPlane).GetIntersection(l);565 CrossDirection[i] = CrossPoint[i] - InPlane;566 CrossPoint[i] -= (*endpoints[i%3]->node->node); // cross point was returned as absolute vector567 const double s = CrossPoint[i].ScalarProduct(Direction)/Direction.NormSquared();568 DoLog(2) && (Log() << Verbose(2) << "INFO: Factor s is " << s << "." << endl);569 if ((s >= -MYEPSILON) && ((s-1.) <= MYEPSILON)) {570 CrossPoint[i] += (*endpoints[i%3]->node->node); // make cross point absolute again571 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);572 const double distance = CrossPoint[i].DistanceSquared(*x);573 if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {574 ShortestDistance = distance;575 (*ClosestPoint) = CrossPoint[i];576 }577 } else578 CrossPoint[i].Zero();579 }580 InsideFlag = true;581 for (int i = 0; i < 3; i++) {582 const double sign = CrossDirection[i].ScalarProduct(CrossDirection[(i + 1) % 3]);583 const double othersign = CrossDirection[i].ScalarProduct(CrossDirection[(i + 2) % 3]);584 585 if ((sign > -MYEPSILON) && (othersign > -MYEPSILON)) // have different sign586 InsideFlag = false;587 }588 if (InsideFlag) {589 (*ClosestPoint) = InPlane;590 ShortestDistance = InPlane.DistanceSquared(*x);591 } else { // also check endnodes592 for (int i = 0; i < 3; i++) {593 const double distance = x->DistanceSquared(*endpoints[i]->node->node);594 if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {595 ShortestDistance = distance;596 (*ClosestPoint) = (*endpoints[i]->node->node);597 }598 }599 }600 DoLog(1) && (Log() << Verbose(1) << "INFO: Closest Point is " << *ClosestPoint << " with shortest squared distance is " << ShortestDistance << "." << endl);601 return ShortestDistance;602 }603 ;604 605 /** Checks whether lines is any of the three boundary lines this triangle contains.606 * \param *line line to test607 * \return true - line is of the triangle, false - is not608 */609 bool BoundaryTriangleSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const610 {611 Info FunctionInfo(__func__);612 for (int i = 0; i < 3; i++)613 if (line == lines[i])614 return true;615 return false;616 }617 ;618 619 /** Checks whether point is any of the three endpoints this triangle contains.620 * \param *point point to test621 * \return true - point is of the triangle, false - is not622 */623 bool BoundaryTriangleSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const624 {625 Info FunctionInfo(__func__);626 for (int i = 0; i < 3; i++)627 if (point == endpoints[i])628 return true;629 return false;630 }631 ;632 633 /** Checks whether point is any of the three endpoints this triangle contains.634 * \param *point TesselPoint to test635 * \return true - point is of the triangle, false - is not636 */637 bool BoundaryTriangleSet::ContainsBoundaryPoint(const TesselPoint * const point) const638 {639 Info FunctionInfo(__func__);640 for (int i = 0; i < 3; i++)641 if (point == endpoints[i]->node)642 return true;643 return false;644 }645 ;646 647 /** Checks whether three given \a *Points coincide with triangle's endpoints.648 * \param *Points[3] pointer to BoundaryPointSet649 * \return true - is the very triangle, false - is not650 */651 bool BoundaryTriangleSet::IsPresentTupel(const BoundaryPointSet * const Points[3]) const652 {653 Info FunctionInfo(__func__);654 DoLog(1) && (Log() << Verbose(1) << "INFO: Checking " << Points[0] << "," << Points[1] << "," << Points[2] << " against " << endpoints[0] << "," << endpoints[1] << "," << endpoints[2] << "." << endl);655 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])656 657 ));658 }659 ;660 661 /** Checks whether three given \a *Points coincide with triangle's endpoints.662 * \param *Points[3] pointer to BoundaryPointSet663 * \return true - is the very triangle, false - is not664 */665 bool BoundaryTriangleSet::IsPresentTupel(const BoundaryTriangleSet * const T) const666 {667 Info FunctionInfo(__func__);668 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])669 670 ));671 }672 ;673 674 /** Returns the endpoint which is not contained in the given \a *line.675 * \param *line baseline defining two endpoints676 * \return pointer third endpoint or NULL if line does not belong to triangle.677 */678 class BoundaryPointSet *BoundaryTriangleSet::GetThirdEndpoint(const BoundaryLineSet * const line) const679 {680 Info FunctionInfo(__func__);681 // sanity check682 if (!ContainsBoundaryLine(line))683 return NULL;684 for (int i = 0; i < 3; i++)685 if (!line->ContainsBoundaryPoint(endpoints[i]))686 return endpoints[i];687 // actually, that' impossible :)688 return NULL;689 }690 ;691 692 /** Returns the baseline which does not contain the given boundary point \a *point.693 * \param *point endpoint which is neither endpoint of the desired line694 * \return pointer to desired third baseline695 */696 class BoundaryLineSet *BoundaryTriangleSet::GetThirdLine(const BoundaryPointSet * const point) const697 {698 Info FunctionInfo(__func__);699 // sanity check700 if (!ContainsBoundaryPoint(point))701 return NULL;702 for (int i = 0; i < 3; i++)703 if (!lines[i]->ContainsBoundaryPoint(point))704 return lines[i];705 // actually, that' impossible :)706 return NULL;707 }708 ;709 710 /** Calculates the center point of the triangle.711 * Is third of the sum of all endpoints.712 * \param *center central point on return.713 */714 void BoundaryTriangleSet::GetCenter(Vector * const center) const715 {716 Info FunctionInfo(__func__);717 center->Zero();718 for (int i = 0; i < 3; i++)719 (*center) += (*endpoints[i]->node->node);720 center->Scale(1. / 3.);721 DoLog(1) && (Log() << Verbose(1) << "INFO: Center is at " << *center << "." << endl);722 }723 724 /**725 * gets the Plane defined by the three triangle Basepoints726 */727 Plane BoundaryTriangleSet::getPlane() const{728 ASSERT(endpoints[0] && endpoints[1] && endpoints[2], "Triangle not fully defined");729 730 return Plane(*endpoints[0]->node->node,731 *endpoints[1]->node->node,732 *endpoints[2]->node->node);733 }734 735 Vector BoundaryTriangleSet::getEndpoint(int i) const{736 ASSERT(i>=0 && i<3,"Index of Endpoint out of Range");737 738 return *endpoints[i]->node->node;739 }740 741 string BoundaryTriangleSet::getEndpointName(int i) const{742 ASSERT(i>=0 && i<3,"Index of Endpoint out of Range");743 744 return endpoints[i]->node->getName();745 }746 747 /** output operator for BoundaryTriangleSet.748 * \param &ost output stream749 * \param &a boundary triangle750 */751 ostream &operator <<(ostream &ost, const BoundaryTriangleSet &a)752 {753 ost << "[" << a.Nr << "|" << a.getEndpointName(0) << "," << a.getEndpointName(1) << "," << a.getEndpointName(2) << "]";754 // ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << ","755 // << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "," << a.endpoints[2]->node->Name << " at " << *a.endpoints[2]->node->node << "]";756 return ost;757 }758 ;759 760 // ======================================== Polygons on Boundary =================================761 762 /** Constructor for BoundaryPolygonSet.763 */764 BoundaryPolygonSet::BoundaryPolygonSet() :765 Nr(-1)766 {767 Info FunctionInfo(__func__);768 }769 ;770 771 /** Destructor of BoundaryPolygonSet.772 * Just clears endpoints.773 * \note When removing triangles from a class Tesselation, use RemoveTesselationTriangle()774 */775 BoundaryPolygonSet::~BoundaryPolygonSet()776 {777 Info FunctionInfo(__func__);778 endpoints.clear();779 DoLog(1) && (Log() << Verbose(1) << "Erasing polygon Nr." << Nr << " itself." << endl);780 }781 ;782 783 /** Calculates the normal vector for this triangle.784 * Is made unique by comparison with \a OtherVector to point in the other direction.785 * \param &OtherVector direction vector to make normal vector unique.786 * \return allocated vector in normal direction787 */788 Vector * BoundaryPolygonSet::GetNormalVector(const Vector &OtherVector) const789 {790 Info FunctionInfo(__func__);791 // get normal vector792 Vector TemporaryNormal;793 Vector *TotalNormal = new Vector;794 PointSet::const_iterator Runner[3];795 for (int i = 0; i < 3; i++) {796 Runner[i] = endpoints.begin();797 for (int j = 0; j < i; j++) { // go as much further798 Runner[i]++;799 if (Runner[i] == endpoints.end()) {800 DoeLog(0) && (eLog() << Verbose(0) << "There are less than three endpoints in the polygon!" << endl);801 performCriticalExit();802 }803 }804 }805 TotalNormal->Zero();806 int counter = 0;807 for (; Runner[2] != endpoints.end();) {808 TemporaryNormal = Plane(*((*Runner[0])->node->node),809 *((*Runner[1])->node->node),810 *((*Runner[2])->node->node)).getNormal();811 for (int i = 0; i < 3; i++) // increase each of them812 Runner[i]++;813 (*TotalNormal) += TemporaryNormal;814 }815 TotalNormal->Scale(1. / (double) counter);816 817 // make it always point inward (any offset vector onto plane projected onto normal vector suffices)818 if (TotalNormal->ScalarProduct(OtherVector) > 0.)819 TotalNormal->Scale(-1.);820 DoLog(1) && (Log() << Verbose(1) << "Normal Vector is " << *TotalNormal << "." << endl);821 822 return TotalNormal;823 }824 ;825 826 /** Calculates the center point of the triangle.827 * Is third of the sum of all endpoints.828 * \param *center central point on return.829 */830 void BoundaryPolygonSet::GetCenter(Vector * const center) const831 {832 Info FunctionInfo(__func__);833 center->Zero();834 int counter = 0;835 for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {836 (*center) += (*(*Runner)->node->node);837 counter++;838 }839 center->Scale(1. / (double) counter);840 DoLog(1) && (Log() << Verbose(1) << "Center is at " << *center << "." << endl);841 }842 843 /** Checks whether the polygons contains all three endpoints of the triangle.844 * \param *triangle triangle to test845 * \return true - triangle is contained polygon, false - is not846 */847 bool BoundaryPolygonSet::ContainsBoundaryTriangle(const BoundaryTriangleSet * const triangle) const848 {849 Info FunctionInfo(__func__);850 return ContainsPresentTupel(triangle->endpoints, 3);851 }852 ;853 854 /** Checks whether the polygons contains both endpoints of the line.855 * \param *line line to test856 * \return true - line is of the triangle, false - is not857 */858 bool BoundaryPolygonSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const859 {860 Info FunctionInfo(__func__);861 return ContainsPresentTupel(line->endpoints, 2);862 }863 ;864 865 /** Checks whether point is any of the three endpoints this triangle contains.866 * \param *point point to test867 * \return true - point is of the triangle, false - is not868 */869 bool BoundaryPolygonSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const870 {871 Info FunctionInfo(__func__);872 for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {873 DoLog(0) && (Log() << Verbose(0) << "Checking against " << **Runner << endl);874 if (point == (*Runner)) {875 DoLog(0) && (Log() << Verbose(0) << " Contained." << endl);876 return true;877 }878 }879 DoLog(0) && (Log() << Verbose(0) << " Not contained." << endl);880 return false;881 }882 ;883 884 /** Checks whether point is any of the three endpoints this triangle contains.885 * \param *point TesselPoint to test886 * \return true - point is of the triangle, false - is not887 */888 bool BoundaryPolygonSet::ContainsBoundaryPoint(const TesselPoint * const point) const889 {890 Info FunctionInfo(__func__);891 for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)892 if (point == (*Runner)->node) {893 DoLog(0) && (Log() << Verbose(0) << " Contained." << endl);894 return true;895 }896 DoLog(0) && (Log() << Verbose(0) << " Not contained." << endl);897 return false;898 }899 ;900 901 /** Checks whether given array of \a *Points coincide with polygons's endpoints.902 * \param **Points pointer to an array of BoundaryPointSet903 * \param dim dimension of array904 * \return true - set of points is contained in polygon, false - is not905 */906 bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const907 {908 Info FunctionInfo(__func__);909 int counter = 0;910 DoLog(1) && (Log() << Verbose(1) << "Polygon is " << *this << endl);911 for (int i = 0; i < dim; i++) {912 DoLog(1) && (Log() << Verbose(1) << " Testing endpoint " << *Points[i] << endl);913 if (ContainsBoundaryPoint(Points[i])) {914 counter++;915 }916 }917 918 if (counter == dim)919 return true;920 else921 return false;922 }923 ;924 925 /** Checks whether given PointList coincide with polygons's endpoints.926 * \param &endpoints PointList927 * \return true - set of points is contained in polygon, false - is not928 */929 bool BoundaryPolygonSet::ContainsPresentTupel(const PointSet &endpoints) const930 {931 Info FunctionInfo(__func__);932 size_t counter = 0;933 DoLog(1) && (Log() << Verbose(1) << "Polygon is " << *this << endl);934 for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {935 DoLog(1) && (Log() << Verbose(1) << " Testing endpoint " << **Runner << endl);936 if (ContainsBoundaryPoint(*Runner))937 counter++;938 }939 940 if (counter == endpoints.size())941 return true;942 else943 return false;944 }945 ;946 947 /** Checks whether given set of \a *Points coincide with polygons's endpoints.948 * \param *P pointer to BoundaryPolygonSet949 * \return true - is the very triangle, false - is not950 */951 bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPolygonSet * const P) const952 {953 return ContainsPresentTupel((const PointSet) P->endpoints);954 }955 ;956 957 /** Gathers all the endpoints' triangles in a unique set.958 * \return set of all triangles959 */960 TriangleSet * BoundaryPolygonSet::GetAllContainedTrianglesFromEndpoints() const961 {962 Info FunctionInfo(__func__);963 pair<TriangleSet::iterator, bool> Tester;964 TriangleSet *triangles = new TriangleSet;965 966 for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)967 for (LineMap::const_iterator Walker = (*Runner)->lines.begin(); Walker != (*Runner)->lines.end(); Walker++)968 for (TriangleMap::const_iterator Sprinter = (Walker->second)->triangles.begin(); Sprinter != (Walker->second)->triangles.end(); Sprinter++) {969 //Log() << Verbose(0) << " Testing triangle " << *(Sprinter->second) << endl;970 if (ContainsBoundaryTriangle(Sprinter->second)) {971 Tester = triangles->insert(Sprinter->second);972 if (Tester.second)973 DoLog(0) && (Log() << Verbose(0) << "Adding triangle " << *(Sprinter->second) << endl);974 }975 }976 977 DoLog(1) && (Log() << Verbose(1) << "The Polygon of " << endpoints.size() << " endpoints has " << triangles->size() << " unique triangles in total." << endl);978 return triangles;979 }980 ;981 982 /** Fills the endpoints of this polygon from the triangles attached to \a *line.983 * \param *line lines with triangles attached984 * \return true - polygon contains endpoints, false - line was NULL985 */986 bool BoundaryPolygonSet::FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line)987 {988 Info FunctionInfo(__func__);989 pair<PointSet::iterator, bool> Tester;990 if (line == NULL)991 return false;992 DoLog(1) && (Log() << Verbose(1) << "Filling polygon from line " << *line << endl);993 for (TriangleMap::const_iterator Runner = line->triangles.begin(); Runner != line->triangles.end(); Runner++) {994 for (int i = 0; i < 3; i++) {995 Tester = endpoints.insert((Runner->second)->endpoints[i]);996 if (Tester.second)997 DoLog(1) && (Log() << Verbose(1) << " Inserting endpoint " << *((Runner->second)->endpoints[i]) << endl);998 }999 }1000 1001 return true;1002 }1003 ;1004 1005 /** output operator for BoundaryPolygonSet.1006 * \param &ost output stream1007 * \param &a boundary polygon1008 */1009 ostream &operator <<(ostream &ost, const BoundaryPolygonSet &a)1010 {1011 ost << "[" << a.Nr << "|";1012 for (PointSet::const_iterator Runner = a.endpoints.begin(); Runner != a.endpoints.end();) {1013 ost << (*Runner)->node->getName();1014 Runner++;1015 if (Runner != a.endpoints.end())1016 ost << ",";1017 }1018 ost << "]";1019 return ost;1020 }1021 ;1022 1023 // =========================================================== class TESSELPOINT ===========================================1024 1025 /** Constructor of class TesselPoint.1026 */1027 TesselPoint::TesselPoint()1028 {1029 //Info FunctionInfo(__func__);1030 node = NULL;1031 nr = -1;1032 }1033 ;1034 1035 /** Destructor for class TesselPoint.1036 */1037 TesselPoint::~TesselPoint()1038 {1039 //Info FunctionInfo(__func__);1040 }1041 ;1042 1043 /** Prints LCNode to screen.1044 */1045 ostream & operator <<(ostream &ost, const TesselPoint &a)1046 {1047 ost << "[" << a.getName() << "|" << *a.node << "]";1048 return ost;1049 }1050 ;1051 1052 /** Prints LCNode to screen.1053 */1054 ostream & TesselPoint::operator <<(ostream &ost)1055 {1056 Info FunctionInfo(__func__);1057 ost << "[" << (nr) << "|" << this << "]";1058 return ost;1059 }1060 ;1061 1062 // =========================================================== class POINTCLOUD ============================================1063 1064 /** Constructor of class PointCloud.1065 */1066 PointCloud::PointCloud()1067 {1068 //Info FunctionInfo(__func__);1069 }1070 ;1071 1072 /** Destructor for class PointCloud.1073 */1074 PointCloud::~PointCloud()1075 {1076 //Info FunctionInfo(__func__);1077 }1078 ;1079 1080 // ============================ CandidateForTesselation =============================1081 1082 /** Constructor of class CandidateForTesselation.1083 */1084 CandidateForTesselation::CandidateForTesselation(BoundaryLineSet* line) :1085 BaseLine(line), ThirdPoint(NULL), T(NULL), ShortestAngle(2. * M_PI), OtherShortestAngle(2. * M_PI)1086 {1087 Info FunctionInfo(__func__);1088 }1089 ;1090 1091 /** Constructor of class CandidateForTesselation.1092 */1093 CandidateForTesselation::CandidateForTesselation(TesselPoint *candidate, BoundaryLineSet* line, BoundaryPointSet* point, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) :1094 BaseLine(line), ThirdPoint(point), T(NULL), ShortestAngle(2. * M_PI), OtherShortestAngle(2. * M_PI)1095 {1096 Info FunctionInfo(__func__);1097 OptCenter = OptCandidateCenter;1098 OtherOptCenter = OtherOptCandidateCenter;1099 };1100 1101 1102 /** Destructor for class CandidateForTesselation.1103 */1104 CandidateForTesselation::~CandidateForTesselation()1105 {1106 }1107 ;1108 1109 /** Checks validity of a given sphere of a candidate line.1110 * Sphere must touch all candidates and the baseline endpoints and there must be no other atoms inside.1111 * \param RADIUS radius of sphere1112 * \param *LC LinkedCell structure with other atoms1113 * \return true - sphere is valid, false - sphere contains other points1114 */1115 bool CandidateForTesselation::CheckValidity(const double RADIUS, const LinkedCell *LC) const1116 {1117 Info FunctionInfo(__func__);1118 1119 const double radiusSquared = RADIUS * RADIUS;1120 list<const Vector *> VectorList;1121 VectorList.push_back(&OptCenter);1122 //VectorList.push_back(&OtherOptCenter); // don't check the other (wrong) center1123 1124 if (!pointlist.empty())1125 DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains candidate list and baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ..." << endl);1126 else1127 DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere with no candidates contains baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ..." << endl);1128 // check baseline for OptCenter and OtherOptCenter being on sphere's surface1129 for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {1130 for (int i = 0; i < 2; i++) {1131 const double distance = fabs((*VRunner)->DistanceSquared(*BaseLine->endpoints[i]->node->node) - radiusSquared);1132 if (distance > HULLEPSILON) {1133 DoeLog(1) && (eLog() << Verbose(1) << "Endpoint " << *BaseLine->endpoints[i] << " is out of sphere at " << *(*VRunner) << " by " << distance << "." << endl);1134 return false;1135 }1136 }1137 }1138 1139 // check Candidates for OptCenter and OtherOptCenter being on sphere's surface1140 for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.end(); ++Runner) {1141 const TesselPoint *Walker = *Runner;1142 for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {1143 const double distance = fabs((*VRunner)->DistanceSquared(*Walker->node) - radiusSquared);1144 if (distance > HULLEPSILON) {1145 DoeLog(1) && (eLog() << Verbose(1) << "Candidate " << *Walker << " is out of sphere at " << *(*VRunner) << " by " << distance << "." << endl);1146 return false;1147 } else {1148 DoLog(1) && (Log() << Verbose(1) << "Candidate " << *Walker << " is inside by " << distance << "." << endl);1149 }1150 }1151 }1152 1153 DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains no others points ..." << endl);1154 bool flag = true;1155 for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {1156 // get all points inside the sphere1157 TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, (*VRunner));1158 1159 DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << (*VRunner) << ":" << endl);1160 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)1161 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)->node->distance(*(*VRunner)) << "." << endl);1162 1163 // remove baseline's endpoints and candidates1164 for (int i = 0; i < 2; i++) {1165 DoLog(1) && (Log() << Verbose(1) << "INFO: removing baseline tesselpoint " << *BaseLine->endpoints[i]->node << "." << endl);1166 ListofPoints->remove(BaseLine->endpoints[i]->node);1167 }1168 for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.end(); ++Runner) {1169 DoLog(1) && (Log() << Verbose(1) << "INFO: removing candidate tesselpoint " << *(*Runner) << "." << endl);1170 ListofPoints->remove(*Runner);1171 }1172 if (!ListofPoints->empty()) {1173 DoeLog(1) && (eLog() << Verbose(1) << "CheckValidity: There are still " << ListofPoints->size() << " points inside the sphere." << endl);1174 flag = false;1175 DoeLog(1) && (eLog() << Verbose(1) << "External atoms inside of sphere at " << *(*VRunner) << ":" << endl);1176 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)1177 DoeLog(1) && (eLog() << Verbose(1) << " " << *(*Runner) << " at distance " << setprecision(13) << (*Runner)->node->distance(*(*VRunner)) << setprecision(6) << "." << endl);1178 1179 // check with animate_sphere.tcl VMD script1180 if (ThirdPoint != NULL) {1181 DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " " << ThirdPoint->Nr + 1 << " " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);1182 } else {1183 DoeLog(1) && (eLog() << Verbose(1) << "Check by: ... missing third point ..." << endl);1184 DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " ??? " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);1185 }1186 }1187 delete (ListofPoints);1188 1189 }1190 return flag;1191 }1192 ;1193 1194 /** output operator for CandidateForTesselation.1195 * \param &ost output stream1196 * \param &a boundary line1197 */1198 ostream & operator <<(ostream &ost, const CandidateForTesselation &a)1199 {1200 ost << "[" << a.BaseLine->Nr << "|" << a.BaseLine->endpoints[0]->node->getName() << "," << a.BaseLine->endpoints[1]->node->getName() << "] with ";1201 if (a.pointlist.empty())1202 ost << "no candidate.";1203 else {1204 ost << "candidate";1205 if (a.pointlist.size() != 1)1206 ost << "s ";1207 else1208 ost << " ";1209 for (TesselPointList::const_iterator Runner = a.pointlist.begin(); Runner != a.pointlist.end(); Runner++)1210 ost << *(*Runner) << " ";1211 ost << " at angle " << (a.ShortestAngle) << ".";1212 }1213 1214 return ost;1215 }1216 ;1217 1218 // =========================================================== class TESSELATION ===========================================1219 36 1220 37 /** Constructor of class Tesselation. … … 1254 71 int num = 0; 1255 72 for (GoToFirst(); (!IsEnd()); GoToNext()) { 1256 (*Center) += ( *GetPoint()->node);73 (*Center) += (GetPoint()->getPosition()); 1257 74 num++; 1258 75 } … … 1337 154 C++; 1338 155 for (; C != PointsOnBoundary.end(); C++) { 1339 tmp = A->second->node-> node->DistanceSquared(*B->second->node->node);156 tmp = A->second->node->DistanceSquared(B->second->node->getPosition()); 1340 157 distance = tmp * tmp; 1341 tmp = A->second->node-> node->DistanceSquared(*C->second->node->node);158 tmp = A->second->node->DistanceSquared(C->second->node->getPosition()); 1342 159 distance += tmp * tmp; 1343 tmp = B->second->node-> node->DistanceSquared(*C->second->node->node);160 tmp = B->second->node->DistanceSquared(C->second->node->getPosition()); 1344 161 distance += tmp * tmp; 1345 162 DistanceMMap.insert(DistanceMultiMapPair(distance, pair<PointMap::iterator, PointMap::iterator> (B, C))); … … 1360 177 // 2. next, we have to check whether all points reside on only one side of the triangle 1361 178 // 3. construct plane vector 1362 PlaneVector = Plane( *A->second->node->node,1363 *baseline->second.first->second->node->node,1364 *baseline->second.second->second->node->node).getNormal();179 PlaneVector = Plane(A->second->node->getPosition(), 180 baseline->second.first->second->node->getPosition(), 181 baseline->second.second->second->node->getPosition()).getNormal(); 1365 182 DoLog(2) && (Log() << Verbose(2) << "Plane vector of candidate triangle is " << PlaneVector << endl); 1366 183 // 4. loop over all points … … 1372 189 continue; 1373 190 // 4a. project onto plane vector 1374 TrialVector = (*checker->second->node->node); 1375 TrialVector.SubtractVector(*A->second->node->node); 191 TrialVector = (checker->second->node->getPosition() - A->second->node->getPosition()); 1376 192 distance = TrialVector.ScalarProduct(PlaneVector); 1377 193 if (fabs(distance) < 1e-4) // we need to have a small epsilon around 0 which is still ok … … 1389 205 } 1390 206 // 4d. Check whether the point is inside the triangle (check distance to each node 1391 tmp = checker->second->node-> node->DistanceSquared(*A->second->node->node);207 tmp = checker->second->node->DistanceSquared(A->second->node->getPosition()); 1392 208 int innerpoint = 0; 1393 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)))209 if ((tmp < A->second->node->DistanceSquared(baseline->second.first->second->node->getPosition())) && (tmp < A->second->node->DistanceSquared(baseline->second.second->second->node->getPosition()))) 1394 210 innerpoint++; 1395 tmp = checker->second->node-> node->DistanceSquared(*baseline->second.first->second->node->node);1396 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)))211 tmp = checker->second->node->DistanceSquared(baseline->second.first->second->node->getPosition()); 212 if ((tmp < baseline->second.first->second->node->DistanceSquared(A->second->node->getPosition())) && (tmp < baseline->second.first->second->node->DistanceSquared(baseline->second.second->second->node->getPosition()))) 1397 213 innerpoint++; 1398 tmp = checker->second->node-> node->DistanceSquared(*baseline->second.second->second->node->node);1399 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)))214 tmp = checker->second->node->DistanceSquared(baseline->second.second->second->node->getPosition()); 215 if ((tmp < baseline->second.second->second->node->DistanceSquared(baseline->second.first->second->node->getPosition())) && (tmp < baseline->second.second->second->node->DistanceSquared(A->second->node->getPosition()))) 1400 216 innerpoint++; 1401 217 // 4e. If so, break 4. loop and continue with next candidate in 1. loop … … 1478 294 // prepare some auxiliary vectors 1479 295 Vector BaseLineCenter, BaseLine; 1480 BaseLineCenter = 0.5 * (( *baseline->second->endpoints[0]->node->node) +1481 ( *baseline->second->endpoints[1]->node->node));1482 BaseLine = ( *baseline->second->endpoints[0]->node->node) - (*baseline->second->endpoints[1]->node->node);296 BaseLineCenter = 0.5 * ((baseline->second->endpoints[0]->node->getPosition()) + 297 (baseline->second->endpoints[1]->node->getPosition())); 298 BaseLine = (baseline->second->endpoints[0]->node->getPosition()) - (baseline->second->endpoints[1]->node->getPosition()); 1483 299 1484 300 // offset to center of triangle … … 1498 314 // project center vector onto triangle plane (points from intersection plane-NormalVector to plane-CenterVector intersection) 1499 315 PropagationVector = Plane(BaseLine, NormalVector,0).getNormal(); 1500 TempVector = CenterVector - ( *baseline->second->endpoints[0]->node->node); // TempVector is vector on triangle plane pointing from one baseline egde towards center!316 TempVector = CenterVector - (baseline->second->endpoints[0]->node->getPosition()); // TempVector is vector on triangle plane pointing from one baseline egde towards center! 1501 317 //Log() << Verbose(0) << "Projection of propagation onto temp: " << PropagationVector.Projection(&TempVector) << "." << endl; 1502 318 if (PropagationVector.ScalarProduct(TempVector) > 0) // make sure normal propagation vector points outward from baseline … … 1511 327 1512 328 // first check direction, so that triangles don't intersect 1513 VirtualNormalVector = ( *target->second->node->node) - BaseLineCenter;329 VirtualNormalVector = (target->second->node->getPosition()) - BaseLineCenter; 1514 330 VirtualNormalVector.ProjectOntoPlane(NormalVector); 1515 331 TempAngle = VirtualNormalVector.Angle(PropagationVector); … … 1540 356 1541 357 // check for linear dependence 1542 TempVector = ( *baseline->second->endpoints[0]->node->node) - (*target->second->node->node);1543 helper = ( *baseline->second->endpoints[1]->node->node) - (*target->second->node->node);358 TempVector = (baseline->second->endpoints[0]->node->getPosition()) - (target->second->node->getPosition()); 359 helper = (baseline->second->endpoints[1]->node->getPosition()) - (target->second->node->getPosition()); 1544 360 helper.ProjectOntoPlane(TempVector); 1545 361 if (fabs(helper.NormSquared()) < MYEPSILON) { … … 1550 366 // in case NOT both were found, create virtually this triangle, get its normal vector, calculate angle 1551 367 flag = true; 1552 VirtualNormalVector = Plane( *(baseline->second->endpoints[0]->node->node),1553 *(baseline->second->endpoints[1]->node->node),1554 *(target->second->node->node)).getNormal();1555 TempVector = (1./3.) * (( *baseline->second->endpoints[0]->node->node) +1556 ( *baseline->second->endpoints[1]->node->node) +1557 ( *target->second->node->node));368 VirtualNormalVector = Plane((baseline->second->endpoints[0]->node->getPosition()), 369 (baseline->second->endpoints[1]->node->getPosition()), 370 (target->second->node->getPosition())).getNormal(); 371 TempVector = (1./3.) * ((baseline->second->endpoints[0]->node->getPosition()) + 372 (baseline->second->endpoints[1]->node->getPosition()) + 373 (target->second->node->getPosition())); 1558 374 TempVector -= (*Center); 1559 375 // make it always point outward … … 1569 385 } else if (fabs(SmallestAngle - TempAngle) < MYEPSILON) { // check the angle to propagation, both possible targets are in one plane! (their normals have same angle) 1570 386 // hence, check the angles to some normal direction from our base line but in this common plane of both targets... 1571 helper = ( *target->second->node->node) - BaseLineCenter;387 helper = (target->second->node->getPosition()) - BaseLineCenter; 1572 388 helper.ProjectOntoPlane(BaseLine); 1573 389 // ...the one with the smaller angle is the better candidate 1574 TempVector = ( *target->second->node->node) - BaseLineCenter;390 TempVector = (target->second->node->getPosition()) - BaseLineCenter; 1575 391 TempVector.ProjectOntoPlane(VirtualNormalVector); 1576 392 TempAngle = TempVector.Angle(helper); 1577 TempVector = ( *winner->second->node->node) - BaseLineCenter;393 TempVector = (winner->second->node->getPosition()) - BaseLineCenter; 1578 394 TempVector.ProjectOntoPlane(VirtualNormalVector); 1579 395 if (TempAngle < TempVector.Angle(helper)) { … … 1614 430 BLS[2] = LineChecker[1]->second; 1615 431 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 1616 BTS->GetCenter( &helper);432 BTS->GetCenter(helper); 1617 433 helper -= (*Center); 1618 434 helper *= -1; … … 1662 478 DoLog(0) && (Log() << Verbose(0) << "Current point is " << *Walker << "." << endl); 1663 479 // get the next triangle 1664 triangles = FindClosestTrianglesToVector(Walker-> node, BoundaryPoints);480 triangles = FindClosestTrianglesToVector(Walker->getPosition(), BoundaryPoints); 1665 481 if (triangles != NULL) 1666 482 BTS = triangles->front(); … … 1676 492 DoLog(0) && (Log() << Verbose(0) << "Closest triangle is " << *BTS << "." << endl); 1677 493 // get the intersection point 1678 if (BTS->GetIntersectionInsideTriangle( Center, Walker->node, &Intersection)) {494 if (BTS->GetIntersectionInsideTriangle(*Center, Walker->getPosition(), Intersection)) { 1679 495 DoLog(0) && (Log() << Verbose(0) << "We have an intersection at " << Intersection << "." << endl); 1680 496 // we have the intersection, check whether in- or outside of boundary 1681 if ((Center->DistanceSquared( *Walker->node) - Center->DistanceSquared(Intersection)) < -MYEPSILON) {497 if ((Center->DistanceSquared(Walker->getPosition()) - Center->DistanceSquared(Intersection)) < -MYEPSILON) { 1682 498 // inside, next! 1683 499 DoLog(0) && (Log() << Verbose(0) << *Walker << " is inside wrt triangle " << *BTS << "." << endl); … … 2086 902 DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << CandidateLine.OtherOptCenter << ":" << endl); 2087 903 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 2088 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)-> node->distance(CandidateLine.OtherOptCenter) << "." << endl);904 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)->distance(CandidateLine.OtherOptCenter) << "." << endl); 2089 905 2090 906 // remove triangles's endpoints … … 2102 918 DoLog(1) && (Log() << Verbose(1) << "External atoms inside of sphere at " << CandidateLine.OtherOptCenter << ":" << endl); 2103 919 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 2104 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)-> node->distance(CandidateLine.OtherOptCenter) << "." << endl);920 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)->distance(CandidateLine.OtherOptCenter) << "." << endl); 2105 921 } 2106 922 delete (ListofPoints); … … 2257 1073 if (List != NULL) { 2258 1074 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 2259 if ((*Runner)-> node->at(map[0]) > maxCoordinate[map[0]]) {2260 DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << map[0] << " node is " << *(*Runner) << " at " << *(*Runner)->node<< "." << endl);2261 maxCoordinate[map[0]] = (*Runner)-> node->at(map[0]);1075 if ((*Runner)->at(map[0]) > maxCoordinate[map[0]]) { 1076 DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << map[0] << " node is " << *(*Runner) << " at " << (*Runner)->getPosition() << "." << endl); 1077 maxCoordinate[map[0]] = (*Runner)->at(map[0]); 2262 1078 MaxPoint[map[0]] = (*Runner); 2263 1079 } … … 2295 1111 2296 1112 // construct center of circle 2297 CircleCenter = 0.5 * (( *BaseLine->endpoints[0]->node->node) + (*BaseLine->endpoints[1]->node->node));1113 CircleCenter = 0.5 * ((BaseLine->endpoints[0]->node->getPosition()) + (BaseLine->endpoints[1]->node->getPosition())); 2298 1114 2299 1115 // construct normal vector of circle 2300 CirclePlaneNormal = ( *BaseLine->endpoints[0]->node->node) - (*BaseLine->endpoints[1]->node->node);1116 CirclePlaneNormal = (BaseLine->endpoints[0]->node->getPosition()) - (BaseLine->endpoints[1]->node->getPosition()); 2301 1117 2302 1118 double radius = CirclePlaneNormal.NormSquared(); … … 2515 1331 2516 1332 // construct center of circle 2517 CircleCenter = 0.5 * (( *CandidateLine.BaseLine->endpoints[0]->node->node) +2518 ( *CandidateLine.BaseLine->endpoints[1]->node->node));1333 CircleCenter = 0.5 * ((CandidateLine.BaseLine->endpoints[0]->node->getPosition()) + 1334 (CandidateLine.BaseLine->endpoints[1]->node->getPosition())); 2519 1335 2520 1336 // construct normal vector of circle 2521 CirclePlaneNormal = ( *CandidateLine.BaseLine->endpoints[0]->node->node) -2522 ( *CandidateLine.BaseLine->endpoints[1]->node->node);1337 CirclePlaneNormal = (CandidateLine.BaseLine->endpoints[0]->node->getPosition()) - 1338 (CandidateLine.BaseLine->endpoints[1]->node->getPosition()); 2523 1339 2524 1340 // calculate squared radius of circle … … 2536 1352 // construct SearchDirection and an "outward pointer" 2537 1353 SearchDirection = Plane(RelativeSphereCenter, CirclePlaneNormal,0).getNormal(); 2538 helper = CircleCenter - ( *ThirdPoint->node->node);1354 helper = CircleCenter - (ThirdPoint->node->getPosition()); 2539 1355 if (helper.ScalarProduct(SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards! 2540 1356 SearchDirection.Scale(-1.); … … 2611 1427 for (TesselPointList::iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); Runner++) 2612 1428 SetOfNeighbours.insert(*Runner); 2613 TesselPointList *connectedClosestPoints = GetCircleOfSetOfPoints(&SetOfNeighbours, TurningPoint, CandidateLine.BaseLine->endpoints[1]->node-> node);1429 TesselPointList *connectedClosestPoints = GetCircleOfSetOfPoints(&SetOfNeighbours, TurningPoint, CandidateLine.BaseLine->endpoints[1]->node->getPosition()); 2614 1430 2615 1431 DoLog(0) && (Log() << Verbose(0) << "List of Candidates for Turning Point " << *TurningPoint << ":" << endl); … … 2712 1528 2713 1529 // create normal vector 2714 BTS->GetCenter( &Center);1530 BTS->GetCenter(Center); 2715 1531 Center -= CandidateLine.OptCenter; 2716 1532 BTS->SphereCenter = CandidateLine.OptCenter; … … 2791 1607 2792 1608 // create normal vector 2793 BTS->GetCenter( &Center);1609 BTS->GetCenter(Center); 2794 1610 Center.SubtractVector(*OptCenter); 2795 1611 BTS->SphereCenter = *OptCenter; … … 2837 1653 Vector DistanceToIntersection[2], BaseLine; 2838 1654 double distance[2]; 2839 BaseLine = ( *Base->endpoints[1]->node->node) - (*Base->endpoints[0]->node->node);1655 BaseLine = (Base->endpoints[1]->node->getPosition()) - (Base->endpoints[0]->node->getPosition()); 2840 1656 for (int i = 0; i < 2; i++) { 2841 DistanceToIntersection[i] = (*ClosestPoint) - ( *Base->endpoints[i]->node->node);1657 DistanceToIntersection[i] = (*ClosestPoint) - (Base->endpoints[i]->node->getPosition()); 2842 1658 distance[i] = BaseLine.ScalarProduct(DistanceToIntersection[i]); 2843 1659 } … … 2919 1735 2920 1736 // calculate volume 2921 volume = CalculateVolumeofGeneralTetraeder( *Base->endpoints[1]->node->node, *OtherBase->endpoints[0]->node->node, *OtherBase->endpoints[1]->node->node, *Base->endpoints[0]->node->node);1737 volume = CalculateVolumeofGeneralTetraeder(Base->endpoints[1]->node->getPosition(), OtherBase->endpoints[0]->node->getPosition(), OtherBase->endpoints[1]->node->getPosition(), Base->endpoints[0]->node->getPosition()); 2922 1738 2923 1739 // delete the temporary other base line and the closest points … … 3125 1941 3126 1942 OrthogonalizedOben = Oben; 3127 aCandidate = ( *a->node) - (*Candidate->node);1943 aCandidate = (a->getPosition()) - (Candidate->getPosition()); 3128 1944 OrthogonalizedOben.ProjectOntoPlane(aCandidate); 3129 1945 OrthogonalizedOben.Normalize(); … … 3132 1948 OrthogonalizedOben.Scale(scaleFactor); 3133 1949 3134 Center = 0.5 * (( *Candidate->node) + (*a->node));1950 Center = 0.5 * ((Candidate->getPosition()) + (a->getPosition())); 3135 1951 Center += OrthogonalizedOben; 3136 1952 3137 AngleCheck = Center - ( *a->node);1953 AngleCheck = Center - (a->getPosition()); 3138 1954 norm = aCandidate.Norm(); 3139 1955 // second point shall have smallest angle with respect to Oben vector … … 3220 2036 3221 2037 // construct center of circle 3222 CircleCenter = 0.5 * (( *CandidateLine.BaseLine->endpoints[0]->node->node) +3223 ( *CandidateLine.BaseLine->endpoints[1]->node->node));2038 CircleCenter = 0.5 * ((CandidateLine.BaseLine->endpoints[0]->node->getPosition()) + 2039 (CandidateLine.BaseLine->endpoints[1]->node->getPosition())); 3224 2040 3225 2041 // construct normal vector of circle 3226 CirclePlaneNormal = ( *CandidateLine.BaseLine->endpoints[0]->node->node) -3227 ( *CandidateLine.BaseLine->endpoints[1]->node->node);2042 CirclePlaneNormal = (CandidateLine.BaseLine->endpoints[0]->node->getPosition()) - 2043 (CandidateLine.BaseLine->endpoints[1]->node->getPosition()); 3228 2044 3229 2045 RelativeOldSphereCenter = OldSphereCenter - CircleCenter; … … 3252 2068 3253 2069 // get cell for the starting point 3254 if (LC->SetIndexToVector( &CircleCenter)) {2070 if (LC->SetIndexToVector(CircleCenter)) { 3255 2071 for (int i = 0; i < NDIM; i++) // store indices of this cell 3256 2072 N[i] = LC->n[i]; … … 3282 2098 3283 2099 // find center on the plane 3284 GetCenterofCircumcircle( &NewPlaneCenter, *CandidateLine.BaseLine->endpoints[0]->node->node, *CandidateLine.BaseLine->endpoints[1]->node->node, *Candidate->node);2100 GetCenterofCircumcircle(NewPlaneCenter, CandidateLine.BaseLine->endpoints[0]->node->getPosition(), CandidateLine.BaseLine->endpoints[1]->node->getPosition(), Candidate->getPosition()); 3285 2101 DoLog(1) && (Log() << Verbose(1) << "INFO: NewPlaneCenter is " << NewPlaneCenter << "." << endl); 3286 2102 3287 2103 try { 3288 NewNormalVector = Plane( *(CandidateLine.BaseLine->endpoints[0]->node->node),3289 *(CandidateLine.BaseLine->endpoints[1]->node->node),3290 *(Candidate->node)).getNormal();2104 NewNormalVector = Plane((CandidateLine.BaseLine->endpoints[0]->node->getPosition()), 2105 (CandidateLine.BaseLine->endpoints[1]->node->getPosition()), 2106 (Candidate->getPosition())).getNormal(); 3291 2107 DoLog(1) && (Log() << Verbose(1) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl); 3292 radius = CandidateLine.BaseLine->endpoints[0]->node-> node->DistanceSquared(NewPlaneCenter);2108 radius = CandidateLine.BaseLine->endpoints[0]->node->DistanceSquared(NewPlaneCenter); 3293 2109 DoLog(1) && (Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl); 3294 2110 DoLog(1) && (Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl); 3295 2111 DoLog(1) && (Log() << Verbose(1) << "INFO: Radius of CircumCenterCircle is " << radius << "." << endl); 3296 2112 if (radius < RADIUS * RADIUS) { 3297 otherradius = CandidateLine.BaseLine->endpoints[1]->node-> node->DistanceSquared(NewPlaneCenter);2113 otherradius = CandidateLine.BaseLine->endpoints[1]->node->DistanceSquared(NewPlaneCenter); 3298 2114 if (fabs(radius - otherradius) < HULLEPSILON) { 3299 2115 // construct both new centers … … 3422 2238 * \return map of BoundaryPointSet of closest points sorted by squared distance or NULL. 3423 2239 */ 3424 DistanceToPointMap * Tesselation::FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const2240 DistanceToPointMap * Tesselation::FindClosestBoundaryPointsToVector(const Vector &x, const LinkedCell* LC) const 3425 2241 { 3426 2242 Info FunctionInfo(__func__); … … 3450 2266 FindPoint = PointsOnBoundary.find((*Runner)->nr); 3451 2267 if (FindPoint != PointsOnBoundary.end()) { 3452 points->insert(DistanceToPointPair(FindPoint->second->node-> node->DistanceSquared(*x), FindPoint->second));2268 points->insert(DistanceToPointPair(FindPoint->second->node->DistanceSquared(x), FindPoint->second)); 3453 2269 DoLog(1) && (Log() << Verbose(1) << "INFO: Putting " << *FindPoint->second << " into the list." << endl); 3454 2270 } … … 3474 2290 * \return closest BoundaryLineSet or NULL in degenerate case. 3475 2291 */ 3476 BoundaryLineSet * Tesselation::FindClosestBoundaryLineToVector(const Vector *x, const LinkedCell* LC) const2292 BoundaryLineSet * Tesselation::FindClosestBoundaryLineToVector(const Vector &x, const LinkedCell* LC) const 3477 2293 { 3478 2294 Info FunctionInfo(__func__); … … 3485 2301 3486 2302 // for each point, check its lines, remember closest 3487 DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryLine to " << *x << " ... " << endl);2303 DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryLine to " << x << " ... " << endl); 3488 2304 BoundaryLineSet *ClosestLine = NULL; 3489 2305 double MinDistance = -1.; … … 3494 2310 for (LineMap::iterator LineRunner = Runner->second->lines.begin(); LineRunner != Runner->second->lines.end(); LineRunner++) { 3495 2311 // calculate closest point on line to desired point 3496 helper = 0.5 * (( *(LineRunner->second)->endpoints[0]->node->node) +3497 ( *(LineRunner->second)->endpoints[1]->node->node));3498 Center = ( *x) - helper;3499 BaseLine = ( *(LineRunner->second)->endpoints[0]->node->node) -3500 ( *(LineRunner->second)->endpoints[1]->node->node);2312 helper = 0.5 * (((LineRunner->second)->endpoints[0]->node->getPosition()) + 2313 ((LineRunner->second)->endpoints[1]->node->getPosition())); 2314 Center = (x) - helper; 2315 BaseLine = ((LineRunner->second)->endpoints[0]->node->getPosition()) - 2316 ((LineRunner->second)->endpoints[1]->node->getPosition()); 3501 2317 Center.ProjectOntoPlane(BaseLine); 3502 2318 const double distance = Center.NormSquared(); 3503 2319 if ((ClosestLine == NULL) || (distance < MinDistance)) { 3504 2320 // additionally calculate intersection on line (whether it's on the line section or not) 3505 helper = ( *x) - (*(LineRunner->second)->endpoints[0]->node->node) - Center;2321 helper = (x) - ((LineRunner->second)->endpoints[0]->node->getPosition()) - Center; 3506 2322 const double lengthA = helper.ScalarProduct(BaseLine); 3507 helper = ( *x) - (*(LineRunner->second)->endpoints[1]->node->node) - Center;2323 helper = (x) - ((LineRunner->second)->endpoints[1]->node->getPosition()) - Center; 3508 2324 const double lengthB = helper.ScalarProduct(BaseLine); 3509 2325 if (lengthB * lengthA < 0) { // if have different sign … … 3534 2350 * \return BoundaryTriangleSet of nearest triangle or NULL. 3535 2351 */ 3536 TriangleList * Tesselation::FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const2352 TriangleList * Tesselation::FindClosestTrianglesToVector(const Vector &x, const LinkedCell* LC) const 3537 2353 { 3538 2354 Info FunctionInfo(__func__); … … 3545 2361 3546 2362 // for each point, check its lines, remember closest 3547 DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << *x << " ... " << endl);2363 DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << x << " ... " << endl); 3548 2364 LineSet ClosestLines; 3549 2365 double MinDistance = 1e+16; … … 3555 2371 for (LineMap::iterator LineRunner = Runner->second->lines.begin(); LineRunner != Runner->second->lines.end(); LineRunner++) { 3556 2372 3557 BaseLine = ( *(LineRunner->second)->endpoints[0]->node->node) -3558 ( *(LineRunner->second)->endpoints[1]->node->node);2373 BaseLine = ((LineRunner->second)->endpoints[0]->node->getPosition()) - 2374 ((LineRunner->second)->endpoints[1]->node->getPosition()); 3559 2375 const double lengthBase = BaseLine.NormSquared(); 3560 2376 3561 BaseLineIntersection = ( *x) - (*(LineRunner->second)->endpoints[0]->node->node);2377 BaseLineIntersection = (x) - ((LineRunner->second)->endpoints[0]->node->getPosition()); 3562 2378 const double lengthEndA = BaseLineIntersection.NormSquared(); 3563 2379 3564 BaseLineIntersection = ( *x) - (*(LineRunner->second)->endpoints[1]->node->node);2380 BaseLineIntersection = (x) - ((LineRunner->second)->endpoints[1]->node->getPosition()); 3565 2381 const double lengthEndB = BaseLineIntersection.NormSquared(); 3566 2382 … … 3580 2396 } else { // intersection is closer, calculate 3581 2397 // calculate closest point on line to desired point 3582 BaseLineIntersection = ( *x) - (*(LineRunner->second)->endpoints[1]->node->node);2398 BaseLineIntersection = (x) - ((LineRunner->second)->endpoints[1]->node->getPosition()); 3583 2399 Center = BaseLineIntersection; 3584 2400 Center.ProjectOntoPlane(BaseLine); … … 3621 2437 * \return list of BoundaryTriangleSet of nearest triangles or NULL. 3622 2438 */ 3623 class BoundaryTriangleSet * Tesselation::FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const2439 class BoundaryTriangleSet * Tesselation::FindClosestTriangleToVector(const Vector &x, const LinkedCell* LC) const 3624 2440 { 3625 2441 Info FunctionInfo(__func__); … … 3636 2452 double MinAlignment = 2. * M_PI; 3637 2453 for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) { 3638 (*Runner)->GetCenter( &Center);3639 helper = ( *x) - Center;2454 (*Runner)->GetCenter(Center); 2455 helper = (x) - Center; 3640 2456 const double Alignment = helper.Angle((*Runner)->NormalVector); 3641 2457 if (Alignment < MinAlignment) { … … 3663 2479 { 3664 2480 Info FunctionInfo(__func__); 3665 TriangleIntersectionList Intersections( &Point, this, LC);2481 TriangleIntersectionList Intersections(Point, this, LC); 3666 2482 3667 2483 return Intersections.IsInside(); … … 3703 2519 } 3704 2520 3705 triangle->GetCenter( &Center);2521 triangle->GetCenter(Center); 3706 2522 DoLog(2) && (Log() << Verbose(2) << "INFO: Central point of the triangle is " << Center << "." << endl); 3707 2523 DistanceToCenter = Center - Point; … … 3714 2530 Center = Point - triangle->NormalVector; // points towards MolCenter 3715 2531 DoLog(1) && (Log() << Verbose(1) << "INFO: Calling Intersection with " << Center << " and " << DistanceToCenter << "." << endl); 3716 if (triangle->GetIntersectionInsideTriangle( &Center, &DistanceToCenter, &Intersection)) {2532 if (triangle->GetIntersectionInsideTriangle(Center, DistanceToCenter, Intersection)) { 3717 2533 DoLog(1) && (Log() << Verbose(1) << Point << " is inner point: sufficiently close to boundary, " << Intersection << "." << endl); 3718 2534 return 0.; … … 3723 2539 } else { 3724 2540 // calculate smallest distance 3725 distance = triangle->GetClosestPointInsideTriangle( &Point, &Intersection);2541 distance = triangle->GetClosestPointInsideTriangle(Point, Intersection); 3726 2542 DoLog(1) && (Log() << Verbose(1) << "Closest point on triangle is " << Intersection << "." << endl); 3727 2543 … … 3747 2563 { 3748 2564 Info FunctionInfo(__func__); 3749 TriangleIntersectionList Intersections( &Point, this, LC);2565 TriangleIntersectionList Intersections(Point, this, LC); 3750 2566 3751 2567 return Intersections.GetSmallestDistance(); … … 3762 2578 { 3763 2579 Info FunctionInfo(__func__); 3764 TriangleIntersectionList Intersections( &Point, this, LC);2580 TriangleIntersectionList Intersections(Point, this, LC); 3765 2581 3766 2582 return Intersections.GetClosestTriangle(); … … 3839 2655 * @return list of the all points linked to the provided one 3840 2656 */ 3841 TesselPointList * Tesselation::GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * constReference) const2657 TesselPointList * Tesselation::GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector &Reference) const 3842 2658 { 3843 2659 Info FunctionInfo(__func__); … … 3871 2687 3872 2688 // construct one orthogonal vector 3873 if (Reference != NULL) { 3874 AngleZero = (*Reference) - (*Point->node); 3875 AngleZero.ProjectOntoPlane(PlaneNormal); 3876 } 3877 if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON)) { 3878 DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node << " as angle 0 referencer." << endl); 3879 AngleZero = (*(*SetOfNeighbours->begin())->node) - (*Point->node); 2689 AngleZero = (Reference) - (Point->getPosition()); 2690 AngleZero.ProjectOntoPlane(PlaneNormal); 2691 if ((AngleZero.NormSquared() < MYEPSILON)) { 2692 DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << (*SetOfNeighbours->begin())->getPosition() << " as angle 0 referencer." << endl); 2693 AngleZero = ((*SetOfNeighbours->begin())->getPosition()) - (Point->getPosition()); 3880 2694 AngleZero.ProjectOntoPlane(PlaneNormal); 3881 2695 if (AngleZero.NormSquared() < MYEPSILON) { … … 3893 2707 // go through all connected points and calculate angle 3894 2708 for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) { 3895 helper = ( *(*listRunner)->node) - (*Point->node);2709 helper = ((*listRunner)->getPosition()) - (Point->getPosition()); 3896 2710 helper.ProjectOntoPlane(PlaneNormal); 3897 2711 double angle = GetAngle(helper, AngleZero, OrthogonalVector); … … 3915 2729 * @param *SetOfNeighbours all points for which the angle should be calculated 3916 2730 * @param *Point of which get all connected points 3917 * @param *Reference Reference vector for zero angle or NULLfor no preference2731 * @param *Reference Reference vector for zero angle or (0,0,0) for no preference 3918 2732 * @return list of the all points linked to the provided one 3919 2733 */ 3920 TesselPointList * Tesselation::GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * constReference) const2734 TesselPointList * Tesselation::GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector &Reference) const 3921 2735 { 3922 2736 Info FunctionInfo(__func__); … … 3942 2756 } 3943 2757 3944 DoLog(1) && (Log() << Verbose(1) << "INFO: Point is " << *Point << " and Reference is " << *Reference << "." << endl);2758 DoLog(1) && (Log() << Verbose(1) << "INFO: Point is " << *Point << " and Reference is " << Reference << "." << endl); 3945 2759 // calculate central point 3946 2760 TesselPointSet::const_iterator TesselA = SetOfNeighbours->begin(); … … 3952 2766 int counter = 0; 3953 2767 while (TesselC != SetOfNeighbours->end()) { 3954 helper = Plane( *((*TesselA)->node),3955 *((*TesselB)->node),3956 *((*TesselC)->node)).getNormal();2768 helper = Plane(((*TesselA)->getPosition()), 2769 ((*TesselB)->getPosition()), 2770 ((*TesselC)->getPosition())).getNormal(); 3957 2771 DoLog(0) && (Log() << Verbose(0) << "Making normal vector out of " << *(*TesselA) << ", " << *(*TesselB) << " and " << *(*TesselC) << ":" << helper << endl); 3958 2772 counter++; … … 3974 2788 3975 2789 // construct one orthogonal vector 3976 if ( Reference != NULL) {3977 AngleZero = ( *Reference) - (*Point->node);2790 if (!Reference.IsZero()) { 2791 AngleZero = (Reference) - (Point->getPosition()); 3978 2792 AngleZero.ProjectOntoPlane(PlaneNormal); 3979 2793 } 3980 if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON )) {3981 DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node<< " as angle 0 referencer." << endl);3982 AngleZero = ( *(*SetOfNeighbours->begin())->node) - (*Point->node);2794 if ((Reference.IsZero()) || (AngleZero.NormSquared() < MYEPSILON )) { 2795 DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << (*SetOfNeighbours->begin())->getPosition() << " as angle 0 referencer." << endl); 2796 AngleZero = ((*SetOfNeighbours->begin())->getPosition()) - (Point->getPosition()); 3983 2797 AngleZero.ProjectOntoPlane(PlaneNormal); 3984 2798 if (AngleZero.NormSquared() < MYEPSILON) { … … 3997 2811 pair<map<double, TesselPoint*>::iterator, bool> InserterTest; 3998 2812 for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) { 3999 helper = ( *(*listRunner)->node) - (*Point->node);2813 helper = ((*listRunner)->getPosition()) - (Point->getPosition()); 4000 2814 helper.ProjectOntoPlane(PlaneNormal); 4001 2815 double angle = GetAngle(helper, AngleZero, OrthogonalVector); … … 4242 3056 4243 3057 // copy old location for the volume 4244 OldPoint = ( *point->node->node);3058 OldPoint = (point->node->getPosition()); 4245 3059 4246 3060 // get list of connected points … … 4305 3119 StartNode--; 4306 3120 //Log() << Verbose(3) << "INFO: StartNode is " << **StartNode << "." << endl; 4307 Point = ( *(*StartNode)->node) - (*(*MiddleNode)->node);3121 Point = ((*StartNode)->getPosition()) - ((*MiddleNode)->getPosition()); 4308 3122 StartNode = MiddleNode; 4309 3123 StartNode++; … … 4311 3125 StartNode = connectedPath->begin(); 4312 3126 //Log() << Verbose(3) << "INFO: EndNode is " << **StartNode << "." << endl; 4313 Reference = ( *(*StartNode)->node) - (*(*MiddleNode)->node);4314 OrthogonalVector = ( *(*MiddleNode)->node) - OldPoint;3127 Reference = ((*StartNode)->getPosition()) - ((*MiddleNode)->getPosition()); 3128 OrthogonalVector = ((*MiddleNode)->getPosition()) - OldPoint; 4315 3129 OrthogonalVector.MakeNormalTo(Reference); 4316 3130 angle = GetAngle(Point, Reference, OrthogonalVector); … … 4367 3181 AddTesselationTriangle(); 4368 3182 // calculate volume summand as a general tetraeder 4369 volume += CalculateVolumeofGeneralTetraeder( *TPS[0]->node->node, *TPS[1]->node->node, *TPS[2]->node->node, OldPoint);3183 volume += CalculateVolumeofGeneralTetraeder(TPS[0]->node->getPosition(), TPS[1]->node->getPosition(), TPS[2]->node->getPosition(), OldPoint); 4370 3184 // advance number 4371 3185 count++; … … 4752 3566 // find nearest boundary point 4753 3567 class TesselPoint *BackupPoint = NULL; 4754 class TesselPoint *NearestPoint = FindClosestTesselPoint(point-> node, BackupPoint, LC);3568 class TesselPoint *NearestPoint = FindClosestTesselPoint(point->getPosition(), BackupPoint, LC); 4755 3569 class BoundaryPointSet *NearestBoundaryPoint = NULL; 4756 3570 PointMap::iterator PointRunner; … … 4773 3587 class BoundaryLineSet *BestLine = NULL; 4774 3588 for (LineMap::iterator Runner = NearestBoundaryPoint->lines.begin(); Runner != NearestBoundaryPoint->lines.end(); Runner++) { 4775 BaseLine = ( *Runner->second->endpoints[0]->node->node) -4776 ( *Runner->second->endpoints[1]->node->node);4777 CenterToPoint = 0.5 * (( *Runner->second->endpoints[0]->node->node) +4778 ( *Runner->second->endpoints[1]->node->node));4779 CenterToPoint -= ( *point->node);3589 BaseLine = (Runner->second->endpoints[0]->node->getPosition()) - 3590 (Runner->second->endpoints[1]->node->getPosition()); 3591 CenterToPoint = 0.5 * ((Runner->second->endpoints[0]->node->getPosition()) + 3592 (Runner->second->endpoints[1]->node->getPosition())); 3593 CenterToPoint -= (point->getPosition()); 4780 3594 angle = CenterToPoint.Angle(BaseLine); 4781 3595 if (fabs(angle - M_PI/2.) < fabs(BestAngle - M_PI/2.)) { -
src/tesselation.hpp
r8d6d31 r8f4df1 2 2 * tesselation.hpp 3 3 * 4 * The tesselation class is meant to contain the envelope (concave, convex or neither) of a set of Vectors. As we actually mean this stuff for atoms, we have to encapsulate it all a bit. 4 * The tesselation class is meant to contain the envelope (concave, convex or neither) of a set of Vectors. 5 * As we actually mean this stuff for atoms, we have to encapsulate it all a bit. 5 6 * 6 7 * Created on: Aug 3, 2009 … … 25 26 #include <stack> 26 27 28 #include "BoundaryMaps.hpp" 29 #include "PointCloud.hpp" 30 #include "TesselPoint.hpp" 27 31 #include "atom_particleinfo.hpp" 28 32 #include "Helpers/helpers.hpp" 29 33 #include "LinearAlgebra/Vector.hpp" 34 30 35 31 36 /****************************************** forward declarations *****************************/ … … 34 39 class BoundaryLineSet; 35 40 class BoundaryTriangleSet; 41 class CandidateForTesselation; 36 42 class LinkedCell; 37 class TesselPoint;38 class PointCloud;39 43 class Tesselation; 40 44 class Plane; … … 53 57 // ======================================================= some template functions ========================================= 54 58 55 #define IndexToIndex map <int, int>56 57 #define PointMap map < int, class BoundaryPointSet * >58 #define PointSet set < class BoundaryPointSet * >59 #define PointList list < class BoundaryPointSet * >60 #define PointPair pair < int, class BoundaryPointSet * >61 #define PointTestPair pair < PointMap::iterator, bool >62 63 #define CandidateList list <class CandidateForTesselation *>64 #define CandidateMap map <class BoundaryLineSet *, class CandidateForTesselation *>65 66 #define LineMap multimap < int, class BoundaryLineSet * >67 #define LineSet set < class BoundaryLineSet * >68 #define LineList list < class BoundaryLineSet * >69 #define LinePair pair < int, class BoundaryLineSet * >70 #define LineTestPair pair < LineMap::iterator, bool >71 72 #define TriangleMap map < int, class BoundaryTriangleSet * >73 #define TriangleSet set < class BoundaryTriangleSet * >74 #define TriangleList list < class BoundaryTriangleSet * >75 #define TrianglePair pair < int, class BoundaryTriangleSet * >76 #define TriangleTestPair pair < TrianglePair::iterator, bool >77 78 #define PolygonMap map < int, class BoundaryPolygonSet * >79 #define PolygonSet set < class BoundaryPolygonSet * >80 #define PolygonList list < class BoundaryPolygonSet * >81 82 #define DistanceToPointMap multimap <double, class BoundaryPointSet * >83 #define DistanceToPointPair pair <double, class BoundaryPointSet * >84 85 #define DistanceMultiMap multimap <double, pair < PointMap::iterator, PointMap::iterator> >86 #define DistanceMultiMapPair pair <double, pair < PointMap::iterator, PointMap::iterator> >87 88 #define TesselPointList list <TesselPoint *>89 #define TesselPointSet set <TesselPoint *>90 91 #define ListOfTesselPointList list<list <TesselPoint *> *>92 93 enum centers {Opt, OtherOpt};94 95 59 /********************************************** declarations *******************************/ 96 97 template <typename T> void SetEndpointsOrdered(T endpoints[2], T endpoint1, T endpoint2)98 {99 if (endpoint1->Nr < endpoint2->Nr) {100 endpoints[0] = endpoint1;101 endpoints[1] = endpoint2;102 } else {103 endpoints[0] = endpoint2;104 endpoints[1] = endpoint1;105 }106 };107 108 // ======================================================== class BoundaryPointSet =========================================109 110 class BoundaryPointSet {111 public:112 BoundaryPointSet();113 BoundaryPointSet(TesselPoint * const Walker);114 ~BoundaryPointSet();115 116 void AddLine(BoundaryLineSet * const line);117 118 LineMap lines;119 int LinesCount;120 TesselPoint *node;121 double value;122 int Nr;123 };124 125 ostream & operator << (ostream &ost, const BoundaryPointSet &a);126 127 // ======================================================== class BoundaryLineSet ==========================================128 129 class BoundaryLineSet {130 public:131 BoundaryLineSet();132 BoundaryLineSet(BoundaryPointSet * const Point[2], const int number);133 BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number);134 ~BoundaryLineSet();135 136 void AddTriangle(BoundaryTriangleSet * const triangle);137 bool IsConnectedTo(const BoundaryLineSet * const line) const;138 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;139 bool CheckConvexityCriterion() const;140 double CalculateConvexity() const;141 class BoundaryPointSet *GetOtherEndpoint(const BoundaryPointSet * const point) const;142 class BoundaryTriangleSet *GetOtherTriangle(const BoundaryTriangleSet * const triangle) const;143 144 class BoundaryPointSet *endpoints[2];145 TriangleMap triangles;146 int Nr;147 bool skipped;148 };149 150 ostream & operator << (ostream &ost, const BoundaryLineSet &a);151 152 // ======================================================== class BoundaryTriangleSet =======================================153 154 class BoundaryTriangleSet {155 public:156 BoundaryTriangleSet();157 BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number);158 ~BoundaryTriangleSet();159 160 void GetNormalVector(const Vector &NormalVector);161 void GetCenter(Vector * const center) const;162 bool GetIntersectionInsideTriangle(const Vector * const MolCenter, const Vector * const x, Vector * const Intersection) const;163 double GetClosestPointInsideTriangle(const Vector * const x, Vector * const ClosestPoint) const;164 bool ContainsBoundaryLine(const BoundaryLineSet * const line) const;165 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;166 bool ContainsBoundaryPoint(const TesselPoint * const point) const;167 class BoundaryPointSet *GetThirdEndpoint(const BoundaryLineSet * const line) const;168 class BoundaryLineSet *GetThirdLine(const BoundaryPointSet * const point) const;169 bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const;170 bool IsPresentTupel(const BoundaryTriangleSet * const T) const;171 172 Plane getPlane() const;173 Vector getEndpoint(int) const;174 std::string getEndpointName(int) const;175 176 class BoundaryPointSet *endpoints[3];177 class BoundaryLineSet *lines[3];178 Vector NormalVector;179 Vector SphereCenter;180 int Nr;181 182 private:183 184 };185 186 ostream & operator << (ostream &ost, const BoundaryTriangleSet &a);187 188 189 // ======================================================== class BoundaryTriangleSet =======================================190 191 /** Set of BoundaryPointSet.192 * This is just meant as a container for a group of endpoints, extending the node, line, triangle concept. However, this has193 * only marginally something to do with the tesselation. Hence, there is no incorporation into the bookkeeping of the Tesselation194 * class (i.e. no allocation, no deletion).195 * \note we assume that the set of endpoints reside (more or less) on a plane.196 */197 class BoundaryPolygonSet {198 public:199 BoundaryPolygonSet();200 ~BoundaryPolygonSet();201 202 Vector * GetNormalVector(const Vector &NormalVector) const;203 void GetCenter(Vector *center) const;204 bool ContainsBoundaryLine(const BoundaryLineSet * const line) const;205 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;206 bool ContainsBoundaryPoint(const TesselPoint * const point) const;207 bool ContainsBoundaryTriangle(const BoundaryTriangleSet * const point) const;208 bool ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const;209 bool ContainsPresentTupel(const BoundaryPolygonSet * const P) const;210 bool ContainsPresentTupel(const PointSet &endpoints) const;211 TriangleSet * GetAllContainedTrianglesFromEndpoints() const;212 bool FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line);213 214 PointSet endpoints;215 int Nr;216 };217 218 ostream & operator << (ostream &ost, const BoundaryPolygonSet &a);219 220 // =========================================================== class TESSELPOINT ===========================================221 222 /** Is a single point of the set of Vectors, also a super-class to be inherited and and its functions to be implemented.223 */224 class TesselPoint : virtual public ParticleInfo {225 public:226 TesselPoint();227 virtual ~TesselPoint();228 229 Vector *node; // pointer to position of the dot in space230 231 virtual ostream & operator << (ostream &ost);232 };233 234 ostream & operator << (ostream &ost, const TesselPoint &a);235 236 // =========================================================== class POINTCLOUD ============================================237 238 /** Super-class for all point clouds structures, also molecules. They have to inherit this structure and implement the virtual function to access the Vectors.239 * This basically encapsulates a list structure.240 */241 class PointCloud {242 public:243 PointCloud();244 virtual ~PointCloud();245 246 virtual const char * const GetName() const { return "unknown"; };247 virtual Vector *GetCenter() const { return NULL; };248 virtual TesselPoint *GetPoint() const { return NULL; };249 virtual int GetMaxId() const { return 0; };250 virtual void GoToNext() const {};251 virtual void GoToFirst() const {};252 virtual bool IsEmpty() const { return true; };253 virtual bool IsEnd() const { return true; };254 };255 256 // ======================================================== class CandidateForTesselation =========================================257 258 class CandidateForTesselation {259 public :260 CandidateForTesselation(BoundaryLineSet* currentBaseLine);261 CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, BoundaryPointSet *point, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);262 ~CandidateForTesselation();263 264 bool CheckValidity(const double RADIUS, const LinkedCell *LC) const;265 266 TesselPointList pointlist;267 const BoundaryLineSet * BaseLine;268 const BoundaryPointSet * ThirdPoint;269 const BoundaryTriangleSet *T;270 Vector OldCenter;271 Vector OptCenter;272 Vector OtherOptCenter;273 double ShortestAngle;274 double OtherShortestAngle;275 };276 277 ostream & operator <<(ostream &ost, const CandidateForTesselation &a);278 60 279 61 // =========================================================== class TESSELATION =========================================== … … 289 71 void AddTesselationPoint(TesselPoint* Candidate, const int n); 290 72 void SetTesselationPoint(TesselPoint* Candidate, const int n) const; 291 void AddTesselationLine(const Vector * constOptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);73 void AddTesselationLine(const Vector * OptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n); 292 74 void AddNewTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n); 293 75 void AddExistingTesselationTriangleLine(class BoundaryLineSet *FindLine, int n); … … 330 112 ListOfTesselPointList * GetPathsOfConnectedPoints(const TesselPoint* const Point) const; 331 113 ListOfTesselPointList * GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const; 332 TesselPointList * GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference = NULL) const;333 TesselPointList * GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * constReference) const;114 TesselPointList * GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector &Reference) const; 115 TesselPointList * GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector &Reference) const; 334 116 class BoundaryPointSet * GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const; 335 117 TriangleList * FindTriangles(const TesselPoint* const Points[3]) const; 336 TriangleList * FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const;337 BoundaryTriangleSet * FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const;118 TriangleList * FindClosestTrianglesToVector(const Vector &x, const LinkedCell* LC) const; 119 BoundaryTriangleSet * FindClosestTriangleToVector(const Vector &x, const LinkedCell* LC) const; 338 120 bool IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const; 339 121 double GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const; … … 341 123 BoundaryTriangleSet * GetClosestTriangleOnSurface(const Vector &Point, const LinkedCell* const LC) const; 342 124 bool AddBoundaryPoint(TesselPoint * Walker, const int n); 343 DistanceToPointMap * FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const;344 BoundaryLineSet * FindClosestBoundaryLineToVector(const Vector *x, const LinkedCell* LC) const;125 DistanceToPointMap * FindClosestBoundaryPointsToVector(const Vector &x, const LinkedCell* LC) const; 126 BoundaryLineSet * FindClosestBoundaryLineToVector(const Vector &x, const LinkedCell* LC) const; 345 127 346 128 // print for debugging -
src/tesselationhelpers.cpp
r8d6d31 r8f4df1 10 10 #include <fstream> 11 11 12 #include "BoundaryLineSet.hpp" 13 #include "BoundaryPointSet.hpp" 14 #include "BoundaryPolygonSet.hpp" 15 #include "BoundaryTriangleSet.hpp" 16 #include "CandidateForTesselation.hpp" 12 17 #include "Helpers/Info.hpp" 13 18 #include "linkedcell.hpp" … … 18 23 #include "LinearAlgebra/Vector.hpp" 19 24 #include "LinearAlgebra/Line.hpp" 20 #include " vector_ops.hpp"25 #include "LinearAlgebra/vector_ops.hpp" 21 26 #include "Helpers/Verbose.hpp" 22 27 #include "LinearAlgebra/Plane.hpp" … … 144 149 * \param *c third point 145 150 */ 146 void GetCenterofCircumcircle(Vector * constCenter, const Vector &a, const Vector &b, const Vector &c)151 void GetCenterofCircumcircle(Vector &Center, const Vector &a, const Vector &b, const Vector &c) 147 152 { 148 153 Info FunctionInfo(__func__); … … 156 161 helper[2] = SideC.NormSquared()*(SideA.NormSquared()+SideB.NormSquared() - SideC.NormSquared()); 157 162 158 Center ->Zero();159 *Center += helper[0] * a;160 *Center += helper[1] * b;161 *Center += helper[2] * c;162 Center ->Scale(1./(helper[0]+helper[1]+helper[2]));163 Log() << Verbose(1) << "INFO: Center (2nd algo) is at " << *Center << "." << endl;163 Center.Zero(); 164 Center += helper[0] * a; 165 Center += helper[1] * b; 166 Center += helper[2] * c; 167 Center.Scale(1./(helper[0]+helper[1]+helper[2])); 168 Log() << Verbose(1) << "INFO: Center (2nd algo) is at " << Center << "." << endl; 164 169 }; 165 170 … … 388 393 * @return point which is second closest to the provided one 389 394 */ 390 TesselPoint* FindSecondClosestTesselPoint(const Vector *Point, const LinkedCell* const LC)395 TesselPoint* FindSecondClosestTesselPoint(const Vector& Point, const LinkedCell* const LC) 391 396 { 392 397 Info FunctionInfo(__func__); … … 412 417 if (List != NULL) { 413 418 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 414 helper = ( *Point) - (*(*Runner)->node);419 helper = (Point) - ((*Runner)->getPosition()); 415 420 double currentNorm = helper. Norm(); 416 421 if (currentNorm < distance) { … … 441 446 * @return point which is closest to the provided one, NULL if none found 442 447 */ 443 TesselPoint* FindClosestTesselPoint(const Vector *Point, TesselPoint *&SecondPoint, const LinkedCell* const LC)448 TesselPoint* FindClosestTesselPoint(const Vector& Point, TesselPoint *&SecondPoint, const LinkedCell* const LC) 444 449 { 445 450 Info FunctionInfo(__func__); … … 465 470 if (List != NULL) { 466 471 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 467 helper = ( *Point) - (*(*Runner)->node);472 helper = (Point) - ((*Runner)->getPosition()); 468 473 double currentNorm = helper.NormSquared(); 469 474 if (currentNorm < distance) { … … 503 508 Info FunctionInfo(__func__); 504 509 // construct the plane of the two baselines (i.e. take both their directional vectors) 505 Vector Baseline = ( *Base->endpoints[1]->node->node) - (*Base->endpoints[0]->node->node);506 Vector OtherBaseline = ( *OtherBase->endpoints[1]->node->node) - (*OtherBase->endpoints[0]->node->node);510 Vector Baseline = (Base->endpoints[1]->node->getPosition()) - (Base->endpoints[0]->node->getPosition()); 511 Vector OtherBaseline = (OtherBase->endpoints[1]->node->getPosition()) - (OtherBase->endpoints[0]->node->getPosition()); 507 512 Vector Normal = Baseline; 508 513 Normal.VectorProduct(OtherBaseline); … … 511 516 512 517 // project one offset point of OtherBase onto this plane (and add plane offset vector) 513 Vector NewOffset = ( *OtherBase->endpoints[0]->node->node) - (*Base->endpoints[0]->node->node);518 Vector NewOffset = (OtherBase->endpoints[0]->node->getPosition()) - (Base->endpoints[0]->node->getPosition()); 514 519 NewOffset.ProjectOntoPlane(Normal); 515 NewOffset += ( *Base->endpoints[0]->node->node);520 NewOffset += (Base->endpoints[0]->node->getPosition()); 516 521 Vector NewDirection = NewOffset + OtherBaseline; 517 522 518 523 // calculate the intersection between this projected baseline and Base 519 524 Vector *Intersection = new Vector; 520 Line line1 = makeLineThrough( *(Base->endpoints[0]->node->node),*(Base->endpoints[1]->node->node));525 Line line1 = makeLineThrough((Base->endpoints[0]->node->getPosition()),(Base->endpoints[1]->node->getPosition())); 521 526 Line line2 = makeLineThrough(NewOffset, NewDirection); 522 527 *Intersection = line1.getIntersection(line2); 523 Normal = (*Intersection) - ( *Base->endpoints[0]->node->node);528 Normal = (*Intersection) - (Base->endpoints[0]->node->getPosition()); 524 529 DoLog(1) && (Log() << Verbose(1) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(Baseline)/Baseline.NormSquared()) << "." << endl); 525 530 … … 566 571 *vrmlfile << "Sphere {" << endl << " "; // 2 is sphere type 567 572 for (i=0;i<NDIM;i++) 568 *vrmlfile << Walker-> node->at(i)-center->at(i) << " ";573 *vrmlfile << Walker->at(i)-center->at(i) << " "; 569 574 *vrmlfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour 570 575 cloud->GoToNext(); … … 576 581 for (i=0;i<3;i++) { // print each node 577 582 for (int j=0;j<NDIM;j++) // and for each node all NDIM coordinates 578 *vrmlfile << TriangleRunner->second->endpoints[i]->node-> node->at(j)-center->at(j) << " ";583 *vrmlfile << TriangleRunner->second->endpoints[i]->node->at(j)-center->at(j) << " "; 579 584 *vrmlfile << "\t"; 580 585 } … … 603 608 Vector *center = cloud->GetCenter(); 604 609 // make the circumsphere's center absolute again 605 Vector helper = (1./3.) * (( *Tess->LastTriangle->endpoints[0]->node->node) +606 ( *Tess->LastTriangle->endpoints[1]->node->node) +607 ( *Tess->LastTriangle->endpoints[2]->node->node));610 Vector helper = (1./3.) * ((Tess->LastTriangle->endpoints[0]->node->getPosition()) + 611 (Tess->LastTriangle->endpoints[1]->node->getPosition()) + 612 (Tess->LastTriangle->endpoints[2]->node->getPosition())); 608 613 helper -= (*center); 609 614 // and add to file plus translucency object … … 638 643 *rasterfile << "2" << endl << " "; // 2 is sphere type 639 644 for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates 640 const double tmp = Walker-> node->at(j)-center->at(j);645 const double tmp = Walker->at(j)-center->at(j); 641 646 *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " "; 642 647 } … … 651 656 for (i=0;i<3;i++) { // print each node 652 657 for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates 653 const double tmp = TriangleRunner->second->endpoints[i]->node-> node->at(j)-center->at(j);658 const double tmp = TriangleRunner->second->endpoints[i]->node->at(j)-center->at(j); 654 659 *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " "; 655 660 } … … 705 710 LookupList[Walker->nr] = Counter++; 706 711 for (int i=0;i<NDIM;i++) { 707 const double tmp = Walker-> node->at(i);712 const double tmp = Walker->at(i); 708 713 *tecplot << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " "; 709 714 } … … 754 759 TriangleSet *triangles = TesselStruct->GetAllTriangles(PointRunner->second); 755 760 for (TriangleSet::iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); ++TriangleRunner) { 756 totalarea += CalculateAreaofGeneralTriangle( *(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node);761 totalarea += CalculateAreaofGeneralTriangle((*TriangleRunner)->endpoints[0]->node->getPosition() , (*TriangleRunner)->endpoints[1]->node->getPosition() , (*TriangleRunner)->endpoints[2]->node->getPosition()); 757 762 } 758 763 ConcavityPerLine *= totalarea; … … 763 768 line = (*TriangleRunner)->GetThirdLine(PointRunner->second); 764 769 triangle = line->GetOtherTriangle(*TriangleRunner); 765 area = CalculateAreaofGeneralTriangle( *triangle->endpoints[0]->node->node, *triangle->endpoints[1]->node->node, *triangle->endpoints[2]->node->node);766 area += CalculateAreaofGeneralTriangle( *(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node);770 area = CalculateAreaofGeneralTriangle(triangle->endpoints[0]->node->getPosition() , triangle->endpoints[1]->node->getPosition() , triangle->endpoints[2]->node->getPosition()); 771 area += CalculateAreaofGeneralTriangle((*TriangleRunner)->endpoints[0]->node->getPosition() , (*TriangleRunner)->endpoints[1]->node->getPosition() , (*TriangleRunner)->endpoints[2]->node->getPosition()); 767 772 area *= -line->CalculateConvexity(); 768 773 if (area > 0) … … 797 802 distance = 0.; 798 803 for (TriangleMap::const_iterator TriangleRunner = Convex->TrianglesOnBoundary.begin(); TriangleRunner != Convex->TrianglesOnBoundary.end(); TriangleRunner++) { 799 const double CurrentDistance = Convex->GetDistanceSquaredToTriangle( *PointRunner->second->node->node, TriangleRunner->second);804 const double CurrentDistance = Convex->GetDistanceSquaredToTriangle(PointRunner->second->node->getPosition() , TriangleRunner->second); 800 805 if (CurrentDistance < distance) 801 806 distance = CurrentDistance; -
src/tesselationhelpers.hpp
r8d6d31 r8f4df1 29 29 class BoundaryLineSet; 30 30 class BoundaryTriangleSet; 31 class BoundaryPolygonSet; 32 class CandidateForTesselation; 31 33 class LinkedCell; 32 34 class TesselPoint; … … 37 39 /********************************************** definitions *********************************/ 38 40 39 #define HULLEPSILON 1e-9 //!< TODO: Get rid of HULLEPSILON, points to numerical instabilities40 41 41 /********************************************** declarations *******************************/ 42 42 43 void GetSphere(Vector * constCenter, const Vector &a, const Vector &b, const Vector &c, const double RADIUS);44 void GetCenterOfSphere(Vector * const Center, const Vector &a, const Vector &b, const Vector &c, Vector * const NewUmkreismittelpunkt, const Vector* constDirection, const Vector* const AlternativeDirection, const double HalfplaneIndicator, const double AlternativeIndicator, const double alpha, const double beta, const double gamma, const double RADIUS, const double Umkreisradius);45 void GetCenterofCircumcircle(Vector * constCenter, const Vector &a, const Vector &b, const Vector &c);43 void GetSphere(Vector & Center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS); 44 void GetCenterOfSphere(Vector& Center, const Vector &a, const Vector &b, const Vector &c, Vector &NewUmkreismittelpunkt, const Vector &Direction, const Vector* const AlternativeDirection, const double HalfplaneIndicator, const double AlternativeIndicator, const double alpha, const double beta, const double gamma, const double RADIUS, const double Umkreisradius); 45 void GetCenterofCircumcircle(Vector & Center, const Vector &a, const Vector &b, const Vector &c); 46 46 double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection); 47 47 double CalculateVolumeofGeneralTetraeder(const Vector &a, const Vector &b, const Vector &c, const Vector &d); … … 51 51 bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet * const nodes[3]); 52 52 bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation *candidate2); 53 TesselPoint* FindClosestTesselPoint(const Vector *Point, TesselPoint *&SecondPoint, const LinkedCell* const LC);54 TesselPoint* FindSecondClosestTesselPoint(const Vector *, const LinkedCell* const LC);53 TesselPoint* FindClosestTesselPoint(const Vector & Point, TesselPoint *&SecondPoint, const LinkedCell* const LC); 54 TesselPoint* FindSecondClosestTesselPoint(const Vector &, const LinkedCell* const LC); 55 55 Vector * GetClosestPointBetweenLine(const BoundaryLineSet * const Base, const BoundaryLineSet * const OtherBase); 56 56 … … 61 61 void CalculateConcavityPerBoundaryPoint(const Tesselation * const TesselStruct); 62 62 void CalculateConstrictionPerBoundaryPoint(const Tesselation * const TesselStruct, const Tesselation * const Convex); 63 double DistanceToTrianglePlane(const Vector *x, const BoundaryTriangleSet * const triangle);63 double DistanceToTrianglePlane(const Vector &x, const BoundaryTriangleSet * const triangle); 64 64 65 65 bool CheckListOfBaselines(const Tesselation * const TesselStruct); -
src/triangleintersectionlist.cpp
r8d6d31 r8f4df1 16 16 17 17 #include "Helpers/Info.hpp" 18 #include "BoundaryMaps.hpp" 19 #include "BoundaryPointSet.hpp" 20 #include "BoundaryLineSet.hpp" 21 #include "BoundaryTriangleSet.hpp" 18 22 #include "tesselation.hpp" 19 23 #include "LinearAlgebra/Vector.hpp" … … 23 27 * 24 28 */ 25 TriangleIntersectionList::TriangleIntersectionList(const Vector *x, const Tesselation *surface, const LinkedCell* LC) :29 TriangleIntersectionList::TriangleIntersectionList(const Vector &x, const Tesselation *surface, const LinkedCell* LC) : 26 30 Point(x), 27 31 Tess(surface), … … 70 74 } 71 75 // return reference, if none can be found 72 return *Point;76 return Point; 73 77 }; 74 78 … … 99 103 if (runner != IntersectionList.end()) { 100 104 // if we have found one, check Scalarproduct between the vector 101 Vector TestVector = ( *Point) - (*(*runner).second);105 Vector TestVector = (Point) - (*(*runner).second); 102 106 if (fabs(TestVector.NormSquared()) < MYEPSILON) // 103 107 return true; … … 138 142 // get intersection with triangle plane 139 143 Intersection = new Vector; 140 (*TriangleRunner)->GetClosestPointInsideTriangle(Point, Intersection);141 //Log() << Verbose(1) << "Intersection between " << *Point << " and " << **TriangleRunner << " is at " << *Intersection << "." << endl;144 (*TriangleRunner)->GetClosestPointInsideTriangle(Point, *Intersection); 145 //Log() << Verbose(1) << "Intersection between " << Point << " and " << **TriangleRunner << " is at " << *Intersection << "." << endl; 142 146 IntersectionList.insert( pair<BoundaryTriangleSet *, Vector * > (*TriangleRunner, Intersection) ); 143 147 } … … 151 155 if (DistanceList.empty()) 152 156 for (TriangleVectorMap::const_iterator runner = IntersectionList.begin(); runner != IntersectionList.end(); runner++) 153 DistanceList.insert( pair<double, BoundaryTriangleSet *> (Point ->distance(*(*runner).second), (*runner).first) );157 DistanceList.insert( pair<double, BoundaryTriangleSet *> (Point.distance(*(*runner).second), (*runner).first) ); 154 158 155 159 //for (DistanceTriangleMap::const_iterator runner = DistanceList.begin(); runner != DistanceList.end(); runner++) -
src/triangleintersectionlist.hpp
r8d6d31 r8f4df1 39 39 { 40 40 public: 41 TriangleIntersectionList(const Vector *x, const Tesselation *surface, const LinkedCell* LC);41 TriangleIntersectionList(const Vector &x, const Tesselation *surface, const LinkedCell* LC); 42 42 ~TriangleIntersectionList(); 43 43 … … 52 52 void FillDistanceList() const; 53 53 54 const Vector *Point;54 const Vector &Point; 55 55 const Tesselation *Tess; 56 56 const LinkedCell *Vicinity; -
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
r8d6d31 r8f4df1 53 53 TestMolecule = World::getInstance().createMolecule(); 54 54 Walker = World::getInstance().createAtom(); 55 Walker-> type = hydrogen;56 *Walker->node = Vector(1., 0., 1.);55 Walker->setType(hydrogen); 56 Walker->setPosition(Vector(1., 0., 1. )); 57 57 TestMolecule->AddAtom(Walker); 58 58 Walker = World::getInstance().createAtom(); 59 Walker-> type = hydrogen;60 *Walker->node = Vector(0., 1., 1.);59 Walker->setType(hydrogen); 60 Walker->setPosition(Vector(0., 1., 1. )); 61 61 TestMolecule->AddAtom(Walker); 62 62 Walker = World::getInstance().createAtom(); 63 Walker-> type = hydrogen;64 *Walker->node = Vector(1., 1., 0.);63 Walker->setType(hydrogen); 64 Walker->setPosition(Vector(1., 1., 0. )); 65 65 TestMolecule->AddAtom(Walker); 66 66 Walker = World::getInstance().createAtom(); 67 Walker-> type = hydrogen;68 *Walker->node = Vector(0., 0., 0.);67 Walker->setType(hydrogen); 68 Walker->setPosition(Vector(0., 0., 0. )); 69 69 TestMolecule->AddAtom(Walker); 70 70 -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
r8d6d31 r8f4df1 44 44 ASSERT_DO(Assert::Throw); 45 45 46 setVerbosity(5); 47 46 48 atom *Walker = NULL; 47 49 … … 62 64 63 65 Walker = World::getInstance().createAtom(); 64 Walker-> type = hydrogen;65 *Walker->node = Vector(1., 0., 1.);66 TestSurfaceMolecule->AddAtom(Walker); 67 68 Walker = World::getInstance().createAtom(); 69 Walker-> type = hydrogen;70 *Walker->node = Vector(0., 1., 1.);71 TestSurfaceMolecule->AddAtom(Walker); 72 73 Walker = World::getInstance().createAtom(); 74 Walker-> type = hydrogen;75 *Walker->node = Vector(1., 1., 0.);76 TestSurfaceMolecule->AddAtom(Walker); 77 78 Walker = World::getInstance().createAtom(); 79 Walker-> type = hydrogen;80 *Walker->node = Vector(0., 0., 0.);66 Walker->setType(hydrogen); 67 Walker->setPosition(Vector(1., 0., 1. )); 68 TestSurfaceMolecule->AddAtom(Walker); 69 70 Walker = World::getInstance().createAtom(); 71 Walker->setType(hydrogen); 72 Walker->setPosition(Vector(0., 1., 1. )); 73 TestSurfaceMolecule->AddAtom(Walker); 74 75 Walker = World::getInstance().createAtom(); 76 Walker->setType(hydrogen); 77 Walker->setPosition(Vector(1., 1., 0. )); 78 TestSurfaceMolecule->AddAtom(Walker); 79 80 Walker = World::getInstance().createAtom(); 81 Walker->setType(hydrogen); 82 Walker->setPosition(Vector(0., 0., 0. )); 81 83 TestSurfaceMolecule->AddAtom(Walker); 82 84 … … 95 97 TestSurfaceMolecule = World::getInstance().createMolecule(); 96 98 Walker = World::getInstance().createAtom(); 97 Walker-> type = carbon;98 *Walker->node = Vector(4., 0., 4.);99 TestSurfaceMolecule->AddAtom(Walker); 100 101 Walker = World::getInstance().createAtom(); 102 Walker-> type = carbon;103 *Walker->node = Vector(0., 4., 4.);104 TestSurfaceMolecule->AddAtom(Walker); 105 106 Walker = World::getInstance().createAtom(); 107 Walker-> type = carbon;108 *Walker->node = Vector(4., 4., 0.);99 Walker->setType(carbon); 100 Walker->setPosition(Vector(4., 0., 4. )); 101 TestSurfaceMolecule->AddAtom(Walker); 102 103 Walker = World::getInstance().createAtom(); 104 Walker->setType(carbon); 105 Walker->setPosition(Vector(0., 4., 4. )); 106 TestSurfaceMolecule->AddAtom(Walker); 107 108 Walker = World::getInstance().createAtom(); 109 Walker->setType(carbon); 110 Walker->setPosition(Vector(4., 4., 0. )); 109 111 TestSurfaceMolecule->AddAtom(Walker); 110 112 111 113 // add inner atoms 112 114 Walker = World::getInstance().createAtom(); 113 Walker-> type = carbon;114 *Walker->node = Vector(0.5, 0.5, 0.5);115 Walker->setType(carbon); 116 Walker->setPosition(Vector(0.5, 0.5, 0.5 )); 115 117 TestSurfaceMolecule->AddAtom(Walker); 116 118 -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
r8d6d31 r8f4df1 58 58 TestMolecule = World::getInstance().createMolecule(); 59 59 Walker = World::getInstance().createAtom(); 60 Walker-> type = hydrogen;61 *Walker->node = Vector(1., 0., 1.);60 Walker->setType(hydrogen); 61 Walker->setPosition(Vector(1., 0., 1. )); 62 62 TestMolecule->AddAtom(Walker); 63 63 Walker = World::getInstance().createAtom(); 64 Walker-> type = hydrogen;65 *Walker->node = Vector(0., 1., 1.);64 Walker->setType(hydrogen); 65 Walker->setPosition(Vector(0., 1., 1. )); 66 66 TestMolecule->AddAtom(Walker); 67 67 Walker = World::getInstance().createAtom(); 68 Walker-> type = hydrogen;69 *Walker->node = Vector(1., 1., 0.);68 Walker->setType(hydrogen); 69 Walker->setPosition(Vector(1., 1., 0. )); 70 70 TestMolecule->AddAtom(Walker); 71 71 Walker = World::getInstance().createAtom(); 72 Walker-> type = hydrogen;73 *Walker->node = Vector(0., 0., 0.);72 Walker->setType(hydrogen); 73 Walker->setPosition(Vector(0., 0., 0. )); 74 74 TestMolecule->AddAtom(Walker); 75 75 -
src/unittests/CountBondsUnitTest.cpp
r8d6d31 r8f4df1 54 54 Walker = World::getInstance().createAtom(); 55 55 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 56 Walker-> type = hydrogen;57 *Walker->node = Vector(-0.2418, 0.9350, 0.);56 Walker->setType(hydrogen); 57 Walker->setPosition(Vector(-0.2418, 0.9350, 0. )); 58 58 TestMolecule1->AddAtom(Walker); 59 59 Walker = World::getInstance().createAtom(); 60 60 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 61 Walker-> type = hydrogen;62 *Walker->node = Vector(0.9658, 0., 0.);61 Walker->setType(hydrogen); 62 Walker->setPosition(Vector(0.9658, 0., 0. )); 63 63 TestMolecule1->AddAtom(Walker); 64 64 Walker = World::getInstance().createAtom(); 65 65 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 66 Walker-> type = oxygen;67 *Walker->node = Vector(0., 0., 0.);66 Walker->setType(oxygen); 67 Walker->setPosition(Vector(0., 0., 0. )); 68 68 TestMolecule1->AddAtom(Walker); 69 69 … … 72 72 Walker = World::getInstance().createAtom(); 73 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 74 Walker-> type = hydrogen;75 *Walker->node = Vector(-0.2418, 0.9350, 0.);74 Walker->setType(hydrogen); 75 Walker->setPosition(Vector(-0.2418, 0.9350, 0. )); 76 76 TestMolecule2->AddAtom(Walker); 77 77 Walker = World::getInstance().createAtom(); 78 78 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 79 Walker-> type = hydrogen;80 *Walker->node = Vector(0.9658, 0., 0.);79 Walker->setType(hydrogen); 80 Walker->setPosition(Vector(0.9658, 0., 0. )); 81 81 TestMolecule2->AddAtom(Walker); 82 82 Walker = World::getInstance().createAtom(); 83 83 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 84 Walker-> type = oxygen;85 *Walker->node = Vector(0., 0., 0.);84 Walker->setType(oxygen); 85 Walker->setPosition(Vector(0., 0., 0. )); 86 86 TestMolecule2->AddAtom(Walker); 87 87 -
src/unittests/LinkedCellUnitTest.cpp
r8d6d31 r8f4df1 50 50 Walker = World::getInstance().createAtom(); 51 51 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 52 Walker-> type = hydrogen;53 *Walker->node = Vector(x, y, z);52 Walker->setType(hydrogen); 53 Walker->setPosition(Vector(x, y, z )); 54 54 TestMolecule->AddAtom(Walker); 55 55 } … … 192 192 atom *newAtom = World::getInstance().createAtom(); 193 193 newAtom->setName("test"); 194 newAtom-> x= Vector(1,1,1);194 newAtom->setPosition(Vector(1,1,1)); 195 195 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) ); 196 196 World::getInstance().destroyAtom(newAtom); … … 199 199 newAtom = World::getInstance().createAtom(); 200 200 newAtom->setName("test"); 201 newAtom-> x = Vector(0,-1,0);201 newAtom->setPosition(Vector(0,-1,0)); 202 202 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) ); 203 203 World::getInstance().destroyAtom(newAtom); … … 216 216 for (double z=0.5;z<3;z+=1.) { 217 217 tester = Vector(x,y,z); 218 CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector( &tester) );218 CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(tester) ); 219 219 } 220 220 // check corners of each cell … … 224 224 tester= Vector(x,y,z); 225 225 cout << "Tester is at " << tester << "." << endl; 226 CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector( &tester) );226 CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(tester) ); 227 227 } 228 228 // check out of bounds … … 232 232 tester = Vector(x,y,z); 233 233 cout << "The following test is supposed to fail and produce an ERROR." << endl; 234 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector( &tester) );234 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(tester) ); 235 235 } 236 236 // check nonsense vectors 237 237 tester= Vector(-423598,3245978,29349); 238 238 cout << "The following test is supposed to fail and produce an ERROR." << endl; 239 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector( &tester) );239 CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(tester) ); 240 240 }; 241 241 … … 249 249 250 250 tester= Vector(0.5,0.5,0.5); 251 LC->SetIndexToVector( &tester);251 LC->SetIndexToVector(tester); 252 252 LC->GetNeighbourBounds(lower, upper); 253 253 for (int i=0;i<NDIM;i++) … … 268 268 // get all atoms 269 269 tester= Vector(1.5,1.5,1.5); 270 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector( &tester) );270 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); 271 271 ListOfPoints = LC->GetallNeighbours(); 272 272 size = ListOfPoints->size(); … … 285 285 // get all atoms in one corner 286 286 tester= Vector(0.5, 0.5, 0.5); 287 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector( &tester) );287 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); 288 288 ListOfPoints = LC->GetallNeighbours(); 289 289 size=ListOfPoints->size(); 290 290 CPPUNIT_ASSERT_EQUAL( (size_t)8, size ); 291 291 for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){ 292 if (((*iter)-> x[0] <2) && ((*iter)->x[1] <2) && ((*iter)->x[2]<2)) {292 if (((*iter)->at(0) <2) && ((*iter)->at(1) <2) && ((*iter)->at(2) <2)) { 293 293 ListOfPoints->remove(*iter); 294 294 size--; … … 303 303 // get all atoms from one corner 304 304 tester = Vector(0.5, 0.5, 0.5); 305 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector( &tester) );305 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); 306 306 ListOfPoints = LC->GetallNeighbours(3); 307 307 size=ListOfPoints->size(); … … 329 329 // get all points around central arom with radius 1. 330 330 tester= Vector(1.5,1.5,1.5); 331 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector( &tester) );331 CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(tester) ); 332 332 ListOfPoints = LC->GetPointsInsideSphere(1., &tester); 333 333 size = ListOfPoints->size(); 334 334 CPPUNIT_ASSERT_EQUAL( (size_t)7, size ); 335 335 for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){ 336 if (((*iter)-> x.DistanceSquared(tester) - 1.) < MYEPSILON ) {336 if (((*iter)->DistanceSquared(tester) - 1.) < MYEPSILON ) { 337 337 ListOfPoints->remove(*iter); 338 338 size--; -
src/unittests/ParserUnitTest.cpp
r8d6d31 r8f4df1 208 208 input << Tremolo_Atomdata2; 209 209 testParser->load(&input); 210 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))-> x[0]== 3.0);210 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->at(0) == 3.0); 211 211 input.clear(); 212 212 } … … 219 219 input << Tremolo_velocity; 220 220 testParser->load(&input); 221 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))-> v[0] == 3.0);221 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->AtomicVelocity[0] == 3.0); 222 222 input.clear(); 223 223 } … … 271 271 // with the maximum number of fields and minimal information, default values are printed 272 272 atom* newAtom = World::getInstance().createAtom(); 273 newAtom-> type = World::getInstance().getPeriode()->FindElement(1);273 newAtom->setType(1); 274 274 testParser->setFieldsForSave("x=3 u=3 F stress Id neighbors=5 imprData GroupMeasureTypeNo Type extType name resName chainID resSeq occupancy tempFactor segID Charge charge GrpTypeNo torsion"); 275 275 testParser->save(&output); … … 304 304 atom *Walker = NULL; 305 305 Walker = World::getInstance().createAtom(); 306 Walker-> type = World::getInstance().getPeriode()->FindElement(8);307 Walker-> x = Vector(0,0,0);306 Walker->setType(8); 307 Walker->setPosition(Vector(0,0,0)); 308 308 Walker = World::getInstance().createAtom(); 309 Walker-> type = World::getInstance().getPeriode()->FindElement(1);310 Walker-> x = Vector(0.758602,0,0.504284);309 Walker->setType(1); 310 Walker->setPosition(Vector(0.758602,0,0.504284)); 311 311 Walker = World::getInstance().createAtom(); 312 Walker-> type = World::getInstance().getPeriode()->FindElement(1);313 Walker-> x = Vector(0.758602,0,-0.504284);312 Walker->setType(1); 313 Walker->setPosition(Vector(0.758602,0,-0.504284)); 314 314 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 315 315 -
src/unittests/analysisbondsunittest.cpp
r8d6d31 r8f4df1 16 16 #include <cstring> 17 17 18 #include "World.hpp"19 18 #include "analysis_bonds.hpp" 20 19 #include "analysisbondsunittest.hpp" … … 25 24 #include "molecule.hpp" 26 25 #include "periodentafel.hpp" 26 #include "LinearAlgebra/Vector.hpp" 27 27 #include "World.hpp" 28 28 … … 52 52 Walker = World::getInstance().createAtom(); 53 53 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 54 Walker-> type = hydrogen;55 *Walker->node = Vector(1.5, 0., 1.5);54 Walker->setType(hydrogen); 55 Walker->setPosition(Vector(1.5, 0., 1.5 )); 56 56 TestMolecule->AddAtom(Walker); 57 57 Walker = World::getInstance().createAtom(); 58 58 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 59 Walker-> type = hydrogen;60 *Walker->node = Vector(0., 1.5, 1.5);59 Walker->setType(hydrogen); 60 Walker->setPosition(Vector(0., 1.5, 1.5 )); 61 61 TestMolecule->AddAtom(Walker); 62 62 Walker = World::getInstance().createAtom(); 63 63 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 64 Walker-> type = hydrogen;65 *Walker->node = Vector(1.5, 1.5, 0.);64 Walker->setType(hydrogen); 65 Walker->setPosition(Vector(1.5, 1.5, 0. )); 66 66 TestMolecule->AddAtom(Walker); 67 67 Walker = World::getInstance().createAtom(); 68 68 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 69 Walker-> type = hydrogen;70 *Walker->node = Vector(0., 0., 0.);69 Walker->setType(hydrogen); 70 Walker->setPosition(Vector(0., 0., 0. )); 71 71 TestMolecule->AddAtom(Walker); 72 72 Walker = World::getInstance().createAtom(); 73 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 74 Walker-> type = carbon;75 *Walker->node = Vector(0.5, 0.5, 0.5);74 Walker->setType(carbon); 75 Walker->setPosition(Vector(0.5, 0.5, 0.5 )); 76 76 TestMolecule->AddAtom(Walker); 77 77 -
src/unittests/bondgraphunittest.cpp
r8d6d31 r8f4df1 54 54 Walker = World::getInstance().createAtom(); 55 55 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 56 Walker-> type = carbon;57 *Walker->node = Vector(1., 0., 1.);56 Walker->setType(carbon); 57 Walker->setPosition(Vector(1., 0., 1. )); 58 58 TestMolecule->AddAtom(Walker); 59 59 60 60 Walker = World::getInstance().createAtom(); 61 61 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 62 Walker-> type = carbon;63 *Walker->node = Vector(0., 1., 1.);62 Walker->setType(carbon); 63 Walker->setPosition(Vector(0., 1., 1. )); 64 64 TestMolecule->AddAtom(Walker); 65 65 66 66 Walker = World::getInstance().createAtom(); 67 67 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 68 Walker-> type = carbon;69 *Walker->node = Vector(1., 1., 0.);68 Walker->setType(carbon); 69 Walker->setPosition(Vector(1., 1., 0. )); 70 70 TestMolecule->AddAtom(Walker); 71 71 72 72 Walker = World::getInstance().createAtom(); 73 73 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 74 Walker-> type = carbon;75 *Walker->node = Vector(0., 0., 0.);74 Walker->setType(carbon); 75 Walker->setPosition(Vector(0., 0., 0. )); 76 76 TestMolecule->AddAtom(Walker); 77 77 -
src/unittests/listofbondsunittest.cpp
r8d6d31 r8f4df1 47 47 Walker = World::getInstance().createAtom(); 48 48 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 49 Walker-> type = hydrogen;50 *Walker->node = Vector(1., 0., 1.);51 TestMolecule->AddAtom(Walker); 52 Walker = World::getInstance().createAtom(); 53 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 54 Walker-> type = hydrogen;55 *Walker->node = Vector(0., 1., 1.);56 TestMolecule->AddAtom(Walker); 57 Walker = World::getInstance().createAtom(); 58 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 59 Walker-> type = hydrogen;60 *Walker->node = Vector(1., 1., 0.);61 TestMolecule->AddAtom(Walker); 62 Walker = World::getInstance().createAtom(); 63 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 64 Walker-> type = hydrogen;65 *Walker->node = Vector(0., 0., 0.);49 Walker->setType(hydrogen); 50 Walker->setPosition(Vector(1., 0., 1. )); 51 TestMolecule->AddAtom(Walker); 52 Walker = World::getInstance().createAtom(); 53 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 54 Walker->setType(hydrogen); 55 Walker->setPosition(Vector(0., 1., 1. )); 56 TestMolecule->AddAtom(Walker); 57 Walker = World::getInstance().createAtom(); 58 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 59 Walker->setType(hydrogen); 60 Walker->setPosition(Vector(1., 1., 0. )); 61 TestMolecule->AddAtom(Walker); 62 Walker = World::getInstance().createAtom(); 63 CPPUNIT_ASSERT(Walker != NULL && "could not create atom"); 64 Walker->setType(hydrogen); 65 Walker->setPosition(Vector(0., 0., 0. )); 66 66 TestMolecule->AddAtom(Walker); 67 67 -
src/unittests/tesselation_boundarytriangleunittest.cpp
r8d6d31 r8f4df1 13 13 14 14 #include <cstring> 15 #include <iostream> 15 16 16 17 #include "defs.hpp" 17 #include "tesselation.hpp" 18 #include "TesselPoint.hpp" 19 #include "BoundaryPointSet.hpp" 20 #include "BoundaryLineSet.hpp" 21 #include "BoundaryTriangleSet.hpp" 22 #include "CandidateForTesselation.hpp" 18 23 #include "tesselation_boundarytriangleunittest.hpp" 19 24 … … 36 41 // create nodes 37 42 tesselpoints[0] = new TesselPoint; 38 tesselpoints[0]-> node = new Vector(0., 0., 0.);43 tesselpoints[0]->setPosition(Vector(0., 0., 0.)); 39 44 tesselpoints[0]->setName("1"); 40 45 tesselpoints[0]->nr = 1; 41 46 points[0] = new BoundaryPointSet(tesselpoints[0]); 42 47 tesselpoints[1] = new TesselPoint; 43 tesselpoints[1]-> node = new Vector(0., 1., 0.);48 tesselpoints[1]->setPosition(Vector(0., 1., 0.)); 44 49 tesselpoints[1]->setName("2"); 45 50 tesselpoints[1]->nr = 2; 46 51 points[1] = new BoundaryPointSet(tesselpoints[1]); 47 52 tesselpoints[2] = new TesselPoint; 48 tesselpoints[2]-> node = new Vector(1., 0., 0.);53 tesselpoints[2]->setPosition(Vector(1., 0., 0.)); 49 54 tesselpoints[2]->setName("3"); 50 55 tesselpoints[2]->nr = 3; … … 67 72 for (int i=0;i<3;++i) { 68 73 // TesselPoint does not delete its vector as it only got a reference 69 delete tesselpoints[i]->node;70 74 delete tesselpoints[i]; 71 75 } … … 83 87 // simple test on y line 84 88 Point = Vector(-1.,0.5,0.); 85 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );89 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 86 90 Point = Vector(0.,0.5,0.); 87 91 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 88 92 Point = Vector(-4.,0.5,0.); 89 CPPUNIT_ASSERT_EQUAL( 16., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );93 CPPUNIT_ASSERT_EQUAL( 16., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 90 94 Point = Vector(0.,0.5,0.); 91 95 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 93 97 // simple test on x line 94 98 Point = Vector(0.5,-1.,0.); 95 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );99 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 96 100 Point = Vector(0.5,0.,0.); 97 101 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 98 102 Point = Vector(0.5,-6.,0.); 99 CPPUNIT_ASSERT_EQUAL( 36., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );103 CPPUNIT_ASSERT_EQUAL( 36., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 100 104 Point = Vector(0.5,0.,0.); 101 105 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 103 107 // simple test on slanted line 104 108 Point = Vector(1.,1.,0.); 105 CPPUNIT_ASSERT_EQUAL( 0.5, triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );109 CPPUNIT_ASSERT_EQUAL( 0.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 106 110 Point = Vector(0.5,0.5,0.); 107 111 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 108 112 Point = Vector(5.,5.,0.); 109 CPPUNIT_ASSERT_EQUAL( 40.5, triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );113 CPPUNIT_ASSERT_EQUAL( 40.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 110 114 Point = Vector(0.5,0.5,0.); 111 115 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 113 117 // simple test on first node 114 118 Point = Vector(-1.,-1.,0.); 115 CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );119 CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 116 120 Point = Vector(0.,0.,0.); 117 121 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 119 123 // simple test on second node 120 124 Point = Vector(0.,2.,0.); 121 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );125 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 122 126 Point = Vector(0.,1.,0.); 123 127 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 125 129 // simple test on third node 126 130 Point = Vector(2.,0.,0.); 127 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );131 CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 128 132 Point = Vector(1.,0.,0.); 129 133 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 139 143 // straight down/up 140 144 Point = Vector(1./3.,1./3.,+5.); 141 CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );145 CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 142 146 Point = Vector(1./3.,1./3.,0.); 143 147 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 144 148 Point = Vector(1./3.,1./3.,-5.); 145 CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );149 CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 146 150 Point = Vector(1./3.,1./3.,0.); 147 151 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 149 153 // simple test on y line 150 154 Point = Vector(-1.,0.5,+2.); 151 CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );155 CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 152 156 Point = Vector(0.,0.5,0.); 153 157 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 154 158 Point = Vector(-1.,0.5,-3.); 155 CPPUNIT_ASSERT_EQUAL( 10., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );159 CPPUNIT_ASSERT_EQUAL( 10., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 156 160 Point = Vector(0.,0.5,0.); 157 161 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 159 163 // simple test on x line 160 164 Point = Vector(0.5,-1.,+1.); 161 CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );165 CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 162 166 Point = Vector(0.5,0.,0.); 163 167 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 164 168 Point = Vector(0.5,-1.,-2.); 165 CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );169 CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 166 170 Point = Vector(0.5,0.,0.); 167 171 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 169 173 // simple test on slanted line 170 174 Point = Vector(1.,1.,+3.); 171 CPPUNIT_ASSERT_EQUAL( 9.5, triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );175 CPPUNIT_ASSERT_EQUAL( 9.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 172 176 Point = Vector(0.5,0.5,0.); 173 177 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 174 178 Point = Vector(1.,1.,-4.); 175 CPPUNIT_ASSERT_EQUAL( 16.5, triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );179 CPPUNIT_ASSERT_EQUAL( 16.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 176 180 Point = Vector(0.5,0.5,0.); 177 181 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 179 183 // simple test on first node 180 184 Point = Vector(-1.,-1.,5.); 181 CPPUNIT_ASSERT_EQUAL( 27., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );185 CPPUNIT_ASSERT_EQUAL( 27., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 182 186 Point = Vector(0.,0.,0.); 183 187 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 185 189 // simple test on second node 186 190 Point = Vector(0.,2.,5.); 187 CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );191 CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 188 192 Point = Vector(0.,1.,0.); 189 193 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); … … 191 195 // simple test on third node 192 196 Point = Vector(2.,0.,5.); 193 CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle( &Point, &TestIntersection) );197 CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) ); 194 198 Point = Vector(1.,0.,0.); 195 199 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); -
src/unittests/tesselation_boundarytriangleunittest.hpp
r8d6d31 r8f4df1 15 15 #include "linkedcell.hpp" 16 16 #include "tesselation.hpp" 17 18 class TesselPoint; 17 19 18 20 /********************************************** Test classes **************************************/ -
src/unittests/tesselation_insideoutsideunittest.cpp
r8d6d31 r8f4df1 13 13 14 14 #include <cstring> 15 #include <iostream> 15 16 16 17 #include "defs.hpp" 17 #include "tesselation.hpp" 18 #include "TesselPoint.hpp" 19 #include "BoundaryLineSet.hpp" 20 #include "BoundaryTriangleSet.hpp" 21 #include "CandidateForTesselation.hpp" 18 22 #include "tesselation_insideoutsideunittest.hpp" 19 23 #include "Helpers/Verbose.hpp" … … 30 34 CPPUNIT_TEST_SUITE_REGISTRATION( TesselationInOutsideTest ); 31 35 32 33 36 void TesselationInOutsideTest::setUp() 34 37 { … … 38 41 class TesselPoint *Walker; 39 42 Walker = new TesselPoint; 40 Walker-> node = new Vector(0., 0., 0.);43 Walker->setPosition(Vector(0., 0., 0.)); 41 44 Walker->setName("1"); 42 45 Walker->nr = 1; 43 46 Corners.push_back(Walker); 44 47 Walker = new TesselPoint; 45 Walker-> node = new Vector(0., 1., 0.);48 Walker->setPosition(Vector(0., 1., 0.)); 46 49 Walker->setName("2"); 47 50 Walker->nr = 2; 48 51 Corners.push_back(Walker); 49 52 Walker = new TesselPoint; 50 Walker-> node = new Vector(1., 0., 0.);53 Walker->setPosition(Vector(1., 0., 0.)); 51 54 Walker->setName("3"); 52 55 Walker->nr = 3; 53 56 Corners.push_back(Walker); 54 57 Walker = new TesselPoint; 55 Walker-> node = new Vector(1., 1., 0.);58 Walker->setPosition(Vector(1., 1., 0.)); 56 59 Walker->setName("4"); 57 60 Walker->nr = 4; 58 61 Corners.push_back(Walker); 59 62 Walker = new TesselPoint; 60 Walker-> node = new Vector(0., 0., 1.);63 Walker->setPosition(Vector(0., 0., 1.)); 61 64 Walker->setName("5"); 62 65 Walker->nr = 5; 63 66 Corners.push_back(Walker); 64 67 Walker = new TesselPoint; 65 Walker-> node = new Vector(0., 1., 1.);68 Walker->setPosition(Vector(0., 1., 1.)); 66 69 Walker->setName("6"); 67 70 Walker->nr = 6; 68 71 Corners.push_back(Walker); 69 72 Walker = new TesselPoint; 70 Walker-> node = new Vector(1., 0., 1.);73 Walker->setPosition(Vector(1., 0., 1.)); 71 74 Walker->setName("7"); 72 75 Walker->nr = 7; 73 76 Corners.push_back(Walker); 74 77 Walker = new TesselPoint; 75 Walker-> node = new Vector(1., 1., 1.);78 Walker->setPosition(Vector(1., 1., 1.)); 76 79 Walker->setName("8"); 77 80 Walker->nr = 8; … … 130 133 delete(LinkedList); 131 134 delete(TesselStruct); 132 for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) { 133 delete((*Runner)->node); 135 for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) 134 136 delete(*Runner); 135 }136 137 Corners.clear(); 137 138 logger::purgeInstance(); -
src/unittests/tesselationunittest.cpp
r8d6d31 r8f4df1 16 16 17 17 #include "defs.hpp" 18 #include "tesselation.hpp" 18 #include "TesselPoint.hpp" 19 #include "BoundaryLineSet.hpp" 20 #include "BoundaryTriangleSet.hpp" 21 #include "CandidateForTesselation.hpp" 19 22 #include "tesselationunittest.hpp" 20 23 … … 36 39 class TesselPoint *Walker; 37 40 Walker = new TesselPoint; 38 Walker-> node = new Vector(1., 0., -1.);41 Walker->setPosition(Vector(1., 0., -1.)); 39 42 Walker->setName("1"); 40 43 Walker->nr = 1; 41 44 Corners.push_back(Walker); 42 45 Walker = new TesselPoint; 43 Walker-> node = new Vector(-1., 1., -1.);46 Walker->setPosition(Vector(-1., 1., -1.)); 44 47 Walker->setName("2"); 45 48 Walker->nr = 2; 46 49 Corners.push_back(Walker); 47 50 Walker = new TesselPoint; 48 Walker-> node = new Vector(-1., -1., -1.);51 Walker->setPosition(Vector(-1., -1., -1.)); 49 52 Walker->setName("3"); 50 53 Walker->nr = 3; 51 54 Corners.push_back(Walker); 52 55 Walker = new TesselPoint; 53 Walker-> node = new Vector(-1., 0., 1.);56 Walker->setPosition(Vector(-1., 0., 1.)); 54 57 Walker->setName("4"); 55 58 Walker->nr = 4; … … 101 104 delete(LinkedList); 102 105 delete(TesselStruct); 103 for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) { 104 delete((*Runner)->node); 106 for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) 105 107 delete(*Runner); 106 }107 108 Corners.clear(); 108 109 logger::purgeInstance(); -
src/unittests/vectorunittest.cpp
r8d6d31 r8f4df1 16 16 #include "Helpers/Log.hpp" 17 17 #include "LinearAlgebra/Vector.hpp" 18 #include " vector_ops.hpp"18 #include "LinearAlgebra/vector_ops.hpp" 19 19 #include "vectorunittest.hpp" 20 20 #include "LinearAlgebra/Plane.hpp" … … 52 52 errorLogger::purgeInstance(); 53 53 }; 54 55 /** UnitTest for Constructors and Vector::IsZero() and Vector::IsOne(). 56 */ 57 void VectorTest::AssignmentTest() 58 { 59 // test with zero 60 zero.at(0) = 0; 61 zero.at(1) = 0; 62 zero.at(2) = 0; 63 double zero_array[3] = {0., 0., 0.}; 64 65 CPPUNIT_ASSERT_EQUAL( zero, Vector(0,0,0)); 66 CPPUNIT_ASSERT_EQUAL( zero, Vector(0.,0.,0.)); 67 CPPUNIT_ASSERT_EQUAL( zero, Vector(zero_array[0], zero_array[1], zero_array[2])); 68 CPPUNIT_ASSERT_EQUAL( zero, Vector(zero_array)); 69 70 // test with unit 71 unit.at(0) = 1; 72 unit.at(1) = 0; 73 unit.at(2) = 0; 74 double unit_array[3] = {1., 0., 0.}; 75 76 CPPUNIT_ASSERT_EQUAL( unit, Vector(1,0,0)); 77 CPPUNIT_ASSERT_EQUAL( unit, Vector(1.,0.,0.)); 78 CPPUNIT_ASSERT_EQUAL( unit, Vector(unit_array[0], unit_array[1], unit_array[2])); 79 CPPUNIT_ASSERT_EQUAL( unit, Vector(unit_array)); 80 81 // test with two 82 two.at(0) = 2; 83 two.at(1) = 1; 84 two.at(2) = 0; 85 double two_array[3] = {2., 1., 0.}; 86 87 CPPUNIT_ASSERT_EQUAL( two, Vector(2,1,0)); 88 CPPUNIT_ASSERT_EQUAL( two, Vector(2.,1.,0.)); 89 CPPUNIT_ASSERT_EQUAL( two, Vector(two_array[0], two_array[1], two_array[2])); 90 CPPUNIT_ASSERT_EQUAL( two, Vector(two_array)); 91 92 // test with three 93 three.at(0) = 1; 94 three.at(1) = 2; 95 three.at(2) = 3; 96 double three_array[3] = {1., 2., 3.}; 97 98 CPPUNIT_ASSERT_EQUAL( three, Vector(1,2,3)); 99 CPPUNIT_ASSERT_EQUAL( three, Vector(1.,2.,3.)); 100 CPPUNIT_ASSERT_EQUAL( three, Vector(three_array[0], three_array[1], three_array[2])); 101 CPPUNIT_ASSERT_EQUAL( three, Vector(three_array)); 102 } 54 103 55 104 /** UnitTest for Constructors and Vector::IsZero() and Vector::IsOne(). -
src/unittests/vectorunittest.hpp
r8d6d31 r8f4df1 18 18 { 19 19 CPPUNIT_TEST_SUITE( VectorTest) ; 20 CPPUNIT_TEST ( AssignmentTest ); 20 21 CPPUNIT_TEST ( UnityTest ); 21 22 CPPUNIT_TEST ( SimpleAlgebraTest ); … … 33 34 void tearDown(); 34 35 36 void AssignmentTest(); 35 37 void UnityTest(); 36 38 void OperatorAlgebraTest();
Note:
See TracChangeset
for help on using the changeset viewer.