5#ifndef GEMMI_REFLN_HPP_
6#define GEMMI_REFLN_HPP_
34 if (
const std::string* hm = impl::find_spacegroup_hm_value(
block))
38 const char*
wave_tag =
"_diffrn_radiation_wavelength.wavelength";
58 if (
o.diffrn_refln_loop)
80 for (
size_t i = 0;
i !=
labels.size(); ++
i)
125 for (
int i = 0;
i != 3; ++
i)
132 fail(
"Unit cell is not known");
137 for (
int i = 0;
i != 3; ++
i)
146 for (
double&
d : vec)
147 d = 1.0 / std::sqrt(
d);
155 std::vector<ReflnBlock>
rvec;
156 rvec.reserve(blocks.size());
158 rvec.emplace_back(std::move(block));
166 else if (!
rblock.spacegroup)
168 if (
rblock.cell.is_crystal()) {
181 const std::vector<std::string>&
labels,
182 const char* block_name=
nullptr) {
187 if (
const std::string* hm = impl::find_spacegroup_hm_value(block)) {
191 impl::set_cell_from_mmcif(block, cell);
195 if (!block_name || block.name == block_name) {
197 if (
cif::Loop* loop = block.find_loop(
"_refln.index_h").get_loop())
199 [&](
const std::string& s) { return loop->has_tag(
"_refln."+s); })) {
208 fail(
"Required block not found in SF-mmCIF file.");
214 rb.block.swap(block);
215 rb.entry_id =
rb.block.name;
216 impl::set_cell_from_mmcif(
rb.block,
rb.cell,
false);
217 const char*
hm_tag =
"_symmetry_space_group_name_H-M";
218 if (
const std::string* hm =
rb.block.find_value(
hm_tag))
220 rb.cell.alpha,
rb.cell.gamma);
221 rb.cell.set_cell_images_from_spacegroup(
rb.spacegroup);
222 rb.refln_loop =
rb.block.find_loop(
"_refln_index_h").get_loop();
223 rb.default_loop =
rb.refln_loop;
230 std::array<size_t,3> hkl_cols_;
232 : rb_(
rb), hkl_cols_(rb_.get_hkl_column_indices()) {}
233 size_t stride()
const {
return loop().tags.size(); }
234 size_t size()
const {
return loop().values.size(); }
240 return {{get_int(
offset + hkl_cols_[0]),
241 get_int(
offset + hkl_cols_[1]),
242 get_int(
offset + hkl_cols_[2])}};
247 int get_int(
size_t n)
const {
return cif::as_int(loop().values[n]); }
struct Document that represents the CIF file (but can also be read from a different representation,...
fail(), unreachable() and __declspec/__attribute__ macros
Functions used in both mmcif. hpp and refln. hpp (for coordinate and reflection mmCIF files).
int as_any(const std::string &s, int null)
double as_number(const std::string &s, double nan=NAN)
std::string as_string(const std::string &value)
int as_int(const std::string &str)
MtzDataProxy data_proxy(const Mtz &mtz)
std::vector< ReflnBlock > as_refln_blocks(std::vector< cif::Block > &&blocks)
ReflnBlock hkl_cif_as_refln_block(cif::Block &block)
std::array< int, 3 > Miller
A synonym for convenient passing of hkl.
GEMMI_DLL const SpaceGroup * find_spacegroup_by_name(std::string name, double alpha=0., double gamma=0., const char *prefer=nullptr)
If angles alpha and gamma are provided, they are used to distinguish hexagonal and rhombohedral setti...
ReflnBlock get_refln_block(std::vector< cif::Block > &&blocks, const std::vector< std::string > &labels, const char *block_name=nullptr)
std::string join_str(T begin, T end, const S &sep, const F &getter)
void fail(const std::string &msg)
Utilities for parsing CIF numbers (the CIF spec calls them 'numb').
int find_column_index(const std::string &tag) const
size_t tag_offset() const
std::vector< T > make_vector(const std::string &tag, T null) const
void use_unmerged(bool unmerged)
ReflnBlock & operator=(const ReflnBlock &o)
std::vector< Miller > make_miller_vector() const
cif::Loop * diffrn_refln_loop
ReflnBlock & operator=(ReflnBlock &&)=default
const SpaceGroup * spacegroup
size_t get_column_index(const std::string &tag) const
std::vector< double > make_d_vector() const
ReflnBlock(cif::Block &&block_)
std::array< size_t, 3 > get_hkl_column_indices() const
ReflnBlock(ReflnBlock &&rblock_)=default
std::vector< double > make_1_d2_vector() const
std::vector< std::string > column_labels() const
ReflnDataProxy(const ReflnBlock &rb)
Miller get_hkl(size_t offset) const
double get_num(size_t n) const
const UnitCell & unit_cell() const
const SpaceGroup * spacegroup() const
size_t column_index(const std::string &label) const
double calculate_1_d2(const Miller &hkl) const
void set_cell_images_from_spacegroup(const SpaceGroup *sg)
Column find_values(const std::string &tag)
Column find_loop(const std::string &tag)
const std::string * find_value(const std::string &tag) const
std::vector< std::string > tags
std::vector< std::string > values
Crystallographic Symmetry. Space Groups. Coordinate Triplets.