Files
SaraP bf3a3fa297 Extern :
- aggiunta libreria vroni 7.6.
2023-11-23 12:09:32 +01:00

1168 lines
24 KiB
C

/*****************************************************************************/
/* */
/* 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_VD_DATA_H
#define VRONI_VD_DATA_H
/* #define TRACE */
#define DATA_BLOCK_SIZE 1024
inline void vroniObject::ResetLoopStackSize(int size)
{
num_loop_stack = size;
}
inline void vroniObject::ResetLoopStackMin(int size)
{
min_loop_stack = size;
}
inline void vroniObject::ResetLoopStack()
{
num_loop_stack = 0;
min_loop_stack = 0;
}
inline void vroniObject::GetLoopStackSize(int& size)
{
size = num_loop_stack;
}
inline void vroniObject::GetLoopStackMin(int& size)
{
size = min_loop_stack;
}
inline int vroniObject::GetLoopStackSizeFunc(void)
{
return num_loop_stack;
}
inline int vroniObject::GetLoopStackMinFunc(void)
{
return min_loop_stack;
}
inline int vroniObject::GetLoopStackElementFunc(int I)
{
assert(I < num_loop_stack);
assert(I >= 0);
return loop_stack[I];
}
#define GetLoopStackElement(I, E) \
{\
assert(I < num_loop_stack); \
assert(I >= 0); \
E = loop_stack[I]; \
}
#define PushOntoLoopStack(E) \
{\
if (num_loop_stack >= max_num_loop_stack) { \
max_num_loop_stack += DATA_BLOCK_SIZE; \
loop_stack = (int*) ReallocateArray(loop_stack, max_num_loop_stack, \
sizeof(int), "voronoi:loop_stack"); \
} \
loop_stack[num_loop_stack] = E; \
++num_loop_stack; \
}
#define DeleteFromLoopStack \
{\
assert(num_loop_stack > 0); \
--num_loop_stack; \
}\
#ifdef TRACE
#define IncreaseThreshold(zero) \
{\
++threshold_counter; \
if (zero < 0.0) { \
zero = 0.0; \
} \
else if (zero == 0.0) { \
zero = TINY; \
} \
else { \
zero *= 10.0; \
} \
}
#else
#define IncreaseThreshold(zero) \
{\
if (zero < 0.0) { \
zero = 0.0; \
} \
else if (zero == 0.0) { \
zero = TINY; \
} \
else { \
zero *= 10.0; \
} \
}
#endif
#define SetThreshold(zero, epsilon) \
{\
zero = epsilon; \
}
#define ResetPreserveBuffer \
{\
num_preserve = 0; \
}
#define AddToPreserveBuffer(S, T) \
{\
if (num_preserve >= max_num_preserve) { \
max_num_preserve += DATA_BLOCK_SIZE; \
preserve = (preserve_buffer*) ReallocateArray(preserve, \
max_num_preserve, \
sizeof(preserve_buffer), \
"voronoi:preserve"); \
} \
preserve[num_preserve].site = S; \
preserve[num_preserve].type = T; \
++num_preserve; \
}
#define AddSiteVisited(I, T) \
{\
if (num_visited >= max_num_visited) { \
max_num_visited += DATA_BLOCK_SIZE; \
sites_visited = (s_visited*) ReallocateArray(sites_visited, \
max_num_visited, \
sizeof(s_visited), \
"voronoi:sites_visited"); \
}\
sites_visited[num_visited].ind = I; \
sites_visited[num_visited].type = T; \
++num_visited; \
}
#define AddPntVisited(I) \
{\
if (num_pnt_visited >= max_num_pnt_visited) { \
max_num_pnt_visited += DATA_BLOCK_SIZE; \
pnt_visited = (int*) ReallocateArray(pnt_visited, \
max_num_pnt_visited, \
sizeof(int), \
"voronoi:pnt_visited"); \
}\
pnt_visited[num_pnt_visited] = I; \
++num_pnt_visited; \
}
#define ResetPntVisited(I) \
{\
for (I = 0; I < num_pnt_visited; ++I) { \
SetPntVisited(pnt_visited[I], false); \
} \
num_pnt_visited = 0; \
}
#define AddNodeChecked(I) \
{\
if (num_checked >= max_num_checked) { \
max_num_checked += DATA_BLOCK_SIZE; \
nodes_checked = (int*) ReallocateArray(nodes_checked, \
max_num_checked, \
sizeof(int), \
"voronoi:nodes_checked"); \
}\
nodes_checked[num_checked] = I; \
++num_checked; \
}
#define ResetNodeChecked(I) \
{\
for (I = 0; I < num_checked; ++I) { \
MarkNodeUnchecked(nodes_checked[I]); \
} \
num_checked = 0; \
}
#define InsertSiteNode(E, P, N, I) \
{ \
N = StoreNode(P.x, P.y, 0.0); \
InsertDummyNode(E, N, false); \
MarkNodeUnchecked(N); \
SetNodeSite(N, I); \
SetPntNode(I, N); \
SetVDPtr(I, PNT, E); \
SetIncidentSite(I, true); \
}
#ifdef TRACE
inline unsigned long vroniObject::GetThresholdCounter(void)
{
return threshold_counter;
}
#endif
inline void vroniObject::SetDebugFlagVD(vr_bool dbg_flag)
{
debug_flag_VD = dbg_flag;
return;
}
/** Get first vertex of given site of given type */
inline int vroniObject::Get1stVtx(int site, int type)
{
if (type == SEG) {
assert(InSegsList(site));
return segs[site].i1;
} else if (type == ARC) {
assert(InArcsList(site));
return arcs[site].i1;
} else {
assert(false);
return NIL;
}
}
/** Get second vertex of given site of given type */
inline int vroniObject::Get2ndVtx(int site, int type)
{
if (type == SEG) {
assert(InSegsList(site));
return segs[site].i2;
} else if (type == ARC) {
assert(InArcsList(site));
return arcs[site].i2;
} else {
assert(false);
return NIL;
}
}
/** Get first vertex of given segment */
inline int vroniObject::Get1stVtxSeg(int site)
{
assert(InSegsList(site));
return segs[site].i1;
}
/** Get second vertex of given segment */
inline int vroniObject::Get2ndVtxSeg(int site)
{
assert(InSegsList(site));
return segs[site].i2;
}
/** Get first vertex of given arc */
inline int vroniObject::Get1stVtxArc(int site)
{
assert(InArcsList(site));
return arcs[site].i1;
}
/** Get second vertex of given arc */
inline int vroniObject::Get2ndVtxArc(int site)
{
assert(InArcsList(site));
return arcs[site].i2;
}
/** Set first vertex of site of given type to pnt */
inline void vroniObject::Set1stVtx(int site, int type, int pnt)
{
if (type == SEG) {
assert(InSegsList(site));
segs[site].i1 = pnt;
} else if (type == ARC) {
assert(InArcsList(site));
arcs[site].i1 = pnt;
} else
assert(false);
}
/** Set second vertex of site of given type to pnt */
inline void vroniObject::Set2ndVtx(int site, int type, int pnt)
{
if (type == SEG) {
assert(InSegsList(site));
segs[site].i2 = pnt;
} else if (type == ARC) {
assert(InArcsList(site));
arcs[site].i2 = pnt;
} else
assert(false);
}
/** Set first vertex of given segment */
inline void vroniObject::Set1stVtxSeg(int site, int pnt)
{
assert(InSegsList(site));
segs[site].i1 = pnt;
}
/** Set second vertex of given segment */
inline void vroniObject::Set2ndVtxSeg(int site, int pnt)
{
assert(InSegsList(site));
segs[site].i2 = pnt;
}
/** Set first vertex of given arc */
inline void vroniObject::Set1stVtxArc(int site, int pnt)
{
assert(InArcsList(site));
arcs[site].i1 = pnt;
}
/** Set second vertex of given arc */
inline void vroniObject::Set2ndVtxArc(int site, int pnt)
{
assert(InArcsList(site));
arcs[site].i2 = pnt;
}
/** Check whether point has been visited */
inline vr_bool vroniObject::IsPntVisited(int site)
{
assert(InPntsList(site));
return pnts[site].vis;
}
/** Set whether point has been visited */
inline void vroniObject::SetPntVisited(int site, vr_bool vis)
{
assert(InPntsList(site));
pnts[site].vis = vis;
}
/** Check if pnt is start point of seg */
inline vr_bool vroniObject::IsSegStartPnt(int seg, int pnt)
{
assert(InSegsList(seg));
return segs[seg].i1 == pnt;
}
/** Check if pnt is send point of seg */
inline vr_bool vroniObject::IsSegEndPnt(int seg, int pnt)
{
assert(InSegsList(seg));
return segs[seg].i2 == pnt;
}
/** Get coordinates of input point */
inline coord vroniObject::GetPntCoords(int pnt)
{
assert(InPntsList(pnt));
return pnts[pnt].p;
}
/** Set x-coordinate of point */
inline void vroniObject::SetXCoord(int pnt, double_arg x)
{
assert(InPntsList(pnt));
pnts[pnt].p.x = x;
}
/** Set y-coordinate of point */
inline void vroniObject::SetYCoord(int pnt, double_arg y)
{
assert(InPntsList(pnt));
pnts[pnt].p.y = y;
}
/** Get start point coordinates of seg */
inline coord vroniObject::GetSegStartCoord(int seg)
{
assert(InSegsList(seg));
return pnts[segs[seg].i1].p;
}
/** Get end point coordinates of seg */
inline coord vroniObject::GetSegEndCoord(int seg)
{
assert(InSegsList(seg));
return pnts[segs[seg].i2].p;
}
/** Get start point coordinates of arc */
inline coord vroniObject::GetArcStartCoord(int arc)
{
assert(InArcsList(arc));
return pnts[arcs[arc].i1].p;
}
/** Get end point coordinates of arc */
inline coord vroniObject::GetArcEndCoord(int arc)
{
assert(InArcsList(arc));
return pnts[arcs[arc].i2].p;
}
/** Get center point of arc a */
inline coord vroniObject::GetArcCenter(int a)
{
assert(InArcsList(a));
return arcs[a].c;
}
/** Get radius of arc a */
inline double vroniObject::GetArcRadius(int a)
{
assert(InArcsList(a));
return arcs[a].r;
}
/** Check whether p is start point of a */
inline vr_bool vroniObject::IsArcStartPnt(int a, int p)
{
assert(InArcsList(a));
return (arcs[a].i1 == p);
}
/** Check whether p is end point of a */
inline vr_bool vroniObject::IsArcEndPnt(int a, int p)
{
assert(InArcsList(a));
return (arcs[a].i2 == p);
}
/** Get original orientation of arc a
* Attention: within VRONI all arcs are oriented CCW! */
inline vr_bool vroniObject::GetArcOrientation(int a)
{
assert(InArcsList(a));
return arcs[a].ccw;
}
/** Set radius of arc a */
inline void vroniObject::SetArcRadius(int a, double_arg r)
{
assert(InArcsList(a));
arcs[a].r = r;
}
/** Set center of arc a */
inline void vroniObject::SetArcCenter(int a, coord p)
{
assert(InArcsList(a));
arcs[a].c = p;
}
/** Set orientation of arc a */
inline void vroniObject::SetArcOrientation(int a, vr_bool ccw)
{
assert(InArcsList(a));
arcs[a].ccw = ccw;
}
/** Set normal vector of start point of arc a */
inline void vroniObject::SetArcStartNormal(int a, coord ns)
{
assert(InArcsList(a));
arcs[a].ns = ns;
}
/** Set normal vector of end point of arc a */
inline void vroniObject::SetArcEndNormal(int a, coord ne)
{
assert(InArcsList(a));
arcs[a].ne = ne;
}
/** Get normal vector of start point of arc a */
inline coord vroniObject::GetArcStartNormal(int a)
{
assert(InArcsList(a));
return arcs[a].ns;
}
/** Get normal vector of end point of arc a */
inline coord vroniObject::GetArcEndNormal(int a)
{
assert(InArcsList(a));
return arcs[a].ne;
}
/** Set chord equation coefficients of arc s to a, b, d */
inline void vroniObject::SetChordEqnData(int s, double_arg a, double_arg b, double_arg d)
{
assert(InArcsList(s));
arcs[s].a = a;
arcs[s].b = b;
arcs[s].d = d;
}
/** Get chord equation coefficients of arc s */
inline void vroniObject::GetChordEqnData(int s, double* a, double* b, double* d)
{
assert(InArcsList(s));
*a = arcs[s].a;
*b = arcs[s].b;
*d = arcs[s].d;
}
/** Set equation data of segment s */
inline void vroniObject::SetSegEqnData(int s, double_arg a, double_arg b, double_arg c)
{
assert(InSegsList(s));
segs[s].a = a;
segs[s].b = b;
segs[s].c = c;
}
/** Get equation data of segment s */
inline void vroniObject::GetSegEqnData(int s, double* a, double* b, double* c)
{
assert(InSegsList(s));
*a = segs[s].a;
*b = segs[s].b;
*c = segs[s].c;
}
/** Get normal vector of seg s */
inline coord vroniObject::GetSegNormal(int s)
{
assert(InSegsList(s));
return MakeVec(segs[s].a, segs[s].b);
}
/** Get unit vector from start point to end point of seg s */
inline coord vroniObject::GetSegDirection(int s)
{
assert(InSegsList(s));
return VecCW(GetSegNormal(s));
}
/** Get length of segment s*/
inline double vroniObject::GetSegLgth(int s)
{
assert(InSegsList(s));
return segs[s].lgth;
}
/** Set length of segment s */
inline void vroniObject::SetSegLgth(int s, double_arg l)
{
assert(InSegsList(s));
segs[s].lgth = l;
}
/** Check whether point p has incident site */
inline vr_bool vroniObject::HasIncidentSite(int p)
{
assert(InPntsList(p));
return pnts[p].s;
}
/** set incident site of point p */
inline void vroniObject::SetIncidentSite(int p, int status)
{
assert(InPntsList(p));
pnts[p].s = (status != 0);
}
/** Check whether point p is to be deleted */
inline vr_bool vroniObject::IsDeletedPnt(int p)
{
assert(InPntsList(p));
return pnts[p].del;
}
/** Set whether point p is to be deleted */
inline void vroniObject::SetDeletedPnt(int p, vr_bool del)
{
assert(InPntsList(p));
pnts[p].del = del;
if (del) {
pnts_deleted = true;
#ifdef GRAPHICS
pnts[p].draw = false;
#endif
}
}
/** Get node of point p */
inline int vroniObject::GetPntNode(int p)
{
assert(InPntsList(p));
return pnts[p].node;
}
/** Set node of point p */
inline void vroniObject::SetPntNode(int p, int n)
{
assert(InPntsList(p));
assert(InNodesList(n));
pnts[p].node = n;
}
/** Set vd-pointer of point p */
inline void vroniObject::SetPntVDPtr(int p, int e)
{
assert(InPntsList(p));
pnts[p].vd = e;
}
/** Get vd-pointer of point p */
inline int vroniObject::GetPntVDPtr(int p)
{
assert(InPntsList(p));
return pnts[p].vd;
}
/** Reset vd-pointer of point p */
inline void vroniObject::ResetPntVDPtr(int p)
{
assert(InPntsList(p));
pnts[p].vd = NIL;
}
/** Reset vd-pointer of segment s */
inline void vroniObject::ResetSegVDPtr(int s)
{
assert(InSegsList(s));
segs[s].vd = NIL;
}
/** Set vd-pointer of site s of type t to e */
inline void vroniObject::SetVDPtr(int s, int t, int e)
{
assert(InEdgesList(e));
if (t == PNT) {
assert(InPntsList(s));
pnts[s].vd = e;
} else if (t == SEG) {
assert(InSegsList(s));
segs[s].vd = e;
} else if (t == ARC) {
assert(InArcsList(s));
arcs[s].vd = e;
} else {
#ifdef VRONI_WARN
printf("\nwarning in SetVDPtr() - unknown site type %d\n", t);
#endif
assert(false);
}
}
/** Get vd-pointer of site s of type t */
inline int vroniObject::GetVDPtr(int s, int t)
{
if (t == PNT) {
assert(InPntsList(s));
return pnts[s].vd;
} else if (t == SEG) {
assert(InSegsList(s));
return segs[s].vd;
} else if (t == ARC) {
assert(InArcsList(s));
return arcs[s].vd;
} else {
#ifdef VRONI_WARN
printf("\nwarning in GetVDPtr() - unknown site type %d\n", t);
#endif
assert(false);
return NIL;
}
}
/** Set start node of edge e to n */
inline void vroniObject::SetStartNode(int e, int n)
{
assert(InEdgesList(e));
assert(InNodesList(n));
edges[e].n1 = n;
}
/** Set end node of edge e to n */
inline void vroniObject::SetEndNode(int e, int n)
{
assert(InEdgesList(e));
assert(InNodesList(n));
edges[e].n2 = n;
}
/** Get start node of edge e */
inline int vroniObject::GetStartNode(int e)
{
assert(InEdgesList(e));
return edges[e].n1;
}
/** Get end node of edge e */
inline int vroniObject::GetEndNode(int e)
{
assert(InEdgesList(e));
return edges[e].n2;
}
/** Ist n the start node of edge e? */
inline vr_bool vroniObject::IsStartNode(int e, int n)
{
assert(InEdgesList(e));
return (edges[e].n1 == n);
}
/** Ist n the end node of edge e? */
inline vr_bool vroniObject::IsEndNode(int e, int n)
{
assert(InEdgesList(e));
return (edges[e].n2 == n);
}
/** Is edge e incident to node n? */
inline vr_bool vroniObject::IsEdgeIncident(int e, int n)
{
assert(InEdgesList(e));
assert(InNodesList(n));
return edges[e].n1 == n || edges[e].n2 == n;
}
/** Get the opposite node to n at edge e */
inline int vroniObject::GetOtherNode(int e, int n)
{
assert(IsEdgeIncident(e, n));
return (edges[e].n1 == n) ? edges[e].n2 : edges[e].n1;
}
/** Get site and type left to edge e */
inline void vroniObject::GetLftSiteData(int e, int* s, t_site* t)
{
assert(InEdgesList(e));
*s = edges[e].lft;
*t = edges[e].ltype;
}
/** Get site and type right to edge e */
inline void vroniObject::GetRgtSiteData(int e, int* s, t_site* t)
{
assert(InEdgesList(e));
*s = edges[e].rgt;
*t = edges[e].rtype;
}
/** Get type of site left to edge e */
inline t_site vroniObject::GetLftSiteType(int e)
{
assert(InEdgesList(e));
return edges[e].ltype;
}
/** Get type of site right to edge e */
inline t_site vroniObject::GetRgtSiteType(int e)
{
assert(InEdgesList(e));
return edges[e].rtype;
}
/** Get site left to edge e */
inline int vroniObject::GetLftSite(int e)
{
assert(InEdgesList(e));
return edges[e].lft;
}
/** Get site right to edge e */
inline int vroniObject::GetRgtSite(int e)
{
assert(InEdgesList(e));
return edges[e].rgt;
}
/** Given an edge e and a defining site s1 of type t1.
* Retrieve opposite site s2 and its type t2. */
inline void vroniObject::GetOtherSiteData(int e, int s1, t_site t1,
int* s2, t_site* t2)
{
assert(InEdgesList(e));
if ((edges[e].lft == s1) && (edges[e].ltype == t1)) {
*s2 = edges[e].rgt;
*t2 = edges[e].rtype;
} else {
assert((edges[e].rgt == s1) && (edges[e].rtype == t1));
*s2 = edges[e].lft;
*t2 = edges[e].ltype;
}
}
/** Is node n a degree-2 node? */
inline vr_bool vroniObject::IsDeg2Node(int n)
{
assert(InNodesList(n));
return nodes[n].deg2;
}
/** Set is-degree-2 flag of node n */
inline void vroniObject::SetNodeDegree(int n, vr_bool f)
{
assert(InNodesList(n));
nodes[n].deg2 = f;
}
/** If site s of type t the left site of edge e? */
inline vr_bool vroniObject::IsLftSite(int e, int s, t_site t)
{
assert(InEdgesList(e));
return edges[e].lft == s && edges[e].ltype == t;
}
/** If site s of type t the right site of edge e? */
inline vr_bool vroniObject::IsRgtSite(int e, int s, t_site t)
{
assert(InEdgesList(e));
return edges[e].rgt == s && edges[e].rtype == t;
}
/** Is site s of type t a left or right site of edge e? */
inline vr_bool vroniObject::IsLftRgtSite(int e, int s, t_site t)
{
return IsLftSite(e, s, t) || IsRgtSite(e, s, t);
}
/** Is left site of edge e the point s?
* Attention: We do not check for site type! */
inline vr_bool vroniObject::IsLftPnt(int e, int s)
{
assert(InEdgesList(e));
return edges[e].lft == s;
}
/** Is right site of edge e the point s?
* Attention: We do not check for site type! */
inline vr_bool vroniObject::IsRgtPnt(int e, int s)
{
assert(InEdgesList(e));
return edges[e].rgt == s;
}
/** Get CCW edge of edge e at node n */
inline int vroniObject::GetCCWEdge(int e, int n)
{
assert(IsEdgeIncident(e, n));
return edges[e].n1 == n ? edges[e].s_ccw : edges[e].e_ccw;
}
/** Get CW edge of edge e at node n */
inline int vroniObject::GetCWEdge(int e, int n)
{
assert(IsEdgeIncident(e, n));
return edges[e].n1 == n ? edges[e].s_cw : edges[e].e_cw;
}
/** Set CCW edge of edge e at node n to e1 */
inline void vroniObject::SetCCWEdge(int e, int n, int e1)
{
assert(IsEdgeIncident(e, n));
if (edges[e].n1 == n)
edges[e].s_ccw = e1;
else
edges[e].e_ccw = e1;
}
/** Set CW edge of edge e at node n to e1 */
inline void vroniObject::SetCWEdge(int e, int n, int e1)
{
assert(IsEdgeIncident(e, n));
if (edges[e].n1 == n)
edges[e].s_cw = e1;
else
edges[e].e_cw = e1;
}
/** Reset CW edge of edge e at node n to e1 */
inline void vroniObject::ResetCWEdge(int e, int n)
{
SetCWEdge(e, n, NIL);
}
/** Reset CCW edge of edge e at node n to e1 */
inline void vroniObject::ResetCCWEdge(int e, int n)
{
SetCCWEdge(e, n, NIL);
}
/** Get status of node n */
inline n_status vroniObject::GetNodeStatus(int n)
{
assert(InNodesList(n));
return nodes[n].status;
}
/** Set status of node n to s */
inline void vroniObject::SetNodeStatus(int n, n_status s)
{
assert(InNodesList(n));
nodes[n].status = s;
}
/** Mark node n as deleted */
inline void vroniObject::MarkNodeDeleted(int n)
{
SetNodeStatus(n, DELETED);
}
/** Mark node n as visited */
inline void vroniObject::MarkNodeVisited(int n)
{
SetNodeStatus(n, VISITED);
}
/** Mark node n as unchecked */
inline void vroniObject::MarkNodeUnchecked(int n)
{
SetNodeStatus(n, UNCHECKED);
}
/** Mark node n as checked */
inline void vroniObject::MarkNodeChecked(int n)
{
SetNodeStatus(n, CHECKED);
}
/** Mark node n as dummy */
inline void vroniObject::MarkNodeDummy(int n)
{
SetNodeStatus(n, DUMMY);
}
/** Is node n marked as deleted? */
inline vr_bool vroniObject::IsNodeDeleted(int n)
{
return GetNodeStatus(n) == DELETED;
}
/** Is node n marked as visited? */
inline vr_bool vroniObject::IsNodeVisited(int n)
{
return GetNodeStatus(n) == VISITED;
}
/** Is node n marked as checked? */
inline vr_bool vroniObject::IsNodeChecked(int n)
{
return GetNodeStatus(n) == CHECKED;
}
/** Is node n marked as unchecked? */
inline vr_bool vroniObject::IsNodeUnchecked(int n)
{
return GetNodeStatus(n) == UNCHECKED;
}
/** Is node n marked as dummy? */
inline vr_bool vroniObject::IsNodeDummy(int n)
{
return GetNodeStatus(n) == DUMMY;
}
/** Mark edge e as deleted */
inline void vroniObject::MarkEdgeDeleted(int e)
{
assert(InEdgesList(e));
edges[e].del = true;
}
/** Is edge e marked as deleted? */
inline vr_bool vroniObject::IsEdgeDeleted(int e)
{
assert(InEdgesList(e));
return edges[e].del;
}
/** Is this edge not marked as deleted and has non-NIL left and right sites? */
inline vr_bool vroniObject::IsEdgeActive(int e)
{
assert(InEdgesList(e));
return !IsEdgeDeleted(e) && edges[e].lft != NIL && edges[e].rgt != NIL;
}
/** Is this edge e a genuine edge? That is, edge e is active (IsEdgeActive) and
* if left or right sites are points, then the indices of the points are
* greater (resp. less) than minidx (resp. maxidx) */
inline vr_bool vroniObject::IsEdgeGenuine(int e, int minidx, int maxidx)
{
assert(InEdgesList(e));
if (!IsEdgeActive(e))
return false;
if (GetLftSiteType(e) == PNT)
if (GetLftSite(e) <= minidx || GetLftSite(e) >= maxidx)
return false;
if (GetRgtSiteType(e) == PNT)
if (GetRgtSite(e) <= minidx || GetRgtSite(e) >= maxidx)
return false;
return true;
}
/** Get coordinates of node n */
inline coord vroniObject::GetNodeCoord(int n)
{
assert(InNodesList(n));
return nodes[n].p;
}
/** Get parameter (clearance [squared]) of node n */
inline double vroniObject::GetNodeParam(int n)
{
assert(InNodesList(n));
return nodes[n].r2;
}
/** Get coordinate and parameter of node n */
inline void vroniObject::GetNodeData(int n, coord* p, double* r)
{
*p = GetNodeCoord(n);
*r = GetNodeParam(n);
}
/** Get parameter of start and end node of edge e */
inline void vroniObject::GetEdgeParam(int e, double* rs, double *re)
{
*rs = GetNodeParam(GetStartNode(e));
*re = GetNodeParam(GetEndNode(e));
}
/** Get an edge incident to node n */
inline int vroniObject::GetIncidentEdge(int n)
{
assert(InNodesList(n));
return nodes[n].edge;
}
/** Set the edge-pointer of node n to e */
inline void vroniObject::SetIncidentEdge(int n, int e)
{
assert(InNodesList(n));
assert(InEdgesList(e));
nodes[n].edge = e;
}
/** Get a site where node n belongs to */
inline int vroniObject::GetNodeSite(int n)
{
assert(InNodesList(n));
return nodes[n].site;
}
/** Set site-pointer of node n to s */
inline void vroniObject::SetNodeSite(int n, int s)
{
assert(InNodesList(n));
assert(InPntsList(s));
nodes[n].site = s;
}
#endif