1.2.1
CCC
 
util.cpp File Reference
#include <Geometry/GeometryHelper.hpp>
#include "geoslib_f.h"
#include "geoslib_old_f.h"
#include "geoslib_f_private.h"
#include "LithoRule/Rule.hpp"
#include "Basic/Law.hpp"
#include "Basic/AException.hpp"
#include "Basic/Utilities.hpp"
#include "Basic/File.hpp"
#include "Basic/String.hpp"
#include "Basic/OptDbg.hpp"
#include "Basic/PolyLine2D.hpp"
#include "Space/ASpaceObject.hpp"
#include "Space/ASpace.hpp"
#include "Space/SpaceSN.hpp"
#include <string.h>
#include <complex>
#include <cmath>
#include <regex>

Classes

struct  Keypair
 
struct  Projec_Environ
 
struct  Dim_Loop
 

Functions

void projec_toggle (int mode)
 
void projec_query (int *actif)
 
void projec_print (void)
 
void set_keypair (const char *keyword, int origin, int nrow, int ncol, const double *values)
 
void app_keypair (const char *keyword, int origin, int nrow, int ncol, double *values)
 
void set_keypair_int (const char *keyword, int origin, int nrow, int ncol, int *values)
 
void app_keypair_int (const char *keyword, int origin, int nrow, int ncol, int *values)
 
void del_keypair (const char *keyword, int flag_exact)
 
double get_keypone (const char *keyword, double valdef)
 
int get_keypair (const char *keyword, int *nrow, int *ncol, double **values)
 
int get_keypair_int (const char *keyword, int *nrow, int *ncol, int **values)
 
void print_keypair (int flag_short)
 
int solve_P2 (double a, double b, double c, double *x)
 
int solve_P3 (double a, double b, double c, double d, double *x)
 
double ut_distance (int ndim, const double *tab1, const double *tab2)
 
void ut_distance_allocated (int ndim, double **tab1, double **tab2)
 
VectorDouble util_set_array_double (int ntab, const double *rtab)
 
VectorInt util_set_array_integer (int ntab, const int *itab)
 
VectorString util_set_array_char (int ntab, char **names)
 
void set_last_message (int mode, const char *string)
 
void print_last_message (void)
 
int * ut_split_into_two (int ncolor, int flag_half, int verbose, int *nposs)
 
char * convert (const std::string &s)
 
std::vector< char * > util_vs_to_vs (VectorString vs)
 

Function Documentation

void app_keypair ( const char *  keyword,
int  origin,
int  nrow,
int  ncol,
double *  values 
)

Deposit a keypair (double values) - Append to existing array

Parameters
[in]keywordKeyword
[in]origin1 from C; 2 from R
[in]nrowNumber of rows
[in]ncolNumber of columns
[in]valuesArray of values (Dimension: nrow * ncol)
Remarks
Appending extends the number of rows but keeps the number of
columns and the origin unchanged... otherwise fatal error is issued
All keypair related function use realloc (rather than mem_realloc)
not to show up in the memory leak calculations
void app_keypair_int ( const char *  keyword,
int  origin,
int  nrow,
int  ncol,
int *  values 
)

Deposit a keypair (doubleinteger values) - Append to existing array

Parameters
[in]keywordKeyword
[in]origin1 from C; 2 from R
[in]nrowNumber of rows
[in]ncolNumber of columns
[in]valuesArray of values (Dimension: nrow * ncol)
Remarks
Appending extends the number of rows but keeps the number of
columns and the origin unchanged ... otherwise fatal error is issued
All keypair related function use realloc (rather than mem_realloc)
not to show up in the memory leak calculations
char* convert ( const std::string &  s)

Convert std::string into a char *

Returns
Pointer to the returned array of characters
Parameters
[in]sInput VectorString
void del_keypair ( const char *  keyword,
int  flag_exact 
)

Delete a keypair

Parameters
[in]keywordKeyword to be deleted
[in]flag_exact1 if Exact keyword matching is required
Remarks
All keypair related function use malloc (rather than mem_alloc)
not to show up in the memory leak calculations
int get_keypair ( const char *  keyword,
int *  nrow,
int *  ncol,
double **  values 
)

Inquiry the keypair

Returns
Error returned code
Parameters
[in]keywordKeyword
[out]nrowNumber of rows
[out]ncolNumber of columns
[out]valuesArray of values attached to the keyword
Remarks
The returned array must be freed by the calling function
All keypair related function use malloc (rather than mem_alloc)
not to show up in the memory leak calculations
int get_keypair_int ( const char *  keyword,
int *  nrow,
int *  ncol,
int **  values 
)

Inquiry the keypair (integer values)

Returns
Error returned code
Parameters
[in]keywordKeyword
[out]nrowNumber of rows
[out]ncolNumber of columns
[out]valuesArray of values attached to the keyword
Remarks
The returned array must be freed by the calling function
All keypair related function use malloc (rather than mem_alloc)
not to show up in the memory leak calculations
double get_keypone ( const char *  keyword,
double  valdef 
)

