- Timestamp:
- Oct 27, 2009, 4:11:22 PM (16 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, Candidate_v1.7.0, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- fb73b8
- Parents:
- ad37ab
- Location:
- src
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
src/analysis_correlation.cpp
rad37ab r776b64 24 24 * \return Map of doubles with values the pair of the two atoms. 25 25 */ 26 PairCorrelationMap *PairCorrelation( ofstream *out, molecule *mol, element *type1, element *type2 )26 PairCorrelationMap *PairCorrelation( const ofstream *out, const molecule * const mol, const element * const type1, const element * const type2 ) 27 27 { 28 28 PairCorrelationMap *outmap = NULL; … … 61 61 * \return Map of dobules with values as pairs of atom and the vector 62 62 */ 63 CorrelationToPointMap *CorrelationToPoint( ofstream *out, molecule *mol, element *type,Vector *point )63 CorrelationToPointMap *CorrelationToPoint( const ofstream *out, const molecule * const mol, const element * const type, const Vector *point ) 64 64 { 65 65 CorrelationToPointMap *outmap = NULL; … … 76 76 if ((type == NULL) || (Walker->type == type)) { 77 77 distance = Walker->node->Distance(point); 78 outmap->insert ( pair<double, pair<atom *, Vector*> >(distance, pair<atom *,Vector*> (Walker, point) ) );78 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) ); 79 79 } 80 80 } … … 91 91 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest 92 92 */ 93 CorrelationToSurfaceMap *CorrelationToSurface( ofstream *out, molecule *mol, element *type, Tesselation *Surface,LinkedCell *LC )93 CorrelationToSurfaceMap *CorrelationToSurface( ofstream *out, const molecule * const mol, const element * const type, const Tesselation * const Surface, const LinkedCell *LC ) 94 94 { 95 95 … … 124 124 * \param BinStart first bin 125 125 */ 126 double GetBin ( double value, double BinWidth,double BinStart )126 double GetBin ( const double value, const double BinWidth, const double BinStart ) 127 127 { 128 128 double bin =(double) (floor((value - BinStart)/BinWidth)); … … 135 135 * \param *map map to write 136 136 */ 137 void OutputCorrelation( ofstream *file, BinPairMap *map )137 void OutputCorrelation( ofstream *file, const BinPairMap * const map ) 138 138 { 139 139 *file << "# BinStart\tCount" << endl; 140 for (BinPairMap:: iterator runner = map->begin(); runner != map->end(); ++runner) {140 for (BinPairMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 141 141 *file << runner->first << "\t" << runner->second << endl; 142 142 } … … 147 147 * \param *map map to write 148 148 */ 149 void OutputPairCorrelation( ofstream *file, PairCorrelationMap *map )149 void OutputPairCorrelation( ofstream *file, const PairCorrelationMap * const map ) 150 150 { 151 151 *file << "# BinStart\tAtom1\tAtom2" << endl; 152 for (PairCorrelationMap:: iterator runner = map->begin(); runner != map->end(); ++runner) {152 for (PairCorrelationMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 153 153 *file << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl; 154 154 } … … 159 159 * \param *map map to write 160 160 */ 161 void OutputCorrelationToPoint( ofstream *file, CorrelationToPointMap *map )161 void OutputCorrelationToPoint( ofstream *file, const CorrelationToPointMap * const map ) 162 162 { 163 163 *file << "# BinStart\tAtom::x[i]-point.x[i]" << endl; 164 for (CorrelationToPointMap:: iterator runner = map->begin(); runner != map->end(); ++runner) {164 for (CorrelationToPointMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 165 165 *file << runner->first; 166 166 for (int i=0;i<NDIM;i++) … … 174 174 * \param *map map to write 175 175 */ 176 void OutputCorrelationToSurface( ofstream *file, CorrelationToSurfaceMap *map )176 void OutputCorrelationToSurface( ofstream *file, const CorrelationToSurfaceMap * const map ) 177 177 { 178 178 *file << "# BinStart\tTriangle" << endl; 179 for (CorrelationToSurfaceMap:: iterator runner = map->begin(); runner != map->end(); ++runner) {179 for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) { 180 180 *file << runner->first << "\t" << *(runner->second.second) << endl; 181 181 } -
src/analysis_correlation.hpp
rad37ab r776b64 39 39 40 40 typedef multimap<double, pair<atom *, atom *> > PairCorrelationMap; 41 typedef multimap<double, pair<atom *, Vector *> > CorrelationToPointMap;41 typedef multimap<double, pair<atom *, const Vector *> > CorrelationToPointMap; 42 42 typedef multimap<double, pair<atom *, BoundaryTriangleSet *> > CorrelationToSurfaceMap; 43 43 typedef map<double, int> BinPairMap; … … 45 45 /********************************************** declarations *******************************/ 46 46 47 PairCorrelationMap *PairCorrelation( ofstream *out, molecule *mol, element *type1, element *type2 );48 CorrelationToPointMap *CorrelationToPoint( ofstream *out, molecule *mol, element *type,Vector *point );49 CorrelationToSurfaceMap *CorrelationToSurface( ofstream *out, molecule *mol, element *type, Tesselation *Surface,LinkedCell *LC );50 double GetBin ( double value, double BinWidth,double BinStart );51 void OutputCorrelation( ofstream *file, BinPairMap *map );52 void OutputPairCorrelation( ofstream *file, BinPairMap *map );53 void OutputCorrelationToPoint( ofstream *file, BinPairMap *map );54 void OutputCorrelationToSurface( ofstream *file, BinPairMap *map );47 PairCorrelationMap *PairCorrelation( const ofstream *out, const molecule * const mol, const element * const type1, const element * const type2 ); 48 CorrelationToPointMap *CorrelationToPoint( const ofstream *out, const molecule * const mol, const element * const type, const Vector *point ); 49 CorrelationToSurfaceMap *CorrelationToSurface( ofstream *out, const molecule * const mol, const element * const type, const Tesselation * const Surface, const LinkedCell *LC ); 50 double GetBin ( const double value, const double BinWidth, const double BinStart ); 51 void OutputCorrelation( ofstream *file, const BinPairMap * const map ); 52 void OutputPairCorrelation( ofstream *file, const BinPairMap * const map ); 53 void OutputCorrelationToPoint( ofstream *file, const BinPairMap * const map ); 54 void OutputCorrelationToSurface( ofstream *file, const BinPairMap * const map ); 55 55 56 56 … … 95 95 * \return Map of doubles (the bins) with counts as values 96 96 */ 97 template <typename T> BinPairMap *BinData ( ofstream *out, T *map, double BinWidth, double BinStart,double BinEnd )97 template <typename T> BinPairMap *BinData ( ofstream *out, T *map, const double BinWidth, const double BinStart, const double BinEnd ) 98 98 { 99 99 BinPairMap *outmap = new BinPairMap; -
src/boundary.cpp
rad37ab r776b64 26 26 * \param *BoundaryPoints NDIM set of boundary points defining the convex envelope on each projected plane 27 27 * \param *mol molecule structure representing the cluster 28 * \param *&TesselStruct Tesselation structure with triangles 28 29 * \param IsAngstroem whether we have angstroem or atomic units 29 30 * \return NDIM array of the diameters 30 31 */ 31 double *GetDiametersOfCluster(ofstream *out, Boundaries *BoundaryPtr, molecule *mol,bool IsAngstroem)32 double *GetDiametersOfCluster(ofstream *out, const Boundaries *BoundaryPtr, const molecule *mol, Tesselation *&TesselStruct, const bool IsAngstroem) 32 33 { 33 34 // get points on boundary of NULL was given as parameter 34 35 bool BoundaryFreeFlag = false; 35 Boundaries *BoundaryPoints = BoundaryPtr;36 36 double OldComponent = 0.; 37 37 double tmp = 0.; … … 42 42 int component = 0; 43 43 int Othercomponent = 0; 44 Boundaries:: iterator Neighbour;45 Boundaries:: iterator OtherNeighbour;44 Boundaries::const_iterator Neighbour; 45 Boundaries::const_iterator OtherNeighbour; 46 46 double *GreatestDiameter = new double[NDIM]; 47 47 48 if (BoundaryPoints == NULL) { 48 const Boundaries *BoundaryPoints; 49 if (BoundaryPtr == NULL) { 49 50 BoundaryFreeFlag = true; 50 BoundaryPoints = GetBoundaryPoints(out, mol );51 BoundaryPoints = GetBoundaryPoints(out, mol, TesselStruct); 51 52 } else { 53 BoundaryPoints = BoundaryPtr; 52 54 *out << Verbose(1) << "Using given boundary points set." << endl; 53 55 } … … 63 65 Othercomponent = (axis + 1 + ((j + 1) & 1)) % NDIM; 64 66 //*out << Verbose(1) << "Current component is " << component << ", Othercomponent is " << Othercomponent << "." << endl; 65 for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner 66 != BoundaryPoints[axis].end(); runner++) 67 { 67 for (Boundaries::const_iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) { 68 68 //*out << Verbose(2) << "Current runner is " << *(runner->second.second) << "." << endl; 69 69 // seek for the neighbours pair where the Othercomponent sign flips … … 74 74 DistanceVector.CopyVector(&runner->second.second->x); 75 75 DistanceVector.SubtractVector(&Neighbour->second.second->x); 76 do 77 { // seek for neighbour pair where it flips 76 do { // seek for neighbour pair where it flips 78 77 OldComponent = DistanceVector.x[Othercomponent]; 79 78 Neighbour++; … … 83 82 DistanceVector.SubtractVector(&Neighbour->second.second->x); 84 83 //*out << Verbose(3) << "OldComponent is " << OldComponent << ", new one is " << DistanceVector.x[Othercomponent] << "." << endl; 85 } 86 while ((runner != Neighbour) && (fabs(OldComponent / fabs( 84 } while ((runner != Neighbour) && (fabs(OldComponent / fabs( 87 85 OldComponent) - DistanceVector.x[Othercomponent] / fabs( 88 86 DistanceVector.x[Othercomponent])) < MYEPSILON)); // as long as sign does not flip 89 if (runner != Neighbour) 90 { 87 if (runner != Neighbour) { 91 88 OtherNeighbour = Neighbour; 92 89 if (OtherNeighbour == BoundaryPoints[axis].begin()) // make it wrap around … … 133 130 * \param *out output stream for debugging 134 131 * \param *mol molecule structure representing the cluster 135 */ 136 Boundaries *GetBoundaryPoints(ofstream *out, molecule *mol) 132 * \param *&TesselStruct pointer to Tesselation structure 133 */ 134 Boundaries *GetBoundaryPoints(ofstream *out, const molecule *mol, Tesselation *&TesselStruct) 137 135 { 138 136 atom *Walker = NULL; … … 148 146 Vector ProjectedVector; 149 147 Boundaries *BoundaryPoints = new Boundaries[NDIM]; // first is alpha, second is (r, nr) 150 double radius = 0.;151 148 double angle = 0.; 152 149 … … 172 169 173 170 // correct for negative side 174 radius = ProjectedVector.NormSquared();171 const double radius = ProjectedVector.NormSquared(); 175 172 if (fabs(radius) > MYEPSILON) 176 173 angle = ProjectedVector.Angle(&AngleReferenceVector); … … 188 185 *out << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl; 189 186 *out << Verbose(2) << "New vector: " << *Walker << endl; 190 double tmp= ProjectedVector.NormSquared();191 if (( tmp- BoundaryTestPair.first->second.first) > MYEPSILON) {192 BoundaryTestPair.first->second.first = tmp;187 const double ProjectedVectorNorm = ProjectedVector.NormSquared(); 188 if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) { 189 BoundaryTestPair.first->second.first = ProjectedVectorNorm; 193 190 BoundaryTestPair.first->second.second = Walker; 194 *out << Verbose(2) << "Keeping new vector due to larger projected distance " << tmp<< "." << endl;195 } else if (fabs( tmp- BoundaryTestPair.first->second.first) < MYEPSILON) {191 *out << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl; 192 } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) { 196 193 helper.CopyVector(&Walker->x); 197 194 helper.SubtractVector(MolCenter); 198 tmp= helper.NormSquared();195 const double oldhelperNorm = helper.NormSquared(); 199 196 helper.CopyVector(&BoundaryTestPair.first->second.second->x); 200 197 helper.SubtractVector(MolCenter); 201 if (helper.NormSquared() < tmp) {198 if (helper.NormSquared() < oldhelperNorm) { 202 199 BoundaryTestPair.first->second.second = Walker; 203 200 *out << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl; 204 201 } else { 205 *out << Verbose(2) << "Keeping present vector due to larger distance to molecule center " << tmp<< "." << endl;202 *out << Verbose(2) << "Keeping present vector due to larger distance to molecule center " << oldhelperNorm << "." << endl; 206 203 } 207 204 } else { 208 *out << Verbose(2) << "Keeping present vector due to larger projected distance " << tmp<< "." << endl;205 *out << Verbose(2) << "Keeping present vector due to larger projected distance " << ProjectedVectorNorm << "." << endl; 209 206 } 210 207 } … … 305 302 /** Tesselates the convex boundary by finding all boundary points. 306 303 * \param *out output stream for debugging 307 * \param *mol molecule structure with Atom's and Bond's 304 * \param *mol molecule structure with Atom's and Bond's. 308 305 * \param *TesselStruct Tesselation filled with points, lines and triangles on boundary on return 309 306 * \param *LCList atoms in LinkedCell list … … 311 308 * \return *TesselStruct is filled with convex boundary and tesselation is stored under \a *filename. 312 309 */ 313 void FindConvexBorder(ofstream *out, molecule* mol, classLinkedCell *LCList, const char *filename)310 void FindConvexBorder(ofstream *out, const molecule* mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename) 314 311 { 315 312 bool BoundaryFreeFlag = false; … … 318 315 cout << Verbose(1) << "Begin of FindConvexBorder" << endl; 319 316 320 if ( mol->TesselStruct != NULL) // free if allocated321 delete( mol->TesselStruct);322 mol->TesselStruct = new class Tesselation;317 if (TesselStruct != NULL) // free if allocated 318 delete(TesselStruct); 319 TesselStruct = new class Tesselation; 323 320 324 321 // 1. Find all points on the boundary 325 322 if (BoundaryPoints == NULL) { 326 323 BoundaryFreeFlag = true; 327 BoundaryPoints = GetBoundaryPoints(out, mol );324 BoundaryPoints = GetBoundaryPoints(out, mol, TesselStruct); 328 325 } else { 329 326 *out << Verbose(1) << "Using given boundary points set." << endl; … … 348 345 for (int axis = 0; axis < NDIM; axis++) 349 346 for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) 350 if (! mol->TesselStruct->AddBoundaryPoint(runner->second.second, 0))347 if (!TesselStruct->AddBoundaryPoint(runner->second.second, 0)) 351 348 *out << Verbose(3) << "WARNING: Point " << *(runner->second.second) << " is already present!" << endl; 352 349 353 *out << Verbose(2) << "I found " << mol->TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl;350 *out << Verbose(2) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl; 354 351 // now we have the whole set of edge points in the BoundaryList 355 352 … … 362 359 363 360 // 3a. guess starting triangle 364 mol->TesselStruct->GuessStartingTriangle(out);361 TesselStruct->GuessStartingTriangle(out); 365 362 366 363 // 3b. go through all lines, that are not yet part of two triangles (only of one so far) 367 mol->TesselStruct->TesselateOnBoundary(out, mol);364 TesselStruct->TesselateOnBoundary(out, mol); 368 365 369 366 // 3c. check whether all atoms lay inside the boundary, if not, add to boundary points, segment triangle into three with the new point 370 if (! mol->TesselStruct->InsertStraddlingPoints(out, mol, LCList))367 if (!TesselStruct->InsertStraddlingPoints(out, mol, LCList)) 371 368 *out << Verbose(1) << "Insertion of straddling points failed!" << endl; 372 369 373 *out << Verbose(2) << "I created " << mol->TesselStruct->TrianglesOnBoundary.size() << " intermediate triangles with " << mol->TesselStruct->LinesOnBoundary.size() << " lines and " << mol->TesselStruct->PointsOnBoundary.size() << " points." << endl;370 *out << Verbose(2) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " intermediate triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl; 374 371 375 372 // 4. Store triangles in tecplot file … … 380 377 OutputName.append(TecplotSuffix); 381 378 ofstream *tecplot = new ofstream(OutputName.c_str()); 382 WriteTecplotFile(out, tecplot, mol->TesselStruct, mol, 0);379 WriteTecplotFile(out, tecplot, TesselStruct, mol, 0); 383 380 tecplot->close(); 384 381 delete(tecplot); … … 389 386 OutputName.append(Raster3DSuffix); 390 387 ofstream *rasterplot = new ofstream(OutputName.c_str()); 391 WriteRaster3dFile(out, rasterplot, mol->TesselStruct, mol);388 WriteRaster3dFile(out, rasterplot, TesselStruct, mol); 392 389 rasterplot->close(); 393 390 delete(rasterplot); … … 400 397 do { 401 398 AllConvex = true; 402 for (LineMap::iterator LineRunner = mol->TesselStruct->LinesOnBoundary.begin(); LineRunner != mol->TesselStruct->LinesOnBoundary.end(); LineRunner++) {399 for (LineMap::iterator LineRunner = TesselStruct->LinesOnBoundary.begin(); LineRunner != TesselStruct->LinesOnBoundary.end(); LineRunner++) { 403 400 line = LineRunner->second; 404 401 *out << Verbose(1) << "INFO: Current line is " << *line << "." << endl; … … 407 404 408 405 // flip the line 409 if ( mol->TesselStruct->PickFarthestofTwoBaselines(out, line) == 0.)406 if (TesselStruct->PickFarthestofTwoBaselines(out, line) == 0.) 410 407 *out << Verbose(1) << "ERROR: Correction of concave baselines failed!" << endl; 411 408 else { 412 mol->TesselStruct->FlipBaseline(out, line);409 TesselStruct->FlipBaseline(out, line); 413 410 *out << Verbose(1) << "INFO: Correction of concave baselines worked." << endl; 414 411 } … … 418 415 419 416 // 3e. we need another correction here, for TesselPoints that are below the surface (i.e. have an odd number of concave triangles surrounding it) 420 // if (! mol->TesselStruct->CorrectConcaveTesselPoints(out))417 // if (!TesselStruct->CorrectConcaveTesselPoints(out)) 421 418 // *out << Verbose(1) << "Correction of concave tesselpoints failed!" << endl; 422 419 423 *out << Verbose(2) << "I created " << mol->TesselStruct->TrianglesOnBoundary.size() << " triangles with " << mol->TesselStruct->LinesOnBoundary.size() << " lines and " << mol->TesselStruct->PointsOnBoundary.size() << " points." << endl;420 *out << Verbose(2) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl; 424 421 425 422 // 4. Store triangles in tecplot file … … 429 426 OutputName.append(TecplotSuffix); 430 427 ofstream *tecplot = new ofstream(OutputName.c_str()); 431 WriteTecplotFile(out, tecplot, mol->TesselStruct, mol, 0);428 WriteTecplotFile(out, tecplot, TesselStruct, mol, 0); 432 429 tecplot->close(); 433 430 delete(tecplot); … … 437 434 OutputName.append(Raster3DSuffix); 438 435 ofstream *rasterplot = new ofstream(OutputName.c_str()); 439 WriteRaster3dFile(out, rasterplot, mol->TesselStruct, mol);436 WriteRaster3dFile(out, rasterplot, TesselStruct, mol); 440 437 rasterplot->close(); 441 438 delete(rasterplot); … … 458 455 * \return true - all removed, false - something went wrong 459 456 */ 460 bool RemoveAllBoundaryPoints(ofstream *out, class Tesselation * TesselStruct, molecule *mol, char *filename)457 bool RemoveAllBoundaryPoints(ofstream *out, class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename) 461 458 { 462 459 int i=0; … … 481 478 // store envelope 482 479 sprintf(number, "-%04d", i++); 483 StoreTrianglesinFile(out, mol, filename, number);480 StoreTrianglesinFile(out, mol, (const Tesselation *&)TesselStruct, filename, number); 484 481 } 485 482 … … 511 508 * \return volume difference between the non- and the created convex envelope 512 509 */ 513 double ConvexizeNonconvexEnvelope(ofstream *out, class Tesselation * TesselStruct, molecule *mol, char *filename)510 double ConvexizeNonconvexEnvelope(ofstream *out, class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename) 514 511 { 515 512 double volume = 0; … … 539 536 sprintf(dummy, "-first-%d", run); 540 537 //CalculateConcavityPerBoundaryPoint(out, TesselStruct); 541 StoreTrianglesinFile(out, mol, filename, dummy);538 StoreTrianglesinFile(out, mol, (const Tesselation *&)TesselStruct, filename, dummy); 542 539 543 540 PointRunner = TesselStruct->PointsOnBoundary.begin(); … … 555 552 volume += TesselStruct->RemovePointFromTesselatedSurface(out, point); 556 553 sprintf(dummy, "-first-%d", ++run); 557 StoreTrianglesinFile(out, mol, filename, dummy);554 StoreTrianglesinFile(out, mol, (const Tesselation *&)TesselStruct, filename, dummy); 558 555 Concavity = true; 559 556 break; … … 565 562 sprintf(dummy, "-second-%d", run); 566 563 //CalculateConcavityPerBoundaryPoint(out, TesselStruct); 567 StoreTrianglesinFile(out, mol, filename, dummy);564 StoreTrianglesinFile(out, mol, (const Tesselation *&)TesselStruct, filename, dummy); 568 565 569 566 // second step: PickFarthestofTwoBaselines … … 579 576 volume += tmp; 580 577 if (tmp != 0.) { 581 mol->TesselStruct->FlipBaseline(out, line);578 TesselStruct->FlipBaseline(out, line); 582 579 Concavity = true; 583 580 } … … 611 608 612 609 CalculateConcavityPerBoundaryPoint(out, TesselStruct); 613 StoreTrianglesinFile(out, mol, filename, "");610 StoreTrianglesinFile(out, mol, (const Tesselation *&)TesselStruct, filename, ""); 614 611 615 612 // end … … 668 665 * \param *out output stream for debugging 669 666 * \param *mol molecule with atoms and bonds 667 * \param *&TesselStruct Tesselation with boundary triangles 670 668 * \param *filename prefix of filename 671 669 * \param *extraSuffix intermediate suffix 672 670 */ 673 void StoreTrianglesinFile(ofstream *out, molecule *mol, const char *filename, const char *extraSuffix)671 void StoreTrianglesinFile(ofstream *out, const molecule * const mol, const Tesselation *&TesselStruct, const char *filename, const char *extraSuffix) 674 672 { 675 673 // 4. Store triangles in tecplot file … … 680 678 OutputName.append(TecplotSuffix); 681 679 ofstream *tecplot = new ofstream(OutputName.c_str()); 682 WriteTecplotFile(out, tecplot, mol->TesselStruct, mol, 0);680 WriteTecplotFile(out, tecplot, TesselStruct, mol, 0); 683 681 tecplot->close(); 684 682 delete(tecplot); … … 689 687 OutputName.append(Raster3DSuffix); 690 688 ofstream *rasterplot = new ofstream(OutputName.c_str()); 691 WriteRaster3dFile(out, rasterplot, mol->TesselStruct, mol);689 WriteRaster3dFile(out, rasterplot, TesselStruct, mol); 692 690 rasterplot->close(); 693 691 delete(rasterplot); … … 701 699 * \param *configuration needed for path to store convex envelope file 702 700 * \param *mol molecule structure representing the cluster 701 * \param *&TesselStruct Tesselation structure with triangles on return 703 702 * \param ClusterVolume guesstimated cluster volume, if equal 0 we used VolumeOfConvexEnvelope() instead. 704 703 * \param celldensity desired average density in final cell … … 722 721 723 722 IsAngstroem = configuration->GetIsAngstroem(); 724 GreatestDiameter = GetDiametersOfCluster(out, BoundaryPoints, mol, IsAngstroem);725 BoundaryPoints = GetBoundaryPoints(out, mol );723 GreatestDiameter = GetDiametersOfCluster(out, BoundaryPoints, mol, TesselStruct, IsAngstroem); 724 BoundaryPoints = GetBoundaryPoints(out, mol, TesselStruct); 726 725 LinkedCell LCList(mol, 10.); 727 FindConvexBorder(out, mol, &LCList, NULL);726 FindConvexBorder(out, mol, TesselStruct, &LCList, NULL); 728 727 729 728 // some preparations beforehand … … 821 820 LinkedCell *LCList[List->ListOfMolecules.size()]; 822 821 double phi[NDIM]; 822 class Tesselation *TesselStruct[List->ListOfMolecules.size()]; 823 823 824 824 *out << Verbose(0) << "Begin of FillBoxWithMolecule" << endl; … … 828 828 *out << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl; 829 829 LCList[i] = new LinkedCell((*ListRunner), 5.); // get linked cell list 830 if ( (*ListRunner)->TesselStruct== NULL) {830 if (TesselStruct[i] == NULL) { 831 831 *out << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl; 832 FindNonConvexBorder((ofstream *)&cout, (*ListRunner), LCList[i], 5., NULL);832 FindNonConvexBorder((ofstream *)&cout, (*ListRunner), TesselStruct[i], (const LinkedCell *&)LCList[i], 5., NULL); 833 833 } 834 834 i++; … … 868 868 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) { 869 869 // get linked cell list 870 if ( (*ListRunner)->TesselStruct== NULL) {870 if (TesselStruct[i] == NULL) { 871 871 *out << Verbose(1) << "ERROR: TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl; 872 872 FillIt = false; 873 } else 874 FillIt = FillIt && (!(*ListRunner)->TesselStruct->IsInnerPoint(out, CurrentPosition, LCList[i++])); 873 } else { 874 FillIt = FillIt && (!TesselStruct[i]->IsInnerPoint(out, CurrentPosition, LCList[i])); 875 i++; 876 } 875 877 } 876 878 … … 947 949 * \param *out output stream for debugging 948 950 * \param *mol molecule structure with Atom's and Bond's 949 * \param * TessTesselation filled with points, lines and triangles on boundary on return950 * \param * LCList atoms in LinkedCell list951 * \param *&TesselStruct Tesselation filled with points, lines and triangles on boundary on return 952 * \param *&LCList atoms in LinkedCell list 951 953 * \param RADIUS radius of the virtual sphere 952 954 * \param *filename filename prefix for output of vertex data 953 955 */ 954 void FindNonConvexBorder(ofstream *out, molecule* mol, class LinkedCell *LCList, const double RADIUS, const char *filename = NULL)956 void FindNonConvexBorder(ofstream *out, const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *&LCList, const double RADIUS, const char *filename = NULL) 955 957 { 956 958 bool freeLC = false; … … 961 963 962 964 *out << Verbose(1) << "Entering search for non convex hull. " << endl; 963 if ( mol->TesselStruct == NULL) {965 if (TesselStruct == NULL) { 964 966 *out << Verbose(1) << "Allocating Tesselation struct ..." << endl; 965 mol->TesselStruct= new Tesselation;967 TesselStruct= new Tesselation; 966 968 } else { 967 delete( mol->TesselStruct);969 delete(TesselStruct); 968 970 *out << Verbose(1) << "Re-Allocating Tesselation struct ..." << endl; 969 mol->TesselStruct = new Tesselation;971 TesselStruct = new Tesselation; 970 972 } 971 973 … … 979 981 980 982 // 1. get starting triangle 981 mol->TesselStruct->FindStartingTriangle(out, RADIUS, LCList);983 TesselStruct->FindStartingTriangle(out, RADIUS, LCList); 982 984 983 985 // 2. expand from there 984 baseline = mol->TesselStruct->LinesOnBoundary.begin();986 baseline = TesselStruct->LinesOnBoundary.begin(); 985 987 baseline++; // skip first line 986 while ((baseline != mol->TesselStruct->LinesOnBoundary.end()) || (OneLoopWithoutSuccessFlag)) {988 while ((baseline != TesselStruct->LinesOnBoundary.end()) || (OneLoopWithoutSuccessFlag)) { 987 989 if (baseline->second->triangles.size() == 1) { 988 990 // 3. find next triangle 989 TesselationFailFlag = mol->TesselStruct->FindNextSuitableTriangle(out, *(baseline->second), *(((baseline->second->triangles.begin()))->second), RADIUS, LCList); //the line is there, so there is a triangle, but only one.991 TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(out, *(baseline->second), *(((baseline->second->triangles.begin()))->second), RADIUS, LCList); //the line is there, so there is a triangle, but only one. 990 992 OneLoopWithoutSuccessFlag = OneLoopWithoutSuccessFlag || TesselationFailFlag; 991 993 if (!TesselationFailFlag) … … 994 996 // write temporary envelope 995 997 if (filename != NULL) { 996 if ((DoSingleStepOutput && (( mol->TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration997 mol->TesselStruct->Output(out, filename, mol);998 if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration 999 TesselStruct->Output(out, filename, mol); 998 1000 } 999 1001 } 1000 baseline = mol->TesselStruct->LinesOnBoundary.end();1002 baseline = TesselStruct->LinesOnBoundary.end(); 1001 1003 *out << Verbose(2) << "Baseline set to end." << endl; 1002 1004 } else { … … 1006 1008 } 1007 1009 1008 if ((baseline == mol->TesselStruct->LinesOnBoundary.end()) && (OneLoopWithoutSuccessFlag)) {1009 baseline = mol->TesselStruct->LinesOnBoundary.begin(); // restart if we reach end due to newly inserted lines1010 if ((baseline == TesselStruct->LinesOnBoundary.end()) && (OneLoopWithoutSuccessFlag)) { 1011 baseline = TesselStruct->LinesOnBoundary.begin(); // restart if we reach end due to newly inserted lines 1010 1012 OneLoopWithoutSuccessFlag = false; 1011 1013 } … … 1013 1015 } 1014 1016 // check envelope for consistency 1015 CheckListOfBaselines(out, mol->TesselStruct);1017 CheckListOfBaselines(out, TesselStruct); 1016 1018 1017 1019 // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles 1018 // mol->TesselStruct->InsertStraddlingPoints(out, mol, LCList);1020 //->InsertStraddlingPoints(out, mol, LCList); 1019 1021 // mol->GoToFirst(); 1020 1022 // class TesselPoint *Runner = NULL; … … 1022 1024 // Runner = mol->GetPoint(); 1023 1025 // *out << Verbose(1) << "Checking on " << Runner->Name << " ... " << endl; 1024 // if (! mol->TesselStruct->IsInnerPoint(out, Runner, LCList)) {1026 // if (!->IsInnerPoint(out, Runner, LCList)) { 1025 1027 // *out << Verbose(2) << Runner->Name << " is outside of envelope, adding via degenerated triangles." << endl; 1026 // mol->TesselStruct->AddBoundaryPointByDegeneratedTriangle(out, Runner, LCList);1028 // ->AddBoundaryPointByDegeneratedTriangle(out, Runner, LCList); 1027 1029 // } else { 1028 1030 // *out << Verbose(2) << Runner->Name << " is inside of or on envelope." << endl; … … 1032 1034 1033 1035 // Purges surplus triangles. 1034 mol->TesselStruct->RemoveDegeneratedTriangles();1036 TesselStruct->RemoveDegeneratedTriangles(); 1035 1037 1036 1038 // check envelope for consistency 1037 CheckListOfBaselines(out, mol->TesselStruct);1039 CheckListOfBaselines(out, TesselStruct); 1038 1040 1039 1041 // write final envelope 1040 CalculateConcavityPerBoundaryPoint(out, mol->TesselStruct);1041 StoreTrianglesinFile(out, mol, filename, "");1042 CalculateConcavityPerBoundaryPoint(out, TesselStruct); 1043 StoreTrianglesinFile(out, mol, (const Tesselation *&)TesselStruct, filename, ""); 1042 1044 1043 1045 if (freeLC) -
src/boundary.hpp
rad37ab r776b64 48 48 /********************************************** declarations *******************************/ 49 49 50 double ConvexizeNonconvexEnvelope(ofstream *out, class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename); 51 molecule * FillBoxWithMolecule(ofstream *out, MoleculeListClass *List, molecule *filler, config &configuration, double distance[NDIM], double RandAtomDisplacement, double RandMolDisplacement, bool DoRandomRotation); 52 void FindConvexBorder(ofstream *out, const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename); 53 Vector* FindEmbeddingHole(ofstream *out, MoleculeListClass *mols, molecule *srcmol); 54 void FindNextSuitablePoint(class BoundaryTriangleSet *BaseTriangle, class BoundaryLineSet *BaseLine, atom*& OptCandidate, Vector *OptCandidateCenter, double *ShortestAngle, const double RADIUS, LinkedCell *LC); 55 void FindNonConvexBorder(ofstream *out, const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *&LC, const double RADIUS, const char *tempbasename); 56 Boundaries *GetBoundaryPoints(ofstream *out, const molecule *mol, Tesselation *&TesselStruct); 57 double * GetDiametersOfCluster(ofstream *out, const Boundaries *BoundaryPtr, const molecule *mol, Tesselation *&TesselStruct, const bool IsAngstroem); 58 void PrepareClustersinWater(ofstream *out, config *configuration, molecule *mol, double ClusterVolume, double celldensity); 59 bool RemoveAllBoundaryPoints(ofstream *out, class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename); 60 void StoreTrianglesinFile(ofstream *out, const molecule * const mol, const Tesselation *&TesselStruct, const char *filename, const char *extraSuffix); 50 61 double VolumeOfConvexEnvelope(ofstream *out, class Tesselation *TesselStruct, class config *configuration); 51 double * GetDiametersOfCluster(ofstream *out, Boundaries *BoundaryPtr, molecule *mol, bool IsAngstroem);52 void PrepareClustersinWater(ofstream *out, config *configuration, molecule *mol, double ClusterVolume, double celldensity);53 molecule * FillBoxWithMolecule(ofstream *out, MoleculeListClass *List, molecule *filler, config &configuration, double distance[NDIM], double RandAtomDisplacement, double RandMolDisplacement, bool DoRandomRotation);54 void FindConvexBorder(ofstream *out, molecule* mol, class LinkedCell *LCList, const char *filename);55 void FindNonConvexBorder(ofstream *out, molecule* mol, class LinkedCell *LC, const double RADIUS, const char *tempbasename);56 double ConvexizeNonconvexEnvelope(ofstream *out, class Tesselation *TesselStruct, molecule *mol, char *filename);57 void FindNextSuitablePoint(class BoundaryTriangleSet *BaseTriangle, class BoundaryLineSet *BaseLine, atom*& OptCandidate, Vector *OptCandidateCenter, double *ShortestAngle, const double RADIUS, LinkedCell *LC);58 Boundaries *GetBoundaryPoints(ofstream *out, molecule *mol);59 void StoreTrianglesinFile(ofstream *out, molecule *mol, const char *filename, const char *extraSuffix);60 bool RemoveAllBoundaryPoints(ofstream *out, class Tesselation *TesselStruct, molecule *mol, char *filename);61 Vector* FindEmbeddingHole(ofstream *out, MoleculeListClass *mols, molecule *srcmol);62 62 63 63 -
src/builder.cpp
rad37ab r776b64 254 254 } while ((j != -1) && (i<128)); 255 255 if (i >= 2) { 256 first->x.LSQdistance( atoms, i);256 first->x.LSQdistance((const Vector **)atoms, i); 257 257 258 258 first->x.Output((ofstream *)&cout); … … 592 592 { 593 593 cout << Verbose(0) << "Evaluating volume of the convex envelope."; 594 LinkedCell LCList(mol, 10.);595 594 class Tesselation *TesselStruct = NULL; 596 FindConvexBorder((ofstream *)&cout, mol, &LCList, NULL); 595 const LinkedCell *LCList = NULL; 596 LCList = new LinkedCell(mol, 10.); 597 FindConvexBorder((ofstream *)&cout, mol, TesselStruct, LCList, NULL); 597 598 double clustervolume = VolumeOfConvexEnvelope((ofstream *)&cout, TesselStruct, configuration); 598 cout << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl; 599 cout << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl;\ 600 delete(LCList); 599 601 delete(TesselStruct); 600 602 } … … 720 722 cin >> factor[2]; 721 723 valid = true; 722 mol->Scale( &factor);724 mol->Scale((const double ** const)&factor); 723 725 delete[](factor); 724 726 } … … 1588 1590 // get the boundary 1589 1591 class molecule *Boundary = new molecule(periode); 1592 class Tesselation *TesselStruct = NULL; 1590 1593 struct ConfigFileBuffer *FileBuffer = NULL; 1591 1594 PrepareFileBuffer(argv[argptr], FileBuffer); 1592 1595 LoadMolecule(Boundary, FileBuffer, periode, false); 1593 LinkedCell LCList(Boundary, 2.*radius); 1596 const LinkedCell *LCList = NULL; 1597 LCList = new LinkedCell(Boundary, 2.*radius); 1594 1598 element *oxygen = periode->FindElement(8); 1595 FindNonConvexBorder((ofstream *)&cout, Boundary, &LCList, radius, NULL); 1596 1597 CorrelationToSurfaceMap *surfacemap = CorrelationToSurface( (ofstream *)&cout, mol, oxygen, Boundary->TesselStruct, &LCList ); 1599 FindNonConvexBorder((ofstream *)&cout, Boundary, TesselStruct, LCList, radius, NULL); 1600 CorrelationToSurfaceMap *surfacemap = CorrelationToSurface( (ofstream *)&cout, mol, oxygen, TesselStruct, LCList ); 1598 1601 BinPairMap *binmap = BinData( (ofstream *)&cout, surfacemap, 0.5, 0., 0. ); 1599 1602 OutputCorrelation ( &binoutput, binmap ); 1600 1603 output.close(); 1601 1604 binoutput.close(); 1605 delete(LCList); 1602 1606 delete(FileBuffer); 1607 delete(TesselStruct); 1603 1608 delete(Boundary); 1604 1609 argptr+=3; … … 1675 1680 cerr << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl; 1676 1681 } else { 1677 class Tesselation T; 1682 class Tesselation *T = NULL; 1683 const LinkedCell *LCList = NULL; 1678 1684 string filename(argv[argptr+1]); 1679 1685 filename.append(".csv"); … … 1681 1687 cout << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl; 1682 1688 start = clock(); 1683 L inkedCell LCList(mol, atof(argv[argptr])*2.);1684 FindNonConvexBorder((ofstream *)&cout, mol, &LCList, atof(argv[argptr]), argv[argptr+1]);1685 //FindDistributionOfEllipsoids((ofstream *)&cout, &T, &LCList, N, number, filename.c_str());1689 LCList = new LinkedCell(mol, atof(argv[argptr])*2.); 1690 FindNonConvexBorder((ofstream *)&cout, mol, T, LCList, atof(argv[argptr]), argv[argptr+1]); 1691 //FindDistributionOfEllipsoids((ofstream *)&cout, T, &LCList, N, number, filename.c_str()); 1686 1692 end = clock(); 1687 1693 cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl; 1694 delete(LCList); 1688 1695 argptr+=2; 1689 1696 } … … 1806 1813 factor[1] = atof(argv[argptr+1]); 1807 1814 factor[2] = atof(argv[argptr+2]); 1808 mol->Scale( &factor);1815 mol->Scale((const double ** const)&factor); 1809 1816 for (int i=0;i<NDIM;i++) { 1810 1817 j += i+1; … … 1935 1942 cerr << "Not enough or invalid arguments given for convex envelope: -o <convex output file> <non-convex output file>" << endl; 1936 1943 } else { 1944 class Tesselation *TesselStruct = NULL; 1945 const LinkedCell *LCList = NULL; 1937 1946 cout << Verbose(0) << "Evaluating volume of the convex envelope."; 1938 1947 cout << Verbose(1) << "Storing tecplot convex data in " << argv[argptr] << "." << endl; 1939 1948 cout << Verbose(1) << "Storing tecplot non-convex data in " << argv[argptr+1] << "." << endl; 1940 L inkedCell LCList(mol, 10.);1941 //FindConvexBorder((ofstream *)&cout, mol, &LCList, argv[argptr]);1942 FindNonConvexBorder((ofstream *)&cout, mol, &LCList, 5., argv[argptr+1]);1943 // RemoveAllBoundaryPoints((ofstream *)&cout, mol->TesselStruct, mol, argv[argptr]);1944 double volumedifference = ConvexizeNonconvexEnvelope((ofstream *)&cout, mol->TesselStruct, mol, argv[argptr]);1945 double clustervolume = VolumeOfConvexEnvelope((ofstream *)&cout, mol->TesselStruct, &configuration);1949 LCList = new LinkedCell(mol, 10.); 1950 //FindConvexBorder((ofstream *)&cout, mol, LCList, argv[argptr]); 1951 FindNonConvexBorder((ofstream *)&cout, mol, TesselStruct, LCList, 5., argv[argptr+1]); 1952 // RemoveAllBoundaryPoints((ofstream *)&cout, TesselStruct, mol, argv[argptr]); 1953 double volumedifference = ConvexizeNonconvexEnvelope((ofstream *)&cout, TesselStruct, mol, argv[argptr]); 1954 double clustervolume = VolumeOfConvexEnvelope((ofstream *)&cout, TesselStruct, &configuration); 1946 1955 cout << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl; 1947 1956 cout << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl; 1957 delete(TesselStruct); 1958 delete(LCList); 1948 1959 argptr+=2; 1949 1960 } -
src/ellipsoid.cpp
rad37ab r776b64 234 234 int index; 235 235 TesselPoint *Candidate = NULL; 236 LinkedNodes *List = NULL;237 236 *out << Verbose(2) << "Begin of PickRandomPointSet" << endl; 238 237 … … 249 248 *out << Verbose(2) << "INFO: Center cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " ... "; 250 249 // get random cell 251 List = LC->GetCurrentCell();250 const LinkedNodes *List = LC->GetCurrentCell(); 252 251 if (List == NULL) { // set index to it 253 252 continue; … … 268 267 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 269 268 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 270 List = LC->GetCurrentCell();269 const LinkedNodes *List = LC->GetCurrentCell(); 271 270 PointsLeft += List->size(); 272 271 } … … 293 292 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 294 293 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 295 List = LC->GetCurrentCell();294 const LinkedNodes *List = LC->GetCurrentCell(); 296 295 // *out << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl; 297 296 if (List != NULL) { … … 300 299 // else 301 300 // *out << Verbose(2) << "Cell is empty ... " << endl; 302 for (LinkedNodes:: iterator Runner = List->begin(); Runner != List->end(); Runner++) {301 for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 303 302 if ((current != PickedAtomNrs.end()) && (*current == index)) { 304 303 Candidate = (*Runner); -
src/leastsquaremin.cpp
rad37ab r776b64 16 16 * \return sum of square distances 17 17 */ 18 double LSQ (const gsl_vector * x, void * params)18 double LSQ (const gsl_vector * const x, void * params) 19 19 { 20 20 double sum = 0.; 21 21 struct LSQ_params *par = (struct LSQ_params *)params; 22 Vector **vectors = par->vectors;22 const Vector ** vectors = par->vectors; 23 23 int num = par->num; 24 24 -
src/leastsquaremin.hpp
rad37ab r776b64 31 31 */ 32 32 struct LSQ_params { 33 Vector **vectors;33 const Vector **vectors; 34 34 int num; 35 35 }; 36 36 37 double LSQ(const gsl_vector * x, void * params);37 double LSQ(const gsl_vector * const x, void * params); 38 38 39 39 /** Parameter structure for least square minimsation. -
src/linkedcell.cpp
rad37ab r776b64 33 33 * \param RADIUS edge length of cells 34 34 */ 35 LinkedCell::LinkedCell( PointCloud *set,double radius)35 LinkedCell::LinkedCell(const PointCloud * const set, const double radius) 36 36 { 37 37 TesselPoint *Walker = NULL; … … 109 109 * \param RADIUS edge length of cells 110 110 */ 111 LinkedCell::LinkedCell(LinkedNodes *set, double radius)111 LinkedCell::LinkedCell(LinkedNodes *set, const double radius) 112 112 { 113 113 class TesselPoint *Walker = NULL; … … 192 192 * \return if all in intervals - true, else -false 193 193 */ 194 bool LinkedCell::CheckBounds() 194 bool LinkedCell::CheckBounds() const 195 195 { 196 196 bool status = true; … … 207 207 * \return if all in intervals - true, else -false 208 208 */ 209 bool LinkedCell::CheckBounds( int relative[NDIM])209 bool LinkedCell::CheckBounds(const int relative[NDIM]) const 210 210 { 211 211 bool status = true; … … 219 219 * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[] are out of bounds. 220 220 */ 221 LinkedNodes* LinkedCell::GetCurrentCell() 221 const LinkedNodes* LinkedCell::GetCurrentCell() const 222 222 { 223 223 if (CheckBounds()) { … … 233 233 * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[]+relative[] are out of bounds. 234 234 */ 235 LinkedNodes* LinkedCell::GetRelativeToCurrentCell(int relative[NDIM]) 235 const LinkedNodes* LinkedCell::GetRelativeToCurrentCell(const int relative[NDIM]) const 236 236 { 237 237 if (CheckBounds(relative)) { … … 247 247 * \return if the atom is also found in this cell - true, else - false 248 248 */ 249 bool LinkedCell::SetIndexToNode(const TesselPoint * Walker)249 bool LinkedCell::SetIndexToNode(const TesselPoint * const Walker) const 250 250 { 251 251 bool status = false; … … 268 268 * \param *upper upper bounds 269 269 */ 270 void LinkedCell::GetNeighbourBounds(int lower[NDIM], int upper[NDIM]) 270 void LinkedCell::GetNeighbourBounds(int lower[NDIM], int upper[NDIM]) const 271 271 { 272 272 for (int i=0;i<NDIM;i++) { … … 288 288 * \return Vector is inside bounding box - true, else - false 289 289 */ 290 bool LinkedCell::SetIndexToVector(const Vector * x)290 bool LinkedCell::SetIndexToVector(const Vector * const x) const 291 291 { 292 292 bool status = true; -
src/linkedcell.hpp
rad37ab r776b64 46 46 double RADIUS; // cell edge length 47 47 int N[NDIM]; // number of cells per axis 48 int n[NDIM]; // temporary variable for current cell per axis49 int index; // temporary index variable , access by index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];48 mutable int n[NDIM]; // temporary variable for current cell per axis 49 mutable int index; // temporary index variable , access by index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2]; 50 50 51 51 LinkedCell(); 52 LinkedCell( PointCloud *set,double RADIUS);53 LinkedCell(LinkedNodes *set, double radius);52 LinkedCell(const PointCloud * const set, const double RADIUS); 53 LinkedCell(LinkedNodes *set, const double radius); 54 54 ~LinkedCell(); 55 LinkedNodes* GetCurrentCell();56 LinkedNodes* GetRelativeToCurrentCell(int relative[NDIM]);57 bool SetIndexToNode(const TesselPoint * Walker);58 bool SetIndexToVector(const Vector * x);59 bool CheckBounds() ;60 bool CheckBounds( int relative[NDIM]);61 void GetNeighbourBounds(int lower[NDIM], int upper[NDIM]) ;55 const LinkedNodes* GetCurrentCell()const ; 56 const LinkedNodes* GetRelativeToCurrentCell(const int relative[NDIM])const ; 57 bool SetIndexToNode(const TesselPoint * const Walker)const ; 58 bool SetIndexToVector(const Vector * const x)const ; 59 bool CheckBounds()const ; 60 bool CheckBounds(const int relative[NDIM])const ; 61 void GetNeighbourBounds(int lower[NDIM], int upper[NDIM])const ; 62 62 63 63 // not implemented yet -
src/molecule.cpp
rad37ab r776b64 56 56 IndexNr = -1; 57 57 ActiveFlag = false; 58 TesselStruct = NULL;59 58 }; 60 59 … … 64 63 molecule::~molecule() 65 64 { 66 if (TesselStruct != NULL)67 delete(TesselStruct);68 65 CleanupMolecule(); 69 66 delete(first); -
src/molecule.hpp
rad37ab r776b64 99 99 char name[MAXSTRINGSIZE]; //!< arbitrary name 100 100 int IndexNr; //!< index of molecule in a MoleculeListClass 101 class Tesselation *TesselStruct;102 101 103 102 molecule(periodentafel *teil); … … 105 104 106 105 // re-definition of virtual functions from PointCloud 107 Vector *GetCenter(ofstream *out) ;108 TesselPoint *GetPoint() ;109 TesselPoint *GetTerminalPoint() ;110 void GoToNext() ;111 void GoToPrevious() ;112 void GoToFirst() ;113 void GoToLast() ;114 bool IsEmpty() ;115 bool IsEnd() ;106 Vector *GetCenter(ofstream *out) const ; 107 TesselPoint *GetPoint() const ; 108 TesselPoint *GetTerminalPoint() const ; 109 void GoToNext() const ; 110 void GoToPrevious() const ; 111 void GoToFirst() const ; 112 void GoToLast() const ; 113 bool IsEmpty() const ; 114 bool IsEnd() const ; 116 115 117 116 // templates for allowing global manipulation of all vectors … … 217 216 void Mirror(const Vector *x); 218 217 void Align(Vector *n); 219 void Scale( double **factor);218 void Scale(const double ** const factor); 220 219 void DeterminePeriodicCenter(Vector ¢er); 221 220 Vector * DetermineCenterOfGravity(ofstream *out); 222 Vector * DetermineCenterOfAll(ofstream *out) ;221 Vector * DetermineCenterOfAll(ofstream *out) const; 223 222 void SetNameFromFilename(const char *filename); 224 223 void SetBoxDimension(Vector *dim); … … 298 297 private: 299 298 int last_atom; //!< number given to last atom 300 atom *InternalPointer; //!< internal pointer for PointCloud299 mutable atom *InternalPointer; //!< internal pointer for PointCloud 301 300 }; 302 301 -
src/molecule_geometry.cpp
rad37ab r776b64 122 122 * \return pointer to center of all vector 123 123 */ 124 Vector * molecule::DetermineCenterOfAll(ofstream *out) 124 Vector * molecule::DetermineCenterOfAll(ofstream *out) const 125 125 { 126 126 atom *ptr = start->next; // start at first in list … … 198 198 * \param *factor pointer to scaling factor 199 199 */ 200 void molecule::Scale( double **factor)200 void molecule::Scale(const double ** const factor) 201 201 { 202 202 atom *ptr = start; -
src/molecule_graph.cpp
rad37ab r776b64 102 102 double distance, MinDistance, MaxDistance; 103 103 LinkedCell *LC = NULL; 104 LinkedNodes *List = NULL;105 LinkedNodes *OtherList = NULL;106 104 107 105 BondDistance = bonddistance; // * ((IsAngstroem) ? 1. : 1./AtomicLengthToAngstroem); … … 131 129 for (LC->n[1] = 0; LC->n[1] < LC->N[1]; LC->n[1]++) 132 130 for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) { 133 List = LC->GetCurrentCell();131 const LinkedNodes *List = LC->GetCurrentCell(); 134 132 //*out << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl; 135 133 if (List != NULL) { 136 for (LinkedNodes:: iterator Runner = List->begin(); Runner != List->end(); Runner++) {134 for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 137 135 Walker = AtomMap[(*Runner)->nr]; 138 136 //*out << Verbose(0) << "Current Atom is " << *Walker << "." << endl; … … 141 139 for (n[1] = -1; n[1] <= 1; n[1]++) 142 140 for (n[2] = -1; n[2] <= 1; n[2]++) { 143 OtherList = LC->GetRelativeToCurrentCell(n);141 const LinkedNodes *OtherList = LC->GetRelativeToCurrentCell(n); 144 142 //*out << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl; 145 143 if (OtherList != NULL) { 146 for (LinkedNodes:: iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {144 for (LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) { 147 145 if ((*OtherRunner)->nr > Walker->nr) { 148 146 OtherWalker = AtomMap[(*OtherRunner)->nr]; -
src/molecule_pointcloud.cpp
rad37ab r776b64 18 18 * \return pointer to allocated with central coordinates 19 19 */ 20 Vector *molecule::GetCenter(ofstream *out) 20 Vector *molecule::GetCenter(ofstream *out) const 21 21 { 22 22 Vector *center = DetermineCenterOfAll(out); … … 27 27 * \return pointer to atom or NULL if none present 28 28 */ 29 TesselPoint *molecule::GetPoint() 29 TesselPoint *molecule::GetPoint() const 30 30 { 31 31 if ((InternalPointer != start) && (InternalPointer != end)) … … 38 38 * \return pointer to end marker 39 39 */ 40 TesselPoint *molecule::GetTerminalPoint() 40 TesselPoint *molecule::GetTerminalPoint() const 41 41 { 42 42 return end; … … 46 46 * Stops at last one. 47 47 */ 48 void molecule::GoToNext() 48 void molecule::GoToNext() const 49 49 { 50 50 if (InternalPointer != end) … … 55 55 * Stops at first one. 56 56 */ 57 void molecule::GoToPrevious() 57 void molecule::GoToPrevious() const 58 58 { 59 59 if (InternalPointer->previous != start) … … 63 63 /** Goes to first atom. 64 64 */ 65 void molecule::GoToFirst() 65 void molecule::GoToFirst() const 66 66 { 67 67 InternalPointer = start->next; … … 70 70 /** Goes to last atom. 71 71 */ 72 void molecule::GoToLast() 72 void molecule::GoToLast() const 73 73 { 74 74 InternalPointer = end->previous; … … 78 78 * \return true - no atoms, false - not empty 79 79 */ 80 bool molecule::IsEmpty() 80 bool molecule::IsEmpty() const 81 81 { 82 82 return (start->next == end); … … 86 86 * \return true - current atom is last one, false - is not last one 87 87 */ 88 bool molecule::IsEnd() 88 bool molecule::IsEnd() const 89 89 { 90 90 return (InternalPointer == end); -
src/moleculelist.cpp
rad37ab r776b64 306 306 bool MoleculeListClass::EmbedMerge(molecule *mol, molecule *srcmol) 307 307 { 308 LinkedCell *LCList = NULL; 309 Tesselation *TesselStruct = NULL; 308 310 if ((srcmol == NULL) || (mol == NULL)) { 309 311 cout << Verbose(1) << "ERROR: Either fixed or variable molecule is given as NULL." << endl; … … 312 314 313 315 // calculate envelope for *mol 314 L inkedCell *LCList = new LinkedCell(mol, 8.);315 FindNonConvexBorder((ofstream *)&cout, mol, LCList, 4., NULL);316 if ( mol->TesselStruct == NULL) {316 LCList = new LinkedCell(mol, 8.); 317 FindNonConvexBorder((ofstream *)&cout, mol, TesselStruct, (const LinkedCell *&)LCList, 4., NULL); 318 if (TesselStruct == NULL) { 317 319 cout << Verbose(1) << "ERROR: Could not tesselate the fixed molecule." << endl; 318 320 return false; 319 321 } 320 322 delete(LCList); 321 LCList = new LinkedCell( mol->TesselStruct, 8.); // re-create with boundary points only!323 LCList = new LinkedCell(TesselStruct, 8.); // re-create with boundary points only! 322 324 323 325 // prepare index list for bonds … … 333 335 Walker = Walker->next; 334 336 cout << Verbose(2) << "INFO: Current Walker is " << *Walker << "." << endl; 335 if (! mol->TesselStruct->IsInnerPoint((ofstream *)&cout, Walker->x, LCList)) {337 if (!TesselStruct->IsInnerPoint((ofstream *)&cout, Walker->x, LCList)) { 336 338 CopyAtoms[Walker->nr] = new atom(Walker); 337 339 mol->AddAtom(CopyAtoms[Walker->nr]); -
src/tesselation.cpp
rad37ab r776b64 31 31 * \param *Walker TesselPoint this boundary point represents 32 32 */ 33 BoundaryPointSet::BoundaryPointSet(TesselPoint * Walker)33 BoundaryPointSet::BoundaryPointSet(TesselPoint * Walker) 34 34 { 35 35 node = Walker; … … 73 73 * \param &a boundary point 74 74 */ 75 ostream & operator <<(ostream &ost, BoundaryPointSet &a)75 ostream & operator <<(ostream &ost, const BoundaryPointSet &a) 76 76 { 77 77 ost << "[" << a.Nr << "|" << a.node->Name << " at " << *a.node->node << "]"; … … 96 96 * \param number number of the list 97 97 */ 98 BoundaryLineSet::BoundaryLineSet(class BoundaryPointSet *Point[2], int number)98 BoundaryLineSet::BoundaryLineSet(class BoundaryPointSet *Point[2], const int number) 99 99 { 100 100 // set number … … 275 275 * \param &a boundary line 276 276 */ 277 ostream & operator <<(ostream &ost, BoundaryLineSet &a)277 ostream & operator <<(ostream &ost, const BoundaryLineSet &a) 278 278 { 279 279 ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << "," << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "]"; … … 532 532 * \param &a boundary triangle 533 533 */ 534 ostream &operator <<(ostream &ost, BoundaryTriangleSet &a)534 ostream &operator <<(ostream &ost, const BoundaryTriangleSet &a) 535 535 { 536 536 ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << "," … … 642 642 * Uses PointsOnBoundary and STL stuff. 643 643 */ 644 Vector * Tesselation::GetCenter(ofstream *out) 644 Vector * Tesselation::GetCenter(ofstream *out) const 645 645 { 646 646 Vector *Center = new Vector(0.,0.,0.); … … 657 657 * Uses PointsOnBoundary and STL stuff. 658 658 */ 659 TesselPoint * Tesselation::GetPoint() 659 TesselPoint * Tesselation::GetPoint() const 660 660 { 661 661 return (InternalPointer->second->node); … … 665 665 * Uses PointsOnBoundary and STL stuff. 666 666 */ 667 TesselPoint * Tesselation::GetTerminalPoint() 668 { 669 PointMap:: iterator Runner = PointsOnBoundary.end();667 TesselPoint * Tesselation::GetTerminalPoint() const 668 { 669 PointMap::const_iterator Runner = PointsOnBoundary.end(); 670 670 Runner--; 671 671 return (Runner->second->node); … … 675 675 * Uses PointsOnBoundary and STL stuff. 676 676 */ 677 void Tesselation::GoToNext() 677 void Tesselation::GoToNext() const 678 678 { 679 679 if (InternalPointer != PointsOnBoundary.end()) … … 684 684 * Uses PointsOnBoundary and STL stuff. 685 685 */ 686 void Tesselation::GoToPrevious() 686 void Tesselation::GoToPrevious() const 687 687 { 688 688 if (InternalPointer != PointsOnBoundary.begin()) … … 693 693 * Uses PointsOnBoundary and STL stuff. 694 694 */ 695 void Tesselation::GoToFirst() 695 void Tesselation::GoToFirst() const 696 696 { 697 697 InternalPointer = PointsOnBoundary.begin(); … … 700 700 /** PointCloud implementation of GoToLast. 701 701 * Uses PointsOnBoundary and STL stuff. 702 */ 703 void Tesselation::GoToLast() 702 */ 703 void Tesselation::GoToLast() const 704 704 { 705 705 InternalPointer = PointsOnBoundary.end(); … … 710 710 * Uses PointsOnBoundary and STL stuff. 711 711 */ 712 bool Tesselation::IsEmpty() 712 bool Tesselation::IsEmpty() const 713 713 { 714 714 return (PointsOnBoundary.empty()); … … 718 718 * Uses PointsOnBoundary and STL stuff. 719 719 */ 720 bool Tesselation::IsEnd() 720 bool Tesselation::IsEnd() const 721 721 { 722 722 return (InternalPointer == PointsOnBoundary.end()); … … 899 899 * \param *cloud cluster of points 900 900 */ 901 void Tesselation::TesselateOnBoundary(ofstream *out, PointCloud *cloud)901 void Tesselation::TesselateOnBoundary(ofstream *out, const PointCloud * const cloud) 902 902 { 903 903 bool flag; … … 1097 1097 * \return true - all straddling points insert, false - something went wrong 1098 1098 */ 1099 bool Tesselation::InsertStraddlingPoints(ofstream *out, PointCloud *cloud,LinkedCell *LC)1099 bool Tesselation::InsertStraddlingPoints(ofstream *out, const PointCloud *cloud, const LinkedCell *LC) 1100 1100 { 1101 1101 Vector Intersection, Normal; … … 1207 1207 * \return true - new point was added, false - point already present 1208 1208 */ 1209 bool 1210 Tesselation::AddBoundaryPoint(TesselPoint *Walker, int n) 1209 bool Tesselation::AddBoundaryPoint(TesselPoint * Walker, const int n) 1211 1210 { 1212 1211 PointTestPair InsertUnique; … … 1229 1228 * @param n index for this point in Tesselation::TPS array 1230 1229 */ 1231 void 1232 Tesselation::AddTesselationPoint(TesselPoint* Candidate, int n) 1230 void Tesselation::AddTesselationPoint(TesselPoint* Candidate, const int n) 1233 1231 { 1234 1232 PointTestPair InsertUnique; … … 1252 1250 * @param n index of Tesselation::BLS giving the line with both endpoints 1253 1251 */ 1254 void Tesselation::AddTesselationLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n) {1252 void Tesselation::AddTesselationLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n) { 1255 1253 bool insertNewLine = true; 1256 1254 … … 1290 1288 * @param n index of Tesselation::BLS giving the line with both endpoints 1291 1289 */ 1292 void Tesselation::AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n)1290 void Tesselation::AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n) 1293 1291 { 1294 1292 cout << Verbose(4) << "Adding line [" << LinesOnBoundaryCount << "|" << *(a->node) << " and " << *(b->node) << "." << endl; … … 1323 1321 * \param nr triangle number 1324 1322 */ 1325 void Tesselation::AddTesselationTriangle( int nr)1323 void Tesselation::AddTesselationTriangle(const int nr) 1326 1324 { 1327 1325 cout << Verbose(1) << "Adding triangle to global TrianglesOnBoundary map." << endl; … … 1554 1552 * \param *LC LinkedCell structure with neighbouring TesselPoint's 1555 1553 */ 1556 void Tesselation::FindStartingTriangle(ofstream *out, const double RADIUS, LinkedCell *LC)1554 void Tesselation::FindStartingTriangle(ofstream *out, const double RADIUS, const LinkedCell *LC) 1557 1555 { 1558 1556 cout << Verbose(1) << "Begin of FindStartingTriangle\n"; 1559 1557 int i = 0; 1560 LinkedNodes *List = NULL;1561 1558 TesselPoint* FirstPoint = NULL; 1562 1559 TesselPoint* SecondPoint = NULL; … … 1580 1577 for (LC->n[(i+1)%NDIM]=0;LC->n[(i+1)%NDIM]<LC->N[(i+1)%NDIM];LC->n[(i+1)%NDIM]++) 1581 1578 for (LC->n[(i+2)%NDIM]=0;LC->n[(i+2)%NDIM]<LC->N[(i+2)%NDIM];LC->n[(i+2)%NDIM]++) { 1582 List = LC->GetCurrentCell();1579 const LinkedNodes *List = LC->GetCurrentCell(); 1583 1580 //cout << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl; 1584 1581 if (List != NULL) { 1585 for (LinkedNodes:: iterator Runner = List->begin();Runner != List->end();Runner++) {1582 for (LinkedNodes::const_iterator Runner = List->begin();Runner != List->end();Runner++) { 1586 1583 if ((*Runner)->node->x[i] > maxCoordinate[i]) { 1587 1584 cout << Verbose(2) << "New maximal for axis " << i << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl; … … 1645 1642 1646 1643 //cout << Verbose(2) << "INFO: OldSphereCenter is at " << helper << ".\n"; 1647 FindThirdPointForTesselation( 1648 Oben, SearchDirection, helper, BLS[0], NULL, *&OptCandidates, &ShortestAngle, RADIUS, LC 1649 ); 1644 FindThirdPointForTesselation(Oben, SearchDirection, helper, BLS[0], NULL, *&OptCandidates, &ShortestAngle, RADIUS, LC); 1650 1645 cout << Verbose(1) << "List of third Points is "; 1651 1646 for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) { … … 1713 1708 * @param *LC LinkedCell structure with neighbouring points 1714 1709 */ 1715 bool Tesselation::FindNextSuitableTriangle(ofstream *out, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, LinkedCell *LC)1710 bool Tesselation::FindNextSuitableTriangle(ofstream *out, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC) 1716 1711 { 1717 1712 cout << Verbose(0) << "Begin of FindNextSuitableTriangle\n"; … … 1774 1769 1775 1770 // add third point 1776 FindThirdPointForTesselation( 1777 T.NormalVector, SearchDirection, OldSphereCenter, &Line, ThirdNode, OptCandidates, 1778 &ShortestAngle, RADIUS, LC 1779 ); 1771 FindThirdPointForTesselation(T.NormalVector, SearchDirection, OldSphereCenter, &Line, ThirdNode, OptCandidates, &ShortestAngle, RADIUS, LC); 1780 1772 1781 1773 } else { … … 1813 1805 AddTesselationPoint(BaseRay->endpoints[1]->node, 2); 1814 1806 1815 if (CheckLineCriteriaForDegeneratedTriangle( TPS)) {1807 if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet **)TPS)) { 1816 1808 AddTesselationLine(TPS[0], TPS[1], 0); 1817 1809 AddTesselationLine(TPS[0], TPS[2], 1); … … 1842 1834 // We demand that at most one new degenerate line is created and that this line also already exists (which has to be the case due to existentTrianglesCount == 1) 1843 1835 // i.e. at least one of the three lines must be present with TriangleCount <= 1 1844 if (CheckLineCriteriaForDegeneratedTriangle( TPS)) {1836 if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet **)TPS)) { 1845 1837 AddTesselationLine(TPS[0], TPS[1], 0); 1846 1838 AddTesselationLine(TPS[0], TPS[2], 1); … … 1949 1941 }; 1950 1942 1951 void Tesselation::PrintAllBoundaryPoints(ofstream *out) 1943 void Tesselation::PrintAllBoundaryPoints(ofstream *out) const 1952 1944 { 1953 1945 // print all lines 1954 1946 *out << Verbose(1) << "Printing all boundary points for debugging:" << endl; 1955 for (PointMap:: iterator PointRunner = PointsOnBoundary.begin();PointRunner != PointsOnBoundary.end(); PointRunner++)1947 for (PointMap::const_iterator PointRunner = PointsOnBoundary.begin();PointRunner != PointsOnBoundary.end(); PointRunner++) 1956 1948 *out << Verbose(2) << *(PointRunner->second) << endl; 1957 1949 }; 1958 1950 1959 void Tesselation::PrintAllBoundaryLines(ofstream *out) 1951 void Tesselation::PrintAllBoundaryLines(ofstream *out) const 1960 1952 { 1961 1953 // print all lines 1962 1954 *out << Verbose(1) << "Printing all boundary lines for debugging:" << endl; 1963 for (LineMap:: iterator LineRunner = LinesOnBoundary.begin(); LineRunner != LinesOnBoundary.end(); LineRunner++)1955 for (LineMap::const_iterator LineRunner = LinesOnBoundary.begin(); LineRunner != LinesOnBoundary.end(); LineRunner++) 1964 1956 *out << Verbose(2) << *(LineRunner->second) << endl; 1965 1957 }; 1966 1958 1967 void Tesselation::PrintAllBoundaryTriangles(ofstream *out) 1959 void Tesselation::PrintAllBoundaryTriangles(ofstream *out) const 1968 1960 { 1969 1961 // print all triangles 1970 1962 *out << Verbose(1) << "Printing all boundary triangles for debugging:" << endl; 1971 for (TriangleMap:: iterator TriangleRunner = TrianglesOnBoundary.begin(); TriangleRunner != TrianglesOnBoundary.end(); TriangleRunner++)1963 for (TriangleMap::const_iterator TriangleRunner = TrianglesOnBoundary.begin(); TriangleRunner != TrianglesOnBoundary.end(); TriangleRunner++) 1972 1964 *out << Verbose(2) << *(TriangleRunner->second) << endl; 1973 1965 }; … … 2165 2157 * \param *LC LinkedCell structure with neighbouring points 2166 2158 */ 2167 void Tesselation::FindSecondPointForTesselation(TesselPoint* a, Vector Oben, TesselPoint*& OptCandidate, double Storage[3], double RADIUS, LinkedCell *LC)2159 void Tesselation::FindSecondPointForTesselation(TesselPoint* a, Vector Oben, TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC) 2168 2160 { 2169 2161 cout << Verbose(2) << "Begin of FindSecondPointForTesselation" << endl; 2170 2162 Vector AngleCheck; 2171 2163 class TesselPoint* Candidate = NULL; 2172 double norm = -1., angle; 2173 LinkedNodes *List = NULL; 2174 int N[NDIM], Nlower[NDIM], Nupper[NDIM]; 2164 double norm = -1.; 2165 double angle = 0.; 2166 int N[NDIM]; 2167 int Nlower[NDIM]; 2168 int Nupper[NDIM]; 2175 2169 2176 2170 if (LC->SetIndexToNode(a)) { // get cell for the starting point … … 2198 2192 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 2199 2193 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 2200 List = LC->GetCurrentCell();2194 const LinkedNodes *List = LC->GetCurrentCell(); 2201 2195 //cout << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl; 2202 2196 if (List != NULL) { 2203 for (LinkedNodes:: iterator Runner = List->begin(); Runner != List->end(); Runner++) {2197 for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 2204 2198 Candidate = (*Runner); 2205 2199 // check if we only have one unique point yet ... … … 2285 2279 * @param *LC LinkedCell structure with neighbouring points 2286 2280 */ 2287 void Tesselation::FindThirdPointForTesselation(Vector NormalVector, Vector SearchDirection, Vector OldSphereCenter, class BoundaryLineSet *BaseLine, class TesselPoint *ThirdNode, CandidateList* &candidates, double *ShortestAngle, const double RADIUS, LinkedCell *LC)2281 void Tesselation::FindThirdPointForTesselation(Vector NormalVector, Vector SearchDirection, Vector OldSphereCenter, class BoundaryLineSet *BaseLine, class TesselPoint *ThirdNode, CandidateList* &candidates, double *ShortestAngle, const double RADIUS, const LinkedCell *LC) 2288 2282 { 2289 2283 Vector CircleCenter; // center of the circle, i.e. of the band of sphere's centers … … 2294 2288 Vector NewNormalVector; // normal vector of the Candidate's triangle 2295 2289 Vector helper, OptCandidateCenter, OtherOptCandidateCenter; 2296 LinkedNodes *List = NULL;2297 2290 double CircleRadius; // radius of this circle 2298 2291 double radius; … … 2357 2350 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 2358 2351 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 2359 List = LC->GetCurrentCell();2352 const LinkedNodes *List = LC->GetCurrentCell(); 2360 2353 //cout << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl; 2361 2354 if (List != NULL) { 2362 for (LinkedNodes:: iterator Runner = List->begin(); Runner != List->end(); Runner++) {2355 for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 2363 2356 Candidate = (*Runner); 2364 2357 … … 2471 2464 * \return point which is shared or NULL if none 2472 2465 */ 2473 class BoundaryPointSet *Tesselation::GetCommonEndpoint(class BoundaryLineSet * line1, class BoundaryLineSet * line2) 2474 { 2475 class BoundaryLineSet * lines[2] = 2476 { line1, line2 }; 2466 class BoundaryPointSet *Tesselation::GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const 2467 { 2468 const BoundaryLineSet * lines[2] = { line1, line2 }; 2477 2469 class BoundaryPointSet *node = NULL; 2478 2470 map<int, class BoundaryPointSet *> OrderMap; … … 2502 2494 * \return list of BoundaryTriangleSet of nearest triangles or NULL in degenerate case. 2503 2495 */ 2504 list<BoundaryTriangleSet*> * Tesselation::FindClosestTrianglesToPoint(ofstream *out, Vector *x, LinkedCell* LC)2496 list<BoundaryTriangleSet*> * Tesselation::FindClosestTrianglesToPoint(ofstream *out, const Vector *x, const LinkedCell* LC) const 2505 2497 { 2506 2498 TesselPoint *trianglePoints[3]; … … 2522 2514 if (trianglePoints[0]->node->DistanceSquared(x) < MYEPSILON) { 2523 2515 *out << Verbose(3) << "Point is right on a tesselation point, no nearest triangle." << endl; 2524 PointMap:: iterator PointRunner = PointsOnBoundary.find(trianglePoints[0]->nr);2516 PointMap::const_iterator PointRunner = PointsOnBoundary.find(trianglePoints[0]->nr); 2525 2517 triangles = new list<BoundaryTriangleSet*>; 2526 2518 if (PointRunner != PointsOnBoundary.end()) { … … 2578 2570 * \return list of BoundaryTriangleSet of nearest triangles or NULL. 2579 2571 */ 2580 class BoundaryTriangleSet * Tesselation::FindClosestTriangleToPoint(ofstream *out, Vector *x, LinkedCell* LC)2572 class BoundaryTriangleSet * Tesselation::FindClosestTriangleToPoint(ofstream *out, const Vector *x, const LinkedCell* LC) const 2581 2573 { 2582 2574 class BoundaryTriangleSet *result = NULL; … … 2614 2606 * @return true if the point is inside the tesselation structure, false otherwise 2615 2607 */ 2616 bool Tesselation::IsInnerPoint(ofstream *out, Vector Point, LinkedCell* LC)2608 bool Tesselation::IsInnerPoint(ofstream *out, const Vector &Point, const LinkedCell* const LC) const 2617 2609 { 2618 2610 class BoundaryTriangleSet *result = FindClosestTriangleToPoint(out, &Point, LC); … … 2644 2636 * @return true if the point is inside the tesselation structure, false otherwise 2645 2637 */ 2646 bool Tesselation::IsInnerPoint(ofstream *out, TesselPoint *Point, LinkedCell* LC)2638 bool Tesselation::IsInnerPoint(ofstream *out, const TesselPoint * const Point, const LinkedCell* const LC) const 2647 2639 { 2648 2640 return IsInnerPoint(out, *(Point->node), LC); … … 2655 2647 * @return set of the all points linked to the provided one 2656 2648 */ 2657 set<TesselPoint*> * Tesselation::GetAllConnectedPoints(ofstream *out, TesselPoint* Point)2649 set<TesselPoint*> * Tesselation::GetAllConnectedPoints(ofstream *out, const TesselPoint* const Point) const 2658 2650 { 2659 2651 set<TesselPoint*> *connectedPoints = new set<TesselPoint*>; … … 2665 2657 2666 2658 // find the respective boundary point 2667 PointMap:: iterator PointRunner = PointsOnBoundary.find(Point->nr);2659 PointMap::const_iterator PointRunner = PointsOnBoundary.find(Point->nr); 2668 2660 if (PointRunner != PointsOnBoundary.end()) { 2669 2661 ReferencePoint = PointRunner->second; … … 2675 2667 // little trick so that we look just through lines connect to the BoundaryPoint 2676 2668 // OR fall-back to look through all lines if there is no such BoundaryPoint 2677 LineMap *Lines = &LinesOnBoundary;2669 const LineMap *Lines;; 2678 2670 if (ReferencePoint != NULL) 2679 2671 Lines = &(ReferencePoint->lines); 2680 LineMap::iterator findLines = Lines->begin(); 2672 else 2673 Lines = &LinesOnBoundary; 2674 LineMap::const_iterator findLines = Lines->begin(); 2681 2675 while (findLines != Lines->end()) { 2682 2676 takePoint = false; … … 2719 2713 * @return list of the all points linked to the provided one 2720 2714 */ 2721 list<TesselPoint*> * Tesselation::GetCircleOfConnectedPoints(ofstream *out, TesselPoint* Point, Vector *Reference)2715 list<TesselPoint*> * Tesselation::GetCircleOfConnectedPoints(ofstream *out, const TesselPoint* const Point, const Vector * const Reference) const 2722 2716 { 2723 2717 map<double, TesselPoint*> anglesOfPoints; … … 2733 2727 2734 2728 // calculate central point 2735 for (set<TesselPoint*>:: iterator TesselRunner = connectedPoints->begin(); TesselRunner != connectedPoints->end(); TesselRunner++)2729 for (set<TesselPoint*>::const_iterator TesselRunner = connectedPoints->begin(); TesselRunner != connectedPoints->end(); TesselRunner++) 2736 2730 center.AddVector((*TesselRunner)->node); 2737 2731 //*out << "Summed vectors " << center << "; number of points " << connectedPoints.size() … … 2796 2790 * @return list of the all points linked to the provided one 2797 2791 */ 2798 list<list<TesselPoint*> *> * Tesselation::GetPathsOfConnectedPoints(ofstream *out, TesselPoint* Point)2792 list<list<TesselPoint*> *> * Tesselation::GetPathsOfConnectedPoints(ofstream *out, const TesselPoint* const Point) const 2799 2793 { 2800 2794 map<double, TesselPoint*> anglesOfPoints; … … 2813 2807 2814 2808 // find the respective boundary point 2815 PointMap:: iterator PointRunner = PointsOnBoundary.find(Point->nr);2809 PointMap::const_iterator PointRunner = PointsOnBoundary.find(Point->nr); 2816 2810 if (PointRunner != PointsOnBoundary.end()) { 2817 2811 ReferencePoint = PointRunner->second; … … 2911 2905 * @return list of the closed paths 2912 2906 */ 2913 list<list<TesselPoint*> *> * Tesselation::GetClosedPathsOfConnectedPoints(ofstream *out, TesselPoint* Point)2907 list<list<TesselPoint*> *> * Tesselation::GetClosedPathsOfConnectedPoints(ofstream *out, const TesselPoint* const Point) const 2914 2908 { 2915 2909 list<list<TesselPoint*> *> *ListofPaths = GetPathsOfConnectedPoints(out, Point); … … 2972 2966 * \return pointer to allocated list of triangles 2973 2967 */ 2974 set<BoundaryTriangleSet*> *Tesselation::GetAllTriangles(ofstream *out, c lass BoundaryPointSet *Point)2968 set<BoundaryTriangleSet*> *Tesselation::GetAllTriangles(ofstream *out, const BoundaryPointSet * const Point) const 2975 2969 { 2976 2970 set<BoundaryTriangleSet*> *connectedTriangles = new set<BoundaryTriangleSet*>; … … 2980 2974 } else { 2981 2975 // go through its lines and insert all triangles 2982 for (LineMap:: iterator LineRunner = Point->lines.begin(); LineRunner != Point->lines.end(); LineRunner++)2976 for (LineMap::const_iterator LineRunner = Point->lines.begin(); LineRunner != Point->lines.end(); LineRunner++) 2983 2977 for (TriangleMap::iterator TriangleRunner = (LineRunner->second)->triangles.begin(); TriangleRunner != (LineRunner->second)->triangles.end(); TriangleRunner++) { 2984 2978 connectedTriangles->insert(TriangleRunner->second); … … 3224 3218 * will usually be one, in case of degeneration, there will be two 3225 3219 */ 3226 list<BoundaryTriangleSet*> *Tesselation::FindTriangles( TesselPoint* Points[3])3220 list<BoundaryTriangleSet*> *Tesselation::FindTriangles(const TesselPoint* const Points[3]) const 3227 3221 { 3228 3222 list<BoundaryTriangleSet*> *result = new list<BoundaryTriangleSet*>; 3229 LineMap::iterator FindLine; 3230 PointMap::iterator FindPoint; 3231 TriangleMap::iterator FindTriangle; 3223 LineMap::const_iterator FindLine; 3224 TriangleMap::const_iterator FindTriangle; 3232 3225 class BoundaryPointSet *TrianglePoints[3]; 3233 3226 3234 3227 for (int i = 0; i < 3; i++) { 3235 FindPoint = PointsOnBoundary.find(Points[i]->nr);3228 PointMap::const_iterator FindPoint = PointsOnBoundary.find(Points[i]->nr); 3236 3229 if (FindPoint != PointsOnBoundary.end()) { 3237 3230 TrianglePoints[i] = FindPoint->second; … … 3544 3537 * \param *cloud PointCloud structure with all nodes 3545 3538 */ 3546 void Tesselation::Output(ofstream *out, const char *filename, PointCloud *cloud)3539 void Tesselation::Output(ofstream *out, const char *filename, const PointCloud * const cloud) 3547 3540 { 3548 3541 ofstream *tempstream = NULL; -
src/tesselation.hpp
rad37ab r776b64 83 83 public: 84 84 BoundaryPointSet(); 85 BoundaryPointSet(TesselPoint * Walker);85 BoundaryPointSet(TesselPoint * Walker); 86 86 ~BoundaryPointSet(); 87 87 … … 95 95 }; 96 96 97 ostream & operator << (ostream &ost, BoundaryPointSet &a);97 ostream & operator << (ostream &ost, const BoundaryPointSet &a); 98 98 99 99 // ======================================================== class BoundaryLineSet ========================================== … … 102 102 public: 103 103 BoundaryLineSet(); 104 BoundaryLineSet(class BoundaryPointSet *Point[2], int number);104 BoundaryLineSet(class BoundaryPointSet *Point[2], const int number); 105 105 ~BoundaryLineSet(); 106 106 … … 116 116 }; 117 117 118 ostream & operator << (ostream &ost, BoundaryLineSet &a);118 ostream & operator << (ostream &ost, const BoundaryLineSet &a); 119 119 120 120 // ======================================================== class BoundaryTriangleSet ======================================= … … 142 142 }; 143 143 144 ostream & operator << (ostream &ost, BoundaryTriangleSet &a);144 ostream & operator << (ostream &ost, const BoundaryTriangleSet &a); 145 145 146 146 // =========================================================== class TESSELPOINT =========================================== … … 170 170 virtual ~PointCloud(); 171 171 172 virtual Vector *GetCenter(ofstream *out) { return NULL; };173 virtual TesselPoint *GetPoint() { return NULL; };174 virtual TesselPoint *GetTerminalPoint() { return NULL; };175 virtual void GoToNext() {};176 virtual void GoToPrevious() {};177 virtual void GoToFirst() {};178 virtual void GoToLast() {};179 virtual bool IsEmpty() { return false; };180 virtual bool IsEnd() { return false; };172 virtual Vector *GetCenter(ofstream *out) const { return NULL; }; 173 virtual TesselPoint *GetPoint() const { return NULL; }; 174 virtual TesselPoint *GetTerminalPoint() const { return NULL; }; 175 virtual void GoToNext() const {}; 176 virtual void GoToPrevious() const {}; 177 virtual void GoToFirst() const {}; 178 virtual void GoToLast() const {}; 179 virtual bool IsEmpty() const { return false; }; 180 virtual bool IsEnd() const { return false; }; 181 181 }; 182 182 … … 204 204 virtual ~Tesselation(); 205 205 206 void AddTesselationPoint(TesselPoint* Candidate, int n);207 void AddTesselationLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n);208 void AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n);206 void AddTesselationPoint(TesselPoint* Candidate, const int n); 207 void AddTesselationLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n); 208 void AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n); 209 209 void AddTesselationTriangle(); 210 void AddTesselationTriangle( int nr);210 void AddTesselationTriangle(const int nr); 211 211 void RemoveTesselationTriangle(class BoundaryTriangleSet *triangle); 212 212 void RemoveTesselationLine(class BoundaryLineSet *line); 213 213 void RemoveTesselationPoint(class BoundaryPointSet *point); 214 214 215 class BoundaryPointSet *GetCommonEndpoint(class BoundaryLineSet * line1, class BoundaryLineSet * line2);216 215 217 216 // concave envelope 218 void FindStartingTriangle(ofstream *out, const double RADIUS, c lassLinkedCell *LC);219 void FindSecondPointForTesselation(class TesselPoint* a, Vector Oben, class TesselPoint*& OptCandidate, double Storage[3], double RADIUS, c lassLinkedCell *LC);220 void FindThirdPointForTesselation(Vector NormalVector, Vector SearchDirection, Vector OldSphereCenter, class BoundaryLineSet *BaseLine, class TesselPoint *ThirdNode, CandidateList* &candidates, double *ShortestAngle, const double RADIUS, c lassLinkedCell *LC);221 bool FindNextSuitableTriangle(ofstream *out, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, LinkedCell *LC);217 void FindStartingTriangle(ofstream *out, const double RADIUS, const LinkedCell *LC); 218 void FindSecondPointForTesselation(class TesselPoint* a, Vector Oben, class TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC); 219 void FindThirdPointForTesselation(Vector NormalVector, Vector SearchDirection, Vector OldSphereCenter, class BoundaryLineSet *BaseLine, class TesselPoint *ThirdNode, CandidateList* &candidates, double *ShortestAngle, const double RADIUS, const LinkedCell *LC); 220 bool FindNextSuitableTriangle(ofstream *out, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC); 222 221 int CheckPresenceOfTriangle(ofstream *out, class TesselPoint *Candidates[3]); 223 222 class BoundaryTriangleSet * GetPresentTriangle(ofstream *out, TesselPoint *Candidates[3]); 224 223 225 224 // convex envelope 226 void TesselateOnBoundary(ofstream *out, PointCloud *cloud);225 void TesselateOnBoundary(ofstream *out, const PointCloud * const cloud); 227 226 void GuessStartingTriangle(ofstream *out); 228 bool InsertStraddlingPoints(ofstream *out, PointCloud *cloud,LinkedCell *LC);227 bool InsertStraddlingPoints(ofstream *out, const PointCloud *cloud, const LinkedCell *LC); 229 228 double RemovePointFromTesselatedSurface(ofstream *out, class BoundaryPointSet *point); 230 229 class BoundaryLineSet * FlipBaseline(ofstream *out, class BoundaryLineSet *Base); … … 236 235 void AddBoundaryPointByDegeneratedTriangle(ofstream *out, class TesselPoint *point, LinkedCell *LC); 237 236 238 set<TesselPoint*> * GetAllConnectedPoints(ofstream *out, TesselPoint* Point); 239 set<BoundaryTriangleSet*> *GetAllTriangles(ofstream *out, class BoundaryPointSet *Point); 240 list<list<TesselPoint*> *> * GetPathsOfConnectedPoints(ofstream *out, TesselPoint* Point); 241 list<list<TesselPoint*> *> * GetClosedPathsOfConnectedPoints(ofstream *out, TesselPoint* Point); 242 list<TesselPoint*> * GetCircleOfConnectedPoints(ofstream *out, TesselPoint* Point, Vector *Reference = NULL); 243 list<BoundaryTriangleSet*> *FindTriangles(TesselPoint* Points[3]); 244 list<BoundaryTriangleSet*> * FindClosestTrianglesToPoint(ofstream *out, Vector *x, LinkedCell* LC); 245 class BoundaryTriangleSet * FindClosestTriangleToPoint(ofstream *out, Vector *x, LinkedCell* LC); 246 bool IsInnerPoint(ofstream *out, Vector Point, LinkedCell* LC); 247 bool IsInnerPoint(ofstream *out, TesselPoint *Point, LinkedCell* LC); 248 bool AddBoundaryPoint(TesselPoint *Walker, int n); 237 set<TesselPoint*> * GetAllConnectedPoints(ofstream *out, const TesselPoint* const Point) const; 238 set<BoundaryTriangleSet*> *GetAllTriangles(ofstream *out, const BoundaryPointSet * const Point) const; 239 list<list<TesselPoint*> *> * GetPathsOfConnectedPoints(ofstream *out, const TesselPoint* const Point) const; 240 list<list<TesselPoint*> *> * GetClosedPathsOfConnectedPoints(ofstream *out, const TesselPoint* const Point) const; 241 list<TesselPoint*> * GetCircleOfConnectedPoints(ofstream *out, const TesselPoint* const Point, const Vector * const Reference = NULL) const; 242 class BoundaryPointSet *GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const; 243 list<BoundaryTriangleSet*> *FindTriangles(const TesselPoint* const Points[3]) const; 244 list<BoundaryTriangleSet*> * FindClosestTrianglesToPoint(ofstream *out, const Vector *x, const LinkedCell* LC) const; 245 class BoundaryTriangleSet * FindClosestTriangleToPoint(ofstream *out, const Vector *x, const LinkedCell* LC) const; 246 bool IsInnerPoint(ofstream *out, const Vector &Point, const LinkedCell* const LC) const; 247 bool IsInnerPoint(ofstream *out, const TesselPoint * const Point, const LinkedCell* const LC) const; 248 bool AddBoundaryPoint(TesselPoint * Walker, const int n); 249 249 250 250 // print for debugging 251 void PrintAllBoundaryPoints(ofstream *out) ;252 void PrintAllBoundaryLines(ofstream *out) ;253 void PrintAllBoundaryTriangles(ofstream *out) ;251 void PrintAllBoundaryPoints(ofstream *out) const; 252 void PrintAllBoundaryLines(ofstream *out) const; 253 void PrintAllBoundaryTriangles(ofstream *out) const; 254 254 255 255 // store envelope in file 256 void Output(ofstream *out, const char *filename, PointCloud *cloud);256 void Output(ofstream *out, const char *filename, const PointCloud * const cloud); 257 257 258 258 PointMap PointsOnBoundary; … … 264 264 265 265 // PointCloud implementation for PointsOnBoundary 266 virtual Vector *GetCenter(ofstream *out) ;267 virtual TesselPoint *GetPoint() ;268 virtual TesselPoint *GetTerminalPoint() ;269 virtual void GoToNext() ;270 virtual void GoToPrevious() ;271 virtual void GoToFirst() ;272 virtual void GoToLast() ;273 virtual bool IsEmpty() ;274 virtual bool IsEnd() ;266 virtual Vector *GetCenter(ofstream *out) const; 267 virtual TesselPoint *GetPoint() const; 268 virtual TesselPoint *GetTerminalPoint() const; 269 virtual void GoToNext() const; 270 virtual void GoToPrevious() const; 271 virtual void GoToFirst() const; 272 virtual void GoToLast() const; 273 virtual bool IsEmpty() const; 274 virtual bool IsEnd() const; 275 275 276 276 class BoundaryPointSet *BPS[2]; … … 283 283 class BoundaryPointSet *TPS[3]; //this is a Storage for pointers to triangle points, this and BPS[2] needed due to AddLine restrictions 284 284 285 PointMap::iterator InternalPointer;285 mutable PointMap::const_iterator InternalPointer; 286 286 }; 287 287 -
src/tesselationhelpers.cpp
rad37ab r776b64 452 452 * \return true - there is such a line (i.e. creation of degenerated triangle is valid), false - no such line (don't create) 453 453 */ 454 bool CheckLineCriteriaForDegeneratedTriangle(c lassBoundaryPointSet *nodes[3])454 bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet *nodes[3]) 455 455 { 456 456 bool result = false; … … 461 461 for (int j=i+1; j<3; j++) { 462 462 if (nodes[i]->lines.find(nodes[j]->node->nr) != nodes[i]->lines.end()) { // there already is a line 463 LineMap:: iterator FindLine;464 pair<LineMap:: iterator,LineMap::iterator> FindPair;463 LineMap::const_iterator FindLine; 464 pair<LineMap::const_iterator,LineMap::const_iterator> FindPair; 465 465 FindPair = nodes[i]->lines.equal_range(nodes[j]->node->nr); 466 466 for (FindLine = FindPair.first; FindLine != FindPair.second; ++FindLine) { … … 486 486 /** Sort function for the candidate list. 487 487 */ 488 bool SortCandidates( CandidateForTesselation* candidate1,CandidateForTesselation* candidate2)488 bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation* candidate2) 489 489 { 490 490 Vector BaseLineVector, OrthogonalVector, helper; … … 538 538 TesselPoint* FindSecondClosestPoint(const Vector* Point, LinkedCell* LC) 539 539 { 540 LinkedNodes *List = NULL;541 540 TesselPoint* closestPoint = NULL; 542 541 TesselPoint* secondClosestPoint = NULL; … … 556 555 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 557 556 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 558 List = LC->GetCurrentCell();557 const LinkedNodes *List = LC->GetCurrentCell(); 559 558 //cout << Verbose(3) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl; 560 559 if (List != NULL) { 561 for (LinkedNodes:: iterator Runner = List->begin(); Runner != List->end(); Runner++) {560 for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 562 561 helper.CopyVector(Point); 563 562 helper.SubtractVector((*Runner)->node); … … 591 590 * @return point which is closest to the provided one, NULL if none found 592 591 */ 593 TesselPoint* FindClosestPoint(const Vector* Point, TesselPoint *&SecondPoint, LinkedCell* LC) 594 { 595 LinkedNodes *List = NULL; 592 TesselPoint* FindClosestPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC) 593 { 596 594 TesselPoint* closestPoint = NULL; 597 595 SecondPoint = NULL; … … 611 609 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 612 610 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 613 List = LC->GetCurrentCell();611 const LinkedNodes *List = LC->GetCurrentCell(); 614 612 //cout << Verbose(3) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl; 615 613 if (List != NULL) { 616 for (LinkedNodes:: iterator Runner = List->begin(); Runner != List->end(); Runner++) {614 for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 617 615 helper.CopyVector(Point); 618 616 helper.SubtractVector((*Runner)->node); … … 651 649 * \return Vector on reference line that has closest distance 652 650 */ 653 Vector * GetClosestPointBetweenLine(ofstream *out, c lass BoundaryLineSet *Base, classBoundaryLineSet *OtherBase)651 Vector * GetClosestPointBetweenLine(ofstream *out, const BoundaryLineSet *Base, const BoundaryLineSet *OtherBase) 654 652 { 655 653 // construct the plane of the two baselines (i.e. take both their directional vectors) … … 691 689 * \return distance between \a *x and plane defined by \a *triangle, -1 - if something went wrong 692 690 */ 693 double DistanceToTrianglePlane(ofstream *out, Vector *x,BoundaryTriangleSet *triangle)691 double DistanceToTrianglePlane(ofstream *out, const Vector *x, const BoundaryTriangleSet *triangle) 694 692 { 695 693 double distance = 0.; … … 707 705 * \param *mol molecule structure with atom positions 708 706 */ 709 void WriteVrmlFile(ofstream *out, ofstream *vrmlfile, c lass Tesselation *Tess,PointCloud *cloud)707 void WriteVrmlFile(ofstream *out, ofstream *vrmlfile, const Tesselation *Tess, const PointCloud *cloud) 710 708 { 711 709 TesselPoint *Walker = NULL; … … 728 726 729 727 *vrmlfile << "# All tesselation triangles" << endl; 730 for (TriangleMap:: iterator TriangleRunner = Tess->TrianglesOnBoundary.begin(); TriangleRunner != Tess->TrianglesOnBoundary.end(); TriangleRunner++) {728 for (TriangleMap::const_iterator TriangleRunner = Tess->TrianglesOnBoundary.begin(); TriangleRunner != Tess->TrianglesOnBoundary.end(); TriangleRunner++) { 731 729 *vrmlfile << "1" << endl << " "; // 1 is triangle type 732 730 for (i=0;i<3;i++) { // print each node … … 750 748 * \param *mol molecule structure with atom positions 751 749 */ 752 void IncludeSphereinRaster3D(ofstream *out, ofstream *rasterfile, c lass Tesselation *Tess,PointCloud *cloud)750 void IncludeSphereinRaster3D(ofstream *out, ofstream *rasterfile, const Tesselation *Tess, const PointCloud *cloud) 753 751 { 754 752 Vector helper; … … 775 773 * \param *mol molecule structure with atom positions 776 774 */ 777 void WriteRaster3dFile(ofstream *out, ofstream *rasterfile, c lass Tesselation *Tess,PointCloud *cloud)775 void WriteRaster3dFile(ofstream *out, ofstream *rasterfile, const Tesselation *Tess, const PointCloud *cloud) 778 776 { 779 777 TesselPoint *Walker = NULL; … … 797 795 *rasterfile << "# All tesselation triangles" << endl; 798 796 *rasterfile << "8\n 25. -1. 1. 1. 1. 0.0 0 0 0 2\n SOLID 1.0 0.0 0.0\n BACKFACE 0.3 0.3 1.0 0 0\n"; 799 for (TriangleMap:: iterator TriangleRunner = Tess->TrianglesOnBoundary.begin(); TriangleRunner != Tess->TrianglesOnBoundary.end(); TriangleRunner++) {797 for (TriangleMap::const_iterator TriangleRunner = Tess->TrianglesOnBoundary.begin(); TriangleRunner != Tess->TrianglesOnBoundary.end(); TriangleRunner++) { 800 798 *rasterfile << "1" << endl << " "; // 1 is triangle type 801 799 for (i=0;i<3;i++) { // print each node … … 820 818 * \param N arbitrary number to differentiate various zones in the tecplot format 821 819 */ 822 void WriteTecplotFile(ofstream *out, ofstream *tecplot, c lass Tesselation *TesselStruct, PointCloud *cloud,int N)820 void WriteTecplotFile(ofstream *out, ofstream *tecplot, const Tesselation *TesselStruct, const PointCloud *cloud, const int N) 823 821 { 824 822 if ((tecplot != NULL) && (TesselStruct != NULL)) { … … 840 838 int Counter = 1; 841 839 TesselPoint *Walker = NULL; 842 for (PointMap:: iterator target = TesselStruct->PointsOnBoundary.begin(); target != TesselStruct->PointsOnBoundary.end(); target++) {840 for (PointMap::const_iterator target = TesselStruct->PointsOnBoundary.begin(); target != TesselStruct->PointsOnBoundary.end(); target++) { 843 841 Walker = target->second->node; 844 842 LookupList[Walker->nr] = Counter++; … … 847 845 *tecplot << endl; 848 846 // print connectivity 849 for (TriangleMap:: iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++) {847 for (TriangleMap::const_iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++) { 850 848 *out << " " << runner->second->endpoints[0]->node->Name << "<->" << runner->second->endpoints[1]->node->Name << "<->" << runner->second->endpoints[2]->node->Name; 851 849 *tecplot << LookupList[runner->second->endpoints[0]->node->nr] << " " << LookupList[runner->second->endpoints[1]->node->nr] << " " << LookupList[runner->second->endpoints[2]->node->nr] << endl; … … 861 859 * \param *TesselStruct pointer to Tesselation structure 862 860 */ 863 void CalculateConcavityPerBoundaryPoint(ofstream *out, c lassTesselation *TesselStruct)861 void CalculateConcavityPerBoundaryPoint(ofstream *out, const Tesselation *TesselStruct) 864 862 { 865 863 class BoundaryPointSet *point = NULL; … … 868 866 //*out << Verbose(2) << "Begin of CalculateConcavityPerBoundaryPoint" << endl; 869 867 // calculate remaining concavity 870 for (PointMap:: iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {868 for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) { 871 869 point = PointRunner->second; 872 870 *out << Verbose(1) << "INFO: Current point is " << *point << "." << endl; … … 888 886 * \return true - all have exactly two triangles, false - some not, list is printed to screen 889 887 */ 890 bool CheckListOfBaselines(ofstream *out, Tesselation *TesselStruct)891 { 892 LineMap:: iterator testline;888 bool CheckListOfBaselines(ofstream *out, const Tesselation *TesselStruct) 889 { 890 LineMap::const_iterator testline; 893 891 bool result = false; 894 892 int counter = 0; -
src/tesselationhelpers.hpp
rad37ab r776b64 57 57 double GetAngle(const Vector &point, const Vector &reference, const Vector OrthogonalVector); 58 58 59 bool CheckLineCriteriaForDegeneratedTriangle(c lassBoundaryPointSet *nodes[3]);60 bool SortCandidates(c lass CandidateForTesselation* candidate1, classCandidateForTesselation* candidate2);61 TesselPoint* FindClosestPoint(const Vector* Point, TesselPoint *&SecondPoint, LinkedCell*LC);62 TesselPoint* FindSecondClosestPoint(const Vector*, LinkedCell*);63 Vector * GetClosestPointBetweenLine(ofstream *out, c lass BoundaryLineSet *Base, classBoundaryLineSet *OtherBase);59 bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet *nodes[3]); 60 bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation* candidate2); 61 TesselPoint* FindClosestPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC); 62 TesselPoint* FindSecondClosestPoint(const Vector*, const LinkedCell*); 63 Vector * GetClosestPointBetweenLine(ofstream *out, const BoundaryLineSet *Base, const BoundaryLineSet *OtherBase); 64 64 65 void WriteTecplotFile(ofstream *out, ofstream *tecplot, c lass Tesselation *TesselStruct, PointCloud *cloud,int N);66 void WriteRaster3dFile(ofstream *out, ofstream *rasterfile, c lass Tesselation *Tess,PointCloud *cloud);67 void IncludeSphereinRaster3D(ofstream *out, ofstream *rasterfile, c lass Tesselation *Tess,PointCloud *cloud);68 void WriteVrmlFile(ofstream *out, ofstream *vrmlfile, c lass Tesselation *Tess,PointCloud *cloud);69 void CalculateConcavityPerBoundaryPoint(ofstream *out, c lassTesselation *TesselStruct);70 double DistanceToTrianglePlane(ofstream *out, Vector *x,BoundaryTriangleSet *triangle);65 void WriteTecplotFile(ofstream *out, ofstream *tecplot, const Tesselation *TesselStruct, const PointCloud *cloud, const int N); 66 void WriteRaster3dFile(ofstream *out, ofstream *rasterfile, const Tesselation *Tess, const PointCloud *cloud); 67 void IncludeSphereinRaster3D(ofstream *out, ofstream *rasterfile, const Tesselation *Tess, const PointCloud *cloud); 68 void WriteVrmlFile(ofstream *out, ofstream *vrmlfile, const Tesselation *Tess, const PointCloud *cloud); 69 void CalculateConcavityPerBoundaryPoint(ofstream *out, const Tesselation *TesselStruct); 70 double DistanceToTrianglePlane(ofstream *out, const Vector *x, const BoundaryTriangleSet *triangle); 71 71 72 bool CheckListOfBaselines(ofstream *out, Tesselation *TesselStruct);72 bool CheckListOfBaselines(ofstream *out, const Tesselation *TesselStruct); 73 73 74 74 -
src/unittests/ActOnAllUnitTest.cpp
rad37ab r776b64 62 62 63 63 // scaling by value 64 VL.ActOnAll( (void (Vector::*)( double)) &Vector::Scale, 2. );64 VL.ActOnAll( (void (Vector::*)(const double)) &Vector::Scale, 2. ); 65 65 CPPUNIT_ASSERT_EQUAL( VL == Ref , false ); 66 66 67 VL.ActOnAll( (void (Vector::*)( double)) &Vector::Scale, 0.5 );67 VL.ActOnAll( (void (Vector::*)(const double)) &Vector::Scale, 0.5 ); 68 68 CPPUNIT_ASSERT_EQUAL( VL == Ref , true ); 69 69 70 70 // scaling by ref 71 VL.ActOnAll( (void (Vector::*)( double *)) &Vector::Scale,&factor );71 VL.ActOnAll( (void (Vector::*)(const double * const)) &Vector::Scale, (const double * const)&factor ); 72 72 CPPUNIT_ASSERT_EQUAL( VL == Ref , false ); 73 73 74 VL.ActOnAll( (void (Vector::*)( double *)) &Vector::Scale,&inverse );74 VL.ActOnAll( (void (Vector::*)(const double * const)) &Vector::Scale, (const double * const)&inverse ); 75 75 CPPUNIT_ASSERT_EQUAL( VL == Ref , true ); 76 76 … … 82 82 inverses[i] = 1./factors[i]; 83 83 } 84 VL.ActOnAll( (void (Vector::*)( double **)) &Vector::Scale,&factors );84 VL.ActOnAll( (void (Vector::*)(const double ** const)) &Vector::Scale, (const double ** const)&factors ); 85 85 CPPUNIT_ASSERT_EQUAL( VL == Ref , false ); 86 86 87 VL.ActOnAll( (void (Vector::*)( double **)) &Vector::Scale,&inverses );87 VL.ActOnAll( (void (Vector::*)(const double ** const)) &Vector::Scale, (const double ** const)&inverses ); 88 88 CPPUNIT_ASSERT_EQUAL( VL == Ref , true ); 89 89 }; -
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
rad37ab r776b64 77 77 78 78 // init maps 79 pointmap = CorrelationToPoint( (ofstream *)&cout, TestMolecule, hydrogen,point );79 pointmap = CorrelationToPoint( (ofstream *)&cout, (const molecule * const)TestMolecule, (const element * const)hydrogen, (const Vector *)point ); 80 80 binmap = NULL; 81 81 -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
rad37ab r776b64 81 81 // init tesselation and linked cell 82 82 Surface = new Tesselation; 83 TestMolecule->TesselStruct = Surface; 84 FindNonConvexBorder((ofstream *)&cerr, TestMolecule, LC, 2.5, NULL); 83 FindNonConvexBorder((ofstream *)&cerr, TestMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL); 85 84 LC = new LinkedCell(TestMolecule, 5.); 86 85 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() ); … … 123 122 // remove 124 123 delete(TestMolecule); 125 // note that Surface and all the atoms are cleaned by TestMolecule 124 delete(Surface); 125 // note that all the atoms are cleaned by TestMolecule 126 126 delete(LC); 127 127 delete(tafel); -
src/vector.cpp
rad37ab r776b64 21 21 /** Constructor of class vector. 22 22 */ 23 Vector::Vector( double x1, double x2,double x3) { x[0] = x1; x[1] = x2; x[2] = x3; };23 Vector::Vector(const double x1, const double x2, const double x3) { x[0] = x1; x[1] = x2; x[2] = x3; }; 24 24 25 25 /** Desctructor of class vector. … … 31 31 * \return \f$| x - y |^2\f$ 32 32 */ 33 double Vector::DistanceSquared(const Vector * y) const33 double Vector::DistanceSquared(const Vector * const y) const 34 34 { 35 35 double res = 0.; … … 43 43 * \return \f$| x - y |\f$ 44 44 */ 45 double Vector::Distance(const Vector * y) const45 double Vector::Distance(const Vector * const y) const 46 46 { 47 47 double res = 0.; … … 56 56 * \return \f$| x - y |\f$ 57 57 */ 58 double Vector::PeriodicDistance(const Vector * y, const double *cell_size) const58 double Vector::PeriodicDistance(const Vector * const y, const double * const cell_size) const 59 59 { 60 60 double res = Distance(y), tmp, matrix[NDIM*NDIM]; … … 94 94 * \return \f$| x - y |^2\f$ 95 95 */ 96 double Vector::PeriodicDistanceSquared(const Vector * y, const double *cell_size) const96 double Vector::PeriodicDistanceSquared(const Vector * const y, const double * const cell_size) const 97 97 { 98 98 double res = DistanceSquared(y), tmp, matrix[NDIM*NDIM]; … … 131 131 * Tries to translate a vector into each adjacent neighbouring cell. 132 132 */ 133 void Vector::KeepPeriodic(ofstream *out, double *matrix)133 void Vector::KeepPeriodic(ofstream *out, const double * const matrix) 134 134 { 135 135 // int N[NDIM]; … … 162 162 * \return \f$\langle x, y \rangle\f$ 163 163 */ 164 double Vector::ScalarProduct(const Vector * y) const164 double Vector::ScalarProduct(const Vector * const y) const 165 165 { 166 166 double res = 0.; … … 177 177 * \return \f$ x \times y \f& 178 178 */ 179 void Vector::VectorProduct(const Vector * y)179 void Vector::VectorProduct(const Vector * const y) 180 180 { 181 181 Vector tmp; … … 184 184 tmp.x[2] = x[0]* (y->x[1]) - x[1]* (y->x[0]); 185 185 this->CopyVector(&tmp); 186 187 186 }; 188 187 … … 192 191 * \return \f$\langle x, y \rangle\f$ 193 192 */ 194 void Vector::ProjectOntoPlane(const Vector * y)193 void Vector::ProjectOntoPlane(const Vector * const y) 195 194 { 196 195 Vector tmp; … … 217 216 * \return true - \a this contains intersection point on return, false - line is parallel to plane 218 217 */ 219 bool Vector::GetIntersectionWithPlane(ofstream *out, Vector *PlaneNormal, Vector *PlaneOffset, Vector *Origin, Vector *LineVector)218 bool Vector::GetIntersectionWithPlane(ofstream *out, const Vector * const PlaneNormal, const Vector * const PlaneOffset, const Vector * const Origin, const Vector * const LineVector) 220 219 { 221 220 double factor; … … 264 263 * \return distance to plane 265 264 */ 266 double Vector::DistanceToPlane(ofstream *out, Vector *PlaneNormal, Vector *PlaneOffset)265 double Vector::DistanceToPlane(ofstream *out, const Vector * const PlaneNormal, const Vector * const PlaneOffset) const 267 266 { 268 267 Vector temp; … … 292 291 * \return true - \a this will contain the intersection on return, false - lines are parallel 293 292 */ 294 bool Vector::GetIntersectionOfTwoLinesOnPlane(ofstream *out, Vector *Line1a, Vector *Line1b, Vector *Line2a, Vector *Line2b, const Vector *PlaneNormal)293 bool Vector::GetIntersectionOfTwoLinesOnPlane(ofstream *out, const Vector * const Line1a, const Vector * const Line1b, const Vector * const Line2a, const Vector * const Line2b, const Vector *PlaneNormal) 295 294 { 296 295 bool result = true; … … 375 374 * \param *y array to second vector 376 375 */ 377 void Vector::ProjectIt(const Vector * y)376 void Vector::ProjectIt(const Vector * const y) 378 377 { 379 378 Vector helper(*y); … … 386 385 * \return Vector 387 386 */ 388 Vector Vector::Projection(const Vector * y) const387 Vector Vector::Projection(const Vector * const y) const 389 388 { 390 389 Vector helper(*y); … … 435 434 /** Zeros all components of this vector. 436 435 */ 437 void Vector::One( double one)436 void Vector::One(const double one) 438 437 { 439 438 for (int i=NDIM;i--;) … … 443 442 /** Initialises all components of this vector. 444 443 */ 445 void Vector::Init( double x1, double x2,double x3)444 void Vector::Init(const double x1, const double x2, const double x3) 446 445 { 447 446 x[0] = x1; … … 469 468 * @return true - vector is normalized, false - vector is not 470 469 */ 471 bool Vector::IsNormalTo(const Vector * normal) const470 bool Vector::IsNormalTo(const Vector * const normal) const 472 471 { 473 472 if (ScalarProduct(normal) < MYEPSILON) … … 481 480 * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$ 482 481 */ 483 double Vector::Angle(const Vector * y) const482 double Vector::Angle(const Vector * const y) const 484 483 { 485 484 double norm1 = Norm(), norm2 = y->Norm(); … … 500 499 * \param alpha rotation angle in radian 501 500 */ 502 void Vector::RotateVector(const Vector * axis, const double alpha)501 void Vector::RotateVector(const Vector * const axis, const double alpha) 503 502 { 504 503 Vector a,y; … … 656 655 * \param *factor pointer to scaling factor 657 656 */ 658 void Vector::Scale( double **factor)657 void Vector::Scale(const double ** const factor) 659 658 { 660 659 for (int i=NDIM;i--;) … … 662 661 }; 663 662 664 void Vector::Scale( double *factor)663 void Vector::Scale(const double * const factor) 665 664 { 666 665 for (int i=NDIM;i--;) … … 668 667 }; 669 668 670 void Vector::Scale( double factor)669 void Vector::Scale(const double factor) 671 670 { 672 671 for (int i=NDIM;i--;) … … 677 676 * \param trans[] translation vector. 678 677 */ 679 void Vector::Translate(const Vector * trans)678 void Vector::Translate(const Vector * const trans) 680 679 { 681 680 for (int i=NDIM;i--;) … … 687 686 * \param *Minv inverse matrix 688 687 */ 689 void Vector::WrapPeriodically(const double * M, const double *Minv)688 void Vector::WrapPeriodically(const double * const M, const double * const Minv) 690 689 { 691 690 MatrixMultiplication(Minv); … … 704 703 * \param *matrix NDIM_NDIM array 705 704 */ 706 void Vector::MatrixMultiplication(const double * M)705 void Vector::MatrixMultiplication(const double * const M) 707 706 { 708 707 Vector C; … … 719 718 * \param *matrix NDIM_NDIM array 720 719 */ 721 double * Vector::InverseMatrix( double *A)720 double * Vector::InverseMatrix( const double * const A) 722 721 { 723 722 double *B = Malloc<double>(NDIM * NDIM, "Vector::InverseMatrix: *B"); … … 746 745 * \param *matrix NDIM_NDIM array 747 746 */ 748 void Vector::InverseMatrixMultiplication(const double * A)747 void Vector::InverseMatrixMultiplication(const double * const A) 749 748 { 750 749 Vector C; … … 786 785 * \param *factors three-component vector with the factor for each given vector 787 786 */ 788 void Vector::LinearCombinationOfVectors(const Vector * x1, const Vector *x2, const Vector *x3, double *factors)787 void Vector::LinearCombinationOfVectors(const Vector * const x1, const Vector * const x2, const Vector * const x3, const double * const factors) 789 788 { 790 789 for(int i=NDIM;i--;) … … 795 794 * \param n[] normal vector of mirror plane. 796 795 */ 797 void Vector::Mirror(const Vector * n)796 void Vector::Mirror(const Vector * const n) 798 797 { 799 798 double projection; … … 817 816 * \return true - success, vectors are linear independent, false - failure due to linear dependency 818 817 */ 819 bool Vector::MakeNormalVector(const Vector * y1, const Vector *y2, const Vector *y3)818 bool Vector::MakeNormalVector(const Vector * const y1, const Vector * const y2, const Vector * const y3) 820 819 { 821 820 Vector x1, x2; … … 853 852 * \return true - success, vectors are linear independent, false - failure due to linear dependency 854 853 */ 855 bool Vector::MakeNormalVector(const Vector * y1, const Vector *y2)854 bool Vector::MakeNormalVector(const Vector * const y1, const Vector * const y2) 856 855 { 857 856 Vector x1,x2; … … 884 883 * \return true - success, false - vector is zero 885 884 */ 886 bool Vector::MakeNormalVector(const Vector * y1)885 bool Vector::MakeNormalVector(const Vector * const y1) 887 886 { 888 887 bool result = false; … … 904 903 * \return true - success, false - failure (null vector given) 905 904 */ 906 bool Vector::GetOneNormalVector(const Vector * GivenVector)905 bool Vector::GetOneNormalVector(const Vector * const GivenVector) 907 906 { 908 907 int Components[NDIM]; // contains indices of non-zero components … … 950 949 * \return scaling parameter for this vector 951 950 */ 952 double Vector::CutsPlaneAt( Vector *A, Vector *B, Vector *C)951 double Vector::CutsPlaneAt(const Vector * const A, const Vector * const B, const Vector * const C) const 953 952 { 954 953 // cout << Verbose(3) << "For comparison: "; … … 965 964 * \return true if success, false if failed due to linear dependency 966 965 */ 967 bool Vector::LSQdistance( Vector **vectors, int num)966 bool Vector::LSQdistance(const Vector **vectors, int num) 968 967 { 969 968 int j; … … 1047 1046 * \param *y vector 1048 1047 */ 1049 void Vector::AddVector(const Vector * y)1048 void Vector::AddVector(const Vector * const y) 1050 1049 { 1051 1050 for (int i=NDIM;i--;) … … 1056 1055 * \param *y vector 1057 1056 */ 1058 void Vector::SubtractVector(const Vector * y)1057 void Vector::SubtractVector(const Vector * const y) 1059 1058 { 1060 1059 for (int i=NDIM;i--;) … … 1065 1064 * \param *y vector 1066 1065 */ 1067 void Vector::CopyVector(const Vector * y)1066 void Vector::CopyVector(const Vector * const y) 1068 1067 { 1069 1068 for (int i=NDIM;i--;) … … 1074 1073 * \param y vector 1075 1074 */ 1076 void Vector::CopyVector(const Vector y)1075 void Vector::CopyVector(const Vector &y) 1077 1076 { 1078 1077 for (int i=NDIM;i--;) … … 1085 1084 * \param check whether bounds shall be checked (true) or not (false) 1086 1085 */ 1087 void Vector::AskPosition( double *cell_size,bool check)1086 void Vector::AskPosition(const double * const cell_size, const bool check) 1088 1087 { 1089 1088 char coords[3] = {'x','y','z'}; … … 1113 1112 * \bug this is not yet working properly 1114 1113 */ 1115 bool Vector::SolveSystem(Vector * x1, Vector *x2, Vector *y, double alpha, double beta,double c)1114 bool Vector::SolveSystem(Vector * x1, Vector * x2, Vector * y, const double alpha, const double beta, const double c) 1116 1115 { 1117 1116 double D1,D2,D3,E1,E2,F1,F2,F3,p,q=0., A, B1, B2, C; … … 1276 1275 * @param three vectors forming the matrix that defines the shape of the parallelpiped 1277 1276 */ 1278 bool Vector::IsInParallelepiped(const Vector offset, const double *parallelepiped) const1277 bool Vector::IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const 1279 1278 { 1280 1279 Vector a; -
src/vector.hpp
rad37ab r776b64 30 30 ~Vector(); 31 31 32 double Distance(const Vector * y) const;33 double DistanceSquared(const Vector * y) const;34 double DistanceToPlane(ofstream *out, Vector *PlaneNormal, Vector *PlaneOffset);35 double PeriodicDistance(const Vector * y, const double *cell_size) const;36 double PeriodicDistanceSquared(const Vector * y, const double *cell_size) const;37 double ScalarProduct(const Vector * y) const;32 double Distance(const Vector * const y) const; 33 double DistanceSquared(const Vector * const y) const; 34 double DistanceToPlane(ofstream *out, const Vector * const PlaneNormal, const Vector * const PlaneOffset) const; 35 double PeriodicDistance(const Vector * const y, const double * const cell_size) const; 36 double PeriodicDistanceSquared(const Vector * const y, const double * const cell_size) const; 37 double ScalarProduct(const Vector * const y) const; 38 38 double Norm() const; 39 39 double NormSquared() const; 40 double Angle(const Vector * y) const;40 double Angle(const Vector * const y) const; 41 41 bool IsZero() const; 42 42 bool IsOne() const; 43 bool IsNormalTo(const Vector * normal) const;43 bool IsNormalTo(const Vector * const normal) const; 44 44 45 void AddVector(const Vector * y);46 void SubtractVector(const Vector * y);47 void CopyVector(const Vector * y);48 void CopyVector(const Vector y);49 void RotateVector(const Vector * y, const double alpha);50 void VectorProduct(const Vector * y);51 void ProjectOntoPlane(const Vector * y);52 void ProjectIt(const Vector * y);53 Vector Projection(const Vector * y) const;45 void AddVector(const Vector * const y); 46 void SubtractVector(const Vector * const y); 47 void CopyVector(const Vector * const y); 48 void CopyVector(const Vector &y); 49 void RotateVector(const Vector * const y, const double alpha); 50 void VectorProduct(const Vector * const y); 51 void ProjectOntoPlane(const Vector * const y); 52 void ProjectIt(const Vector * const y); 53 Vector Projection(const Vector * const y) const; 54 54 void Zero(); 55 void One( double one);56 void Init( double x1, double x2,double x3);55 void One(const double one); 56 void Init(const double x1, const double x2, const double x3); 57 57 void Normalize(); 58 void Translate(const Vector * x);59 void Mirror(const Vector * x);60 void Scale( double **factor);61 void Scale( double *factor);62 void Scale( double factor);63 void MatrixMultiplication(const double * M);64 double * InverseMatrix( double *A);65 void InverseMatrixMultiplication(const double * M);66 void KeepPeriodic(ofstream *out, double *matrix);67 void LinearCombinationOfVectors(const Vector * x1, const Vector *x2, const Vector *x3, double *factors);68 double CutsPlaneAt( Vector *A, Vector *B, Vector *C);69 bool GetIntersectionWithPlane(ofstream *out, Vector *PlaneNormal, Vector *PlaneOffset, Vector *Origin, Vector *LineVector);70 bool GetIntersectionOfTwoLinesOnPlane(ofstream *out, Vector *Line1a, Vector *Line1b, Vector *Line2a, Vector *Line2b, const Vector *Normal = NULL);71 bool GetOneNormalVector(const Vector * x1);72 bool MakeNormalVector(const Vector * y1);73 bool MakeNormalVector(const Vector * y1, const Vector *y2);74 bool MakeNormalVector(const Vector * x1, const Vector *x2, const Vector *x3);75 bool SolveSystem(Vector * x1, Vector *x2, Vector *y, double alpha, double beta,double c);76 bool LSQdistance( Vector **vectors, int dim);77 void AskPosition( double *cell_size,bool check);58 void Translate(const Vector * const x); 59 void Mirror(const Vector * const x); 60 void Scale(const double ** const factor); 61 void Scale(const double * const factor); 62 void Scale(const double factor); 63 void MatrixMultiplication(const double * const M); 64 double * InverseMatrix(const double * const A); 65 void InverseMatrixMultiplication(const double * const M); 66 void KeepPeriodic(ofstream *out, const double * const matrix); 67 void LinearCombinationOfVectors(const Vector * const x1, const Vector * const x2, const Vector * const x3, const double * const factors); 68 double CutsPlaneAt(const Vector * const A, const Vector * const B, const Vector * const C) const; 69 bool GetIntersectionWithPlane(ofstream *out, const Vector * const PlaneNormal, const Vector * const PlaneOffset, const Vector * const Origin, const Vector * const LineVector); 70 bool GetIntersectionOfTwoLinesOnPlane(ofstream *out, const Vector * const Line1a, const Vector * const Line1b, const Vector * const Line2a, const Vector * const Line2b, const Vector *Normal = NULL); 71 bool GetOneNormalVector(const Vector * const x1); 72 bool MakeNormalVector(const Vector * const y1); 73 bool MakeNormalVector(const Vector * const y1, const Vector * const y2); 74 bool MakeNormalVector(const Vector * const x1, const Vector * const x2, const Vector * const x3); 75 bool SolveSystem(Vector * x1, Vector * x2, Vector * y, const double alpha, const double beta, const double c); 76 bool LSQdistance(const Vector ** vectors, int dim); 77 void AskPosition(const double * const cell_size, const bool check); 78 78 bool Output(ofstream *out) const; 79 bool IsInParallelepiped(const Vector offset, const double *parallelepiped) const;80 void WrapPeriodically(const double * M, const double *Minv);79 bool IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const; 80 void WrapPeriodically(const double * const M, const double * const Minv); 81 81 }; 82 82
Note:
See TracChangeset
for help on using the changeset viewer.