Extern :
- aggiunta libreria vroni 7.6.
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
// recupero le definizioni dal file api_functions.cc
|
||||
|
||||
#pragma once
|
||||
|
||||
/* */
|
||||
/* get standard libraries */
|
||||
/* */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* */
|
||||
/* get my header files */
|
||||
/* */
|
||||
#include "fpkernel.h"
|
||||
#include "coord.h"
|
||||
#include "vroni_object.h"
|
||||
|
||||
|
||||
/* */
|
||||
/* function prototypes of functions provided in this file; see arg_eval.cc */
|
||||
/* for the default values of most of those parameters. */
|
||||
/* */
|
||||
|
||||
// get access to underlying VD
|
||||
vroniObject& API_VD();
|
||||
|
||||
void API_ParseCommandLineArgs(int argc, char *argv[], vr_bool *graphics, vr_bool *color_graphics, vr_bool *full_screen);
|
||||
|
||||
// call this routine once prior calling any other routine of VRONI
|
||||
void API_InitializeProgram(void);
|
||||
|
||||
void API_GetInputData(vr_bool *input_received);
|
||||
|
||||
void API_ProceedWithoutGraphics(vr_bool new_input);
|
||||
|
||||
// call this routine whenever new data is to be input and VRONI's data structures are to be reset;
|
||||
// note that this function won't free memory allocated
|
||||
void API_ResetAll(void);
|
||||
|
||||
// call this routine to release all memory allocated by VRONI
|
||||
void API_TerminateProgram(void);
|
||||
|
||||
|
||||
void API_HandleInput(char input_file[], // name of the input file
|
||||
vr_bool *new_input, // true if new data has been read
|
||||
vr_bool read_polygon, // read ".dat" format
|
||||
vr_bool read_poly, // read ".poly" format
|
||||
vr_bool read_sites, // read ".site" format
|
||||
vr_bool read_xdr, // read ".xdr" format
|
||||
vr_bool read_e00, // read ".e00" format
|
||||
vr_bool read_polylines, // read ".polylines" format
|
||||
vr_bool read_usgs, // read ".usgs" format
|
||||
vr_bool read_dxf, // read ".dxf" format
|
||||
vr_bool read_pnts, // read ".pnt" format
|
||||
vr_bool read_graphml); // read ".graphml" format
|
||||
|
||||
// this function requires the user to stick to my naming convention for the extension of the input file relative to the data format used
|
||||
void API_FileInput(char input_file[], // name of the input file
|
||||
vr_bool *new_input); // true if new data has been read
|
||||
|
||||
void API_ArrayInput( int number_of_points, // data in point_data[0,..,k] for k := number_of_points-1
|
||||
in_pnts *point_data, // see ext_appl_inout.h
|
||||
int number_of_segments,
|
||||
in_segs *segment_data, // see ext_appl_inout.h
|
||||
int number_of_arcs,
|
||||
in_arcs *arc_data, // see ext_appl_inout.h
|
||||
vr_bool *new_input);
|
||||
|
||||
void API_ComputeVD( vr_bool save_data, // save input data to file?
|
||||
vr_bool new_data, // first call for this data?
|
||||
vr_bool time, // do you want to time the computation?
|
||||
int bound, // scale factor for bounding box; default value: 3
|
||||
int sample, // sampling factor for sampling segs/arcs; default: 0; see SampleData() in approx.cc
|
||||
int approx, // approximation factor for circular arcs; default: 0; see ApproxArcsHeuristic() in approx.cc. obsolet by now!
|
||||
char output_file[], // name of the output file; irrelevant if save_data is false
|
||||
vr_bool discard_duplicate_sites, //d shall the code check prior to the computation whether duplicate segs/arcs have been input? default: false.
|
||||
vr_bool pnts_only, // compute VD/DT of points only
|
||||
vr_bool write_vd_dt, // output point VD/DT
|
||||
char vd_dt_file[], // output file for point VD/DT
|
||||
vr_bool clean_up); // shall we clean up the data prior to the VD computation?
|
||||
|
||||
void API_ComputeOff( vr_bool time, // do you want to time the computation?
|
||||
char off_file[], // name of the file that will contain the offsets computed
|
||||
vr_bool write_off, // shall we output the offsets to off_file[]?
|
||||
vr_bool dxf_format, // if offsets are to be output: shall we use DXF format?
|
||||
double t_offset, // compute offset curve(s) for offset distance t_offset
|
||||
double d_offset, // incremental step-over distance for further offset curves
|
||||
vr_bool auto_offset, // shall we use my heuristic for finding offset distances that create a family of offsets?
|
||||
vr_bool left_offset, // true if offsets are to be computed only on the left side of input segments
|
||||
vr_bool right_offset); // true if offsets are to be computed only on the right side of input segments
|
||||
|
||||
|
||||
void API_ComputeWMAT( vr_bool auto_wmat, // shall we use my heuristic for finding nice WMAT thresholds?
|
||||
double wmat_angle, // angle threshold for WMAT computation;in radians, out of the interval [0, pi]
|
||||
double wmat_dist, // distance threshold for WMAT computation
|
||||
vr_bool time, // do you want to time the computation?
|
||||
vr_bool left_wmat, // true if WMAT is to be computed only on the left side of input segments
|
||||
vr_bool right_wmat); // true if WMAT is to be computed only on the right side of input segments
|
||||
|
||||
|
||||
#ifdef WRITE_VD
|
||||
void API_Output_VD( char vd_file[], // name of the file that will contain the VD polygons
|
||||
double vd_apx_dist, // sampling distance used for approximating conic VD edges
|
||||
vr_bool left_vd, // true if VD is to be output only on the left side of input segments
|
||||
vr_bool right_vd); // true if VD is to be output on the right side of input segments
|
||||
#endif
|
||||
|
||||
void API_ComputeOutputMIC( vr_bool time, // do you want to time the computation?
|
||||
vr_bool left_mic, // true if MIC is to be computed only on the left side of input segments
|
||||
vr_bool right_mic, // true if MIC is to be computed only on the right side of input segments
|
||||
coord *center, // x,y-coordinates of a MIC center
|
||||
double *radius); // radius of a MIC circle
|
||||
|
||||
void API_OutputMA(char vdma_file[]) ;
|
||||
|
||||
// discard all offsets computed so far
|
||||
void API_ResetOffsetData(void);
|
||||
|
||||
// VRONI exception handling
|
||||
void API_HandleError(void);
|
||||
|
||||
const char* API_GetProgName();
|
||||
const char* API_GetProgVersion();
|
||||
const char* API_GetProgYear();
|
||||
@@ -0,0 +1,101 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 2003--2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_APPROX_H
|
||||
#define VRONI_APPROX_H
|
||||
|
||||
inline void ApproxArc(const coord & p1, const coord & p2,
|
||||
double_arg xc3, double_arg yc3, double_arg radius,
|
||||
vr_bool ccw_orientation, double_arg apx_absolute,
|
||||
vronivector<coord> & apx_vtx, int & max_num_apx_vtx,
|
||||
double_arg max_incr, int & number)
|
||||
{
|
||||
double incr;
|
||||
/* */
|
||||
/* determine the start angle and end angle of the arc */
|
||||
/* */
|
||||
double angle_s = atan2(p1.y - yc3, p1.x - xc3);
|
||||
double angle_e = atan2(p2.y - yc3, p2.x - xc3);
|
||||
|
||||
if (angle_s < 0.0) angle_s += M_2PI;
|
||||
if (angle_e < 0.0) angle_e += M_2PI;
|
||||
if (angle_e < angle_s) angle_e += M_2PI;
|
||||
|
||||
/* */
|
||||
/* determine the angular increment incr: we will insert points at */
|
||||
/* the angles angle_s + 0.5 * incr, angle_s + 1.5 * incr, ..., */
|
||||
/* angle_e - 0.5 * incr (for a CCW arc). */
|
||||
/* */
|
||||
|
||||
if (apx_absolute > 0.0) {
|
||||
incr = acos(radius / (radius + apx_absolute));
|
||||
incr = Min(incr, max_incr);
|
||||
}
|
||||
else {
|
||||
incr = max_incr;
|
||||
}
|
||||
incr *= 10.0;
|
||||
assert(gt(incr, ZERO));
|
||||
double diff = (angle_e - angle_s);
|
||||
incr = diff / (2.0 * incr);
|
||||
number = REAL_TO_INT(Ceiling(incr));
|
||||
if (number <= 0) number = 1;
|
||||
incr = diff / ((double) (number));
|
||||
|
||||
/* */
|
||||
/* the new pnts will lie at a distance lgth from the arc's center */
|
||||
/* */
|
||||
// double lgth = radius / cos(incr / 2.0);
|
||||
double lgth = radius;
|
||||
double alpha;
|
||||
if (ccw_orientation) {
|
||||
alpha = angle_s + incr / 2.0;
|
||||
}
|
||||
else {
|
||||
alpha = angle_e - incr / 2.0;
|
||||
incr = - incr;
|
||||
}
|
||||
|
||||
/* */
|
||||
/* allocate memory for the new vertices to be computed */
|
||||
/* */
|
||||
if (number > max_num_apx_vtx) {
|
||||
max_num_apx_vtx = number;
|
||||
gentlyResizeSTLVector(apx_vtx, max_num_apx_vtx, "approx:apx_vtx");
|
||||
}
|
||||
|
||||
/* */
|
||||
/* compute and store the new pnts and segs */
|
||||
/* */
|
||||
//printf("p1.x = %20.16f, p1.y = %20.16f\n", p1.x, p1.y);
|
||||
//printf("p2.x = %20.16f, p2.y = %20.16f\n", p2.x, p2.y);
|
||||
for (int k = 0; k < number; ++k) {
|
||||
assert(k <= max_num_apx_vtx);
|
||||
apx_vtx[k].x = xc3 + lgth * cos(alpha);
|
||||
apx_vtx[k].y = yc3 + lgth * sin(alpha);
|
||||
//printf("alpha = %20.16f\n", alpha);
|
||||
alpha += incr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,46 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 2007-2023 M. Held, S. Huber */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Stefan Huber, Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef VRONI_ARC_COMMON_H
|
||||
#define VRONI_ARC_COMMON_H
|
||||
|
||||
|
||||
//Uncomment this line to print quality messages
|
||||
//#define ARC_QUALITY_MSG
|
||||
|
||||
|
||||
/** Test if pnt is in arc-cone. */
|
||||
inline vr_bool vroniObject::IsPntInArcCone(int arc, coord pnt)
|
||||
{
|
||||
return IsPntInArcConeEps(arc, pnt, ZERO);
|
||||
}
|
||||
|
||||
/** Test if pnt is in arc-cone. */
|
||||
inline vr_bool vroniObject::IsPntInArcConeStrict(int arc, coord pnt)
|
||||
{
|
||||
return IsPntInArcConeEps(arc, pnt, -ZERO);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 1999-2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.c". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifndef VRONI_BASIC_H
|
||||
#define VRONI_BASIC_H
|
||||
|
||||
|
||||
#include "consts.h"
|
||||
#include "util.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
|
||||
#define BASIC_MINI 1.0e-20
|
||||
|
||||
#ifndef RAND
|
||||
|
||||
#define RND_MAX 2147483647
|
||||
|
||||
#define UniformRandom(x) \
|
||||
{\
|
||||
x = ((double) random()) / RND_MAX; }
|
||||
|
||||
#define RandomInteger(N) \
|
||||
(\
|
||||
assert(N > 0), \
|
||||
basic_i_local = random(), \
|
||||
basic_i_local - (basic_i_local / (N)) * (N))
|
||||
|
||||
#define InitRandom(seed) \
|
||||
{\
|
||||
srandom(seed); }
|
||||
|
||||
#else
|
||||
|
||||
#ifdef RAND_MAX
|
||||
#define RND_MAX RAND_MAX
|
||||
#else
|
||||
#define RND_MAX 32767
|
||||
#endif
|
||||
|
||||
#define UniformRandom(x) \
|
||||
{\
|
||||
x = ((double) rand()) / RND_MAX; \
|
||||
}
|
||||
|
||||
#define RandomInteger(N) \
|
||||
(\
|
||||
assert(N > 0), \
|
||||
basic_i_local = rand(), \
|
||||
basic_i_local - (basic_i_local / (N)) * (N))
|
||||
|
||||
|
||||
#define InitRandom(seed) \
|
||||
{\
|
||||
srand(seed); }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
#define ScaleX(xc) (scale_factor * (xc - shift.x))
|
||||
|
||||
#define ScaleY(yc) (scale_factor * (yc - shift.y))
|
||||
|
||||
#define ScaleV(value) (value * scale_factor)
|
||||
|
||||
#define UnscaleX(xc) (assert(scale_factor > 0.0), xc / scale_factor + shift.x)
|
||||
|
||||
#define UnscaleY(yc) (assert(scale_factor > 0.0), yc / scale_factor + shift.y)
|
||||
|
||||
#define UnscaleV(value) (assert(scale_factor > 0.0), value / scale_factor)
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#define CirBBox(p, r, bb_min, bb_max) {\
|
||||
(bb_min).x = (p).x - r; \
|
||||
(bb_min).y = (p).y - r; \
|
||||
(bb_max).x = (p).x + r; \
|
||||
(bb_max).y = (p).y + r; }
|
||||
|
||||
|
||||
#define TriBBox(a, b, c, bb_min, bb_max) {\
|
||||
MinMax3((a).x, (b).x, (c).x, (bb_min).x, (bb_max).x); \
|
||||
MinMax3((a).y, (b).y, (c).y, (bb_min).y, (bb_max).y); }
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,189 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 2010-2023 M. Held, S. Huber */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Stefan Huber, Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_CONSTS_H
|
||||
#define VRONI_CONSTS_H
|
||||
|
||||
#ifndef DOUBLE_OVERRIDE
|
||||
/* */
|
||||
/* please do not change the following tolerance thresholds */
|
||||
/* */
|
||||
#define TINY 1.0e-14 /* about the size of the machine precision */
|
||||
#define SMALL 0.0078125 /* 0.01 >= SMALL = 1/128 >> ZERO */
|
||||
#define INVERSE_SMALL 128.0 /* INVERSE_SMALL = 1/SMALL */
|
||||
/* */
|
||||
/* the following tolerance thresholds may be changed if you know what you do */
|
||||
/* */
|
||||
#define ZERO 1.0e-13 /* small number with ZERO >= TINY */
|
||||
#define ZERO_MAX 1.0e-5 /* SMALL >> ZERO_MAX >= ZERO */
|
||||
#define ZERO_IO 1.0e-5 /* SMALL >> ZERO_IO >= ZERO_MAX */
|
||||
#define DECENT 1.0e-10 /* = ZERO_MAX / 1000 */
|
||||
#define GRAZE 1.0e-4 /* = ZERO_MAX * 10 */
|
||||
/* */
|
||||
/* the following thresholds depend on thresholds defined in previous lines */
|
||||
/* */
|
||||
#define THRESHOLD 1.0e-6 /* THRESHOLD = ZERO_MAX / 10.0 */
|
||||
#define ZERO2 1.0e-26 /* ZERO2 = ZERO * ZERO */
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#define NIL -1
|
||||
#define APPROX 10
|
||||
#define MAX_RESTART 50 /* max. number of retries if computation fails */
|
||||
|
||||
#ifdef WITH_MPFRBACKEND
|
||||
|
||||
extern double SMALL;
|
||||
extern double INVERSE_SMALL;
|
||||
extern double ZERO_IO;
|
||||
extern double ZERO_MAX;
|
||||
extern double ZERO;
|
||||
extern double ZERO2;
|
||||
extern double THRESHOLD;
|
||||
extern double TINY;
|
||||
|
||||
#elif defined(WITH_COREBACKEND)
|
||||
|
||||
const double SMALL = 0;
|
||||
/* INVERSE_SMALL is not used anyway of SMALL == 0, so keep value from
|
||||
plain value. */
|
||||
const double INVERSE_SMALL = 128;
|
||||
const double ZERO_IO = 1.0e-6;
|
||||
const double ZERO_MAX = 0;
|
||||
const double ZERO = 0;
|
||||
const double ZERO2 = 0;
|
||||
const double THRESHOLD = 0;
|
||||
const double TINY = 0;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef DOUBLE_OVERRIDE
|
||||
|
||||
|
||||
#ifndef M_E
|
||||
#define M_E 2.71828182845904553488
|
||||
#endif
|
||||
#ifndef M_1_E
|
||||
#define M_1_E 0.36787944117144227851
|
||||
#endif
|
||||
#ifndef M_LOG2E
|
||||
#define M_LOG2E 1.44269504088896360904
|
||||
#endif
|
||||
#ifndef M_LOG10E
|
||||
#define M_LOG10E 0.43429448190325182765
|
||||
#endif
|
||||
#ifndef M_LN2
|
||||
#define M_LN2 0.69314718055994530942
|
||||
#endif
|
||||
#ifndef M_LN10
|
||||
#define M_LN10 2.30258509299404568402
|
||||
#endif
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
#ifndef M_PI_2
|
||||
#define M_PI_2 1.57079632679489661923
|
||||
#endif
|
||||
#ifndef M_PI_4
|
||||
#define M_PI_4 0.78539816339744830962
|
||||
#endif
|
||||
#ifndef M_PI_8
|
||||
#define M_PI_8 0.39269908169872415481
|
||||
#endif
|
||||
#ifndef M_1_PI
|
||||
#define M_1_PI 0.31830988618379067154
|
||||
#endif
|
||||
#ifndef M_2_PI
|
||||
#define M_2_PI 0.63661977236758134308
|
||||
#endif
|
||||
#ifndef M_2PI
|
||||
#define M_2PI 6.28318530717958623199
|
||||
#endif
|
||||
#ifndef M_180_PI
|
||||
#define M_180_PI 57.2957795130823208767
|
||||
#endif
|
||||
#ifndef M_PI_180
|
||||
#define M_PI_180 0.01745329251994329576
|
||||
#endif
|
||||
#ifndef M_2_SQRTPI
|
||||
#define M_2_SQRTPI 1.12837916709551257390
|
||||
#endif
|
||||
#ifndef M_SQRT2
|
||||
#define M_SQRT2 1.41421356237309504880
|
||||
#endif
|
||||
#ifndef M_SQRT1_2
|
||||
#define M_SQRT1_2 0.70710678118654752440
|
||||
#endif
|
||||
#ifndef M_SQRT3
|
||||
#define M_SQRT3 1.73205080756887719317
|
||||
#endif
|
||||
#ifndef M_SQRT1_3
|
||||
#define M_SQRT1_3 0.57735026918962584208
|
||||
#endif
|
||||
#ifndef M_1_3
|
||||
#define M_1_3 0.33333333333333333333
|
||||
#endif
|
||||
|
||||
#elif defined(WITH_MPFRBACKEND)
|
||||
|
||||
extern double M_1_3;
|
||||
extern double M_180_PI;
|
||||
extern double M_PI_180;
|
||||
#undef M_SQRT2
|
||||
extern double M_SQRT2;
|
||||
#undef M_PI_4
|
||||
extern double M_PI_4;
|
||||
#undef M_PI_2
|
||||
extern double M_PI_2;
|
||||
#undef M_PI
|
||||
extern double M_PI;
|
||||
#undef M_2PI
|
||||
extern double M_2PI;
|
||||
|
||||
#else
|
||||
//defined(WITH_COREBACKEND)
|
||||
|
||||
const double M_1_3 = double(1) / 3;
|
||||
#undef M_SQRT2
|
||||
const double M_SQRT2 = sqrt(double(2));
|
||||
#undef M_PI
|
||||
const double M_PI = pi();
|
||||
#undef M_PI_4
|
||||
const double M_PI_4 = M_PI / 4;
|
||||
#undef M_PI_2
|
||||
const double M_PI_2 = M_PI / 2;;
|
||||
#undef M_2PI
|
||||
const double M_2PI = M_PI * 2;
|
||||
const double M_180_PI = 180 / M_PI;
|
||||
const double M_PI_180 = M_PI * 180;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,171 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 2010-2023 M. Held, S. Huber */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Stefan Huber */
|
||||
/* Modified: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef VRONI_COORD_H
|
||||
#define VRONI_COORD_H
|
||||
|
||||
|
||||
#ifndef DOUBLE_OVERRIDE
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#include "fpkernel.h"
|
||||
|
||||
/** Defines a vector in the plane */
|
||||
struct coord {
|
||||
double x;
|
||||
double y;
|
||||
inline coord(double_arg x, double_arg y) : x(x), y(y) {}
|
||||
//Ensure construction doesn't implicitly initialize elements - done explicitly later anyway
|
||||
inline coord() {}
|
||||
};
|
||||
|
||||
struct coord3D {
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
inline coord3D(double_arg x, double_arg y, double_arg z) : x(x), y(y), z(z) {}
|
||||
//Ensure construction doesn't implicitly initialize elements - done explicitly later anyway
|
||||
inline coord3D() {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Computes determinant of 3x3 matrix given by homogeneous coordinates
|
||||
* of the three column vectors u, v and w. */
|
||||
inline static double VecDet(coord u, coord v, coord w)
|
||||
{
|
||||
return (((u).x - (v).x) * ((v).y - (w).y) + ((v).y - (u).y) * ((v).x - (w).x));
|
||||
}
|
||||
|
||||
|
||||
/** Computes standard inner-product of vectors u and v */
|
||||
inline static double VecDotProd(coord u, coord v)
|
||||
{
|
||||
return (((u).x * (v).x) + ((u).y * (v).y));
|
||||
}
|
||||
|
||||
|
||||
/** Adds two vectors */
|
||||
inline static coord VecAdd(coord p, coord q)
|
||||
{
|
||||
coord r;
|
||||
r.x = p.x + q.x;
|
||||
r.y = p.y + q.y;
|
||||
return r;
|
||||
}
|
||||
|
||||
/** Subtracs two vectors */
|
||||
inline static coord VecSub(coord p, coord q)
|
||||
{
|
||||
coord r;
|
||||
r.x = p.x - q.x;
|
||||
r.y = p.y - q.y;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/** Multiply vector with scalar */
|
||||
inline static coord VecMult(double_arg scalar, const coord & u)
|
||||
{
|
||||
coord r;
|
||||
r.x = scalar * u.x;
|
||||
r.y = scalar * u.y;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/** Divide vector by scalar */
|
||||
inline static coord VecDiv(double_arg scalar, const coord & u)
|
||||
{
|
||||
return VecMult(1.0/scalar, u);
|
||||
}
|
||||
|
||||
|
||||
/** Get vector -p of p */
|
||||
inline static coord VecInv(coord p)
|
||||
{
|
||||
coord q;
|
||||
q.x = -p.x;
|
||||
q.y = -p.y;
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
/** Squared vector length */
|
||||
inline static double VecLenSq(coord p)
|
||||
{
|
||||
return (p.x*p.x + p.y*p.y);
|
||||
}
|
||||
|
||||
|
||||
/** Vector length */
|
||||
inline static double VecLen(coord p)
|
||||
{
|
||||
return sqrt(VecLenSq(p));
|
||||
}
|
||||
|
||||
/** Normalize vector */
|
||||
inline static coord VecNorm(coord p)
|
||||
{
|
||||
return VecDiv(VecLen(p), p);
|
||||
}
|
||||
|
||||
|
||||
/** Get counter clock-wise 90 degree rotation */
|
||||
inline static coord VecCCW(coord p)
|
||||
{
|
||||
coord q;
|
||||
q.x = -p.y;
|
||||
q.y = p.x;
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
/** Get clock-wise 90 degree rotation */
|
||||
inline static coord VecCW(coord p)
|
||||
{
|
||||
coord q;
|
||||
q.x = p.y;
|
||||
q.y = -p.x;
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Make vector by its coordinates */
|
||||
inline static coord MakeVec(double_arg x, double_arg y)
|
||||
{
|
||||
coord p;
|
||||
p.x = x;
|
||||
p.y = y;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/* */
|
||||
/* Copyright (C) 1999-2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_CORE_ATAN2_H
|
||||
#define VRONI_CPRE_ATAN2_H
|
||||
|
||||
|
||||
inline double atan2local(const double &y, const double &x)
|
||||
{
|
||||
if( fabs(x) >= fabs(y) )
|
||||
{
|
||||
// Sector to the right
|
||||
if( x > 0 )
|
||||
{
|
||||
const double phi = y/x;
|
||||
return atan(phi);
|
||||
}
|
||||
// Sector to the left
|
||||
else if( x < 0 )
|
||||
{
|
||||
const double phi = y/x;
|
||||
if( y >= 0) {
|
||||
return atan(phi) + M_PI;
|
||||
} else {
|
||||
return atan(phi) - M_PI;
|
||||
}
|
||||
}
|
||||
// Hence, x and y are zero
|
||||
else
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
else if( fabs(y) >= fabs(x) )
|
||||
{
|
||||
// Sector to the top
|
||||
if( y > 0 )
|
||||
{
|
||||
const double phi = x/y;
|
||||
return M_PI_2 - atan(phi);
|
||||
}
|
||||
// Sector to the bottom
|
||||
if( y < 0 )
|
||||
{
|
||||
const double phi = x/y;
|
||||
return - M_PI_2 - atan(phi);
|
||||
}
|
||||
// Actually, the impossible case, x=y=0. Should be catched above.
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
}
|
||||
// This can only happen, if x or y is NaN.
|
||||
else
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 1999-2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-172 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_DEFS_H
|
||||
#define VRONI_DEFS_H
|
||||
|
||||
#include "mydefs.h"
|
||||
|
||||
#define PROG_NAME "V R O N I"
|
||||
#define PROG_VERSION "7.6"
|
||||
#define PROG_YEAR "1999-2023"
|
||||
|
||||
/* */
|
||||
/* get the definitions for "exterior applications" */
|
||||
/* */
|
||||
#include "ext_appl_defs.h"
|
||||
|
||||
/* */
|
||||
/* colors for OpenGL drawing */
|
||||
/* */
|
||||
#define VroniBrown 0
|
||||
#define VroniGreen 1
|
||||
#define VroniBlue 2
|
||||
#define VroniWhite 3
|
||||
#define VroniRed 4
|
||||
#define VroniCyan 5
|
||||
#define VroniYellow 6
|
||||
#define VroniOrange 7
|
||||
#define VroniMagenta 8
|
||||
#define VroniBlack 9
|
||||
#define VroniNumColors 10
|
||||
|
||||
|
||||
#define NoColor VroniBlack
|
||||
#define SupColor VroniWhite
|
||||
#define PntColor VroniGreen
|
||||
#define SegColor VroniGreen
|
||||
#define ArcColor VroniCyan
|
||||
#define CirColor VroniYellow
|
||||
#define AlertColor VroniRed
|
||||
#define CurrColor VroniBlue
|
||||
#define MICColor VroniYellow
|
||||
#define VDColor VroniRed
|
||||
#define GridColor VroniBrown
|
||||
#define TreeColor VroniBrown
|
||||
#define VDCurrColor VroniMagenta
|
||||
#define DTCurrColor VroniOrange
|
||||
#define SiteCurrColor VroniBlue
|
||||
#define DTColor VroniWhite
|
||||
#define OffColor VroniWhite
|
||||
#define WMATColor VroniBlue
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 2002--2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_EXT_APPL_DEFS_H
|
||||
#define VRONI_EXT_APPL_DEFS_H
|
||||
|
||||
#include "defs.h"
|
||||
#include <utility>
|
||||
#include <tuple>
|
||||
|
||||
/* */
|
||||
/* the following data types are used for user-defined entities that are to */
|
||||
/* be stored as part of my data structures. you are welcome to redefine them */
|
||||
/* according to your needs. however, please note that it is your task to */
|
||||
/* make sure that the functions and macros for I/O operations are modified */
|
||||
/* accordingly in io_parse.c !! also, you'd need to redefine the constants */
|
||||
/* eap_NIL, eas_NIL, ean_NIL, eae_NIL, eam_NIL, and eao_NIL in the file */
|
||||
/* ext_appl_defs.c to whatever constant integral value or structure that can */
|
||||
/* be used for initializing the exterior application structures. see the */
|
||||
/* sample use for eap_... below. */
|
||||
/* */
|
||||
|
||||
typedef std::pair<int,int> eap_type; /* ext. appl. hook for pnt */
|
||||
typedef std::pair<int,int> eas_type; /* ext. appl. hook for seg and arc */
|
||||
typedef int ean_type; /* ext. appl. hook for node */
|
||||
typedef int eae_type; /* ext. appl. hook for edge */
|
||||
typedef int eam_type; /* ext. appl. hook for wmat */
|
||||
typedef int eao_type; /* ext. appl. hook for off_data */
|
||||
|
||||
/*
|
||||
* sample user-specific eap data:
|
||||
*
|
||||
* typedef struct {
|
||||
* long id;
|
||||
* char ch[10];
|
||||
* } eap_type;
|
||||
*/
|
||||
|
||||
extern const eap_type eap_NIL;
|
||||
extern const eas_type eas_NIL;
|
||||
extern const ean_type ean_NIL;
|
||||
extern const eam_type eam_NIL;
|
||||
extern const eao_type eao_NIL;
|
||||
extern const eae_type eae_NIL;
|
||||
|
||||
|
||||
#define ExtApplFuncNewInput
|
||||
|
||||
#define ExtApplFuncRestart
|
||||
|
||||
#define ExtApplFuncFirstPnts
|
||||
|
||||
#define ExtApplFuncDonePnts
|
||||
|
||||
#define ExtApplFuncFirstSegs
|
||||
|
||||
#define ExtApplFuncDoneSegs
|
||||
|
||||
#define ExtApplFuncDoneSegs
|
||||
|
||||
#define ExtApplFuncDoneArcs
|
||||
|
||||
#define ExtApplFuncFirstArcs
|
||||
|
||||
#define ExtApplFuncDoneVD
|
||||
|
||||
#define ExtApplFuncReset
|
||||
|
||||
#define ExtApplFuncIsoOffset
|
||||
|
||||
#define ExtApplFuncIsoOffsetDone
|
||||
|
||||
#define ExtApplFuncOffsetInit
|
||||
|
||||
#define ExtApplFuncOffsetRepeat
|
||||
|
||||
#define ExtApplFuncOffLoops
|
||||
|
||||
#define ExtApplFuncOffDone
|
||||
|
||||
#define ExtApplFuncOffStart
|
||||
|
||||
#define ExtApplFuncOffSegment
|
||||
|
||||
#define ExtApplFuncOffsetEnd
|
||||
|
||||
#define ExtApplFuncWMATInit
|
||||
|
||||
#define ExtApplFuncWMATLoop
|
||||
|
||||
#define ExtApplFuncWMATComputed
|
||||
|
||||
#define ExtApplFuncWMATDone
|
||||
|
||||
#define ExtApplFuncMICInit
|
||||
|
||||
#define ExtApplFuncMICDone
|
||||
|
||||
#define ExtApplFuncMICNotFound
|
||||
|
||||
#define ExtApplFuncVD_Warning
|
||||
|
||||
#define ExtApplFuncVD_Dbg_Warning
|
||||
|
||||
#define ExtApplFuncVD_IO_Warning
|
||||
|
||||
#define ExtApplFuncVD_Info
|
||||
|
||||
#define ExtApplFuncArgEvalParse
|
||||
|
||||
#define ExtApplFuncArgEvalInit
|
||||
|
||||
#define ExtApplFuncArgEvalDone
|
||||
|
||||
#define ExtApplFuncEvalErrorOption
|
||||
|
||||
#define ExtApplFuncEvalErrorExplain
|
||||
|
||||
#define ExtApplFuncReadOptCoord
|
||||
|
||||
#define ExtApplFuncReadOptNumber
|
||||
|
||||
#define ExtApplFuncReadNumber
|
||||
|
||||
#define ExtApplFuncReadPntData
|
||||
|
||||
#define ExtApplFuncReadSiteData
|
||||
|
||||
#define ExtApplFuncReadVectorData
|
||||
|
||||
#define ExtApplFuncWritePntData
|
||||
|
||||
#define ExtApplIsCorrectSide
|
||||
|
||||
#define ExtApplInsertDummyNode
|
||||
|
||||
#define ExtApplResetGraphicsData
|
||||
|
||||
#define ExtApplInitializeEdgeData
|
||||
|
||||
#define ExtApplInitializeProgram
|
||||
|
||||
#define ExtApplRemoveSeg
|
||||
|
||||
#define ExtApplRemoveArc
|
||||
|
||||
#define ExtApplSetStepSize
|
||||
|
||||
#define ExtApplSegPntIntersection
|
||||
|
||||
#define ExtApplArcPntIntersection
|
||||
|
||||
#define ExtApplSegSegIntersection
|
||||
|
||||
#define ExtApplSegArcIntersection
|
||||
|
||||
#define ExtApplArcArcIntersection
|
||||
|
||||
#define ExtApplHandleSeg
|
||||
|
||||
#define ExtApplHandleArc
|
||||
|
||||
#define ExtApplComputeRestarts
|
||||
|
||||
#define ExtApplAddDummyCorners
|
||||
|
||||
#define ExtApplScanVDEdges
|
||||
|
||||
#define ExtApplFuncVRONI_HandleError
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,94 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 2003--2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_EXT_APPL_INOUT_H
|
||||
#define VRONI_EXT_APPL_INOUT_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
class vroniObject;
|
||||
|
||||
#ifndef VRONI_COORD_H
|
||||
typedef struct {
|
||||
double x; /* x-coordinate */
|
||||
double y; /* y-coordinate */
|
||||
} coord; /********** point/vector ******************************/
|
||||
#endif
|
||||
|
||||
/* Make sure that double arg is defined, to ensure that external appliations do
|
||||
not break if they don't include fpkernel.h */
|
||||
#ifndef double_arg
|
||||
#define double_arg double
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* The following data structures and macros may be modified at the user's */
|
||||
/* discretion. They are only used in API_HandleArrayInput() in */
|
||||
/* api_functions.c. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
typedef struct {
|
||||
double x1; /* x-coordinate */
|
||||
double y1; /* y-coordinate */
|
||||
#ifdef EXT_APPL_PNTS
|
||||
eap_type ext_appl;/* this field can be set by an application program to */
|
||||
/* refer to a user-defined entity. */
|
||||
#endif
|
||||
} in_pnts; /********** point/vector ******************************/
|
||||
|
||||
|
||||
typedef struct {
|
||||
double x1; /* x-coordinate start */
|
||||
double y1; /* y-coordinate start */
|
||||
double x2; /* x-coordinate end */
|
||||
double y2; /* y-coordinate end */
|
||||
#ifdef EXT_APPL_SITES
|
||||
eas_type ext_appl;/* this field can be set by an application program to */
|
||||
/* refer to a user-defined entity. */
|
||||
#endif
|
||||
} in_segs; /********** point/vector ******************************/
|
||||
|
||||
|
||||
typedef struct {
|
||||
double x1; /* x-coordinate start */
|
||||
double y1; /* y-coordinate start */
|
||||
double x2; /* x-coordinate end */
|
||||
double y2; /* y-coordinate end */
|
||||
double x3; /* x-coordinate center */
|
||||
double y3; /* y-coordinate center */
|
||||
vr_bool attr; /* orientation; true for CCW arcs, false for CW arcs */
|
||||
#ifdef EXT_APPL_SITES
|
||||
eas_type ext_appl;/* this field can be set by an application program to */
|
||||
/* refer to a user-defined entity. */
|
||||
#endif
|
||||
} in_arcs; /********** point/vector ******************************/
|
||||
|
||||
|
||||
/* api_functions.c */
|
||||
|
||||
#include "api_functions.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,63 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 2002--2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_EXT_APPL_VRONI_OBJECT_H
|
||||
#define VRONI_EXT_APPL_VRONI_OBJECT_H
|
||||
|
||||
#include "vroni_object.h"
|
||||
|
||||
|
||||
/* */
|
||||
/* VRONI object derived class declaration */
|
||||
/* */
|
||||
class extApplVroniObject : public vroniObject
|
||||
{
|
||||
public:
|
||||
|
||||
//
|
||||
// CONSTRUCTOR / DESTRUCTOR
|
||||
//
|
||||
extApplVroniObject();
|
||||
|
||||
virtual ~extApplVroniObject();
|
||||
|
||||
|
||||
//
|
||||
// EXTRA FUNCTIONS
|
||||
//
|
||||
bool EdgeDataNeedInitializing();
|
||||
|
||||
void InitializeAllEdgeData();
|
||||
|
||||
bool IsDegenerateEdge(int ie);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,231 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 1999-2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_FP_KERNEL_H
|
||||
#define VRONI_FP_KERNEL_H
|
||||
|
||||
#ifdef WITH_COREBACKEND
|
||||
/* Set CORE Level to 4. Otherwise all unsigned long no longer work */
|
||||
#define CORE_LEVEL 4
|
||||
|
||||
#ifdef WITH_CORE_EXPR_WRAPPER
|
||||
#include<ExprWrapper.h>
|
||||
#else
|
||||
#include<CORE/CORE.h>
|
||||
#endif /* WITH_CORE_EXPR_WRAPPER */
|
||||
|
||||
|
||||
#undef double
|
||||
#ifdef WITH_COREBACKEND_BIGFLOAT
|
||||
#define double CORE::BigFloat
|
||||
#else
|
||||
/* allow double to be used as Expr */
|
||||
#define double Expr
|
||||
#endif
|
||||
|
||||
#define double_arg const double &
|
||||
|
||||
//This is used to indicate that double gets a different meaning!
|
||||
#define DOUBLE_OVERRIDE
|
||||
|
||||
#include <formattedIO.h>
|
||||
|
||||
#define TO_MDOUBLE(x) (x).doubleValue()
|
||||
|
||||
inline CORE::BigInt cut_comma(const Expr & x) {
|
||||
CORE::BigInt v = floor(x);
|
||||
if(v < 0) {
|
||||
return v + 1;
|
||||
} else {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
#include "coreatan2.h"
|
||||
|
||||
inline int intfloor(const Expr & e) {
|
||||
return floor(e).intValue();
|
||||
}
|
||||
|
||||
inline unsigned int uintceil(const Expr & e) {
|
||||
return (unsigned)ceil(e).intValue();
|
||||
}
|
||||
|
||||
//REAL_TO_INT behaves like (int)(x)
|
||||
#define REAL_TO_INT(x) cut_comma(x).intValue()
|
||||
#define REAL_TO_GLINT(x) cut_comma(x).intValue()
|
||||
#define REAL_TO_FLOAT(x) (x).floatValue()
|
||||
#define BIGINT_TO_INT(x) (x).intValue()
|
||||
#define TO_REAL(x) double(x)
|
||||
|
||||
//Definitions for functions undefined in CORE
|
||||
#define isnan(x) 0
|
||||
#define atan2(y,x) atan2local((y),(x))
|
||||
#define signbit(x) ((x) < 0 ? 1 : 0)
|
||||
|
||||
#define CORE_EXPR_OPS(name, x) { \
|
||||
std::map<std::string, unsigned int > m; \
|
||||
(x).rep()->rekCollectOp(m); \
|
||||
for(std::map<std::string, unsigned int>::iterator it = m.begin(); it != m.end(); ++it) { \
|
||||
std::cout << it->second << "\t: " << it->first << std::endl; \
|
||||
}}
|
||||
|
||||
#ifdef WITH_CORE_EXPR_WRAPPER
|
||||
inline void CORE_EXPR_SEQ(std::string name, const Expr & x) {
|
||||
std::map<unsigned int, std::string > m;
|
||||
(x).rep()->rekSequen(m);
|
||||
for (std::map<unsigned int, std::string>::iterator it = m.begin(); it != m.end(); ++it) {
|
||||
std::cout << it->second << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
inline void CORE_EXPR_DEBUG1(std::string name, const Expr & x) {
|
||||
std::cout << name << " depth: " << (x).rep()->getDepth() << std::endl;
|
||||
std::cout << name << " elementCount: " << (x).rep()->getElementCount() << std::endl;
|
||||
CORE_EXPR_SEQ(name, (x));
|
||||
std::cout << name << " value: " << (x) << std::endl;
|
||||
}
|
||||
#else
|
||||
inline void CORE_EXPR_SEQ(std::string name, const Expr & x) {}
|
||||
inline void CORE_EXPR_DEBUG1(std::string name, const Expr & x) {}
|
||||
#endif
|
||||
|
||||
//IO
|
||||
#define FP_printf formattedIO::fmc_printf
|
||||
#define FP_fprintf formattedIO::fmc_fprintf
|
||||
|
||||
inline const double * FP_PRNTARG(const double & x) { return &x; }
|
||||
|
||||
//[sf]scanf methods
|
||||
#define FP_fscanf formattedIO::cfscanf
|
||||
#define FP_sscanf formattedIO::csscanf
|
||||
|
||||
|
||||
// The second argument is the SHA1sum of "shift\n". This avoids a
|
||||
// conflict with a shift function in CORE - VRONI uses some
|
||||
// variables named shift
|
||||
#define shift a68fe7dac8c32f30ad04d52fab4aa46be1068d82
|
||||
|
||||
#elif defined(WITH_MPFRBACKEND)
|
||||
|
||||
#include <mpfr_class.h>
|
||||
|
||||
#include <formattedIO.h>
|
||||
|
||||
typedef double machine_double;
|
||||
#undef double
|
||||
|
||||
#ifdef WITH_CORE_EXPR_WRAPPER
|
||||
#include<ExprWrapper.h>
|
||||
#define double Expr<Mpfr_class>
|
||||
#else
|
||||
#define double Mpfr_class
|
||||
#endif /* WITH_CORE_EXPR_WRAPPER */
|
||||
|
||||
#define double_arg const double &
|
||||
|
||||
//This is used to indicate that double gets a different meaning!
|
||||
#define DOUBLE_OVERRIDE
|
||||
|
||||
|
||||
#define TO_MDOUBLE(x) (x).doubleValue()
|
||||
#define REAL_TO_INT(x) (x).intValue()
|
||||
#define REAL_TO_GLINT(x) (x).intValue()
|
||||
#define REAL_TO_FLOAT(x) (x).floatValue()
|
||||
#define TO_REAL(x) double(x)
|
||||
|
||||
inline void CORE_EXPR_DEBUG1(std::string , const double & ) {}
|
||||
|
||||
inline long intfloor(const double & e) {
|
||||
return floor(e).intValue();
|
||||
}
|
||||
|
||||
inline unsigned long uintceil(const double & e) {
|
||||
return ceil(e).intValue();
|
||||
}
|
||||
|
||||
//Definitions for functions undefined in CORE
|
||||
#if WITH_CORE_EXPR_WRAPPER
|
||||
#define is_nan(x) 0
|
||||
#define sign_bit(x) ((x) < 0 ? 1 : 0)
|
||||
#endif
|
||||
|
||||
//IO
|
||||
#define FP_printf formattedIO::fmc_printf
|
||||
#define FP_fprintf formattedIO::fmc_fprintf
|
||||
|
||||
inline const double * FP_PRNTARG(const double & x) { return &x; }
|
||||
|
||||
//[sf]scanf methods
|
||||
#define FP_fscanf formattedIO::cfscanf
|
||||
#define FP_sscanf formattedIO::csscanf
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define TO_MDOUBLE(x) (x)
|
||||
#define REAL_TO_INT(x) (int)(x)
|
||||
#define REAL_TO_GLINT(x) (GLint)(x)
|
||||
#define REAL_TO_FLOAT(x) (float)(x)
|
||||
#define BIGINT_TO_INT(x) (x)
|
||||
#define TO_REAL(x) (x)
|
||||
|
||||
#define machine_double double
|
||||
|
||||
#define double_arg double
|
||||
|
||||
inline int intfloor(const double e) {
|
||||
return (int)(floor(e));
|
||||
}
|
||||
|
||||
inline unsigned int uintceil(const double e) {
|
||||
return (unsigned)ceil(e);
|
||||
}
|
||||
|
||||
#define CORE_EXPR_DEBUG1(x,y)
|
||||
|
||||
#define is_nan(x) isnan(x)
|
||||
#define sign_bit(x) signbit(x)
|
||||
|
||||
#ifdef DOUBLE_OVERRIDE
|
||||
#error "DOUBLE_OVERRIDE should not be defined here!"
|
||||
#endif
|
||||
|
||||
//IO
|
||||
#define FP_printf printf
|
||||
#define FP_fprintf fprintf
|
||||
|
||||
#define FP_PRNTARG(x) (x)
|
||||
|
||||
//[sf]scanf methods
|
||||
#define FP_fscanf fscanf
|
||||
#define FP_sscanf sscanf
|
||||
|
||||
|
||||
|
||||
#endif /* LIB_CORE */
|
||||
|
||||
#endif /* VRONI_FP_KERNEL_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 2010-2023 M. Held, S. Huber */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Stefan Huber, Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_GEOM_H
|
||||
#define VRONI_GEOM_H
|
||||
|
||||
#include "util.h"
|
||||
|
||||
|
||||
/** Compute squared distance between two points */
|
||||
inline double vroniObject::PntPntDistSq(coord pi, coord pj)
|
||||
{
|
||||
const double x = pi.x - pj.x;
|
||||
const double y = pi.y - pj.y;
|
||||
return x*x + y*y;
|
||||
}
|
||||
|
||||
/** Compute distance between two points */
|
||||
inline double vroniObject::PntPntDist(coord pi, coord pj)
|
||||
{
|
||||
const double x = pi.x - pj.x;
|
||||
const double y = pi.y - pj.y;
|
||||
return sqrt(x*x + y*y);
|
||||
}
|
||||
|
||||
/** Compute mid point on the line (pi,pj) */
|
||||
inline coord vroniObject::MidPoint(coord pi, coord pj)
|
||||
{
|
||||
coord q;
|
||||
q.x = (pi.x + pj.x) / 2.0;
|
||||
q.y = (pi.y + pj.y) / 2.0;
|
||||
return q;
|
||||
}
|
||||
|
||||
/** Compute centroid point of the triangle (pi,pj,pk) */
|
||||
inline coord vroniObject::Centroid(coord pi, coord pj, coord pk)
|
||||
{
|
||||
coord q;
|
||||
q.x = (pi.x + pj.x + pk.x)/3.0;
|
||||
q.y = (pi.y + pj.y + pk.y)/3.0;
|
||||
return q;
|
||||
}
|
||||
|
||||
/** Build linar combination of vectors p and r by parameter t */
|
||||
inline coord vroniObject::LinearComb(const coord & p, const coord & r,
|
||||
double_arg t)
|
||||
{
|
||||
coord q;
|
||||
q.x = p.x + t*(r.x-p.x);
|
||||
q.y = p.y + t*(r.y-p.y);
|
||||
return q;
|
||||
}
|
||||
|
||||
/** Get the point q = p + t*v */
|
||||
inline coord vroniObject::RayPnt(const coord & p, const coord & v,
|
||||
double_arg t)
|
||||
{
|
||||
coord q;
|
||||
q.x = p.x + t*v.x;
|
||||
q.y = p.y + t*v.y;
|
||||
return q;
|
||||
}
|
||||
|
||||
/** Compute (signed) distance of point p to circle (c,r). Positive
|
||||
* values indicate that p is outside the circle (c,r). */
|
||||
inline double vroniObject::PntCircleDist(const coord & c, double_arg r,
|
||||
const coord & p)
|
||||
{
|
||||
return PntPntDist(p, c) - r;
|
||||
}
|
||||
|
||||
/** Compute absolute distance of point p tor circle (c,r) */
|
||||
inline double vroniObject::AbsPntCircleDist(const coord & c, double_arg r,
|
||||
const coord & p)
|
||||
{
|
||||
return Abs(PntCircleDist(c, r, p));
|
||||
}
|
||||
|
||||
/** Test if point p is on circle (c,r) */
|
||||
inline int vroniObject::IsPntOnCircle(const coord & c, double_arg r, const coord & p)
|
||||
{
|
||||
return eq(PntCircleDist(c,r,p), ZERO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Compute the signed distance of the point p to the line given by
|
||||
* the equation a*x + b*y + c = 0. A positive result means that
|
||||
* p lies in the positive half-plane defined by the line. */
|
||||
inline double vroniObject::PntLineDist(double_arg a, double_arg b, double_arg c, const coord & p)
|
||||
{
|
||||
return a*p.x + b*p.y + c;
|
||||
}
|
||||
|
||||
|
||||
/** Compute the absolute distance of the point p to the line given by
|
||||
* the equation a*x + b*y + c = 0 */
|
||||
inline double vroniObject::AbsPntLineDist(double_arg a, double_arg b, double_arg c, const coord & p)
|
||||
{
|
||||
return Abs( PntLineDist(a, b, c, p));
|
||||
}
|
||||
|
||||
|
||||
inline vr_bool vroniObject::IsBetweenVoronoiNodes(int e, const coord & p, double eps)
|
||||
{
|
||||
return (NodeEdgeClassificator(e, p, eps) == 0.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 1999-2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-172 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_HEADER_H
|
||||
#define VRONI_HEADER_H
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,88 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 1999-2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.c". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* Universitaet Salzburg */
|
||||
/* FB Informatik */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifndef VRONI_INTERSECTIONS_H
|
||||
#define VRONI_INTERSECTIONS_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
//#ifdef VRONI_INFO
|
||||
#ifdef VRONI_DBG_WARN
|
||||
#define IntWarning(S1, I1, S2, I2) \
|
||||
{\
|
||||
if (verbose) { \
|
||||
printf("\nwarning in ComputeVD() - the %s %d and the %s %d intersect!\n",\
|
||||
S1, I1, S2, I2); \
|
||||
if (strcmp(S1, "pnt") == 0) { \
|
||||
printf("pnt %d: (%20.16f,%20.16f)\n", I1, \
|
||||
UnscaleX(pnts[I1].p.x), \
|
||||
UnscaleY(pnts[I1].p.y)); \
|
||||
} \
|
||||
else if (strcmp(S1, "seg") == 0) { \
|
||||
printf("seg %d: (%20.16f,%20.16f) to (%20.16f,%20.16f)\n", I1, \
|
||||
UnscaleX(pnts[segs[I1].i1].p.x), \
|
||||
UnscaleY(pnts[segs[I1].i1].p.y), \
|
||||
UnscaleX(pnts[segs[I1].i2].p.x), \
|
||||
UnscaleY(pnts[segs[I1].i2].p.y)); \
|
||||
} \
|
||||
else if (strcmp(S1, "arc") == 0) { \
|
||||
printf("arc %d: (%20.16f,%20.16f) to (%20.16f,%20.16f) centered at (%20.16f,%20.16f)\n", I1, \
|
||||
UnscaleX(pnts[arcs[I1].i1].p.x), \
|
||||
UnscaleY(pnts[arcs[I1].i1].p.y), \
|
||||
UnscaleX(pnts[arcs[I1].i2].p.x), \
|
||||
UnscaleY(pnts[arcs[I1].i2].p.y), \
|
||||
UnscaleX(arcs[I1].c.x), \
|
||||
UnscaleY(arcs[I1].c.y)); \
|
||||
} \
|
||||
if (strcmp(S2, "pnt") == 0) { \
|
||||
printf("pnt %d: (%20.16f,%20.16f)\n", I2, \
|
||||
UnscaleX(pnts[I2].p.x), \
|
||||
UnscaleY(pnts[I2].p.y)); \
|
||||
} \
|
||||
else if (strcmp(S2, "seg") == 0) { \
|
||||
printf("seg %d: (%20.16f,%20.16f) to (%20.16f,%20.16f)\n", I2, \
|
||||
UnscaleX(pnts[segs[I2].i1].p.x), \
|
||||
UnscaleY(pnts[segs[I2].i1].p.y), \
|
||||
UnscaleX(pnts[segs[I2].i2].p.x), \
|
||||
UnscaleY(pnts[segs[I2].i2].p.y)); \
|
||||
} \
|
||||
else if (strcmp(S2, "arc") == 0) { \
|
||||
printf("arc %d: (%20.16f,%20.16f) to (%20.16f,%20.16f) centered at (%20.16f,%20.16f)\n", I2, \
|
||||
UnscaleX(pnts[arcs[I2].i1].p.x), \
|
||||
UnscaleY(pnts[arcs[I2].i1].p.y), \
|
||||
UnscaleX(pnts[arcs[I2].i2].p.x), \
|
||||
UnscaleY(pnts[arcs[I2].i2].p.y), \
|
||||
UnscaleX(arcs[I2].c.x), \
|
||||
UnscaleY(arcs[I2].c.y)); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define IntWarning(S1, I1, S2, I2) {}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 2003--2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_IO_DXF_H
|
||||
#define VRONI_IO_DXF_H
|
||||
|
||||
/* */
|
||||
/* I'm not sure whether those are indeed the colors used in DXF files. */
|
||||
/* Unfortunately, I do not seem to be able to get my hands on a decent */
|
||||
/* specification of DXF... */
|
||||
/* */
|
||||
#define DXF_NO_COLOR -1
|
||||
#define DXF_RED 1
|
||||
#define DXF_YELLOW 2
|
||||
#define DXF_GREEN 2
|
||||
#define DXF_CYAN 4
|
||||
#define DXF_BLUE 5
|
||||
#define DXF_MAGENTA 6
|
||||
#define DXF_WHITE 7
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,104 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 1996-2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Purpose: This is an interface to Ipe. */
|
||||
/* */
|
||||
/* Acknowledgements: based on fragments written by Ch. Spielberger. */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-172 */
|
||||
/* Voice Mail: (+43 662) 6044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* Universitaet Salzburg */
|
||||
/* FB Informatik */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
#ifndef IPE7_IO_H
|
||||
#define IPE7_IO_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
|
||||
|
||||
#define XMIN 0.0
|
||||
#define XMAX 452.0
|
||||
#define YMIN 0.0
|
||||
#define YMAX 568.0
|
||||
|
||||
#define LAYER0 "boundary"
|
||||
#define LAYER1 "voronoi"
|
||||
#define LAYER2 "MAT"
|
||||
#define LAYER3 "delaunay"
|
||||
#define LAYER4 "offset"
|
||||
#define LAYER5 "MIC"
|
||||
#define LAYER6 "bd_vertices"
|
||||
#define LAYER7 "vd_nodes"
|
||||
|
||||
#define COLOR0 "seagreen"
|
||||
#define COLOR1 "red"
|
||||
#define COLOR2 "black"
|
||||
#define COLOR3 "blue"
|
||||
#define COLOR4 "lightgray"
|
||||
#define COLOR5 "yellow"
|
||||
#define COLOR6 "black"
|
||||
#define COLOR7 "violet"
|
||||
|
||||
#define PEN0 "ultrafat"
|
||||
#define PEN1 "normal"
|
||||
#define PEN2 "fat"
|
||||
#define PEN3 "normal"
|
||||
#define PEN4 "normal"
|
||||
#define PEN5 "normal"
|
||||
#define PEN6 "normal"
|
||||
#define PEN7 "normal"
|
||||
|
||||
|
||||
FILE *InitIpeFile(char *filename);
|
||||
|
||||
FILE *InitIpe(char *filename, double_arg xl, double_arg xr, double_arg yl, double_arg yr);
|
||||
|
||||
void CloseIpeFile(FILE *ipe_file);
|
||||
|
||||
void WriteBeginPath(FILE *ipe_file, double x1, double y1);
|
||||
|
||||
void WriteBeginGroup(FILE *ipe_file, short int layer);
|
||||
|
||||
void WriteEndGroup(FILE *ipe_file);
|
||||
|
||||
|
||||
void WriteArcCCW(FILE *ipe_file, double_arg xc, double_arg yc, double_arg r,
|
||||
double_arg alpha, double_arg beta);
|
||||
|
||||
void WriteArcCW(FILE *ipe_file, double_arg xc, double_arg yc, double_arg r,
|
||||
double_arg alpha, double_arg beta);
|
||||
|
||||
void WriteMark(FILE *ipe_file, int type, int size, double_arg x, double_arg y);
|
||||
|
||||
void SetIpeDimensions(double_arg xmin, double_arg xmax, double_arg ymin, double_arg ymax);
|
||||
|
||||
void SetWorldDimensions(double_arg xmin, double_arg xmax, double_arg ymin, double_arg ymax);
|
||||
|
||||
void SetScaleFactor(void);
|
||||
|
||||
void InitIpeDimensions(double_arg xmin, double_arg ymin, double_arg xmax, double_arg ymax,
|
||||
double_arg ixmin, double_arg iymin, double_arg ixmax, double_arg iymax);
|
||||
|
||||
double scaleX(double x);
|
||||
double scaleY(double y);
|
||||
|
||||
void WriteLineSegment(FILE *ipe_file,
|
||||
double x1, double y1, double x2, double y2);
|
||||
|
||||
void WriteCircularArc(FILE *ipe_file, double_arg xc, double_arg yc,
|
||||
double_arg x1, double_arg y1, double_arg x2, double_arg y2, vr_bool ccw);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
// preprocessor definitions da usare per compilare correttamente
|
||||
|
||||
#define NO_CPUTIME
|
||||
#define RANDOM
|
||||
#define RAND
|
||||
#define HAVE_BOOL
|
||||
#define GENUINE_ARCS
|
||||
#define MIC
|
||||
#define MAT
|
||||
#define EXT_APPL_PNTS
|
||||
#define EXT_APPL_SITES
|
||||
@@ -0,0 +1,205 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 1999-2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_NUMERICS_H
|
||||
#define VRONI_NUMERICS_H
|
||||
|
||||
|
||||
#define Det2D(u, v, w) \
|
||||
(((u).x - (v).x) * ((v).y - (w).y) + ((v).y - (u).y) * ((v).x - (w).x))
|
||||
|
||||
|
||||
/* */
|
||||
/* this macro solves the equation p + s * q = u + t * v */
|
||||
/* for the parameter s, with p and u being points and q and v */
|
||||
/* being direction vectors of the lines through p and u. */
|
||||
/* if the equation cannot be solved (since the two lines are parallel) then */
|
||||
/* exists = 0; if the solution is not unique then exists = 2; and */
|
||||
/* exists = 1, otherwise. also, w := p + xy[0] * q. */
|
||||
/* */
|
||||
/* A[2][2], B[2], xy[2], I0, I1, J0, J1 are used internally within this */
|
||||
/* macro. */
|
||||
/* */
|
||||
#define LineLineIntersection(A, B, xy, I0, J0, I1, J1, p, q, u, v, w, exists) \
|
||||
{\
|
||||
A[0][0] = (q).x; \
|
||||
A[1][0] = (q).y; \
|
||||
A[0][1] = - (v).x; \
|
||||
A[1][1] = - (v).y; \
|
||||
B[0] = (u).x - (p).x; \
|
||||
B[1] = (u).y - (p).y; \
|
||||
LinearEqnSolver_2x2(A, B, xy, exists, I0, J0, I1, J1); \
|
||||
if (exists == 1) { \
|
||||
(w).x = (p).x + xy[0] * (q).x; \
|
||||
(w).y = (p).y + xy[0] * (q).y; \
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* */
|
||||
/* P ... query point */
|
||||
/* U ... start point of segment */
|
||||
/* A, B, C ... normalized line coefficients, where (B,-A) is the unit */
|
||||
/* direction vector of the line segment */
|
||||
/* L ... length of the line segment */
|
||||
/* */
|
||||
|
||||
#define IsInSegConeStrict(U, P, A, B, L) \
|
||||
(((((P).x - (U).x) * (B) - ((P).y - (U).y) * (A) < (L)) ? ((((P).x - (U).x) * (B) - ((P).y - (U).y) * (A) <= 0.0) ? -1 : 0) : 1))
|
||||
|
||||
|
||||
#define IsInSegCone(U, P, A, B, L) \
|
||||
(((((P).x - (U).x) * (B) - ((P).y - (U).y) * (A) <= ((L) + ZERO)) ? ((((P).x - (U).x) * (B) - ((P).y - (U).y) * (A) < -ZERO) ? -1 : 0) : 1))
|
||||
|
||||
|
||||
#define IsInSegConeZero(U, P, A, B, L, eps) \
|
||||
(((((P).x - (U).x) * (B) - ((P).y - (U).y) * (A) <= ((L) + (eps))) ? ((((P).x - (U).x) * (B) - ((P).y - (U).y) * (A) < -(eps)) ? -1 : 0) : 1))
|
||||
|
||||
#define PntSegDist(U, P, A, B, C, L, eps) \
|
||||
((IsInSegConeZero(U, P, A, B, L, eps) == 0) ? \
|
||||
(PntLineDist(A, B, C, P)) : LARGE)
|
||||
|
||||
|
||||
#define AbsPntSegDist(U, P, A, B, C, L, eps) \
|
||||
((IsInSegConeZero(U, P, A, B, L, eps) == 0) ? \
|
||||
(AbsPntLineDist(A, B, C, P)) : LARGE)
|
||||
|
||||
|
||||
#define xParabola(A, a, b, sign, dist, t, k1, k2, r, x) \
|
||||
{ \
|
||||
if (r * r + 2.0 * t * (r * k1 - dist * k2) - dist * dist <= 0.0) { \
|
||||
(x) = A - a * t * k2; \
|
||||
} \
|
||||
else { \
|
||||
(x) = A - a * t * k2 + sign * b * sqrt(r * r + 2.0 * t * (r * k1 - dist * k2) - dist * dist); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define yParabola(B, a, b, sign, dist, t, k1, k2, r, y) \
|
||||
{ \
|
||||
if (r * r + 2.0 * t * (r * k1 - dist * k2) - dist * dist <= 0.0) { \
|
||||
(y) = B - b * t * k2; \
|
||||
} \
|
||||
else { \
|
||||
(y) = B - b * t * k2 - sign * a * sqrt(r * r + 2.0 * t * (r * k1 - dist * k2) - dist * dist); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define xHyperEll(A, C, sign, dist, dy, t, k1, k2, r1, r2, r1t, r2t, ht, x) \
|
||||
{ \
|
||||
r1t = r1 + k1 * t; \
|
||||
r2t = r2 + k2 * t; \
|
||||
ht = (r2t * r2t - r1t * r1t - dist * dist) / (2.0 * dist); \
|
||||
if (r1t * r1t - ht * ht <= 0.0) { \
|
||||
(x) = A - C * t; \
|
||||
} \
|
||||
else { \
|
||||
(x) = A - C * t + sign * dy * sqrt(r1t * r1t - ht * ht); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define yHyperEll(B, D, sign, dist, dx, t, k1, k2, r1, r2, r1t, r2t, ht, y) \
|
||||
{ \
|
||||
r1t = r1 + k1 * t; \
|
||||
r2t = r2 + k2 * t; \
|
||||
ht = (r2t * r2t - r1t * r1t - dist * dist) / (2.0 * dist); \
|
||||
if (r1t * r1t - ht * ht <= 0.0) { \
|
||||
(y) = B - D * t; \
|
||||
} \
|
||||
else { \
|
||||
(y) = B - D * t - sign * dx * sqrt(r1t * r1t - ht * ht); \
|
||||
} \
|
||||
}
|
||||
|
||||
/* */
|
||||
/* A, B, C ... normalized coefficients of the equation of the arc's chord */
|
||||
/* such that the arc's center is to the left of the chord */
|
||||
/* P ... query point */
|
||||
/* */
|
||||
/* note: we assume that the arc is oriented CCW, and that a point-on-circle */
|
||||
/* test has been performed! */
|
||||
/* */
|
||||
#define IsOnArc(A, B, C, P) \
|
||||
(PntLineDist(A, B, C, P) <= ZERO)
|
||||
|
||||
|
||||
#define IsOnArcStrict(A, B, C, P) \
|
||||
(PntLineDist(A, B, C, P) < 0.0)
|
||||
|
||||
|
||||
#define IsOnArcZero(A, B, C, P, eps) \
|
||||
(PntLineDist(A, B, C, P) <= (eps))
|
||||
|
||||
|
||||
/* */
|
||||
/* VS ... unit outwards normal vector of arc at start point */
|
||||
/* VE ... unit outwards normal vector of arc at end point */
|
||||
/* CP ... vector from arc's center to query point */
|
||||
/* */
|
||||
/* note: (1) we assume that the arc is oriented CCW, and */
|
||||
/* that it spans less than 180 degrees! */
|
||||
/* (2) if a point is inside a circle then its distance to the circle */
|
||||
/* is negative. */
|
||||
/* */
|
||||
#define IsInArcCone(VS, VE, CP) \
|
||||
((((VS).x * (CP).y - (VS).y * (CP).x) >= -ZERO) ? \
|
||||
((((VE).y * (CP).x - (VE).x * (CP).y) >= -ZERO) ? 0 : -1) : 1)
|
||||
|
||||
|
||||
#define IsInArcConeZero(VS, VE, CP, eps) \
|
||||
((((VS).x * (CP).y - (VS).y * (CP).x) >= -(eps)) ? \
|
||||
((((VE).y * (CP).x - (VE).x * (CP).y) >= -(eps)) ? 0 : -1) : 1)
|
||||
|
||||
|
||||
#define IsInArcConeStrict(VS, VE, CP) \
|
||||
((((VS).x * (CP).y - (VS).y * (CP).x) > 0.0) ? \
|
||||
((((VE).y * (CP).x - (VE).x * (CP).y) > 0.0) ? 0 : -1) : 1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define PntArcDist(VS, VE, CP, R, eps) \
|
||||
((((VS).x * (CP).y - (VS).y * (CP).x) >= -(eps)) ? \
|
||||
((((VE).y * (CP).x - (VE).x * (CP).y) >= -(eps)) ? (VecLen(CP) - R) \
|
||||
: LARGE) : LARGE)
|
||||
|
||||
|
||||
//#define AbsPntArcDist(VS, VE, CP, R, Z) \
|
||||
// ((((VS).x * (CP).y - (VS).y * (CP).x) >= -(Z)) ? \
|
||||
// ((((VE).y * (CP).x - (VE).x * (CP).y) >= -(Z)) ? \
|
||||
// (numerics_h_local = VecLen(CP) - R, \
|
||||
// ((numerics_h_local < 0.0) ? -numerics_h_local : numerics_h_local)) : \
|
||||
// LARGE) : LARGE)
|
||||
|
||||
|
||||
#define AbsPntArcDist(VS, VE, CP, R, Z) \
|
||||
((((VS).x * (CP).y - (VS).y * (CP).x) >= -(Z)) ? \
|
||||
((((VE).y * (CP).x - (VE).x * (CP).y) >= -(Z)) ? \
|
||||
(((VecLen(CP) - R < 0.0) ? -(VecLen(CP) - R) : VecLen(CP) - R)) : \
|
||||
LARGE) : LARGE)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,218 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 1999-2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_OFFSET_H
|
||||
#define VRONI_OFFSET_H
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
/* */
|
||||
/* the offset curves are stored as closed loops in the array offset_list[]. */
|
||||
/* the individual offset segments are stored in the array offset_data[]. */
|
||||
/* the i-th offset curve contains the offset segments whose indices range */
|
||||
/* from offset_list[i].start to offset_list[i].end. the actual offset */
|
||||
/* distance of the i-th offset curve is stored in offset_list[i].offset. */
|
||||
/* there is a total of num_offset_list many offset curves. */
|
||||
/* */
|
||||
struct off_list {
|
||||
int start; /* index of first segment of this offset curve . */
|
||||
int end; /* index of last segment of this offset curve. */
|
||||
double offset; /* boundary clearance for this offset curve. */
|
||||
//Ensure construction doesn't implicitly initialize elements - done explicitly later anyway
|
||||
inline off_list() {}
|
||||
}; /* data for one offset curve. */
|
||||
|
||||
struct off_data {
|
||||
int site; /* index of corresponding site (contour segment). */
|
||||
t_site type; /* type of corresponding contour segment: PNT, LINE, */
|
||||
/* or CCW, CW. */
|
||||
coord p; /* coordinates of start point of offset segment */
|
||||
#ifdef EXT_APPL_OFF
|
||||
eao_type ext_appl;
|
||||
#endif
|
||||
//Ensure construction doesn't implicitly initialize elements - done explicitly later anyway
|
||||
inline off_data() {}
|
||||
}; /* data for one offset segment */
|
||||
|
||||
off_list* GetOffsetList(int i);
|
||||
off_data* GetOffsetData(int i);
|
||||
|
||||
#define SetEdgeFlagNew(I, F) \
|
||||
{\
|
||||
assert(InEdgeFlagList(I)); \
|
||||
edge_flags[I].e_new = F;\
|
||||
}
|
||||
|
||||
|
||||
#define SetEdgeFlagDeg(I, F) \
|
||||
{\
|
||||
assert(InEdgeFlagList(I)); \
|
||||
edge_flags[I].deg = F;\
|
||||
}
|
||||
|
||||
|
||||
#define SetEdgeDataInit(I, F) \
|
||||
{\
|
||||
assert(InEdgeDataList(I)); \
|
||||
edge_data[I].init = F;\
|
||||
}
|
||||
|
||||
|
||||
#define GetEdgeFlagNew(I) (assert(InEdgeFlagList(I)), edge_flags[I].e_new)
|
||||
|
||||
|
||||
#define GetEdgeFlagDeg(I) (assert(InEdgeFlagList(I)), edge_flags[I].deg)
|
||||
|
||||
|
||||
#define GetEdgeDataInit(I) (assert(InEdgeDataList(I)), edge_data[I].init)
|
||||
|
||||
|
||||
#define AdvanceActiveEdge(I, J, delete) \
|
||||
{\
|
||||
if (delete) { \
|
||||
assert(InActiveEdgeList(J)); \
|
||||
--num_active_edges; \
|
||||
if ((num_active_edges >= 0) && (J < num_active_edges)) { \
|
||||
I = active_edges[J] = active_edges[num_active_edges]; \
|
||||
} \
|
||||
else { \
|
||||
I = NIL; \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
++J; \
|
||||
if (J < num_active_edges) { \
|
||||
I = active_edges[J]; \
|
||||
} \
|
||||
else { \
|
||||
I = NIL; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
// define from offset.cc
|
||||
|
||||
#define OFFS_BLOCK_SIZE 32768
|
||||
#define OFFS_HALF_BLOCK_SIZE 1024
|
||||
|
||||
|
||||
#define NewOffsetCurve \
|
||||
{ \
|
||||
cur_offset_list = num_offset_list; \
|
||||
if (cur_offset_list >= max_num_offset_list) { \
|
||||
max_num_offset_list += OFFS_HALF_BLOCK_SIZE; \
|
||||
gentlyResizeSTLVector(offset_list, max_num_offset_list, "offset:offset_list"); \
|
||||
} \
|
||||
++num_offset_list; \
|
||||
\
|
||||
offset_list[cur_offset_list].start = num_offset_data; \
|
||||
offset_list[cur_offset_list].offset = UnscaleV(t); \
|
||||
\
|
||||
}
|
||||
|
||||
|
||||
#define SetOffsetNumber \
|
||||
{\
|
||||
offset_list[cur_offset_list].end = num_offset_data - 1; \
|
||||
}
|
||||
|
||||
|
||||
#define GetCurrentOffsetSegNumber num_offset_data
|
||||
|
||||
|
||||
#ifdef EXT_APPL_OFF
|
||||
#define StoreOffsetData(S, T, P) \
|
||||
{ \
|
||||
if (num_offset_data >= max_num_offset_data) { \
|
||||
max_num_offset_data += OFFS_BLOCK_SIZE; \
|
||||
gentlyResizeSTLVector(offset_data, max_num_offset_data, "offset:offset_data"); \
|
||||
} \
|
||||
offset_data[num_offset_data].site = S; \
|
||||
offset_data[num_offset_data].type = T; \
|
||||
offset_data[num_offset_data].p = P; \
|
||||
offset_data[num_offset_data].ext_appl = eao_NIL; \
|
||||
\
|
||||
++num_offset_data; \
|
||||
}
|
||||
#else
|
||||
#define StoreOffsetData(S, T, P) \
|
||||
{ \
|
||||
if (num_offset_data >= max_num_offset_data) { \
|
||||
max_num_offset_data += OFFS_BLOCK_SIZE; \
|
||||
gentlyResizeSTLVector(offset_data, max_num_offset_data, "offset:offset_data"); \
|
||||
} \
|
||||
offset_data[num_offset_data].site = S; \
|
||||
offset_data[num_offset_data].type = T; \
|
||||
offset_data[num_offset_data].p = P; \
|
||||
\
|
||||
++num_offset_data; \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef EXT_APPL_OFF
|
||||
#define GetExtApplOffset(O) \
|
||||
(\
|
||||
assert(InOffsetData(O)), \
|
||||
offset_data[O].ext_appl)
|
||||
|
||||
|
||||
#define SetExtApplOffset(O, X) \
|
||||
{\
|
||||
assert(InOffsetData(O)), \
|
||||
offset_data[O].ext_appl = X; \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#define GetOffsetListStart(i) \
|
||||
(\
|
||||
assert(InOffsetList(i)), \
|
||||
offset_list[i].start)
|
||||
|
||||
|
||||
#define GetOffsetListEnd(i) \
|
||||
(\
|
||||
assert(InOffsetList(i)), \
|
||||
offset_list[i].end)
|
||||
|
||||
|
||||
#define GetOffsetEleType(j) \
|
||||
(\
|
||||
assert(InOffsetData(j)), \
|
||||
offset_data[j].type)
|
||||
|
||||
|
||||
#define GetOffsetEleSite(j) \
|
||||
(\
|
||||
assert(InOffsetData(j)), \
|
||||
offset_data[j].site)
|
||||
|
||||
|
||||
#define GetOffsetXCoord(j) \
|
||||
(\
|
||||
assert(InOffsetData(j)), \
|
||||
offset_data[j].p.x)
|
||||
|
||||
|
||||
#define GetOffsetYCoord(j) \
|
||||
(\
|
||||
assert(InOffsetData(j)), \
|
||||
offset_data[j].p.y)
|
||||
|
||||
|
||||
#define GetOffsetPntCoords(j) \
|
||||
(\
|
||||
assert(InOffsetData(j)), \
|
||||
offset_data[j].p)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 1999-2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_RANDOM_H
|
||||
#define VRONI_RANDOM_H
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
#ifndef RAND
|
||||
|
||||
#define RND_MAX 2147483647
|
||||
|
||||
#define UniformRandom(x) \
|
||||
{\
|
||||
x = ((double) random()) / RND_MAX; }
|
||||
|
||||
#define RandomInteger(N) \
|
||||
(\
|
||||
assert(N > 0), \
|
||||
random() % N)
|
||||
|
||||
#define InitRandom(seed) \
|
||||
{\
|
||||
srandom(seed); }
|
||||
|
||||
#else
|
||||
|
||||
#ifdef RAND_MAX
|
||||
#define RND_MAX RAND_MAX
|
||||
#else
|
||||
#define RND_MAX 32767
|
||||
#endif
|
||||
|
||||
#define UniformRandom(x) \
|
||||
{\
|
||||
x = ((double) rand()) / RND_MAX; \
|
||||
}
|
||||
|
||||
#define RandomInteger(N) \
|
||||
(\
|
||||
assert(N > 0), \
|
||||
rand() % N)
|
||||
|
||||
#define InitRandom(seed) \
|
||||
{\
|
||||
srand(seed); }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,273 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 1999-2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_ROOTS_H
|
||||
#define VRONI_ROOTS_H
|
||||
|
||||
int Roots3(double lead, double a, double b, double c, double roots[]);
|
||||
int Roots4(double lead, double a, double b, double c, double d,
|
||||
double roots[]);
|
||||
|
||||
#define ROOTS_ZERO 1.0e-50
|
||||
#define ROOTS_ZERO2 1.0e-100
|
||||
//#define ROOTS_ZERO 1.0e-14
|
||||
//#define ROOTS_ZERO2 1.0e-28
|
||||
#define DISCR_ZERO 1.0e-8
|
||||
#define ROOT_SMALL 0.125 /* ROOT_SMALL = 1/8 >> ZERO */
|
||||
#define ROOT_INV_SMALL 8.0 /* ROOT_INV_SMALL = 1/ROOT_SMALL */
|
||||
|
||||
/* */
|
||||
/* This macro solves the following second-degree polynomial equation: */
|
||||
/* */
|
||||
/* a * x^2 + b * x + c = 0. */
|
||||
/* */
|
||||
/* The roots are stored in roots[0] and roots[1]. Note that only real */
|
||||
/* roots are sought. The number of real roots found is stored in num_roots. */
|
||||
/* */
|
||||
#define Roots2abc(a, b, c, roots, num_roots) \
|
||||
{ \
|
||||
while (eq(a, ROOT_SMALL) && eq(b, ROOT_SMALL) && eq(c, ROOT_SMALL) && ((a != 0.0) || (b != 0.0) || (c != 0.0))) { \
|
||||
a *= 2.0; \
|
||||
b *= 2.0; \
|
||||
c *= 2.0; \
|
||||
} \
|
||||
while ((Abs(a) > ROOT_INV_SMALL) && (Abs(b) > ROOT_INV_SMALL) && (Abs(c) > ROOT_INV_SMALL)) { \
|
||||
a /= 2.0; \
|
||||
b /= 2.0; \
|
||||
c /= 2.0; \
|
||||
} \
|
||||
if (eq(a, ROOTS_ZERO)) { \
|
||||
if (eq(b, ROOTS_ZERO)) { \
|
||||
if (eq(c, ROOTS_ZERO)) { \
|
||||
num_roots = -1; \
|
||||
} \
|
||||
else { \
|
||||
num_roots = 0; \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
roots[0] = - c / b; \
|
||||
num_roots = 1; \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
basic_h_local_delta = b * b - 4 * a * c; \
|
||||
if (basic_h_local_delta > 0.0) { \
|
||||
if (b > 0) { \
|
||||
basic_h_local = - 0.5 * (b + sqrt(basic_h_local_delta)); \
|
||||
} \
|
||||
else { \
|
||||
basic_h_local = - 0.5 * (b - sqrt(basic_h_local_delta)); \
|
||||
} \
|
||||
if (eq(basic_h_local, ROOTS_ZERO)) { \
|
||||
roots[0] = basic_h_local / a; \
|
||||
num_roots = 1; \
|
||||
} \
|
||||
else { \
|
||||
roots[0] = basic_h_local / a; \
|
||||
roots[1] = c / basic_h_local; \
|
||||
num_roots = 2; \
|
||||
} \
|
||||
} \
|
||||
else if (eq(basic_h_local_delta, DISCR_ZERO)) { \
|
||||
roots[0] = - b / (2.0 * a); \
|
||||
num_roots = 1; \
|
||||
} \
|
||||
else { \
|
||||
num_roots = 0; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* */
|
||||
/* This macro solves the following second-degree polynomial equation: */
|
||||
/* */
|
||||
/* x^2 + p * x + q = 0. */
|
||||
/* */
|
||||
/* The roots are stored in roots[0] and roots[1]. Note that only real */
|
||||
/* roots are sought. The number of real roots found is stored in num_roots. */
|
||||
/* */
|
||||
#define Roots2pq(p, q, roots, num_roots) \
|
||||
{ \
|
||||
basic_h_local_delta = p * p - 4 * q; \
|
||||
if (basic_h_local_delta > 0.0) { \
|
||||
if (p > 0) { \
|
||||
basic_h_local = - 0.5 * (p + sqrt(basic_h_local_delta)); \
|
||||
} \
|
||||
else { \
|
||||
basic_h_local = - 0.5 * (p - sqrt(basic_h_local_delta)); \
|
||||
} \
|
||||
if (eq(basic_h_local, ROOTS_ZERO)) { \
|
||||
roots[0] = basic_h_local; \
|
||||
num_roots = 1; \
|
||||
} \
|
||||
else { \
|
||||
roots[0] = basic_h_local; \
|
||||
roots[1] = q / basic_h_local; \
|
||||
num_roots = 2; \
|
||||
} \
|
||||
} \
|
||||
else if (eq(basic_h_local_delta, ROOTS_ZERO2)) { \
|
||||
roots[0] = - 0.5 * p; \
|
||||
num_roots = 1; \
|
||||
} \
|
||||
else { \
|
||||
num_roots = 0; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* */
|
||||
/* This macro solves the following 2x2 linear system: */
|
||||
/* */
|
||||
/* A[0][0] * x + A[0][1] * y = B[0] */
|
||||
/* A[1][1] * x + A[1][1] * y = B[1] */
|
||||
/* */
|
||||
/* If a unique solution exists, then exists := 1, and the solution is stored */
|
||||
/* in xy[2]. If the solution is not unique, then exists := 2, and a solution */
|
||||
/* is stored in xy[2]. Otherwise, exists := 0. */
|
||||
/* */
|
||||
/* i, j, I, J are dummy integers needed within the macro. */
|
||||
/* */
|
||||
#define LinearEqnSolver_2x2(A, B, xy, exists, i, j, I, J) \
|
||||
{ \
|
||||
/* */ \
|
||||
/* find a column with a non-zero element */ \
|
||||
/* */ \
|
||||
exists = 0; \
|
||||
if (!eq((A)[0][0], ROOTS_ZERO) || !eq((A)[1][0], ROOTS_ZERO)) { \
|
||||
I = 0; \
|
||||
J = 1; \
|
||||
} \
|
||||
else if (!eq((A)[0][1], ROOTS_ZERO) || !eq((A)[1][1], ROOTS_ZERO)) { \
|
||||
I = 1; \
|
||||
J = 0; \
|
||||
} \
|
||||
else { \
|
||||
if (eq((B)[0], ROOTS_ZERO) && eq((B)[1], ROOTS_ZERO)) { \
|
||||
(xy)[0] = (xy)[1] = 0.0; \
|
||||
(exists) = 2; \
|
||||
} \
|
||||
I = J = 0; \
|
||||
} \
|
||||
\
|
||||
/* */ \
|
||||
/* determine i s.t. Abs(A[i][I]) is maximum. */ \
|
||||
/* */ \
|
||||
if ((I > 0) || (J > 0)) { \
|
||||
if (Abs((A)[0][I]) > Abs((A)[1][I])) { \
|
||||
i = 0; \
|
||||
j = 1; \
|
||||
} \
|
||||
else { \
|
||||
i = 1; \
|
||||
j = 0; \
|
||||
} \
|
||||
\
|
||||
basic_h_local_quot = (A)[j][I] / (A)[i][I]; \
|
||||
basic_h_local_delta = (A)[j][J] - basic_h_local_quot * (A)[i][J]; \
|
||||
if (!eq(basic_h_local_delta, ROOTS_ZERO)) { \
|
||||
(xy)[J] = ((B)[j] - basic_h_local_quot * (B)[i]) / basic_h_local_delta; \
|
||||
(xy)[I] = ((B)[i] - (xy)[J] * (A)[i][J]) / (A)[i][I]; \
|
||||
(exists) = 1; \
|
||||
} \
|
||||
else { \
|
||||
basic_h_local_delta = (B)[j] - basic_h_local_quot * (B)[i]; \
|
||||
if (eq(basic_h_local_delta, ROOTS_ZERO)) { \
|
||||
(xy)[J] = 0.0; \
|
||||
(xy)[I] = (B)[i] / (A)[i][I]; \
|
||||
(exists) = 2; \
|
||||
} \
|
||||
else { \
|
||||
(exists) = 0; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* */
|
||||
/* This macro solves the following 2x2 linear system: */
|
||||
/* */
|
||||
/* A[0][0] * x + A[0][1] * y = B[0] */
|
||||
/* A[1][1] * x + A[1][1] * y = B[1] */
|
||||
/* */
|
||||
/* If a unique solution exists, then exists := 1, and the solution is stored */
|
||||
/* in xy[2]. If the solution is not unique, then exists := 2, and a solution */
|
||||
/* is stored in xy[2]. Otherwise, exists := 0. */
|
||||
/* */
|
||||
/* i, j, I, J are dummy integers needed within the macro. */
|
||||
/* */
|
||||
#define LinearEqnSolver_2x2_Zero(A, B, xy, exists, i, j, I, J) \
|
||||
{ \
|
||||
/* */ \
|
||||
/* find a column with a non-zero element */ \
|
||||
/* */ \
|
||||
exists = 0; \
|
||||
if (!eq((A)[0][0], ROOTS_ZERO) || !eq((A)[1][0], ROOTS_ZERO)) { \
|
||||
I = 0; \
|
||||
J = 1; \
|
||||
} \
|
||||
else if (!eq((A)[0][1], ROOTS_ZERO) || !eq((A)[1][1], ROOTS_ZERO)) { \
|
||||
I = 1; \
|
||||
J = 0; \
|
||||
} \
|
||||
else { \
|
||||
if (eq((B)[0], ROOTS_ZERO) && eq((B)[1], ROOTS_ZERO)) { \
|
||||
(xy)[0] = (xy)[1] = 0.0; \
|
||||
(exists) = 2; \
|
||||
} \
|
||||
I = J = 0; \
|
||||
} \
|
||||
\
|
||||
/* */ \
|
||||
/* determine i s.t. Abs(A[i][I]) is maximum. */ \
|
||||
/* */ \
|
||||
if ((I > 0) || (J > 0)) { \
|
||||
if (Abs((A)[0][I]) > Abs((A)[1][I])) { \
|
||||
i = 0; \
|
||||
j = 1; \
|
||||
} \
|
||||
else { \
|
||||
i = 1; \
|
||||
j = 0; \
|
||||
} \
|
||||
\
|
||||
basic_h_local_quot = (A)[j][I] / (A)[i][I]; \
|
||||
basic_h_local_delta = (A)[j][J] - basic_h_local_quot * (A)[i][J]; \
|
||||
if (!eq(basic_h_local_delta, ROOTS_ZERO)) { \
|
||||
(xy)[J] = ((B)[j] - basic_h_local_quot * (B)[i]) / basic_h_local_delta; \
|
||||
(xy)[I] = ((B)[i] - (xy)[J] * (A)[i][J]) / (A)[i][I]; \
|
||||
(exists) = 1; \
|
||||
} \
|
||||
else { \
|
||||
basic_h_local_delta = (B)[j] - basic_h_local_quot * (B)[i]; \
|
||||
if (eq(basic_h_local_delta, ROOTS_ZERO)) { \
|
||||
(xy)[J] = 0.0; \
|
||||
(xy)[I] = (B)[i] / (A)[i][I]; \
|
||||
(exists) = 2; \
|
||||
} \
|
||||
else { \
|
||||
(exists) = 0; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 2000-2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-172 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_STACK_H
|
||||
#define VRONI_STACK_H
|
||||
|
||||
#define Push(data) \
|
||||
{\
|
||||
++num_stack; \
|
||||
if (num_stack >= max_num_stack) { \
|
||||
max_num_stack += STACK_INCR; \
|
||||
stack = (STACK_TYPE*) ReallocateArray(stack, max_num_stack, sizeof(STACK_TYPE), STACK_STRING); \
|
||||
} \
|
||||
stack[num_stack] = data; \
|
||||
}
|
||||
|
||||
|
||||
#define Pop(data) \
|
||||
{\
|
||||
assert(num_stack > 0); \
|
||||
data = stack[num_stack]; \
|
||||
--num_stack; \
|
||||
}
|
||||
|
||||
|
||||
#define GetStackSize (num_stack)
|
||||
|
||||
#define StackIsNotEmpty (num_stack > 0)
|
||||
|
||||
#define StackIsEmpty (num_stack <= 0)
|
||||
|
||||
#define ResetStack { num_stack = 0; }
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 2001-2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Stefan Huber */
|
||||
/* Modified: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
#ifndef VRONI_TYPES_H
|
||||
#define VRONI_TYPES_H
|
||||
|
||||
|
||||
#ifdef HAVE_BOOL
|
||||
#include <stdbool.h>
|
||||
typedef bool vr_bool;
|
||||
#else
|
||||
#define false 0
|
||||
#define true (!false)
|
||||
typedef unsigned char vr_bool;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,287 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 2010-2023 M. Held, S. Huber */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Stefan Huber, Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_UTIL_H
|
||||
#define VRONI_UTIL_H
|
||||
|
||||
#ifndef DOUBLE_OVERRIDE
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#include "consts.h"
|
||||
|
||||
|
||||
inline static int Sign(double_arg x)
|
||||
{
|
||||
if ((x == 0.0) || (x == -0.0))
|
||||
return 0;
|
||||
|
||||
if ( x > 0.0)
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/** Like Sign but closed interval (-eps, eps) is identified with 0 */
|
||||
inline static int SignEps(double_arg x, double_arg eps)
|
||||
{
|
||||
if (x > eps)
|
||||
return 1;
|
||||
else if (x < -eps)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline static double Abs(double_arg x)
|
||||
{
|
||||
return fabs(x);
|
||||
}
|
||||
|
||||
inline static void Swap_d(double* x, double* y)
|
||||
{
|
||||
double t = *y;
|
||||
*y = *x;
|
||||
*x = t;
|
||||
}
|
||||
|
||||
inline static void Swap_i(int* x, int* y)
|
||||
{
|
||||
int t = *y;
|
||||
*y = *x;
|
||||
*x = t;
|
||||
}
|
||||
|
||||
inline static double Ceiling(double_arg x)
|
||||
{
|
||||
return ceil(x);
|
||||
}
|
||||
|
||||
#ifndef DOUBLE_OVERRIDE
|
||||
//function currently unused. In case it is used later, it requires
|
||||
//another way to calculate the CubicRoot for CORE and possibly MPFR
|
||||
inline static double CubicRoot(double_arg x)
|
||||
{
|
||||
const double r = pow(x, M_1_3);
|
||||
if(Sign(x)<0)
|
||||
return -r;
|
||||
else
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define Sq(x) ((x) * (x))
|
||||
|
||||
#define VroniSwap(i1, i2, i) \
|
||||
{(i) = (i1); \
|
||||
(i1) = (i2); \
|
||||
(i2) = (i); }
|
||||
|
||||
#define Min(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define Max(a, b) ((b) < (a) ? (a) : (b))
|
||||
#define Min3(a, b, c) (((a) < (b)) ? \
|
||||
(((a) < (c)) ? \
|
||||
(a) : (c)) \
|
||||
: \
|
||||
(((b) < (c)) ? \
|
||||
(b) : (c)))
|
||||
#define Max3(a, b, c) (((a) < (b)) ? \
|
||||
(((b) < (c)) ? \
|
||||
(c) : (b)) \
|
||||
: \
|
||||
(((a) < (c)) ? \
|
||||
(c) : (a)))
|
||||
#define Min4(a, b, c, d) (((a) < (b)) ? \
|
||||
(((a) < (c)) ? \
|
||||
(((a) < (d)) ?\
|
||||
(a) : (d)) \
|
||||
: \
|
||||
(((c) < (d)) ? \
|
||||
(c) : (d))) \
|
||||
: \
|
||||
(((b) < (c)) ? \
|
||||
(((b) < (d)) ? \
|
||||
(b) : (d)) \
|
||||
: \
|
||||
(((c) < (d)) ? \
|
||||
(c) : (d))))
|
||||
#define Max4(a, b, c, d) (((a) < (b)) ? \
|
||||
(((b) < (c)) ? \
|
||||
(((c) < (d)) ?\
|
||||
(d) : (c)) \
|
||||
: \
|
||||
(((b) < (d)) ? \
|
||||
(d) : (b))) \
|
||||
: \
|
||||
(((a) < (c)) ? \
|
||||
(((c) < (d)) ? \
|
||||
(d) : (c)) \
|
||||
: \
|
||||
(((a) < (d)) ? \
|
||||
(d) : (a))))
|
||||
|
||||
#define MinMax3(a, b, c, min, max) {\
|
||||
if ((a) < (b)) {\
|
||||
if ((a) < (c)) {\
|
||||
min = (a); \
|
||||
if ((b) < (c)) max = (c); \
|
||||
else max = (b); \
|
||||
}\
|
||||
else { \
|
||||
min = (c); \
|
||||
max = (b); \
|
||||
}\
|
||||
}\
|
||||
else { \
|
||||
if ((a) < (c)) {\
|
||||
min = (b); \
|
||||
max = (c); \
|
||||
} \
|
||||
else { \
|
||||
max = (a); \
|
||||
if ((b) < (c)) min = (b); \
|
||||
else min = (c); \
|
||||
} \
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
#define MinMax4(a, b, c, d, min, max) {\
|
||||
if ((a) < (b)) {\
|
||||
if ((a) < (c)) {\
|
||||
min = (a); \
|
||||
if ((b) < (c)) max = (c); \
|
||||
else max = (b); \
|
||||
} \
|
||||
else { \
|
||||
min = (c); \
|
||||
max = (b); \
|
||||
} \
|
||||
}\
|
||||
else { \
|
||||
if ((a) < (c)) { \
|
||||
min = (b); \
|
||||
max = (c); \
|
||||
} \
|
||||
else { \
|
||||
max = (a); \
|
||||
if ((b) < (c)) min = (b); \
|
||||
else min = (c); \
|
||||
}\
|
||||
} \
|
||||
if ((d) < min) min = (d); \
|
||||
else if ((d) > max) max = (d); \
|
||||
}
|
||||
|
||||
|
||||
#define SortTwoNumbers(a, b, c) {\
|
||||
if (a > b) { \
|
||||
c = a; \
|
||||
a = b; \
|
||||
b = c; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define SortThreeNumbers(a, b, c, d) {\
|
||||
if (a < b) {\
|
||||
if (a < c) {\
|
||||
if (b > c) {\
|
||||
d = b; \
|
||||
b = c; \
|
||||
c = d; \
|
||||
}\
|
||||
}\
|
||||
else { \
|
||||
d = a; \
|
||||
a = c; \
|
||||
c = b; \
|
||||
b = d; \
|
||||
}\
|
||||
}\
|
||||
else { \
|
||||
if (a < c) { \
|
||||
d = a; \
|
||||
a = b; \
|
||||
b = d; \
|
||||
} \
|
||||
else { \
|
||||
if (b < c) {\
|
||||
d = a; \
|
||||
a = b; \
|
||||
b = c; \
|
||||
c = d; \
|
||||
}\
|
||||
else { \
|
||||
d = a; \
|
||||
a = c; \
|
||||
c = d; \
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
#define MinMax(a, b, min, max) {\
|
||||
if ((b) < (a)) {\
|
||||
min = (b); \
|
||||
max = (a); \
|
||||
} \
|
||||
else { \
|
||||
min = (a); \
|
||||
max = (b); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define MinMaxQ(a, b, min, max) \
|
||||
(((b) < (a)) ? (min = (b), max = (a)) : (min = (a), max = (b)))
|
||||
|
||||
|
||||
#define MinMax3Q(a, b, c, min, max) \
|
||||
(((b) < (a)) ? (((c) < (b)) ? (min = (c), max = (a)) : \
|
||||
(((c) > (a)) ? (min = (b), max = (c)) : \
|
||||
(min = (b), max = (a)))) : \
|
||||
(((c) > (b)) ? (min = (a), max = (c)) : \
|
||||
(((c) > (a)) ? (min = (a), max = (b)) : \
|
||||
(min = (c), max = (b)))))
|
||||
|
||||
|
||||
|
||||
|
||||
/* */
|
||||
/* some macros for epsilon-based comparisons with respect to zero... */
|
||||
/* */
|
||||
#define lt(a, b) ( ((a) < -b) )
|
||||
#define ge(a, b) (! ((a) < -b) )
|
||||
#define le(a, b) ( ((a) <= b) )
|
||||
#define gt(a, b) (! ((a) <= b) )
|
||||
#define eq(a, eps) ( (((a) <= eps) && !((a) < -eps)) )
|
||||
#define ne(a, eps) ( !eq(a,eps) )
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,349 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 2010-2023 M. Held, S. Huber */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Stefan Huber, Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_VDDATA_H
|
||||
#define VRONI_VDDATA_H
|
||||
|
||||
#ifndef DOUBLE_OVERRIDE
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
#include "consts.h"
|
||||
#include "ext_appl_defs.h"
|
||||
#include "wmat.h"
|
||||
|
||||
|
||||
#if defined(OGL_GRAPHICS)
|
||||
#ifndef GRAPHICS
|
||||
#define GRAPHICS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// tipo di bisettore
|
||||
typedef enum {
|
||||
LINE,
|
||||
PARABOLA,
|
||||
HYPERBOLA,
|
||||
HYPERELL,
|
||||
NONE
|
||||
} BisectorType ;
|
||||
|
||||
|
||||
|
||||
/** Different types of input sites, Voronoi diagram objects, Delaunay
|
||||
* triangulation object, and offsetting object */
|
||||
typedef enum
|
||||
{
|
||||
/** Segment */
|
||||
SEG,
|
||||
/** Arc */
|
||||
ARC,
|
||||
/** Point */
|
||||
PNT,
|
||||
|
||||
/** Voronoi node */
|
||||
VDN,
|
||||
/** Voronoi edge */
|
||||
VDE,
|
||||
|
||||
/** Delaunay triangulation edge */
|
||||
DTE,
|
||||
|
||||
/** CCW offset arc */
|
||||
CCW,
|
||||
/** CW offset arc */
|
||||
CW,
|
||||
|
||||
UNKNOWN
|
||||
} t_site;
|
||||
|
||||
|
||||
|
||||
/** Status of voronoi node */
|
||||
typedef enum
|
||||
{
|
||||
/** not yet checked */
|
||||
UNCHECKED,
|
||||
/** keep this node */
|
||||
CHECKED,
|
||||
/** delete this node */
|
||||
DELETED,
|
||||
/** already visited, marked for deletion */
|
||||
VISITED,
|
||||
/** this is a dummy node */
|
||||
DUMMY,
|
||||
MISC
|
||||
} n_status;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** Input vertex */
|
||||
struct pnt
|
||||
{
|
||||
/** Position of vertex */
|
||||
coord p;
|
||||
|
||||
/** An edge to the Voronoi cell of this point */
|
||||
int vd;
|
||||
/** A Voronoi node that concides with it */
|
||||
int node;
|
||||
|
||||
/** Already visited */
|
||||
vr_bool vis;
|
||||
/** Segment/arc that is incident has already been inserted. */
|
||||
vr_bool s;
|
||||
|
||||
/** Will be deleted during next restart */
|
||||
vr_bool del;
|
||||
|
||||
#ifdef WRITE_VD
|
||||
int vd_edge;
|
||||
int idx;
|
||||
#endif
|
||||
|
||||
#ifdef GRAPHICS
|
||||
/** We draw this point */
|
||||
vr_bool draw;
|
||||
#endif
|
||||
|
||||
#ifdef ORDERED
|
||||
/** number assinged in increasing order for every pnt */
|
||||
int key;
|
||||
#endif
|
||||
|
||||
#ifdef EXT_APPL_PNTS
|
||||
eap_type ext_appl;/* this field can be set by an application program to */
|
||||
/* refer to a user-defined entity. */
|
||||
#endif
|
||||
//Ensure construction doesn't implicitly initialize elements - done explicitly later anyway
|
||||
inline pnt() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** Input segment */
|
||||
struct seg
|
||||
{
|
||||
/** Start point */
|
||||
int i1;
|
||||
/** End point */
|
||||
int i2;
|
||||
|
||||
/** parameter in a*x + b*x + c = 0 */
|
||||
double a;
|
||||
/** parameter in a*x + b*x + c = 0 */
|
||||
double b;
|
||||
/** parameter in a*x + b*x + c = 0 */
|
||||
double c;
|
||||
|
||||
/** length of line segment */
|
||||
double lgth;
|
||||
|
||||
/** an edge of the Voroni cell of this seg*/
|
||||
int vd;
|
||||
|
||||
#ifdef WRITE_VD
|
||||
int vd_edge;
|
||||
#endif
|
||||
|
||||
#ifdef GRAPHICS
|
||||
/** We draw this point */
|
||||
vr_bool draw;
|
||||
#endif
|
||||
|
||||
#ifdef ORDERED
|
||||
/** number assigned in increasing order for every pnt */
|
||||
int key;
|
||||
#endif
|
||||
|
||||
#ifdef EXT_APPL_SITES
|
||||
eas_type ext_appl;/* this field can be set by an application program to */
|
||||
/* refer to a user-defined entity. */
|
||||
#endif
|
||||
//Ensure construction doesn't implicitly initialize elements - done explicitly later anyway
|
||||
inline seg() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** Input arc */
|
||||
struct arc
|
||||
{
|
||||
/** start point */
|
||||
int i1;
|
||||
/** end point */
|
||||
int i2;
|
||||
|
||||
/** center point */
|
||||
coord c;
|
||||
/** radius */
|
||||
double r;
|
||||
/** orientation */
|
||||
vr_bool ccw;
|
||||
|
||||
/** unit normal vector at start point point outwards */
|
||||
coord ns;
|
||||
/** unit normal vector at end point point outwards */
|
||||
coord ne;
|
||||
|
||||
/** parameter of chord line equation a*x + b*y + d = 0 */
|
||||
double a;
|
||||
/** parameter of chord line equation a*x + b*y + d = 0 */
|
||||
double b;
|
||||
/** parameter of chord line equation a*x + b*y + d = 0 */
|
||||
double d;
|
||||
|
||||
/** an edge of the voronoi cell of this arc */
|
||||
int vd;
|
||||
|
||||
#ifdef GRAPHICS
|
||||
/** We draw this point */
|
||||
vr_bool draw;
|
||||
#endif
|
||||
|
||||
#ifdef ORDERED
|
||||
/** number assigned in increasing order for every pnt */
|
||||
int key;
|
||||
#endif
|
||||
|
||||
#ifdef EXT_APPL_SITES
|
||||
eas_type ext_appl;/* this field can be set by an application program to */
|
||||
/* refer to a user-defined entity. */
|
||||
#endif
|
||||
//Ensure construction doesn't implicitly initialize elements - done explicitly later anyway
|
||||
inline arc() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** Voronoi node */
|
||||
struct node
|
||||
{
|
||||
/** Position */
|
||||
coord p;
|
||||
/** Clearance.
|
||||
* Attention: During pnt-VD generation this is the squared clearance!!! */
|
||||
double r2;
|
||||
/** A degree-two node */
|
||||
vr_bool deg2;
|
||||
|
||||
/** Current status of node */
|
||||
n_status status;
|
||||
|
||||
/** an incident edge */
|
||||
int edge;
|
||||
/** an input point, if node coincides with some. NIL otherwise. */
|
||||
int site;
|
||||
|
||||
#ifdef WRITE_VD
|
||||
int idx;
|
||||
#endif
|
||||
|
||||
#ifdef EXT_APPL_VD
|
||||
ean_type ext_appl;/* this field can be set by an application program to */
|
||||
/* refer to a user-defined entity. */
|
||||
#endif
|
||||
//Ensure construction doesn't implicitly initialize elements - done explicitly later anyway
|
||||
inline node() {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct edge {
|
||||
int n1; /* start node */
|
||||
int n2; /* end node */
|
||||
int lft; /* left defining site */
|
||||
int rgt; /* right defining site */
|
||||
t_site ltype; /* type of left defining site: PNT, SEG, or ARC */
|
||||
t_site rtype; /* type of right defining site: PNT, SEG, or ARC */
|
||||
int s_ccw; /* next edge in CCW order around start node */
|
||||
int s_cw; /* next edge in CW order around start node */
|
||||
int e_ccw; /* next edge in CCW order around end node */
|
||||
int e_cw; /* next edge in CW order around end node */
|
||||
vr_bool del; /* edge to be deleted during the incremental insertion? */
|
||||
#ifdef MAT
|
||||
w_mat_data w_mat; /* data for the (weighted) medial axis */
|
||||
#endif
|
||||
#ifdef EXT_APPL_VD
|
||||
eae_type ext_appl;/* this field can be set by an application program to */
|
||||
/* refer to a user-defined entity. */
|
||||
#endif
|
||||
//Ensure construction doesn't implicitly initialize elements - done explicitly later anyway
|
||||
inline edge() {}
|
||||
}; /********** Voronoi edge ******************************/
|
||||
|
||||
|
||||
typedef struct {
|
||||
vr_bool active; /* for repeated offsetting: true if the offset value is */
|
||||
/* less than the maximum of the clearances of the nodes */
|
||||
/* of this VD edge. */
|
||||
vr_bool e_new; /* true if no offset curve (at the current offset) has */
|
||||
/* already intersected this bisector. */
|
||||
vr_bool deg; /* true if the clearance of the start node of this edge */
|
||||
/* is identical to the clearance of the end node */
|
||||
} e_flag; /************* status flags for Voronoi edges ***********/
|
||||
|
||||
struct e_formula {
|
||||
vr_bool init; /* true if a parameterization of this bisectors has not */
|
||||
/* yet been computed. */
|
||||
double A; /* coefficient of parameterization; see data_off.c */
|
||||
double B; /* coefficient of parameterization; see data_off.c */
|
||||
#ifdef GENUINE_ARCS
|
||||
double C; /* coefficient of parameterization; see data_off.c */
|
||||
double D; /* coefficient of parameterization; see data_off.c */
|
||||
#endif
|
||||
double d; /* coefficient of parameterization; see data_off.c */
|
||||
vr_bool k1; /* positive or negative sliding direction of site #1 */
|
||||
vr_bool k2; /* positive or negative sliding direction of site #2 */
|
||||
vr_bool sign; /* positive or negative sign in the parameterization? */
|
||||
//Ensure construction doesn't implicitly initialize elements - done explicitly later anyway
|
||||
inline e_formula() {}
|
||||
}; /******* parameterization data for Voronoi edges ********/
|
||||
|
||||
#ifdef ORDERED
|
||||
struct ordered_sites
|
||||
{
|
||||
int ind;
|
||||
int key;
|
||||
//Ensure construction doesn't implicitly initialize elements - done explicitly later anyway
|
||||
inline ordered_sites() {}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef SORTED
|
||||
struct sorted_sites
|
||||
{
|
||||
int ind;
|
||||
double lgth;
|
||||
//Ensure construction doesn't implicitly initialize elements - done explicitly later anyway
|
||||
inline sorted_sites() {}
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,109 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 1999-2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_VECTOR_H
|
||||
#define VRONI_VECTOR_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <new>
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
template<typename T>
|
||||
class vronivector {
|
||||
|
||||
private:
|
||||
unsigned int arraysize;
|
||||
T * array;
|
||||
|
||||
public:
|
||||
inline vronivector() : arraysize(0), array(NULL) {}
|
||||
|
||||
inline ~vronivector() {
|
||||
free(array);
|
||||
}
|
||||
|
||||
T * begin() {
|
||||
return array;
|
||||
}
|
||||
|
||||
T * end() {
|
||||
return array + arraysize;
|
||||
}
|
||||
|
||||
unsigned int size() {
|
||||
return arraysize;
|
||||
}
|
||||
|
||||
void inline reserve(unsigned int ) {}
|
||||
|
||||
void resize(unsigned int newsize) {
|
||||
|
||||
/* */
|
||||
/* Call destructor of elements no longer needed if the size of the */
|
||||
/* array is reduced */
|
||||
/* */
|
||||
for(unsigned int i = newsize; i < arraysize; ++i) {
|
||||
array[i].~T();
|
||||
}
|
||||
|
||||
// Reallocate
|
||||
T * newarray = (T*) realloc(array, newsize * sizeof(T));
|
||||
if (newarray == NULL) throw std::bad_alloc();
|
||||
|
||||
//Initialize new elements of array
|
||||
for(unsigned int i = arraysize; i < newsize; ++i) {
|
||||
new (&newarray[i]) T();
|
||||
}
|
||||
array = newarray;
|
||||
arraysize = newsize;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
free(array);
|
||||
array = NULL;
|
||||
arraysize = 0;
|
||||
}
|
||||
|
||||
|
||||
inline T & operator[](unsigned int ind) {
|
||||
return array[ind];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <class vtype>
|
||||
inline void gentlyResizeSTLVector(vtype & v, unsigned int newsize,
|
||||
const char * vname) {
|
||||
try {
|
||||
v.reserve(newsize);
|
||||
v.resize(newsize);
|
||||
}
|
||||
catch (std::bad_alloc& c) {
|
||||
std::cerr << "\n" << "VRONI exception while trying to resize vector "
|
||||
<< vname << " (" << c.what() << ")" << std::endl;
|
||||
throw std::runtime_error("VRONI error: gentlyResizeSTLVector() - memory reallocation failed!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,150 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Copyright (C) 2001-2023 M. Held */
|
||||
/* */
|
||||
/* This code is not in the public domain. All rights reserved! Please make */
|
||||
/* sure to read the full copyright statement contained in "README.txt" or in */
|
||||
/* the "main" file of this code, such as "main.cc". */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* Written by: Martin Held */
|
||||
/* */
|
||||
/* E-Mail: held@cs.sbg.ac.at */
|
||||
/* Fax Mail: (+43 662) 8044-611 */
|
||||
/* Voice Mail: (+43 662) 8044-6304 */
|
||||
/* Snail Mail: Martin Held */
|
||||
/* FB Informatik */
|
||||
/* Universitaet Salzburg */
|
||||
/* A-5020 Salzburg, Austria */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef VRONI_WMAT_H
|
||||
#define VRONI_WMAT_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
|
||||
#ifdef WMAT
|
||||
#ifndef MAT
|
||||
#define MAT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MAT
|
||||
|
||||
|
||||
typedef struct {
|
||||
vr_bool in_w_mat; /* true if a portion of this VD edge belongs also to */
|
||||
/* WMAT or MAT */
|
||||
#ifdef WMAT
|
||||
double r_min; /* minimum contour clearance of this edge */
|
||||
double r_max; /* maximum contour clearance of this edge */
|
||||
coord lft_mn_pnt; /* left contact point for disk with radius r_min */
|
||||
coord lft_mx_pnt; /* left contact point for disk with radius r_max */
|
||||
coord rgt_mn_pnt; /* right contact point for disk with radius r_min */
|
||||
coord rgt_mx_pnt; /* right contact point for disk with radius r_max */
|
||||
#endif
|
||||
#ifdef EXT_APPL_WMAT
|
||||
eam_type ext_appl;/* this field can be set by an application program to */
|
||||
/* refer to a user-defined entity. */
|
||||
#endif
|
||||
} w_mat_data; /*********** (weighted) medial axis *********************/
|
||||
|
||||
|
||||
|
||||
#define IsWmatEdge(E) \
|
||||
(\
|
||||
assert(InEdgesList(E)), \
|
||||
(edges[E].w_mat.in_w_mat))
|
||||
|
||||
|
||||
#define SetWmatEdge(E, B) \
|
||||
{\
|
||||
assert(InEdgesList(E)); \
|
||||
edges[E].w_mat.in_w_mat = B; \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WMAT
|
||||
#define GetWmatRMin(E) \
|
||||
(\
|
||||
assert(InEdgesList(E)), \
|
||||
(edges[E].w_mat.r_min))
|
||||
|
||||
|
||||
#define SetWmatRMin(E, R) \
|
||||
{\
|
||||
assert(InEdgesList(E)); \
|
||||
edges[E].w_mat.r_min = R; \
|
||||
}
|
||||
|
||||
|
||||
#define GetWmatRMax(E) \
|
||||
(\
|
||||
assert(InEdgesList(E)), \
|
||||
(edges[E].w_mat.r_max))
|
||||
|
||||
|
||||
#define SetWmatRMax(E, R) \
|
||||
{\
|
||||
assert(InEdgesList(E)); \
|
||||
edges[E].w_mat.r_max = R; \
|
||||
}
|
||||
|
||||
|
||||
#define GetWmatLftMnPnt(E) \
|
||||
(\
|
||||
assert(InEdgesList(E)), \
|
||||
(edges[E].w_mat.lft_mn_pnt))
|
||||
|
||||
|
||||
#define SetWmatLftMnPnt(E, P) \
|
||||
{\
|
||||
assert(InEdgesList(E)); \
|
||||
edges[E].w_mat.lft_mn_pnt = P; \
|
||||
}
|
||||
|
||||
|
||||
#define GetWmatRgtMnPnt(E) \
|
||||
(\
|
||||
assert(InEdgesList(E)), \
|
||||
(edges[E].w_mat.rgt_mn_pnt))
|
||||
|
||||
|
||||
#define SetWmatRgtMnPnt(E, P) \
|
||||
{\
|
||||
assert(InEdgesList(E)); \
|
||||
edges[E].w_mat.rgt_mn_pnt = P; \
|
||||
}
|
||||
|
||||
|
||||
#define GetWmatLftMxPnt(E) \
|
||||
(\
|
||||
assert(InEdgesList(E)), \
|
||||
(edges[E].w_mat.lft_mx_pnt))
|
||||
|
||||
|
||||
#define SetWmatLftMxPnt(E, P) \
|
||||
{\
|
||||
assert(InEdgesList(E)); \
|
||||
edges[E].w_mat.lft_mx_pnt = P; \
|
||||
}
|
||||
|
||||
|
||||
#define GetWmatRgtMxPnt(E) \
|
||||
(\
|
||||
assert(InEdgesList(E)), \
|
||||
(edges[E].w_mat.rgt_mx_pnt))
|
||||
|
||||
|
||||
#define SetWmatRgtMxPnt(E, P) \
|
||||
{\
|
||||
assert(InEdgesList(E)); \
|
||||
edges[E].w_mat.rgt_mx_pnt = P; \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user