1.2.3
CCC
 
CalcMigrate.cpp File Reference
#include "geoslib_f_private.h"
#include "Enum/ELoc.hpp"
#include "Basic/NamingConvention.hpp"
#include "Basic/OptDbg.hpp"
#include "Calculators/CalcMigrate.hpp"
#include "Calculators/ACalcDbToDb.hpp"
#include "Db/DbGrid.hpp"
#include "Db/Db.hpp"
#include "Morpho/Morpho.hpp"
#include "Tree/Ball.hpp"
#include "Tree/KNN.hpp"
#include "geoslib_old_f.h"
#include <math.h>

Macros

#define RES(nval, idim)   (res[(idim) + (ndim+1) * (nval)])
 

Functions

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)
 
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, double *xp, double *yp, double *zp, double *tab)
 
double * dbgridLineSampling (DbGrid *dbgrid, double *x1, double *x2, int ndisc, int ncut, 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)
 

Macro Definition Documentation

#define RES (   nval,
  idim 
)    (res[(idim) + (ndim+1) * (nval)])

Function Documentation

double* dbgridLineSampling ( DbGrid dbgrid,
double *  x1,
double *  x2,
int  ndisc,
int  ncut,
double *  cuts,
int *  nval_ret 
)

Sampling vertices within a Grid between two points

Returns
Array of sampled vertices
Parameters
[in]dbgridreference Grid
[in]x1Array giving the coordinates of the first point
[in]x2Array giving the coordinates of the second point
[in]ndiscNumber of discretized points in the segment
[in]ncutNumber of cutoffs
[in]cutsArray of cutoffs
[out]nval_retNumber of samples in the output array
Remarks
This function considers the segment [x1,x2] and subdivises it
into 'ndisc' intervals. The endpoints of each interval correspond
to two points in the space
At each endpoint, the target variable is interpolated from the grid
If the target variable values cross a cutoff, the coordinates of
the intersection are calculated.
The program returns the list of all these intersection coordinates
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)

Returns
Error return code
Parameters
[in]db1descriptor of the input parameters
[in]iattrank of the input attribute
[in]coordsArray of coordinates
[out]tabOutput 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)

Returns
Error return code
Parameters
[in]db1descriptor of the input parameters
[in]iattrank of the input attribute
[in]coordsArray of coordinates
[out]tabOutput 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

Returns
Error return code
Parameters
[in]db_pointDescriptor of the point parameters
[in]db_gridDescriptor of the grid parameters
[in]iattRank of the point attribute
[in]iatt_timeOptional variable for Time shift
[in]iatt_angleOptional variable for anisotropy angle (around Z)
[in]iatt_scaleuOptional variable for anisotropy scale factor (U)
[in]iatt_scalevOptional variable for anisotropy scale factor (V)
[in]iatt_scalewOptional variable for anisotropy scale factor (W)
[in]flag_index1 if the Index must be assigned to grid node 0 the 'iatt' attribute is assigned instead
[in]distTypeType of distance for calculating maximum distance 1 for L1 and 2 for L2 distance
[in]dmaxArray of maximum distances (optional)
[out]tabOutput array
Remarks
When a Time Shift is present, this corresponds to Johnson-Mehl
The Time Shift is an optional variable which increases the
distance (the time-to-distance conversion is assumed to be 1)
Only positive Time Shifts are considered
int interpolateVariableToPoint ( DbGrid db_grid,
int  iatt,
int  np,
double *  xp,
double *  yp,
double *  zp,
double *  tab 
)

Interpolate a variable from a grid Db on discretization points

Parameters
[in]db_gridDescriptor of the grid parameters
[in]iattRank of the attribute in db_grid
[in]npNumber of discretized points
[in]xpArray of first coordinates
[in]ypArray of second coordinates
[in]zpArray of third coordinates
[out]tabOutput array
Remarks
The arguments 'xp', 'yp' and 'zp' must be defined in accordance
with the space dimension in argument 'db_grid'
A point which does not lie between two valuated grid nodes
(in all space dimensions) is always set to FFFF
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

Returns
Error return code
Parameters
[in]mode1 for allocation; -1 for deallocation
[in]locatorTypeType of the pointer (ELoc)
[in]dbinDescriptor of the input Db
[in]dboutDescriptor of the output Db
[out]flag_createdTrue if variables have been created
Remarks
This function only functions when the Output Db is a grid
However, in case of a Point output Db, this function should not
be used: the external drift functions should already be present
in the output Db.
If this is not the case, an error is issued.
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

