Skip to content

Commit

Permalink
Refs #5190 round to integers for sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
VickieLynch committed May 11, 2012
1 parent 7973338 commit b7f22bf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Code/Mantid/Framework/Crystal/inc/MantidCrystal/SortHKL.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidGeometry/Crystal/PointGroup.h"
#include "MantidKernel/V3D.h"

namespace Mantid
{
Expand Down Expand Up @@ -40,10 +41,11 @@ namespace Crystal
void exec();
void Outliers(std::vector<double>& data, std::vector<double>& err);

double round(double d);
Kernel::V3D round(Kernel::V3D d);
};


} // namespace Mantid
} // namespace Crystal
} // namespace Mantid

#endif /* MANTID_CRYSTAL_SORTHKL_H_ */
22 changes: 20 additions & 2 deletions Code/Mantid/Framework/Crystal/src/SortHKL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ namespace Crystal
if (peaksW != InPeaksW)
peaksW = InPeaksW->clone();

int NumberPeaks = peaksW->getNumberPeaks();
for (int i = 0; i < NumberPeaks; i++)
{
V3D hkl1 = round(peaksW->getPeaks()[i].getHKL());
peaksW->getPeaks()[i].setHKL(hkl1);
}
//Use the primitive by default
PointGroup_sptr pointGroup(new PointGroupLaue1());
//Get it from the property
Expand All @@ -96,7 +102,6 @@ namespace Crystal

double Chisq = 0.0;
std::vector<Peak> &peaks = peaksW->getPeaks();
int NumberPeaks = peaksW->getNumberPeaks();
for (int i = 0; i < NumberPeaks; i++)
{
V3D hkl1 = peaks[i].getHKL();
Expand All @@ -106,7 +111,9 @@ namespace Crystal
V3D hkl2 = peaks[j].getHKL();
std::string bank2 = peaks[j].getBankName();
if (pointGroup->isEquivalent(hkl1,hkl2) && bank1.compare(bank2) == 0)
{
peaks[j].setHKL(hkl1);
}
}
}

Expand Down Expand Up @@ -210,7 +217,18 @@ namespace Crystal
}
}
}

V3D SortHKL::round(V3D hkl)
{
V3D hkl1;
hkl1.setX(round(hkl.X()));
hkl1.setY(round(hkl.Y()));
hkl1.setZ(round(hkl.Z()));
return hkl1;
}
double SortHKL::round(double d)
{
return floor(d + 0.5);
}

} // namespace Mantid
} // namespace Crystal
Expand Down

0 comments on commit b7f22bf

Please sign in to comment.