739088af9f
- aggiornamento versione.
272 lines
6.2 KiB
C++
272 lines
6.2 KiB
C++
/*****************************************************************************/
|
|
/* */
|
|
/* Copyright (C) 2010-2025 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 */
|
|
/* */
|
|
/*****************************************************************************/
|
|
/* */
|
|
/* get standard libraries */
|
|
/* */
|
|
#include <stdlib.h>
|
|
#include <assert.h>
|
|
|
|
/* */
|
|
/* get my header files */
|
|
/* */
|
|
#include "vroni_object.h"
|
|
|
|
|
|
|
|
/** Update node n of edge e to node n0 */
|
|
void vroniObject::UpdateNodeEdgeData(int e, int n, int n0)
|
|
{
|
|
assert(IsEdgeIncident(e, n));
|
|
|
|
if (GetStartNode(e) == n)
|
|
SetStartNode(e, n0);
|
|
else
|
|
SetEndNode(e, n0);
|
|
|
|
SetCCWEdge(e, n0, NIL);
|
|
SetCWEdge(e, n0, NIL);
|
|
SetIncidentEdge(n0, e);
|
|
}
|
|
|
|
|
|
/** Consider edges and nodes e1-n1-e0-n2-e2 in CW order. Set cw and ccw
|
|
* pointers of e0 to e1, e2, GetCWEdge(e1,n1), GetCCWEdge(e2,n2) and vice
|
|
* versa. */
|
|
void vroniObject::CloseVoronoiCell(int e1, int e0, int e2, int n1, int n2)
|
|
{
|
|
int e;
|
|
|
|
SetCCWEdge(e1, n1, e0);
|
|
SetCWEdge(e0, n1, e1);
|
|
SetCWEdge(e2, n2, e0);
|
|
SetCCWEdge(e0, n2, e2);
|
|
e = GetCWEdge(e1, n1);
|
|
if (e != NIL) {
|
|
SetCWEdge(e, n1, e0);
|
|
SetCCWEdge(e0, n1, e);
|
|
}
|
|
e = GetCCWEdge(e2, n2);
|
|
if (e != NIL) {
|
|
SetCCWEdge(e, n2, e0);
|
|
SetCWEdge(e0, n2, e);
|
|
}
|
|
}
|
|
|
|
|
|
/** Copy segment s1 to segment s */
|
|
void vroniObject::CopySegData(int s, int s1)
|
|
{
|
|
assert(InSegsList(s));
|
|
assert(InSegsList(s1));
|
|
segs[s] = segs[s1];
|
|
}
|
|
|
|
|
|
/** Copy arc s1 to arc s */
|
|
void vroniObject::CopyArcData(int s, int s1)
|
|
{
|
|
assert(InArcsList(s));
|
|
assert(InArcsList(s1));
|
|
arcs[s] = arcs[s1];
|
|
}
|
|
|
|
#ifdef WRITE_VD
|
|
void vroniObject::SetVDEdge(int s, int t, int e)
|
|
{
|
|
if (t == PNT) {
|
|
assert(InPntsList(s));
|
|
pnts[s].vd_edge = e;
|
|
} else if (t == SEG) {
|
|
assert(InSegsList(s));
|
|
segs[s].vd_edge = e;
|
|
} else {
|
|
#ifdef VRONI_WARN
|
|
printf("\nwarning in SetVDEdge() - unknown site type %d\n", t);
|
|
#endif
|
|
assert(false);
|
|
}
|
|
}
|
|
|
|
int vroniObject::GetVDEdge(int s, int t)
|
|
{
|
|
if (t == PNT) {
|
|
assert(InPntsList(s));
|
|
return pnts[s].vd_edge;
|
|
} else if (t == SEG) {
|
|
assert(InSegsList(s));
|
|
return segs[s].vd_edge;
|
|
} else {
|
|
#ifdef VRONI_WARN
|
|
printf("\nwarning in GetVDEdge() - unknown site type %d\n", t);
|
|
#endif
|
|
assert(false);
|
|
return NIL;
|
|
}
|
|
}
|
|
|
|
void vroniObject::SetPntIndex(int i, int n)
|
|
{
|
|
assert(InPntsList(i));
|
|
pnts[i].idx = n;
|
|
}
|
|
|
|
|
|
int vroniObject::GetPntIndex(int i)
|
|
{
|
|
assert(InPntsList(i));
|
|
return pnts[i].idx;
|
|
}
|
|
|
|
void vroniObject::SetNodeIndex(int i, int n)
|
|
{
|
|
assert(InNodesList(i));
|
|
nodes[i].idx = n;
|
|
}
|
|
|
|
int vroniObject::GetNodeIndex(int i)
|
|
{
|
|
assert(InNodesList(i));
|
|
return nodes[i].idx;
|
|
}
|
|
#endif
|
|
|
|
#ifdef ORDERED
|
|
|
|
/** Set key of site s of type t to n */
|
|
void vroniObject::SetSiteNumber(int s, t_site t, int n)
|
|
{
|
|
if (t == PNT) {
|
|
assert(InPntsList(s));
|
|
pnts[s].key = n;
|
|
} else if (t == SEG) {
|
|
assert(InSegsList(s));
|
|
segs[s].key = n;
|
|
} else if (t == ARC) {
|
|
assert(InArcsList(s));
|
|
arcs[s].key = n;
|
|
} else
|
|
assert(false);
|
|
}
|
|
|
|
/** Get key of site s of type n */
|
|
int vroniObject::GetSiteNumber(int s, t_site t)
|
|
{
|
|
if (t == PNT) {
|
|
assert(InPntsList(s));
|
|
return pnts[s].key;
|
|
} else if (t == SEG) {
|
|
assert(InSegsList(s));
|
|
return segs[s].key;
|
|
} else if (t == ARC) {
|
|
assert(InArcsList(s));
|
|
return arcs[s].key;
|
|
} else
|
|
assert(false);
|
|
return NIL;
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef EXT_APPL_VD
|
|
|
|
|
|
ean_type vroniObject::GetExtApplNode(int n)
|
|
{
|
|
assert(InNodesList(n));
|
|
return nodes[n].ext_appl;
|
|
}
|
|
|
|
void vroniObject::SetExtApplNode(int n, ean_type t)
|
|
{
|
|
assert(InNodesList(n));
|
|
nodes[n].ext_appl = t;
|
|
}
|
|
|
|
|
|
eae_type vroniObject::GetExtApplEdge(int e)
|
|
{
|
|
assert(InEdgesList(e));
|
|
return edges[e].ext_appl;
|
|
}
|
|
|
|
void vroniObject::SetExtApplEdge(int e, eae_type t)
|
|
{
|
|
assert(InEdgesList(e));
|
|
edges[e].ext_appl = t;
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef EXT_APPL_PNTS
|
|
|
|
eap_type vroniObject::GetExtApplPnt(int p)
|
|
{
|
|
assert(InPntsList(p));
|
|
return pnts[p].ext_appl;
|
|
}
|
|
|
|
void vroniObject::SetExtApplPnt(int p, eap_type t)
|
|
{
|
|
assert(InPntsList(p));
|
|
pnts[p].ext_appl = t;
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
#ifdef EXT_APPL_SITES
|
|
|
|
eas_type vroniObject::GetExtApplSeg(int s)
|
|
{
|
|
assert(InSegsList(s));
|
|
return segs[s].ext_appl;
|
|
}
|
|
|
|
void vroniObject::SetExtApplSeg(int s, eas_type t)
|
|
{
|
|
assert(InSegsList(s));
|
|
segs[s].ext_appl = t;
|
|
}
|
|
|
|
eas_type vroniObject::GetExtApplArc(int s)
|
|
{
|
|
assert(InArcsList(s));
|
|
return arcs[s].ext_appl;
|
|
}
|
|
|
|
void vroniObject::SetExtApplArc(int s, eas_type t)
|
|
{
|
|
assert(InArcsList(s));
|
|
arcs[s].ext_appl = t;
|
|
}
|
|
|
|
#endif
|
|
|