Changeset c0f6c6 for src


Ignore:
Timestamp:
Oct 27, 2009, 5:41:12 PM (15 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, 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:
d96277
Parents:
fb73b8
Message:

Refactored tesselationhelpers.cpp with respect to ticket #38 (make const what is const).
Signed-off-by: Frederik Heber <heber@…>

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/tesselation.cpp

    rfb73b8 rc0f6c6  
    17461746
    17471747    // construct old center
    1748     GetCenterofCircumcircle(&OldSphereCenter, T.endpoints[0]->node->node, T.endpoints[1]->node->node, T.endpoints[2]->node->node);
     1748    GetCenterofCircumcircle(&OldSphereCenter, *T.endpoints[0]->node->node, *T.endpoints[1]->node->node, *T.endpoints[2]->node->node);
    17491749    helper.CopyVector(&T.NormalVector);  // normal vector ensures that this is correct center of the two possible ones
    17501750    radius = Line.endpoints[0]->node->node->DistanceSquared(&OldSphereCenter);
     
    18051805      AddTesselationPoint(BaseRay->endpoints[1]->node, 2);
    18061806
    1807       if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet **)TPS)) {
     1807      if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const )TPS)) {
    18081808        AddTesselationLine(TPS[0], TPS[1], 0);
    18091809        AddTesselationLine(TPS[0], TPS[2], 1);
     
    18341834        // 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)
    18351835        // i.e. at least one of the three lines must be present with TriangleCount <= 1
    1836         if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet **)TPS)) {
     1836        if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const)TPS)) {
    18371837          AddTesselationLine(TPS[0], TPS[1], 0);
    18381838          AddTesselationLine(TPS[0], TPS[2], 1);
     
    19961996
    19971997  // calculate volume
    1998   volume = CalculateVolumeofGeneralTetraeder(Base->endpoints[1]->node->node, OtherBase->endpoints[0]->node->node, OtherBase->endpoints[1]->node->node, Base->endpoints[0]->node->node);
     1998  volume = CalculateVolumeofGeneralTetraeder(*Base->endpoints[1]->node->node, *OtherBase->endpoints[0]->node->node, *OtherBase->endpoints[1]->node->node, *Base->endpoints[0]->node->node);
    19991999
    20002000  // delete the temporary other base line and the closest points
     
    23612361
    23622362                  // construct both new centers
    2363                   GetCenterofCircumcircle(&NewSphereCenter, BaseLine->endpoints[0]->node->node, BaseLine->endpoints[1]->node->node, Candidate->node);
     2363                  GetCenterofCircumcircle(&NewSphereCenter, *BaseLine->endpoints[0]->node->node, *BaseLine->endpoints[1]->node->node, *Candidate->node);
    23642364                  OtherNewSphereCenter.CopyVector(&NewSphereCenter);
    23652365
     
    31383138        AddTesselationTriangle();
    31393139        // calculate volume summand as a general tetraeder
    3140         volume += CalculateVolumeofGeneralTetraeder(TPS[0]->node->node, TPS[1]->node->node, TPS[2]->node->node, &OldPoint);
     3140        volume += CalculateVolumeofGeneralTetraeder(*TPS[0]->node->node, *TPS[1]->node->node, *TPS[2]->node->node, OldPoint);
    31413141        // advance number
    31423142        count++;
  • src/tesselationhelpers.cpp

    rfb73b8 rc0f6c6  
    1414#include "verbose.hpp"
    1515
    16 double DetGet(gsl_matrix *A, int inPlace) {
     16double DetGet(gsl_matrix * const A, const int inPlace) {
    1717  /*
    1818  inPlace = 1 => A is replaced with the LU decomposed copy.
     
    4242};
    4343
    44 void GetSphere(Vector *center, Vector &a, Vector &b, Vector &c, double RADIUS)
     44void GetSphere(Vector * const center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS)
    4545{
    4646  gsl_matrix *A = gsl_matrix_calloc(3,3);
     
    9696 * @param b vector second point of triangle
    9797 * @param c vector third point of triangle
    98  * @param *Umkreismittelpunkt new cneter point of circumference
     98 * @param *Umkreismittelpunkt new center point of circumference
    9999 * @param Direction vector indicates up/down
    100  * @param AlternativeDirection vecotr, needed in case the triangles have 90 deg angle
     100 * @param AlternativeDirection Vector, needed in case the triangles have 90 deg angle
    101101 * @param Halfplaneindicator double indicates whether Direction is up or down
    102  * @param AlternativeIndicator doube indicates in case of orthogonal triangles which direction of AlternativeDirection is suitable
     102 * @param AlternativeIndicator double indicates in case of orthogonal triangles which direction of AlternativeDirection is suitable
    103103 * @param alpha double angle at a
    104104 * @param beta double, angle at b
     
    107107 * @param Umkreisradius double radius of circumscribing circle
    108108 */
    109 void GetCenterOfSphere(Vector* Center, Vector a, Vector b, Vector c, Vector *NewUmkreismittelpunkt, Vector* Direction, Vector* AlternativeDirection,
    110     double HalfplaneIndicator, double AlternativeIndicator, double alpha, double beta, double gamma, double RADIUS, double Umkreisradius)
     109void GetCenterOfSphere(Vector* const & Center, const Vector &a, const Vector &b, const Vector &c, Vector * const NewUmkreismittelpunkt, const Vector* const Direction, const Vector* const AlternativeDirection,
     110    const double HalfplaneIndicator, const double AlternativeIndicator, const double alpha, const double beta, const double gamma, const double RADIUS, const double Umkreisradius)
    111111{
    112112  Vector TempNormal, helper;
     
    171171 * \param *c third point
    172172 */
    173 void GetCenterofCircumcircle(Vector *Center, Vector *a, Vector *b, Vector *c)
     173void GetCenterofCircumcircle(Vector * const Center, const Vector &a, const Vector &b, const Vector &c)
    174174{
    175175  Vector helper;
     
    177177  Vector SideA, SideB, SideC;
    178178  SideA.CopyVector(b);
    179   SideA.SubtractVector(c);
     179  SideA.SubtractVector(&c);
    180180  SideB.CopyVector(c);
    181   SideB.SubtractVector(a);
     181  SideB.SubtractVector(&a);
    182182  SideC.CopyVector(a);
    183   SideC.SubtractVector(b);
     183  SideC.SubtractVector(&b);
    184184  alpha = M_PI - SideB.Angle(&SideC);
    185185  beta = M_PI - SideC.Angle(&SideA);
     
    215215 * \return Angle between \a NewSphereCenter and \a OldSphereCenter relative to \a CircleCenter, 2.*M_PI if one test fails
    216216 */
    217 double GetPathLengthonCircumCircle(Vector &CircleCenter, Vector &CirclePlaneNormal, double CircleRadius, Vector &NewSphereCenter, Vector &OldSphereCenter, Vector &NormalVector, Vector &SearchDirection)
     217double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection)
    218218{
    219219  Vector helper;
     
    300300 * @return true if there is an intersection between the given lines, false otherwise
    301301 */
    302 bool existsIntersection(Vector point1, Vector point2, Vector point3, Vector point4)
     302bool existsIntersection(const Vector &point1, const Vector &point2, const Vector &point3, const Vector &point4)
    303303{
    304304  bool result;
     
    403403 * @return angle between point and reference
    404404 */
    405 double GetAngle(const Vector &point, const Vector &reference, const Vector OrthogonalVector)
     405double GetAngle(const Vector &point, const Vector &reference, const Vector &OrthogonalVector)
    406406{
    407407  if (reference.IsZero())
     
    429429 * \return \f$ \frac{1}{6} \cdot ((a-d) \times (a-c) \cdot  (a-b)) \f$
    430430 */
    431 double CalculateVolumeofGeneralTetraeder(Vector *a, Vector *b, Vector *c, Vector *d)
     431double CalculateVolumeofGeneralTetraeder(const Vector &a, const Vector &b, const Vector &c, const Vector &d)
    432432{
    433433  Vector Point, TetraederVector[3];
     
    438438  TetraederVector[2].CopyVector(c);
    439439  for (int j=0;j<3;j++)
    440     TetraederVector[j].SubtractVector(d);
     440    TetraederVector[j].SubtractVector(&d);
    441441  Point.CopyVector(&TetraederVector[0]);
    442442  Point.VectorProduct(&TetraederVector[1]);
     
    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(const BoundaryPointSet *nodes[3])
     454bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet * const nodes[3])
    455455{
    456456  bool result = false;
     
    536536 * @return point which is second closest to the provided one
    537537 */
    538 TesselPoint* FindSecondClosestPoint(const Vector* Point, LinkedCell* LC)
     538TesselPoint* FindSecondClosestPoint(const Vector* Point, const LinkedCell* const LC)
    539539{
    540540  TesselPoint* closestPoint = NULL;
     
    649649 * \return Vector on reference line that has closest distance
    650650 */
    651 Vector * GetClosestPointBetweenLine(ofstream *out, const BoundaryLineSet *Base, const BoundaryLineSet *OtherBase)
     651Vector * GetClosestPointBetweenLine(ofstream *out, const BoundaryLineSet * const Base, const BoundaryLineSet * const OtherBase)
    652652{
    653653  // construct the plane of the two baselines (i.e. take both their directional vectors)
     
    689689 * \return distance between \a *x and plane defined by \a *triangle, -1 - if something went wrong
    690690 */
    691 double DistanceToTrianglePlane(ofstream *out, const Vector *x, const BoundaryTriangleSet *triangle)
     691double DistanceToTrianglePlane(ofstream * const out, const Vector *x, const BoundaryTriangleSet * const triangle)
    692692{
    693693  double distance = 0.;
     
    705705 * \param *mol molecule structure with atom positions
    706706 */
    707 void WriteVrmlFile(ofstream *out, ofstream *vrmlfile, const Tesselation *Tess, const PointCloud *cloud)
     707void WriteVrmlFile(ofstream * const out, ofstream * const vrmlfile, const Tesselation * const Tess, const PointCloud * const cloud)
    708708{
    709709  TesselPoint *Walker = NULL;
     
    748748 * \param *mol molecule structure with atom positions
    749749 */
    750 void IncludeSphereinRaster3D(ofstream *out, ofstream *rasterfile, const Tesselation *Tess, const PointCloud *cloud)
     750void IncludeSphereinRaster3D(ofstream * const out, ofstream * const rasterfile, const Tesselation * const Tess, const PointCloud * const cloud)
    751751{
    752752  Vector helper;
     
    773773 * \param *mol molecule structure with atom positions
    774774 */
    775 void WriteRaster3dFile(ofstream *out, ofstream *rasterfile, const Tesselation *Tess, const PointCloud *cloud)
     775void WriteRaster3dFile(ofstream * const out, ofstream * const rasterfile, const Tesselation * const Tess, const PointCloud * const cloud)
    776776{
    777777  TesselPoint *Walker = NULL;
     
    818818 * \param N arbitrary number to differentiate various zones in the tecplot format
    819819 */
    820 void WriteTecplotFile(ofstream *out, ofstream *tecplot, const Tesselation *TesselStruct, const PointCloud *cloud, const int N)
     820void WriteTecplotFile(ofstream * const out, ofstream * const tecplot, const Tesselation * const TesselStruct, const PointCloud * const cloud, const int N)
    821821{
    822822  if ((tecplot != NULL) && (TesselStruct != NULL)) {
     
    859859 * \param *TesselStruct pointer to Tesselation structure
    860860 */
    861 void CalculateConcavityPerBoundaryPoint(ofstream *out, const Tesselation *TesselStruct)
     861void CalculateConcavityPerBoundaryPoint(ofstream * const out, const Tesselation * const TesselStruct)
    862862{
    863863  class BoundaryPointSet *point = NULL;
     
    886886 * \return true - all have exactly two triangles, false - some not, list is printed to screen
    887887 */
    888 bool CheckListOfBaselines(ofstream *out, const Tesselation *TesselStruct)
     888bool CheckListOfBaselines(ofstream * const out, const Tesselation * const TesselStruct)
    889889{
    890890  LineMap::const_iterator testline;
  • src/tesselationhelpers.hpp

    rfb73b8 rc0f6c6  
    4747/********************************************** declarations *******************************/
    4848
    49 double DetGet(gsl_matrix *A, int inPlace);
    50 void GetSphere(Vector *center, Vector &a, Vector &b, Vector &c, double RADIUS);
    51 void GetCenterOfSphere(Vector* Center, Vector a, Vector b, Vector c, Vector *NewUmkreismittelpunkt, Vector* Direction, Vector* AlternativeDirection, double HalfplaneIndicator, double AlternativeIndicator, double alpha, double beta, double gamma, double RADIUS, double Umkreisradius);
    52 void GetCenterofCircumcircle(Vector *Center, Vector *a, Vector *b, Vector *c);
    53 double GetPathLengthonCircumCircle(Vector &CircleCenter, Vector &CirclePlaneNormal, double CircleRadius, Vector &NewSphereCenter, Vector &OldSphereCenter, Vector &NormalVector, Vector &SearchDirection);
     49double DetGet(gsl_matrix * const A, const int inPlace);
     50void GetSphere(Vector * const Center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS);
     51void GetCenterOfSphere(Vector* const Center, const Vector &a, const Vector &b, const Vector &c, Vector * const NewUmkreismittelpunkt, const Vector* const Direction, const Vector* const AlternativeDirection, const double HalfplaneIndicator, const double AlternativeIndicator, const double alpha, const double beta, const double gamma, const double RADIUS, const double Umkreisradius);
     52void GetCenterofCircumcircle(Vector * const Center, const Vector &a, const Vector &b, const Vector &c);
     53double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection);
    5454double MinIntersectDistance(const gsl_vector * x, void *params);
    55 bool existsIntersection(Vector point1, Vector point2, Vector point3, Vector point4);
    56 double CalculateVolumeofGeneralTetraeder(Vector *a, Vector *b, Vector *c, Vector *d);
    57 double GetAngle(const Vector &point, const Vector &reference, const Vector OrthogonalVector);
     55bool existsIntersection(const Vector &point1, const Vector &point2, const Vector &point3, const Vector &point4);
     56double CalculateVolumeofGeneralTetraeder(const Vector &a, const Vector &b, const Vector &c, const Vector &d);
     57double GetAngle(const Vector &point, const Vector &reference, const Vector &OrthogonalVector);
    5858
    59 bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet *nodes[3]);
    60 bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation* candidate2);
     59bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet * const nodes[3]);
     60bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation *candidate2);
    6161TesselPoint* FindClosestPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC);
    62 TesselPoint* FindSecondClosestPoint(const Vector*, const LinkedCell*);
    63 Vector * GetClosestPointBetweenLine(ofstream *out, const BoundaryLineSet *Base, const BoundaryLineSet *OtherBase);
     62TesselPoint* FindSecondClosestPoint(const Vector*, const LinkedCell* const LC);
     63Vector * GetClosestPointBetweenLine(ofstream *out, const BoundaryLineSet * const Base, const BoundaryLineSet * const OtherBase);
    6464
    65 void WriteTecplotFile(ofstream *out, ofstream *tecplot, const Tesselation *TesselStruct, const PointCloud *cloud, const int N);
    66 void WriteRaster3dFile(ofstream *out, ofstream *rasterfile, const Tesselation *Tess, const PointCloud *cloud);
    67 void IncludeSphereinRaster3D(ofstream *out, ofstream *rasterfile, const Tesselation *Tess, const PointCloud *cloud);
    68 void WriteVrmlFile(ofstream *out, ofstream *vrmlfile, const Tesselation *Tess, const PointCloud *cloud);
    69 void CalculateConcavityPerBoundaryPoint(ofstream *out, const Tesselation *TesselStruct);
    70 double DistanceToTrianglePlane(ofstream *out, const Vector *x, const BoundaryTriangleSet *triangle);
     65void WriteTecplotFile(ofstream * const out, ofstream * const tecplot, const Tesselation * const TesselStruct, const PointCloud * const cloud, const int N);
     66void WriteRaster3dFile(ofstream * const out, ofstream * const rasterfile, const Tesselation * const Tess, const PointCloud * const cloud);
     67void IncludeSphereinRaster3D(ofstream * const out, ofstream * const rasterfile, const Tesselation *Tess, const PointCloud *cloud);
     68void WriteVrmlFile(ofstream * const out, ofstream * const vrmlfile, const Tesselation * const Tess, const PointCloud * const cloud);
     69void CalculateConcavityPerBoundaryPoint(ofstream * const out, const Tesselation * const TesselStruct);
     70double DistanceToTrianglePlane(ofstream * const out, const Vector *x, const BoundaryTriangleSet * const triangle);
    7171
    72 bool CheckListOfBaselines(ofstream *out, const Tesselation *TesselStruct);
     72bool CheckListOfBaselines(ofstream * const out, const Tesselation * const TesselStruct);
    7373
    7474
Note: See TracChangeset for help on using the changeset viewer.