diff --git a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h index 1f29aabb2b0b45fe731639fa799a88fd28befac2..8148492506f7e6c708eb2d328cb518219068659d 100644 --- a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h +++ b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h @@ -25,11 +25,22 @@ namespace Geometry class MANTID_GEOMETRY_DLL PointGroup { public: + enum CrystalSystem { + Triclinic, + Monoclinic, + Orthorhombic, + Tetragonal, + Hexagonal, + Trigonal, + Cubic + }; + virtual ~PointGroup() {} /// Name of the point group virtual std::string getName() = 0; /// Return true if the hkls are in same group virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2) = 0; + virtual CrystalSystem crystalSystem() const = 0; /// Returns a vector with all equivalent hkls std::vector<Kernel::V3D> getEquivalents(const Kernel::V3D &hkl) const; @@ -61,6 +72,7 @@ namespace Geometry virtual std::string getName(); /// Return true if the hkls are equivalent. virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2); + virtual PointGroup::CrystalSystem crystalSystem() const; }; //------------------------------------------------------------------------ @@ -73,6 +85,7 @@ namespace Geometry virtual std::string getName(); /// Return true if the hkls are equivalent. virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2); + virtual PointGroup::CrystalSystem crystalSystem() const; }; //------------------------------------------------------------------------ @@ -85,6 +98,7 @@ namespace Geometry virtual std::string getName(); /// Return true if the hkls are equivalent. virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2); + virtual PointGroup::CrystalSystem crystalSystem() const; }; //------------------------------------------------------------------------ @@ -97,6 +111,7 @@ namespace Geometry virtual std::string getName(); /// Return true if the hkls are equivalent. virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2); + virtual PointGroup::CrystalSystem crystalSystem() const; }; //------------------------------------------------------------------------ @@ -109,6 +124,7 @@ namespace Geometry virtual std::string getName(); /// Return true if the hkls are equivalent. virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2); + virtual PointGroup::CrystalSystem crystalSystem() const; }; //------------------------------------------------------------------------ @@ -121,6 +137,7 @@ namespace Geometry virtual std::string getName(); /// Return true if the hkls are equivalent. virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2); + virtual PointGroup::CrystalSystem crystalSystem() const; }; //------------------------------------------------------------------------ @@ -133,6 +150,7 @@ namespace Geometry virtual std::string getName(); /// Return true if the hkls are equivalent. virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2); + virtual PointGroup::CrystalSystem crystalSystem() const; }; //------------------------------------------------------------------------ @@ -145,6 +163,7 @@ namespace Geometry virtual std::string getName(); /// Return true if the hkls are equivalent. virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2); + virtual PointGroup::CrystalSystem crystalSystem() const; }; //------------------------------------------------------------------------ @@ -157,6 +176,7 @@ namespace Geometry virtual std::string getName(); /// Return true if the hkls are equivalent. virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2); + virtual PointGroup::CrystalSystem crystalSystem() const; }; //------------------------------------------------------------------------ @@ -169,6 +189,7 @@ namespace Geometry virtual std::string getName(); /// Return true if the hkls are equivalent. virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2); + virtual PointGroup::CrystalSystem crystalSystem() const; }; //------------------------------------------------------------------------ @@ -181,6 +202,7 @@ namespace Geometry virtual std::string getName(); /// Return true if the hkls are equivalent. virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2); + virtual PointGroup::CrystalSystem crystalSystem() const; }; //------------------------------------------------------------------------ @@ -193,6 +215,7 @@ namespace Geometry virtual std::string getName(); /// Return true if the hkls are equivalent. virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2); + virtual PointGroup::CrystalSystem crystalSystem() const; }; //------------------------------------------------------------------------ @@ -205,6 +228,7 @@ namespace Geometry virtual std::string getName(); /// Return true if the hkls are equivalent. virtual bool isEquivalent(Kernel::V3D hkl, Kernel::V3D hkl2); + virtual PointGroup::CrystalSystem crystalSystem() const; }; @@ -213,6 +237,11 @@ namespace Geometry MANTID_GEOMETRY_DLL std::vector<PointGroup_sptr> getAllPointGroups(); + typedef std::multimap<PointGroup::CrystalSystem, PointGroup_sptr> PointGroupCrystalSystemMap; + MANTID_GEOMETRY_DLL PointGroupCrystalSystemMap getPointGroupsByCrystalSystem(); + + + } // namespace Mantid } // namespace Geometry diff --git a/Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp b/Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp index db82f8e36f38838ebcb8b735165bd496b4225887..c243de7813e7603d2d73501e1dcde1177962ae56 100644 --- a/Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp +++ b/Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp @@ -169,6 +169,11 @@ namespace Geometry return (hkl2 == V3D(h,k,l)) || (hkl2 == V3D(-h,-k,-l)); } + PointGroup::CrystalSystem PointGroupLaue1::crystalSystem() const + { + return Triclinic; + } + PointGroupLaue2::PointGroupLaue2() { addSymmetryOperation(boost::make_shared<const SymOpRotationTwoFoldY>()); @@ -191,6 +196,11 @@ namespace Geometry 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; + } + PointGroupLaue3::PointGroupLaue3() { addSymmetryOperation(boost::make_shared<const SymOpRotationTwoFoldZ>()); @@ -213,6 +223,11 @@ namespace Geometry 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; + } + PointGroupLaue4::PointGroupLaue4() { addSymmetryOperation(boost::make_shared<const SymOpRotationTwoFoldX>()); @@ -238,6 +253,11 @@ namespace Geometry || (hkl2 == V3D(h,-k,l)) || (hkl2 == V3D(-h,k,l)); } + PointGroup::CrystalSystem PointGroupLaue4::crystalSystem() const + { + return Orthorhombic; + } + PointGroupLaue5::PointGroupLaue5() { addSymmetryOperation(boost::make_shared<const SymOpRotationFourFoldZ>()); @@ -262,6 +282,11 @@ namespace Geometry || (hkl2 == V3D(k,-h,-l)) || (hkl2 == V3D(-k,h,-l)); } + PointGroup::CrystalSystem PointGroupLaue5::crystalSystem() const + { + return Tetragonal; + } + PointGroupLaue6::PointGroupLaue6() { addSymmetryOperation(boost::make_shared<const SymOpRotationFourFoldZ>()); @@ -290,6 +315,11 @@ namespace Geometry || (hkl2 == V3D(k,h,l)); } + PointGroup::CrystalSystem PointGroupLaue6::crystalSystem() const + { + return Tetragonal; + } + PointGroupLaue7::PointGroupLaue7() { addSymmetryOperation(boost::make_shared<const SymOpRotationThreeFoldZHexagonal>()); @@ -313,6 +343,11 @@ namespace Geometry || (hkl2 == V3D(-h,-k,-l)) || (hkl2 == V3D(k,-h+k,-l)) || (hkl2 == V3D(h-k,h,-l)); } + PointGroup::CrystalSystem PointGroupLaue7::crystalSystem() const + { + return Trigonal; + } + PointGroupLaue8::PointGroupLaue8() { addSymmetryOperation(boost::make_shared<const SymOpRotationThreeFoldZHexagonal>()); @@ -339,6 +374,11 @@ namespace Geometry || (hkl2 == V3D(k,h,l)) || (hkl2 == V3D(h-k,-k,l)) || (hkl2 == V3D(-h,-h+k,l)); } + PointGroup::CrystalSystem PointGroupLaue8::crystalSystem() const + { + return Trigonal; + } + PointGroupLaue9::PointGroupLaue9() { addSymmetryOperation(boost::make_shared<const SymOpRotationThreeFoldZHexagonal>()); @@ -365,6 +405,11 @@ namespace Geometry || (hkl2 == V3D(k,h,l)) || (hkl2 == V3D(h-k,-k,l)) || (hkl2 == V3D(-h,-h+k,l)); } + PointGroup::CrystalSystem PointGroupLaue9::crystalSystem() const + { + return Trigonal; + } + PointGroupLaue10::PointGroupLaue10() { addSymmetryOperation(boost::make_shared<const SymOpRotationSixFoldZHexagonal>()); @@ -390,6 +435,11 @@ namespace Geometry || (hkl2 == V3D(h,k,-l)) || (hkl2 == V3D(-k,h-k,-l)) || (hkl2 == V3D(-h+k,-h,-l)); } + PointGroup::CrystalSystem PointGroupLaue10::crystalSystem() const + { + return Hexagonal; + } + PointGroupLaue11::PointGroupLaue11() { addSymmetryOperation(boost::make_shared<const SymOpRotationSixFoldZHexagonal>()); @@ -420,6 +470,11 @@ namespace Geometry || (hkl2 == V3D(k,h,l)) || (hkl2 == V3D(h-k,-k,l)) || (hkl2 == V3D(-h,-h+k,l)); } + PointGroup::CrystalSystem PointGroupLaue11::crystalSystem() const + { + return Hexagonal; + } + PointGroupLaue12::PointGroupLaue12() { addSymmetryOperation(boost::make_shared<const SymOpRotationThreeFold111>()); @@ -451,6 +506,11 @@ namespace Geometry || (hkl2 == V3D(k,-l,h)) || (hkl2 == V3D(-k,l,h)) || (hkl2 == V3D(k,l,-h)); } + PointGroup::CrystalSystem PointGroupLaue12::crystalSystem() const + { + return Cubic; + } + PointGroupLaue13::PointGroupLaue13() { addSymmetryOperation(boost::make_shared<const SymOpRotationThreeFold111>()); @@ -490,6 +550,11 @@ namespace Geometry || (hkl2 == V3D(-l,k,-h)) || (hkl2 == V3D(l,-k,-h)) || (hkl2 == V3D(l,k,h)); } + PointGroup::CrystalSystem PointGroupLaue13::crystalSystem() const + { + return Cubic; + } + /** @return a vector with all possible PointGroup objects */ std::vector<PointGroup_sptr> getAllPointGroups() { @@ -510,6 +575,18 @@ namespace Geometry return out; } + PointGroupCrystalSystemMap getPointGroupsByCrystalSystem() + { + PointGroupCrystalSystemMap map; + + std::vector<PointGroup_sptr> pointGroups = getAllPointGroups(); + for(size_t i = 0; i < pointGroups.size(); ++i) { + map.insert(std::make_pair(pointGroups[i]->crystalSystem(), pointGroups[i])); + } + + return map; + } + } // namespace Mantid diff --git a/Code/Mantid/Framework/Geometry/test/PointGroupTest.h b/Code/Mantid/Framework/Geometry/test/PointGroupTest.h index 6967b29ec58a63e461e45ed7ecc168fbef5df443..ffab380daf0a672eb85638f35bec60eaf934c8ab 100644 --- a/Code/Mantid/Framework/Geometry/test/PointGroupTest.h +++ b/Code/Mantid/Framework/Geometry/test/PointGroupTest.h @@ -182,6 +182,46 @@ public: TS_ASSERT_DIFFERS(matrices[0], matrices[1]); } + void testCrystalSystems() + { + std::map<std::string, PointGroup::CrystalSystem> crystalSystemsMap; + crystalSystemsMap["-1 (Triclinic)"] = PointGroup::Triclinic; + crystalSystemsMap["1 2/m 1 (Monoclinic, unique axis b)"] = PointGroup::Monoclinic; + crystalSystemsMap["1 1 2/m (Monoclinic, unique axis c)"] = PointGroup::Monoclinic; + crystalSystemsMap["mmm (Orthorombic)"] = PointGroup::Orthorhombic; + crystalSystemsMap["4/m (Tetragonal)"] = PointGroup::Tetragonal; + crystalSystemsMap["4/mmm (Tetragonal)"] = PointGroup::Tetragonal; + crystalSystemsMap["-3 (Trigonal - Hexagonal)"] = PointGroup::Trigonal; + crystalSystemsMap["-3m1 (Trigonal - Rhombohedral)"] = PointGroup::Trigonal; + crystalSystemsMap["-31m (Trigonal - Rhombohedral)"] = PointGroup::Trigonal; + crystalSystemsMap["6/m (Hexagonal)"] = PointGroup::Hexagonal; + crystalSystemsMap["6/mmm (Hexagonal)"] = PointGroup::Hexagonal; + crystalSystemsMap["m-3 (Cubic)"] = PointGroup::Cubic; + crystalSystemsMap["m-3m (Cubic)"] = PointGroup::Cubic; + + std::vector<PointGroup_sptr> pointgroups = getAllPointGroups(); + + for(size_t i = 0; i < pointgroups.size(); ++i) { + TSM_ASSERT_EQUALS(pointgroups[i]->getName() + ": Unexpected crystal system.", pointgroups[i]->crystalSystem(), crystalSystemsMap[pointgroups[i]->getName()]); + } + } + + void testCrystalSystemMap() + { + std::vector<PointGroup_sptr> pointgroups = getAllPointGroups(); + PointGroupCrystalSystemMap pgMap = getPointGroupsByCrystalSystem(); + + TS_ASSERT_EQUALS(pointgroups.size(), pgMap.size()); + + TS_ASSERT_EQUALS(pgMap.count(PointGroup::Triclinic), 1); + TS_ASSERT_EQUALS(pgMap.count(PointGroup::Monoclinic), 2); + TS_ASSERT_EQUALS(pgMap.count(PointGroup::Orthorhombic), 1); + TS_ASSERT_EQUALS(pgMap.count(PointGroup::Tetragonal), 2); + TS_ASSERT_EQUALS(pgMap.count(PointGroup::Trigonal), 3); + TS_ASSERT_EQUALS(pgMap.count(PointGroup::Hexagonal), 2); + TS_ASSERT_EQUALS(pgMap.count(PointGroup::Cubic), 2); + } + private: class TestablePointGroup : public PointGroup { @@ -194,6 +234,7 @@ private: MOCK_METHOD0(getName, std::string()); MOCK_METHOD2(isEquivalent, bool(V3D hkl, V3D hkl2)); + MOCK_CONST_METHOD0(crystalSystem, PointGroup::CrystalSystem()); }; };