#include "geoslib_old_f.h"
#include "Enum/ELoc.hpp"
#include "Basic/NamingConvention.hpp"
#include "Basic/OptDbg.hpp"
#include "Calculators/CalcMigrate.hpp"
#include "Calculators/ACalcDbToDb.hpp"
#include "Geometry/GeometryHelper.hpp"
#include "Db/DbGrid.hpp"
#include "Db/Db.hpp"
#include "Morpho/Morpho.hpp"
#include "Tree/Ball.hpp"
#include "Basic/Memory.hpp"
#include "Core/Keypair.hpp"
#include <math.h>
Macros | |
#define | RES(nval, idim) (res[(idim) + (ndim+1) * (nval)]) |
Functions | |
static void | st_shift (int rank, Db *dbgrid, const VectorInt &indg1, const VectorDouble &prop, VectorInt &indg2, double *weight) |
static int | st_multilinear_evaluate (DbGrid *db_grid, const VectorInt &indg, int iatt, double *value) |
static double | st_multilinear_interpolation (DbGrid *dbgrid, int iatt, int distType, const VectorDouble &dmax, const VectorDouble &coor) |
static double | st_distance_modify (DbGrid *dbgrid, int ig, Db *dbpoint, int ip, VectorDouble &dvect, int flag_aniso, int iatt_time, int iatt_angle, int iatt_scaleu, int iatt_scalev, int iatt_scalew) |
void | st_get_closest_sample (DbGrid *dbgrid, int ig, Db *dbpoint, int ip, int flag_aniso, int iatt_time, int iatt_angle, int iatt_scaleu, int iatt_scalev, int iatt_scalew, int *ipmin, double *ddmin, VectorDouble &dvect) |
int | st_next_sample (int ip0_init, const VectorInt &rank, const VectorDouble &xtab, double xtarget) |
static int | st_locate_point_on_grid (const Db *db_point, const DbGrid *db_grid, VectorDouble &coor, VectorDouble &tab) |
static int | st_locate_coor_on_grid (int np, const VectorVectorDouble &coords, const DbGrid *db_grid, VectorDouble &tab) |
static int | st_larger_than_dmax (int ndim, const VectorDouble &dvect, int distType, const VectorDouble &dmax) |
static void | st_expand (int flag_size, DbGrid *dbgrid, VectorDouble &tab1, VectorInt &indg0, VectorInt &indg, VectorDouble &tab2) |
int | migrate (Db *dbin, Db *dbout, const String &name, int dist_type, const VectorDouble &dmax, bool flag_fill, bool flag_inter, bool flag_ball, const NamingConvention &namconv) |
int | migrateMulti (Db *dbin, Db *dbout, const VectorString &names, int dist_type, const VectorDouble &dmax, bool flag_fill, bool flag_inter, bool flag_ball, const NamingConvention &namconv) |
int | migrateByAttribute (Db *dbin, Db *dbout, const VectorInt &atts, int dist_type, const VectorDouble &dmax, bool flag_fill, bool flag_inter, bool flag_ball, const NamingConvention &namconv) |
int | migrateByLocator (Db *dbin, Db *dbout, const ELoc &locatorType, int dist_type, const VectorDouble &dmax, bool flag_fill, bool flag_inter, bool flag_ball, const NamingConvention &namconv) |
int | manageExternalInformation (int mode, const ELoc &locatorType, Db *dbin, Db *dbout, bool *flag_created) |
int | interpolateVariableToPoint (DbGrid *db_grid, int iatt, int np, const double *xp, const double *yp, const double *zp, double *tab) |
double * | dbgridLineSampling (DbGrid *dbgrid, const double *x1, const double *x2, int ndisc, int ncut, const double *cuts, int *nval_ret) |
int | expandPointToGrid (Db *db_point, DbGrid *db_grid, int iatt, int iatt_time, int iatt_angle, int iatt_scaleu, int iatt_scalev, int iatt_scalew, int flag_index, int distType, const VectorDouble &dmax, VectorDouble &tab) |
int | expandPointToCoor (const Db *db1, int iatt, const VectorVectorDouble &coords, VectorDouble &tab) |
int | pointToBlock (Db *dbpoint, DbGrid *dbgrid, int option, int flag_size, int iatt_time, int iatt_size, int iatt_angle, int iatt_scaleu, int iatt_scalev, int iatt_scalew) |
int | migrateGridToCoor (const DbGrid *db_grid, int iatt, const VectorVectorDouble &coords, VectorDouble &tab) |
int | expand_point_to_coor (const Db *db1, int iatt, const VectorVectorDouble &coords, VectorDouble &tab) |
#define RES | ( | nval, | |
idim | |||
) | (res[(idim) + (ndim+1) * (nval)]) |
double* dbgridLineSampling | ( | DbGrid * | dbgrid, |
const double * | x1, | ||
const double * | x2, | ||
int | ndisc, | ||
int | ncut, | ||
const double * | cuts, | ||
int * | nval_ret | ||
) |
Sampling vertices within a Grid between two points
[in] | dbgrid | reference Grid |
[in] | x1 | Array giving the coordinates of the first point |
[in] | x2 | Array giving the coordinates of the second point |
[in] | ndisc | Number of discretized points in the segment |
[in] | ncut | Number of cutoffs |
[in] | cuts | Array of cutoffs |
[out] | nval_ret | Number of samples in the output array |
TODO FUTURE_REFACTOR
int expand_point_to_coor | ( | const Db * | db1, |
int | iatt, | ||
const VectorVectorDouble & | coords, | ||
VectorDouble & | tab | ||
) |
Expands a variable from one point Db into a variable at points defined by coordinate vectors (maximum 3D)
[in] | db1 | descriptor of the input parameters |
[in] | iatt | rank of the input attribute |
[in] | coords | Array of coordinates |
[out] | tab | Output array (Dimension: number of discretized points) |
int expandPointToCoor | ( | const Db * | db1, |
int | iatt, | ||
const VectorVectorDouble & | coords, | ||
VectorDouble & | tab | ||
) |
Expands a variable from one point Db into a variable at points defined by coordinate vectors (maximum 3D)
[in] | db1 | descriptor of the input parameters |
[in] | iatt | rank of the input attribute |
[in] | coords | Array of coordinates |
[out] | tab | Output array (Dimension: number of discretized points) |
int expandPointToGrid | ( | Db * | db_point, |
DbGrid * | db_grid, | ||
int | iatt, | ||
int | iatt_time, | ||
int | iatt_angle, | ||
int | iatt_scaleu, | ||
int | iatt_scalev, | ||
int | iatt_scalew, | ||
int | flag_index, | ||
int | distType, | ||
const VectorDouble & | dmax, | ||
VectorDouble & | tab | ||
) |
Expands a variable from the point structure into a variable in the grid structure
[in] | db_point | Descriptor of the point parameters |
[in] | db_grid | Descriptor of the grid parameters |
[in] | iatt | Rank of the point attribute |
[in] | iatt_time | Optional variable for Time shift |
[in] | iatt_angle | Optional variable for anisotropy angle (around Z) |
[in] | iatt_scaleu | Optional variable for anisotropy scale factor (U) |
[in] | iatt_scalev | Optional variable for anisotropy scale factor (V) |
[in] | iatt_scalew | Optional variable for anisotropy scale factor (W) |
[in] | flag_index | 1 if the Index must be assigned to grid node 0 the 'iatt' attribute is assigned instead |
[in] | distType | Type of distance for calculating maximum distance 1 for L1 and 2 for L2 distance |
[in] | dmax | Array of maximum distances (optional) |
[out] | tab | Output array |
int interpolateVariableToPoint | ( | DbGrid * | db_grid, |
int | iatt, | ||
int | np, | ||
const double * | xp, | ||
const double * | yp, | ||
const double * | zp, | ||
double * | tab | ||
) |
Interpolate a variable from a grid Db on discretization points
[in] | db_grid | Descriptor of the grid parameters |
[in] | iatt | Rank of the attribute in db_grid |
[in] | np | Number of discretized points |
[in] | xp | Array of first coordinates |
[in] | yp | Array of second coordinates |
[in] | zp | Array of third coordinates |
[out] | tab | Output array |
int manageExternalInformation | ( | int | mode, |
const ELoc & | locatorType, | ||
Db * | dbin, | ||
Db * | dbout, | ||
bool * | flag_created | ||
) |
Derive the external information(s) from the Output db (if Grid) to the Input Db
int migrate | ( | Db * | dbin, |
Db * | dbout, | ||
const String & | name, | ||
int | dist_type, | ||
const VectorDouble & | dmax, | ||
bool | flag_fill, | ||
bool | flag_inter, | ||
bool | flag_ball, | ||
const NamingConvention & | namconv | ||
) |
Migrates a variable from one Db to another one
[in] | dbin | Descriptor of the input Db |
[in] | dbout | Descriptor of the output Db |
[in] | name | Name of the attribute to be migrated |
[in] | dist_type | Type of distance for calculating maximum distance 1 for L1 and 2 for L2 distance |
[in] | dmax | Array of maximum distances (optional) |
[in] | flag_fill | Filling option |
[in] | flag_inter | Interpolation |
[in] | flag_ball | Use BallTree sorting algorithm when available |
[in] | namconv | Naming convention |
int migrateByAttribute | ( | Db * | dbin, |
Db * | dbout, | ||
const VectorInt & | atts, | ||
int | dist_type, | ||
const VectorDouble & | dmax, | ||
bool | flag_fill, | ||
bool | flag_inter, | ||
bool | flag_ball, | ||
const NamingConvention & | namconv | ||
) |
Migrates a variable from one Db to another one
[in] | dbin | Descriptor of the input Db |
[in] | dbout | Descriptor of the output Db |
[in] | atts | Array of attributes to be migrated |
[in] | dist_type | Type of distance for calculating maximum distance 1 for L1 and 2 for L2 distance |
[in] | dmax | Array of maximum distances (optional) |
[in] | flag_fill | Filling option |
[in] | flag_inter | Interpolation |
[in] | flag_ball | Use BallTree sorting algorithm when available |
[in] | namconv | Naming Convention |
int migrateByLocator | ( | Db * | dbin, |
Db * | dbout, | ||
const ELoc & | locatorType, | ||
int | dist_type, | ||
const VectorDouble & | dmax, | ||
bool | flag_fill, | ||
bool | flag_inter, | ||
bool | flag_ball, | ||
const NamingConvention & | namconv | ||
) |
Migrates all z-locator variables from one Db to another one
[in] | dbin | Descriptor of the input Db |
[in] | dbout | Descriptor of the output Db |
[in] | locatorType | Locator Type |
[in] | dist_type | Type of distance for calculating maximum distance 1 for L1 and 2 for L2 distance |
[in] | dmax | Array of maximum distances (optional) |
[in] | flag_fill | Filling option |
[in] | flag_inter | Interpolation |
[in] | flag_ball | Use BallTree sorting algorithm when available |
[in] | namconv | Naming convention |
int migrateGridToCoor | ( | const DbGrid * | db_grid, |
int | iatt, | ||
const VectorVectorDouble & | coords, | ||
VectorDouble & | tab | ||
) |
Migrates a variable from the grid structure into a variable at points defined by coordinate vectors
[in] | db_grid | descriptor of the grid parameters |
[in] | iatt | rank of the grid attribute |
[in] | coords | Array of coordinates (dimension: ndim, np) |
[out] | tab | Output array (Dimension: number of discretized points) |
int migrateMulti | ( | Db * | dbin, |
Db * | dbout, | ||
const VectorString & | names, | ||
int | dist_type, | ||
const VectorDouble & | dmax, | ||
bool | flag_fill, | ||
bool | flag_inter, | ||
bool | flag_ball, | ||
const NamingConvention & | namconv | ||
) |
Migrates a set of variables from one Db to another one
[in] | dbin | Descriptor of the input Db |
[in] | dbout | Descriptor of the output Db |
[in] | names | Name of the attribute to be migrated |
[in] | dist_type | Type of distance for calculating maximum distance 1 for L1 and 2 for L2 distance |
[in] | dmax | Array of maximum distances (optional) |
[in] | flag_fill | Filling option |
[in] | flag_inter | Interpolation |
[in] | flag_ball | Use BallTree sorting algorithm when available |
[in] | namconv | Naming convention |
int pointToBlock | ( | Db * | dbpoint, |
DbGrid * | dbgrid, | ||
int | option, | ||
int | flag_size, | ||
int | iatt_time, | ||
int | iatt_size, | ||
int | iatt_angle, | ||
int | iatt_scaleu, | ||
int | iatt_scalev, | ||
int | iatt_scalew | ||
) |
Plunge a set of isolated points within a discretization grid in order to compute the voronoi of the points and derive:
[in] | dbpoint | Descriptor of the point parameters |
[in] | dbgrid | Descriptor of the grid parameters |
[in] | option | Connectivity option (0 for cross and 1 for block) |
[in] | flag_size | When 1, the border pixels report the border thickness When 0, the border pixels are painted in 1 |
[in] | iatt_time | Attribute of 'dbpoint'for Time shift (optional) |
[in] | iatt_size | Attribute of 'dbpoint' giving size (optional) |
[in] | iatt_angle | Optional variable for anisotropy angle (around Z) |
[in] | iatt_scaleu | Optional variable for anisotropy scale factor (U) |
[in] | iatt_scalev | Optional variable for anisotropy scale factor (V) |
[in] | iatt_scalew | Optional variable for anisotropy scale factor (W) |
|
static |
|
static |
Expand the joins at each cell in its vicinity, the radius is given per pixel in the array 'tab1'
[in] | flag_size | when 0, the norder pixels are painted with 1 when 1, the border pixels report the border thckness |
[in] | dbgrid | Descriptor of the grid parameters |
[in] | tab1 | Array containing expansion radius |
[in] | indg0 | Array used for encoding/decoding |
[in] | indg | Array used for encoding/decoding |
[in] | tab2 | Returned array |
void st_get_closest_sample | ( | DbGrid * | dbgrid, |
int | ig, | ||
Db * | dbpoint, | ||
int | ip, | ||
int | flag_aniso, | ||
int | iatt_time, | ||
int | iatt_angle, | ||
int | iatt_scaleu, | ||
int | iatt_scalev, | ||
int | iatt_scalew, | ||
int * | ipmin, | ||
double * | ddmin, | ||
VectorDouble & | dvect | ||
) |
Update minimum distance and rank of the corresponding sample
[in] | dbgrid | Descriptor of the grid parameters |
[in] | ig | Rank of the sample in the Grid file |
[in] | dbpoint | Descriptor of the point parameters |
[in] | ip | Rank of the sample in the Point file |
[in] | flag_aniso | 1 if anisotropic distance must be calculated |
[in] | iatt_time | Optional variable for Time shift |
[in] | iatt_angle | Optional variable for anisotropy angle (around Z) |
[in] | iatt_scaleu | Optional variable for anisotropy scale factor (U) |
[in] | iatt_scalev | Optional variable for anisotropy scale factor (V) |
[in] | iatt_scalew | Optional variable for anisotropy scale factor (W) |
[in,out] | ipmin | Rank of the Point sample |
[in,out] | ddmin | Minimum distance |
[out] | dvect | Working vector |
|
static |
Check if vector is out of range by comparing each component to the maximum value defined per direction
[in] | ndim | Space dimension |
[in] | dvect | Vector |
[in] | distType | Type of distance for calculating maximum distance 1 for L1 and 2 for L2 distance |
[in] | dmax | Array of maximum distances (optional) |
|
static |
Locate a set of points on a grid
[in] | np | Number of samples |
[in] | coords | Array of coordinates (dimension: ndim, np) |
[in] | db_grid | descriptor of the grid parameters |
[out] | tab | Output array (Dimension: Number of discretized points) |
|
static |
Locate a set of points on a grid
[in] | db_point | descriptor of the point parameters |
[in] | db_grid | descriptor of the grid parameters |
[out] | coor | Working array |
[out] | tab | Output array (Dimension: Number of point samples) |
|
static |
|
static |
Perform the multi-linear interpolation from a regular grid Db
[in] | dbgrid | descriptor of the grid parameters |
[in] | iatt | rank of the target variable in dbgrid |
[in] | distType | Type of distance for calculating maximum distance 1 for L1 and 2 for L2 distance |
[in] | dmax | Array of maximum distances (optional) |
[in] | coor | Coordinates of the target point |
int st_next_sample | ( | int | ip0_init, |
const VectorInt & | rank, | ||
const VectorDouble & | xtab, | ||
double | xtarget | ||
) |
Get the rank of the next sample just above the target To speed up the process, this operation is performed starting from the rank assigned to the previous sample (this assumes that samples are treated by increasing coordinate)
ip0_init | Rank of the previous sample |
rank | Array of sample ordering |
xtab | Array of sample coordinates |
xtarget | Target coordinate |
|
static |