Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tesselationhelpers.cpp

    rd74077 r952f38  
    1010#include <fstream>
    1111
    12 #include "BoundaryLineSet.hpp"
    13 #include "BoundaryPointSet.hpp"
    14 #include "BoundaryPolygonSet.hpp"
    15 #include "BoundaryTriangleSet.hpp"
    16 #include "CandidateForTesselation.hpp"
    17 #include "info.hpp"
     12#include "Helpers/Info.hpp"
    1813#include "linkedcell.hpp"
    19 #include "linearsystemofequations.hpp"
    20 #include "log.hpp"
     14#include "LinearAlgebra/linearsystemofequations.hpp"
     15#include "Helpers/Log.hpp"
    2116#include "tesselation.hpp"
    2217#include "tesselationhelpers.hpp"
    23 #include "vector.hpp"
    24 #include "Line.hpp"
     18#include "LinearAlgebra/Vector.hpp"
     19#include "LinearAlgebra/Line.hpp"
    2520#include "vector_ops.hpp"
    26 #include "verbose.hpp"
    27 #include "Plane.hpp"
    28 #include "Matrix.hpp"
     21#include "Helpers/Verbose.hpp"
     22#include "LinearAlgebra/Plane.hpp"
     23#include "LinearAlgebra/Matrix.hpp"
    2924
    3025void GetSphere(Vector * const center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS)
     
    149144 * \param *c third point
    150145 */
    151 void GetCenterofCircumcircle(Vector &Center, const Vector &a, const Vector &b, const Vector &c)
     146void GetCenterofCircumcircle(Vector * const Center, const Vector &a, const Vector &b, const Vector &c)
    152147{
    153148        Info FunctionInfo(__func__);
     
    161156  helper[2] = SideC.NormSquared()*(SideA.NormSquared()+SideB.NormSquared() - SideC.NormSquared());
    162157
    163   Center.Zero();
    164   Center += helper[0] * a;
    165   Center += helper[1] * b;
    166   Center += helper[2] * c;
    167   Center.Scale(1./(helper[0]+helper[1]+helper[2]));
    168   Log() << Verbose(1) << "INFO: Center (2nd algo) is at " << Center << "." << endl;
     158  Center->Zero();
     159  *Center += helper[0] * a;
     160  *Center += helper[1] * b;
     161  *Center += helper[2] * c;
     162  Center->Scale(1./(helper[0]+helper[1]+helper[2]));
     163  Log() << Verbose(1) << "INFO: Center (2nd algo) is at " << *Center << "." << endl;
    169164};
    170165
     
    393388 * @return point which is second closest to the provided one
    394389 */
    395 TesselPoint* FindSecondClosestTesselPoint(const Vector& Point, const LinkedCell* const LC)
     390TesselPoint* FindSecondClosestTesselPoint(const Vector* Point, const LinkedCell* const LC)
    396391{
    397392        Info FunctionInfo(__func__);
     
    417412        if (List != NULL) {
    418413          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    419             helper = (Point) - ((*Runner)->getPosition());
     414            helper = (*Point) - (*(*Runner)->node);
    420415            double currentNorm = helper. Norm();
    421416            if (currentNorm < distance) {
     
    446441 * @return point which is closest to the provided one, NULL if none found
    447442 */
    448 TesselPoint* FindClosestTesselPoint(const Vector& Point, TesselPoint *&SecondPoint, const LinkedCell* const LC)
     443TesselPoint* FindClosestTesselPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC)
    449444{
    450445        Info FunctionInfo(__func__);
     
    470465        if (List != NULL) {
    471466          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    472             helper = (Point) - ((*Runner)->getPosition());
     467            helper = (*Point) - (*(*Runner)->node);
    473468            double currentNorm = helper.NormSquared();
    474469            if (currentNorm < distance) {
     
    508503        Info FunctionInfo(__func__);
    509504  // construct the plane of the two baselines (i.e. take both their directional vectors)
    510   Vector Baseline = (Base->endpoints[1]->node->getPosition()) - (Base->endpoints[0]->node->getPosition());
    511   Vector OtherBaseline = (OtherBase->endpoints[1]->node->getPosition()) - (OtherBase->endpoints[0]->node->getPosition());
     505  Vector Baseline = (*Base->endpoints[1]->node->node) - (*Base->endpoints[0]->node->node);
     506  Vector OtherBaseline = (*OtherBase->endpoints[1]->node->node) - (*OtherBase->endpoints[0]->node->node);
    512507  Vector Normal = Baseline;
    513508  Normal.VectorProduct(OtherBaseline);
     
    516511
    517512  // project one offset point of OtherBase onto this plane (and add plane offset vector)
    518   Vector NewOffset = (OtherBase->endpoints[0]->node->getPosition()) - (Base->endpoints[0]->node->getPosition());
     513  Vector NewOffset = (*OtherBase->endpoints[0]->node->node) - (*Base->endpoints[0]->node->node);
    519514  NewOffset.ProjectOntoPlane(Normal);
    520   NewOffset += (Base->endpoints[0]->node->getPosition());
     515  NewOffset += (*Base->endpoints[0]->node->node);
    521516  Vector NewDirection = NewOffset + OtherBaseline;
    522517
    523518  // calculate the intersection between this projected baseline and Base
    524519  Vector *Intersection = new Vector;
    525   Line line1 = makeLineThrough((Base->endpoints[0]->node->getPosition()),(Base->endpoints[1]->node->getPosition()));
     520  Line line1 = makeLineThrough(*(Base->endpoints[0]->node->node),*(Base->endpoints[1]->node->node));
    526521  Line line2 = makeLineThrough(NewOffset, NewDirection);
    527522  *Intersection = line1.getIntersection(line2);
    528   Normal = (*Intersection) - (Base->endpoints[0]->node->getPosition());
     523  Normal = (*Intersection) - (*Base->endpoints[0]->node->node);
    529524  DoLog(1) && (Log() << Verbose(1) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(Baseline)/Baseline.NormSquared()) << "." << endl);
    530525
     
    571566      *vrmlfile << "Sphere {" << endl << "  "; // 2 is sphere type
    572567      for (i=0;i<NDIM;i++)
    573         *vrmlfile << Walker->at(i)-center->at(i) << " ";
     568        *vrmlfile << Walker->node->at(i)-center->at(i) << " ";
    574569      *vrmlfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour
    575570      cloud->GoToNext();
     
    581576      for (i=0;i<3;i++) { // print each node
    582577        for (int j=0;j<NDIM;j++)  // and for each node all NDIM coordinates
    583           *vrmlfile << TriangleRunner->second->endpoints[i]->node->at(j)-center->at(j) << " ";
     578          *vrmlfile << TriangleRunner->second->endpoints[i]->node->node->at(j)-center->at(j) << " ";
    584579        *vrmlfile << "\t";
    585580      }
     
    608603    Vector *center = cloud->GetCenter();
    609604    // make the circumsphere's center absolute again
    610     Vector helper = (1./3.) * ((Tess->LastTriangle->endpoints[0]->node->getPosition()) +
    611                                (Tess->LastTriangle->endpoints[1]->node->getPosition()) +
    612                                (Tess->LastTriangle->endpoints[2]->node->getPosition()));
     605    Vector helper = (1./3.) * ((*Tess->LastTriangle->endpoints[0]->node->node) +
     606                               (*Tess->LastTriangle->endpoints[1]->node->node) +
     607                               (*Tess->LastTriangle->endpoints[2]->node->node));
    613608    helper -= (*center);
    614609    // and add to file plus translucency object
     
    643638      *rasterfile << "2" << endl << "  ";  // 2 is sphere type
    644639      for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates
    645         const double tmp = Walker->at(j)-center->at(j);
     640        const double tmp = Walker->node->at(j)-center->at(j);
    646641        *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
    647642      }
     
    656651      for (i=0;i<3;i++) {  // print each node
    657652        for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates
    658           const double tmp = TriangleRunner->second->endpoints[i]->node->at(j)-center->at(j);
     653          const double tmp = TriangleRunner->second->endpoints[i]->node->node->at(j)-center->at(j);
    659654          *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
    660655        }
     
    710705      LookupList[Walker->nr] = Counter++;
    711706      for (int i=0;i<NDIM;i++) {
    712         const double tmp = Walker->at(i);
     707        const double tmp = Walker->node->at(i);
    713708        *tecplot << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
    714709      }
     
    759754    TriangleSet *triangles = TesselStruct->GetAllTriangles(PointRunner->second);
    760755    for (TriangleSet::iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); ++TriangleRunner) {
    761       totalarea += CalculateAreaofGeneralTriangle((*TriangleRunner)->endpoints[0]->node->getPosition() , (*TriangleRunner)->endpoints[1]->node->getPosition() , (*TriangleRunner)->endpoints[2]->node->getPosition());
     756      totalarea += CalculateAreaofGeneralTriangle(*(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node);
    762757    }
    763758    ConcavityPerLine *= totalarea;
     
    768763      line = (*TriangleRunner)->GetThirdLine(PointRunner->second);
    769764      triangle = line->GetOtherTriangle(*TriangleRunner);
    770       area = CalculateAreaofGeneralTriangle(triangle->endpoints[0]->node->getPosition() , triangle->endpoints[1]->node->getPosition() , triangle->endpoints[2]->node->getPosition());
    771       area += CalculateAreaofGeneralTriangle((*TriangleRunner)->endpoints[0]->node->getPosition() , (*TriangleRunner)->endpoints[1]->node->getPosition() , (*TriangleRunner)->endpoints[2]->node->getPosition());
     765      area = CalculateAreaofGeneralTriangle(*triangle->endpoints[0]->node->node, *triangle->endpoints[1]->node->node, *triangle->endpoints[2]->node->node);
     766      area += CalculateAreaofGeneralTriangle(*(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node);
    772767      area *= -line->CalculateConvexity();
    773768      if (area > 0)
     
    802797    distance = 0.;
    803798    for (TriangleMap::const_iterator TriangleRunner = Convex->TrianglesOnBoundary.begin(); TriangleRunner != Convex->TrianglesOnBoundary.end(); TriangleRunner++) {
    804       const double CurrentDistance = Convex->GetDistanceSquaredToTriangle(PointRunner->second->node->getPosition() , TriangleRunner->second);
     799      const double CurrentDistance = Convex->GetDistanceSquaredToTriangle(*PointRunner->second->node->node, TriangleRunner->second);
    805800      if (CurrentDistance < distance)
    806801        distance = CurrentDistance;
Note: See TracChangeset for help on using the changeset viewer.