| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
#line 453 "lib/PDL/PP.pm" |
|
3
|
|
|
|
|
|
|
/* |
|
4
|
|
|
|
|
|
|
* THIS FILE WAS GENERATED BY PDL::PP from lib/PDL/ImageND.pd! Do not modify! |
|
5
|
|
|
|
|
|
|
*/ |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#define PDL_FREE_CODE(trans, destroy, comp_free_code, ntpriv_free_code) \ |
|
8
|
|
|
|
|
|
|
if (destroy) { \ |
|
9
|
|
|
|
|
|
|
comp_free_code \ |
|
10
|
|
|
|
|
|
|
} \ |
|
11
|
|
|
|
|
|
|
if ((trans)->dims_redone) { \ |
|
12
|
|
|
|
|
|
|
ntpriv_free_code \ |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
16
|
|
|
|
|
|
|
#include "perl.h" |
|
17
|
|
|
|
|
|
|
#include "XSUB.h" |
|
18
|
|
|
|
|
|
|
#include "pdl.h" |
|
19
|
|
|
|
|
|
|
#include "pdlcore.h" |
|
20
|
|
|
|
|
|
|
#define PDL PDL_ImageND |
|
21
|
|
|
|
|
|
|
extern Core* PDL; /* Structure hold core C functions */ |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#line 1857 "lib/PDL/PP.pm" |
|
24
|
|
|
|
|
|
|
pdl_error pdl_contour_polylines_redodims(pdl_trans *__privtrans) { |
|
25
|
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
26
|
|
|
|
|
|
|
#line 27 "lib/PDL/ImageND-pp-contour_polylines.c" |
|
27
|
1
|
|
|
|
|
|
__privtrans->ind_sizes[3] = (__privtrans->ind_sizes[1]-1)*(__privtrans->ind_sizes[2]-1)*5; |
|
28
|
1
|
50
|
|
|
|
|
PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans)); |
|
29
|
1
|
|
|
|
|
|
return PDL_err; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#line 1857 "lib/PDL/PP.pm" |
|
34
|
|
|
|
|
|
|
pdl_error pdl_contour_polylines_readdata(pdl_trans *__privtrans) { |
|
35
|
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
36
|
|
|
|
|
|
|
#line 37 "lib/PDL/ImageND-pp-contour_polylines.c" |
|
37
|
1
|
|
|
|
|
|
register PDL_Indx __d_size = __privtrans->ind_sizes[0]; |
|
38
|
1
|
|
|
|
|
|
register PDL_Indx __m_size = __privtrans->ind_sizes[1]; |
|
39
|
1
|
|
|
|
|
|
register PDL_Indx __n_size = __privtrans->ind_sizes[2]; |
|
40
|
1
|
|
|
|
|
|
register PDL_Indx __q_size = __privtrans->ind_sizes[3]; |
|
41
|
1
|
50
|
|
|
|
|
if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in contour_polylines:" "broadcast.incs NULL"); |
|
42
|
|
|
|
|
|
|
/* broadcastloop declarations */ |
|
43
|
|
|
|
|
|
|
int __brcloopval; |
|
44
|
|
|
|
|
|
|
register PDL_Indx __tind0,__tind1; /* counters along dim */ |
|
45
|
1
|
|
|
|
|
|
register PDL_Indx __tnpdls = __privtrans->broadcast.npdls; |
|
46
|
|
|
|
|
|
|
/* dims here are how many steps along those dims */ |
|
47
|
1
|
|
|
|
|
|
register PDL_Indx __tinc0_c = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0); |
|
48
|
1
|
|
|
|
|
|
register PDL_Indx __tinc0_data = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0); |
|
49
|
1
|
|
|
|
|
|
register PDL_Indx __tinc0_points = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0); |
|
50
|
1
|
|
|
|
|
|
register PDL_Indx __tinc0_pathendindex = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,0); |
|
51
|
1
|
|
|
|
|
|
register PDL_Indx __tinc0_paths = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,4,0); |
|
52
|
1
|
|
|
|
|
|
register PDL_Indx __tinc0_seenmap = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,5,0); |
|
53
|
1
|
|
|
|
|
|
register PDL_Indx __tinc1_c = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1); |
|
54
|
1
|
|
|
|
|
|
register PDL_Indx __tinc1_data = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1); |
|
55
|
1
|
|
|
|
|
|
register PDL_Indx __tinc1_points = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1); |
|
56
|
1
|
|
|
|
|
|
register PDL_Indx __tinc1_pathendindex = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,1); |
|
57
|
1
|
|
|
|
|
|
register PDL_Indx __tinc1_paths = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,4,1); |
|
58
|
1
|
|
|
|
|
|
register PDL_Indx __tinc1_seenmap = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,5,1); |
|
59
|
|
|
|
|
|
|
#define PDL_BROADCASTLOOP_START_contour_polylines_readdata PDL_BROADCASTLOOP_START( \ |
|
60
|
|
|
|
|
|
|
readdata, \ |
|
61
|
|
|
|
|
|
|
__privtrans->broadcast, \ |
|
62
|
|
|
|
|
|
|
__privtrans->vtable, \ |
|
63
|
|
|
|
|
|
|
c_datap += __offsp[0]; \ |
|
64
|
|
|
|
|
|
|
data_datap += __offsp[1]; \ |
|
65
|
|
|
|
|
|
|
points_datap += __offsp[2]; \ |
|
66
|
|
|
|
|
|
|
pathendindex_datap += __offsp[3]; \ |
|
67
|
|
|
|
|
|
|
paths_datap += __offsp[4]; \ |
|
68
|
|
|
|
|
|
|
seenmap_datap += __offsp[5]; \ |
|
69
|
|
|
|
|
|
|
, \ |
|
70
|
|
|
|
|
|
|
( ,c_datap += __tinc1_c - __tinc0_c * __tdims0 \ |
|
71
|
|
|
|
|
|
|
,data_datap += __tinc1_data - __tinc0_data * __tdims0 \ |
|
72
|
|
|
|
|
|
|
,points_datap += __tinc1_points - __tinc0_points * __tdims0 \ |
|
73
|
|
|
|
|
|
|
,pathendindex_datap += __tinc1_pathendindex - __tinc0_pathendindex * __tdims0 \ |
|
74
|
|
|
|
|
|
|
,paths_datap += __tinc1_paths - __tinc0_paths * __tdims0 \ |
|
75
|
|
|
|
|
|
|
,seenmap_datap += __tinc1_seenmap - __tinc0_seenmap * __tdims0 \ |
|
76
|
|
|
|
|
|
|
), \ |
|
77
|
|
|
|
|
|
|
( ,c_datap += __tinc0_c \ |
|
78
|
|
|
|
|
|
|
,data_datap += __tinc0_data \ |
|
79
|
|
|
|
|
|
|
,points_datap += __tinc0_points \ |
|
80
|
|
|
|
|
|
|
,pathendindex_datap += __tinc0_pathendindex \ |
|
81
|
|
|
|
|
|
|
,paths_datap += __tinc0_paths \ |
|
82
|
|
|
|
|
|
|
,seenmap_datap += __tinc0_seenmap \ |
|
83
|
|
|
|
|
|
|
) \ |
|
84
|
|
|
|
|
|
|
) |
|
85
|
|
|
|
|
|
|
#define PDL_BROADCASTLOOP_END_contour_polylines_readdata PDL_BROADCASTLOOP_END( \ |
|
86
|
|
|
|
|
|
|
__privtrans->broadcast, \ |
|
87
|
|
|
|
|
|
|
c_datap -= __tinc1_c * __tdims1 + __offsp[0]; \ |
|
88
|
|
|
|
|
|
|
data_datap -= __tinc1_data * __tdims1 + __offsp[1]; \ |
|
89
|
|
|
|
|
|
|
points_datap -= __tinc1_points * __tdims1 + __offsp[2]; \ |
|
90
|
|
|
|
|
|
|
pathendindex_datap -= __tinc1_pathendindex * __tdims1 + __offsp[3]; \ |
|
91
|
|
|
|
|
|
|
paths_datap -= __tinc1_paths * __tdims1 + __offsp[4]; \ |
|
92
|
|
|
|
|
|
|
seenmap_datap -= __tinc1_seenmap * __tdims1 + __offsp[5]; \ |
|
93
|
|
|
|
|
|
|
) |
|
94
|
1
|
|
|
|
|
|
register PDL_Indx __inc_data_m = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,0)]; (void)__inc_data_m;register PDL_Indx __inc_data_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,1)]; (void)__inc_data_n; |
|
95
|
1
|
|
|
|
|
|
register PDL_Indx __inc_pathendindex_q = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,3,0)]; (void)__inc_pathendindex_q; |
|
96
|
1
|
|
|
|
|
|
register PDL_Indx __inc_paths_d = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,4,0)]; (void)__inc_paths_d;register PDL_Indx __inc_paths_q = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,4,1)]; (void)__inc_paths_q; |
|
97
|
1
|
|
|
|
|
|
register PDL_Indx __inc_points_d = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,2,0)]; (void)__inc_points_d;register PDL_Indx __inc_points_m = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,2,1)]; (void)__inc_points_m;register PDL_Indx __inc_points_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,2,2)]; (void)__inc_points_n; |
|
98
|
1
|
|
|
|
|
|
register PDL_Indx __inc_seenmap_m = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,5,0)]; (void)__inc_seenmap_m;register PDL_Indx __inc_seenmap_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,5,1)]; (void)__inc_seenmap_n; |
|
99
|
|
|
|
|
|
|
#ifndef PDL_DECLARE_PARAMS_contour_polylines_1 |
|
100
|
|
|
|
|
|
|
#define PDL_DECLARE_PARAMS_contour_polylines_1(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_pathendindex,PDL_PPSYM_PARAM_pathendindex,PDL_TYPE_PARAM_seenmap,PDL_PPSYM_PARAM_seenmap) \ |
|
101
|
|
|
|
|
|
|
PDL_DECLARE_PARAMETER(PDL_TYPE_OP, c, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \ |
|
102
|
|
|
|
|
|
|
PDL_DECLARE_PARAMETER(PDL_TYPE_OP, data, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) \ |
|
103
|
|
|
|
|
|
|
PDL_DECLARE_PARAMETER(PDL_TYPE_OP, points, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP) \ |
|
104
|
|
|
|
|
|
|
PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_pathendindex, pathendindex, (__privtrans->pdls[3]), 1, PDL_PPSYM_PARAM_pathendindex) \ |
|
105
|
|
|
|
|
|
|
PDL_DECLARE_PARAMETER(PDL_TYPE_OP, paths, (__privtrans->pdls[4]), 1, PDL_PPSYM_OP) \ |
|
106
|
|
|
|
|
|
|
PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_seenmap, seenmap, (__privtrans->pdls[5]), 1, PDL_PPSYM_PARAM_seenmap) |
|
107
|
|
|
|
|
|
|
#endif |
|
108
|
|
|
|
|
|
|
#define PDL_IF_BAD(t,f) f |
|
109
|
1
|
50
|
|
|
|
|
switch (__privtrans->__datatype) { /* Start generic switch */ |
|
110
|
1
|
|
|
|
|
|
case PDL_F: { |
|
111
|
1
|
50
|
|
|
|
|
PDL_DECLARE_PARAMS_contour_polylines_1(PDL_Float,F,PDL_Indx,N,PDL_Byte,B) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
112
|
1
|
|
|
|
|
|
{int dir2xy[4][2] = { /* 0 = east, 1 = south, 2 = west, 3 = north */ |
|
113
|
|
|
|
|
|
|
{1,0}, {0,1}, {-1,0}, {0,-1} |
|
114
|
|
|
|
|
|
|
}; |
|
115
|
4
|
50
|
|
|
|
|
PDL_BROADCASTLOOP_START_contour_polylines_readdata |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
|
PDL_Indx polyind = 0, p = 0; |
|
117
|
31
|
100
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {{/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) { (seenmap_datap)[0+(__inc_seenmap_m*(m))+(__inc_seenmap_n*(n))] = 0; }} /* Close n */}} /* Close m */ /* & 1 = east, & 2 = south */ |
|
|
|
100
|
|
|
|
|
|
|
118
|
81
|
100
|
|
|
|
|
{/* Open q */ PDL_EXPAND2(register PDL_Indx q=0, __q_stop=(__q_size)); for(; q<__q_stop; q+=1) { (pathendindex_datap)[0+(__inc_pathendindex_q*(q))] = -1; }} /* Close q */ |
|
119
|
|
|
|
|
|
|
#define PDL_DCALC(vname,c,x1,y1,x2,y2) \ |
|
120
|
|
|
|
|
|
|
PDL_Float vname = (c-(data_datap)[0+(__inc_data_m*(x1))+(__inc_data_n*(y1))])/((data_datap)[0+(__inc_data_m*(x2))+(__inc_data_n*(y2))]-(data_datap)[0+(__inc_data_m*(x1))+(__inc_data_n*(y1))]) |
|
121
|
|
|
|
|
|
|
#define PDL_PCALC(dname,d,x1,y1,x2,y2) \ |
|
122
|
|
|
|
|
|
|
((points_datap)[0+(__inc_points_d*(d))+(__inc_points_m*(x1))+(__inc_points_n*(y1))]+dname*((points_datap)[0+(__inc_points_d*(d))+(__inc_points_m*(x2))+(__inc_points_n*(y2))]-(points_datap)[0+(__inc_points_d*(d))+(__inc_points_m*(x1))+(__inc_points_n*(y1))])) |
|
123
|
|
|
|
|
|
|
#define PDL_LINEPOINT(x,y,dir,c,p) do { \ |
|
124
|
|
|
|
|
|
|
PDL_Indx x2 = x+dir2xy[dir][0], y2 = y+dir2xy[dir][1]; \ |
|
125
|
|
|
|
|
|
|
PDL_DCALC(dist,c,x,y,x2,y2); \ |
|
126
|
|
|
|
|
|
|
{/* Open d */ PDL_EXPAND2(register PDL_Indx d=0, __d_stop=(__d_size)); for(; d<__d_stop; d+=1) { (paths_datap)[0+(__inc_paths_d*(d))+(__inc_paths_q*(p))] = PDL_PCALC(dist,d,x,y,x2,y2); }} /* Close d */ \ |
|
127
|
|
|
|
|
|
|
p++; \ |
|
128
|
|
|
|
|
|
|
} while (0) |
|
129
|
|
|
|
|
|
|
#define PDL_CONTOUR_BREAK(x,y,dir,c) \ |
|
130
|
|
|
|
|
|
|
(x >= 0 && x < __privtrans->ind_sizes[1] && y >= 0 && y < __privtrans->ind_sizes[2] && \ |
|
131
|
|
|
|
|
|
|
(x+dir2xy[dir][0]) >= 0 && (x+dir2xy[dir][0]) < __privtrans->ind_sizes[1] && \ |
|
132
|
|
|
|
|
|
|
(y+dir2xy[dir][1]) >= 0 && (y+dir2xy[dir][1]) < __privtrans->ind_sizes[2] && \ |
|
133
|
|
|
|
|
|
|
!((dir == 0 && ((seenmap_datap)[0+(__inc_seenmap_m*(x))+(__inc_seenmap_n*(y))] & (1<
|
|
134
|
|
|
|
|
|
|
(dir == 1 && ((seenmap_datap)[0+(__inc_seenmap_m*(x))+(__inc_seenmap_n*(y))] & (1<
|
|
135
|
|
|
|
|
|
|
(dir == 2 && ((seenmap_datap)[0+(__inc_seenmap_m*(x-1))+(__inc_seenmap_n*(y))] & (1<<(dir % 2)))) || \ |
|
136
|
|
|
|
|
|
|
(dir == 3 && ((seenmap_datap)[0+(__inc_seenmap_m*(x))+(__inc_seenmap_n*(y-1))] & (1<<(dir % 2)))) \ |
|
137
|
|
|
|
|
|
|
) && \ |
|
138
|
|
|
|
|
|
|
(((data_datap)[0+(__inc_data_m*(x))+(__inc_data_n*(y))] < c) != ((data_datap)[0+(__inc_data_m*(x+dir2xy[dir][0]))+(__inc_data_n*(y+dir2xy[dir][1]))] < c))) |
|
139
|
31
|
100
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {{/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) { |
|
|
|
100
|
|
|
|
|
|
|
140
|
25
|
|
|
|
|
|
PDL_Indx m1=m+1, n1=n+1, linex=-1, liney=-1, linedir=-1; |
|
141
|
|
|
|
|
|
|
/* linedir is same as dir, but outside linex/y and facing clockwise */ |
|
142
|
25
|
50
|
|
|
|
|
char brk_ab = PDL_CONTOUR_BREAK(m,n,0,(c_datap)[0]), |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
143
|
25
|
50
|
|
|
|
|
brk_ad = PDL_CONTOUR_BREAK(m,n,1,(c_datap)[0]), |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
144
|
25
|
50
|
|
|
|
|
brk_be = PDL_CONTOUR_BREAK(m1,n,1,(c_datap)[0]), |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
145
|
25
|
50
|
|
|
|
|
brk_cd = PDL_CONTOUR_BREAK(m,n1,2,(c_datap)[0]), /* actually dc */ |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
146
|
25
|
50
|
|
|
|
|
brk_de = PDL_CONTOUR_BREAK(m,n1,0,(c_datap)[0]); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
147
|
25
|
50
|
|
|
|
|
if (brk_ab && (brk_ad || brk_de || brk_be)) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
linex = m, liney = n, linedir = 1; |
|
149
|
|
|
|
|
|
|
else |
|
150
|
25
|
|
|
|
|
|
(seenmap_datap)[0+(__inc_seenmap_m*(m))+(__inc_seenmap_n*(n))] |= 1; |
|
151
|
25
|
50
|
|
|
|
|
if (linedir < 0 && brk_ad && brk_cd) |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
152
|
2
|
|
|
|
|
|
linex = m, liney = n, linedir = 2; |
|
153
|
25
|
100
|
|
|
|
|
if (linedir < 0 && brk_ad && (brk_de || brk_be)) |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
linex = m, liney = n1, linedir = 0; |
|
155
|
25
|
100
|
|
|
|
|
if (linedir < 0) { (seenmap_datap)[0+(__inc_seenmap_m*(m))+(__inc_seenmap_n*(n))] |= 2; continue; } |
|
156
|
2
|
|
|
|
|
|
PDL_Indx startlinex=linex, startliney=liney, startlinedir=linedir; |
|
157
|
2
|
|
|
|
|
|
PDL_Float startmidx=linex+0.5*dir2xy[(linedir+3)%4][0], startmidy=liney+0.5*dir2xy[(linedir+3)%4][1]; /* of the line-segment */ |
|
158
|
2
|
|
|
|
|
|
PDL_Float startbackx=startmidx+0.5*dir2xy[(linedir+2)%4][0], startbacky=startmidy+0.5*dir2xy[(linedir+2)%4][1]; |
|
159
|
|
|
|
|
|
|
/* walk the line */ |
|
160
|
14
|
|
|
|
|
|
while (1) { |
|
161
|
48
|
100
|
|
|
|
|
PDL_LINEPOINT(linex,liney,(linedir+3)%4,(c_datap)[0],p); |
|
162
|
16
|
|
|
|
|
|
switch (linedir) { |
|
163
|
4
|
|
|
|
|
|
case 0: (seenmap_datap)[0+(__inc_seenmap_m*(linex))+(__inc_seenmap_n*(liney-1))] |= (1<<((linedir+1)%2)); break; |
|
164
|
4
|
|
|
|
|
|
case 1: (seenmap_datap)[0+(__inc_seenmap_m*(linex))+(__inc_seenmap_n*(liney))] |= (1<<((linedir+1)%2)); break; |
|
165
|
4
|
|
|
|
|
|
case 2: (seenmap_datap)[0+(__inc_seenmap_m*(linex))+(__inc_seenmap_n*(liney))] |= (1<<((linedir+1)%2)); break; |
|
166
|
4
|
|
|
|
|
|
case 3: (seenmap_datap)[0+(__inc_seenmap_m*(linex-1))+(__inc_seenmap_n*(liney))] |= (1<<((linedir+1)%2)); break; |
|
167
|
0
|
|
|
|
|
|
default: return PDL->make_error(PDL_EUSERERROR, "Error in contour_polylines:" "linedir had invalid value %"IND_FLAG,linedir); |
|
168
|
|
|
|
|
|
|
} |
|
169
|
16
|
50
|
|
|
|
|
char brk_right = PDL_CONTOUR_BREAK(linex,liney,linedir,(c_datap)[0]), |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
170
|
16
|
50
|
|
|
|
|
brk_straight = PDL_CONTOUR_BREAK(linex+dir2xy[linedir][0],liney+dir2xy[linedir][1],(linedir+3)%4,(c_datap)[0]), |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
171
|
16
|
50
|
|
|
|
|
brk_left = PDL_CONTOUR_BREAK(linex+dir2xy[(linedir+3)%4][0],liney+dir2xy[(linedir+3)%4][1],linedir,(c_datap)[0]); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
172
|
16
|
100
|
|
|
|
|
if (brk_right) { |
|
173
|
2
|
|
|
|
|
|
linedir = (linedir+1)%4; |
|
174
|
2
|
|
|
|
|
|
continue; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
14
|
100
|
|
|
|
|
if (brk_straight) { |
|
177
|
4
|
|
|
|
|
|
linex += dir2xy[linedir][0], liney += dir2xy[linedir][1]; |
|
178
|
4
|
|
|
|
|
|
continue; |
|
179
|
|
|
|
|
|
|
} |
|
180
|
10
|
100
|
|
|
|
|
if (brk_left) { |
|
181
|
8
|
|
|
|
|
|
linex += dir2xy[linedir][0], liney += dir2xy[linedir][1]; /* step with */ |
|
182
|
8
|
|
|
|
|
|
linedir = (linedir+3)%4; |
|
183
|
8
|
|
|
|
|
|
linex += dir2xy[linedir][0], liney += dir2xy[linedir][1]; /* and left */ |
|
184
|
8
|
|
|
|
|
|
continue; |
|
185
|
|
|
|
|
|
|
} |
|
186
|
2
|
|
|
|
|
|
break; |
|
187
|
|
|
|
|
|
|
} |
|
188
|
2
|
|
|
|
|
|
PDL_Float endmidx=linex+0.5*dir2xy[(linedir+3)%4][0], endmidy=liney+0.5*dir2xy[(linedir+3)%4][1]; |
|
189
|
2
|
|
|
|
|
|
PDL_Float endfrontx=endmidx+0.5*dir2xy[linedir][0], endfronty=endmidy+0.5*dir2xy[linedir][1]; |
|
190
|
2
|
50
|
|
|
|
|
if (endfrontx == startbackx && endfronty == startbacky) /* close polygon */ |
|
|
|
50
|
|
|
|
|
|
|
191
|
6
|
100
|
|
|
|
|
PDL_LINEPOINT(startlinex,startliney,(startlinedir+3)%4,(c_datap)[0],p); |
|
192
|
2
|
|
|
|
|
|
(pathendindex_datap)[0+(__inc_pathendindex_q*(polyind++))] = p - 1; |
|
193
|
|
|
|
|
|
|
}} /* Close n */}} /* Close m */ |
|
194
|
1
|
50
|
|
|
|
|
PDL_BROADCASTLOOP_END_contour_polylines_readdata |
|
|
|
50
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
#undef PDL_DCALC |
|
196
|
|
|
|
|
|
|
#undef PDL_PCALC |
|
197
|
|
|
|
|
|
|
#undef PDL_LINEPOINT |
|
198
|
|
|
|
|
|
|
#undef PDL_CONTOUR_BREAK |
|
199
|
|
|
|
|
|
|
} |
|
200
|
1
|
|
|
|
|
|
} break; |
|
201
|
0
|
|
|
|
|
|
default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in contour_polylines: unhandled datatype(%d), only handles (F)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype); |
|
202
|
|
|
|
|
|
|
} |
|
203
|
|
|
|
|
|
|
#undef PDL_IF_BAD |
|
204
|
1
|
|
|
|
|
|
return PDL_err; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
static pdl_datatypes pdl_contour_polylines_vtable_gentypes[] = { PDL_F, -1 }; |
|
208
|
|
|
|
|
|
|
static PDL_Indx pdl_contour_polylines_vtable_realdims[] = { 0, 2, 3, 1, 2, 2 }; |
|
209
|
|
|
|
|
|
|
static char *pdl_contour_polylines_vtable_parnames[] = { "c","data","points","pathendindex","paths","seenmap" }; |
|
210
|
|
|
|
|
|
|
static short pdl_contour_polylines_vtable_parflags[] = { |
|
211
|
|
|
|
|
|
|
0, |
|
212
|
|
|
|
|
|
|
0, |
|
213
|
|
|
|
|
|
|
0, |
|
214
|
|
|
|
|
|
|
PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISTYPED|PDL_PARAM_ISWRITE, |
|
215
|
|
|
|
|
|
|
PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE, |
|
216
|
|
|
|
|
|
|
PDL_PARAM_ISCREAT|PDL_PARAM_ISTEMP|PDL_PARAM_ISTYPED|PDL_PARAM_ISWRITE |
|
217
|
|
|
|
|
|
|
}; |
|
218
|
|
|
|
|
|
|
static pdl_datatypes pdl_contour_polylines_vtable_partypes[] = { -1, -1, -1, PDL_IND, -1, PDL_B }; |
|
219
|
|
|
|
|
|
|
static PDL_Indx pdl_contour_polylines_vtable_realdims_starts[] = { 0, 0, 2, 5, 6, 8 }; |
|
220
|
|
|
|
|
|
|
static PDL_Indx pdl_contour_polylines_vtable_realdims_ind_ids[] = { 1, 2, 0, 1, 2, 3, 0, 3, 1, 2 }; |
|
221
|
|
|
|
|
|
|
static char *pdl_contour_polylines_vtable_indnames[] = { "d","m","n","q" }; |
|
222
|
|
|
|
|
|
|
pdl_transvtable pdl_contour_polylines_vtable = { |
|
223
|
|
|
|
|
|
|
PDL_TRANS_DO_BROADCAST, 0, pdl_contour_polylines_vtable_gentypes, 3, 6, NULL /*CORE21*/, |
|
224
|
|
|
|
|
|
|
pdl_contour_polylines_vtable_realdims, pdl_contour_polylines_vtable_parnames, |
|
225
|
|
|
|
|
|
|
pdl_contour_polylines_vtable_parflags, pdl_contour_polylines_vtable_partypes, |
|
226
|
|
|
|
|
|
|
pdl_contour_polylines_vtable_realdims_starts, pdl_contour_polylines_vtable_realdims_ind_ids, 10, |
|
227
|
|
|
|
|
|
|
4, pdl_contour_polylines_vtable_indnames, |
|
228
|
|
|
|
|
|
|
pdl_contour_polylines_redodims, pdl_contour_polylines_readdata, NULL, |
|
229
|
|
|
|
|
|
|
NULL, |
|
230
|
|
|
|
|
|
|
0,"PDL::ImageND::contour_polylines" |
|
231
|
|
|
|
|
|
|
}; |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
|
|
234
|
1
|
|
|
|
|
|
pdl_error pdl_run_contour_polylines(pdl *c,pdl *data,pdl *points,pdl *pathendindex,pdl *paths) { |
|
235
|
1
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
236
|
1
|
50
|
|
|
|
|
if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0}; |
|
237
|
1
|
|
|
|
|
|
pdl_trans *__privtrans = PDL->create_trans(&pdl_contour_polylines_vtable); |
|
238
|
1
|
50
|
|
|
|
|
if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans"); |
|
239
|
1
|
|
|
|
|
|
__privtrans->pdls[0] = c; |
|
240
|
1
|
|
|
|
|
|
__privtrans->pdls[1] = data; |
|
241
|
1
|
|
|
|
|
|
__privtrans->pdls[2] = points; |
|
242
|
1
|
|
|
|
|
|
__privtrans->pdls[3] = pathendindex; |
|
243
|
1
|
|
|
|
|
|
__privtrans->pdls[4] = paths; |
|
244
|
1
|
50
|
|
|
|
|
PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); |
|
245
|
1
|
50
|
|
|
|
|
PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans)); |
|
246
|
1
|
|
|
|
|
|
return PDL_err; |
|
247
|
|
|
|
|
|
|
} |