bf3a3fa297
- aggiunta libreria vroni 7.6.
350 lines
9.6 KiB
C
350 lines
9.6 KiB
C
/*****************************************************************************/
|
|
/* */
|
|
/* 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
|
|
|