1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
|
From: Andreas Tille <tille@debian.org>
Date: Sun, 19 Dec 2021 12:10:57 +0100
Subject: Take over changes from Github
Origin: https://github.com/libigl/triangle/
Forwarded: not-needed
---
triangle.c | 82 +++++++++++++++++++++++++++++++-------------------------------
triangle.h | 20 +++++++++------
2 files changed, 54 insertions(+), 48 deletions(-)
diff --git a/triangle.c b/triangle.c
index 44f68f0..6d4027d 100644
--- a/triangle.c
+++ b/triangle.c
@@ -469,16 +469,16 @@ unsigned long randomseed; /* Current random number seed. */
/* extracted from the two least significant bits of the pointer. */
#define decode(ptr, otri) \
- (otri).orient = (int) ((unsigned long) (ptr) & (unsigned long) 3l); \
+ (otri).orient = (int) ((INT_PTR) (ptr) & (INT_PTR) 3l); \
(otri).tri = (triangle *) \
- ((unsigned long) (ptr) ^ (unsigned long) (otri).orient)
+ ((INT_PTR) (ptr) ^ (INT_PTR) (otri).orient)
/* encode() compresses an oriented triangle into a single pointer. It */
/* relies on the assumption that all triangles are aligned to four-byte */
/* boundaries, so the two least significant bits of (otri).tri are zero. */
#define encode(otri) \
- (triangle) ((unsigned long) (otri).tri | (unsigned long) (otri).orient)
+ (triangle) ((INT_PTR) (otri).tri | (INT_PTR) (otri).orient)
/* The following handle manipulation primitives are all described by Guibas */
/* and Stolfi. However, Guibas and Stolfi use an edge-based data */
@@ -633,16 +633,16 @@ unsigned long randomseed; /* Current random number seed. */
#define infect(otri) \
(otri).tri[6] = (triangle) \
- ((unsigned long) (otri).tri[6] | (unsigned long) 2l)
+ ((INT_PTR) (otri).tri[6] | (INT_PTR) 2l)
#define uninfect(otri) \
(otri).tri[6] = (triangle) \
- ((unsigned long) (otri).tri[6] & ~ (unsigned long) 2l)
+ ((INT_PTR) (otri).tri[6] & ~ (INT_PTR) 2l)
/* Test a triangle for viral infection. */
#define infected(otri) \
- (((unsigned long) (otri).tri[6] & (unsigned long) 2l) != 0l)
+ (((INT_PTR) (otri).tri[6] & (INT_PTR) 2l) != 0l)
/* Check or set a triangle's attributes. */
@@ -679,7 +679,7 @@ unsigned long randomseed; /* Current random number seed. */
/* boundaries, so the least significant bit of (osub).ss is zero. */
#define sencode(osub) \
- (subseg) ((unsigned long) (osub).ss | (unsigned long) (osub).ssorient)
+ (subseg) ((INT_PTR) (osub).ss | (INT_PTR) (osub).ssorient)
/* ssym() toggles the orientation of a subsegment. */
@@ -3391,7 +3391,7 @@ struct memorypool *pool;
#endif /* not ANSI_DECLARATORS */
{
- unsigned long alignptr;
+ INT_PTR alignptr = 0;
pool->items = 0;
pool->maxitems = 0;
@@ -3399,11 +3399,11 @@ struct memorypool *pool;
/* Set the currently active block. */
pool->nowblock = pool->firstblock;
/* Find the first item in the pool. Increment by the size of (VOID *). */
- alignptr = (unsigned long) (pool->nowblock + 1);
+ alignptr = (INT_PTR) (pool->nowblock + 1);
/* Align the item on an `alignbytes'-byte boundary. */
pool->nextitem = (VOID *)
- (alignptr + (unsigned long) pool->alignbytes -
- (alignptr % (unsigned long) pool->alignbytes));
+ (alignptr + (INT_PTR) pool->alignbytes -
+ (alignptr % (INT_PTR) pool->alignbytes));
/* There are lots of unallocated items left in this block. */
pool->unallocateditems = pool->itemsfirstblock;
/* The stack of deallocated items is empty. */
@@ -3508,7 +3508,7 @@ struct memorypool *pool;
{
VOID *newitem;
VOID **newblock;
- unsigned long alignptr;
+ INT_PTR alignptr = 0;
/* First check the linked list of dead items. If the list is not */
/* empty, allocate an item from the list rather than a fresh one. */
@@ -3533,11 +3533,11 @@ struct memorypool *pool;
pool->nowblock = (VOID **) *(pool->nowblock);
/* Find the first item in the block. */
/* Increment by the size of (VOID *). */
- alignptr = (unsigned long) (pool->nowblock + 1);
+ alignptr = (INT_PTR) (pool->nowblock + 1);
/* Align the item on an `alignbytes'-byte boundary. */
pool->nextitem = (VOID *)
- (alignptr + (unsigned long) pool->alignbytes -
- (alignptr % (unsigned long) pool->alignbytes));
+ (alignptr + (INT_PTR) pool->alignbytes -
+ (alignptr % (INT_PTR) pool->alignbytes));
/* There are lots of unallocated items left in this block. */
pool->unallocateditems = pool->itemsperblock;
}
@@ -3592,16 +3592,16 @@ struct memorypool *pool;
#endif /* not ANSI_DECLARATORS */
{
- unsigned long alignptr;
+ INT_PTR alignptr = 0;
/* Begin the traversal in the first block. */
pool->pathblock = pool->firstblock;
/* Find the first item in the block. Increment by the size of (VOID *). */
- alignptr = (unsigned long) (pool->pathblock + 1);
+ alignptr = (INT_PTR) (pool->pathblock + 1);
/* Align with item on an `alignbytes'-byte boundary. */
pool->pathitem = (VOID *)
- (alignptr + (unsigned long) pool->alignbytes -
- (alignptr % (unsigned long) pool->alignbytes));
+ (alignptr + (INT_PTR) pool->alignbytes -
+ (alignptr % (INT_PTR) pool->alignbytes));
/* Set the number of items left in the current block. */
pool->pathitemsleft = pool->itemsfirstblock;
}
@@ -3629,7 +3629,7 @@ struct memorypool *pool;
{
VOID *newitem;
- unsigned long alignptr;
+ INT_PTR alignptr = 0;
/* Stop upon exhausting the list of items. */
if (pool->pathitem == pool->nextitem) {
@@ -3641,11 +3641,11 @@ struct memorypool *pool;
/* Find the next block. */
pool->pathblock = (VOID **) *(pool->pathblock);
/* Find the first item in the block. Increment by the size of (VOID *). */
- alignptr = (unsigned long) (pool->pathblock + 1);
+ alignptr = (INT_PTR) (pool->pathblock + 1);
/* Align with item on an `alignbytes'-byte boundary. */
pool->pathitem = (VOID *)
- (alignptr + (unsigned long) pool->alignbytes -
- (alignptr % (unsigned long) pool->alignbytes));
+ (alignptr + (INT_PTR) pool->alignbytes -
+ (alignptr % (INT_PTR) pool->alignbytes));
/* Set the number of items left in the current block. */
pool->pathitemsleft = pool->itemsperblock;
}
@@ -3697,16 +3697,16 @@ int subsegbytes;
#endif /* not ANSI_DECLARATORS */
{
- unsigned long alignptr;
+ INT_PTR alignptr = 0;
/* Set up `dummytri', the `triangle' that occupies "outer space." */
m->dummytribase = (triangle *) trimalloc(trianglebytes +
m->triangles.alignbytes);
/* Align `dummytri' on a `triangles.alignbytes'-byte boundary. */
- alignptr = (unsigned long) m->dummytribase;
+ alignptr = (INT_PTR) m->dummytribase;
m->dummytri = (triangle *)
- (alignptr + (unsigned long) m->triangles.alignbytes -
- (alignptr % (unsigned long) m->triangles.alignbytes));
+ (alignptr + (INT_PTR) m->triangles.alignbytes -
+ (alignptr % (INT_PTR) m->triangles.alignbytes));
/* Initialize the three adjoining triangles to be "outer space." These */
/* will eventually be changed by various bonding operations, but their */
/* values don't really matter, as long as they can legally be */
@@ -3726,10 +3726,10 @@ int subsegbytes;
m->dummysubbase = (subseg *) trimalloc(subsegbytes +
m->subsegs.alignbytes);
/* Align `dummysub' on a `subsegs.alignbytes'-byte boundary. */
- alignptr = (unsigned long) m->dummysubbase;
+ alignptr = (INT_PTR) m->dummysubbase;
m->dummysub = (subseg *)
- (alignptr + (unsigned long) m->subsegs.alignbytes -
- (alignptr % (unsigned long) m->subsegs.alignbytes));
+ (alignptr + (INT_PTR) m->subsegs.alignbytes -
+ (alignptr % (INT_PTR) m->subsegs.alignbytes));
/* Initialize the two adjoining subsegments to be the omnipresent */
/* subsegment. These will eventually be changed by various bonding */
/* operations, but their values don't really matter, as long as they */
@@ -4086,7 +4086,7 @@ int number;
{
VOID **getblock;
char *foundvertex;
- unsigned long alignptr;
+ INT_PTR alignptr = 0;
int current;
getblock = m->vertices.firstblock;
@@ -4103,9 +4103,9 @@ int number;
}
/* Now find the right vertex. */
- alignptr = (unsigned long) (getblock + 1);
- foundvertex = (char *) (alignptr + (unsigned long) m->vertices.alignbytes -
- (alignptr % (unsigned long) m->vertices.alignbytes));
+ alignptr = (INT_PTR) (getblock + 1);
+ foundvertex = (char *) (alignptr + (INT_PTR) m->vertices.alignbytes -
+ (alignptr % (INT_PTR) m->vertices.alignbytes));
return (vertex) (foundvertex + m->vertices.itembytes * (number - current));
}
@@ -5934,7 +5934,7 @@ REAL dheight;
adxbdy = adx * bdy;
bdxady = bdx * ady;
- det = adheight * (bdxcdy - cdxbdy)
+ det = adheight * (bdxcdy - cdxbdy)
+ bdheight * (cdxady - adxcdy)
+ cdheight * (adxbdy - bdxady);
@@ -7149,7 +7149,7 @@ struct otri *searchtri;
char *firsttri;
struct otri sampletri;
vertex torg, tdest;
- unsigned long alignptr;
+ INT_PTR alignptr = 0;
REAL searchdist, dist;
REAL ahead;
long samplesperblock, totalsamplesleft, samplesleft;
@@ -7221,11 +7221,11 @@ struct otri *searchtri;
population = totalpopulation;
}
/* Find a pointer to the first triangle in the block. */
- alignptr = (unsigned long) (sampleblock + 1);
+ alignptr = (INT_PTR) (sampleblock + 1);
firsttri = (char *) (alignptr +
- (unsigned long) m->triangles.alignbytes -
+ (INT_PTR) m->triangles.alignbytes -
(alignptr %
- (unsigned long) m->triangles.alignbytes));
+ (INT_PTR) m->triangles.alignbytes));
/* Choose `samplesleft' randomly sampled triangles in this block. */
do {
@@ -10975,7 +10975,7 @@ FILE *polyfile;
for (j = 0; j < 2; j++) {
if ((end[j] < b->firstnumber) ||
(end[j] >= b->firstnumber + m->invertices)) {
- printf("Error: Segment %ld has an invalid vertex index.\n",
+ printf("Error: Segment %ld has an invalid vertex index.\n",
segmentnumber);
triexit(1);
}
@@ -12610,7 +12610,7 @@ int regions;
} else {
printf("Spreading regional attributes.\n");
}
- } else {
+ } else {
printf("Spreading regional area constraints.\n");
}
}
diff --git a/triangle.h b/triangle.h
index 4b8e6f5..d603014 100644
--- a/triangle.h
+++ b/triangle.h
@@ -273,8 +273,15 @@
#define REAL double
/*#endif /* not SINGLE */
+/* Define the size large enough to store and operate on a pointer. */
+#define INT_PTR unsigned long long
+
#define ANSI_DECLARATORS
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct triangulateio {
REAL *pointlist; /* In / out */
REAL *pointattributelist; /* In / out */
@@ -308,14 +315,13 @@ struct triangulateio {
#define VOID void
-#ifdef ANSI_DECLARATORS
void triangulate(char *, struct triangulateio *, struct triangulateio *,
struct triangulateio *);
void trifree(VOID *memptr);
-#else /* not ANSI_DECLARATORS */
-void triangulate();
-void trifree();
-#endif /* not ANSI_DECLARATORS */
+
+#ifdef __cplusplus
+}
+#endif
/*****************************************************************************/
/* */
@@ -786,9 +792,9 @@ static int minus1mod3[3] = {2, 0, 1};
/* are masked out to produce the real pointer. */
#define sdecode(sptr, osub) \
- (osub).ssorient = (int) ((unsigned long) (sptr) & (unsigned long) 1l); \
+ (osub).ssorient = (int) ((INT_PTR) (sptr) & (INT_PTR) 1l); \
(osub).ss = (subseg *) \
- ((unsigned long) (sptr) & ~ (unsigned long) 3l)
+ ((INT_PTR) (sptr) & ~ (INT_PTR) 3l)
/* This primitive reads a boundary marker. Boundary markers are */
/* used to hold user-defined tags for setting boundary conditions in */
|