14#include <boost/algorithm/string.hpp>
41 std::sort(equivalents.begin(), equivalents.end(), std::greater<V3D>());
43 equivalents.erase(std::unique(equivalents.begin(), equivalents.end()), equivalents.end());
64 return *std::max_element(equivalents.begin(), equivalents.end());
69 :
Group(group), m_symbolHM(symbolHM), m_name(symbolHM +
" (" + description +
")") {
80 return (std::find(hklEquivalents.cbegin(), hklEquivalents.cend(), hkl2) != hklEquivalents.end());
98 std::vector<V3D> equivalents;
101 [&hkl](
const auto &operation) { return operation.transformHKL(hkl); });
117 std::map<std::string, std::set<V3D>> symbolMap;
124 std::string symbol = element->hmSymbol();
125 V3D axis = element->getAxis();
127 symbolMap[symbol].insert(axis);
131 if (symbolMap[
"3"].size() == 4) {
135 if (symbolMap[
"6"].size() == 1 || symbolMap[
"-6"].size() == 1) {
139 if (symbolMap[
"3"].size() == 1) {
143 if (symbolMap[
"4"].size() == 1 || symbolMap[
"-4"].size() == 1) {
147 if (symbolMap[
"2"].size() == 3 || (symbolMap[
"2"].size() == 1 && symbolMap[
"m"].size() == 2)) {
151 if (symbolMap[
"2"].size() == 1 || symbolMap[
"m"].size() == 1) {
197 std::vector<std::string> allSymbols = pointGroupFactory.getAllPointGroupSymbols();
198 std::vector<PointGroup_sptr> out;
199 out.reserve(allSymbols.size());
200 std::transform(allSymbols.cbegin(), allSymbols.cend(), std::back_inserter(out),
201 [&pointGroupFactory](
const auto &symbol) { return pointGroupFactory.createPointGroup(symbol); });
211 for (
auto &pointGroup : pointGroups) {
212 map.emplace(pointGroup->crystalSystem(), pointGroup);
220 switch (crystalSystem) {
230 return "Orthorhombic";
241 std::string crystalSystemLC = boost::algorithm::to_lower_copy(crystalSystem);
243 if (crystalSystemLC ==
"cubic") {
245 }
else if (crystalSystemLC ==
"tetragonal") {
247 }
else if (crystalSystemLC ==
"hexagonal") {
249 }
else if (crystalSystemLC ==
"trigonal") {
251 }
else if (crystalSystemLC ==
"orthorhombic") {
253 }
else if (crystalSystemLC ==
"monoclinic") {
255 }
else if (crystalSystemLC ==
"triclinic") {
258 throw std::invalid_argument(
"Not a valid crystal system: '" + crystalSystem +
"'.");
264 switch (latticeSystem) {
272 return "Rhombohedral";
274 return "Orthorhombic";
285 std::string latticeSystemLC = boost::algorithm::to_lower_copy(latticeSystem);
287 if (latticeSystemLC ==
"cubic") {
289 }
else if (latticeSystemLC ==
"tetragonal") {
291 }
else if (latticeSystemLC ==
"hexagonal") {
293 }
else if (latticeSystemLC ==
"rhombohedral") {
295 }
else if (latticeSystemLC ==
"orthorhombic") {
297 }
else if (latticeSystemLC ==
"monoclinic") {
299 }
else if (latticeSystemLC ==
"triclinic") {
302 throw std::invalid_argument(
"Not a valid lattice system: '" + latticeSystem +
"'.");
308 return static_cast<int>(lhs) <
static_cast<int>(
rhs);
313 stream <<
"Point group with:\n"
const std::vector< double > & rhs
The class Group represents a set of symmetry operations (or symmetry group).
CoordinateSystem getCoordinateSystem() const
Returns the axis system of the group (either orthogonal or hexagonal).
std::vector< SymmetryOperation > m_allOperations
A class containing the Point Groups for a crystal.
PointGroup(const std::string &symbolHM, const Group &group, const std::string &description="")
Protected constructor - can not be used directly.
bool isEquivalent(const Kernel::V3D &hkl, const Kernel::V3D &hkl2) const
Return true if the hkls are in same group.
std::string getSymbol() const
Hermann-Mauguin symbol.
LatticeSystem getLatticeSystemFromCrystalSystemAndGroup(const CrystalSystem &crystalSystem) const
Returns the LatticeSystem of the point group, using the crystal system.
LatticeSystem latticeSystem() const
std::vector< Kernel::V3D > getEquivalents(const Kernel::V3D &hkl) const
Returns a vector with all equivalent hkls.
CrystalSystem getCrystalSystemFromGroup() const
Returns the CrystalSystem determined from symmetry elements.
CrystalSystem m_crystalSystem
std::vector< Kernel::V3D > getAllEquivalents(const Kernel::V3D &hkl) const
Generates a set of hkls.
LatticeSystem m_latticeSystem
CrystalSystem crystalSystem() const
Kernel::V3D getReflectionFamily(const Kernel::V3D &hkl) const
Returns the same hkl for all equivalent hkls.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
MANTID_GEOMETRY_DLL PointGroup::LatticeSystem getLatticeSystemFromString(const std::string &latticeSystem)
Returns the lattice system enum that corresponds to the supplied string or throws an invalid_argument...
std::multimap< PointGroup::CrystalSystem, PointGroup_sptr, CrystalSystemComparator > PointGroupCrystalSystemMap
std::shared_ptr< SymmetryElementWithAxis > SymmetryElementWithAxis_sptr
MANTID_GEOMETRY_DLL std::string getLatticeSystemAsString(const PointGroup::LatticeSystem &latticeSystem)
Returns the supplied LatticeSystem as a string.
MANTID_GEOMETRY_DLL std::ostream & operator<<(std::ostream &stream, const PointGroup &self)
Returns a streamed representation of the PointGroup object.
MANTID_GEOMETRY_DLL PointGroup::CrystalSystem getCrystalSystemFromString(const std::string &crystalSystem)
Returns the crystal system enum that corresponds to the supplied string or throws an invalid_argument...
MANTID_GEOMETRY_DLL std::string getCrystalSystemAsString(const PointGroup::CrystalSystem &crystalSystem)
Return a human-readable string for the given crystal system.
MANTID_GEOMETRY_DLL std::vector< PointGroup_sptr > getAllPointGroups()
MANTID_GEOMETRY_DLL PointGroupCrystalSystemMap getPointGroupsByCrystalSystem()
Returns a multimap with crystal system as key and point groups as values.
Mantid::Kernel::Matrix< int > IntMatrix
bool operator()(const PointGroup::CrystalSystem &lhs, const PointGroup::CrystalSystem &rhs) const