// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #include "FFBIDXIndexer.h" #include "EigenRefine.h" void FFBIDXIndexer::SetupUnitCell(const std::optional &cell) { if (!cell.has_value()) throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "FFBIDX requires unit cell"); reference_unit_cell = cell; CrystalLattice l1(cell.value()); Eigen::Matrix3f m; indexer.iCellM() << l1.Vec0().x, l1.Vec0().y, l1.Vec0().z, l1.Vec1().x, l1.Vec1().y, l1.Vec1().z, l1.Vec2().x, l1.Vec2().y, l1.Vec2().z; } std::vector FFBIDXIndexer::Run(const std::vector &coord, size_t nspots) { std::vector ret; if (nspots > coord.size()) nspots = coord.size(); if (nspots <= viable_cell_min_spots) return ret; assert(nspots <= MAX_SPOT_COUNT); assert(coord.size() <= MAX_SPOT_COUNT); for (int i = 0; i < coord.size(); i++) { indexer.spotX(i) = coord[i].x; indexer.spotY(i) = coord[i].y; indexer.spotZ(i) = coord[i].z; } // Index indexer.index(1, nspots); RefineParameters parameters{ .viable_cell_min_spots = viable_cell_min_spots, .dist_tolerance_vs_reference = dist_tolerance_vs_reference, .reference_unit_cell = reference_unit_cell, .min_length_A = 1, // doesn't matter .max_length_A = 1000, // doesn't matter .min_angle_deg = 30, .max_angle_deg = 150, .indexing_tolerance = indexing_tolerance }; return Refine(coord, nspots, indexer.oCellM(), indexer.oScoreV(), parameters); }