Skip to content

Commit

Permalink
Merge pull request #341 from mantidproject/11006_refactor_point_group
Browse files Browse the repository at this point in the history
Refactor point group to use Group
  • Loading branch information
FedeMPouzols committed Mar 9, 2015
2 parents c9bf0d1 + 5e4699b commit 7089106
Show file tree
Hide file tree
Showing 22 changed files with 561 additions and 1,034 deletions.
7 changes: 4 additions & 3 deletions Code/Mantid/Framework/Crystal/src/SortHKL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "MantidDataObjects/Peak.h"
#include "MantidDataObjects/PeaksWorkspace.h"
#include "MantidGeometry/Instrument/RectangularDetector.h"
#include "MantidGeometry/Crystal/PointGroup.h"
#include "MantidGeometry/Crystal/PointGroupFactory.h"
#include "MantidKernel/Strings.h"
#include "MantidKernel/System.h"
#include "MantidKernel/Utils.h"
Expand Down Expand Up @@ -75,7 +75,8 @@ void SortHKL::exec() {
peaksW->getPeaks()[i].setHKL(hkl1);
}
// Use the primitive by default
PointGroup_sptr pointGroup(new PointGroupLaue1());
PointGroup_sptr pointGroup =
PointGroupFactory::Instance().createPointGroup("-1");
// Get it from the property
std::string pointGroupName = getPropertyValue("PointGroup");
for (size_t i = 0; i < m_pointGroups.size(); ++i)
Expand All @@ -96,7 +97,7 @@ void SortHKL::exec() {
}
}

std::vector<std::pair<std::string, bool>> criteria;
std::vector<std::pair<std::string, bool> > criteria;
// Sort by detector ID then descending wavelength
criteria.push_back(std::pair<std::string, bool>("BankName", true));
criteria.push_back(std::pair<std::string, bool>("H", true));
Expand Down
232 changes: 17 additions & 215 deletions Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/PointGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
#include <set>

#include "MantidGeometry/Crystal/SymmetryOperation.h"
#include "MantidGeometry/Crystal/Group.h"

namespace Mantid {
namespace Geometry {

/** A class containing the Point Groups for a crystal.
*
* @author Vickie Lynch
* @date 2012-02-02
*/
class MANTID_GEOMETRY_DLL PointGroup {
class MANTID_GEOMETRY_DLL PointGroup : public Group {
public:
enum CrystalSystem {
Triclinic,
Expand All @@ -32,236 +34,36 @@ class MANTID_GEOMETRY_DLL PointGroup {
Cubic
};

PointGroup(const std::string &symbolHM, const Group &group,
const std::string &description = "");

PointGroup(const PointGroup &other);
PointGroup &operator=(const PointGroup &other);

virtual ~PointGroup() {}
/// Name of the point group
virtual std::string getName() const = 0;
std::string getName() const { return m_name; }
/// Hermann-Mauguin symbol
std::string getSymbol() const;

virtual CrystalSystem crystalSystem() const = 0;
CrystalSystem crystalSystem() const { return m_crystalSystem; }

/// Return true if the hkls are in same group
virtual bool isEquivalent(const Kernel::V3D &hkl,
const Kernel::V3D &hkl2) const = 0;
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;

/// 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);

void setSymmetryOperations(const std::vector<SymmetryOperation> &generators);
void addSymmetryOperation(const SymmetryOperation &symmetryOperation);
std::vector<SymmetryOperation> getSymmetryOperations() const;
std::vector<Kernel::V3D> getEquivalentSet(const Kernel::V3D &hkl) const;

std::vector<SymmetryOperation> generateSymmetryOperations(
const std::vector<SymmetryOperation> &symmetryOperations);
CrystalSystem getCrystalSystemFromGroup() const;

std::set<Kernel::V3D> getEquivalentSet(const Kernel::V3D &hkl) const;

std::vector<SymmetryOperation> m_symmetryOperations;
std::string m_symbolHM;
};

//------------------------------------------------------------------------
/** -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;

virtual void init();
};

//------------------------------------------------------------------------
/** 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;

virtual void init();
};

//------------------------------------------------------------------------
/** 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();
std::string m_name;
CrystalSystem m_crystalSystem;
};

/// Shared pointer to a PointGroup
Expand All @@ -270,7 +72,7 @@ typedef boost::shared_ptr<PointGroup> PointGroup_sptr;
MANTID_GEOMETRY_DLL std::vector<PointGroup_sptr> getAllPointGroups();

typedef std::multimap<PointGroup::CrystalSystem, PointGroup_sptr>
PointGroupCrystalSystemMap;
PointGroupCrystalSystemMap;
MANTID_GEOMETRY_DLL PointGroupCrystalSystemMap getPointGroupsByCrystalSystem();

} // namespace Mantid
Expand Down
Loading

0 comments on commit 7089106

Please sign in to comment.