Returns
Error return code
Parameters
[in]dbinDescriptor of the input Db
[in]dboutDescriptor of the output Db
[in]nameName of the attribute to be migrated
[in]dist_typeType of distance for calculating maximum distance 1 for L1 and 2 for L2 distance
[in]dmaxArray of maximum distances (optional)
[in]flag_fillFilling option
[in]flag_interInterpolation
[in]flag_ballUse BallTree sorting algorithm when available
[in]namconvNaming 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

Returns
Error return code
Parameters
[in]dbinDescriptor of the input Db
[in]dboutDescriptor of the output Db
[in]attsArray of attributes to be migrated
[in]dist_typeType of distance for calculating maximum distance 1 for L1 and 2 for L2 distance
[in]dmaxArray of maximum distances (optional)
[in]flag_fillFilling option
[in]flag_interInterpolation
[in]flag_ballUse BallTree sorting algorithm when available
[in]namconvNaming 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

Returns
Error return code
Parameters
[in]dbinDescriptor of the input Db
[in]dboutDescriptor of the output Db
[in]locatorTypeLocator Type
[in]dist_typeType of distance for calculating maximum distance 1 for L1 and 2 for L2 distance
[in]dmaxArray of maximum distances (optional)
[in]flag_fillFilling option
[in]flag_interInterpolation
[in]flag_ballUse BallTree sorting algorithm when available
[in]namconvNaming convention
Remarks
The output variable receive the same locator as the input variables
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

Returns
Error return code
Parameters
[in]db_griddescriptor of the grid parameters
[in]iattrank of the grid attribute
[in]coordsArray of coordinates (dimension: ndim, np)
[out]tabOutput 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

Returns
Error return code
Parameters
[in]dbinDescriptor of the input Db
[in]dboutDescriptor of the output Db
[in]namesName of the attribute to be migrated
[in]dist_typeType of distance for calculating maximum distance 1 for L1 and 2 for L2 distance
[in]dmaxArray of maximum distances (optional)
[in]flag_fillFilling option
[in]flag_interInterpolation
[in]flag_ballUse BallTree sorting algorithm when available
[in]namconvNaming 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:

  • the statistics on the volume and perimeter of the cells
  • the edge between cells
Returns
Error return code
Parameters
[in]dbpointDescriptor of the point parameters
[in]dbgridDescriptor of the grid parameters
[in]optionConnectivity option (0 for cross and 1 for block)
[in]flag_sizeWhen 1, the border pixels report the border thickness When 0, the border pixels are painted in 1
[in]iatt_timeAttribute of 'dbpoint'for Time shift (optional)
[in]iatt_sizeAttribute of 'dbpoint' giving size (optional)
[in]iatt_angleOptional variable for anisotropy angle (around Z)
[in]iatt_scaleuOptional variable for anisotropy scale factor (U)
[in]iatt_scalevOptional variable for anisotropy scale factor (V)
[in]iatt_scalewOptional variable for anisotropy scale factor (W)
Remarks
The value of 'flag_index' can be turned on for assigning
the sample index to the grid cell (instead of the 'iatt' value)
using: set_keypair("PTB_flag_index")
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

Parameters
[in]dbgridDescriptor of the grid parameters
[in]igRank of the sample in the Grid file
[in]dbpointDescriptor of the point parameters
[in]ipRank of the sample in the Point file
[in]flag_aniso1 if anisotropic distance must be calculated
[in]iatt_timeOptional variable for Time shift
[in]iatt_angleOptional variable for anisotropy angle (around Z)
[in]iatt_scaleuOptional variable for anisotropy scale factor (U)
[in]iatt_scalevOptional variable for anisotropy scale factor (V)
[in]iatt_scalewOptional variable for anisotropy scale factor (W)
[in,out]ipminRank of the Point sample
[in,out]ddminMinimum distance
[out]dvectWorking vector
Remarks
The Time Shift is an optional variable which increases the
distance (the time-to-distance conversion is assumed to be 1)
Only positive Time Shifts are considered
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)

Parameters
ip0_initRank of the previous sample
rankArray of sample ordering
xtabArray of sample coordinates
xtargetTarget coordinate
Returns
Rank of the sample just above the target (or equal)
Note
: The use of 'ip0_init' which could be different from 0 has been abandoned temporarily