Inquiry the keypair (for a single value)

Returns
Returned value
Parameters
[in]keywordKeyword
[in]valdefFactory setting value
Remarks
This function will returns systematically the default value
if the targeted keypair contains more than a single value
void print_keypair ( int  flag_short)

Print the list of keypairs

Parameters
[in]flag_short1 for a short output
void print_last_message ( void  )

Print the array of last messages

void projec_print ( void  )

Print the characteristics of the projection

void projec_query ( int *  actif)

Returns the projection characteristics

Parameters
[out]actifactivity flag
void projec_toggle ( int  mode)

Toggle the status of the Projection flag

Parameters
[in]modeToggle of the projection flag
  • 0 : Switch the flag OFF
  • 1 : Switch the flag ON
  • -1 : Toggle the flag
  • else : Do not modify the flag
void set_keypair ( const char *  keyword,
int  origin,
int  nrow,
int  ncol,
const double *  values 
)

Deposit a keypair (double values)

Parameters
[in]keywordKeyword
[in]origin1 from C; 2 from R
[in]nrowNumber of rows
[in]ncolNumber of columns
[in]valuesArray of values (Dimension: nrow * ncol)
Remarks
All keypair related function use malloc (rather than mem_alloc)
not to show up in the memory leak calculations
void set_keypair_int ( const char *  keyword,
int  origin,
int  nrow,
int  ncol,
int *  values 
)

Deposit a keypair (integer values)

Parameters
[in]keywordKeyword
[in]origin1 from C; 2 from R
[in]nrowNumber of rows
[in]ncolNumber of columns
[in]valuesArray of values (Dimension: nrow * ncol)
Remarks
All keypair related function use malloc (rather than mem_alloc)
not to show up in the memory leak calculations
void set_last_message ( int  mode,
const char *  string 
)

Deposit a last message

Parameters
[in]modeType of operation 0 to empty the array of messages 1 to add the string to the array of messages -1 to concatenate the string to the last message
[in]stringCurrent string
Remarks
All keypair related function use malloc (rather than mem_alloc)
not to show up in the memory leak calculations
int solve_P2 ( double  a,
double  b,
double  c,
double *  x 
)

Find the roots of a polynomial of order 2: ax^2 + bx + c = 0

Returns
Number of real solutions
Parameters
[in]a,b,cCoefficients of the polynomial
[out]xArray of real solutions (Dimension: 2)
Remarks
When the solution is double, the returned number os 1.
int solve_P3 ( double  a,
double  b,
double  c,
double  d,
double *  x 
)

Find the roots of a polynomial of order 3: a*x^3 + b*x^2 + c*x + d = 0

Returns
Number of real solutions
Parameters
[in]a,b,c,dCoefficients of the polynomial
[out]xArray of real solutions (Dimension: 3)
Remarks
When the solution is double, the returned number os 1.
double ut_distance ( int  ndim,
const double *  tab1,
const double *  tab2 
)

Calculate the distance between two endpoints

Returns
Distance value (or TEST if a coordinate is not defined)
Parameters
[in]ndimSpace dimension
[in]tab1Array corresponding to the first endpoint
[in]tab2Array corresponding to the second endpoint
void ut_distance_allocated ( int  ndim,
double **  tab1,
double **  tab2 
)

Allocate the necessary arrays for calculating distances using already allocated arrays

Parameters
[in]ndimSpace dimension
[out]tab1Array for coordinates of first sample
[out]tab2Array for coordinates of second sample
Remarks
This function uses realloc (rather than mem_realloc)
not to show up in the memory leak calculations
int* ut_split_into_two ( int  ncolor,
int  flag_half,
int  verbose,
int *  nposs 
)

Return all the ways to split ncolor into two non-empty subsets

Returns
Return an array of possibilities
Parameters
[in]ncolorNumber of colors
[in]flag_half1 if only half of possibilities must be envisaged
[in]verbose1 for a verbose option
[out]npossNumber of possibilities
Remarks
The calling function must free the returned array.
The array has 'ncolor' columns and 'ncomb' subsets
The elements of each row are set to 0 or 1 (subset rank)
VectorString util_set_array_char ( int  ntab,
char **  names 
)

Create a VectorString for storing an array of chars

Returns
The VectorString
Parameters
[in]ntabNumber of samples
[in]namesArray of character values to be loaded
VectorDouble util_set_array_double ( int  ntab,
const double *  rtab 
)

Create a VectorDouble for storing an array of double

Returns
The VectorDouble
Parameters
[in]ntabNumber of samples
[in]rtabArray of double values to be loaded
VectorInt util_set_array_integer ( int  ntab,
const int *  itab 
)

Create a VectorInt for storing an array of integer

Returns
The VectorInt
Parameters
[in]ntabNumber of samples
[in]itabArray of integer values to be loaded
std::vector<char*> util_vs_to_vs ( VectorString  vs)

Convert VectorString into a std::vector<char *> structure

Returns
Pointer to the returned array of characters
Parameters
[in]vsInput VectorString