13#include <boost/algorithm/string.hpp>
21 throw std::invalid_argument(
"Point group with symbol '" + hmSymbol +
"' is not registered.");
39 throw std::invalid_argument(
"Trigonal space groups need to be processed differently.");
43 }
catch (
const std::invalid_argument &) {
45 pointGroupSymbol.append(
" r");
58 std::vector<std::string> pointGroups;
61 [](
const auto &generator) { return generator.first; });
68 std::vector<std::string> pointGroups;
73 if (pointGroup->crystalSystem() == crystalSystem) {
74 pointGroups.emplace_back(generator.first);
82 const std::string &description) {
84 throw std::invalid_argument(
"Point group with this symbol is already registered.");
110 std::string noOriginChoice = boost::regex_replace(spaceGroupSymbol,
m_originChoiceRegex,
"");
111 std::string noScrews = boost::regex_replace(noOriginChoice,
m_screwAxisRegex,
"\\1");
113 std::string noCentering = boost::regex_replace(noGlides,
m_centeringRegex,
"");
115 std::string noSpaces = boost::algorithm::erase_all_copy(noCentering,
" ");
117 if (noSpaces.substr(0, 1) ==
"1" && noSpaces.size() > 2 && noSpaces.substr(noSpaces.size() - 1, 1) ==
"1") {
118 noSpaces = noSpaces.substr(1, noSpaces.size() - 2);
128 throw std::runtime_error(
"No generator for symbol '" + hmSymbol +
"'");
131 return generator->getPrototype();
136 throw std::runtime_error(
"Cannot register null-generator.");
143 return std::make_shared<PointGroup>(*prototype);
148 : m_generatorMap(), m_crystalSystemMap(), m_screwAxisRegex(
"(2|3|4|6)[1|2|3|4|5]"),
149 m_glidePlaneRegex(
"a|b|c|d|e|g|n"), m_centeringRegex(
"[A-Z]"), m_originChoiceRegex(
":(1|2|r)") {
154 std::string description)
155 : m_hmSymbol(
std::move(hmSymbol)), m_generatorString(
std::move(generatorInformation)),
156 m_description(
std::move(description)) {}
169 if (!generatingGroup) {
170 throw std::runtime_error(
"Could not create group from supplied symmetry operations.");
#define DECLARE_POINTGROUP(hmSymbol, generators, description)
CoordinateSystem getCoordinateSystem() const
Returns the axis system of the group (either orthogonal or hexagonal).
PointGroupFactoryImpl()
Private default constructor.
boost::regex m_originChoiceRegex
bool isSubscribed(const std::string &hmSymbol) const
void subscribePointGroup(const std::string &hmSymbol, const std::string &generatorString, const std::string &description)
PointGroup_sptr createPointGroupFromSpaceGroup(const SpaceGroup_const_sptr &spaceGroup)
void subscribe(const PointGroupGenerator_sptr &generator)
std::map< std::string, PointGroupGenerator_sptr > m_generatorMap
boost::regex m_glidePlaneRegex
PointGroup_sptr createPointGroup(const std::string &hmSymbol)
Creates a PointGroup object from its Hermann-Mauguin symbol.
std::string pointGroupSymbolFromSpaceGroupSymbol(const std::string &spaceGroupSymbol) const
Returns the point group symbol from a given space group symbol.
PointGroup_sptr constructFromPrototype(const PointGroup_sptr &prototype) const
std::vector< std::string > getAllPointGroupSymbols() const
Returns the Hermann-Mauguin symbols of all registered point groups.
std::vector< std::string > getPointGroupSymbols(const PointGroup::CrystalSystem &crystalSystem)
Returns the Hermann-Mauguin symbols of all point groups that belong to a certain crystal system.
boost::regex m_screwAxisRegex
PointGroup_sptr getPrototype(const std::string &hmSymbol)
boost::regex m_centeringRegex
PointGroupGenerator(std::string hmSymbol, std::string generatorInformation, std::string description)
PointGroup_sptr getPrototype()
std::string m_description
PointGroup_sptr m_prototype
std::string m_generatorString
bool hasValidPrototype() const
PointGroup_sptr generatePrototype()
A class for representing space groups, inheriting from Group.
std::string hmSymbol() const
Returns the stored Hermann-Mauguin symbol.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< PointGroupGenerator > PointGroupGenerator_sptr
std::shared_ptr< PointGroup > PointGroup_sptr
Shared pointer to a PointGroup.
std::shared_ptr< const SpaceGroup > SpaceGroup_const_sptr
std::shared_ptr< const Group > Group_const_sptr