RotationIndexer: Separate ProcessImage and GetLattice
This commit is contained in:
@@ -39,10 +39,24 @@ RotationIndexer::RotationIndexer(const DiffractionExperiment &x, IndexerThreadPo
|
||||
}
|
||||
}
|
||||
|
||||
void RotationIndexer::TryIndex() {
|
||||
// Index
|
||||
IndexerResult RotationIndexer::RunIndexing() const {
|
||||
std::vector<Coord> coords;
|
||||
coords.reserve(max_spots);
|
||||
|
||||
for (int i = 0; i < v_.size(); i++) {
|
||||
const float angle_deg = axis_->GetAngle_deg(i) + axis_->GetWedge_deg() / 2.0f;
|
||||
const auto rot = axis_->GetTransformationAngle(angle_deg);
|
||||
|
||||
for (const auto &s: v_[i])
|
||||
coords.emplace_back(rot * s.ReciprocalCoord(geom_));
|
||||
}
|
||||
|
||||
return indexer_.Run(experiment, coords);
|
||||
}
|
||||
|
||||
void RotationIndexer::TryIndex() {
|
||||
auto indexer_result = RunIndexing();
|
||||
|
||||
auto indexer_result = indexer_.Run(experiment, coords_);
|
||||
if (!indexer_result.lattice.empty() && indexer_result.lattice[0].CalcVolume() > 1.0) {
|
||||
auto sg = experiment.GetGemmiSpaceGroup();
|
||||
if (sg) {
|
||||
@@ -94,25 +108,19 @@ void RotationIndexer::TryIndex() {
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<RotationIndexerResult> RotationIndexer::ProcessImage(int64_t image, const std::vector<SpotToSave> &spots) {
|
||||
void RotationIndexer::ProcessImage(int64_t image, const std::vector<SpotToSave> &spots) {
|
||||
std::unique_lock ul(m);
|
||||
|
||||
// For non-rotation just ignore the whole procedure
|
||||
if (!axis_)
|
||||
return {};
|
||||
|
||||
const float angle_deg = axis_->GetAngle_deg(image) + axis_->GetWedge_deg() / 2.0f;
|
||||
const auto rot = axis_->GetTransformationAngle(angle_deg);
|
||||
return;
|
||||
|
||||
if (!indexed_lattice && image >= last_accumulated_image + image_stride) {
|
||||
v_[image].reserve(spots.size());
|
||||
coords_.reserve(coords_.size() + spots.size());
|
||||
|
||||
for (const auto &s: spots) {
|
||||
if (index_ice_rings || !s.ice_ring) {
|
||||
if (index_ice_rings || !s.ice_ring)
|
||||
v_[image].emplace_back(s);
|
||||
coords_.emplace_back(rot * s.ReciprocalCoord(geom_));
|
||||
}
|
||||
}
|
||||
|
||||
accumulated_images++;
|
||||
@@ -126,18 +134,11 @@ std::optional<RotationIndexerResult> RotationIndexer::ProcessImage(int64_t image
|
||||
image >= next_image_to_try_indexing)
|
||||
TryIndex();
|
||||
}
|
||||
if (!indexed_lattice)
|
||||
return {};
|
||||
|
||||
return RotationIndexerResult{
|
||||
.lattice = indexed_lattice.value(),
|
||||
.search_result = search_result_,
|
||||
.geom = updated_geom_,
|
||||
.axis = axis_
|
||||
};
|
||||
}
|
||||
|
||||
std::optional<RotationIndexerResult> RotationIndexer::GetLattice() {
|
||||
std::optional<RotationIndexerResult> RotationIndexer::GetLattice() const {
|
||||
std::unique_lock ul(m);
|
||||
|
||||
if (!indexed_lattice)
|
||||
return {};
|
||||
return RotationIndexerResult{
|
||||
|
||||
Reference in New Issue
Block a user