36 #include <fast_methods/fm/eikonalsolver.hpp>
37 #include <fast_methods/utils/utils.h>
58 std::array<unsigned, grid_t::getNDims()> dimsize = g->getDimSizes();
60 for (
size_t i = 0; i < grid_t::getNDims(); ++i) {
66 Tvalues_.reserve(grid_t::getNDims());
75 console::warning(
"Setting a goal point in FSM (and LSM) is experimental. It may lead to wrong results.");
86 grid_->getCell(i).setArrivalTime(0);
106 virtual void printRunInfo
109 std::cout <<
'\t' <<
name_ <<
'\n'
110 <<
'\t' <<
"Maximum sweeps: " <<
maxSweeps_ <<
'\n'
111 <<
'\t' <<
"Sweeps performed: " <<
sweeps_ <<
'\n'
112 <<
'\t' <<
"Elapsed time: " <<
time_ <<
" ms\n";
119 (
size_t depth,
int it = 0) {
126 if (!
grid_->getCell(it+i).isOccupied())
134 const double prevTime =
grid_->getCell(idx).getArrivalTime();
137 grid_->getCell(idx).setArrivalTime(newTime);
141 else if(!isnan(newTime) && !isinf(newTime) && (idx ==
goal_idx_))
155 for (
size_t i = 0; i < grid_t::getNDims(); ++i)
157 if((
incs_[i] += 2) <=1)
164 for (
size_t i = 0; i < grid_t::getNDims(); ++i)
182 for (
size_t i = 0; i < grid_t::getNDims(); ++i) {
211 std::array<int, grid_t::getNDims()>
incs_;
214 std::array<int, grid_t::getNDims()>
inits_;
217 std::array<int, grid_t::getNDims()>
ends_;
224 std::array<int, grid_t::getNDims()>
d_;
Implements Fast Sweeping Method.
Abstract class that serves as interface for the actual EikonalSolvers implemented. It requires (at least) the computeInternal method to be implemented,.
std::array< int, grid_t::getNDims()> dimsize_
Size of each dimension, extended to the maximum size. Extended dimensions always 1.
std::array< int, grid_t::getNDims()> d_
Auxiliar array to speed up indexing generalization: stores parcial multiplications of dimensions size...
double time_
Time elapsed by the compute method.
virtual void setEnvironment(grid_t *g)
Sets and cleans the grid in which operations will be performed.
virtual void setup()
Checks that the solver is ready to run. Sets the grid unclean.
std::array< int, grid_t::getNDims()> incs_
Sweep directions {-1,1} for each dimension. Extended dimensions always 1.
virtual void computeInternal()
Actual method that implements FSM.
virtual double solveEikonal(const int &idx)
Solves nD Eikonal equation for cell idx. If heuristics are activated, it will add the estimated trave...
virtual void setup()
Executes EikonalSolver setup and other checks.
virtual void solveForIdx(unsigned idx)
Actually executes one solving iteration of the FSM.
virtual void reset()
Clears temporal data, so it is ready to run again.
std::array< int, grid_t::getNDims()> ends_
Final indices for each dimension. Extended dimensions always 1.
grid_t * grid_
Grid container.
bool stopPropagation_
Flag to stop sweeping (used when goal point has converged).
static void info(const std::string &val)
std::vector< unsigned int > init_points_
Initial index.
virtual void setEnvironment(grid_t *g)
Sets and cleans the grid in which operations will be performed. Since a maximum number of dimensions ...
void recursiveIteration(size_t depth, int it=0)
Equivalent to nesting as many for loops as dimensions. For every most inner loop iteration, solveForIdx() is called for the corresponding idx.
std::string name_
Solver name.
unsigned int sweeps_
Number of sweeps performed.
bool keepSweeping_
Flag to indicate that at least one more sweep is required.
static bool isTimeBetterThan(double t1, double t2)
Returns true if t1 is at least epsilon-lower than t2, provides robust comparions for doubles...
virtual void setSweep()
Set the sweep variables: initial and final indices for iterations, and the increment of each iteratio...
std::vector< double > Tvalues_
Auxiliar vector with values T0,T1...Tn-1 variables in the Discretized Eikonal Equation.
unsigned int goal_idx_
Goal index.
virtual void initializeSweepArrays()
Initializes the internal arrays employed.
unsigned maxSweeps_
Number of maximum sweeps to perform.
static void warning(const std::string &val)
std::array< int, grid_t::getNDims()> inits_
Initial indices for each dimension. Extended dimensions always 0.
virtual void reset()
Clears temporal data, so it is ready to run again.