Skip to content
Snippets Groups Projects
Commit 8d53b65f authored by Michael Wedel's avatar Michael Wedel
Browse files

Refs #14121. Added LatticeSystem enum

parent 8d1ae82e
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,16 @@ public:
Cubic
};
enum class LatticeSystem {
Triclinic,
Monoclinic,
Orthorhombic,
Tetragonal,
Hexagonal,
Rhombohedral,
Cubic
};
PointGroup(const std::string &symbolHM, const Group &group,
const std::string &description = "");
......@@ -47,6 +57,7 @@ public:
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;
......@@ -60,10 +71,13 @@ 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;
CrystalSystem m_crystalSystem;
LatticeSystem m_latticeSystem;
};
/// Shared pointer to a PointGroup
......@@ -83,6 +97,14 @@ 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);
} // namespace Mantid
} // namespace Geometry
......
......@@ -57,11 +57,13 @@ PointGroup::PointGroup(const std::string &symbolHM, const Group &group,
: Group(group), m_symbolHM(symbolHM),
m_name(symbolHM + " (" + description + ")") {
m_crystalSystem = getCrystalSystemFromGroup();
m_latticeSystem = getLatticeSystemFromCrystalSystemAndGroup(m_crystalSystem);
}
PointGroup::PointGroup(const PointGroup &other)
: Group(other), m_symbolHM(other.m_symbolHM), m_name(other.m_name),
m_crystalSystem(other.m_crystalSystem) {}
m_crystalSystem(other.m_crystalSystem),
m_latticeSystem(other.m_latticeSystem) {}
PointGroup &PointGroup::operator=(const PointGroup &other) {
Group::operator=(other);
......@@ -69,6 +71,7 @@ PointGroup &PointGroup::operator=(const PointGroup &other) {
m_symbolHM = other.m_symbolHM;
m_name = other.m_name;
m_crystalSystem = other.m_crystalSystem;
m_latticeSystem = other.m_latticeSystem;
return *this;
}
......@@ -158,6 +161,31 @@ PointGroup::CrystalSystem PointGroup::getCrystalSystemFromGroup() const {
return CrystalSystem::Triclinic;
}
PointGroup::LatticeSystem PointGroup::getLatticeSystemFromCrystalSystemAndGroup(
const CrystalSystem &crystalSystem) const {
switch (crystalSystem) {
case CrystalSystem::Cubic:
return LatticeSystem::Cubic;
case CrystalSystem::Hexagonal:
return LatticeSystem::Hexagonal;
case CrystalSystem::Tetragonal:
return LatticeSystem::Tetragonal;
case CrystalSystem::Orthorhombic:
return LatticeSystem::Orthorhombic;
case CrystalSystem::Monoclinic:
return LatticeSystem::Monoclinic;
case CrystalSystem::Triclinic:
return LatticeSystem::Triclinic;
default: {
if (getCoordinateSystem() == Group::Hexagonal) {
return LatticeSystem::Hexagonal;
}
return LatticeSystem::Rhombohedral;
}
}
}
/** @return a vector with all possible PointGroup objects */
std::vector<PointGroup_sptr> getAllPointGroups() {
std::vector<std::string> allSymbols =
......@@ -227,5 +255,49 @@ getCrystalSystemFromString(const std::string &crystalSystem) {
}
}
std::string
getLatticeSystemAsString(const PointGroup::LatticeSystem &latticeSystem) {
switch (latticeSystem) {
case PointGroup::LatticeSystem::Cubic:
return "Cubic";
case PointGroup::LatticeSystem::Tetragonal:
return "Tetragonal";
case PointGroup::LatticeSystem::Hexagonal:
return "Hexagonal";
case PointGroup::LatticeSystem::Rhombohedral:
return "Rhombohedral";
case PointGroup::LatticeSystem::Orthorhombic:
return "Orthorhombic";
case PointGroup::LatticeSystem::Monoclinic:
return "Monoclinic";
default:
return "Triclinic";
}
}
PointGroup::LatticeSystem
getLatticeSystemFromString(const std::string &latticeSystem) {
std::string latticeSystemLC = boost::algorithm::to_lower_copy(latticeSystem);
if (latticeSystemLC == "cubic") {
return PointGroup::LatticeSystem::Cubic;
} else if (latticeSystemLC == "tetragonal") {
return PointGroup::LatticeSystem::Tetragonal;
} else if (latticeSystemLC == "hexagonal") {
return PointGroup::LatticeSystem::Hexagonal;
} else if (latticeSystemLC == "rhombohedral") {
return PointGroup::LatticeSystem::Rhombohedral;
} else if (latticeSystemLC == "orthorhombic") {
return PointGroup::LatticeSystem::Orthorhombic;
} else if (latticeSystemLC == "monoclinic") {
return PointGroup::LatticeSystem::Monoclinic;
} else if (latticeSystemLC == "triclinic") {
return PointGroup::LatticeSystem::Triclinic;
} else {
throw std::invalid_argument("Not a valid lattice system: '" +
latticeSystem + "'.");
}
}
} // namespace Mantid
} // namespace Geometry
......@@ -367,6 +367,55 @@ public:
PointGroup::CrystalSystem::Triclinic);
}
void testLatticeSystemNames() {
TS_ASSERT_EQUALS(getLatticeSystemFromString("Cubic"),
PointGroup::LatticeSystem::Cubic);
TS_ASSERT_EQUALS(getLatticeSystemFromString("cubic"),
PointGroup::LatticeSystem::Cubic);
TS_ASSERT_EQUALS(getLatticeSystemFromString("CUBIC"),
PointGroup::LatticeSystem::Cubic);
TS_ASSERT_EQUALS(getLatticeSystemFromString("CuBiC"),
PointGroup::LatticeSystem::Cubic);
TS_ASSERT_EQUALS(getLatticeSystemFromString("Tetragonal"),
PointGroup::LatticeSystem::Tetragonal);
TS_ASSERT_EQUALS(getLatticeSystemFromString("Hexagonal"),
PointGroup::LatticeSystem::Hexagonal);
TS_ASSERT_EQUALS(getLatticeSystemFromString("Rhombohedral"),
PointGroup::LatticeSystem::Rhombohedral);
TS_ASSERT_EQUALS(getLatticeSystemFromString("Orthorhombic"),
PointGroup::LatticeSystem::Orthorhombic);
TS_ASSERT_EQUALS(getLatticeSystemFromString("Monoclinic"),
PointGroup::LatticeSystem::Monoclinic);
TS_ASSERT_EQUALS(getLatticeSystemFromString("Triclinic"),
PointGroup::LatticeSystem::Triclinic);
TS_ASSERT_THROWS(getLatticeSystemFromString("DoesNotExist"),
std::invalid_argument);
TS_ASSERT_EQUALS(getLatticeSystemFromString(getLatticeSystemAsString(
PointGroup::LatticeSystem::Cubic)),
PointGroup::LatticeSystem::Cubic);
TS_ASSERT_EQUALS(getLatticeSystemFromString(getLatticeSystemAsString(
PointGroup::LatticeSystem::Tetragonal)),
PointGroup::LatticeSystem::Tetragonal);
TS_ASSERT_EQUALS(getLatticeSystemFromString(getLatticeSystemAsString(
PointGroup::LatticeSystem::Hexagonal)),
PointGroup::LatticeSystem::Hexagonal);
TS_ASSERT_EQUALS(getLatticeSystemFromString(getLatticeSystemAsString(
PointGroup::LatticeSystem::Rhombohedral)),
PointGroup::LatticeSystem::Rhombohedral);
TS_ASSERT_EQUALS(getLatticeSystemFromString(getLatticeSystemAsString(
PointGroup::LatticeSystem::Orthorhombic)),
PointGroup::LatticeSystem::Orthorhombic);
TS_ASSERT_EQUALS(getLatticeSystemFromString(getLatticeSystemAsString(
PointGroup::LatticeSystem::Monoclinic)),
PointGroup::LatticeSystem::Monoclinic);
TS_ASSERT_EQUALS(getLatticeSystemFromString(getLatticeSystemAsString(
PointGroup::LatticeSystem::Triclinic)),
PointGroup::LatticeSystem::Triclinic);
}
private:
void checkPointGroupPerformance(const PointGroup_sptr &pointGroup) {
V3D equiv[] = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment