Skip to content

Commit

Permalink
refs #7261. Unit test confirms false positive bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Jun 7, 2013
1 parent fb0f18b commit 758b31e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Crystal/src/PeaksInRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ namespace Crystal
for(int i = 0; i < 6; ++i)
{
double distance = normals[i].scalar_prod(peakCenter - faces[i][0]); // Distance between plane and peak center.
if(peakRadius > std::abs(distance)) // Sphere passes through one of the faces, so intersects the box.
if(peakRadius >= std::abs(distance)) // Sphere passes through one of the faces, so intersects the box.
{
doesIntersect = true;
break;
Expand Down
30 changes: 30 additions & 0 deletions Code/Mantid/Framework/Crystal/test/PeaksInRegionTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "MantidDataObjects/PeaksWorkspace.h"
#include "MantidCrystal/PeaksInRegion.h"
#include <boost/tuple/tuple.hpp>
#include <boost/assign/list_of.hpp>

using Mantid::Crystal::PeaksInRegion;
using namespace Mantid::API;
Expand Down Expand Up @@ -332,6 +333,35 @@ class PeaksInRegionTest : public CxxTest::TestSuite
do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, 1, 1, -wallDistanceFromPeakCenter, peakRadius, peakRadius > wallDistanceFromPeakCenter);
}

void test_false_intersection_when_check_peak_extents()
{
std::vector<double> extents = boost::assign::list_of(0)(1)(0)(1)(0)(1); // Extents go from 0, 1 in each dimension.

PeaksWorkspace_sptr ws = WorkspaceCreationHelper::createPeaksWorkspace(1);
auto detectorIds = ws->getInstrument()->getDetectorIDs();
Peak& peak = ws->getPeak(0);
peak.setHKL(Mantid::Kernel::V3D(0, 0, 2)); // This point is actually on the y = 0 plane, i.e. satisfies the plane equation. aX + bY + cZ = 0, but is outside the box.

const std::string outName = "OutWS";

PeaksInRegion alg;
alg.setRethrows(true);
alg.initialize();
alg.setProperty("InputWorkspace", ws);
alg.setPropertyValue("CoordinateFrame", "HKL");
alg.setProperty("Extents", extents);
alg.setPropertyValue("OutputWorkspace", outName);
alg.setProperty("CheckPeakExtents", true); // This wouldn't happen if CheckPeak extents = false.
alg.setProperty("PeakRadius", 0.1);
alg.execute();

ITableWorkspace_sptr outWS = AnalysisDataService::Instance().retrieveWS<ITableWorkspace>(outName);

TS_ASSERT_EQUALS(1, outWS->rowCount());
TSM_ASSERT_EQUALS("Peak index should be zero", 0, outWS->cell<int>(0, 0));
TSM_ASSERT_EQUALS("Peak does NOT intersect the box", Boolean(false), outWS->cell<Boolean>(0, 1));
}

};


Expand Down

0 comments on commit 758b31e

Please sign in to comment.