File Coverage

pp-plot3d.c
Criterion Covered Total %
statement 42 43 97.6
branch 36 64 56.2
condition n/a
subroutine n/a
pod n/a
total 78 107 72.9


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 plplot.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_Graphics_PLplot
21             extern Core* PDL; /* Structure hold core C functions */
22             #line 23 "pp-plot3d.c"
23             #include
24             #include
25             #include
26             #include
27              
28             #ifndef PDL /* this is needed for PDL pre-2.058 */
29             #define PDL PDL_Graphics_PLplot
30             Core* PDL = NULL; PDL_COMMENT("Structure hold core C functions")
31             #endif
32              
33             #define PLPTR_DEFINE(t) typedef t *t ## Ptr; typedef t *t ## Ptr__OUT;
34             PLPTR_DEFINE(PLcGrid)
35             PLPTR_DEFINE(PLcGrid2)
36             #define PLPTR_RECEIVE_IN(t, v, v_in) t *v = (t *)v_in;
37             #define PLPTR_RECEIVE_SV(v) ((PLPointer) (SvROK(v) ? SvIV((SV*)SvRV(v)) : (IV)NULL))
38              
39             void pltr_iv_set(IV iv0, IV iv1, IV iv2);
40             void pltr_callback_set(SV *sv, char *msg);
41             void pltr_callback(PLFLT x, PLFLT y, PLFLT* tx, PLFLT* ty, PLPointer pltr_data);
42             void* get_standard_pltrcb(SV* cb);
43             void defined_callback_set(SV *sv, char *msg);
44             PLINT defined_callback(PLFLT x, PLFLT y);
45             void default_magic(pdl *p, size_t pa);
46             void mapform_callback_set(SV *sv, char *msg);
47             void mapform_callback(PLINT n, PLFLT* x, PLFLT* y);
48             void xform_callback_set(SV *sv, char *msg);
49             void xform_callback(PLFLT x, PLFLT y, PLFLT *xt, PLFLT *yt, PLPointer data);
50             void labelfunc_callback_set(SV *sv, char *msg);
51             void labelfunc_callback(PLINT axis, PLFLT value, char *label_text, PLINT length, void *data);
52              
53             #line 1857 "lib/PDL/PP.pm"
54             pdl_error pdl_plot3d_readdata(pdl_trans *__privtrans) {
55             pdl_error PDL_err = {0, NULL, 0};
56             #line 57 "pp-plot3d.c"
57 2 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in plot3d:" "broadcast.incs NULL");
58             /* broadcastloop declarations */
59             int __brcloopval;
60             register PDL_Indx __tind0,__tind1; /* counters along dim */
61 2           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
62             /* dims here are how many steps along those dims */
63 2           register PDL_Indx __tinc0_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
64 2           register PDL_Indx __tinc0_y = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
65 2           register PDL_Indx __tinc0_z = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0);
66 2           register PDL_Indx __tinc0_opt = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,0);
67 2           register PDL_Indx __tinc0_side = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,4,0);
68 2           register PDL_Indx __tinc1_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
69 2           register PDL_Indx __tinc1_y = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
70 2           register PDL_Indx __tinc1_z = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1);
71 2           register PDL_Indx __tinc1_opt = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,1);
72 2           register PDL_Indx __tinc1_side = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,4,1);
73             #define PDL_BROADCASTLOOP_START_plot3d_readdata PDL_BROADCASTLOOP_START( \
74             readdata, \
75             __privtrans->broadcast, \
76             __privtrans->vtable, \
77             x_datap += __offsp[0]; \
78             y_datap += __offsp[1]; \
79             z_datap += __offsp[2]; \
80             opt_datap += __offsp[3]; \
81             side_datap += __offsp[4]; \
82             , \
83             ( ,x_datap += __tinc1_x - __tinc0_x * __tdims0 \
84             ,y_datap += __tinc1_y - __tinc0_y * __tdims0 \
85             ,z_datap += __tinc1_z - __tinc0_z * __tdims0 \
86             ,opt_datap += __tinc1_opt - __tinc0_opt * __tdims0 \
87             ,side_datap += __tinc1_side - __tinc0_side * __tdims0 \
88             ), \
89             ( ,x_datap += __tinc0_x \
90             ,y_datap += __tinc0_y \
91             ,z_datap += __tinc0_z \
92             ,opt_datap += __tinc0_opt \
93             ,side_datap += __tinc0_side \
94             ) \
95             )
96             #define PDL_BROADCASTLOOP_END_plot3d_readdata PDL_BROADCASTLOOP_END( \
97             __privtrans->broadcast, \
98             x_datap -= __tinc1_x * __tdims1 + __offsp[0]; \
99             y_datap -= __tinc1_y * __tdims1 + __offsp[1]; \
100             z_datap -= __tinc1_z * __tdims1 + __offsp[2]; \
101             opt_datap -= __tinc1_opt * __tdims1 + __offsp[3]; \
102             side_datap -= __tinc1_side * __tdims1 + __offsp[4]; \
103             )
104 2           register PDL_Indx __inc_x_nx = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_x_nx;
105 2           register PDL_Indx __inc_y_ny = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,0)]; (void)__inc_y_ny;
106 2           register PDL_Indx __inc_z_nx = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,2,0)]; (void)__inc_z_nx;register PDL_Indx __inc_z_ny = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,2,1)]; (void)__inc_z_ny;
107             #ifndef PDL_DECLARE_PARAMS_plot3d_1
108             #define PDL_DECLARE_PARAMS_plot3d_1(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_opt,PDL_PPSYM_PARAM_opt,PDL_TYPE_PARAM_side,PDL_PPSYM_PARAM_side) \
109             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, x, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
110             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, y, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) \
111             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, z, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP) \
112             PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_opt, opt, (__privtrans->pdls[3]), 1, PDL_PPSYM_PARAM_opt) \
113             PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_side, side, (__privtrans->pdls[4]), 1, PDL_PPSYM_PARAM_side)
114             #endif
115             #define PDL_IF_BAD(t,f) f
116 2 50         switch (__privtrans->__datatype) { /* Start generic switch */
117 2           case PDL_D: {
118 2 50         PDL_DECLARE_PARAMS_plot3d_1(PDL_Double,D,PDL_Long,L,PDL_Long,L)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
119 8 50         PDL_BROADCASTLOOP_START_plot3d_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
120             int i, j, size_x, size_y;
121             PLFLT** zz;
122              
123 2           size_x = __privtrans->ind_sizes[0];
124 2           size_y = __privtrans->ind_sizes[1];
125              
126 2           plAlloc2dGrid (&zz, size_x, size_y);
127              
128 72 100         for (i = 0; i < size_x; i++)
129 3290 100         for (j = 0; j < size_y; j++)
130 3220           zz[i][j] = (z_datap)[0+(__inc_z_nx*(i))+(__inc_z_ny*(j))];
131              
132 2           c_plot3d (x_datap, y_datap, (const PLFLT **)zz, size_x, size_y, (opt_datap)[0], (side_datap)[0]);
133              
134 4 50         plFree2dGrid (zz, size_x, size_y);}PDL_BROADCASTLOOP_END_plot3d_readdata
    50          
135 2           } break;
136 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in plot3d: unhandled datatype(%d), only handles (D)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
137             }
138             #undef PDL_IF_BAD
139 2           return PDL_err;
140             }
141              
142             static pdl_datatypes pdl_plot3d_vtable_gentypes[] = { PDL_D, -1 };
143             static PDL_Indx pdl_plot3d_vtable_realdims[] = { 1, 1, 2, 0, 0 };
144             static char *pdl_plot3d_vtable_parnames[] = { "x","y","z","opt","side" };
145             static short pdl_plot3d_vtable_parflags[] = {
146             PDL_PARAM_ISPHYS,
147             PDL_PARAM_ISPHYS,
148             0,
149             PDL_PARAM_ISTYPED,
150             PDL_PARAM_ISTYPED
151             };
152             static pdl_datatypes pdl_plot3d_vtable_partypes[] = { -1, -1, -1, PDL_L, PDL_L };
153             static PDL_Indx pdl_plot3d_vtable_realdims_starts[] = { 0, 1, 2, 4, 4 };
154             static PDL_Indx pdl_plot3d_vtable_realdims_ind_ids[] = { 0, 1, 0, 1 };
155             static char *pdl_plot3d_vtable_indnames[] = { "nx","ny" };
156             pdl_transvtable pdl_plot3d_vtable = {
157             PDL_TRANS_DO_BROADCAST|PDL_TRANS_NO_PARALLEL, 0, pdl_plot3d_vtable_gentypes, 5, 5, NULL /*CORE21*/,
158             pdl_plot3d_vtable_realdims, pdl_plot3d_vtable_parnames,
159             pdl_plot3d_vtable_parflags, pdl_plot3d_vtable_partypes,
160             pdl_plot3d_vtable_realdims_starts, pdl_plot3d_vtable_realdims_ind_ids, 4,
161             2, pdl_plot3d_vtable_indnames,
162             NULL, pdl_plot3d_readdata, NULL,
163             NULL,
164             0,"PDL::Graphics::PLplot::plot3d"
165             };
166              
167              
168 2           pdl_error pdl_run_plot3d(pdl *x,pdl *y,pdl *z,pdl *opt,pdl *side) {
169 2           pdl_error PDL_err = {0, NULL, 0};
170 2 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
171 2           pdl_trans *__privtrans = PDL->create_trans(&pdl_plot3d_vtable);
172 2 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
173 2           __privtrans->pdls[0] = x;
174 2           __privtrans->pdls[1] = y;
175 2           __privtrans->pdls[2] = z;
176 2           __privtrans->pdls[3] = opt;
177 2           __privtrans->pdls[4] = side;
178 2 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
179 2 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
180 2           return PDL_err;
181             }