14#include <boost/algorithm/string.hpp>
23Kernel::Logger
g_log(
"PointGroup");
45 std::sort(equivalents.begin(), equivalents.end(), std::greater<V3D>());
47 equivalents.erase(std::unique(equivalents.begin(), equivalents.end()), equivalents.end());
68 return *std::max_element(equivalents.begin(), equivalents.end());
73 :
Group(
group), m_symbolHM(symbolHM), m_name(symbolHM +
" (" + description +
")") {
84 return (std::find(hklEquivalents.cbegin(), hklEquivalents.cend(), hkl2) != hklEquivalents.end());
136 g_log.
warning() <<
"Invalid crystal system - returning group with lowest symmetry (inversion only).\n";
156 std::vector<V3D> equivalents;
159 [&hkl](
const auto &operation) { return operation.transformHKL(hkl); });
175 std::map<std::string, std::set<V3D>> symbolMap;
179 SymmetryElementFactory::Instance().createSymElement(operation));
182 std::string symbol = element->hmSymbol();
183 V3D axis = element->getAxis();
185 symbolMap[symbol].insert(axis);
189 if (symbolMap[
"3"].size() == 4) {
193 if (symbolMap[
"6"].size() == 1 || symbolMap[
"-6"].size() == 1) {
197 if (symbolMap[
"3"].size() == 1) {
201 if (symbolMap[
"4"].size() == 1 || symbolMap[
"-4"].size() == 1) {
205 if (symbolMap[
"2"].size() == 3 || (symbolMap[
"2"].size() == 1 && symbolMap[
"m"].size() == 2)) {
209 if (symbolMap[
"2"].size() == 1 || symbolMap[
"m"].size() == 1) {
254 auto &pointGroupFactory = PointGroupFactory::Instance();
255 std::vector<std::string> allSymbols = pointGroupFactory.getAllPointGroupSymbols();
256 std::vector<PointGroup_sptr> out;
257 out.reserve(allSymbols.size());
258 std::transform(allSymbols.cbegin(), allSymbols.cend(), std::back_inserter(out),
259 [&pointGroupFactory](
const auto &symbol) { return pointGroupFactory.createPointGroup(symbol); });
269 for (
auto &pointGroup : pointGroups) {
270 map.emplace(pointGroup->crystalSystem(), pointGroup);
278 switch (crystalSystem) {
288 return "Orthorhombic";
299 std::string crystalSystemLC = boost::algorithm::to_lower_copy(crystalSystem);
301 if (crystalSystemLC ==
"cubic") {
303 }
else if (crystalSystemLC ==
"tetragonal") {
305 }
else if (crystalSystemLC ==
"hexagonal") {
307 }
else if (crystalSystemLC ==
"trigonal") {
309 }
else if (crystalSystemLC ==
"orthorhombic") {
311 }
else if (crystalSystemLC ==
"monoclinic") {
313 }
else if (crystalSystemLC ==
"triclinic") {
316 throw std::invalid_argument(
"Not a valid crystal system: '" + crystalSystem +
"'.");
322 switch (latticeSystem) {
330 return "Rhombohedral";
332 return "Orthorhombic";
343 std::string latticeSystemLC = boost::algorithm::to_lower_copy(latticeSystem);
345 if (latticeSystemLC ==
"cubic") {
347 }
else if (latticeSystemLC ==
"tetragonal") {
349 }
else if (latticeSystemLC ==
"hexagonal") {
351 }
else if (latticeSystemLC ==
"rhombohedral") {
353 }
else if (latticeSystemLC ==
"orthorhombic") {
355 }
else if (latticeSystemLC ==
"monoclinic") {
357 }
else if (latticeSystemLC ==
"triclinic") {
360 throw std::invalid_argument(
"Not a valid lattice system: '" + latticeSystem +
"'.");
366 return static_cast<int>(lhs) <
static_cast<int>(
rhs);
371 stream <<
"Point group with:\n"
const std::vector< double > & rhs
The class Group represents a set of symmetry operations (or symmetry group).
CoordinateSystem getCoordinateSystem() const
Returns the axis system of the group (either orthogonal or hexagonal).
std::vector< SymmetryOperation > m_allOperations
A class containing the Point Groups for a crystal.
PointGroup(const std::string &symbolHM, const Group &group, const std::string &description="")
Protected constructor - can not be used directly.
bool isEquivalent(const Kernel::V3D &hkl, const Kernel::V3D &hkl2) const
Return true if the hkls are in same group.
LatticeSystem getLatticeSystemFromCrystalSystemAndGroup(const CrystalSystem &crystalSystem) const
Returns the LatticeSystem of the point group, using the crystal system.
const std::string & getSymbol() const
Hermann-Mauguin symbol.
LatticeSystem latticeSystem() const
std::vector< Kernel::V3D > getEquivalents(const Kernel::V3D &hkl) const
Returns a vector with all equivalent hkls.
CrystalSystem getCrystalSystemFromGroup() const
Returns the CrystalSystem determined from symmetry elements.
CrystalSystem m_crystalSystem
std::vector< Kernel::V3D > getAllEquivalents(const Kernel::V3D &hkl) const
Generates a set of hkls.
LatticeSystem m_latticeSystem
std::string getLauePointGroupSymbol() const
CrystalSystem crystalSystem() const
Kernel::V3D getReflectionFamily(const Kernel::V3D &hkl) const
Returns the same hkl for all equivalent hkls.
void warning(const std::string &msg)
Logs at warning level.
MANTID_GEOMETRY_DLL PointGroup::LatticeSystem getLatticeSystemFromString(const std::string &latticeSystem)
Returns the lattice system enum that corresponds to the supplied string or throws an invalid_argument...
Mantid::Kernel::Logger g_log("Goniometer")
std::multimap< PointGroup::CrystalSystem, PointGroup_sptr, CrystalSystemComparator > PointGroupCrystalSystemMap
std::shared_ptr< SymmetryElementWithAxis > SymmetryElementWithAxis_sptr
MANTID_GEOMETRY_DLL std::string getLatticeSystemAsString(const PointGroup::LatticeSystem &latticeSystem)
Returns the supplied LatticeSystem as a string.
MANTID_GEOMETRY_DLL std::ostream & operator<<(std::ostream &stream, const PointGroup &self)
Returns a streamed representation of the PointGroup object.
MANTID_GEOMETRY_DLL PointGroup::CrystalSystem getCrystalSystemFromString(const std::string &crystalSystem)
Returns the crystal system enum that corresponds to the supplied string or throws an invalid_argument...
MANTID_GEOMETRY_DLL std::string getCrystalSystemAsString(const PointGroup::CrystalSystem &crystalSystem)
Return a human-readable string for the given crystal system.
MANTID_GEOMETRY_DLL std::vector< PointGroup_sptr > getAllPointGroups()
MANTID_GEOMETRY_DLL PointGroupCrystalSystemMap getPointGroupsByCrystalSystem()
Returns a multimap with crystal system as key and point groups as values.
Mantid::Kernel::Matrix< int > IntMatrix
bool operator()(const PointGroup::CrystalSystem &lhs, const PointGroup::CrystalSystem &rhs) const