Mantid
Loading...
Searching...
No Matches
MDHistoDimensionBuilder.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
11
12#include <cmath>
13
14namespace Mantid {
15namespace Geometry {
16
28class MANTID_GEOMETRY_DLL MDHistoDimensionBuilder {
29public:
38 template <typename CoordT> static void resizeToFitMDBox(CoordT &min, CoordT &max) {
39 // Always use minimum float value as DBL_EPS is always too small
40 static constexpr CoordT twoEps = 2 * std::numeric_limits<float>::epsilon();
41 if (std::fabs(min) > twoEps)
42 min *= (1 - std::copysign(twoEps, min));
43 else
44 min -= twoEps;
45 if (std::fabs(max) > twoEps)
46 max *= (1 + std::copysign(twoEps, max));
47 else
48 max += twoEps;
49 }
50
52 void setName(const std::string &name);
53 void setId(std::string id);
54 void setUnits(const Kernel::UnitLabel &units);
55 void setMin(double min);
56 void setMax(double max);
57 void setNumBins(size_t nbins);
58 void setFrameName(std::string frameName);
59
60 size_t getNumBins() const { return m_nbins; }
61 MDHistoDimension *createRaw();
63
64private:
66 std::string m_name;
68 std::string m_id;
72 double m_min;
74 double m_max;
76 size_t m_nbins;
82 std::string m_frameName;
83};
84
86using Vec_MDHistoDimensionBuilder = std::vector<MDHistoDimensionBuilder>;
87} // namespace Geometry
88} // namespace Mantid
bool m_maxSet
Flag indicating that max has been set.
bool m_minSet
Flag indicating that min has been set.
static void resizeToFitMDBox(CoordT &min, CoordT &max)
Push the min/max values out by a defined amount.
A base-class for the a class that is able to return unit labels in different representations.
Definition: UnitLabel.h:20
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
std::vector< MDHistoDimensionBuilder > Vec_MDHistoDimensionBuilder
Handy typedef for collection of builders.
std::shared_ptr< IMDDimension > IMDDimension_sptr
Shared Pointer for IMDDimension. Frequently used type in framework.
Definition: IMDDimension.h:98
Helper class which provides the Collimation Length for SANS instruments.