Skip to content
Snippets Groups Projects
PointGroup.h 3.23 KiB
Newer Older
#ifndef MANTID_GEOMETRY_POINTGROUP_H_
#define MANTID_GEOMETRY_POINTGROUP_H_
#include "MantidGeometry/DllConfig.h"
#include "MantidKernel/V3D.h"
#include "MantidKernel/Matrix.h"
#include <boost/shared_ptr.hpp>
#include <vector>
#include <string>
#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 : public Group {
    Triclinic,
    Monoclinic,
    Orthorhombic,
    Tetragonal,
    Hexagonal,
    Trigonal,
    Cubic
  enum class LatticeSystem {
    Triclinic,
    Monoclinic,
    Orthorhombic,
    Tetragonal,
    Hexagonal,
    Rhombohedral,
    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
  std::string getName() const { return m_name; }
  /// Hermann-Mauguin symbol
  std::string getSymbol() const;

  CrystalSystem crystalSystem() const { return m_crystalSystem; }
  LatticeSystem latticeSystem() const { return m_latticeSystem; }

  /// Return true if the hkls are in same group
  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;

protected:
  std::vector<Kernel::V3D> getEquivalentSet(const Kernel::V3D &hkl) const;
  CrystalSystem getCrystalSystemFromGroup() const;
  LatticeSystem getLatticeSystemFromCrystalSystemAndGroup(
      const CrystalSystem &crystalSystem) const;
  std::string m_symbolHM;
  std::string m_name;
  LatticeSystem m_latticeSystem;
};

/// Shared pointer to a PointGroup
typedef boost::shared_ptr<PointGroup> PointGroup_sptr;

MANTID_GEOMETRY_DLL std::vector<PointGroup_sptr> getAllPointGroups();

MANTID_GEOMETRY_DLL
std::string
getCrystalSystemAsString(const PointGroup::CrystalSystem &crystalSystem);

MANTID_GEOMETRY_DLL
PointGroup::CrystalSystem
getCrystalSystemFromString(const std::string &crystalSystem);

MANTID_GEOMETRY_DLL
std::string
getLatticeSystemAsString(const PointGroup::LatticeSystem &latticeSystem);

MANTID_GEOMETRY_DLL
PointGroup::LatticeSystem
getLatticeSystemFromString(const std::string &latticeSystem);

/// This is necessary to make the map work with older compilers. Can be removed
/// when GCC 4.4 is not used anymore.
struct MANTID_GEOMETRY_DLL CrystalSystemComparator {
  bool operator()(const PointGroup::CrystalSystem &lhs,
                  const PointGroup::CrystalSystem &rhs) const;
};

typedef std::multimap<PointGroup::CrystalSystem, PointGroup_sptr,
                      CrystalSystemComparator> PointGroupCrystalSystemMap;

MANTID_GEOMETRY_DLL PointGroupCrystalSystemMap getPointGroupsByCrystalSystem();

} // namespace Mantid
} // namespace Geometry

#endif /* MANTID_GEOMETRY_POINTGROUP_H_ */