Commit 383c7a5e authored by Martin Kostelnik's avatar Martin Kostelnik
Browse files

Fix per solid tolerances and change types from double to Precision

parent c64128a3
......@@ -250,9 +250,9 @@ int ShapeTester<ImplT>::TestConsistencySolids()
if (fIfSaveAllData) {
Vec_t point;
for (int i = 0; i < fMaxPoints; i++) {
point = fPoints[i];
Inside_t inside = fVolume->Inside(point);
fResultDouble[i] = (double)inside;
point = fPoints[i];
Inside_t inside = fVolume->Inside(point);
fResultPrecision[i] = (Precision)inside;
}
SaveResultsToFile("Inside");
}
......@@ -578,9 +578,9 @@ int ShapeTester<ImplT>::TestSafetyFromOutsideSolids()
if (fIfSaveAllData) {
Vec_t point;
for (int i = 0; i < fMaxPoints; i++) {
point = fPoints[i];
double res = fVolume->SafetyToIn(point);
fResultDouble[i] = res;
point = fPoints[i];
Precision res = fVolume->SafetyToIn(point);
fResultPrecision[i] = res;
}
SaveResultsToFile("SafetyFromOutside");
}
......@@ -600,9 +600,9 @@ int ShapeTester<ImplT>::TestSafetyFromInsideSolids()
Vec_t point;
for (int i = 0; i < fMaxPoints; i++) {
point = fPoints[i];
double res = fVolume->SafetyToOut(point);
fResultDouble[i] = res;
point = fPoints[i];
Precision res = fVolume->SafetyToOut(point);
fResultPrecision[i] = res;
}
SaveResultsToFile("SafetyFromInside");
......@@ -639,10 +639,10 @@ int ShapeTester<ImplT>::TestDistanceToInSolids()
if (fIfSaveAllData) {
Vec_t point, direction;
for (int i = 0; i < fMaxPoints; i++) {
point = fPoints[i];
direction = fDirections[i];
double res = fVolume->DistanceToIn(point, direction);
fResultDouble[i] = res;
point = fPoints[i];
direction = fDirections[i];
Precision res = fVolume->DistanceToIn(point, direction);
fResultPrecision[i] = res;
Vec_t normal;
PropagatedNormalU(point, direction, res, normal);
......@@ -671,9 +671,9 @@ int ShapeTester<ImplT>::TestDistanceToOutSolids()
point = fPoints[i];
direction = fDirections[i];
normal.Set(0);
double res = CallDistanceToOut(fVolume, point, direction, normal, convex);
Precision res = CallDistanceToOut(fVolume, point, direction, normal, convex);
fResultDouble[i] = res;
fResultPrecision[i] = res;
fResultVector[i] = normal;
}
}
......@@ -688,8 +688,8 @@ int ShapeTester<ImplT>::TestFarAwayPoint()
int errCode = 0;
Vec_t point, point1, vec, direction, normal, pointSurf;
int icount = 0, icount1 = 0, nError = 0;
double distIn, diff, difMax = 0., maxDistIn = 0.;
double tolerance = fSolidTolerance;
Precision distIn, diff, difMax = 0., maxDistIn = 0.;
Precision tolerance = fSolidTolerance;
ClearErrors();
// for ( int j=0; j<fMaxPointsSurface+fMaxPointsEdge; j++)
......@@ -1865,7 +1865,7 @@ void ShapeTester<ImplT>::CreatePointsAndDirections()
fPoints.resize(fMaxPoints);
fDirections.resize(fMaxPoints);
fResultDouble.resize(fMaxPoints);
fResultPrecision.resize(fMaxPoints);
fResultVector.resize(fMaxPoints);
CreatePointsAndDirectionsOutside();
......@@ -1964,7 +1964,7 @@ int ShapeTester<ImplT>::SaveResultsToFile(const string &fMethod1)
if (saveVectors)
file << "Norm=" << PrintCoordinates(fResultVector[i], spacer, prec) << "\n";
else
file << fResultDouble[i] << "\n";
file << fResultPrecision[i] << "\n";
}
return 0;
}
......
......@@ -8,10 +8,16 @@
#include "VecGeom/base/Vector3D.h"
#include "VecGeom/base/RNG.h"
#ifdef VECGEOM_ROOT
#include "utilities/Visualizer.h"
#endif
const double kApproxEqualTolerance = 1E-6;
#ifdef VECGEOM_FLOAT_PRECISION
const Precision kApproxEqualTolerance = 1e-3;
#else
const Precision kApproxEqualTolerance = 1e-6;
#endif
using vecgeom::Precision;
using Vec_t = vecgeom::Vector3D<Precision>;
......@@ -141,11 +147,11 @@ private:
return rand;
}
inline double RandomIncrease()
inline Precision RandomIncrease()
{
double tolerance = vecgeom::kTolerance;
double rand = -1 + 2 * fRNG.uniform();
double dif = tolerance * 0.1 * rand;
Precision tolerance = vecgeom::kTolerance;
Precision rand = -1 + 2 * fRNG.uniform();
Precision dif = tolerance * 0.1 * rand;
return dif;
}
......@@ -199,8 +205,8 @@ private:
ImplT const *fVolume; // Pointer that owns shape object.
std::string fVolumeString; // data member to store the name of volume;
std::vector<double> fResultDouble; // stl vector for storing the double results
std::vector<Vec_t> fResultVector; // stl vector for storing the vector results
std::vector<Precision> fResultPrecision; // stl vector for storing the double/float results
std::vector<Vec_t> fResultVector; // stl vector for storing the vector results
int fOffsetSurface; // offset of surface points
int fOffsetInside; // offset of inside points
......@@ -229,7 +235,7 @@ private:
int fNumDisp; // number of points to be displayed in case a shape is not following conventions.
bool fVisualize; // Flag to be set or unset by EnableDebugger() function that user will
// call with true parameter if want to see visualization in case of some mismatch
double fSolidTolerance; // Tolerance on boundary declared by solid (default kTolerance)
Precision fSolidTolerance; // Tolerance on boundary declared by solid (default kTolerance)
#ifdef VECGEOM_ROOT
vecgeom::Visualizer fVisualizer; // Visualizer object to visualize the geometry if fVisualize is set.
#endif
......
......@@ -33,7 +33,9 @@ int runTester(ImplT const *shape, int npoints, bool debug, bool stat)
{
ShapeTester<ImplT> tester;
tester.SetSolidTolerance(1.e-7);
#ifndef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1.e-7);
#endif
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
......
......@@ -57,7 +57,6 @@ int main(int argc, char *argv[])
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetSolidTolerance(1.e-9);
tester.SetTestBoundaryErrors(true);
int errCode = tester.Run(cuttube);
......
......@@ -23,7 +23,6 @@ int main(int argc, char *argv[])
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetSolidTolerance(1.e-9);
tester.SetTestBoundaryErrors(false);
int errCode = tester.Run(placed);
......
......@@ -89,7 +89,11 @@ int main(int argc, char *argv[])
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetSolidTolerance(1.e-7);
#ifndef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1.e-7);
#endif
tester.SetTestBoundaryErrors(true);
int errCode = tester.Run(solid);
......
......@@ -24,7 +24,11 @@ int main(int argc, char *argv[])
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetSolidTolerance(1.e-7);
#ifndef VECGEOM_FLOAT_PRECISION
tester.SetSolidTolerance(1.e-7);
#endif
tester.SetTestBoundaryErrors(false);
int errCode = tester.Run(poly2);
......
......@@ -17,7 +17,6 @@ int main(int argc, char *argv[])
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetSolidTolerance(1.e-9);
tester.SetTestBoundaryErrors(true);
int errCode = tester.Run(hype);
......
......@@ -51,7 +51,6 @@ int main(int argc, char *argv[])
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetSolidTolerance(1.e-9);
tester.SetTestBoundaryErrors(false);
int errCode = tester.Run(solid);
......
......@@ -36,7 +36,6 @@ int runTester(ImplT const *shape, int npoints, bool debug, bool stat)
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetSolidTolerance(1.e-9);
tester.SetTestBoundaryErrors(true);
int errCode = tester.Run(shape);
......
......@@ -38,7 +38,6 @@ int runTester(ImplT const *shape, int npoints, bool debug, bool stat)
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetSolidTolerance(1.e-9);
tester.SetTestBoundaryErrors(true);
int errCode = tester.Run(shape);
......
......@@ -53,7 +53,6 @@ int main(int argc, char *argv[])
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetSolidTolerance(1.e-9);
tester.SetTestBoundaryErrors(true);
int errCode = tester.Run(solid);
......
......@@ -73,7 +73,6 @@ int main(int argc, char *argv[])
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetSolidTolerance(1.e-9);
tester.SetTestBoundaryErrors(false);
int errCode = tester.Run(poly2);
......
......@@ -51,7 +51,6 @@ int main(int argc, char *argv[])
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetSolidTolerance(1.e-9);
tester.SetTestBoundaryErrors(false);
int errCode = tester.Run(solid);
......
......@@ -33,7 +33,6 @@ int main(int argc, char *argv[])
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetSolidTolerance(1.e-9);
tester.SetTestBoundaryErrors(false);
int errCode = tester.Run(solid);
......
......@@ -37,7 +37,6 @@ int runTester(ImplT const *shape, int npoints, bool debug, bool stat)
tester.setDebug(debug);
tester.setStat(stat);
tester.SetMaxPoints(npoints);
tester.SetSolidTolerance(1.e-9);
tester.SetTestBoundaryErrors(true);
int errCode = tester.Run(shape);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment