Changeset 776b64 for src


Ignore:
Timestamp:
Oct 27, 2009, 4:11:22 PM (16 years ago)
Author:
Frederik Heber <heber@…>
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
Message:

Huge refactoring to make const what is const (ticket #38), continued.

  • too many changes because of too many cross-references to be able to list them up here.
  • NOTE that "make check" runs fine and did catch several error.
  • note that we had to use const_iterator several times when the map, ... was declared const.
  • at times we changed an allocated LinkedCell LCList(...) into

const LinkedCell *LCList;
LCList = new LinkedCell(...);

  • also mutable (see ticket #5) was used, e.g. for molecule::InternalPointer (PointCloud changes are allowed, because they are just accounting).

Signed-off-by: Frederik Heber <heber@…>

Location:
src
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • src/analysis_correlation.cpp

    rad37ab r776b64  
    2424 * \return Map of doubles with values the pair of the two atoms.
    2525 */
    26 PairCorrelationMap *PairCorrelation( ofstream *out, molecule *mol, element *type1, element *type2 )
     26PairCorrelationMap *PairCorrelation( const ofstream *out, const molecule * const mol, const element * const type1, const element * const type2 )
    2727{
    2828  PairCorrelationMap *outmap = NULL;
     
    6161 * \return Map of dobules with values as pairs of atom and the vector
    6262 */
    63 CorrelationToPointMap *CorrelationToPoint( ofstream *out, molecule *mol, element *type, Vector *point )
     63CorrelationToPointMap *CorrelationToPoint( const ofstream *out, const molecule * const mol, const element * const type, const Vector *point )
    6464{
    6565  CorrelationToPointMap *outmap = NULL;
     
    7676    if ((type == NULL) || (Walker->type == type)) {
    7777      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) ) );
    7979    }
    8080  }
     
    9191 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    9292 */
    93 CorrelationToSurfaceMap *CorrelationToSurface( ofstream *out, molecule *mol, element *type, Tesselation *Surface, LinkedCell *LC )
     93CorrelationToSurfaceMap *CorrelationToSurface( ofstream *out, const molecule * const mol, const element * const type, const Tesselation * const Surface, const LinkedCell *LC )
    9494{
    9595
     
    124124 * \param BinStart first bin
    125125 */
    126 double GetBin ( double value, double BinWidth, double BinStart )
     126double GetBin ( const double value, const double BinWidth, const double BinStart )
    127127{
    128128  double bin =(double) (floor((value - BinStart)/BinWidth));
     
    135135 * \param *map map to write
    136136 */
    137 void OutputCorrelation( ofstream *file, BinPairMap *map )
     137void OutputCorrelation( ofstream *file, const BinPairMap * const map )
    138138{
    139139  *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) {
    141141    *file << runner->first << "\t" << runner->second << endl;
    142142  }
     
    147147 * \param *map map to write
    148148 */
    149 void OutputPairCorrelation( ofstream *file, PairCorrelationMap *map )
     149void OutputPairCorrelation( ofstream *file, const PairCorrelationMap * const map )
    150150{
    151151  *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) {
    153153    *file << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
    154154  }
     
    159159 * \param *map map to write
    160160 */
    161 void OutputCorrelationToPoint( ofstream *file, CorrelationToPointMap *map )
     161void OutputCorrelationToPoint( ofstream *file, const CorrelationToPointMap * const map )
    162162{
    163163  *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) {
    165165    *file << runner->first;
    166166    for (int i=0;i<NDIM;i++)
     
    174174 * \param *map map to write
    175175 */
    176 void OutputCorrelationToSurface( ofstream *file, CorrelationToSurfaceMap *map )
     176void OutputCorrelationToSurface( ofstream *file, const CorrelationToSurfaceMap * const map )
    177177{
    178178  *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) {
    180180    *file << runner->first << "\t" << *(runner->second.second) << endl;
    181181  }
  • src/analysis_correlation.hpp

    rad37ab r776b64  
    3939
    4040typedef multimap<double, pair<atom *, atom *> > PairCorrelationMap;
    41 typedef multimap<double, pair<atom *, Vector *> > CorrelationToPointMap;
     41typedef multimap<double, pair<atom *, const Vector *> > CorrelationToPointMap;
    4242typedef multimap<double, pair<atom *, BoundaryTriangleSet *> > CorrelationToSurfaceMap;
    4343typedef map<double, int> BinPairMap;
     
    4545/********************************************** declarations *******************************/
    4646
    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 );
     47PairCorrelationMap *PairCorrelation( const ofstream *out, const molecule * const mol, const element * const type1, const element * const  type2 );
     48CorrelationToPointMap *CorrelationToPoint( const ofstream *out, const molecule * const mol, const element * const type, const Vector *point );
     49CorrelationToSurfaceMap *CorrelationToSurface( ofstream *out, const molecule * const mol, const element * const type, const Tesselation * const Surface, const LinkedCell *LC );
     50double GetBin ( const double value, const double BinWidth, const double BinStart );
     51void OutputCorrelation( ofstream *file, const BinPairMap * const map );
     52void OutputPairCorrelation( ofstream *file, const BinPairMap * const map );
     53void OutputCorrelationToPoint( ofstream *file, const BinPairMap * const map );
     54void OutputCorrelationToSurface( ofstream *file, const BinPairMap * const map );
    5555
    5656
     
    9595 * \return Map of doubles (the bins) with counts as values
    9696 */
    97 template <typename T> BinPairMap *BinData ( ofstream *out,  T *map, double BinWidth, double BinStart, double BinEnd )
     97template <typename T> BinPairMap *BinData ( ofstream *out,  T *map, const double BinWidth, const double BinStart, const double BinEnd )
    9898{
    9999  BinPairMap *outmap = new BinPairMap;
  • src/boundary.cpp

    rad37ab r776b64  
    2626 * \param *BoundaryPoints NDIM set of boundary points defining the convex envelope on each projected plane
    2727 * \param *mol molecule structure representing the cluster
     28 * \param *&TesselStruct Tesselation structure with triangles
    2829 * \param IsAngstroem whether we have angstroem or atomic units
    2930 * \return NDIM array of the diameters
    3031 */
    31 double *GetDiametersOfCluster(ofstream *out, Boundaries *BoundaryPtr, molecule *mol, bool IsAngstroem)
     32double *GetDiametersOfCluster(ofstream *out, const Boundaries *BoundaryPtr, const molecule *mol, Tesselation *&TesselStruct, const bool IsAngstroem)
    3233{
    3334  // get points on boundary of NULL was given as parameter
    3435  bool BoundaryFreeFlag = false;
    35   Boundaries *BoundaryPoints = BoundaryPtr;
    3636  double OldComponent = 0.;
    3737  double tmp = 0.;
     
    4242  int component = 0;
    4343  int Othercomponent = 0;
    44   Boundaries::iterator Neighbour;
    45   Boundaries::iterator OtherNeighbour;
     44  Boundaries::const_iterator Neighbour;
     45  Boundaries::const_iterator OtherNeighbour;
    4646  double *GreatestDiameter = new double[NDIM];
    4747
    48   if (BoundaryPoints == NULL) {
     48  const Boundaries *BoundaryPoints;
     49  if (BoundaryPtr == NULL) {
    4950    BoundaryFreeFlag = true;
    50     BoundaryPoints = GetBoundaryPoints(out, mol);
     51    BoundaryPoints = GetBoundaryPoints(out, mol, TesselStruct);
    5152  } else {
     53    BoundaryPoints = BoundaryPtr;
    5254    *out << Verbose(1) << "Using given boundary points set." << endl;
    5355  }
     
    6365          Othercomponent = (axis + 1 + ((j + 1) & 1)) % NDIM;
    6466          //*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++) {
    6868              //*out << Verbose(2) << "Current runner is " << *(runner->second.second) << "." << endl;
    6969              // seek for the neighbours pair where the Othercomponent sign flips
     
    7474              DistanceVector.CopyVector(&runner->second.second->x);
    7575              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
    7877                  OldComponent = DistanceVector.x[Othercomponent];
    7978                  Neighbour++;
     
    8382                  DistanceVector.SubtractVector(&Neighbour->second.second->x);
    8483                  //*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(
    8785                  OldComponent) - DistanceVector.x[Othercomponent] / fabs(
    8886                  DistanceVector.x[Othercomponent])) < MYEPSILON)); // as long as sign does not flip
    89               if (runner != Neighbour)
    90                 {
     87              if (runner != Neighbour) {
    9188                  OtherNeighbour = Neighbour;
    9289                  if (OtherNeighbour == BoundaryPoints[axis].begin()) // make it wrap around
     
    133130 * \param *out output stream for debugging
    134131 * \param *mol molecule structure representing the cluster
    135  */
    136 Boundaries *GetBoundaryPoints(ofstream *out, molecule *mol)
     132 * \param *&TesselStruct pointer to Tesselation structure
     133 */
     134Boundaries *GetBoundaryPoints(ofstream *out, const molecule *mol, Tesselation *&TesselStruct)
    137135{
    138136  atom *Walker = NULL;
     
    148146  Vector ProjectedVector;
    149147  Boundaries *BoundaryPoints = new Boundaries[NDIM]; // first is alpha, second is (r, nr)
    150   double radius = 0.;
    151148  double angle = 0.;
    152149
     
    172169
    173170      // correct for negative side
    174       radius = ProjectedVector.NormSquared();
     171      const double radius = ProjectedVector.NormSquared();
    175172      if (fabs(radius) > MYEPSILON)
    176173        angle = ProjectedVector.Angle(&AngleReferenceVector);
     
    188185        *out << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl;
    189186        *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;
    193190          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) {
    196193          helper.CopyVector(&Walker->x);
    197194          helper.SubtractVector(MolCenter);
    198           tmp = helper.NormSquared();
     195          const double oldhelperNorm = helper.NormSquared();
    199196          helper.CopyVector(&BoundaryTestPair.first->second.second->x);
    200197          helper.SubtractVector(MolCenter);
    201           if (helper.NormSquared() < tmp) {
     198          if (helper.NormSquared() < oldhelperNorm) {
    202199            BoundaryTestPair.first->second.second = Walker;
    203200            *out << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl;
    204201          } 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;
    206203          }
    207204        } 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;
    209206        }
    210207      }
     
    305302/** Tesselates the convex boundary by finding all boundary points.
    306303 * \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.
    308305 * \param *TesselStruct Tesselation filled with points, lines and triangles on boundary on return
    309306 * \param *LCList atoms in LinkedCell list
     
    311308 * \return *TesselStruct is filled with convex boundary and tesselation is stored under \a *filename.
    312309 */
    313 void FindConvexBorder(ofstream *out, molecule* mol, class LinkedCell *LCList, const char *filename)
     310void FindConvexBorder(ofstream *out, const molecule* mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename)
    314311{
    315312  bool BoundaryFreeFlag = false;
     
    318315  cout << Verbose(1) << "Begin of FindConvexBorder" << endl;
    319316
    320   if (mol->TesselStruct != NULL) // free if allocated
    321     delete(mol->TesselStruct);
    322   mol->TesselStruct = new class Tesselation;
     317  if (TesselStruct != NULL) // free if allocated
     318    delete(TesselStruct);
     319  TesselStruct = new class Tesselation;
    323320
    324321  // 1. Find all points on the boundary
    325322  if (BoundaryPoints == NULL) {
    326323      BoundaryFreeFlag = true;
    327       BoundaryPoints = GetBoundaryPoints(out, mol);
     324      BoundaryPoints = GetBoundaryPoints(out, mol, TesselStruct);
    328325  } else {
    329326      *out << Verbose(1) << "Using given boundary points set." << endl;
     
    348345  for (int axis = 0; axis < NDIM; axis++)
    349346    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))
    351348          *out << Verbose(3) << "WARNING: Point " << *(runner->second.second) << " is already present!" << endl;
    352349
    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;
    354351  // now we have the whole set of edge points in the BoundaryList
    355352
     
    362359
    363360  // 3a. guess starting triangle
    364   mol->TesselStruct->GuessStartingTriangle(out);
     361  TesselStruct->GuessStartingTriangle(out);
    365362
    366363  // 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);
    368365
    369366  // 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))
    371368    *out << Verbose(1) << "Insertion of straddling points failed!" << endl;
    372369
    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;
    374371
    375372  // 4. Store triangles in tecplot file
     
    380377      OutputName.append(TecplotSuffix);
    381378      ofstream *tecplot = new ofstream(OutputName.c_str());
    382       WriteTecplotFile(out, tecplot, mol->TesselStruct, mol, 0);
     379      WriteTecplotFile(out, tecplot, TesselStruct, mol, 0);
    383380      tecplot->close();
    384381      delete(tecplot);
     
    389386      OutputName.append(Raster3DSuffix);
    390387      ofstream *rasterplot = new ofstream(OutputName.c_str());
    391       WriteRaster3dFile(out, rasterplot, mol->TesselStruct, mol);
     388      WriteRaster3dFile(out, rasterplot, TesselStruct, mol);
    392389      rasterplot->close();
    393390      delete(rasterplot);
     
    400397  do {
    401398    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++) {
    403400      line = LineRunner->second;
    404401      *out << Verbose(1) << "INFO: Current line is " << *line << "." << endl;
     
    407404
    408405        // flip the line
    409         if (mol->TesselStruct->PickFarthestofTwoBaselines(out, line) == 0.)
     406        if (TesselStruct->PickFarthestofTwoBaselines(out, line) == 0.)
    410407          *out << Verbose(1) << "ERROR: Correction of concave baselines failed!" << endl;
    411408        else {
    412           mol->TesselStruct->FlipBaseline(out, line);
     409          TesselStruct->FlipBaseline(out, line);
    413410          *out << Verbose(1) << "INFO: Correction of concave baselines worked." << endl;
    414411        }
     
    418415
    419416  // 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))
    421418//    *out << Verbose(1) << "Correction of concave tesselpoints failed!" << endl;
    422419
    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;
    424421
    425422  // 4. Store triangles in tecplot file
     
    429426      OutputName.append(TecplotSuffix);
    430427      ofstream *tecplot = new ofstream(OutputName.c_str());
    431       WriteTecplotFile(out, tecplot, mol->TesselStruct, mol, 0);
     428      WriteTecplotFile(out, tecplot, TesselStruct, mol, 0);
    432429      tecplot->close();
    433430      delete(tecplot);
     
    437434      OutputName.append(Raster3DSuffix);
    438435      ofstream *rasterplot = new ofstream(OutputName.c_str());
    439       WriteRaster3dFile(out, rasterplot, mol->TesselStruct, mol);
     436      WriteRaster3dFile(out, rasterplot, TesselStruct, mol);
    440437      rasterplot->close();
    441438      delete(rasterplot);
     
    458455 * \return true - all removed, false - something went wrong
    459456 */
    460 bool RemoveAllBoundaryPoints(ofstream *out, class Tesselation *TesselStruct, molecule *mol, char *filename)
     457bool RemoveAllBoundaryPoints(ofstream *out, class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename)
    461458{
    462459  int i=0;
     
    481478    // store envelope
    482479    sprintf(number, "-%04d", i++);
    483     StoreTrianglesinFile(out, mol, filename, number);
     480    StoreTrianglesinFile(out, mol, (const Tesselation *&)TesselStruct, filename, number);
    484481  }
    485482
     
    511508 * \return volume difference between the non- and the created convex envelope
    512509 */
    513 double ConvexizeNonconvexEnvelope(ofstream *out, class Tesselation *TesselStruct, molecule *mol, char *filename)
     510double ConvexizeNonconvexEnvelope(ofstream *out, class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename)
    514511{
    515512  double volume = 0;
     
    539536    sprintf(dummy, "-first-%d", run);
    540537    //CalculateConcavityPerBoundaryPoint(out, TesselStruct);
    541     StoreTrianglesinFile(out, mol, filename, dummy);
     538    StoreTrianglesinFile(out, mol, (const Tesselation *&)TesselStruct, filename, dummy);
    542539
    543540    PointRunner = TesselStruct->PointsOnBoundary.begin();
     
    555552          volume += TesselStruct->RemovePointFromTesselatedSurface(out, point);
    556553          sprintf(dummy, "-first-%d", ++run);
    557           StoreTrianglesinFile(out, mol, filename, dummy);
     554          StoreTrianglesinFile(out, mol, (const Tesselation *&)TesselStruct, filename, dummy);
    558555          Concavity = true;
    559556          break;
     
    565562    sprintf(dummy, "-second-%d", run);
    566563    //CalculateConcavityPerBoundaryPoint(out, TesselStruct);
    567     StoreTrianglesinFile(out, mol, filename, dummy);
     564    StoreTrianglesinFile(out, mol, (const Tesselation *&)TesselStruct, filename, dummy);
    568565
    569566    // second step: PickFarthestofTwoBaselines
     
    579576        volume += tmp;
    580577        if (tmp != 0.) {
    581           mol->TesselStruct->FlipBaseline(out, line);
     578          TesselStruct->FlipBaseline(out, line);
    582579          Concavity = true;
    583580        }
     
    611608
    612609  CalculateConcavityPerBoundaryPoint(out, TesselStruct);
    613   StoreTrianglesinFile(out, mol, filename, "");
     610  StoreTrianglesinFile(out, mol, (const Tesselation *&)TesselStruct, filename, "");
    614611
    615612  // end
     
    668665 * \param *out output stream for debugging
    669666 * \param *mol molecule with atoms and bonds
     667 * \param *&TesselStruct Tesselation with boundary triangles
    670668 * \param *filename prefix of filename
    671669 * \param *extraSuffix intermediate suffix
    672670 */
    673 void StoreTrianglesinFile(ofstream *out, molecule *mol, const char *filename, const char *extraSuffix)
     671void StoreTrianglesinFile(ofstream *out, const molecule * const mol, const Tesselation *&TesselStruct, const char *filename, const char *extraSuffix)
    674672{
    675673  // 4. Store triangles in tecplot file
     
    680678      OutputName.append(TecplotSuffix);
    681679      ofstream *tecplot = new ofstream(OutputName.c_str());
    682       WriteTecplotFile(out, tecplot, mol->TesselStruct, mol, 0);
     680      WriteTecplotFile(out, tecplot, TesselStruct, mol, 0);
    683681      tecplot->close();
    684682      delete(tecplot);
     
    689687      OutputName.append(Raster3DSuffix);
    690688      ofstream *rasterplot = new ofstream(OutputName.c_str());
    691       WriteRaster3dFile(out, rasterplot, mol->TesselStruct, mol);
     689      WriteRaster3dFile(out, rasterplot, TesselStruct, mol);
    692690      rasterplot->close();
    693691      delete(rasterplot);
     
    701699 * \param *configuration needed for path to store convex envelope file
    702700 * \param *mol molecule structure representing the cluster
     701 * \param *&TesselStruct Tesselation structure with triangles on return
    703702 * \param ClusterVolume guesstimated cluster volume, if equal 0 we used VolumeOfConvexEnvelope() instead.
    704703 * \param celldensity desired average density in final cell
     
    722721
    723722  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);
    726725  LinkedCell LCList(mol, 10.);
    727   FindConvexBorder(out, mol, &LCList, NULL);
     726  FindConvexBorder(out, mol, TesselStruct, &LCList, NULL);
    728727
    729728  // some preparations beforehand
     
    821820  LinkedCell *LCList[List->ListOfMolecules.size()];
    822821  double phi[NDIM];
     822  class Tesselation *TesselStruct[List->ListOfMolecules.size()];
    823823
    824824  *out << Verbose(0) << "Begin of FillBoxWithMolecule" << endl;
     
    828828    *out << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl;
    829829    LCList[i] = new LinkedCell((*ListRunner), 5.); // get linked cell list
    830     if ((*ListRunner)->TesselStruct == NULL) {
     830    if (TesselStruct[i] == NULL) {
    831831      *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);
    833833    }
    834834    i++;
     
    868868        for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
    869869          // get linked cell list
    870           if ((*ListRunner)->TesselStruct == NULL) {
     870          if (TesselStruct[i] == NULL) {
    871871            *out << Verbose(1) << "ERROR: TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl;
    872872            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          }
    875877        }
    876878
     
    947949 * \param *out output stream for debugging
    948950 * \param *mol molecule structure with Atom's and Bond's
    949  * \param *Tess Tesselation filled with points, lines and triangles on boundary on return
    950  * \param *LCList atoms in LinkedCell list
     951 * \param *&TesselStruct Tesselation filled with points, lines and triangles on boundary on return
     952 * \param *&LCList atoms in LinkedCell list
    951953 * \param RADIUS radius of the virtual sphere
    952954 * \param *filename filename prefix for output of vertex data
    953955 */
    954 void FindNonConvexBorder(ofstream *out, molecule* mol, class LinkedCell *LCList, const double RADIUS, const char *filename = NULL)
     956void FindNonConvexBorder(ofstream *out, const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *&LCList, const double RADIUS, const char *filename = NULL)
    955957{
    956958  bool freeLC = false;
     
    961963
    962964  *out << Verbose(1) << "Entering search for non convex hull. " << endl;
    963   if (mol->TesselStruct == NULL) {
     965  if (TesselStruct == NULL) {
    964966    *out << Verbose(1) << "Allocating Tesselation struct ..." << endl;
    965     mol->TesselStruct = new Tesselation;
     967    TesselStruct= new Tesselation;
    966968  } else {
    967     delete(mol->TesselStruct);
     969    delete(TesselStruct);
    968970    *out << Verbose(1) << "Re-Allocating Tesselation struct ..." << endl;
    969     mol->TesselStruct = new Tesselation;
     971    TesselStruct = new Tesselation;
    970972  }
    971973
     
    979981
    980982  // 1. get starting triangle
    981   mol->TesselStruct->FindStartingTriangle(out, RADIUS, LCList);
     983  TesselStruct->FindStartingTriangle(out, RADIUS, LCList);
    982984
    983985  // 2. expand from there
    984   baseline = mol->TesselStruct->LinesOnBoundary.begin();
     986  baseline = TesselStruct->LinesOnBoundary.begin();
    985987  baseline++; // skip first line
    986   while ((baseline != mol->TesselStruct->LinesOnBoundary.end()) || (OneLoopWithoutSuccessFlag)) {
     988  while ((baseline != TesselStruct->LinesOnBoundary.end()) || (OneLoopWithoutSuccessFlag)) {
    987989    if (baseline->second->triangles.size() == 1) {
    988990      // 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.
    990992      OneLoopWithoutSuccessFlag = OneLoopWithoutSuccessFlag || TesselationFailFlag;
    991993      if (!TesselationFailFlag)
     
    994996      // write temporary envelope
    995997      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 configuration
    997           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);
    9981000        }
    9991001      }
    1000       baseline = mol->TesselStruct->LinesOnBoundary.end();
     1002      baseline = TesselStruct->LinesOnBoundary.end();
    10011003      *out << Verbose(2) << "Baseline set to end." << endl;
    10021004    } else {
     
    10061008    }
    10071009
    1008     if ((baseline == mol->TesselStruct->LinesOnBoundary.end()) && (OneLoopWithoutSuccessFlag)) {
    1009       baseline = mol->TesselStruct->LinesOnBoundary.begin();   // restart if we reach end due to newly inserted lines
     1010    if ((baseline == TesselStruct->LinesOnBoundary.end()) && (OneLoopWithoutSuccessFlag)) {
     1011      baseline = TesselStruct->LinesOnBoundary.begin();   // restart if we reach end due to newly inserted lines
    10101012      OneLoopWithoutSuccessFlag = false;
    10111013    }
     
    10131015  }
    10141016  // check envelope for consistency
    1015   CheckListOfBaselines(out, mol->TesselStruct);
     1017  CheckListOfBaselines(out, TesselStruct);
    10161018
    10171019  // 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);
    10191021//  mol->GoToFirst();
    10201022//  class TesselPoint *Runner = NULL;
     
    10221024//    Runner = mol->GetPoint();
    10231025//    *out << Verbose(1) << "Checking on " << Runner->Name << " ... " << endl;
    1024 //    if (!mol->TesselStruct->IsInnerPoint(out, Runner, LCList)) {
     1026//    if (!->IsInnerPoint(out, Runner, LCList)) {
    10251027//      *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);
    10271029//    } else {
    10281030//      *out << Verbose(2) << Runner->Name << " is inside of or on envelope." << endl;
     
    10321034
    10331035  // Purges surplus triangles.
    1034   mol->TesselStruct->RemoveDegeneratedTriangles();
     1036  TesselStruct->RemoveDegeneratedTriangles();
    10351037
    10361038  // check envelope for consistency
    1037   CheckListOfBaselines(out, mol->TesselStruct);
     1039  CheckListOfBaselines(out, TesselStruct);
    10381040
    10391041  // 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, "");
    10421044
    10431045  if (freeLC)
  • src/boundary.hpp

    rad37ab r776b64  
    4848/********************************************** declarations *******************************/
    4949
     50double ConvexizeNonconvexEnvelope(ofstream *out, class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename);
     51molecule * FillBoxWithMolecule(ofstream *out, MoleculeListClass *List, molecule *filler, config &configuration, double distance[NDIM], double RandAtomDisplacement, double RandMolDisplacement, bool DoRandomRotation);
     52void FindConvexBorder(ofstream *out, const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename);
     53Vector* FindEmbeddingHole(ofstream *out, MoleculeListClass *mols, molecule *srcmol);
     54void FindNextSuitablePoint(class BoundaryTriangleSet *BaseTriangle, class BoundaryLineSet *BaseLine, atom*& OptCandidate, Vector *OptCandidateCenter, double *ShortestAngle, const double RADIUS, LinkedCell *LC);
     55void FindNonConvexBorder(ofstream *out, const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *&LC, const double RADIUS, const char *tempbasename);
     56Boundaries *GetBoundaryPoints(ofstream *out, const molecule *mol, Tesselation *&TesselStruct);
     57double * GetDiametersOfCluster(ofstream *out, const Boundaries *BoundaryPtr, const molecule *mol, Tesselation *&TesselStruct, const bool IsAngstroem);
     58void PrepareClustersinWater(ofstream *out, config *configuration, molecule *mol, double ClusterVolume, double celldensity);
     59bool RemoveAllBoundaryPoints(ofstream *out, class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename);
     60void StoreTrianglesinFile(ofstream *out, const molecule * const mol, const Tesselation *&TesselStruct, const char *filename, const char *extraSuffix);
    5061double 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);
    6262
    6363
  • src/builder.cpp

    rad37ab r776b64  
    254254        } while ((j != -1) && (i<128));
    255255        if (i >= 2) {
    256           first->x.LSQdistance(atoms, i);
     256          first->x.LSQdistance((const Vector **)atoms, i);
    257257
    258258          first->x.Output((ofstream *)&cout);
     
    592592      {
    593593        cout << Verbose(0) << "Evaluating volume of the convex envelope.";
    594         LinkedCell LCList(mol, 10.);
    595594        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);
    597598        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);
    599601        delete(TesselStruct);
    600602      }
     
    720722       cin >> factor[2];
    721723       valid = true;
    722        mol->Scale(&factor);
     724       mol->Scale((const double ** const)&factor);
    723725       delete[](factor);
    724726      }
     
    15881590                // get the boundary
    15891591                class molecule *Boundary = new molecule(periode);
     1592                class Tesselation *TesselStruct = NULL;
    15901593                struct ConfigFileBuffer *FileBuffer = NULL;
    15911594                PrepareFileBuffer(argv[argptr], FileBuffer);
    15921595                LoadMolecule(Boundary, FileBuffer, periode, false);
    1593                 LinkedCell LCList(Boundary, 2.*radius);
     1596                const LinkedCell *LCList = NULL;
     1597                LCList = new LinkedCell(Boundary, 2.*radius);
    15941598                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 );
    15981601                BinPairMap *binmap = BinData( (ofstream *)&cout, surfacemap, 0.5, 0., 0. );
    15991602                OutputCorrelation ( &binoutput, binmap );
    16001603                output.close();
    16011604                binoutput.close();
     1605                delete(LCList);
    16021606                delete(FileBuffer);
     1607                delete(TesselStruct);
    16031608                delete(Boundary);
    16041609                argptr+=3;
     
    16751680                cerr << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl;
    16761681              } else {
    1677                 class Tesselation T;
     1682                class Tesselation *T = NULL;
     1683                const LinkedCell *LCList = NULL;
    16781684                string filename(argv[argptr+1]);
    16791685                filename.append(".csv");
     
    16811687                cout << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl;
    16821688                start = clock();
    1683                 LinkedCell 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());
    16861692                end = clock();
    16871693                cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
     1694                delete(LCList);
    16881695                argptr+=2;
    16891696              }
     
    18061813                factor[1] = atof(argv[argptr+1]);
    18071814                factor[2] = atof(argv[argptr+2]);
    1808                 mol->Scale(&factor);
     1815                mol->Scale((const double ** const)&factor);
    18091816                for (int i=0;i<NDIM;i++) {
    18101817                  j += i+1;
     
    19351942                cerr << "Not enough or invalid arguments given for convex envelope: -o <convex output file> <non-convex output file>" << endl;
    19361943              } else {
     1944                class Tesselation *TesselStruct = NULL;
     1945                const LinkedCell *LCList = NULL;
    19371946                cout << Verbose(0) << "Evaluating volume of the convex envelope.";
    19381947                cout << Verbose(1) << "Storing tecplot convex data in " << argv[argptr] << "." << endl;
    19391948                cout << Verbose(1) << "Storing tecplot non-convex data in " << argv[argptr+1] << "." << endl;
    1940                 LinkedCell 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);
    19461955                cout << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl;
    19471956                cout << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl;
     1957                delete(TesselStruct);
     1958                delete(LCList);
    19481959                argptr+=2;
    19491960              }
  • src/ellipsoid.cpp

    rad37ab r776b64  
    234234  int index;
    235235  TesselPoint *Candidate = NULL;
    236   LinkedNodes *List = NULL;
    237236  *out << Verbose(2) << "Begin of PickRandomPointSet" << endl;
    238237
     
    249248    *out << Verbose(2) << "INFO: Center cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " ... ";
    250249    // get random cell
    251     List = LC->GetCurrentCell();
     250    const LinkedNodes *List = LC->GetCurrentCell();
    252251    if (List == NULL) {  // set index to it
    253252      continue;
     
    268267      for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    269268        for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    270           List = LC->GetCurrentCell();
     269          const LinkedNodes *List = LC->GetCurrentCell();
    271270          PointsLeft += List->size();
    272271        }
     
    293292      for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    294293        for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    295           List = LC->GetCurrentCell();
     294          const LinkedNodes *List = LC->GetCurrentCell();
    296295//          *out << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
    297296          if (List != NULL) {
     
    300299//            else
    301300//              *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++) {
    303302              if ((current != PickedAtomNrs.end()) && (*current == index)) {
    304303                Candidate = (*Runner);
  • src/leastsquaremin.cpp

    rad37ab r776b64  
    1616 * \return sum of square distances
    1717 */
    18 double LSQ (const gsl_vector * x, void * params)
     18double LSQ (const gsl_vector * const x, void * params)
    1919{
    2020  double sum = 0.;
    2121  struct LSQ_params *par = (struct LSQ_params *)params;
    22   Vector **vectors = par->vectors;
     22  const Vector ** vectors = par->vectors;
    2323  int num = par->num;
    2424
  • src/leastsquaremin.hpp

    rad37ab r776b64  
    3131 */
    3232struct LSQ_params {
    33   Vector **vectors;
     33  const Vector **vectors;
    3434  int num;
    3535};
    3636
    37 double LSQ(const gsl_vector * x, void * params);
     37double LSQ(const gsl_vector * const x, void * params);
    3838
    3939/** Parameter structure for least square minimsation.
  • src/linkedcell.cpp

    rad37ab r776b64  
    3333 * \param RADIUS edge length of cells
    3434 */
    35 LinkedCell::LinkedCell(PointCloud *set, double radius)
     35LinkedCell::LinkedCell(const PointCloud * const set, const double radius)
    3636{
    3737  TesselPoint *Walker = NULL;
     
    109109 * \param RADIUS edge length of cells
    110110 */
    111 LinkedCell::LinkedCell(LinkedNodes *set, double radius)
     111LinkedCell::LinkedCell(LinkedNodes *set, const double radius)
    112112{
    113113  class TesselPoint *Walker = NULL;
     
    192192 * \return if all in intervals - true, else -false
    193193 */
    194 bool LinkedCell::CheckBounds()
     194bool LinkedCell::CheckBounds() const
    195195{
    196196  bool status = true;
     
    207207 * \return if all in intervals - true, else -false
    208208 */
    209 bool LinkedCell::CheckBounds(int relative[NDIM])
     209bool LinkedCell::CheckBounds(const int relative[NDIM]) const
    210210{
    211211  bool status = true;
     
    219219 * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[] are out of bounds.
    220220 */
    221 LinkedNodes* LinkedCell::GetCurrentCell()
     221const LinkedNodes* LinkedCell::GetCurrentCell() const
    222222{
    223223  if (CheckBounds()) {
     
    233233 * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[]+relative[] are out of bounds.
    234234 */
    235 LinkedNodes* LinkedCell::GetRelativeToCurrentCell(int relative[NDIM])
     235const LinkedNodes* LinkedCell::GetRelativeToCurrentCell(const int relative[NDIM]) const
    236236{
    237237  if (CheckBounds(relative)) {
     
    247247 * \return if the atom is also found in this cell - true, else - false
    248248 */
    249 bool LinkedCell::SetIndexToNode(const TesselPoint *Walker)
     249bool LinkedCell::SetIndexToNode(const TesselPoint * const Walker) const
    250250{
    251251  bool status = false;
     
    268268 * \param *upper upper bounds
    269269 */
    270 void LinkedCell::GetNeighbourBounds(int lower[NDIM], int upper[NDIM])
     270void LinkedCell::GetNeighbourBounds(int lower[NDIM], int upper[NDIM]) const
    271271{
    272272  for (int i=0;i<NDIM;i++) {
     
    288288 * \return Vector is inside bounding box - true, else - false
    289289 */
    290 bool LinkedCell::SetIndexToVector(const Vector *x)
     290bool LinkedCell::SetIndexToVector(const Vector * const x) const
    291291{
    292292  bool status = true;
  • src/linkedcell.hpp

    rad37ab r776b64  
    4646    double RADIUS;    // cell edge length
    4747    int N[NDIM];      // number of cells per axis
    48     int n[NDIM];      // temporary variable for current cell per axis
    49     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];
    5050
    5151    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);
    5454    ~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 ;
    6262
    6363    // not implemented yet
  • src/molecule.cpp

    rad37ab r776b64  
    5656  IndexNr  = -1;
    5757  ActiveFlag = false;
    58   TesselStruct = NULL;
    5958};
    6059
     
    6463molecule::~molecule()
    6564{
    66   if (TesselStruct != NULL)
    67     delete(TesselStruct);
    6865  CleanupMolecule();
    6966  delete(first);
  • src/molecule.hpp

    rad37ab r776b64  
    9999    char name[MAXSTRINGSIZE];         //!< arbitrary name
    100100    int IndexNr;        //!< index of molecule in a MoleculeListClass
    101     class Tesselation *TesselStruct;
    102101
    103102  molecule(periodentafel *teil);
     
    105104
    106105  // 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 ;
    116115
    117116  // templates for allowing global manipulation of all vectors
     
    217216  void Mirror(const Vector *x);
    218217  void Align(Vector *n);
    219   void Scale(double **factor);
     218  void Scale(const double ** const factor);
    220219  void DeterminePeriodicCenter(Vector &center);
    221220  Vector * DetermineCenterOfGravity(ofstream *out);
    222   Vector * DetermineCenterOfAll(ofstream *out);
     221  Vector * DetermineCenterOfAll(ofstream *out) const;
    223222  void SetNameFromFilename(const char *filename);
    224223  void SetBoxDimension(Vector *dim);
     
    298297  private:
    299298  int last_atom;      //!< number given to last atom
    300   atom *InternalPointer;  //!< internal pointer for PointCloud
     299  mutable atom *InternalPointer;  //!< internal pointer for PointCloud
    301300};
    302301
  • src/molecule_geometry.cpp

    rad37ab r776b64  
    122122 * \return pointer to center of all vector
    123123 */
    124 Vector * molecule::DetermineCenterOfAll(ofstream *out)
     124Vector * molecule::DetermineCenterOfAll(ofstream *out) const
    125125{
    126126  atom *ptr = start->next;  // start at first in list
     
    198198 * \param *factor pointer to scaling factor
    199199 */
    200 void molecule::Scale(double **factor)
     200void molecule::Scale(const double ** const factor)
    201201{
    202202  atom *ptr = start;
  • src/molecule_graph.cpp

    rad37ab r776b64  
    102102  double distance, MinDistance, MaxDistance;
    103103  LinkedCell *LC = NULL;
    104   LinkedNodes *List = NULL;
    105   LinkedNodes *OtherList = NULL;
    106104
    107105  BondDistance = bonddistance; // * ((IsAngstroem) ? 1. : 1./AtomicLengthToAngstroem);
     
    131129      for (LC->n[1] = 0; LC->n[1] < LC->N[1]; LC->n[1]++)
    132130        for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) {
    133           List = LC->GetCurrentCell();
     131          const LinkedNodes *List = LC->GetCurrentCell();
    134132          //*out << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
    135133          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++) {
    137135              Walker = AtomMap[(*Runner)->nr];
    138136              //*out << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
     
    141139                for (n[1] = -1; n[1] <= 1; n[1]++)
    142140                  for (n[2] = -1; n[2] <= 1; n[2]++) {
    143                     OtherList = LC->GetRelativeToCurrentCell(n);
     141                    const LinkedNodes *OtherList = LC->GetRelativeToCurrentCell(n);
    144142                    //*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;
    145143                    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++) {
    147145                        if ((*OtherRunner)->nr > Walker->nr) {
    148146                          OtherWalker = AtomMap[(*OtherRunner)->nr];
  • src/molecule_pointcloud.cpp

    rad37ab r776b64  
    1818 * \return pointer to allocated with central coordinates
    1919 */
    20 Vector *molecule::GetCenter(ofstream *out)
     20Vector *molecule::GetCenter(ofstream *out) const
    2121{
    2222  Vector *center = DetermineCenterOfAll(out);
     
    2727 * \return pointer to atom or NULL if none present
    2828 */
    29 TesselPoint *molecule::GetPoint()
     29TesselPoint *molecule::GetPoint() const
    3030{
    3131  if ((InternalPointer != start) && (InternalPointer != end))
     
    3838 * \return pointer to end marker
    3939 */
    40 TesselPoint *molecule::GetTerminalPoint()
     40TesselPoint *molecule::GetTerminalPoint() const
    4141{
    4242  return end;
     
    4646 * Stops at last one.
    4747 */
    48 void molecule::GoToNext()
     48void molecule::GoToNext() const
    4949{
    5050  if (InternalPointer != end)
     
    5555 * Stops at first one.
    5656 */
    57 void molecule::GoToPrevious()
     57void molecule::GoToPrevious() const
    5858{
    5959  if (InternalPointer->previous != start)
     
    6363/** Goes to first atom.
    6464 */
    65 void molecule::GoToFirst()
     65void molecule::GoToFirst() const
    6666{
    6767  InternalPointer = start->next;
     
    7070/** Goes to last atom.
    7171 */
    72 void molecule::GoToLast()
     72void molecule::GoToLast() const
    7373{
    7474  InternalPointer = end->previous;
     
    7878 * \return true - no atoms, false - not empty
    7979 */
    80 bool molecule::IsEmpty()
     80bool molecule::IsEmpty() const
    8181{
    8282  return (start->next == end);
     
    8686 * \return true - current atom is last one, false - is not last one
    8787 */
    88 bool molecule::IsEnd()
     88bool molecule::IsEnd() const
    8989{
    9090  return (InternalPointer == end);
  • src/moleculelist.cpp

    rad37ab r776b64  
    306306bool MoleculeListClass::EmbedMerge(molecule *mol, molecule *srcmol)
    307307{
     308  LinkedCell *LCList = NULL;
     309  Tesselation *TesselStruct = NULL;
    308310  if ((srcmol == NULL) || (mol == NULL)) {
    309311    cout << Verbose(1) << "ERROR: Either fixed or variable molecule is given as NULL." << endl;
     
    312314
    313315  // calculate envelope for *mol
    314   LinkedCell *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) {
    317319    cout << Verbose(1) << "ERROR: Could not tesselate the fixed molecule." << endl;
    318320    return false;
    319321  }
    320322  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!
    322324
    323325  // prepare index list for bonds
     
    333335    Walker = Walker->next;
    334336    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)) {
    336338      CopyAtoms[Walker->nr] = new atom(Walker);
    337339      mol->AddAtom(CopyAtoms[Walker->nr]);
  • src/tesselation.cpp

    rad37ab r776b64  
    3131 * \param *Walker TesselPoint this boundary point represents
    3232 */
    33 BoundaryPointSet::BoundaryPointSet(TesselPoint *Walker)
     33BoundaryPointSet::BoundaryPointSet(TesselPoint * Walker)
    3434{
    3535  node = Walker;
     
    7373 * \param &a boundary point
    7474 */
    75 ostream & operator <<(ostream &ost, BoundaryPointSet &a)
     75ostream & operator <<(ostream &ost, const BoundaryPointSet &a)
    7676{
    7777  ost << "[" << a.Nr << "|" << a.node->Name << " at " << *a.node->node << "]";
     
    9696 * \param number number of the list
    9797 */
    98 BoundaryLineSet::BoundaryLineSet(class BoundaryPointSet *Point[2], int number)
     98BoundaryLineSet::BoundaryLineSet(class BoundaryPointSet *Point[2], const int number)
    9999{
    100100  // set number
     
    275275 * \param &a boundary line
    276276 */
    277 ostream & operator <<(ostream &ost, BoundaryLineSet &a)
     277ostream & operator <<(ostream &ost, const  BoundaryLineSet &a)
    278278{
    279279  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 << "]";
     
    532532 * \param &a boundary triangle
    533533 */
    534 ostream &operator <<(ostream &ost, BoundaryTriangleSet &a)
     534ostream &operator <<(ostream &ost, const BoundaryTriangleSet &a)
    535535{
    536536  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << ","
     
    642642 * Uses PointsOnBoundary and STL stuff.
    643643 */   
    644 Vector * Tesselation::GetCenter(ofstream *out)
     644Vector * Tesselation::GetCenter(ofstream *out) const
    645645{
    646646  Vector *Center = new Vector(0.,0.,0.);
     
    657657 * Uses PointsOnBoundary and STL stuff.
    658658 */   
    659 TesselPoint * Tesselation::GetPoint()
     659TesselPoint * Tesselation::GetPoint() const
    660660{
    661661  return (InternalPointer->second->node);
     
    665665 * Uses PointsOnBoundary and STL stuff.
    666666 */   
    667 TesselPoint * Tesselation::GetTerminalPoint()
    668 {
    669   PointMap::iterator Runner = PointsOnBoundary.end();
     667TesselPoint * Tesselation::GetTerminalPoint() const
     668{
     669  PointMap::const_iterator Runner = PointsOnBoundary.end();
    670670  Runner--;
    671671  return (Runner->second->node);
     
    675675 * Uses PointsOnBoundary and STL stuff.
    676676 */   
    677 void Tesselation::GoToNext()
     677void Tesselation::GoToNext() const
    678678{
    679679  if (InternalPointer != PointsOnBoundary.end())
     
    684684 * Uses PointsOnBoundary and STL stuff.
    685685 */   
    686 void Tesselation::GoToPrevious()
     686void Tesselation::GoToPrevious() const
    687687{
    688688  if (InternalPointer != PointsOnBoundary.begin())
     
    693693 * Uses PointsOnBoundary and STL stuff.
    694694 */   
    695 void Tesselation::GoToFirst()
     695void Tesselation::GoToFirst() const
    696696{
    697697  InternalPointer = PointsOnBoundary.begin();
     
    700700/** PointCloud implementation of GoToLast.
    701701 * Uses PointsOnBoundary and STL stuff.
    702  */   
    703 void Tesselation::GoToLast()
     702 */
     703void Tesselation::GoToLast() const
    704704{
    705705  InternalPointer = PointsOnBoundary.end();
     
    710710 * Uses PointsOnBoundary and STL stuff.
    711711 */   
    712 bool Tesselation::IsEmpty()
     712bool Tesselation::IsEmpty() const
    713713{
    714714  return (PointsOnBoundary.empty());
     
    718718 * Uses PointsOnBoundary and STL stuff.
    719719 */   
    720 bool Tesselation::IsEnd()
     720bool Tesselation::IsEnd() const
    721721{
    722722  return (InternalPointer == PointsOnBoundary.end());
     
    899899 * \param *cloud cluster of points
    900900 */
    901 void Tesselation::TesselateOnBoundary(ofstream *out, PointCloud *cloud)
     901void Tesselation::TesselateOnBoundary(ofstream *out, const PointCloud * const cloud)
    902902{
    903903  bool flag;
     
    10971097 * \return true - all straddling points insert, false - something went wrong
    10981098 */
    1099 bool Tesselation::InsertStraddlingPoints(ofstream *out, PointCloud *cloud, LinkedCell *LC)
     1099bool Tesselation::InsertStraddlingPoints(ofstream *out, const PointCloud *cloud, const LinkedCell *LC)
    11001100{
    11011101  Vector Intersection, Normal;
     
    12071207 * \return true - new point was added, false - point already present
    12081208 */
    1209 bool
    1210 Tesselation::AddBoundaryPoint(TesselPoint *Walker, int n)
     1209bool Tesselation::AddBoundaryPoint(TesselPoint * Walker, const int n)
    12111210{
    12121211  PointTestPair InsertUnique;
     
    12291228 * @param n index for this point in Tesselation::TPS array
    12301229 */
    1231 void
    1232 Tesselation::AddTesselationPoint(TesselPoint* Candidate, int n)
     1230void Tesselation::AddTesselationPoint(TesselPoint* Candidate, const int n)
    12331231{
    12341232  PointTestPair InsertUnique;
     
    12521250 * @param n index of Tesselation::BLS giving the line with both endpoints
    12531251 */
    1254 void Tesselation::AddTesselationLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n) {
     1252void Tesselation::AddTesselationLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n) {
    12551253  bool insertNewLine = true;
    12561254
     
    12901288 * @param n index of Tesselation::BLS giving the line with both endpoints
    12911289 */
    1292 void Tesselation::AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n)
     1290void Tesselation::AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n)
    12931291{
    12941292  cout << Verbose(4) << "Adding line [" << LinesOnBoundaryCount << "|" << *(a->node) << " and " << *(b->node) << "." << endl;
     
    13231321 * \param nr triangle number
    13241322 */
    1325 void Tesselation::AddTesselationTriangle(int nr)
     1323void Tesselation::AddTesselationTriangle(const int nr)
    13261324{
    13271325  cout << Verbose(1) << "Adding triangle to global TrianglesOnBoundary map." << endl;
     
    15541552 * \param *LC LinkedCell structure with neighbouring TesselPoint's
    15551553 */
    1556 void Tesselation::FindStartingTriangle(ofstream *out, const double RADIUS, LinkedCell *LC)
     1554void Tesselation::FindStartingTriangle(ofstream *out, const double RADIUS, const LinkedCell *LC)
    15571555{
    15581556  cout << Verbose(1) << "Begin of FindStartingTriangle\n";
    15591557  int i = 0;
    1560   LinkedNodes *List = NULL;
    15611558  TesselPoint* FirstPoint = NULL;
    15621559  TesselPoint* SecondPoint = NULL;
     
    15801577    for (LC->n[(i+1)%NDIM]=0;LC->n[(i+1)%NDIM]<LC->N[(i+1)%NDIM];LC->n[(i+1)%NDIM]++)
    15811578      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();
    15831580        //cout << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    15841581        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++) {
    15861583            if ((*Runner)->node->x[i] > maxCoordinate[i]) {
    15871584              cout << Verbose(2) << "New maximal for axis " << i << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl;
     
    16451642
    16461643    //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);
    16501645    cout << Verbose(1) << "List of third Points is ";
    16511646    for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
     
    17131708 * @param *LC LinkedCell structure with neighbouring points
    17141709 */
    1715 bool Tesselation::FindNextSuitableTriangle(ofstream *out, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, LinkedCell *LC)
     1710bool Tesselation::FindNextSuitableTriangle(ofstream *out, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC)
    17161711{
    17171712  cout << Verbose(0) << "Begin of FindNextSuitableTriangle\n";
     
    17741769
    17751770    // 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);
    17801772
    17811773  } else {
     
    18131805      AddTesselationPoint(BaseRay->endpoints[1]->node, 2);
    18141806
    1815       if (CheckLineCriteriaForDegeneratedTriangle(TPS)) {
     1807      if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet **)TPS)) {
    18161808        AddTesselationLine(TPS[0], TPS[1], 0);
    18171809        AddTesselationLine(TPS[0], TPS[2], 1);
     
    18421834        // 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)
    18431835        // 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)) {
    18451837          AddTesselationLine(TPS[0], TPS[1], 0);
    18461838          AddTesselationLine(TPS[0], TPS[2], 1);
     
    19491941};
    19501942
    1951 void Tesselation::PrintAllBoundaryPoints(ofstream *out)
     1943void Tesselation::PrintAllBoundaryPoints(ofstream *out) const
    19521944{
    19531945  // print all lines
    19541946  *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++)
    19561948    *out << Verbose(2) << *(PointRunner->second) << endl;
    19571949};
    19581950
    1959 void Tesselation::PrintAllBoundaryLines(ofstream *out)
     1951void Tesselation::PrintAllBoundaryLines(ofstream *out) const
    19601952{
    19611953  // print all lines
    19621954  *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++)
    19641956    *out << Verbose(2) << *(LineRunner->second) << endl;
    19651957};
    19661958
    1967 void Tesselation::PrintAllBoundaryTriangles(ofstream *out)
     1959void Tesselation::PrintAllBoundaryTriangles(ofstream *out) const
    19681960{
    19691961  // print all triangles
    19701962  *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++)
    19721964    *out << Verbose(2) << *(TriangleRunner->second) << endl;
    19731965};
     
    21652157 * \param *LC LinkedCell structure with neighbouring points
    21662158 */
    2167 void Tesselation::FindSecondPointForTesselation(TesselPoint* a, Vector Oben, TesselPoint*& OptCandidate, double Storage[3], double RADIUS, LinkedCell *LC)
     2159void Tesselation::FindSecondPointForTesselation(TesselPoint* a, Vector Oben, TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC)
    21682160{
    21692161  cout << Verbose(2) << "Begin of FindSecondPointForTesselation" << endl;
    21702162  Vector AngleCheck;
    21712163  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];
    21752169
    21762170  if (LC->SetIndexToNode(a)) {  // get cell for the starting point
     
    21982192    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    21992193      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    2200         List = LC->GetCurrentCell();
     2194        const LinkedNodes *List = LC->GetCurrentCell();
    22012195        //cout << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    22022196        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++) {
    22042198            Candidate = (*Runner);
    22052199            // check if we only have one unique point yet ...
     
    22852279 * @param *LC LinkedCell structure with neighbouring points
    22862280 */
    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)
     2281void Tesselation::FindThirdPointForTesselation(Vector NormalVector, Vector SearchDirection, Vector OldSphereCenter, class BoundaryLineSet *BaseLine, class TesselPoint  *ThirdNode, CandidateList* &candidates, double *ShortestAngle, const double RADIUS, const LinkedCell *LC)
    22882282{
    22892283  Vector CircleCenter;  // center of the circle, i.e. of the band of sphere's centers
     
    22942288  Vector NewNormalVector;   // normal vector of the Candidate's triangle
    22952289  Vector helper, OptCandidateCenter, OtherOptCandidateCenter;
    2296   LinkedNodes *List = NULL;
    22972290  double CircleRadius; // radius of this circle
    22982291  double radius;
     
    23572350        for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    23582351          for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    2359             List = LC->GetCurrentCell();
     2352            const LinkedNodes *List = LC->GetCurrentCell();
    23602353            //cout << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    23612354            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++) {
    23632356                Candidate = (*Runner);
    23642357
     
    24712464 * \return point which is shared or NULL if none
    24722465 */
    2473 class BoundaryPointSet *Tesselation::GetCommonEndpoint(class BoundaryLineSet * line1, class BoundaryLineSet * line2)
    2474 {
    2475   class BoundaryLineSet * lines[2] =
    2476     { line1, line2 };
     2466class BoundaryPointSet *Tesselation::GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const
     2467{
     2468  const BoundaryLineSet * lines[2] = { line1, line2 };
    24772469  class BoundaryPointSet *node = NULL;
    24782470  map<int, class BoundaryPointSet *> OrderMap;
     
    25022494 * \return list of BoundaryTriangleSet of nearest triangles or NULL in degenerate case.
    25032495 */
    2504 list<BoundaryTriangleSet*> * Tesselation::FindClosestTrianglesToPoint(ofstream *out, Vector *x, LinkedCell* LC)
     2496list<BoundaryTriangleSet*> * Tesselation::FindClosestTrianglesToPoint(ofstream *out, const Vector *x, const LinkedCell* LC) const
    25052497{
    25062498  TesselPoint *trianglePoints[3];
     
    25222514  if (trianglePoints[0]->node->DistanceSquared(x) < MYEPSILON) {
    25232515    *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);
    25252517    triangles = new list<BoundaryTriangleSet*>;
    25262518    if (PointRunner != PointsOnBoundary.end()) {
     
    25782570 * \return list of BoundaryTriangleSet of nearest triangles or NULL.
    25792571 */
    2580 class BoundaryTriangleSet * Tesselation::FindClosestTriangleToPoint(ofstream *out, Vector *x, LinkedCell* LC)
     2572class BoundaryTriangleSet * Tesselation::FindClosestTriangleToPoint(ofstream *out, const Vector *x, const LinkedCell* LC) const
    25812573{
    25822574  class BoundaryTriangleSet *result = NULL;
     
    26142606 * @return true if the point is inside the tesselation structure, false otherwise
    26152607 */
    2616 bool Tesselation::IsInnerPoint(ofstream *out, Vector Point, LinkedCell* LC)
     2608bool Tesselation::IsInnerPoint(ofstream *out, const Vector &Point, const LinkedCell* const LC) const
    26172609{
    26182610  class BoundaryTriangleSet *result = FindClosestTriangleToPoint(out, &Point, LC);
     
    26442636 * @return true if the point is inside the tesselation structure, false otherwise
    26452637 */
    2646 bool Tesselation::IsInnerPoint(ofstream *out, TesselPoint *Point, LinkedCell* LC)
     2638bool Tesselation::IsInnerPoint(ofstream *out, const TesselPoint * const Point, const LinkedCell* const LC) const
    26472639{
    26482640  return IsInnerPoint(out, *(Point->node), LC);
     
    26552647 * @return set of the all points linked to the provided one
    26562648 */
    2657 set<TesselPoint*> * Tesselation::GetAllConnectedPoints(ofstream *out, TesselPoint* Point)
     2649set<TesselPoint*> * Tesselation::GetAllConnectedPoints(ofstream *out, const TesselPoint* const Point) const
    26582650{
    26592651  set<TesselPoint*> *connectedPoints = new set<TesselPoint*>;
     
    26652657
    26662658  // find the respective boundary point
    2667   PointMap::iterator PointRunner = PointsOnBoundary.find(Point->nr);
     2659  PointMap::const_iterator PointRunner = PointsOnBoundary.find(Point->nr);
    26682660  if (PointRunner != PointsOnBoundary.end()) {
    26692661    ReferencePoint = PointRunner->second;
     
    26752667  // little trick so that we look just through lines connect to the BoundaryPoint
    26762668  // OR fall-back to look through all lines if there is no such BoundaryPoint
    2677   LineMap *Lines = &LinesOnBoundary;
     2669  const LineMap *Lines;;
    26782670  if (ReferencePoint != NULL)
    26792671    Lines = &(ReferencePoint->lines);
    2680   LineMap::iterator findLines = Lines->begin();
     2672  else
     2673    Lines = &LinesOnBoundary;
     2674  LineMap::const_iterator findLines = Lines->begin();
    26812675  while (findLines != Lines->end()) {
    26822676   takePoint = false;
     
    27192713 * @return list of the all points linked to the provided one
    27202714 */
    2721 list<TesselPoint*> * Tesselation::GetCircleOfConnectedPoints(ofstream *out, TesselPoint* Point, Vector *Reference)
     2715list<TesselPoint*> * Tesselation::GetCircleOfConnectedPoints(ofstream *out, const TesselPoint* const Point, const Vector * const Reference) const
    27222716{
    27232717  map<double, TesselPoint*> anglesOfPoints;
     
    27332727
    27342728  // 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++)
    27362730    center.AddVector((*TesselRunner)->node);
    27372731  //*out << "Summed vectors " << center << "; number of points " << connectedPoints.size()
     
    27962790 * @return list of the all points linked to the provided one
    27972791 */
    2798 list<list<TesselPoint*> *> * Tesselation::GetPathsOfConnectedPoints(ofstream *out, TesselPoint* Point)
     2792list<list<TesselPoint*> *> * Tesselation::GetPathsOfConnectedPoints(ofstream *out, const TesselPoint* const Point) const
    27992793{
    28002794  map<double, TesselPoint*> anglesOfPoints;
     
    28132807
    28142808  // find the respective boundary point
    2815   PointMap::iterator PointRunner = PointsOnBoundary.find(Point->nr);
     2809  PointMap::const_iterator PointRunner = PointsOnBoundary.find(Point->nr);
    28162810  if (PointRunner != PointsOnBoundary.end()) {
    28172811    ReferencePoint = PointRunner->second;
     
    29112905 * @return list of the closed paths
    29122906 */
    2913 list<list<TesselPoint*> *> * Tesselation::GetClosedPathsOfConnectedPoints(ofstream *out, TesselPoint* Point)
     2907list<list<TesselPoint*> *> * Tesselation::GetClosedPathsOfConnectedPoints(ofstream *out, const TesselPoint* const Point) const
    29142908{
    29152909  list<list<TesselPoint*> *> *ListofPaths = GetPathsOfConnectedPoints(out, Point);
     
    29722966 * \return pointer to allocated list of triangles
    29732967 */
    2974 set<BoundaryTriangleSet*> *Tesselation::GetAllTriangles(ofstream *out, class BoundaryPointSet *Point)
     2968set<BoundaryTriangleSet*> *Tesselation::GetAllTriangles(ofstream *out, const BoundaryPointSet * const Point) const
    29752969{
    29762970  set<BoundaryTriangleSet*> *connectedTriangles = new set<BoundaryTriangleSet*>;
     
    29802974  } else {
    29812975    // 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++)
    29832977      for (TriangleMap::iterator TriangleRunner = (LineRunner->second)->triangles.begin(); TriangleRunner != (LineRunner->second)->triangles.end(); TriangleRunner++) {
    29842978      connectedTriangles->insert(TriangleRunner->second);
     
    32243218 *         will usually be one, in case of degeneration, there will be two
    32253219 */
    3226 list<BoundaryTriangleSet*> *Tesselation::FindTriangles(TesselPoint* Points[3])
     3220list<BoundaryTriangleSet*> *Tesselation::FindTriangles(const TesselPoint* const Points[3]) const
    32273221{
    32283222  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;
    32323225  class BoundaryPointSet *TrianglePoints[3];
    32333226
    32343227  for (int i = 0; i < 3; i++) {
    3235     FindPoint = PointsOnBoundary.find(Points[i]->nr);
     3228    PointMap::const_iterator FindPoint = PointsOnBoundary.find(Points[i]->nr);
    32363229    if (FindPoint != PointsOnBoundary.end()) {
    32373230      TrianglePoints[i] = FindPoint->second;
     
    35443537 * \param *cloud PointCloud structure with all nodes
    35453538 */
    3546 void Tesselation::Output(ofstream *out, const char *filename, PointCloud *cloud)
     3539void Tesselation::Output(ofstream *out, const char *filename, const PointCloud * const cloud)
    35473540{
    35483541  ofstream *tempstream = NULL;
  • src/tesselation.hpp

    rad37ab r776b64  
    8383  public:
    8484    BoundaryPointSet();
    85     BoundaryPointSet(TesselPoint *Walker);
     85    BoundaryPointSet(TesselPoint * Walker);
    8686    ~BoundaryPointSet();
    8787
     
    9595};
    9696
    97 ostream & operator << (ostream &ost, BoundaryPointSet &a);
     97ostream & operator << (ostream &ost, const BoundaryPointSet &a);
    9898
    9999// ======================================================== class BoundaryLineSet ==========================================
     
    102102  public:
    103103    BoundaryLineSet();
    104     BoundaryLineSet(class BoundaryPointSet *Point[2], int number);
     104    BoundaryLineSet(class BoundaryPointSet *Point[2], const int number);
    105105    ~BoundaryLineSet();
    106106
     
    116116};
    117117
    118 ostream & operator << (ostream &ost, BoundaryLineSet &a);
     118ostream & operator << (ostream &ost, const BoundaryLineSet &a);
    119119
    120120// ======================================================== class BoundaryTriangleSet =======================================
     
    142142};
    143143
    144 ostream & operator << (ostream &ost, BoundaryTriangleSet &a);
     144ostream & operator << (ostream &ost, const BoundaryTriangleSet &a);
    145145
    146146// =========================================================== class TESSELPOINT ===========================================
     
    170170  virtual ~PointCloud();
    171171
    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; };
    181181};
    182182
     
    204204    virtual ~Tesselation();
    205205
    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);
    209209    void AddTesselationTriangle();
    210     void AddTesselationTriangle(int nr);
     210    void AddTesselationTriangle(const int nr);
    211211    void RemoveTesselationTriangle(class BoundaryTriangleSet *triangle);
    212212    void RemoveTesselationLine(class BoundaryLineSet *line);
    213213    void RemoveTesselationPoint(class BoundaryPointSet *point);
    214214
    215     class BoundaryPointSet *GetCommonEndpoint(class BoundaryLineSet * line1, class BoundaryLineSet * line2);
    216215
    217216    // concave envelope
    218     void FindStartingTriangle(ofstream *out, const double RADIUS, class LinkedCell *LC);
    219     void FindSecondPointForTesselation(class TesselPoint* a, Vector Oben, class TesselPoint*& OptCandidate, double Storage[3], double RADIUS, class LinkedCell *LC);
    220     void FindThirdPointForTesselation(Vector NormalVector, Vector SearchDirection, Vector OldSphereCenter, class BoundaryLineSet *BaseLine, class TesselPoint *ThirdNode, CandidateList* &candidates, double *ShortestAngle, const double RADIUS, class LinkedCell *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);
    222221    int CheckPresenceOfTriangle(ofstream *out, class TesselPoint *Candidates[3]);
    223222    class BoundaryTriangleSet * GetPresentTriangle(ofstream *out, TesselPoint *Candidates[3]);
    224223
    225224    // convex envelope
    226     void TesselateOnBoundary(ofstream *out, PointCloud *cloud);
     225    void TesselateOnBoundary(ofstream *out, const PointCloud * const cloud);
    227226    void GuessStartingTriangle(ofstream *out);
    228     bool InsertStraddlingPoints(ofstream *out, PointCloud *cloud, LinkedCell *LC);
     227    bool InsertStraddlingPoints(ofstream *out, const PointCloud *cloud, const LinkedCell *LC);
    229228    double RemovePointFromTesselatedSurface(ofstream *out, class BoundaryPointSet *point);
    230229    class BoundaryLineSet * FlipBaseline(ofstream *out, class BoundaryLineSet *Base);
     
    236235    void AddBoundaryPointByDegeneratedTriangle(ofstream *out, class TesselPoint *point, LinkedCell *LC);
    237236
    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);
    249249
    250250    // 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;
    254254
    255255    // 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);
    257257
    258258    PointMap PointsOnBoundary;
     
    264264
    265265    // 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;
    275275
    276276    class BoundaryPointSet *BPS[2];
     
    283283    class BoundaryPointSet *TPS[3]; //this is a Storage for pointers to triangle points, this and BPS[2] needed due to AddLine restrictions
    284284
    285     PointMap::iterator InternalPointer;
     285    mutable PointMap::const_iterator InternalPointer;
    286286};
    287287
  • src/tesselationhelpers.cpp

    rad37ab r776b64  
    452452 * \return true - there is such a line (i.e. creation of degenerated triangle is valid), false - no such line (don't create)
    453453 */
    454 bool CheckLineCriteriaForDegeneratedTriangle(class BoundaryPointSet *nodes[3])
     454bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet *nodes[3])
    455455{
    456456  bool result = false;
     
    461461    for (int j=i+1; j<3; j++) {
    462462      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;
    465465        FindPair = nodes[i]->lines.equal_range(nodes[j]->node->nr);
    466466        for (FindLine = FindPair.first; FindLine != FindPair.second; ++FindLine) {
     
    486486/** Sort function for the candidate list.
    487487 */
    488 bool SortCandidates(CandidateForTesselation* candidate1, CandidateForTesselation* candidate2)
     488bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation* candidate2)
    489489{
    490490  Vector BaseLineVector, OrthogonalVector, helper;
     
    538538TesselPoint* FindSecondClosestPoint(const Vector* Point, LinkedCell* LC)
    539539{
    540   LinkedNodes *List = NULL;
    541540  TesselPoint* closestPoint = NULL;
    542541  TesselPoint* secondClosestPoint = NULL;
     
    556555    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    557556      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    558         List = LC->GetCurrentCell();
     557        const LinkedNodes *List = LC->GetCurrentCell();
    559558        //cout << Verbose(3) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
    560559        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++) {
    562561            helper.CopyVector(Point);
    563562            helper.SubtractVector((*Runner)->node);
     
    591590 * @return point which is closest to the provided one, NULL if none found
    592591 */
    593 TesselPoint* FindClosestPoint(const Vector* Point, TesselPoint *&SecondPoint, LinkedCell* LC)
    594 {
    595   LinkedNodes *List = NULL;
     592TesselPoint* FindClosestPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC)
     593{
    596594  TesselPoint* closestPoint = NULL;
    597595  SecondPoint = NULL;
     
    611609    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    612610      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    613         List = LC->GetCurrentCell();
     611        const LinkedNodes *List = LC->GetCurrentCell();
    614612        //cout << Verbose(3) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
    615613        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++) {
    617615            helper.CopyVector(Point);
    618616            helper.SubtractVector((*Runner)->node);
     
    651649 * \return Vector on reference line that has closest distance
    652650 */
    653 Vector * GetClosestPointBetweenLine(ofstream *out, class BoundaryLineSet *Base, class BoundaryLineSet *OtherBase)
     651Vector * GetClosestPointBetweenLine(ofstream *out, const BoundaryLineSet *Base, const BoundaryLineSet *OtherBase)
    654652{
    655653  // construct the plane of the two baselines (i.e. take both their directional vectors)
     
    691689 * \return distance between \a *x and plane defined by \a *triangle, -1 - if something went wrong
    692690 */
    693 double DistanceToTrianglePlane(ofstream *out, Vector *x, BoundaryTriangleSet *triangle)
     691double DistanceToTrianglePlane(ofstream *out, const Vector *x, const BoundaryTriangleSet *triangle)
    694692{
    695693  double distance = 0.;
     
    707705 * \param *mol molecule structure with atom positions
    708706 */
    709 void WriteVrmlFile(ofstream *out, ofstream *vrmlfile, class Tesselation *Tess, PointCloud *cloud)
     707void WriteVrmlFile(ofstream *out, ofstream *vrmlfile, const Tesselation *Tess, const PointCloud *cloud)
    710708{
    711709  TesselPoint *Walker = NULL;
     
    728726
    729727    *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++) {
    731729      *vrmlfile << "1" << endl << "  "; // 1 is triangle type
    732730      for (i=0;i<3;i++) { // print each node
     
    750748 * \param *mol molecule structure with atom positions
    751749 */
    752 void IncludeSphereinRaster3D(ofstream *out, ofstream *rasterfile, class Tesselation *Tess, PointCloud *cloud)
     750void IncludeSphereinRaster3D(ofstream *out, ofstream *rasterfile, const Tesselation *Tess, const PointCloud *cloud)
    753751{
    754752  Vector helper;
     
    775773 * \param *mol molecule structure with atom positions
    776774 */
    777 void WriteRaster3dFile(ofstream *out, ofstream *rasterfile, class Tesselation *Tess, PointCloud *cloud)
     775void WriteRaster3dFile(ofstream *out, ofstream *rasterfile, const Tesselation *Tess, const PointCloud *cloud)
    778776{
    779777  TesselPoint *Walker = NULL;
     
    797795    *rasterfile << "# All tesselation triangles" << endl;
    798796    *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++) {
    800798      *rasterfile << "1" << endl << "  ";  // 1 is triangle type
    801799      for (i=0;i<3;i++) {  // print each node
     
    820818 * \param N arbitrary number to differentiate various zones in the tecplot format
    821819 */
    822 void WriteTecplotFile(ofstream *out, ofstream *tecplot, class Tesselation *TesselStruct, PointCloud *cloud, int N)
     820void WriteTecplotFile(ofstream *out, ofstream *tecplot, const Tesselation *TesselStruct, const PointCloud *cloud, const int N)
    823821{
    824822  if ((tecplot != NULL) && (TesselStruct != NULL)) {
     
    840838    int Counter = 1;
    841839    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++) {
    843841      Walker = target->second->node;
    844842      LookupList[Walker->nr] = Counter++;
     
    847845    *tecplot << endl;
    848846    // 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++) {
    850848      *out << " " << runner->second->endpoints[0]->node->Name << "<->" << runner->second->endpoints[1]->node->Name << "<->" << runner->second->endpoints[2]->node->Name;
    851849      *tecplot << LookupList[runner->second->endpoints[0]->node->nr] << " " << LookupList[runner->second->endpoints[1]->node->nr] << " " << LookupList[runner->second->endpoints[2]->node->nr] << endl;
     
    861859 * \param *TesselStruct pointer to Tesselation structure
    862860 */
    863 void CalculateConcavityPerBoundaryPoint(ofstream *out, class Tesselation *TesselStruct)
     861void CalculateConcavityPerBoundaryPoint(ofstream *out, const Tesselation *TesselStruct)
    864862{
    865863  class BoundaryPointSet *point = NULL;
     
    868866  //*out << Verbose(2) << "Begin of CalculateConcavityPerBoundaryPoint" << endl;
    869867  // 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++) {
    871869    point = PointRunner->second;
    872870    *out << Verbose(1) << "INFO: Current point is " << *point << "." << endl;
     
    888886 * \return true - all have exactly two triangles, false - some not, list is printed to screen
    889887 */
    890 bool CheckListOfBaselines(ofstream *out, Tesselation *TesselStruct)
    891 {
    892   LineMap::iterator testline;
     888bool CheckListOfBaselines(ofstream *out, const Tesselation *TesselStruct)
     889{
     890  LineMap::const_iterator testline;
    893891  bool result = false;
    894892  int counter = 0;
  • src/tesselationhelpers.hpp

    rad37ab r776b64  
    5757double GetAngle(const Vector &point, const Vector &reference, const Vector OrthogonalVector);
    5858
    59 bool CheckLineCriteriaForDegeneratedTriangle(class BoundaryPointSet *nodes[3]);
    60 bool SortCandidates(class CandidateForTesselation* candidate1, class CandidateForTesselation* candidate2);
    61 TesselPoint* FindClosestPoint(const Vector* Point, TesselPoint *&SecondPoint, LinkedCell* LC);
    62 TesselPoint* FindSecondClosestPoint(const Vector*, LinkedCell*);
    63 Vector * GetClosestPointBetweenLine(ofstream *out, class BoundaryLineSet *Base, class BoundaryLineSet *OtherBase);
     59bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet *nodes[3]);
     60bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation* candidate2);
     61TesselPoint* FindClosestPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC);
     62TesselPoint* FindSecondClosestPoint(const Vector*, const LinkedCell*);
     63Vector * GetClosestPointBetweenLine(ofstream *out, const BoundaryLineSet *Base, const BoundaryLineSet *OtherBase);
    6464
    65 void WriteTecplotFile(ofstream *out, ofstream *tecplot, class Tesselation *TesselStruct, PointCloud *cloud, int N);
    66 void WriteRaster3dFile(ofstream *out, ofstream *rasterfile, class Tesselation *Tess, PointCloud *cloud);
    67 void IncludeSphereinRaster3D(ofstream *out, ofstream *rasterfile, class Tesselation *Tess, PointCloud *cloud);
    68 void WriteVrmlFile(ofstream *out, ofstream *vrmlfile, class Tesselation *Tess, PointCloud *cloud);
    69 void CalculateConcavityPerBoundaryPoint(ofstream *out, class Tesselation *TesselStruct);
    70 double DistanceToTrianglePlane(ofstream *out, Vector *x, BoundaryTriangleSet *triangle);
     65void WriteTecplotFile(ofstream *out, ofstream *tecplot, const Tesselation *TesselStruct, const PointCloud *cloud, const int N);
     66void WriteRaster3dFile(ofstream *out, ofstream *rasterfile, const Tesselation *Tess, const PointCloud *cloud);
     67void IncludeSphereinRaster3D(ofstream *out, ofstream *rasterfile, const Tesselation *Tess, const PointCloud *cloud);
     68void WriteVrmlFile(ofstream *out, ofstream *vrmlfile, const Tesselation *Tess, const PointCloud *cloud);
     69void CalculateConcavityPerBoundaryPoint(ofstream *out, const Tesselation *TesselStruct);
     70double DistanceToTrianglePlane(ofstream *out, const Vector *x, const BoundaryTriangleSet *triangle);
    7171
    72 bool CheckListOfBaselines(ofstream *out, Tesselation *TesselStruct);
     72bool CheckListOfBaselines(ofstream *out, const Tesselation *TesselStruct);
    7373
    7474
  • src/unittests/ActOnAllUnitTest.cpp

    rad37ab r776b64  
    6262
    6363  // scaling by value
    64   VL.ActOnAll( (void (Vector::*)(double)) &Vector::Scale, 2. );
     64  VL.ActOnAll( (void (Vector::*)(const double)) &Vector::Scale, 2. );
    6565  CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
    6666
    67   VL.ActOnAll( (void (Vector::*)(double)) &Vector::Scale, 0.5 );
     67  VL.ActOnAll( (void (Vector::*)(const double)) &Vector::Scale, 0.5 );
    6868  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
    6969
    7070  // 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 );
    7272  CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
    7373
    74   VL.ActOnAll( (void (Vector::*)(double *)) &Vector::Scale, &inverse );
     74  VL.ActOnAll( (void (Vector::*)(const double * const)) &Vector::Scale, (const double * const)&inverse );
    7575  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
    7676
     
    8282    inverses[i] = 1./factors[i];
    8383  }
    84   VL.ActOnAll( (void (Vector::*)(double **)) &Vector::Scale, &factors );
     84  VL.ActOnAll( (void (Vector::*)(const double ** const)) &Vector::Scale, (const double ** const)&factors );
    8585  CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
    8686
    87   VL.ActOnAll( (void (Vector::*)(double **)) &Vector::Scale, &inverses );
     87  VL.ActOnAll( (void (Vector::*)(const double ** const)) &Vector::Scale, (const double ** const)&inverses );
    8888  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
    8989};
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    rad37ab r776b64  
    7777
    7878  // 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 );
    8080  binmap = NULL;
    8181
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    rad37ab r776b64  
    8181  // init tesselation and linked cell
    8282  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);
    8584  LC = new LinkedCell(TestMolecule, 5.);
    8685  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
     
    123122  // remove
    124123  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
    126126  delete(LC);
    127127  delete(tafel);
  • src/vector.cpp

    rad37ab r776b64  
    2121/** Constructor of class vector.
    2222 */
    23 Vector::Vector(double x1, double x2, double x3) { x[0] = x1; x[1] = x2; x[2] = x3; };
     23Vector::Vector(const double x1, const double x2, const double x3) { x[0] = x1; x[1] = x2; x[2] = x3; };
    2424
    2525/** Desctructor of class vector.
     
    3131 * \return \f$| x - y |^2\f$
    3232 */
    33 double Vector::DistanceSquared(const Vector *y) const
     33double Vector::DistanceSquared(const Vector * const y) const
    3434{
    3535  double res = 0.;
     
    4343 * \return \f$| x - y |\f$
    4444 */
    45 double Vector::Distance(const Vector *y) const
     45double Vector::Distance(const Vector * const y) const
    4646{
    4747  double res = 0.;
     
    5656 * \return \f$| x - y |\f$
    5757 */
    58 double Vector::PeriodicDistance(const Vector *y, const double *cell_size) const
     58double Vector::PeriodicDistance(const Vector * const y, const double * const cell_size) const
    5959{
    6060  double res = Distance(y), tmp, matrix[NDIM*NDIM];
     
    9494 * \return \f$| x - y |^2\f$
    9595 */
    96 double Vector::PeriodicDistanceSquared(const Vector *y, const double *cell_size) const
     96double Vector::PeriodicDistanceSquared(const Vector * const y, const double * const cell_size) const
    9797{
    9898  double res = DistanceSquared(y), tmp, matrix[NDIM*NDIM];
     
    131131 * Tries to translate a vector into each adjacent neighbouring cell.
    132132 */
    133 void Vector::KeepPeriodic(ofstream *out, double *matrix)
     133void Vector::KeepPeriodic(ofstream *out, const double * const matrix)
    134134{
    135135//  int N[NDIM];
     
    162162 * \return \f$\langle x, y \rangle\f$
    163163 */
    164 double Vector::ScalarProduct(const Vector *y) const
     164double Vector::ScalarProduct(const Vector * const y) const
    165165{
    166166  double res = 0.;
     
    177177 *  \return \f$ x \times y \f&
    178178 */
    179 void Vector::VectorProduct(const Vector *y)
     179void Vector::VectorProduct(const Vector * const y)
    180180{
    181181  Vector tmp;
     
    184184  tmp.x[2] = x[0]* (y->x[1]) - x[1]* (y->x[0]);
    185185  this->CopyVector(&tmp);
    186 
    187186};
    188187
     
    192191 * \return \f$\langle x, y \rangle\f$
    193192 */
    194 void Vector::ProjectOntoPlane(const Vector *y)
     193void Vector::ProjectOntoPlane(const Vector * const y)
    195194{
    196195  Vector tmp;
     
    217216 * \return true -  \a this contains intersection point on return, false - line is parallel to plane
    218217 */
    219 bool Vector::GetIntersectionWithPlane(ofstream *out, Vector *PlaneNormal, Vector *PlaneOffset, Vector *Origin, Vector *LineVector)
     218bool Vector::GetIntersectionWithPlane(ofstream *out, const Vector * const PlaneNormal, const Vector * const PlaneOffset, const Vector * const Origin, const Vector * const LineVector)
    220219{
    221220  double factor;
     
    264263 * \return distance to plane
    265264 */
    266 double Vector::DistanceToPlane(ofstream *out, Vector *PlaneNormal, Vector *PlaneOffset)
     265double Vector::DistanceToPlane(ofstream *out, const Vector * const PlaneNormal, const Vector * const PlaneOffset) const
    267266{
    268267  Vector temp;
     
    292291 * \return true - \a this will contain the intersection on return, false - lines are parallel
    293292 */
    294 bool Vector::GetIntersectionOfTwoLinesOnPlane(ofstream *out, Vector *Line1a, Vector *Line1b, Vector *Line2a, Vector *Line2b, const Vector *PlaneNormal)
     293bool Vector::GetIntersectionOfTwoLinesOnPlane(ofstream *out, const Vector * const Line1a, const Vector * const Line1b, const Vector * const Line2a, const Vector * const Line2b, const Vector *PlaneNormal)
    295294{
    296295  bool result = true;
     
    375374 * \param *y array to second vector
    376375 */
    377 void Vector::ProjectIt(const Vector *y)
     376void Vector::ProjectIt(const Vector * const y)
    378377{
    379378  Vector helper(*y);
     
    386385 * \return Vector
    387386 */
    388 Vector Vector::Projection(const Vector *y) const
     387Vector Vector::Projection(const Vector * const y) const
    389388{
    390389  Vector helper(*y);
     
    435434/** Zeros all components of this vector.
    436435 */
    437 void Vector::One(double one)
     436void Vector::One(const double one)
    438437{
    439438  for (int i=NDIM;i--;)
     
    443442/** Initialises all components of this vector.
    444443 */
    445 void Vector::Init(double x1, double x2, double x3)
     444void Vector::Init(const double x1, const double x2, const double x3)
    446445{
    447446  x[0] = x1;
     
    469468 * @return true - vector is normalized, false - vector is not
    470469 */
    471 bool Vector::IsNormalTo(const Vector *normal) const
     470bool Vector::IsNormalTo(const Vector * const normal) const
    472471{
    473472  if (ScalarProduct(normal) < MYEPSILON)
     
    481480 * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$
    482481 */
    483 double Vector::Angle(const Vector *y) const
     482double Vector::Angle(const Vector * const y) const
    484483{
    485484  double norm1 = Norm(), norm2 = y->Norm();
     
    500499 * \param alpha rotation angle in radian
    501500 */
    502 void Vector::RotateVector(const Vector *axis, const double alpha)
     501void Vector::RotateVector(const Vector * const axis, const double alpha)
    503502{
    504503  Vector a,y;
     
    656655 * \param *factor pointer to scaling factor
    657656 */
    658 void Vector::Scale(double **factor)
     657void Vector::Scale(const double ** const factor)
    659658{
    660659  for (int i=NDIM;i--;)
     
    662661};
    663662
    664 void Vector::Scale(double *factor)
     663void Vector::Scale(const double * const factor)
    665664{
    666665  for (int i=NDIM;i--;)
     
    668667};
    669668
    670 void Vector::Scale(double factor)
     669void Vector::Scale(const double factor)
    671670{
    672671  for (int i=NDIM;i--;)
     
    677676 * \param trans[] translation vector.
    678677 */
    679 void Vector::Translate(const Vector *trans)
     678void Vector::Translate(const Vector * const trans)
    680679{
    681680  for (int i=NDIM;i--;)
     
    687686 * \param *Minv inverse matrix
    688687 */
    689 void Vector::WrapPeriodically(const double *M, const double *Minv)
     688void Vector::WrapPeriodically(const double * const M, const double * const Minv)
    690689{
    691690  MatrixMultiplication(Minv);
     
    704703 * \param *matrix NDIM_NDIM array
    705704 */
    706 void Vector::MatrixMultiplication(const double *M)
     705void Vector::MatrixMultiplication(const double * const M)
    707706{
    708707  Vector C;
     
    719718 * \param *matrix NDIM_NDIM array
    720719 */
    721 double * Vector::InverseMatrix(double *A)
     720double * Vector::InverseMatrix( const double * const A)
    722721{
    723722  double *B = Malloc<double>(NDIM * NDIM, "Vector::InverseMatrix: *B");
     
    746745 * \param *matrix NDIM_NDIM array
    747746 */
    748 void Vector::InverseMatrixMultiplication(const double *A)
     747void Vector::InverseMatrixMultiplication(const double * const A)
    749748{
    750749  Vector C;
     
    786785 * \param *factors three-component vector with the factor for each given vector
    787786 */
    788 void Vector::LinearCombinationOfVectors(const Vector *x1, const Vector *x2, const Vector *x3, double *factors)
     787void Vector::LinearCombinationOfVectors(const Vector * const x1, const Vector * const x2, const Vector * const x3, const double * const factors)
    789788{
    790789  for(int i=NDIM;i--;)
     
    795794 * \param n[] normal vector of mirror plane.
    796795 */
    797 void Vector::Mirror(const Vector *n)
     796void Vector::Mirror(const Vector * const n)
    798797{
    799798  double projection;
     
    817816 * \return true - success, vectors are linear independent, false - failure due to linear dependency
    818817 */
    819 bool Vector::MakeNormalVector(const Vector *y1, const Vector *y2, const Vector *y3)
     818bool Vector::MakeNormalVector(const Vector * const y1, const Vector * const y2, const Vector * const y3)
    820819{
    821820  Vector x1, x2;
     
    853852 * \return true - success, vectors are linear independent, false - failure due to linear dependency
    854853 */
    855 bool Vector::MakeNormalVector(const Vector *y1, const Vector *y2)
     854bool Vector::MakeNormalVector(const Vector * const y1, const Vector * const y2)
    856855{
    857856  Vector x1,x2;
     
    884883 * \return true - success, false - vector is zero
    885884 */
    886 bool Vector::MakeNormalVector(const Vector *y1)
     885bool Vector::MakeNormalVector(const Vector * const y1)
    887886{
    888887  bool result = false;
     
    904903 * \return true - success, false - failure (null vector given)
    905904 */
    906 bool Vector::GetOneNormalVector(const Vector *GivenVector)
     905bool Vector::GetOneNormalVector(const Vector * const GivenVector)
    907906{
    908907  int Components[NDIM]; // contains indices of non-zero components
     
    950949 * \return scaling parameter for this vector
    951950 */
    952 double Vector::CutsPlaneAt(Vector *A, Vector *B, Vector *C)
     951double Vector::CutsPlaneAt(const Vector * const A, const Vector * const B, const Vector * const C) const
    953952{
    954953//  cout << Verbose(3) << "For comparison: ";
     
    965964 * \return true if success, false if failed due to linear dependency
    966965 */
    967 bool Vector::LSQdistance(Vector **vectors, int num)
     966bool Vector::LSQdistance(const Vector **vectors, int num)
    968967{
    969968  int j;
     
    10471046 * \param *y vector
    10481047 */
    1049 void Vector::AddVector(const Vector *y)
     1048void Vector::AddVector(const Vector * const y)
    10501049{
    10511050  for (int i=NDIM;i--;)
     
    10561055 * \param *y vector
    10571056 */
    1058 void Vector::SubtractVector(const Vector *y)
     1057void Vector::SubtractVector(const Vector * const y)
    10591058{
    10601059  for (int i=NDIM;i--;)
     
    10651064 * \param *y vector
    10661065 */
    1067 void Vector::CopyVector(const Vector *y)
     1066void Vector::CopyVector(const Vector * const y)
    10681067{
    10691068  for (int i=NDIM;i--;)
     
    10741073 * \param y vector
    10751074 */
    1076 void Vector::CopyVector(const Vector y)
     1075void Vector::CopyVector(const Vector &y)
    10771076{
    10781077  for (int i=NDIM;i--;)
     
    10851084 * \param check whether bounds shall be checked (true) or not (false)
    10861085 */
    1087 void Vector::AskPosition(double *cell_size, bool check)
     1086void Vector::AskPosition(const double * const cell_size, const bool check)
    10881087{
    10891088  char coords[3] = {'x','y','z'};
     
    11131112 * \bug this is not yet working properly
    11141113 */
    1115 bool Vector::SolveSystem(Vector *x1, Vector *x2, Vector *y, double alpha, double beta, double c)
     1114bool Vector::SolveSystem(Vector * x1, Vector * x2, Vector * y, const double alpha, const double beta, const double c)
    11161115{
    11171116  double D1,D2,D3,E1,E2,F1,F2,F3,p,q=0., A, B1, B2, C;
     
    12761275 * @param three vectors forming the matrix that defines the shape of the parallelpiped
    12771276 */
    1278 bool Vector::IsInParallelepiped(const Vector offset, const double *parallelepiped) const
     1277bool Vector::IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const
    12791278{
    12801279  Vector a;
  • src/vector.hpp

    rad37ab r776b64  
    3030  ~Vector();
    3131
    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;
    3838  double Norm() const;
    3939  double NormSquared() const;
    40   double Angle(const Vector *y) const;
     40  double Angle(const Vector * const y) const;
    4141  bool IsZero() const;
    4242  bool IsOne() const;
    43   bool IsNormalTo(const Vector *normal) const;
     43  bool IsNormalTo(const Vector * const normal) const;
    4444
    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;
    5454  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);
    5757  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);
    7878  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);
    8181};
    8282
Note: See TracChangeset for help on using the changeset viewer.