Mantid
Loading...
Searching...
No Matches
ReflectionCondition.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
9#include "MantidGeometry/DllConfig.h"
10
11#ifndef Q_MOC_RUN
12#include <memory>
13#endif
14
15#include <string>
16#include <vector>
17
18namespace Mantid {
19namespace Geometry {
20
28class MANTID_GEOMETRY_DLL ReflectionCondition {
29public:
30 virtual ~ReflectionCondition() = default;
32 virtual std::string getName() = 0;
34 virtual std::string getSymbol() = 0;
36 virtual bool isAllowed(int h, int k, int l) = 0;
37};
38
39//------------------------------------------------------------------------
41class MANTID_GEOMETRY_DLL ReflectionConditionPrimitive : public ReflectionCondition {
42public:
44 std::string getName() override { return "Primitive"; }
46 std::string getSymbol() override { return "P"; }
48 bool isAllowed(int /*h*/, int /*k*/, int /*l*/) override { return true; }
49};
50
51//------------------------------------------------------------------------
53class MANTID_GEOMETRY_DLL ReflectionConditionCFaceCentred : public ReflectionCondition {
54public:
56 std::string getName() override { return "C-face centred"; }
58 std::string getSymbol() override { return "C"; }
60 bool isAllowed(int h, int k, int /*l*/) override { return (((h + k) % 2) == 0); }
61};
62
63//------------------------------------------------------------------------
65class MANTID_GEOMETRY_DLL ReflectionConditionAFaceCentred : public ReflectionCondition {
66public:
68 std::string getName() override { return "A-face centred"; }
70 std::string getSymbol() override { return "A"; }
72 bool isAllowed(int /*h*/, int k, int l) override { return (((k + l) % 2) == 0); }
73};
74
75//------------------------------------------------------------------------
77class MANTID_GEOMETRY_DLL ReflectionConditionBFaceCentred : public ReflectionCondition {
78public:
80 std::string getName() override { return "B-face centred"; }
82 std::string getSymbol() override { return "B"; }
84 bool isAllowed(int h, int /*k*/, int l) override { return (((h + l) % 2) == 0); }
85};
86
87//------------------------------------------------------------------------
89class MANTID_GEOMETRY_DLL ReflectionConditionBodyCentred : public ReflectionCondition {
90public:
92 std::string getName() override { return "Body centred"; }
94 std::string getSymbol() override { return "I"; }
96 bool isAllowed(int h, int k, int l) override { return ((h + k + l) % 2) == 0; }
97};
98
99//------------------------------------------------------------------------
101class MANTID_GEOMETRY_DLL ReflectionConditionAllFaceCentred : public ReflectionCondition {
102public:
104 std::string getName() override { return "All-face centred"; }
106 std::string getSymbol() override { return "F"; }
108 bool isAllowed(int h, int k, int l) override {
109 return (((((h + k) % 2) == 0) && (((h + l) % 2) == 0) && (((k + l) % 2) == 0)) |
110 ((h % 2 == 0) && (k % 2 == 0) && (l % 2 == 0)) ||
111 ((h % 2 == 1) && (k % 2 == 1) && (l % 2 == 1)));
112 }
113};
114
115//------------------------------------------------------------------------
118public:
120 std::string getName() override { return "Rhombohedrally centred, obverse"; }
122 std::string getSymbol() override { return "Robv"; }
124 bool isAllowed(int h, int k, int l) override { return (((-h + k + l) % 3) == 0); }
125};
126
127//------------------------------------------------------------------------
130public:
132 std::string getName() override { return "Rhombohedrally centred, reverse"; }
134 std::string getSymbol() override { return "Rrev"; }
136 bool isAllowed(int h, int k, int l) override { return (((h - k + l) % 3) == 0); }
137};
138
139//------------------------------------------------------------------------
142public:
144 std::string getName() override { return "Hexagonally centred, reverse"; }
146 std::string getSymbol() override { return "H"; }
148 bool isAllowed(int h, int k, int /*l*/) override { return (((h - k) % 3) == 0); }
149};
150
152using ReflectionCondition_sptr = std::shared_ptr<ReflectionCondition>;
154using ReflectionConditions = std::vector<ReflectionCondition_sptr>;
155
156MANTID_GEOMETRY_DLL const ReflectionConditions &getAllReflectionConditions();
157MANTID_GEOMETRY_DLL std::vector<std::string> getAllReflectionConditionNames();
158MANTID_GEOMETRY_DLL std::vector<std::string> getAllReflectionConditionSymbols();
159MANTID_GEOMETRY_DLL ReflectionCondition_sptr getReflectionConditionByName(const std::string &name);
160MANTID_GEOMETRY_DLL ReflectionCondition_sptr getReflectionConditionBySymbol(const std::string &symbol);
161
162} // namespace Geometry
163} // namespace Mantid
std::string getName() override
Name of the reflection condition.
bool isAllowed(int, int k, int l) override
Return true if the hkl is allowed.
std::string getSymbol() override
Symbol of the associated lattice centering.
std::string getName() override
Name of the reflection condition.
std::string getSymbol() override
Symbol of the associated lattice centering.
bool isAllowed(int h, int k, int l) override
Return true if the hkl is allowed.
std::string getSymbol() override
Symbol of the associated lattice centering.
std::string getName() override
Name of the reflection condition.
bool isAllowed(int h, int, int l) override
Return true if the hkl is allowed.
std::string getSymbol() override
Symbol of the associated lattice centering.
bool isAllowed(int h, int k, int l) override
Return true if the hkl is allowed.
std::string getName() override
Name of the reflection condition.
bool isAllowed(int h, int k, int) override
Return true if the hkl is allowed.
std::string getSymbol() override
Symbol of the associated lattice centering.
std::string getName() override
Name of the reflection condition.
Hexagonally centred, reverse ReflectionCondition.
bool isAllowed(int h, int k, int) override
Return true if the hkl is allowed.
std::string getSymbol() override
Symbol of the associated lattice centering.
std::string getName() override
Name of the reflection condition.
std::string getSymbol() override
Symbol of the associated lattice centering.
std::string getName() override
Name of the reflection condition.
bool isAllowed(int, int, int) override
Return true if the hkl is allowed.
Rhombohedrally centred, obverse ReflectionCondition.
std::string getSymbol() override
Symbol of the associated lattice centering.
std::string getName() override
Name of the reflection condition.
bool isAllowed(int h, int k, int l) override
Return true if the hkl is allowed.
Rhombohedrally centred, reverse ReflectionCondition.
std::string getSymbol() override
Symbol of the associated lattice centering.
bool isAllowed(int h, int k, int l) override
Return true if the hkl is allowed.
std::string getName() override
Name of the reflection condition.
A class containing the Reflection Condition for a crystal.
virtual bool isAllowed(int h, int k, int l)=0
Return true if the hkl is allowed.
virtual std::string getName()=0
Name of the reflection condition.
virtual std::string getSymbol()=0
Symbol of the associated lattice centering.
std::shared_ptr< ReflectionCondition > ReflectionCondition_sptr
Shared pointer to a ReflectionCondition.
MANTID_GEOMETRY_DLL ReflectionCondition_sptr getReflectionConditionBySymbol(const std::string &symbol)
Returns the ReflectionCondition for the specified centering symbol, see getAllReflectionConditionSymb...
std::vector< ReflectionCondition_sptr > ReflectionConditions
A collection of reflections.
MANTID_GEOMETRY_DLL const ReflectionConditions & getAllReflectionConditions()
MANTID_GEOMETRY_DLL ReflectionCondition_sptr getReflectionConditionByName(const std::string &name)
Returns the requested ReflectionCondition, see getAllReflectionConditionNames for possible names.
MANTID_GEOMETRY_DLL std::vector< std::string > getAllReflectionConditionSymbols()
Returns all centering symbols.
MANTID_GEOMETRY_DLL std::vector< std::string > getAllReflectionConditionNames()
Returns all ReflectionCondition names.
Helper class which provides the Collimation Length for SANS instruments.