From 556d2d9b4e6ba0656f3a289d277a30a7cded10d6 Mon Sep 17 00:00:00 2001 From: Michael Wedel <michael.wedel@psi.ch> Date: Sun, 1 Mar 2015 20:40:00 +0100 Subject: [PATCH] Refs #11006. Removing comments, performance improvements. --- .../inc/MantidGeometry/Crystal/PointGroup.h | 245 ++------- .../Geometry/src/Crystal/PointGroup.cpp | 496 +----------------- 2 files changed, 75 insertions(+), 666 deletions(-) diff --git a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h index 41764989be2..95bd02cb2d4 100644 --- a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h +++ b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h @@ -16,6 +16,46 @@ namespace Mantid { namespace Geometry { + +class MANTID_GEOMETRY_DLL IndexPermutation { +public: + IndexPermutation(const Kernel::IntMatrix &matrix) : m_factors() { + for (size_t i = 0; i < matrix.numRows(); ++i) { + m_factors.push_back(IndexSum(i, matrix[i])); + } + } + + Kernel::V3D getPermutation(const Kernel::V3D &hkl) const { + Kernel::V3D hklPrime(0, 0, 0); + for (auto it = m_factors.begin(); it != m_factors.end(); ++it) { + hklPrime[(*it).getIndex()] = (*it).transformed(hkl); + } + + return hklPrime; + } + +private: + class IndexSum { + public: + IndexSum(size_t index, const int *matrixRow) + : m_index(index), m_f1(static_cast<double>(matrixRow[0])), + m_f2(static_cast<double>(matrixRow[1])), + m_f3(static_cast<double>(matrixRow[2])) {} + + size_t getIndex() const { return m_index; } + + double transformed(const Kernel::V3D &hkl) const { + return m_f1 * hkl[0] + m_f2 * hkl[1] + m_f3 * hkl[2]; + } + + private: + size_t m_index; + double m_f1, m_f2, m_f3; + }; + + std::vector<IndexSum> m_factors; +}; + /** A class containing the Point Groups for a crystal. * * @author Vickie Lynch @@ -48,220 +88,27 @@ public: CrystalSystem crystalSystem() const { return Cubic; } /// Return true if the hkls are in same group - bool isEquivalent(const Kernel::V3D &hkl, - const Kernel::V3D &hkl2) const; + bool isEquivalent(const Kernel::V3D &hkl, const Kernel::V3D &hkl2) const; /// Returns a vector with all equivalent hkls std::vector<Kernel::V3D> getEquivalents(const Kernel::V3D &hkl) const; /// Returns the same hkl for all equivalent hkls Kernel::V3D getReflectionFamily(const Kernel::V3D &hkl) const; - void init() { } protected: bool groupHasNoTranslations(const Group &group) const; - std::set<Kernel::V3D> getEquivalentSet(const Kernel::V3D &hkl) const; - - std::string m_symbolHM; - std::string m_name; -}; - -//------------------------------------------------------------------------ -/** -1 (Triclinic) PointGroup -class MANTID_GEOMETRY_DLL PointGroupLaue1 : public PointGroup { -public: - PointGroupLaue1(); - /// Name of the point group - virtual std::string getName() const; - /// Return true if the hkls are equivalent. - virtual bool isEquivalent(const Kernel::V3D &hkl, - const Kernel::V3D &hkl2) const; - virtual PointGroup::CrystalSystem crystalSystem() const; - - virtual void init(); -}; - -//------------------------------------------------------------------------ -/** 1 2/m 1 (Monoclinic, unique axis b) PointGroup -class MANTID_GEOMETRY_DLL PointGroupLaue2 : public PointGroup { -public: - PointGroupLaue2(); - /// Name of the point group - virtual std::string getName() const; - /// Return true if the hkls are equivalent. - virtual bool isEquivalent(const Kernel::V3D &hkl, - const Kernel::V3D &hkl2) const; - virtual PointGroup::CrystalSystem crystalSystem() const; - - virtual void init(); -}; - -//------------------------------------------------------------------------ -/** 1 1 2/m (Monoclinic, unique axis c) PointGroup -class MANTID_GEOMETRY_DLL PointGroupLaue3 : public PointGroup { -public: - PointGroupLaue3(); - /// Name of the point group - virtual std::string getName() const; - /// Return true if the hkls are equivalent. - virtual bool isEquivalent(const Kernel::V3D &hkl, - const Kernel::V3D &hkl2) const; - virtual PointGroup::CrystalSystem crystalSystem() const; - - virtual void init(); -}; - -//------------------------------------------------------------------------ -/** mmm (Orthorombic) PointGroup -class MANTID_GEOMETRY_DLL PointGroupLaue4 : public PointGroup { -public: - PointGroupLaue4(); - /// Name of the point group - virtual std::string getName() const; - /// Return true if the hkls are equivalent. - virtual bool isEquivalent(const Kernel::V3D &hkl, - const Kernel::V3D &hkl2) const; - virtual PointGroup::CrystalSystem crystalSystem() const; - - virtual void init(); -}; - -//------------------------------------------------------------------------ -/** 4/m (Tetragonal) PointGroup -class MANTID_GEOMETRY_DLL PointGroupLaue5 : public PointGroup { -public: - PointGroupLaue5(); - /// Name of the point group - virtual std::string getName() const; - /// Return true if the hkls are equivalent. - virtual bool isEquivalent(const Kernel::V3D &hkl, - const Kernel::V3D &hkl2) const; - virtual PointGroup::CrystalSystem crystalSystem() const; - - virtual void init(); -}; - -//------------------------------------------------------------------------ -/** 4/mmm (Tetragonal) PointGroup -class MANTID_GEOMETRY_DLL PointGroupLaue6 : public PointGroup { -public: - PointGroupLaue6(); - /// Name of the point group - virtual std::string getName() const; - /// Return true if the hkls are equivalent. - virtual bool isEquivalent(const Kernel::V3D &hkl, - const Kernel::V3D &hkl2) const; - virtual PointGroup::CrystalSystem crystalSystem() const; - - virtual void init(); -}; - -//------------------------------------------------------------------------ -/** -3 (Trigonal - Hexagonal) PointGroup -class MANTID_GEOMETRY_DLL PointGroupLaue7 : public PointGroup { -public: - PointGroupLaue7(); - /// Name of the point group - virtual std::string getName() const; - /// Return true if the hkls are equivalent. - virtual bool isEquivalent(const Kernel::V3D &hkl, - const Kernel::V3D &hkl2) const; - virtual PointGroup::CrystalSystem crystalSystem() const; - - virtual void init(); -}; - -//------------------------------------------------------------------------ -/** -3m1 (Trigonal - Rhombohedral) PointGroup -class MANTID_GEOMETRY_DLL PointGroupLaue8 : public PointGroup { -public: - PointGroupLaue8(); - /// Name of the point group - virtual std::string getName() const; - /// Return true if the hkls are equivalent. - virtual bool isEquivalent(const Kernel::V3D &hkl, - const Kernel::V3D &hkl2) const; - virtual PointGroup::CrystalSystem crystalSystem() const; - - virtual void init(); -}; - -//------------------------------------------------------------------------ -/** -31m (Trigonal - Rhombohedral) PointGroup -class MANTID_GEOMETRY_DLL PointGroupLaue9 : public PointGroup { -public: - PointGroupLaue9(); - /// Name of the point group - virtual std::string getName() const; - /// Return true if the hkls are equivalent. - virtual bool isEquivalent(const Kernel::V3D &hkl, - const Kernel::V3D &hkl2) const; - virtual PointGroup::CrystalSystem crystalSystem() const; - - virtual void init(); -}; - -//------------------------------------------------------------------------ -/** 6/m (Hexagonal) PointGroup -class MANTID_GEOMETRY_DLL PointGroupLaue10 : public PointGroup { -public: - PointGroupLaue10(); - /// Name of the point group - virtual std::string getName() const; - /// Return true if the hkls are equivalent. - virtual bool isEquivalent(const Kernel::V3D &hkl, - const Kernel::V3D &hkl2) const; - virtual PointGroup::CrystalSystem crystalSystem() const; - - virtual void init(); -}; - -//------------------------------------------------------------------------ -/** 6/mmm (Hexagonal) PointGroup -class MANTID_GEOMETRY_DLL PointGroupLaue11 : public PointGroup { -public: - PointGroupLaue11(); - /// Name of the point group - virtual std::string getName() const; - /// Return true if the hkls are equivalent. - virtual bool isEquivalent(const Kernel::V3D &hkl, - const Kernel::V3D &hkl2) const; - virtual PointGroup::CrystalSystem crystalSystem() const; + std::vector<Kernel::V3D> getEquivalentSet(const Kernel::V3D &hkl) const; - virtual void init(); -}; + void createPermutationsFromOperations(); -//------------------------------------------------------------------------ -/** m-3 (Cubic) PointGroup -class MANTID_GEOMETRY_DLL PointGroupLaue12 : public PointGroup { -public: - PointGroupLaue12(); - /// Name of the point group - virtual std::string getName() const; - /// Return true if the hkls are equivalent. - virtual bool isEquivalent(const Kernel::V3D &hkl, - const Kernel::V3D &hkl2) const; - virtual PointGroup::CrystalSystem crystalSystem() const; + std::vector<IndexPermutation> m_permutations; - virtual void init(); + std::string m_symbolHM; + std::string m_name; }; -//------------------------------------------------------------------------ -/** m-3m (Cubic) PointGroup -class MANTID_GEOMETRY_DLL PointGroupLaue13 : public PointGroup { -public: - PointGroupLaue13(); - /// Name of the point group - virtual std::string getName() const; - /// Return true if the hkls are equivalent. - virtual bool isEquivalent(const Kernel::V3D &hkl, - const Kernel::V3D &hkl2) const; - virtual PointGroup::CrystalSystem crystalSystem() const; - - virtual void init(); -}; -*/ /// Shared pointer to a PointGroup typedef boost::shared_ptr<PointGroup> PointGroup_sptr; diff --git a/Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp b/Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp index dabf4f13f8c..b046d585823 100644 --- a/Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp +++ b/Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp @@ -30,9 +30,9 @@ using Kernel::IntMatrix; * @return :: std::vector containing all equivalent hkls. */ std::vector<V3D> PointGroup::getEquivalents(const V3D &hkl) const { - std::set<V3D> equivalents = getEquivalentSet(hkl); + return getEquivalentSet(hkl); - return std::vector<V3D>(equivalents.rbegin(), equivalents.rend()); + // return std::vector<V3D>(equivalents.rbegin(), equivalents.rend()); } /** @@ -67,14 +67,21 @@ bool PointGroup::groupHasNoTranslations(const Group &group) const { /// Protected constructor - can not be used directly. PointGroup::PointGroup(const std::string &symbolHM, const Group &group, const std::string &name) - : Group(group), m_symbolHM(symbolHM), m_name(name) {} + : Group(group), m_permutations(), m_symbolHM(symbolHM), m_name(name) { + createPermutationsFromOperations(); +} PointGroup::PointGroup(const PointGroup &other) - : Group(other), m_symbolHM(other.m_symbolHM), m_name(other.m_name) {} + : Group(other), m_permutations(), m_symbolHM(other.m_symbolHM), + m_name(other.m_name) { + createPermutationsFromOperations(); +} PointGroup &PointGroup::operator=(const PointGroup &other) { Group::operator=(other); + createPermutationsFromOperations(); + m_symbolHM = other.m_symbolHM; m_name = other.m_name; @@ -86,9 +93,10 @@ std::string PointGroup::getSymbol() const { return m_symbolHM; } bool PointGroup::isEquivalent(const Kernel::V3D &hkl, const Kernel::V3D &hkl2) const { - std::set<V3D> hklEquivalents = getEquivalentSet(hkl); + std::vector<V3D> hklEquivalents = getEquivalentSet(hkl); - return (hklEquivalents.find(hkl2) != hklEquivalents.end()); + return (std::find(hklEquivalents.begin(), hklEquivalents.end(), hkl2) != + hklEquivalents.end()); } /** @@ -105,462 +113,31 @@ bool PointGroup::isEquivalent(const Kernel::V3D &hkl, * @param hkl :: Arbitrary hkl * @return :: set of hkls. */ -std::set<V3D> PointGroup::getEquivalentSet(const Kernel::V3D &hkl) const { - std::set<V3D> equivalents; - - const std::vector<SymmetryOperation> &symmetryOperations = - getSymmetryOperations(); +std::vector<V3D> PointGroup::getEquivalentSet(const Kernel::V3D &hkl) const { + std::vector<V3D> equivalents; + equivalents.reserve(m_permutations.size()); - for (auto op = symmetryOperations.begin(); op != symmetryOperations.end(); - ++op) { - equivalents.insert((*op) * hkl); + for (auto op = m_permutations.begin(); op != m_permutations.end(); ++op) { + equivalents.push_back((*op).getPermutation(hkl)); } - return equivalents; -} - -/* -PointGroupLaue1::PointGroupLaue1() : PointGroup("-1") {} - -std::string PointGroupLaue1::getName() const { return "-1 (Triclinic)"; } - -bool PointGroupLaue1::isEquivalent(const V3D &hkl, const V3D &hkl2) const { - double h = hkl[0]; - double k = hkl[1]; - double l = hkl[2]; - - return (hkl2 == V3D(h, k, l)) || (hkl2 == V3D(-h, -k, -l)); -} - -PointGroup::CrystalSystem PointGroupLaue1::crystalSystem() const { - return Triclinic; -} - -void PointGroupLaue1::init() { - std::vector<SymmetryOperation> generatingSymmetryOperations; - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-x,-y,-z")); - - setSymmetryOperations(generatingSymmetryOperations); -} - -PointGroupLaue2::PointGroupLaue2() : PointGroup("2/m") {} - -std::string PointGroupLaue2::getName() const { - return "1 2/m 1 (Monoclinic, unique axis b)"; -} - -bool PointGroupLaue2::isEquivalent(const V3D &hkl, const V3D &hkl2) const { - double h = hkl[0]; - double k = hkl[1]; - double l = hkl[2]; - - return (hkl2 == V3D(h, k, l)) || (hkl2 == V3D(-h, -k, -l)) || - (hkl2 == V3D(-h, k, -l)) || (hkl2 == V3D(h, -k, l)); -} - -PointGroup::CrystalSystem PointGroupLaue2::crystalSystem() const { - return Monoclinic; -} - -void PointGroupLaue2::init() { - std::vector<SymmetryOperation> generatingSymmetryOperations; - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-x,y,-z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("x,-y,z")); - - setSymmetryOperations(generatingSymmetryOperations); -} - -PointGroupLaue3::PointGroupLaue3() : PointGroup("112/m") {} - -std::string PointGroupLaue3::getName() const { - return "1 1 2/m (Monoclinic, unique axis c)"; -} - -bool PointGroupLaue3::isEquivalent(const V3D &hkl, const V3D &hkl2) const { - double h = hkl[0]; - double k = hkl[1]; - double l = hkl[2]; - - return (hkl2 == V3D(h, k, l)) || (hkl2 == V3D(-h, -k, l)) || - (hkl2 == V3D(-h, -k, -l)) || (hkl2 == V3D(h, k, -l)); -} - -PointGroup::CrystalSystem PointGroupLaue3::crystalSystem() const { - return Monoclinic; -} - -void PointGroupLaue3::init() { - std::vector<SymmetryOperation> generatingSymmetryOperations; - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-x,-y,z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("x,y,-z")); - - setSymmetryOperations(generatingSymmetryOperations); -} - -PointGroupLaue4::PointGroupLaue4() : PointGroup("mmm") {} - -std::string PointGroupLaue4::getName() const { return "mmm (Orthorombic)"; } - -bool PointGroupLaue4::isEquivalent(const V3D &hkl, const V3D &hkl2) const { - double h = hkl[0]; - double k = hkl[1]; - double l = hkl[2]; - - return (hkl2 == V3D(h, k, l)) || (hkl2 == V3D(-h, -k, l)) || - (hkl2 == V3D(-h, k, -l)) || (hkl2 == V3D(h, -k, -l)) || - (hkl2 == V3D(-h, -k, -l)) || (hkl2 == V3D(h, k, -l)) || - (hkl2 == V3D(h, -k, l)) || (hkl2 == V3D(-h, k, l)); -} - -PointGroup::CrystalSystem PointGroupLaue4::crystalSystem() const { - return Orthorhombic; -} - -void PointGroupLaue4::init() { - std::vector<SymmetryOperation> generatingSymmetryOperations; - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("x,-y,-z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-x,y,-z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("x,y,-z")); - - setSymmetryOperations(generatingSymmetryOperations); -} - -PointGroupLaue5::PointGroupLaue5() : PointGroup("4/m") {} - -std::string PointGroupLaue5::getName() const { return "4/m (Tetragonal)"; } - -bool PointGroupLaue5::isEquivalent(const V3D &hkl, const V3D &hkl2) const { - double h = hkl[0]; - double k = hkl[1]; - double l = hkl[2]; - - return (hkl2 == V3D(h, k, l)) || (hkl2 == V3D(-h, -k, l)) || - (hkl2 == V3D(-k, h, l)) || (hkl2 == V3D(k, -h, l)) || - (hkl2 == V3D(-h, -k, -l)) || (hkl2 == V3D(h, k, -l)) || - (hkl2 == V3D(k, -h, -l)) || (hkl2 == V3D(-k, h, -l)); -} - -PointGroup::CrystalSystem PointGroupLaue5::crystalSystem() const { - return Tetragonal; -} - -void PointGroupLaue5::init() { - std::vector<SymmetryOperation> generatingSymmetryOperations; - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-y,x,z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("x,y,-z")); - - setSymmetryOperations(generatingSymmetryOperations); -} - -PointGroupLaue6::PointGroupLaue6() : PointGroup("4/mmm") {} - -std::string PointGroupLaue6::getName() const { return "4/mmm (Tetragonal)"; } - -bool PointGroupLaue6::isEquivalent(const V3D &hkl, const V3D &hkl2) const { - double h = hkl[0]; - double k = hkl[1]; - double l = hkl[2]; - - return (hkl2 == V3D(h, k, l)) || (hkl2 == V3D(-h, -k, l)) || - (hkl2 == V3D(-k, h, l)) || (hkl2 == V3D(k, -h, l)) || - (hkl2 == V3D(-h, k, -l)) || (hkl2 == V3D(h, -k, -l)) || - (hkl2 == V3D(k, h, -l)) || (hkl2 == V3D(-k, -h, -l)) || - (hkl2 == V3D(-h, -k, -l)) || (hkl2 == V3D(h, k, -l)) || - (hkl2 == V3D(k, -h, -l)) || (hkl2 == V3D(-k, h, -l)) || - (hkl2 == V3D(h, -k, l)) || (hkl2 == V3D(-h, k, l)) || - (hkl2 == V3D(-k, -h, l)) || (hkl2 == V3D(k, h, l)); -} - -PointGroup::CrystalSystem PointGroupLaue6::crystalSystem() const { - return Tetragonal; -} - -void PointGroupLaue6::init() { - std::vector<SymmetryOperation> generatingSymmetryOperations; - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-y,x,z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("x,y,-z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("x,-y,-z")); - - setSymmetryOperations(generatingSymmetryOperations); -} - -PointGroupLaue7::PointGroupLaue7() : PointGroup("-3") {} - -std::string PointGroupLaue7::getName() const { - return "-3 (Trigonal - Hexagonal)"; -} - -bool PointGroupLaue7::isEquivalent(const V3D &hkl, const V3D &hkl2) const { - double h = hkl[0]; - double k = hkl[1]; - double l = hkl[2]; - - return (hkl2 == V3D(h, k, l)) || (hkl2 == V3D(-k, h - k, l)) || - (hkl2 == V3D(-h + k, -h, l)) || (hkl2 == V3D(-h, -k, -l)) || - (hkl2 == V3D(k, -h + k, -l)) || (hkl2 == V3D(h - k, h, -l)); -} - -PointGroup::CrystalSystem PointGroupLaue7::crystalSystem() const { - return Trigonal; -} - -void PointGroupLaue7::init() { - std::vector<SymmetryOperation> generatingSymmetryOperations; - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-y,x-y,z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-x,-y,-z")); - - setSymmetryOperations(generatingSymmetryOperations); -} - -PointGroupLaue8::PointGroupLaue8() : PointGroup("-3m1") {} - -std::string PointGroupLaue8::getName() const { - return "-3m1 (Trigonal - Rhombohedral)"; -} - -bool PointGroupLaue8::isEquivalent(const V3D &hkl, const V3D &hkl2) const { - double h = hkl[0]; - double k = hkl[1]; - double l = hkl[2]; - - return (hkl2 == V3D(h, k, l)) || (hkl2 == V3D(-k, h - k, l)) || - (hkl2 == V3D(-h + k, -h, l)) || (hkl2 == V3D(-k, -h, -l)) || - (hkl2 == V3D(-h + k, k, -l)) || (hkl2 == V3D(h, h - k, -l)) || - (hkl2 == V3D(-h, -k, -l)) || (hkl2 == V3D(k, -h + k, -l)) || - (hkl2 == V3D(h - k, h, -l)) || (hkl2 == V3D(k, h, l)) || - (hkl2 == V3D(h - k, -k, l)) || (hkl2 == V3D(-h, -h + k, l)); -} - -PointGroup::CrystalSystem PointGroupLaue8::crystalSystem() const { - return Trigonal; -} - -void PointGroupLaue8::init() { - std::vector<SymmetryOperation> generatingSymmetryOperations; - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-y,x-y,z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-x,-y,-z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-x,y-x,z")); - - setSymmetryOperations(generatingSymmetryOperations); -} - -PointGroupLaue9::PointGroupLaue9() : PointGroup("-31m") {} - -std::string PointGroupLaue9::getName() const { - return "-31m (Trigonal - Rhombohedral)"; -} - -bool PointGroupLaue9::isEquivalent(const V3D &hkl, const V3D &hkl2) const { - double h = hkl[0]; - double k = hkl[1]; - double l = hkl[2]; - - return (hkl2 == V3D(h, k, l)) || (hkl2 == V3D(-k, h - k, l)) || - (hkl2 == V3D(-h + k, -h, l)) || (hkl2 == V3D(-k, -h, -l)) || - (hkl2 == V3D(-h + k, k, -l)) || (hkl2 == V3D(h, h - k, -l)) || - (hkl2 == V3D(-h, -k, -l)) || (hkl2 == V3D(k, -h + k, -l)) || - (hkl2 == V3D(h - k, h, -l)) || (hkl2 == V3D(k, h, l)) || - (hkl2 == V3D(h - k, -k, l)) || (hkl2 == V3D(-h, -h + k, l)); -} - -PointGroup::CrystalSystem PointGroupLaue9::crystalSystem() const { - return Trigonal; -} - -void PointGroupLaue9::init() { - std::vector<SymmetryOperation> generatingSymmetryOperations; - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-y,x-y,z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-x,-y,-z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-x,y-x,z")); - - setSymmetryOperations(generatingSymmetryOperations); -} - -PointGroupLaue10::PointGroupLaue10() : PointGroup("6/m") {} - -std::string PointGroupLaue10::getName() const { return "6/m (Hexagonal)"; } + std::sort(equivalents.begin(), equivalents.end()); -bool PointGroupLaue10::isEquivalent(const V3D &hkl, const V3D &hkl2) const { - double h = hkl[0]; - double k = hkl[1]; - double l = hkl[2]; + equivalents.erase(std::unique(equivalents.begin(), equivalents.end()), + equivalents.end()); - return (hkl2 == V3D(h, k, l)) || (hkl2 == V3D(-k, h - k, l)) || - (hkl2 == V3D(-h + k, -h, l)) || (hkl2 == V3D(-h, -k, l)) || - (hkl2 == V3D(k, -h + k, l)) || (hkl2 == V3D(h - k, h, l)) || - (hkl2 == V3D(-h, -k, -l)) || (hkl2 == V3D(k, -h + k, -l)) || - (hkl2 == V3D(h - k, h, -l)) || (hkl2 == V3D(h, k, -l)) || - (hkl2 == V3D(-k, h - k, -l)) || (hkl2 == V3D(-h + k, -h, -l)); -} - -PointGroup::CrystalSystem PointGroupLaue10::crystalSystem() const { - return Hexagonal; -} - -void PointGroupLaue10::init() { - std::vector<SymmetryOperation> generatingSymmetryOperations; - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("x-y,x,z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-x,-y,-z")); - - setSymmetryOperations(generatingSymmetryOperations); -} - -PointGroupLaue11::PointGroupLaue11() : PointGroup("6/mmm") {} - -std::string PointGroupLaue11::getName() const { return "6/mmm (Hexagonal)"; } - -bool PointGroupLaue11::isEquivalent(const V3D &hkl, const V3D &hkl2) const { - double h = hkl[0]; - double k = hkl[1]; - double l = hkl[2]; - - return (hkl2 == V3D(h, k, l)) || (hkl2 == V3D(-k, h - k, l)) || - (hkl2 == V3D(-h + k, -h, l)) || (hkl2 == V3D(-h, -k, l)) || - (hkl2 == V3D(k, -h + k, l)) || (hkl2 == V3D(h - k, h, l)) || - (hkl2 == V3D(k, h, -l)) || (hkl2 == V3D(h - k, -k, -l)) || - (hkl2 == V3D(-h, -h + k, -l)) || (hkl2 == V3D(-k, -h, -l)) || - (hkl2 == V3D(-h + k, k, -l)) || (hkl2 == V3D(h, h - k, -l)) || - (hkl2 == V3D(-h, -k, -l)) || (hkl2 == V3D(k, -h + k, -l)) || - (hkl2 == V3D(h - k, h, -l)) || (hkl2 == V3D(h, k, -l)) || - (hkl2 == V3D(-k, h - k, -l)) || (hkl2 == V3D(-h + k, -h, -l)) || - (hkl2 == V3D(-k, -h, l)) || (hkl2 == V3D(-h + k, k, l)) || - (hkl2 == V3D(h, h - k, l)) || (hkl2 == V3D(k, h, l)) || - (hkl2 == V3D(h - k, -k, l)) || (hkl2 == V3D(-h, -h + k, l)); -} - -PointGroup::CrystalSystem PointGroupLaue11::crystalSystem() const { - return Hexagonal; -} - -void PointGroupLaue11::init() { - std::vector<SymmetryOperation> generatingSymmetryOperations; - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("x-y,x,z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("x-y,-y,-z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("x,y,-z")); - - setSymmetryOperations(generatingSymmetryOperations); -} - -PointGroupLaue12::PointGroupLaue12() : PointGroup("m-3") {} - -std::string PointGroupLaue12::getName() const { return "m-3 (Cubic)"; } - -bool PointGroupLaue12::isEquivalent(const V3D &hkl, const V3D &hkl2) const { - double h = hkl[0]; - double k = hkl[1]; - double l = hkl[2]; - - return (hkl2 == V3D(h, k, l)) || (hkl2 == V3D(-h, -k, l)) || - (hkl2 == V3D(-h, k, -l)) || (hkl2 == V3D(h, -k, -l)) || - (hkl2 == V3D(l, h, k)) || (hkl2 == V3D(l, -h, -k)) || - (hkl2 == V3D(-l, -h, k)) || (hkl2 == V3D(-l, h, -k)) || - (hkl2 == V3D(k, l, h)) || (hkl2 == V3D(-k, l, -h)) || - (hkl2 == V3D(k, -l, -h)) || (hkl2 == V3D(-k, -l, h)) || - (hkl2 == V3D(-h, -k, -l)) || (hkl2 == V3D(h, k, -l)) || - (hkl2 == V3D(h, -k, l)) || (hkl2 == V3D(-h, k, l)) || - (hkl2 == V3D(-l, -h, -k)) || (hkl2 == V3D(-l, h, k)) || - (hkl2 == V3D(l, h, -k)) || (hkl2 == V3D(l, -h, k)) || - (hkl2 == V3D(-k, -l, -h)) || (hkl2 == V3D(k, -l, h)) || - (hkl2 == V3D(-k, l, h)) || (hkl2 == V3D(k, l, -h)); -} - -PointGroup::CrystalSystem PointGroupLaue12::crystalSystem() const { - return Cubic; -} - -void PointGroupLaue12::init() { - std::vector<SymmetryOperation> generatingSymmetryOperations; - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("z,x,y")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-x,-y,z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("x,-y,z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-x,-y,-z")); - - setSymmetryOperations(generatingSymmetryOperations); + return equivalents; } -PointGroupLaue13::PointGroupLaue13() : PointGroup("m-3m") {} - -std::string PointGroupLaue13::getName() const { return "m-3m (Cubic)"; } - -bool PointGroupLaue13::isEquivalent(const V3D &hkl, const V3D &hkl2) const { - double h = hkl[0]; - double k = hkl[1]; - double l = hkl[2]; - - return (hkl2 == V3D(h, k, l)) || (hkl2 == V3D(-h, -k, l)) || - (hkl2 == V3D(-h, k, -l)) || (hkl2 == V3D(h, -k, -l)) || - (hkl2 == V3D(l, h, k)) || (hkl2 == V3D(l, -h, -k)) || - (hkl2 == V3D(-l, -h, k)) || (hkl2 == V3D(-l, h, -k)) || - (hkl2 == V3D(k, l, h)) || (hkl2 == V3D(-k, l, -h)) || - (hkl2 == V3D(k, -l, -h)) || (hkl2 == V3D(-k, -l, h)) || - (hkl2 == V3D(k, h, -l)) || (hkl2 == V3D(-k, -h, -l)) || - (hkl2 == V3D(k, -h, l)) || (hkl2 == V3D(-k, h, l)) || - (hkl2 == V3D(h, l, -k)) || (hkl2 == V3D(-h, l, k)) || - (hkl2 == V3D(-h, -l, -k)) || (hkl2 == V3D(h, -l, k)) || - (hkl2 == V3D(l, k, -h)) || (hkl2 == V3D(l, -k, h)) || - (hkl2 == V3D(-l, k, h)) || (hkl2 == V3D(-l, -k, -h)) || - (hkl2 == V3D(-h, -k, -l)) || (hkl2 == V3D(h, k, -l)) || - (hkl2 == V3D(h, -k, l)) || (hkl2 == V3D(-h, k, l)) || - (hkl2 == V3D(-l, -h, -k)) || (hkl2 == V3D(-l, h, k)) || - (hkl2 == V3D(l, h, -k)) || (hkl2 == V3D(l, -h, k)) || - (hkl2 == V3D(-k, -l, -h)) || (hkl2 == V3D(k, -l, h)) || - (hkl2 == V3D(-k, l, h)) || (hkl2 == V3D(k, l, -h)) || - (hkl2 == V3D(-k, -h, l)) || (hkl2 == V3D(k, h, l)) || - (hkl2 == V3D(-k, h, -l)) || (hkl2 == V3D(k, -h, -l)) || - (hkl2 == V3D(-h, -l, k)) || (hkl2 == V3D(h, -l, -k)) || - (hkl2 == V3D(h, l, k)) || (hkl2 == V3D(-h, l, -k)) || - (hkl2 == V3D(-l, -k, h)) || (hkl2 == V3D(-l, k, -h)) || - (hkl2 == V3D(l, -k, -h)) || (hkl2 == V3D(l, k, h)); -} +void PointGroup::createPermutationsFromOperations() { + m_permutations.clear(); -PointGroup::CrystalSystem PointGroupLaue13::crystalSystem() const { - return Cubic; + const std::vector<SymmetryOperation> &symOps = getSymmetryOperations(); + for (auto op = symOps.begin(); op != symOps.end(); ++op) { + m_permutations.push_back((*op).matrix()); + } } -void PointGroupLaue13::init() { - std::vector<SymmetryOperation> generatingSymmetryOperations; - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("z,x,y")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-y,x,z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("x,-y,z")); - generatingSymmetryOperations.push_back( - SymmetryOperationFactory::Instance().createSymOp("-x,-y,-z")); - - setSymmetryOperations(generatingSymmetryOperations); -} -*/ /** @return a vector with all possible PointGroup objects */ std::vector<PointGroup_sptr> getAllPointGroups() { std::vector<std::string> allSymbols = @@ -585,20 +162,5 @@ PointGroupCrystalSystemMap getPointGroupsByCrystalSystem() { return map; } -/* -DECLARE_POINTGROUP(PointGroupLaue1) -DECLARE_POINTGROUP(PointGroupLaue2) -DECLARE_POINTGROUP(PointGroupLaue3) -DECLARE_POINTGROUP(PointGroupLaue4) -DECLARE_POINTGROUP(PointGroupLaue5) -DECLARE_POINTGROUP(PointGroupLaue6) -DECLARE_POINTGROUP(PointGroupLaue7) -DECLARE_POINTGROUP(PointGroupLaue8) -DECLARE_POINTGROUP(PointGroupLaue9) -DECLARE_POINTGROUP(PointGroupLaue10) -DECLARE_POINTGROUP(PointGroupLaue11) -DECLARE_POINTGROUP(PointGroupLaue12) -DECLARE_POINTGROUP(PointGroupLaue13) -*/ } // namespace Mantid } // namespace Geometry -- GitLab