From 5ab8802e08a788e42ef3d2202337758969022239 Mon Sep 17 00:00:00 2001 From: Dwight Perry Date: Tue, 22 Nov 2011 13:17:50 -0500 Subject: [PATCH] xlable library edit --- lib/gvc.def | 3 ++- lib/gvc.vcproj | 8 ++++++-- lib/label/index.c | 19 +++++-------------- lib/label/node.c | 7 ++++--- lib/label/nrtmain.c | 11 +++++++++-- lib/label/rectangle.c | 22 ++++------------------ lib/label/rectangle.h | 2 +- lib/label/split.q.c | 9 +++------ lib/label/split.q.h | 2 +- lib/label/xlabels.c | 29 +++++------------------------ 10 files changed, 40 insertions(+), 72 deletions(-) diff --git a/lib/gvc.def b/lib/gvc.def index cdb6acedd..4b44e7444 100644 --- a/lib/gvc.def +++ b/lib/gvc.def @@ -154,7 +154,8 @@ gvusershape_file_release gvwrite htmlEntityUTF8 HTTPServerEnVar -Initial_dist +Initial_dist +EdgeLabelsDone initMapData inPS insertPM diff --git a/lib/gvc.vcproj b/lib/gvc.vcproj index da049e17f..c73d164d7 100644 --- a/lib/gvc.vcproj +++ b/lib/gvc.vcproj @@ -40,7 +40,7 @@ + + diff --git a/lib/label/index.c b/lib/label/index.c index d3b673265..ceefc6c0e 100644 --- a/lib/label/index.c +++ b/lib/label/index.c @@ -22,10 +22,8 @@ LeafList_t *RTreeNewLeafList(Leaf_t * lp) { LeafList_t *llp; - if ((llp = NEW(LeafList_t))) { + if ((llp = NEW(LeafList_t))) llp->leaf = lp; - llp->next = 0; - } return llp; } @@ -48,7 +46,6 @@ void RTreeLeafListFree(LeafList_t * llp) free(llp); llp = tlp; } - free(llp); return; } @@ -121,13 +118,9 @@ static int RTreeClose2(RTree_t * rtp, Node_t * n) for (i = 0; i < NODECARD; i++) { if (!n->branch[i].child) continue; - // free(n->branch[i].child); DisconBranch(n, i); rtp->EntryCount--; - if (rtp->StatFlag) - rtp->ElimCount++; } - //free(n); } return 0; } @@ -136,7 +129,6 @@ static int RTreeClose2(RTree_t * rtp, Node_t * n) int RTreeClose(RTree_t * rtp) { RTreeClose2(rtp, rtp->root); - free(rtp->root); free(rtp); return 0; } @@ -239,7 +231,7 @@ RTreeInsert(RTree_t * rtp, Rect_t * r, void *data, Node_t ** n, int level) /* RTreeInsert(RTree_t*rtp, Rect_t*r, int data, Node_t**n, int level) { */ register int i; register Node_t *newroot; - Node_t *newnode=0; + Node_t *newnode; Branch_t b; int result = 0; @@ -280,7 +272,6 @@ RTreeInsert(RTree_t * rtp, Rect_t * r, void *data, Node_t ** n, int level) b.child = newnode; AddBranch(rtp, &b, newroot, NULL); *n = newroot; - // rtp->root = newroot; rtp->EntryCount += 2; result = 1; } @@ -304,9 +295,9 @@ RTreeInsert2(RTree_t * rtp, Rect_t * r, void *data, /* RTreeInsert2(RTree_t*rtp, Rect_t*r, int data, Node_t*n, Node_t**new, int level) { */ - register int i=0; + register int i; Branch_t b; - Node_t *n2=0; + Node_t *n2; assert(r && n && new); assert(level >= 0 && level <= n->level); @@ -475,7 +466,7 @@ RTreeDelete2(RTree_t * rtp, Rect_t * r, void *data, Node_t * n, */ struct ListNode *NewListNode() { - return (struct ListNode *) NEW(sizeof(struct ListNode)); + return (struct ListNode *) malloc(sizeof(struct ListNode)); } #endif diff --git a/lib/label/node.c b/lib/label/node.c index 0285ca03b..4af16361c 100644 --- a/lib/label/node.c +++ b/lib/label/node.c @@ -119,11 +119,12 @@ Rect_t NodeCover(Node_t * n) */ int PickBranch(Rect_t * r, Node_t * n) { - register Rect_t *rr=0; - register int i=0, flag=1, increase=0, bestIncr=0, area=0, bestArea=0; - int best=0; + register Rect_t *rr; + register int i, flag, increase, bestIncr, area, bestArea; + int best; assert(r && n); + flag = 1; for (i = 0; i < NODECARD; i++) { if (n->branch[i].child) { Rect_t rect; diff --git a/lib/label/nrtmain.c b/lib/label/nrtmain.c index 40f43ab65..d2f827218 100644 --- a/lib/label/nrtmain.c +++ b/lib/label/nrtmain.c @@ -12,12 +12,19 @@ #include #include -#include +//#include #include #include #include "xlabels.h" +#ifdef HAVE_GETOPT_H +#include +#else +#include "compat_getopt.h" +#endif + + #if 0 #define POINTS_PER_INCH 72 #define N_NEW(n,t) (t*)calloc((n),sizeof(t)) @@ -31,7 +38,7 @@ static char *progname; static int Verbose; extern pointf edgeMidpoint(graph_t * g, edge_t * e); -static inline pointf pointfof(double x, double y) +static pointf pointfof(double x, double y) { pointf r; diff --git a/lib/label/rectangle.c b/lib/label/rectangle.c index 94b06cc6a..8413f0481 100644 --- a/lib/label/rectangle.c +++ b/lib/label/rectangle.c @@ -13,7 +13,6 @@ #include "index.h" #include #include -#include #include "logic.h" #include "arith.h" #include "rectangle.h" @@ -116,30 +115,17 @@ void PrintRect(Rect_t * r) /*----------------------------------------------------------------------------- | Calculate the n-dimensional area of a rectangle -----------------------------------------------------------------------------*/ -unsigned int RectArea(Rect_t * r) +int RectArea(Rect_t * r) { - register int i; - unsigned int area; - assert(r); + register int i, area; + assert(r); if (Undefined(r)) return 0; - /* - * XXX add overflow checks - */ area = 1; for (i = 0; i < NUMDIMS; i++) { -#if 1 /* overflow check */ - long long a_test = area * r->boundary[i + NUMDIMS] - r->boundary[i]; - if( a_test > UINT_MAX) { - agerror("label: area too large for rtree\n"); - return UINT_MAX; - } - area = a_test; -#else - area *= r->boundary[i + NUMDIMS] - r->boundary[i]; -#endif + area *= r->boundary[i + NUMDIMS] - r->boundary[i]; } return area; } diff --git a/lib/label/rectangle.h b/lib/label/rectangle.h index dbda16f05..64fbd6fde 100644 --- a/lib/label/rectangle.h +++ b/lib/label/rectangle.h @@ -25,7 +25,7 @@ void InitRect(Rect_t * r); #ifdef RTDEBUG void PrintRect(Rect_t *); #endif -unsigned int RectArea(Rect_t *); +int RectArea(Rect_t *); int Overlap(Rect_t *, Rect_t *); int Contained(Rect_t *, Rect_t *); Rect_t CombineRect(Rect_t *, Rect_t *); diff --git a/lib/label/split.q.c b/lib/label/split.q.c index 6cc593b11..c382f8828 100644 --- a/lib/label/split.q.c +++ b/lib/label/split.q.c @@ -218,16 +218,13 @@ static void MethodZero(RTree_t * rtp) -----------------------------------------------------------------------------*/ static void PickSeeds(RTree_t * rtp) { - register int i, j; - unsigned int waste, worst; - int seed0, seed1; - unsigned int area[NODECARD + 1]; + register int i, j, waste, worst, seed0, seed1; + int area[NODECARD + 1]; for (i = 0; i < NODECARD + 1; i++) area[i] = RectArea(&rtp->split.BranchBuf[i].rect); - //worst = -rtp->split.CoverSplitArea - 1; - worst=0; + worst = -rtp->split.CoverSplitArea - 1; for (i = 0; i < NODECARD; i++) { for (j = i + 1; j < NODECARD + 1; j++) { Rect_t rect; diff --git a/lib/label/split.q.h b/lib/label/split.q.h index 7279bb74c..ee341f344 100644 --- a/lib/label/split.q.h +++ b/lib/label/split.q.h @@ -38,7 +38,7 @@ extern "C" { typedef struct split_q_s { struct Branch BranchBuf[NODECARD + 1]; struct Rect CoverSplit; - unsigned int CoverSplitArea; + int CoverSplitArea; struct PartitionVars Partitions[METHODS]; } SplitQ_t; diff --git a/lib/label/xlabels.c b/lib/label/xlabels.c index 24d792866..e2d13e422 100644 --- a/lib/label/xlabels.c +++ b/lib/label/xlabels.c @@ -596,52 +596,33 @@ static int xlhdxload(XLabels_t * xlp) hp->key = hd_hil_s_from_xy(pi, order); -#if 0 - if (dtsearch(xlp->hdx, hp) != 0) { - free(hp); + if (dtsearch(xlp->hdx, hp) != 0) continue; - } -#endif if (!(dtinsert(xlp->hdx, hp))) return -1; } return 0; } -static void xlhdxunload(XLabels_t * xlp) -{ - int size=dtsize(xlp->hdx), freed=0; - while(dtsize(xlp->hdx) ) { - Void_t*vp=dtfinger(xlp->hdx); - assert(vp); - if(vp) { - dtdetach(xlp->hdx, vp); - free(vp); - freed++; - } - } - assert(size==freed); -} - static int xlspdxload(XLabels_t * xlp) { - HDict_t *op=0; + HDict_t *op; for (op = dtfirst(xlp->hdx); op; op = dtnext(xlp->hdx, op)) { /* tree rectangle data node lvl */ - RTreeInsert(xlp->spdx, &op->d.rect, op->d.data, &xlp->spdx->root, 0); + RTreeInsert(xlp->spdx, &op->d.rect, op->d.data, &xlp->spdx->root, + 0); } return 0; } static int xlinitialize(XLabels_t * xlp) { - int r=0; + int r; if ((r = xlhdxload(xlp)) < 0) return r; if ((r = xlspdxload(xlp)) < 0) return r; - xlhdxunload(xlp); return dtclose(xlp->hdx); } -- 2.40.0