lib/Math/Geometry/Delaunay.xs

filter: Statementstmt 64.5% 102 / 158 Branchbran 47.8% 66 / 138 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 56.7% 168 / 296 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« src/triangle.c ↑ Summary
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4  
5 #include "ppport.h"
6  
7 #include <string.h>
8  
9 /* cross-platform macros to set floating point precision for doubles */
10 /* Mainly needed to restore defaults, since Triangle doesn't. */
11 /* http://www.christian-seiler.de/projekte/fpmath/ */
12  
13 #include "xpfpa.h"
14  
15 /* triangle.h needs these two defines */
16 /* REAL can be single or double, but I've used */
17 /* double everywhere in the code here, so use double. */
18 /* TRIVOID should be void. triangle.c sets it to int */
19 /* to "fool dumb compilers" but void looks like it's */
20 /* more portable. */
21 /* We also set REAL in the Build.PL compiler flags. */
22 /* NOTE: TRIVOID should also be defined as void */
23 /* (instead of int) directly in triangle.c. */
24 /* NOTE: TRIVOID was originally VOID in triangle.c, */
25 /* but that interacted in a bad way with VOID defined */
26 /* in winnt.h in MingW, so: triangle.c =~ s/VOID/TRIVOID/g */
27  
28 #define REAL double
29 #define TRIVOID void
30 typedef REAL *vertex;
31  
32 #include "triangle.h"
33  
34 /* declare a couple functions in triangle.c not exposed by triangle.h */
35 /* mainly to supress compiler warnings */
36  
37 #ifdef ANSI_DECLARATORS
38 REAL counterclockwiseadapt(vertex pa, vertex pb, vertex pc, REAL detsum);
39 void exactinit();
40 #else /* not ANSI_DECLARATORS */
41 void counterclockwiseadapt();
42 void exactinit();
43 #endif /* not ANSI_DECLARATORS */
44  
45 /* these let us refer to the struct in triangle.h */
46  
47 typedef struct triangulateio * Math__Geometry__Delaunay__TriangulateioPtr;
48 typedef struct triangulateio Math__Geometry__Delaunay__Triangulateio;
49  
50 /* for T_ARRAY typmap */
51  
52 typedef double doubleArray;
53 typedef int intArray;
54  
55 /* for our custom T_ARRAY input code */
56  
57 #define doubleArrayPtrContains double
58 #define intArrayPtrContains int
59  
60 /* memory allocation functions for T_ARRAY typemap INPUT */
61  
62 8 doubleArray * doubleArrayPtr( int nelem ) {
63 doubleArray * array;
64 8 array = (doubleArray *) trimalloc(nelem * sizeof(double));
65 8 return array;
66 }
67 5 intArray * intArrayPtr( int nelem ) {
68 intArray * array;
69 5 array = (intArray *) trimalloc(nelem * sizeof(int));
70 5 return array;
71 }
72  
73 /* ccw test with adaptive exact fallback, adapted from */
74 /* Triangle's version (removed mesh and behavior params) */
75 /* "The result is also a rough approximation of twice the */
76 /* signed area of the triangle defined by the three points." */
77  
78 /* A global defined in triangle.c */
79 extern REAL ccwerrboundA;
80  
81 0 double mgdcounterclockwise(vertex pa, vertex pb, vertex pc) {
82 REAL detleft, detright, det;
83 REAL detsum, errbound;
84 XPFPA_DECLARE()
85  
86 0 detleft = (pa[0] - pc[0]) * (pb[1] - pc[1]);
87 0 detright = (pa[1] - pc[1]) * (pb[0] - pc[0]);
88 0 det = detleft - detright;
89  
90 0 ▶ if (detleft > 0.0) {
Branch: 1 branch
BranchTrueFalseTotal
if (detleft > 0.0) { 0 0 0
91 0 ▶ if (detright <= 0.0) {
Branch: 1 branch
BranchTrueFalseTotal
if (detright <= 0.0) { 0 0 0
92 0 return det;
93 } else {
94 0 detsum = detleft + detright;
95 }
96 0 ▶ } else if (detleft < 0.0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (detleft < 0.0) { 0 0 0
97 0 ▶ if (detright >= 0.0) {
Branch: 1 branch
BranchTrueFalseTotal
if (detright >= 0.0) { 0 0 0
98 0 return det;
99 } else {
100 0 detsum = -detleft - detright;
101 }
102 } else {
103 0 return det;
104 }
105  
106 0 errbound = ccwerrboundA * detsum;
107 0 ▶ if ((det >= errbound) || (-det >= errbound)) {
Branch: 2 branches
BranchTrueFalseTotal
if ((det >= errbound) || (-det >= errbound)) { 0 0 0
if ((det >= errbound) || (-det >= errbound)) { 0 0 0
108 0 return det;
109 }
110  
111 0 XPFPA_SWITCH_DOUBLE()
112 0 det = counterclockwiseadapt(pa, pb, pc, detsum);
113 0 XPFPA_RESTORE()
114  
115 0 return det;
116 }
117  
118  
119 /* TODO: */
120 /* Consider offering the -u option, the "user defined constraint" function feature. */
121 /* Define a C function that calls a Perl function stub to be overidden. See perlcall. */
122  
123  
124 MODULE = Math::Geometry::Delaunay PACKAGE = Math::Geometry::Delaunay
125 PROTOTYPES: DISABLE
126  
127 SV *
128 exactinit()
129 PREINIT:
130 XPFPA_DECLARE() /* declares vars to stash the floating point config */
131 CODE:
132 8 XPFPA_SWITCH_DOUBLE()
133 8 exactinit();
134 8 XPFPA_RESTORE()
135  
136 SV *
137 _triangulate(arg0, arg1, arg2, arg3)
138 char * arg0
139 Math::Geometry::Delaunay::TriangulateioPtr arg1
140 Math::Geometry::Delaunay::TriangulateioPtr arg2
141 Math::Geometry::Delaunay::TriangulateioPtr arg3
142 PREINIT:
143 21 ▶ char * doVoronoi = 0;
Branch: 1 branch
BranchTrueFalseTotal
char * doVoronoi = 0; 21 0 21
144 XPFPA_DECLARE() /* declares vars to stash the floating point config */
145 CODE:
146 21 doVoronoi = strchr(arg0, 'v');
147 /* set normal double precision mode (triangle usually does this too) */
148 21 XPFPA_SWITCH_DOUBLE()
149 21 triangulate(arg0,arg1,arg2,arg3);
150 /* set the floating point config back to whatever it was */
151 21 XPFPA_RESTORE()
152  
153 /* Triangle just copies pointers from IN to OUT for these two lists of redundant info. */
154 /* To enable safe garbage collection/DESTROY, we make a copy of the data for OUT. */
155  
156 21 ▶ if (arg1->numberofholes && arg1->holelist ) {
Branch: 2 branches
BranchTrueFalseTotal
if (arg1->numberofholes && arg1->holelist ) { 0 21 21
if (arg1->numberofholes && arg1->holelist ) { 0 0 0
157 0 Newx(arg2->holelist, arg1->numberofholes * 2, double);
158 0 Copy(arg1->holelist, arg2->holelist , arg1->numberofholes * 2, double);
159 0 ▶ if (doVoronoi) {
Branch: 1 branch
BranchTrueFalseTotal
if (doVoronoi) { 0 0 0
160 0 Newx(arg3->holelist, arg1->numberofholes * 2, double);
161 0 Copy(arg1->holelist, arg3->holelist , arg1->numberofholes * 2, double);
162 }
163 }
164 21 ▶ if (arg1->numberofregions && arg1->regionlist) {
Branch: 2 branches
BranchTrueFalseTotal
if (arg1->numberofregions && arg1->regionlist) { 0 21 21
if (arg1->numberofregions && arg1->regionlist) { 0 0 0
165 0 Newx(arg2->regionlist, arg1->numberofregions * (2 + arg1->numberoftriangleattributes), double);
166 0 Copy(arg1->regionlist, arg2->regionlist , arg1->numberofregions * (2 + arg1->numberoftriangleattributes), double);
167 0 ▶ if (doVoronoi) {
Branch: 1 branch
BranchTrueFalseTotal
if (doVoronoi) { 0 0 0
168 0 Newx(arg3->regionlist, arg1->numberofregions * (2 + arg1->numberoftriangleattributes), double);
169 0 Copy(arg1->regionlist, arg3->regionlist , arg1->numberofregions * (2 + arg1->numberoftriangleattributes), double);
170 }
171 }
172  
173 double
174 _counterclockwise(double pax, double pay, double pbx, double pby, double pcx, double pcy)
175 PREINIT:
176 double pa[2];
177 double pb[2];
178 double pc[2];
179 CODE:
180 0 pa[0] = pax; pa[1] = pay;
181 0 pb[0] = pbx; pb[1] = pby;
182 0 pc[0] = pcx; pc[1] = pcy;
183 0 RETVAL = mgdcounterclockwise(pa, pb, pc);
184 OUTPUT:
185 RETVAL
186  
187 MODULE=Math::Geometry::Delaunay PACKAGE=Math::Geometry::Delaunay::Triangulateio PREFIX=triio_
188 PROTOTYPES: DISABLE
189  
190 Math::Geometry::Delaunay::Triangulateio
191 triio_new(char * CLASS)
192 CODE:
193 50 Zero((void*)&RETVAL, sizeof(RETVAL), char);
194 /* initialize everything in the struct */
195 50 RETVAL.pointlist = (double *) NULL; /* In / out */
196 50 RETVAL.pointattributelist = (double *) NULL; /* In / out */
197 50 RETVAL.pointmarkerlist = (int *) NULL; /* In / out */
198 50 RETVAL.numberofpoints = (int) 0; /* In / out */
199 50 RETVAL.numberofpointattributes = (int) 0; /* In / out */
200  
201 50 RETVAL.trianglelist = (int *) NULL; /* In / out */
202 50 RETVAL.triangleattributelist = (double *) NULL; /* In / out */
203 50 RETVAL.trianglearealist = (double *) NULL; /* In only */
204 50 RETVAL.neighborlist = (int *) NULL; /* Out only */
205 50 RETVAL.numberoftriangles = (int) 0; /* In / out */
206 50 RETVAL.numberofcorners = (int) 3; /* In / out */
207 50 RETVAL.numberoftriangleattributes = (int) 0; /* In / out */
208  
209 50 RETVAL.segmentlist = (int *) NULL; /* In / out */
210 50 RETVAL.segmentmarkerlist = (int *) NULL; /* In / out */
211 50 RETVAL.numberofsegments = (int) 0; /* In / out */
212  
213 50 RETVAL.holelist = (double *) NULL; /* In / pointer to array copied out */
214 50 RETVAL.numberofholes = (int) 0; /* In / copied out */
215  
216 50 RETVAL.regionlist = (double *) NULL; /* In / pointer to array copied out */
217 50 RETVAL.numberofregions = (int) 0; /* In / copied out */
218  
219 50 RETVAL.edgelist = (int *) NULL; /* Out only */
220 50 RETVAL.edgemarkerlist = (int *) NULL; /* Not used with Voronoi diagram; out only */
221 50 RETVAL.normlist = (double *) NULL; /* Used only with Voronoi diagram; out only */
222 50 RETVAL.numberofedges = (int) 0; /* Out only */
223 OUTPUT:
224 RETVAL
225  
226 # getter/setter for all the "number of" members of the triangulateio struct
227  
228 int
229 numberof(SV * THIS, int newval = 0)
230 #numberof(Math::Geometry::Delaunay::Triangulateio THIS, int newval = 0)
231 PROTOTYPE: DISABLE
232 ALIAS:
233 numberofpoints = 1
234 numberofpointattributes = 2
235 numberoftriangles = 3
236 numberofcorners = 4
237 numberoftriangleattributes = 5
238 numberofsegments = 6
239 numberofholes = 7
240 numberofregions = 8
241 numberofedges = 9
242 PREINIT:
243 struct triangulateio * p;
244 STRLEN len;
245 CODE:
246 85 ▶ if (!sv_derived_from(THIS, "Math::Geometry::Delaunay::Triangulateio")) {croak("Wrong type to numberof()");}
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(THIS, "Math::Geometry::Delaunay::Triangulateio")) {croak("Wrong type to numberof()");} 0 85 85
247 85 ▶ if (SvCUR(SvRV(THIS)) != sizeof(*p)) { croak("Size %lu of packed data != expected %lu", SvCUR(SvRV(THIS)), sizeof(*p)); }
Branch: 1 branch
BranchTrueFalseTotal
if (SvCUR(SvRV(THIS)) != sizeof(*p)) { croak("Size %lu of packed data != expected %lu", SvCUR(SvRV(THIS)), sizeof(*p)); } 0 85 85
248 85 p = (struct triangulateio *) SvPV((SV*)SvRV(THIS), len);
249
250 85 switch (ix) {
251 31 ▶ case 1 : if ( items > 1 ) {p->numberofpoints = newval;} RETVAL = p->numberofpoints; break;
Branch: 1 branch
BranchTrueFalseTotal
case 1 : if ( items > 1 ) {p->numberofpoints = newval;} RETVAL = p->numberofpoints; break; 0 31 31
252 22 ▶ case 2 : if ( items > 1 ) {p->numberofpointattributes = newval;} RETVAL = p->numberofpointattributes; break;
Branch: 1 branch
BranchTrueFalseTotal
case 2 : if ( items > 1 ) {p->numberofpointattributes = newval;} RETVAL = p->numberofpointattributes; break; 0 22 22
253 5 ▶ case 3 : if ( items > 1 ) {p->numberoftriangles = newval;} RETVAL = p->numberoftriangles; break;
Branch: 1 branch
BranchTrueFalseTotal
case 3 : if ( items > 1 ) {p->numberoftriangles = newval;} RETVAL = p->numberoftriangles; break; 0 5 5
254 10 ▶ case 4 : if ( items > 1 ) {p->numberofcorners = newval;} RETVAL = p->numberofcorners; break;
Branch: 1 branch
BranchTrueFalseTotal
case 4 : if ( items > 1 ) {p->numberofcorners = newval;} RETVAL = p->numberofcorners; break; 1 9 10
255 4 ▶ case 5 : if ( items > 1 ) {p->numberoftriangleattributes = newval;} RETVAL = p->numberoftriangleattributes; break;
Branch: 1 branch
BranchTrueFalseTotal
case 5 : if ( items > 1 ) {p->numberoftriangleattributes = newval;} RETVAL = p->numberoftriangleattributes; break; 0 4 4
256 8 ▶ case 6 : if ( items > 1 ) {p->numberofsegments = newval;} RETVAL = p->numberofsegments; break;
Branch: 1 branch
BranchTrueFalseTotal
case 6 : if ( items > 1 ) {p->numberofsegments = newval;} RETVAL = p->numberofsegments; break; 0 8 8
257 0 ▶ case 7 : if ( items > 1 ) {p->numberofholes = newval;} RETVAL = p->numberofholes; break;
Branch: 1 branch
BranchTrueFalseTotal
case 7 : if ( items > 1 ) {p->numberofholes = newval;} RETVAL = p->numberofholes; break; 0 0 0
258 0 ▶ case 8 : if ( items > 1 ) {p->numberofregions = newval;} RETVAL = p->numberofregions; break;
Branch: 1 branch
BranchTrueFalseTotal
case 8 : if ( items > 1 ) {p->numberofregions = newval;} RETVAL = p->numberofregions; break; 0 0 0
259 5 ▶ case 9 : if ( items > 1 ) {p->numberofedges = newval;} RETVAL = p->numberofedges; break;
Branch: 1 branch
BranchTrueFalseTotal
case 9 : if ( items > 1 ) {p->numberofedges = newval;} RETVAL = p->numberofedges; break; 0 5 5
260 0 default : RETVAL = 0;
261 }
262 OUTPUT:
263 RETVAL
264  
265 # getters/setters for all the arrays in the triangulateio struct
266  
267 # This uses T_ARRAY typmap, with it's INPUT code overridden to accomodate
268 # always getting an object reference as the first, and sometimes the only,
269 # argument.
270 #
271 # Note that the use of T_ARRAY requires certain typedefs and that the modified
272 # INPUT code relies on a couple defines, that follow the typedefs above.
273 #
274 # Also, the modified INPUT code imposes a constraint on the maximum value
275 # integers that can be stored in Triangulateio's lists. Integer input is
276 # interpreted as a double, then cast back to an integer. If your integers have
277 # more than 53 bits they will lose the least significant bits that don't fit in
278 # a double.
279 #
280 # 53 bit integers let you have up to 9,007,199,254,740,992 indexable items of
281 # any kind in your triangulations.
282  
283 # getter/setter for all the arrays of doubles in the triangulateio struct
284  
285 doubleArray *
286 doubleList(doubleArray * array, ... )
287 ALIAS:
288 pointlist = 1
289 pointattributelist = 2
290 triangleattributelist = 3
291 trianglearealist = 4
292 holelist = 5
293 regionlist = 6
294 normlist = 7
295 PREINIT:
296 IV size_RETVAL;
297 struct triangulateio * p;
298 STRLEN len;
299 33 ▶ int orig_items_cnt = (int) items;
Branch: 1 branch
BranchTrueFalseTotal
int orig_items_cnt = (int) items; 8 25 33
300 CODE:
301 33 ▶ if (!sv_derived_from(ST(0), "Math::Geometry::Delaunay::Triangulateio")) {croak("Wrong type to numberof()");}
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(ST(0), "Math::Geometry::Delaunay::Triangulateio")) {croak("Wrong type to numberof()");} 0 33 33
302 33 ▶ if (SvCUR(SvRV(ST(0))) != sizeof(*p)) { croak("Size %lu of packed data != expected %lu", SvCUR(SvRV(ST(0))), sizeof(*p)); }
Branch: 1 branch
BranchTrueFalseTotal
if (SvCUR(SvRV(ST(0))) != sizeof(*p)) { croak("Size %lu of packed data != expected %lu", SvCUR(SvRV(ST(0))), sizeof(*p)); } 0 33 33
303 33 p = (struct triangulateio *) SvPV((SV*)SvRV(ST(0)), len);
304  
305 /* setter */
306 33 ▶ if (orig_items_cnt > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (orig_items_cnt > 1) { 8 25 33
307 8 switch (ix) {
308 8 ▶ case 1 : if (p->pointlist) {trifree(p->pointlist);} p->pointlist = array ; p->numberofpoints = ix_array/2; break;
Branch: 1 branch
BranchTrueFalseTotal
case 1 : if (p->pointlist) {trifree(p->pointlist);} p->pointlist = array ; p->numberofpoints = ix_array/2; break; 1 7 8
309 0 ▶ case 2 : if (p->pointattributelist) {trifree(p->pointattributelist);} p->pointattributelist = array ; break;
Branch: 1 branch
BranchTrueFalseTotal
case 2 : if (p->pointattributelist) {trifree(p->pointattributelist);} p->pointattributelist = array ; break; 0 0 0
310 0 ▶ case 3 : if (p->triangleattributelist) {trifree(p->triangleattributelist);} p->triangleattributelist = array ; break;
Branch: 1 branch
BranchTrueFalseTotal
case 3 : if (p->triangleattributelist) {trifree(p->triangleattributelist);} p->triangleattributelist = array ; break; 0 0 0
311 0 ▶ case 4 : if (p->trianglearealist) {trifree(p->trianglearealist);} p->trianglearealist = array ; break;
Branch: 1 branch
BranchTrueFalseTotal
case 4 : if (p->trianglearealist) {trifree(p->trianglearealist);} p->trianglearealist = array ; break; 0 0 0
312 0 ▶ case 5 : if (p->holelist) {trifree(p->holelist);} p->holelist = array ; p->numberofholes = ix_array/2; break;
Branch: 1 branch
BranchTrueFalseTotal
case 5 : if (p->holelist) {trifree(p->holelist);} p->holelist = array ; p->numberofholes = ix_array/2; break; 0 0 0
313 0 ▶ case 6 : if (p->regionlist) {trifree(p->regionlist);} p->regionlist = array ; p->numberofregions = ix_array/2; break;
Branch: 1 branch
BranchTrueFalseTotal
case 6 : if (p->regionlist) {trifree(p->regionlist);} p->regionlist = array ; p->numberofregions = ix_array/2; break; 0 0 0
314 0 ▶ case 7 : if (p->normlist) {trifree(p->normlist);} p->normlist = array ; break;
Branch: 1 branch
BranchTrueFalseTotal
case 7 : if (p->normlist) {trifree(p->normlist);} p->normlist = array ; break; 0 0 0
315 }
316 /* return count of how many items added */
317 8 ST(0) = sv_newmortal();
318 8 sv_setnv(ST(0), (double) ix_array);
319 8 XSRETURN(1);
320 }
321 /* getter */
322 else {
323 25 switch (ix) {
324 24 case 1 : RETVAL = p->pointlist; size_RETVAL = p->numberofpoints*2; break;
325 0 case 2 : RETVAL = p->pointattributelist; size_RETVAL = p->numberofpoints*p->numberofpointattributes; break;
326 0 case 3 : RETVAL = p->triangleattributelist; size_RETVAL = p->numberoftriangles*p->numberoftriangleattributes; break;
327 0 case 4 : RETVAL = p->trianglearealist; size_RETVAL = p->numberoftriangles; break;
328 0 case 5 : RETVAL = p->holelist; size_RETVAL = p->numberofholes*2; break;
329 0 case 6 : RETVAL = p->regionlist; size_RETVAL = p->numberofregions*p->numberoftriangleattributes; break;
330 1 case 7 : RETVAL = p->normlist; size_RETVAL = p->numberofedges*2; break;
331 0 default: RETVAL = (double *) NULL; size_RETVAL = 0;
332 }
333 }
334 OUTPUT:
335 RETVAL
336 CLEANUP:
337 25 XSRETURN(size_RETVAL);
338  
339 # getter/setter for all the arrays of ints in the triangulateio struct
340  
341 intArray *
342 intList( intArray * array, ... )
343 ALIAS:
344 pointmarkerlist = 1
345 trianglelist = 2
346 neighborlist = 3
347 segmentlist = 4
348 segmentmarkerlist = 5
349 edgelist = 6
350 edgemarkerlist = 7
351 PREINIT:
352 IV size_RETVAL;
353 struct triangulateio * p;
354 STRLEN len;
355 44 ▶ int orig_items_cnt = (int) items;
Branch: 1 branch
BranchTrueFalseTotal
int orig_items_cnt = (int) items; 5 39 44
356 CODE:
357 44 ▶ if (!sv_derived_from(ST(0), "Math::Geometry::Delaunay::Triangulateio")) {croak("Wrong type to numberof()");}
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(ST(0), "Math::Geometry::Delaunay::Triangulateio")) {croak("Wrong type to numberof()");} 0 44 44
358 44 ▶ if (SvCUR(SvRV(ST(0))) != sizeof(*p)) { croak("Size %lu of packed data != expected %lu", SvCUR(SvRV(ST(0))), sizeof(*p)); }
Branch: 1 branch
BranchTrueFalseTotal
if (SvCUR(SvRV(ST(0))) != sizeof(*p)) { croak("Size %lu of packed data != expected %lu", SvCUR(SvRV(ST(0))), sizeof(*p)); } 0 44 44
359 44 p = (struct triangulateio *) SvPV((SV*)SvRV(ST(0)), len);
360 /* setter */
361 44 ▶ if (orig_items_cnt > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (orig_items_cnt > 1) { 5 39 44
362 5 switch (ix) {
363 0 ▶ case 1 : if (p->pointmarkerlist) {trifree(p->pointmarkerlist);} p->pointmarkerlist = array; break;
Branch: 1 branch
BranchTrueFalseTotal
case 1 : if (p->pointmarkerlist) {trifree(p->pointmarkerlist);} p->pointmarkerlist = array; break; 0 0 0
364 0 ▶ case 2 : if (p->trianglelist) {trifree(p->trianglelist);} p->trianglelist = array; p->numberoftriangles = ix_array/3; break;
Branch: 1 branch
BranchTrueFalseTotal
case 2 : if (p->trianglelist) {trifree(p->trianglelist);} p->trianglelist = array; p->numberoftriangles = ix_array/3; break; 0 0 0
365 0 ▶ case 3 : if (p->neighborlist) {trifree(p->neighborlist);} p->neighborlist = array; break;
Branch: 1 branch
BranchTrueFalseTotal
case 3 : if (p->neighborlist) {trifree(p->neighborlist);} p->neighborlist = array; break; 0 0 0
366 5 ▶ case 4 : if (p->segmentlist) {trifree(p->segmentlist);} p->segmentlist = array; p->numberofsegments = ix_array/2; break;
Branch: 1 branch
BranchTrueFalseTotal
case 4 : if (p->segmentlist) {trifree(p->segmentlist);} p->segmentlist = array; p->numberofsegments = ix_array/2; break; 0 5 5
367 0 ▶ case 5 : if (p->segmentmarkerlist) {trifree(p->segmentmarkerlist);} p->segmentmarkerlist = array; break;
Branch: 1 branch
BranchTrueFalseTotal
case 5 : if (p->segmentmarkerlist) {trifree(p->segmentmarkerlist);} p->segmentmarkerlist = array; break; 0 0 0
368 0 ▶ case 6 : if (p->edgelist) {trifree(p->edgelist);} p->edgelist = array; p->numberofedges = ix_array/2; break;
Branch: 1 branch
BranchTrueFalseTotal
case 6 : if (p->edgelist) {trifree(p->edgelist);} p->edgelist = array; p->numberofedges = ix_array/2; break; 0 0 0
369 0 ▶ case 7 : if (p->edgemarkerlist) {trifree(p->edgemarkerlist);} p->edgemarkerlist = array; break;
Branch: 1 branch
BranchTrueFalseTotal
case 7 : if (p->edgemarkerlist) {trifree(p->edgemarkerlist);} p->edgemarkerlist = array; break; 0 0 0
370 }
371 /* return count of how many items added */
372 5 ST(0) = sv_newmortal();
373 5 sv_setiv(ST(0), ix_array);
374 5 XSRETURN(1);
375 }
376 /* getter */
377 else {
378 39 switch (ix) {
379 6 ▶ case 1 : RETVAL = p->pointmarkerlist; size_RETVAL = p->pointmarkerlist ? p->numberofpoints : 0; break;
Branch: 1 branch
BranchTrueFalseTotal
case 1 : RETVAL = p->pointmarkerlist; size_RETVAL = p->pointmarkerlist ? p->numberofpoints : 0; break; 6 0 6
380 4 ▶ case 2 : RETVAL = p->trianglelist; size_RETVAL = p->trianglelist ? p->numberoftriangles * p->numberofcorners : 0; break;
Branch: 1 branch
BranchTrueFalseTotal
case 2 : RETVAL = p->trianglelist; size_RETVAL = p->trianglelist ? p->numberoftriangles * p->numberofcorners : 0; break; 4 0 4
381 4 ▶ case 3 : RETVAL = p->neighborlist; size_RETVAL = p->neighborlist ? p->numberoftriangles*3 : 0; break;
Branch: 1 branch
BranchTrueFalseTotal
case 3 : RETVAL = p->neighborlist; size_RETVAL = p->neighborlist ? p->numberoftriangles*3 : 0; break; 2 2 4
382 6 ▶ case 4 : RETVAL = p->segmentlist; size_RETVAL = p->segmentlist ? p->numberofsegments*2 : 0; break;
Branch: 1 branch
BranchTrueFalseTotal
case 4 : RETVAL = p->segmentlist; size_RETVAL = p->segmentlist ? p->numberofsegments*2 : 0; break; 4 2 6
383 6 ▶ case 5 : RETVAL = p->segmentmarkerlist; size_RETVAL = p->segmentmarkerlist ? p->numberofsegments : 0; break;
Branch: 1 branch
BranchTrueFalseTotal
case 5 : RETVAL = p->segmentmarkerlist; size_RETVAL = p->segmentmarkerlist ? p->numberofsegments : 0; break; 4 2 6
384 7 ▶ case 6 : RETVAL = p->edgelist; size_RETVAL = p->edgelist ? p->numberofedges*2 : 0; break;
Branch: 1 branch
BranchTrueFalseTotal
case 6 : RETVAL = p->edgelist; size_RETVAL = p->edgelist ? p->numberofedges*2 : 0; break; 5 2 7
385 6 ▶ case 7 : RETVAL = p->edgemarkerlist; size_RETVAL = p->edgemarkerlist ? p->numberofedges : 0; break;
Branch: 1 branch
BranchTrueFalseTotal
case 7 : RETVAL = p->edgemarkerlist; size_RETVAL = p->edgemarkerlist ? p->numberofedges : 0; break; 4 2 6
386 0 default: RETVAL = (int *) NULL; size_RETVAL = 0;
387 }
388 }
389 OUTPUT:
390 RETVAL
391 CLEANUP:
392 39 XSRETURN(size_RETVAL);
393  
394 Math::Geometry::Delaunay::TriangulateioPtr
395 to_ptr(SV * THIS)
396 PREINIT:
397 STRLEN len;
398 CODE:
399 126 RETVAL = (struct triangulateio *) SvPV((SV*)SvRV(THIS), len);
400 OUTPUT:
401 RETVAL
402  
403 SV *
404 triio_DESTROY(SV * THIS)
405 PREINIT:
406 STRLEN len;
407 struct triangulateio * p;
408 CODE:
409 50 ▶ if (!sv_derived_from(ST(0), "Math::Geometry::Delaunay::Triangulateio")) {croak("Wrong type to numberof()");}
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(ST(0), "Math::Geometry::Delaunay::Triangulateio")) {croak("Wrong type to numberof()");} 0 50 50
410 50 ▶ if (SvCUR(SvRV(ST(0))) != sizeof(*p)) { croak("Size %lu of packed data != expected %lu", SvCUR(SvRV(ST(0))), sizeof(*p)); }
Branch: 1 branch
BranchTrueFalseTotal
if (SvCUR(SvRV(ST(0))) != sizeof(*p)) { croak("Size %lu of packed data != expected %lu", SvCUR(SvRV(ST(0))), sizeof(*p)); } 0 50 50
411 50 p = (struct triangulateio *) SvPV((SV*)SvRV(ST(0)), len);
412  
413 50 ▶ if (p->pointlist) {trifree(p->pointlist);}
Branch: 1 branch
BranchTrueFalseTotal
if (p->pointlist) {trifree(p->pointlist);} 31 19 50
414 50 ▶ if (p->pointattributelist) {trifree(p->pointattributelist);}
Branch: 1 branch
BranchTrueFalseTotal
if (p->pointattributelist) {trifree(p->pointattributelist);} 3 47 50
415 50 ▶ if (p->pointmarkerlist) {trifree(p->pointmarkerlist);}
Branch: 1 branch
BranchTrueFalseTotal
if (p->pointmarkerlist) {trifree(p->pointmarkerlist);} 21 29 50
416 50 ▶ if (p->trianglelist) {trifree(p->trianglelist);}
Branch: 1 branch
BranchTrueFalseTotal
if (p->trianglelist) {trifree(p->trianglelist);} 21 29 50
417 50 ▶ if (p->triangleattributelist) {trifree(p->triangleattributelist);}
Branch: 1 branch
BranchTrueFalseTotal
if (p->triangleattributelist) {trifree(p->triangleattributelist);} 0 50 50
418 50 ▶ if (p->trianglearealist) {trifree(p->trianglearealist);}
Branch: 1 branch
BranchTrueFalseTotal
if (p->trianglearealist) {trifree(p->trianglearealist);} 0 50 50
419 50 ▶ if (p->neighborlist) {trifree(p->neighborlist);}
Branch: 1 branch
BranchTrueFalseTotal
if (p->neighborlist) {trifree(p->neighborlist);} 1 49 50
420 50 ▶ if (p->segmentlist) {trifree(p->segmentlist);}
Branch: 1 branch
BranchTrueFalseTotal
if (p->segmentlist) {trifree(p->segmentlist);} 10 40 50
421 50 ▶ if (p->segmentmarkerlist) {trifree(p->segmentmarkerlist);}
Branch: 1 branch
BranchTrueFalseTotal
if (p->segmentmarkerlist) {trifree(p->segmentmarkerlist);} 5 45 50
422 50 ▶ if (p->holelist) {trifree(p->holelist);}
Branch: 1 branch
BranchTrueFalseTotal
if (p->holelist) {trifree(p->holelist);} 0 50 50
423 50 ▶ if (p->regionlist) {trifree(p->regionlist);}
Branch: 1 branch
BranchTrueFalseTotal
if (p->regionlist) {trifree(p->regionlist);} 0 50 50
424 50 ▶ if (p->edgelist) {trifree(p->edgelist);}
Branch: 1 branch
BranchTrueFalseTotal
if (p->edgelist) {trifree(p->edgelist);} 7 43 50
425 50 ▶ if (p->edgemarkerlist) {trifree(p->edgemarkerlist);}
Branch: 1 branch
BranchTrueFalseTotal
if (p->edgemarkerlist) {trifree(p->edgemarkerlist);} 4 46 50
426 50 ▶ if (p->normlist) {trifree(p->normlist);}
Branch: 1 branch
BranchTrueFalseTotal
if (p->normlist) {trifree(p->normlist);} 3 47 50
427  
« src/triangle.c ↑ Summary