cbec90699f
- creato il progetto in Visual Studio per compilare come libreria statica - modifiche al codice originale per integrarlo nelle nostre librerie.
194 lines
6.4 KiB
C++
194 lines
6.4 KiB
C++
/*****************************************************************************/
|
|
/* */
|
|
/* F I S T : Fast, Industrial-Strength Triangulation */
|
|
/* */
|
|
/*****************************************************************************/
|
|
/* */
|
|
/* (C) Martin Held */
|
|
/* (C) Universitaet Salzburg, Salzburg, Austria */
|
|
/* */
|
|
/* This code is not in the public domain. All rights reserved! Please make */
|
|
/* sure to read the full copyright statement contained in api_functions.cpp. */
|
|
/* */
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
|
/* get standard libraries */
|
|
/* */
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <assert.h>
|
|
|
|
/* */
|
|
/* get my header files */
|
|
/* */
|
|
#include "fpkernel.h"
|
|
#include "martin.h"
|
|
#include "defs.h"
|
|
#include "header.h"
|
|
|
|
/* */
|
|
/* function prototypes of functions provided in this file */
|
|
/* */
|
|
boolean ReadOptionalNumber(FILE *input, int *data);
|
|
boolean ReadOptionalCoord(FILE *input, double *xy);
|
|
boolean ReadNumber(FILE *input, int *data);
|
|
boolean ReadVectorData(FILE *input, double *xc, double *yc);
|
|
#ifdef EXT_APPL_SITES
|
|
boolean ReadPntData(FILE *input, double *xc, double *yc, eas_type *eas_data);
|
|
#else
|
|
boolean ReadPntData(FILE *input, double *xc, double *yc);
|
|
#endif
|
|
#ifdef EXT_APPL_SITES
|
|
void WritePntData(FILE *output, machine_double xc, machine_double yc,
|
|
eas_type *eas_data);
|
|
#else
|
|
void WritePntData(FILE *output, machine_double xc, machine_double yc);
|
|
#endif
|
|
void WriteNumber(FILE *output, int number);
|
|
void WriteVectorData(FILE *output, machine_double xc, machine_double yc);
|
|
|
|
|
|
|
|
/* */
|
|
/* the following functions provide the basic functionality for parsing my */
|
|
/* data files. you are welcome to adapt them to your needs. however, please */
|
|
/* note that my own data files do not contain "exterior application" data. */
|
|
/* thus, you won't be able to parse my sample data files after switching to */
|
|
/* "exterior application" or after modifying the I/O strings. all input */
|
|
/* functions return "false" if EOF or an incorrect data format is */
|
|
/* encountered, and "true" otherwise. please make sure not to change this */
|
|
/* behavior if you'd decide to modify them! */
|
|
/* */
|
|
|
|
|
|
boolean ReadOptionalNumber(FILE *input, int *data)
|
|
{
|
|
#if 1
|
|
/* */
|
|
/* use this branch if your files provide this data. */
|
|
/* */
|
|
if (EOF == fscanf(input, "%d", data))
|
|
return false;
|
|
else
|
|
return true;
|
|
#else
|
|
/* */
|
|
/* use this branch if your files do not provide this data. */
|
|
/* */
|
|
*data = 0;
|
|
return true;
|
|
#endif
|
|
}
|
|
|
|
|
|
boolean ReadOptionalCoord(FILE *input, double *xy)
|
|
{
|
|
#if 1
|
|
/* */
|
|
/* use this branch if your files provide this data. */
|
|
/* */
|
|
if (EOF == FP_fscanf(input, "%lf", xy))
|
|
return false;
|
|
else
|
|
return true;
|
|
#else
|
|
/* */
|
|
/* use this branch if your files do not provide this data. */
|
|
/* */
|
|
*xy = 0.0;
|
|
return true;
|
|
#endif
|
|
}
|
|
|
|
|
|
|
|
boolean ReadNumber(FILE *input, int *data)
|
|
{
|
|
if (EOF == fscanf(input, "%d", data))
|
|
return false;
|
|
else
|
|
return true;
|
|
}
|
|
|
|
|
|
#ifdef EXT_APPL_SITES
|
|
boolean ReadPntData(FILE *input, double *xc, double *yc, eas_type *eas_data)
|
|
{
|
|
/*
|
|
* sample line for user-specific eas data:
|
|
* if (EOF == fscanf(input, "%lf, %lf, %ld, %s", xc, yc,
|
|
* &(eas_data->id), eas_data->ch))
|
|
*/
|
|
if (EOF == FP_fscanf(input, "%lf %lf %d", xc, yc, eas_data))
|
|
return false;
|
|
else
|
|
return true;
|
|
}
|
|
#else
|
|
boolean ReadPntData(FILE *input, double *xc, double *yc)
|
|
{
|
|
if (EOF == FP_fscanf(input, "%lf %lf", xc, yc))
|
|
return false;
|
|
else
|
|
return true;
|
|
}
|
|
#endif
|
|
|
|
|
|
|
|
boolean ReadVectorData(FILE *input, double *xc, double *yc)
|
|
{
|
|
if (EOF == FP_fscanf(input, "%lf %lf", xc, yc))
|
|
return false;
|
|
else
|
|
return true;
|
|
}
|
|
|
|
|
|
#ifdef EXT_APPL_SITES
|
|
void WritePntData(FILE *output, machine_double xc, machine_double yc,
|
|
eas_type *eas_data)
|
|
{
|
|
fprintf(output, "%f %f %d\n", xc, yc, *eas_data);
|
|
/*
|
|
* sample line for user-specific eas data
|
|
*
|
|
* fprintf(output, "%10d %10d %12ld %10s\n",
|
|
* (int) (xc + 0.5), (int) (yc + 0.5),
|
|
* eas_data->id, eas_data->ch);
|
|
*/
|
|
|
|
return;
|
|
}
|
|
#else
|
|
void WritePntData(FILE *output, machine_double xc, machine_double yc)
|
|
{
|
|
fprintf(output, "%f %f\n", MDOUBLE_TO_IOMDOUBLE(xc), MDOUBLE_TO_IOMDOUBLE(yc));
|
|
|
|
return;
|
|
}
|
|
#endif
|
|
|
|
|
|
|
|
void WriteVectorData(FILE *output, machine_double xc, machine_double yc)
|
|
{
|
|
fprintf(output, "%f %f\n", MDOUBLE_TO_IOMDOUBLE(xc), MDOUBLE_TO_IOMDOUBLE(yc));
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
void WriteNumber(FILE *output, int number)
|
|
{
|
|
fprintf(output, "%d\n", number);
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
|