diff --git a/Code/Mantid/Framework/Geometry/CMakeLists.txt b/Code/Mantid/Framework/Geometry/CMakeLists.txt index e4aa2703bb51..b5912ee54042 100644 --- a/Code/Mantid/Framework/Geometry/CMakeLists.txt +++ b/Code/Mantid/Framework/Geometry/CMakeLists.txt @@ -5,13 +5,13 @@ set ( SRC_FILES src/Crystal/IndexingUtils.cpp src/Crystal/NiggliCell.cpp src/Crystal/OrientedLattice.cpp - src/Crystal/SymmetryOperation.cpp - src/Crystal/SymmetryOperationFactory.cpp src/Crystal/PointGroup.cpp src/Crystal/PointGroupFactory.cpp src/Crystal/ReducedCell.cpp src/Crystal/ReflectionCondition.cpp src/Crystal/ScalarUtils.cpp + src/Crystal/SymmetryOperation.cpp + src/Crystal/SymmetryOperationFactory.cpp src/Crystal/UnitCell.cpp src/IObjComponent.cpp src/Instrument.cpp @@ -108,13 +108,13 @@ set ( INC_FILES inc/MantidGeometry/Crystal/IndexingUtils.h inc/MantidGeometry/Crystal/NiggliCell.h inc/MantidGeometry/Crystal/OrientedLattice.h - inc/MantidGeometry/Crystal/SymmetryOperation.h - inc/MantidGeometry/Crystal/SymmetryOperationFactory.h inc/MantidGeometry/Crystal/PointGroup.h inc/MantidGeometry/Crystal/PointGroupFactory.h inc/MantidGeometry/Crystal/ReducedCell.h inc/MantidGeometry/Crystal/ReflectionCondition.h inc/MantidGeometry/Crystal/ScalarUtils.h + inc/MantidGeometry/Crystal/SymmetryOperation.h + inc/MantidGeometry/Crystal/SymmetryOperationFactory.h inc/MantidGeometry/Crystal/UnitCell.h inc/MantidGeometry/DllConfig.h inc/MantidGeometry/ICompAssembly.h diff --git a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h index 307cd7398e73..2d32c5e97421 100644 --- a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h +++ b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h @@ -51,6 +51,9 @@ namespace Geometry /// Returns the same hkl for all equivalent hkls Kernel::V3D getReflectionFamily(const Kernel::V3D &hkl) const; + /// In this method symmetry operations should be defined. It's called by the factory after construction of the object. + virtual void init() = 0; + protected: PointGroup(const std::string &symbolHM); @@ -78,6 +81,8 @@ namespace Geometry /// 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(); }; //------------------------------------------------------------------------ @@ -91,6 +96,8 @@ namespace Geometry /// 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(); }; //------------------------------------------------------------------------ @@ -104,6 +111,8 @@ namespace Geometry /// 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(); }; //------------------------------------------------------------------------ @@ -117,6 +126,8 @@ namespace Geometry /// 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(); }; //------------------------------------------------------------------------ @@ -130,6 +141,8 @@ namespace Geometry /// 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(); }; //------------------------------------------------------------------------ @@ -143,6 +156,8 @@ namespace Geometry /// 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(); }; //------------------------------------------------------------------------ @@ -156,6 +171,8 @@ namespace Geometry /// 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(); }; //------------------------------------------------------------------------ @@ -169,6 +186,8 @@ namespace Geometry /// 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(); }; //------------------------------------------------------------------------ @@ -182,6 +201,8 @@ namespace Geometry /// 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(); }; //------------------------------------------------------------------------ @@ -195,6 +216,8 @@ namespace Geometry /// 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(); }; //------------------------------------------------------------------------ @@ -208,6 +231,8 @@ namespace Geometry /// 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(); }; //------------------------------------------------------------------------ @@ -221,6 +246,8 @@ namespace Geometry /// 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(); }; //------------------------------------------------------------------------ @@ -234,6 +261,8 @@ namespace Geometry /// 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(); }; diff --git a/Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp b/Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp index 8da40298559e..55daf2b02f6b 100644 --- a/Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp +++ b/Code/Mantid/Framework/Geometry/src/Crystal/PointGroup.cpp @@ -161,11 +161,7 @@ namespace Geometry PointGroupLaue1::PointGroupLaue1() : PointGroup("-1") - { - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("-1")); - - setTransformationMatrices(generateTransformationMatrices(getSymmetryOperations())); - } + { } std::string PointGroupLaue1::getName() const { @@ -186,15 +182,17 @@ namespace Geometry return Triclinic; } - PointGroupLaue2::PointGroupLaue2() : - PointGroup("2/m") + void PointGroupLaue1::init() { - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("2 [010]")); - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("m [010]")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("-1")); setTransformationMatrices(generateTransformationMatrices(getSymmetryOperations())); } + PointGroupLaue2::PointGroupLaue2() : + PointGroup("2/m") + { } + std::string PointGroupLaue2::getName() const { return "1 2/m 1 (Monoclinic, unique axis b)"; @@ -214,15 +212,18 @@ namespace Geometry return Monoclinic; } - PointGroupLaue3::PointGroupLaue3() : - PointGroup("112/m") + void PointGroupLaue2::init() { - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("2 [001]")); - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("m [001]")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("2 [010]")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("m [010]")); setTransformationMatrices(generateTransformationMatrices(getSymmetryOperations())); } + PointGroupLaue3::PointGroupLaue3() : + PointGroup("112/m") + { } + std::string PointGroupLaue3::getName() const { return "1 1 2/m (Monoclinic, unique axis c)"; @@ -242,16 +243,18 @@ namespace Geometry return Monoclinic; } - PointGroupLaue4::PointGroupLaue4() : - PointGroup("mmm") + void PointGroupLaue3::init() { - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("2 [100]")); - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("2 [010]")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("2 [001]")); addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("m [001]")); setTransformationMatrices(generateTransformationMatrices(getSymmetryOperations())); } + PointGroupLaue4::PointGroupLaue4() : + PointGroup("mmm") + { } + std::string PointGroupLaue4::getName() const { return "mmm (Orthorombic)"; @@ -273,15 +276,19 @@ namespace Geometry return Orthorhombic; } - PointGroupLaue5::PointGroupLaue5() : - PointGroup("4/m") + void PointGroupLaue4::init() { - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("4 [001]")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("2 [100]")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("2 [010]")); addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("m [001]")); setTransformationMatrices(generateTransformationMatrices(getSymmetryOperations())); } + PointGroupLaue5::PointGroupLaue5() : + PointGroup("4/m") + { } + std::string PointGroupLaue5::getName() const { return "4/m (Tetragonal)"; @@ -303,16 +310,18 @@ namespace Geometry return Tetragonal; } - PointGroupLaue6::PointGroupLaue6() : - PointGroup("4/mmm") + void PointGroupLaue5::init() { addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("4 [001]")); addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("m [001]")); - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("2 [100]")); setTransformationMatrices(generateTransformationMatrices(getSymmetryOperations())); } + PointGroupLaue6::PointGroupLaue6() : + PointGroup("4/mmm") + { } + std::string PointGroupLaue6::getName() const { return "4/mmm (Tetragonal)"; @@ -337,15 +346,19 @@ namespace Geometry return Tetragonal; } - PointGroupLaue7::PointGroupLaue7() : - PointGroup("-3") + void PointGroupLaue6::init() { - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("3 [001]h")); - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("-1")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("4 [001]")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("m [001]")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("2 [100]")); setTransformationMatrices(generateTransformationMatrices(getSymmetryOperations())); } + PointGroupLaue7::PointGroupLaue7() : + PointGroup("-3") + { } + std::string PointGroupLaue7::getName() const { return "-3 (Trigonal - Hexagonal)"; @@ -366,16 +379,18 @@ namespace Geometry return Trigonal; } - PointGroupLaue8::PointGroupLaue8() : - PointGroup("-3m1") + void PointGroupLaue7::init() { addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("3 [001]h")); addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("-1")); - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("m [210]h")); setTransformationMatrices(generateTransformationMatrices(getSymmetryOperations())); } + PointGroupLaue8::PointGroupLaue8() : + PointGroup("-3m1") + { } + std::string PointGroupLaue8::getName() const { return "-3m1 (Trigonal - Rhombohedral)"; @@ -398,8 +413,7 @@ namespace Geometry return Trigonal; } - PointGroupLaue9::PointGroupLaue9() : - PointGroup("-31m") + void PointGroupLaue8::init() { addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("3 [001]h")); addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("-1")); @@ -408,6 +422,10 @@ namespace Geometry setTransformationMatrices(generateTransformationMatrices(getSymmetryOperations())); } + PointGroupLaue9::PointGroupLaue9() : + PointGroup("-31m") + { } + std::string PointGroupLaue9::getName() const { return "-31m (Trigonal - Rhombohedral)"; @@ -430,15 +448,19 @@ namespace Geometry return Trigonal; } - PointGroupLaue10::PointGroupLaue10() : - PointGroup("6/m") + void PointGroupLaue9::init() { - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("6 [001]h")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("3 [001]h")); addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("-1")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("m [210]h")); setTransformationMatrices(generateTransformationMatrices(getSymmetryOperations())); } + PointGroupLaue10::PointGroupLaue10() : + PointGroup("6/m") + { } + std::string PointGroupLaue10::getName() const { return "6/m (Hexagonal)"; @@ -461,16 +483,18 @@ namespace Geometry return Hexagonal; } - PointGroupLaue11::PointGroupLaue11() : - PointGroup("6/mmm") + void PointGroupLaue10::init() { addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("6 [001]h")); - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("2 [100]h")); - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("m [001]")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("-1")); setTransformationMatrices(generateTransformationMatrices(getSymmetryOperations())); } + PointGroupLaue11::PointGroupLaue11() : + PointGroup("6/mmm") + { } + std::string PointGroupLaue11::getName() const { return "6/mmm (Hexagonal)"; @@ -497,17 +521,19 @@ namespace Geometry return Hexagonal; } - PointGroupLaue12::PointGroupLaue12() : - PointGroup("m-3") + void PointGroupLaue11::init() { - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("3 [111]")); - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("2 [001]")); - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("m [010]")); - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("-1")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("6 [001]h")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("2 [100]h")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("m [001]")); setTransformationMatrices(generateTransformationMatrices(getSymmetryOperations())); } + PointGroupLaue12::PointGroupLaue12() : + PointGroup("m-3") + { } + std::string PointGroupLaue12::getName() const { return "m-3 (Cubic)"; @@ -534,17 +560,20 @@ namespace Geometry return Cubic; } - PointGroupLaue13::PointGroupLaue13() : - PointGroup("m-3m") + void PointGroupLaue12::init() { addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("3 [111]")); - addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("4 [001]")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("2 [001]")); addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("m [010]")); addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("-1")); setTransformationMatrices(generateTransformationMatrices(getSymmetryOperations())); } + PointGroupLaue13::PointGroupLaue13() : + PointGroup("m-3m") + { } + std::string PointGroupLaue13::getName() const { return "m-3m (Cubic)"; @@ -579,6 +608,16 @@ namespace Geometry return Cubic; } + void PointGroupLaue13::init() + { + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("3 [111]")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("4 [001]")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("m [010]")); + addSymmetryOperation(SymmetryOperationFactory::Instance().createSymOp("-1")); + + setTransformationMatrices(generateTransformationMatrices(getSymmetryOperations())); + } + /** @return a vector with all possible PointGroup objects */ std::vector getAllPointGroups() { diff --git a/Code/Mantid/Framework/Geometry/src/Crystal/PointGroupFactory.cpp b/Code/Mantid/Framework/Geometry/src/Crystal/PointGroupFactory.cpp index 3b5fd78812fa..c3adf455d6f3 100644 --- a/Code/Mantid/Framework/Geometry/src/Crystal/PointGroupFactory.cpp +++ b/Code/Mantid/Framework/Geometry/src/Crystal/PointGroupFactory.cpp @@ -10,7 +10,10 @@ namespace Geometry /// Creates a PointGroup object from its Hermann-Mauguin symbol. PointGroup_sptr PointGroupFactoryImpl::createPointGroup(const std::string &hmSymbol) const { - return create(hmSymbol); + PointGroup_sptr pointGroup = create(hmSymbol); + pointGroup->init(); + + return pointGroup; } /// Returns the Hermann-Mauguin symbols of all registered point groups. diff --git a/Code/Mantid/Framework/Geometry/test/PointGroupFactoryTest.h b/Code/Mantid/Framework/Geometry/test/PointGroupFactoryTest.h index 22979bf4b8f1..c4a4fd000735 100644 --- a/Code/Mantid/Framework/Geometry/test/PointGroupFactoryTest.h +++ b/Code/Mantid/Framework/Geometry/test/PointGroupFactoryTest.h @@ -35,6 +35,8 @@ class TestPointGroupCubicA : public PointGroup } PointGroup::CrystalSystem crystalSystem() const { return PointGroup::Cubic; } + + void init() { } }; class TestPointGroupCubicB : public PointGroup @@ -54,6 +56,8 @@ class TestPointGroupCubicB : public PointGroup } PointGroup::CrystalSystem crystalSystem() const { return PointGroup::Cubic; } + + void init() { } }; class TestPointGroupTriclinic : public PointGroup @@ -73,6 +77,8 @@ class TestPointGroupTriclinic : public PointGroup } PointGroup::CrystalSystem crystalSystem() const { return PointGroup::Triclinic; } + + void init() { } }; class PointGroupFactoryTest : public CxxTest::TestSuite diff --git a/Code/Mantid/Framework/Geometry/test/PointGroupTest.h b/Code/Mantid/Framework/Geometry/test/PointGroupTest.h index a3a1fa96d94b..fb89c74344f7 100644 --- a/Code/Mantid/Framework/Geometry/test/PointGroupTest.h +++ b/Code/Mantid/Framework/Geometry/test/PointGroupTest.h @@ -218,6 +218,17 @@ class PointGroupTest : public CxxTest::TestSuite TS_ASSERT_EQUALS(pgMap.count(PointGroup::Cubic), 2); } + void testInit() + { + PointGroupLaue13 pg; + + TS_ASSERT_EQUALS(pg.getEquivalents(V3D(1, 2, 3)).size(), 1); + + pg.init(); + + TS_ASSERT_EQUALS(pg.getEquivalents(V3D(1, 2, 3)).size(), 48); + } + private: class TestablePointGroup : public PointGroup { @@ -231,6 +242,8 @@ class PointGroupTest : public CxxTest::TestSuite MOCK_CONST_METHOD0(getName, std::string()); MOCK_CONST_METHOD2(isEquivalent, bool(const V3D &hkl, const V3D &hkl2)); MOCK_CONST_METHOD0(crystalSystem, PointGroup::CrystalSystem()); + + void init() { } }; };