Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
d6008a8b
Commit
d6008a8b
authored
Sep 11, 2007
by
Rafaël Carré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reverts [21943] for galaktos as it is external to vlc.
Just in case it is merged one day with upstream source.
parent
c6eafbbb
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
2074 additions
and
2074 deletions
+2074
-2074
modules/visualization/galaktos/PCM.c
modules/visualization/galaktos/PCM.c
+25
-25
modules/visualization/galaktos/beat_detect.c
modules/visualization/galaktos/beat_detect.c
+55
-55
modules/visualization/galaktos/builtin_funcs.c
modules/visualization/galaktos/builtin_funcs.c
+47
-47
modules/visualization/galaktos/builtin_funcs.h
modules/visualization/galaktos/builtin_funcs.h
+1
-1
modules/visualization/galaktos/common.h
modules/visualization/galaktos/common.h
+1
-1
modules/visualization/galaktos/custom_shape.c
modules/visualization/galaktos/custom_shape.c
+25
-25
modules/visualization/galaktos/custom_shape_types.h
modules/visualization/galaktos/custom_shape_types.h
+3
-3
modules/visualization/galaktos/custom_wave.c
modules/visualization/galaktos/custom_wave.c
+62
-62
modules/visualization/galaktos/custom_wave_types.h
modules/visualization/galaktos/custom_wave_types.h
+2
-2
modules/visualization/galaktos/engine_vars.c
modules/visualization/galaktos/engine_vars.c
+1
-1
modules/visualization/galaktos/engine_vars.h
modules/visualization/galaktos/engine_vars.h
+1
-1
modules/visualization/galaktos/eval.c
modules/visualization/galaktos/eval.c
+313
-313
modules/visualization/galaktos/eval.h
modules/visualization/galaktos/eval.h
+1
-1
modules/visualization/galaktos/expr_types.h
modules/visualization/galaktos/expr_types.h
+1
-1
modules/visualization/galaktos/fftsg.c
modules/visualization/galaktos/fftsg.c
+93
-93
modules/visualization/galaktos/func.c
modules/visualization/galaktos/func.c
+17
-17
modules/visualization/galaktos/func_types.h
modules/visualization/galaktos/func_types.h
+1
-1
modules/visualization/galaktos/init_cond.c
modules/visualization/galaktos/init_cond.c
+57
-57
modules/visualization/galaktos/param.c
modules/visualization/galaktos/param.c
+211
-211
modules/visualization/galaktos/param.h
modules/visualization/galaktos/param.h
+4
-4
modules/visualization/galaktos/param_types.h
modules/visualization/galaktos/param_types.h
+3
-3
modules/visualization/galaktos/parser.c
modules/visualization/galaktos/parser.c
+484
-484
modules/visualization/galaktos/per_frame_eqn.c
modules/visualization/galaktos/per_frame_eqn.c
+29
-29
modules/visualization/galaktos/per_pixel_eqn.c
modules/visualization/galaktos/per_pixel_eqn.c
+54
-54
modules/visualization/galaktos/per_pixel_eqn_types.h
modules/visualization/galaktos/per_pixel_eqn_types.h
+2
-2
modules/visualization/galaktos/per_point_types.h
modules/visualization/galaktos/per_point_types.h
+1
-1
modules/visualization/galaktos/preset.c
modules/visualization/galaktos/preset.c
+184
-184
modules/visualization/galaktos/preset_types.h
modules/visualization/galaktos/preset_types.h
+4
-4
modules/visualization/galaktos/splaytree.c
modules/visualization/galaktos/splaytree.c
+327
-327
modules/visualization/galaktos/tree_types.c
modules/visualization/galaktos/tree_types.c
+30
-30
modules/visualization/galaktos/video_init.c
modules/visualization/galaktos/video_init.c
+35
-35
No files found.
modules/visualization/galaktos/PCM.c
View file @
d6008a8b
...
@@ -48,13 +48,13 @@ int new; //how many new samples
...
@@ -48,13 +48,13 @@ int new; //how many new samples
void
initPCM
(
int
samples
)
void
initPCM
(
int
samples
)
{
{
int
i
;
int
i
;
//Allocate memory for PCM data buffer
//Allocate memory for PCM data buffer
PCMd
=
(
double
**
)
malloc
(
2
*
sizeof
(
double
*
));
PCMd
=
(
double
**
)
malloc
(
2
*
sizeof
(
double
*
));
PCMd
[
0
]
=
(
double
*
)
malloc
(
samples
*
sizeof
(
double
));
PCMd
[
0
]
=
(
double
*
)
malloc
(
samples
*
sizeof
(
double
));
PCMd
[
1
]
=
(
double
*
)
malloc
(
samples
*
sizeof
(
double
));
PCMd
[
1
]
=
(
double
*
)
malloc
(
samples
*
sizeof
(
double
));
maxsamples
=
samples
;
maxsamples
=
samples
;
new
=
0
;
new
=
0
;
...
@@ -83,15 +83,15 @@ void addPCM(int16_t PCMdata[2][512])
...
@@ -83,15 +83,15 @@ void addPCM(int16_t PCMdata[2][512])
int
i
,
j
;
int
i
,
j
;
int
samples
=
512
;
int
samples
=
512
;
for
(
i
=
0
;
i
<
samples
;
i
++
)
for
(
i
=
0
;
i
<
samples
;
i
++
)
{
{
j
=
i
+
start
;
j
=
i
+
start
;
PCMd
[
0
][
j
%
maxsamples
]
=
(
PCMdata
[
0
][
i
]
/
16384
.
0
);
PCMd
[
0
][
j
%
maxsamples
]
=
(
PCMdata
[
0
][
i
]
/
16384
.
0
);
PCMd
[
1
][
j
%
maxsamples
]
=
(
PCMdata
[
1
][
i
]
/
16384
.
0
);
PCMd
[
1
][
j
%
maxsamples
]
=
(
PCMdata
[
1
][
i
]
/
16384
.
0
);
}
}
// printf("Added %d samples %d %d %f\n",samples,start,(start+samples)%maxsamples,PCM[0][start+10]);
// printf("Added %d samples %d %d %f\n",samples,start,(start+samples)%maxsamples,PCM[0][start+10]);
start
+=
samples
;
start
+=
samples
;
start
=
start
%
maxsamples
;
start
=
start
%
maxsamples
;
...
@@ -113,28 +113,28 @@ void addPCM(int16_t PCMdata[2][512])
...
@@ -113,28 +113,28 @@ void addPCM(int16_t PCMdata[2][512])
void
getPCM
(
double
*
PCMdata
,
int
samples
,
int
channel
,
int
freq
,
double
smoothing
,
int
derive
)
void
getPCM
(
double
*
PCMdata
,
int
samples
,
int
channel
,
int
freq
,
double
smoothing
,
int
derive
)
{
{
int
i
,
index
;
int
i
,
index
;
index
=
start
-
1
;
index
=
start
-
1
;
if
(
index
<
0
)
index
=
maxsamples
+
index
;
if
(
index
<
0
)
index
=
maxsamples
+
index
;
PCMdata
[
0
]
=
PCMd
[
channel
][
index
];
PCMdata
[
0
]
=
PCMd
[
channel
][
index
];
for
(
i
=
1
;
i
<
samples
;
i
++
)
for
(
i
=
1
;
i
<
samples
;
i
++
)
{
{
index
=
start
-
1
-
i
;
index
=
start
-
1
-
i
;
if
(
index
<
0
)
index
=
maxsamples
+
index
;
if
(
index
<
0
)
index
=
maxsamples
+
index
;
PCMdata
[
i
]
=
(
1
-
smoothing
)
*
PCMd
[
channel
][
index
]
+
smoothing
*
PCMdata
[
i
-
1
];
PCMdata
[
i
]
=
(
1
-
smoothing
)
*
PCMd
[
channel
][
index
]
+
smoothing
*
PCMdata
[
i
-
1
];
}
}
//return derivative of PCM data
//return derivative of PCM data
if
(
derive
)
if
(
derive
)
{
{
for
(
i
=
0
;
i
<
samples
-
1
;
i
++
)
for
(
i
=
0
;
i
<
samples
-
1
;
i
++
)
{
{
PCMdata
[
i
]
=
PCMdata
[
i
]
-
PCMdata
[
i
+
1
];
PCMdata
[
i
]
=
PCMdata
[
i
]
-
PCMdata
[
i
+
1
];
}
}
PCMdata
[
samples
-
1
]
=
0
;
PCMdata
[
samples
-
1
]
=
0
;
}
}
...
@@ -142,7 +142,7 @@ void getPCM(double *PCMdata, int samples, int channel, int freq, double smoothin
...
@@ -142,7 +142,7 @@ void getPCM(double *PCMdata, int samples, int channel, int freq, double smoothin
if
(
freq
)
rdft
(
samples
,
1
,
PCMdata
,
ip
,
w
);
if
(
freq
)
rdft
(
samples
,
1
,
PCMdata
,
ip
,
w
);
}
}
//getPCMnew
//getPCMnew
...
@@ -154,28 +154,28 @@ void getPCM(double *PCMdata, int samples, int channel, int freq, double smoothin
...
@@ -154,28 +154,28 @@ void getPCM(double *PCMdata, int samples, int channel, int freq, double smoothin
int
getPCMnew
(
double
*
PCMdata
,
int
channel
,
int
freq
,
double
smoothing
,
int
derive
,
int
reset
)
int
getPCMnew
(
double
*
PCMdata
,
int
channel
,
int
freq
,
double
smoothing
,
int
derive
,
int
reset
)
{
{
int
i
,
index
;
int
i
,
index
;
index
=
start
-
1
;
index
=
start
-
1
;
if
(
index
<
0
)
index
=
maxsamples
+
index
;
if
(
index
<
0
)
index
=
maxsamples
+
index
;
PCMdata
[
0
]
=
PCMd
[
channel
][
index
];
PCMdata
[
0
]
=
PCMd
[
channel
][
index
];
for
(
i
=
1
;
i
<
new
;
i
++
)
for
(
i
=
1
;
i
<
new
;
i
++
)
{
{
index
=
start
-
1
-
i
;
index
=
start
-
1
-
i
;
if
(
index
<
0
)
index
=
maxsamples
+
index
;
if
(
index
<
0
)
index
=
maxsamples
+
index
;
PCMdata
[
i
]
=
(
1
-
smoothing
)
*
PCMd
[
channel
][
index
]
+
smoothing
*
PCMdata
[
i
-
1
];
PCMdata
[
i
]
=
(
1
-
smoothing
)
*
PCMd
[
channel
][
index
]
+
smoothing
*
PCMdata
[
i
-
1
];
}
}
//return derivative of PCM data
//return derivative of PCM data
if
(
derive
)
if
(
derive
)
{
{
for
(
i
=
0
;
i
<
new
-
1
;
i
++
)
for
(
i
=
0
;
i
<
new
-
1
;
i
++
)
{
{
PCMdata
[
i
]
=
PCMdata
[
i
]
-
PCMdata
[
i
+
1
];
PCMdata
[
i
]
=
PCMdata
[
i
]
-
PCMdata
[
i
+
1
];
}
}
PCMdata
[
new
-
1
]
=
0
;
PCMdata
[
new
-
1
]
=
0
;
}
}
...
...
modules/visualization/galaktos/beat_detect.c
View file @
d6008a8b
...
@@ -41,7 +41,7 @@ double vol_buffer[80],vol_instant,vol_history;
...
@@ -41,7 +41,7 @@ double vol_buffer[80],vol_instant,vol_history;
void
initBeatDetect
()
void
initBeatDetect
()
{
{
int
x
,
y
;
int
x
,
y
;
vol_instant
=
0
;
vol_instant
=
0
;
vol_history
=
0
;
vol_history
=
0
;
...
@@ -65,12 +65,12 @@ void initBeatDetect()
...
@@ -65,12 +65,12 @@ void initBeatDetect()
beat_att
[
x
]
=
1
.
0
;
beat_att
[
x
]
=
1
.
0
;
beat_variance
[
x
]
=
0
;
beat_variance
[
x
]
=
0
;
for
(
y
=
0
;
y
<
80
;
y
++
)
for
(
y
=
0
;
y
<
80
;
y
++
)
{
{
beat_buffer
[
x
][
y
]
=
0
;
beat_buffer
[
x
][
y
]
=
0
;
}
}
}
}
}
}
void
getBeatVals
(
double
*
vdataL
,
double
*
vdataR
,
double
*
vol
)
void
getBeatVals
(
double
*
vdataL
,
double
*
vdataR
,
double
*
vol
)
{
{
...
@@ -80,29 +80,29 @@ void getBeatVals(double *vdataL,double *vdataR, double *vol)
...
@@ -80,29 +80,29 @@ void getBeatVals(double *vdataL,double *vdataR, double *vol)
vol_instant
=
0
;
vol_instant
=
0
;
for
(
x
=
0
;
x
<
16
;
x
++
)
for
(
x
=
0
;
x
<
16
;
x
++
)
{
{
beat_instant
[
x
]
=
0
;
beat_instant
[
x
]
=
0
;
for
(
y
=
linear
*
2
;
y
<
(
linear
+
8
+
x
)
*
2
;
y
++
)
for
(
y
=
linear
*
2
;
y
<
(
linear
+
8
+
x
)
*
2
;
y
++
)
{
{
beat_instant
[
x
]
+=
((
vdataL
[
y
]
*
vdataL
[
y
])
+
(
vdataR
[
y
]
*
vdataR
[
y
]))
*
(
1
.
0
/
(
8
+
x
));
beat_instant
[
x
]
+=
((
vdataL
[
y
]
*
vdataL
[
y
])
+
(
vdataR
[
y
]
*
vdataR
[
y
]))
*
(
1
.
0
/
(
8
+
x
));
vol_instant
+=
((
vdataL
[
y
]
*
vdataL
[
y
])
+
(
vdataR
[
y
]
*
vdataR
[
y
]))
*
(
1
.
0
/
512
.
0
);
vol_instant
+=
((
vdataL
[
y
]
*
vdataL
[
y
])
+
(
vdataR
[
y
]
*
vdataR
[
y
]))
*
(
1
.
0
/
512
.
0
);
}
}
linear
=
y
/
2
;
linear
=
y
/
2
;
beat_history
[
x
]
-=
(
beat_buffer
[
x
][
beat_buffer_pos
])
*
.
0125
;
beat_history
[
x
]
-=
(
beat_buffer
[
x
][
beat_buffer_pos
])
*
.
0125
;
beat_buffer
[
x
][
beat_buffer_pos
]
=
beat_instant
[
x
];
beat_buffer
[
x
][
beat_buffer_pos
]
=
beat_instant
[
x
];
beat_history
[
x
]
+=
(
beat_instant
[
x
])
*
.
0125
;
beat_history
[
x
]
+=
(
beat_instant
[
x
])
*
.
0125
;
beat_val
[
x
]
=
(
beat_instant
[
x
])
/
(
beat_history
[
x
]);
beat_val
[
x
]
=
(
beat_instant
[
x
])
/
(
beat_history
[
x
]);
beat_att
[
x
]
+=
(
beat_instant
[
x
])
/
(
beat_history
[
x
]);
beat_att
[
x
]
+=
(
beat_instant
[
x
])
/
(
beat_history
[
x
]);
}
}
vol_history
-=
(
vol_buffer
[
beat_buffer_pos
])
*
.
0125
;
vol_history
-=
(
vol_buffer
[
beat_buffer_pos
])
*
.
0125
;
vol_buffer
[
beat_buffer_pos
]
=
vol_instant
;
vol_buffer
[
beat_buffer_pos
]
=
vol_instant
;
vol_history
+=
(
vol_instant
)
*
.
0125
;
vol_history
+=
(
vol_instant
)
*
.
0125
;
...
@@ -110,33 +110,33 @@ void getBeatVals(double *vdataL,double *vdataR, double *vol)
...
@@ -110,33 +110,33 @@ void getBeatVals(double *vdataL,double *vdataR, double *vol)
double
temp2
=
0
;
double
temp2
=
0
;
mid
=
0
;
mid
=
0
;
for
(
x
=
1
;
x
<
10
;
x
++
)
for
(
x
=
1
;
x
<
10
;
x
++
)
{
{
mid
+=
(
beat_instant
[
x
]);
mid
+=
(
beat_instant
[
x
]);
temp2
+=
(
beat_history
[
x
]);
temp2
+=
(
beat_history
[
x
]);
}
}
mid
=
mid
/
(
1
.
5
*
temp2
);
mid
=
mid
/
(
1
.
5
*
temp2
);
temp2
=
0
;
temp2
=
0
;
treb
=
0
;
treb
=
0
;
for
(
x
=
10
;
x
<
16
;
x
++
)
for
(
x
=
10
;
x
<
16
;
x
++
)
{
{
treb
+=
(
beat_instant
[
x
]);
treb
+=
(
beat_instant
[
x
]);
temp2
+=
(
beat_history
[
x
]);
temp2
+=
(
beat_history
[
x
]);
}
}
treb
=
treb
/
(
1
.
5
*
temp2
);
treb
=
treb
/
(
1
.
5
*
temp2
);
*
vol
=
vol_instant
/
(
1
.
5
*
vol_history
);
*
vol
=
vol_instant
/
(
1
.
5
*
vol_history
);
bass
=
(
beat_instant
[
0
])
/
(
1
.
5
*
beat_history
[
0
]);
bass
=
(
beat_instant
[
0
])
/
(
1
.
5
*
beat_history
[
0
]);
treb_att
=
.
6
*
treb_att
+
.
4
*
treb
;
treb_att
=
.
6
*
treb_att
+
.
4
*
treb
;
mid_att
=
.
6
*
mid_att
+
.
4
*
mid
;
mid_att
=
.
6
*
mid_att
+
.
4
*
mid
;
bass_att
=
.
6
*
bass_att
+
.
4
*
bass
;
bass_att
=
.
6
*
bass_att
+
.
4
*
bass
;
//printf("%f %f %f %f\n",bass,mid,treb,*vol);
//printf("%f %f %f %f\n",bass,mid,treb,*vol);
// *vol=(beat_instant[3])/(beat_history[3]);
// *vol=(beat_instant[3])/(beat_history[3]);
beat_buffer_pos
++
;
beat_buffer_pos
++
;
if
(
beat_buffer_pos
>
79
)
beat_buffer_pos
=
0
;
if
(
beat_buffer_pos
>
79
)
beat_buffer_pos
=
0
;
}
}
void
freeBeatDetect
()
void
freeBeatDetect
()
{
{
...
...
modules/visualization/galaktos/builtin_funcs.c
View file @
d6008a8b
...
@@ -25,8 +25,8 @@
...
@@ -25,8 +25,8 @@
#include <math.h>
#include <math.h>
/* Values to optimize the sigmoid function */
/* Values to optimize the sigmoid function */
#define R 32767
#define R 32767
#define RR 65534
#define RR 65534
inline
double
int_wrapper
(
double
*
arg_list
)
{
inline
double
int_wrapper
(
double
*
arg_list
)
{
...
@@ -36,57 +36,57 @@ inline double int_wrapper(double * arg_list) {
...
@@ -36,57 +36,57 @@ inline double int_wrapper(double * arg_list) {
inline
double
sqr_wrapper
(
double
*
arg_list
)
{
inline
double
sqr_wrapper
(
double
*
arg_list
)
{
return
pow
(
2
,
arg_list
[
0
]);
return
pow
(
2
,
arg_list
[
0
]);
}
}
inline
double
sign_wrapper
(
double
*
arg_list
)
{
inline
double
sign_wrapper
(
double
*
arg_list
)
{
return
-
arg_list
[
0
];
return
-
arg_list
[
0
];
}
}
inline
double
min_wrapper
(
double
*
arg_list
)
{
inline
double
min_wrapper
(
double
*
arg_list
)
{
if
(
arg_list
[
0
]
>
arg_list
[
1
])
if
(
arg_list
[
0
]
>
arg_list
[
1
])
return
arg_list
[
1
];
return
arg_list
[
1
];
return
arg_list
[
0
];
return
arg_list
[
0
];
}
}
inline
double
max_wrapper
(
double
*
arg_list
)
{
inline
double
max_wrapper
(
double
*
arg_list
)
{
if
(
arg_list
[
0
]
>
arg_list
[
1
])
if
(
arg_list
[
0
]
>
arg_list
[
1
])
return
arg_list
[
0
];
return
arg_list
[
0
];
return
arg_list
[
1
];
return
arg_list
[
1
];
}
}
/* consult your AI book */
/* consult your AI book */
inline
double
sigmoid_wrapper
(
double
*
arg_list
)
{
inline
double
sigmoid_wrapper
(
double
*
arg_list
)
{
return
(
RR
/
(
1
+
exp
(
-
(((
double
)(
arg_list
[
0
]))
*
arg_list
[
1
])
/
R
)
-
R
));
return
(
RR
/
(
1
+
exp
(
-
(((
double
)(
arg_list
[
0
]))
*
arg_list
[
1
])
/
R
)
-
R
));
}
}
inline
double
bor_wrapper
(
double
*
arg_list
)
{
inline
double
bor_wrapper
(
double
*
arg_list
)
{
return
(
double
)((
int
)
arg_list
[
0
]
||
(
int
)
arg_list
[
1
]);
return
(
double
)((
int
)
arg_list
[
0
]
||
(
int
)
arg_list
[
1
]);
}
}
inline
double
band_wrapper
(
double
*
arg_list
)
{
inline
double
band_wrapper
(
double
*
arg_list
)
{
return
(
double
)((
int
)
arg_list
[
0
]
&&
(
int
)
arg_list
[
1
]);
return
(
double
)((
int
)
arg_list
[
0
]
&&
(
int
)
arg_list
[
1
]);
}
}
inline
double
bnot_wrapper
(
double
*
arg_list
)
{
inline
double
bnot_wrapper
(
double
*
arg_list
)
{
return
(
double
)(
!
(
int
)
arg_list
[
0
]);
return
(
double
)(
!
(
int
)
arg_list
[
0
]);
}
}
inline
double
if_wrapper
(
double
*
arg_list
)
{
inline
double
if_wrapper
(
double
*
arg_list
)
{
if
((
int
)
arg_list
[
0
]
==
0
)
if
((
int
)
arg_list
[
0
]
==
0
)
return
arg_list
[
2
];
return
arg_list
[
2
];
return
arg_list
[
1
];
return
arg_list
[
1
];
}
}
inline
double
rand_wrapper
(
double
*
arg_list
)
{
inline
double
rand_wrapper
(
double
*
arg_list
)
{
...
@@ -96,48 +96,48 @@ inline double rand_wrapper(double * arg_list) {
...
@@ -96,48 +96,48 @@ inline double rand_wrapper(double * arg_list) {
l
=
(
double
)((
rand
())
%
((
int
)
arg_list
[
0
]));
l
=
(
double
)((
rand
())
%
((
int
)
arg_list
[
0
]));
//printf("VAL: %f\n", l);
//printf("VAL: %f\n", l);
return
l
;
return
l
;
}
}
inline
double
equal_wrapper
(
double
*
arg_list
)
{
inline
double
equal_wrapper
(
double
*
arg_list
)
{
return
(
arg_list
[
0
]
==
arg_list
[
1
]);
return
(
arg_list
[
0
]
==
arg_list
[
1
]);
}
}
inline
double
above_wrapper
(
double
*
arg_list
)
{
inline
double
above_wrapper
(
double
*
arg_list
)
{
return
(
arg_list
[
0
]
>
arg_list
[
1
]);
return
(
arg_list
[
0
]
>
arg_list
[
1
]);
}
}
inline
double
below_wrapper
(
double
*
arg_list
)
{
inline
double
below_wrapper
(
double
*
arg_list
)
{
return
(
arg_list
[
0
]
<
arg_list
[
1
]);
return
(
arg_list
[
0
]
<
arg_list
[
1
]);
}
}
inline
double
sin_wrapper
(
double
*
arg_list
)
{
inline
double
sin_wrapper
(
double
*
arg_list
)
{
return
(
sin
(
arg_list
[
0
]));
return
(
sin
(
arg_list
[
0
]));
}
}
inline
double
cos_wrapper
(
double
*
arg_list
)
{
inline
double
cos_wrapper
(
double
*
arg_list
)
{
return
(
cos
(
arg_list
[
0
]));
return
(
cos
(
arg_list
[
0
]));
}
}
inline
double
tan_wrapper
(
double
*
arg_list
)
{
inline
double
tan_wrapper
(
double
*
arg_list
)
{
return
(
tan
(
arg_list
[
0
]));
return
(
tan
(
arg_list
[
0
]));
}
}
inline
double
asin_wrapper
(
double
*
arg_list
)
{
inline
double
asin_wrapper
(
double
*
arg_list
)
{
return
(
asin
(
arg_list
[
0
]));
return
(
asin
(
arg_list
[
0
]));
}
}
inline
double
acos_wrapper
(
double
*
arg_list
)
{
inline
double
acos_wrapper
(
double
*
arg_list
)
{
return
(
acos
(
arg_list
[
0
]));
return
(
acos
(
arg_list
[
0
]));
}
}
inline
double
atan_wrapper
(
double
*
arg_list
)
{
inline
double
atan_wrapper
(
double
*
arg_list
)
{
return
(
atan
(
arg_list
[
0
]));
return
(
atan
(
arg_list
[
0
]));
}
}
inline
double
atan2_wrapper
(
double
*
arg_list
)
{
inline
double
atan2_wrapper
(
double
*
arg_list
)
{
...
@@ -193,9 +193,9 @@ inline double fact_wrapper(double * arg_list) {
...
@@ -193,9 +193,9 @@ inline double fact_wrapper(double * arg_list) {
int
result
=
1
;
int
result
=
1
;
int
n
=
(
int
)
arg_list
[
0
];
int
n
=
(
int
)
arg_list
[
0
];
while
(
n
>
1
)
{
while
(
n
>
1
)
{
result
=
result
*
n
;
result
=
result
*
n
;
n
--
;
n
--
;
...
...
modules/visualization/galaktos/builtin_funcs.h
View file @
d6008a8b
/* Wrappers for all the builtin functions
/* Wrappers for all the builtin functions
The arg_list pointer is a list of doubles. Its
The arg_list pointer is a list of doubles. Its
size is equal to the number of arguments the parameter
size is equal to the number of arguments the parameter
takes */
takes */
...
...
modules/visualization/galaktos/common.h
View file @
d6008a8b
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
#endif
#endif
#ifndef FALSE
#ifndef FALSE
#define FALSE 0
#define FALSE 0
#endif
#endif
#define PROJECTM_FILE_EXTENSION ".prjm"
#define PROJECTM_FILE_EXTENSION ".prjm"
#define MILKDROP_FILE_EXTENSION ".milk"
#define MILKDROP_FILE_EXTENSION ".milk"
...
...
modules/visualization/galaktos/custom_shape.c
View file @
d6008a8b
...
@@ -77,25 +77,25 @@ custom_shape_t * new_custom_shape(int id) {
...
@@ -77,25 +77,25 @@ custom_shape_t * new_custom_shape(int id) {
/* Initialize tree data structures */
/* Initialize tree data structures */
if
((
custom_shape
->
param_tree
=
if
((
custom_shape
->
param_tree
=
create_splaytree
(
compare_string
,
copy_string
,
free_string
))
==
NULL
)
{
create_splaytree
(
compare_string
,
copy_string
,
free_string
))
==
NULL
)
{
free_custom_shape
(
custom_shape
);
free_custom_shape
(
custom_shape
);
return
NULL
;
return
NULL
;
}
}
if
((
custom_shape
->
per_frame_eqn_tree
=
if
((
custom_shape
->
per_frame_eqn_tree
=
create_splaytree
(
compare_int
,
copy_int
,
free_int
))
==
NULL
)
{
create_splaytree
(
compare_int
,
copy_int
,
free_int
))
==
NULL
)
{
free_custom_shape
(
custom_shape
);
free_custom_shape
(
custom_shape
);
return
NULL
;
return
NULL
;
}
}
if
((
custom_shape
->
init_cond_tree
=
if
((
custom_shape
->
init_cond_tree
=
create_splaytree
(
compare_string
,
copy_string
,
free_string
))
==
NULL
)
{
create_splaytree
(
compare_string
,
copy_string
,
free_string
))
==
NULL
)
{
free_custom_shape
(
custom_shape
);
free_custom_shape
(
custom_shape
);
return
NULL
;
return
NULL
;
}
}
if
((
custom_shape
->
per_frame_init_eqn_tree
=
if
((
custom_shape
->
per_frame_init_eqn_tree
=
create_splaytree
(
compare_string
,
copy_string
,
free_string
))
==
NULL
)
{
create_splaytree
(
compare_string
,
copy_string
,
free_string
))
==
NULL
)
{
free_custom_shape
(
custom_shape
);
free_custom_shape
(
custom_shape
);
return
NULL
;
return
NULL
;
...
@@ -125,7 +125,7 @@ custom_shape_t * new_custom_shape(int id) {
...
@@ -125,7 +125,7 @@ custom_shape_t * new_custom_shape(int id) {
if
((
param
=
new_param_double
(
"b"
,
P_FLAG_NONE
,
&
custom_shape
->
b
,
NULL
,
1
.
0
,
0
.
0
,
.
5
))
==
NULL
){
if
((
param
=
new_param_double
(
"b"
,
P_FLAG_NONE
,
&
custom_shape
->
b
,
NULL
,
1
.
0
,
0
.
0
,
.
5
))
==
NULL
){
free_custom_shape
(
custom_shape
);
free_custom_shape
(
custom_shape
);
return
NULL
;
return
NULL
;
}
}
if
(
insert_param
(
param
,
custom_shape
->
param_tree
)
<
0
)
{
if
(
insert_param
(
param
,
custom_shape
->
param_tree
)
<
0
)
{
...
@@ -165,7 +165,7 @@ custom_shape_t * new_custom_shape(int id) {
...
@@ -165,7 +165,7 @@ custom_shape_t * new_custom_shape(int id) {
if
((
param
=
new_param_double
(
"border_b"
,
P_FLAG_NONE
,
&
custom_shape
->
border_b
,
NULL
,
1
.
0
,
0
.
0
,
.
5
))
==
NULL
){
if
((
param
=
new_param_double
(
"border_b"
,
P_FLAG_NONE
,
&
custom_shape
->
border_b
,
NULL
,
1
.
0
,
0
.
0
,
.
5
))
==
NULL
){
free_custom_shape
(
custom_shape
);
free_custom_shape
(
custom_shape
);
return
NULL
;
return
NULL
;
}
}
if
(
insert_param
(
param
,
custom_shape
->
param_tree
)
<
0
)
{
if
(
insert_param
(
param
,
custom_shape
->
param_tree
)
<
0
)
{
...
@@ -205,7 +205,7 @@ custom_shape_t * new_custom_shape(int id) {
...
@@ -205,7 +205,7 @@ custom_shape_t * new_custom_shape(int id) {
if
((
param
=
new_param_double
(
"b2"
,
P_FLAG_NONE
,
&
custom_shape
->
b2
,
NULL
,
1
.
0
,
0
.
0
,
.
5
))
==
NULL
){
if
((
param
=
new_param_double
(
"b2"
,
P_FLAG_NONE
,
&
custom_shape
->
b2
,
NULL
,
1
.
0
,
0
.
0
,
.
5
))
==
NULL
){
free_custom_shape
(
custom_shape
);
free_custom_shape
(
custom_shape
);
return
NULL
;
return
NULL
;
}
}
if
(
insert_param
(
param
,
custom_shape
->
param_tree
)
<
0
)
{
if
(
insert_param
(
param
,
custom_shape
->
param_tree
)
<
0
)
{
...
@@ -217,7 +217,7 @@ custom_shape_t * new_custom_shape(int id) {
...
@@ -217,7 +217,7 @@ custom_shape_t * new_custom_shape(int id) {
free_custom_shape
(
custom_shape
);
free_custom_shape
(
custom_shape
);
return
NULL
;
return
NULL
;
}
}
if
(
insert_param
(
param
,
custom_shape
->
param_tree
)
<
0
)
{
if
(
insert_param
(
param
,
custom_shape
->
param_tree
)
<
0
)
{
free_custom_shape
(
custom_shape
);
free_custom_shape
(
custom_shape
);
return
NULL
;
return
NULL
;
...
@@ -322,7 +322,7 @@ custom_shape_t * new_custom_shape(int id) {
...
@@ -322,7 +322,7 @@ custom_shape_t * new_custom_shape(int id) {
free_custom_shape
(
custom_shape
);
free_custom_shape
(
custom_shape
);
return
NULL
;
return
NULL
;
}
}
if
((
param
=
new_param_double
(
"tex_ang"
,
P_FLAG_NONE
,
&
custom_shape
->
tex_ang
,
NULL
,
MAX_DOUBLE_SIZE
,
-
MAX_DOUBLE_SIZE
,
0
.
0
))
==
NULL
)
{
if
((
param
=
new_param_double
(
"tex_ang"
,
P_FLAG_NONE
,
&
custom_shape
->
tex_ang
,
NULL
,
MAX_DOUBLE_SIZE
,
-
MAX_DOUBLE_SIZE
,
0
.
0
))
==
NULL
)
{
free_custom_shape
(
custom_shape
);
free_custom_shape
(
custom_shape
);
return
NULL
;
return
NULL
;
...
@@ -409,7 +409,7 @@ custom_shape_t * new_custom_shape(int id) {
...
@@ -409,7 +409,7 @@ custom_shape_t * new_custom_shape(int id) {
}
}
/* End of parameter loading. Note that the read only parameters associated
/* End of parameter loading. Note that the read only parameters associated
with custom shapes (ie, sample) are global variables, and not specific to
with custom shapes (ie, sample) are global variables, and not specific to
the custom shape datastructure. */
the custom shape datastructure. */
...
@@ -475,7 +475,7 @@ void free_custom_shape(custom_shape_t * custom_shape) {
...
@@ -475,7 +475,7 @@ void free_custom_shape(custom_shape_t * custom_shape) {
destroy_init_cond_tree_shape
(
custom_shape
->
init_cond_tree
);
destroy_init_cond_tree_shape
(
custom_shape
->
init_cond_tree
);
destroy_param_db_tree_shape
(
custom_shape
->
param_tree
);
destroy_param_db_tree_shape
(
custom_shape
->
param_tree
);
destroy_per_frame_init_eqn_tree_shape
(
custom_shape
->
per_frame_init_eqn_tree
);
destroy_per_frame_init_eqn_tree_shape
(
custom_shape
->
per_frame_init_eqn_tree
);
free
(
custom_shape
);
free
(
custom_shape
);
return
;
return
;
...
@@ -489,32 +489,32 @@ custom_shape_t * find_custom_shape(int id, preset_t * preset, int create_flag) {
...
@@ -489,32 +489,32 @@ custom_shape_t * find_custom_shape(int id, preset_t * preset, int create_flag) {
if
(
preset
==
NULL
)
if
(
preset
==
NULL
)
return
NULL
;
return
NULL
;
if
((
custom_shape
=
splay_find
(
&
id
,
preset
->
custom_shape_tree
))
==
NULL
)
{
if
((
custom_shape
=
splay_find
(
&
id
,
preset
->
custom_shape_tree
))
==
NULL
)
{
if
(
CUSTOM_SHAPE_DEBUG
)
{
printf
(
"find_custom_shape: creating custom shape (id = %d)..."
,
id
);
fflush
(
stdout
);}
if
(
CUSTOM_SHAPE_DEBUG
)
{
printf
(
"find_custom_shape: creating custom shape (id = %d)..."
,
id
);
fflush
(
stdout
);}
if
(
create_flag
==
FALSE
)
{
if
(
create_flag
==
FALSE
)
{
if
(
CUSTOM_SHAPE_DEBUG
)
printf
(
"you specified not to (create flag = false), returning null
\n
"
);
if
(
CUSTOM_SHAPE_DEBUG
)
printf
(
"you specified not to (create flag = false), returning null
\n
"
);
return
NULL
;
return
NULL
;
}
}
if
((
custom_shape
=
new_custom_shape
(
id
))
==
NULL
)
{
if
((
custom_shape
=
new_custom_shape
(
id
))
==
NULL
)
{
if
(
CUSTOM_SHAPE_DEBUG
)
printf
(
"failed...out of memory?
\n
"
);
if
(
CUSTOM_SHAPE_DEBUG
)
printf
(
"failed...out of memory?
\n
"
);
return
NULL
;
return
NULL
;
}
}
if
(
CUSTOM_SHAPE_DEBUG
)
{
printf
(
"success.Inserting..."
);
fflush
(
stdout
);}
if
(
CUSTOM_SHAPE_DEBUG
)
{
printf
(
"success.Inserting..."
);
fflush
(
stdout
);}
if
(
splay_insert
(
custom_shape
,
&
custom_shape
->
id
,
preset
->
custom_shape_tree
)
<
0
)
{
if
(
splay_insert
(
custom_shape
,
&
custom_shape
->
id
,
preset
->
custom_shape_tree
)
<
0
)
{
if
(
CUSTOM_SHAPE_DEBUG
)
printf
(
"failed, probably a duplicated!!
\n
"
);
if
(
CUSTOM_SHAPE_DEBUG
)
printf
(
"failed, probably a duplicated!!
\n
"
);
free_custom_shape
(
custom_shape
);
free_custom_shape
(
custom_shape
);
return
NULL
;
return
NULL
;
}
}
if
(
CUSTOM_SHAPE_DEBUG
)
printf
(
"done.
\n
"
);
if
(
CUSTOM_SHAPE_DEBUG
)
printf
(
"done.
\n
"
);
}
}
return
custom_shape
;
return
custom_shape
;
}
}
...
@@ -555,14 +555,14 @@ void load_unspec_init_cond_shape(param_t * param) {
...
@@ -555,14 +555,14 @@ void load_unspec_init_cond_shape(param_t * param) {
/* If initial condition was not defined by the preset file, force a default one
/* If initial condition was not defined by the preset file, force a default one
with the following code */
with the following code */
if
((
init_cond
=
splay_find
(
param
->
name
,
interface_shape
->
init_cond_tree
))
==
NULL
)
{
if
((
init_cond
=
splay_find
(
param
->
name
,
interface_shape
->
init_cond_tree
))
==
NULL
)
{
/* Make sure initial condition does not exist in the set of per frame initial equations */
/* Make sure initial condition does not exist in the set of per frame initial equations */
if
((
init_cond
=
splay_find
(
param
->
name
,
interface_shape
->
per_frame_init_eqn_tree
))
!=
NULL
)
if
((
init_cond
=
splay_find
(
param
->
name
,
interface_shape
->
per_frame_init_eqn_tree
))
!=
NULL
)
return
;
return
;
if
(
param
->
type
==
P_TYPE_BOOL
)
if
(
param
->
type
==
P_TYPE_BOOL
)
init_val
.
bool_val
=
0
;
init_val
.
bool_val
=
0
;
else
if
(
param
->
type
==
P_TYPE_INT
)
else
if
(
param
->
type
==
P_TYPE_INT
)
init_val
.
int_val
=
*
(
int
*
)
param
->
engine_val
;
init_val
.
int_val
=
*
(
int
*
)
param
->
engine_val
;
...
@@ -573,13 +573,13 @@ void load_unspec_init_cond_shape(param_t * param) {
...
@@ -573,13 +573,13 @@ void load_unspec_init_cond_shape(param_t * param) {
/* Create new initial condition */
/* Create new initial condition */
if
((
init_cond
=
new_init_cond
(
param
,
init_val
))
==
NULL
)
if
((
init_cond
=
new_init_cond
(
param
,
init_val
))
==
NULL
)
return
;
return
;
/* Insert the initial condition into this presets tree */
/* Insert the initial condition into this presets tree */
if
(
splay_insert
(
init_cond
,
init_cond
->
param
->
name
,
interface_shape
->
init_cond_tree
)
<
0
)
{
if
(
splay_insert
(
init_cond
,
init_cond
->
param
->
name
,
interface_shape
->
init_cond_tree
)
<
0
)
{
free_init_cond
(
init_cond
);
free_init_cond
(
init_cond
);
return
;
return
;
}
}
}
}
}
}
...
...
modules/visualization/galaktos/custom_shape_types.h
View file @
d6008a8b
...
@@ -23,7 +23,7 @@ typedef struct CUSTOM_SHAPE_T {
...
@@ -23,7 +23,7 @@ typedef struct CUSTOM_SHAPE_T {
double
tex_zoom
;
double
tex_zoom
;
double
tex_ang
;
double
tex_ang
;
double
x
;
/* x position for per point equations */
double
x
;
/* x position for per point equations */
double
y
;
/* y position for per point equations */
double
y
;
/* y position for per point equations */
double
rad
;
double
rad
;
...
@@ -67,8 +67,8 @@ typedef struct CUSTOM_SHAPE_T {
...
@@ -67,8 +67,8 @@ typedef struct CUSTOM_SHAPE_T {
char
per_frame_eqn_string_buffer
[
STRING_BUFFER_SIZE
];
char
per_frame_eqn_string_buffer
[
STRING_BUFFER_SIZE
];
char
per_frame_init_eqn_string_buffer
[
STRING_BUFFER_SIZE
];
char
per_frame_init_eqn_string_buffer
[
STRING_BUFFER_SIZE
];
/* Per point equation array */
/* Per point equation array */
}
custom_shape_t
;
}
custom_shape_t
;
...
...
modules/visualization/galaktos/custom_wave.c
View file @
d6008a8b
...
@@ -72,7 +72,7 @@ custom_wave_t * new_custom_wave(int id) {
...
@@ -72,7 +72,7 @@ custom_wave_t * new_custom_wave(int id) {
custom_wave_t
*
custom_wave
;
custom_wave_t
*
custom_wave
;
param_t
*
param
;
param_t
*
param
;
if
((
custom_wave
=
(
custom_wave_t
*
)
malloc
(
sizeof
(
custom_wave_t
)))
==
NULL
)
if
((
custom_wave
=
(
custom_wave_t
*
)
malloc
(
sizeof
(
custom_wave_t
)))
==
NULL
)
return
NULL
;
return
NULL
;
...
@@ -103,38 +103,38 @@ custom_wave_t * new_custom_wave(int id) {
...
@@ -103,38 +103,38 @@ custom_wave_t * new_custom_wave(int id) {
custom_wave
->
sample_mesh
=
malloc
(
MAX_SAMPLE_SIZE
*
sizeof
(
double
));
custom_wave
->
sample_mesh
=
malloc
(
MAX_SAMPLE_SIZE
*
sizeof
(
double
));
/* Initialize tree data structures */
/* Initialize tree data structures */
if
((
custom_wave
->
param_tree
=
if
((
custom_wave
->
param_tree
=
create_splaytree
(
compare_string
,
copy_string
,
free_string
))
==
NULL
)
{
create_splaytree
(
compare_string
,
copy_string
,
free_string
))
==
NULL
)
{
free_custom_wave
(
custom_wave
);
free_custom_wave
(
custom_wave
);
return
NULL
;
return
NULL
;
}
}
if
((
custom_wave
->
per_point_eqn_tree
=
if
((
custom_wave
->
per_point_eqn_tree
=
create_splaytree
(
compare_int
,
copy_int
,
free_int
))
==
NULL
)
{
create_splaytree
(
compare_int
,
copy_int
,
free_int
))
==
NULL
)
{
free_custom_wave
(
custom_wave
);
free_custom_wave
(
custom_wave
);
return
NULL
;
return
NULL
;
}
}
if
((
custom_wave
->
per_frame_eqn_tree
=
if
((
custom_wave
->
per_frame_eqn_tree
=
create_splaytree
(
compare_int
,
copy_int
,
free_int
))
==
NULL
)
{
create_splaytree
(
compare_int
,
copy_int
,
free_int
))
==
NULL
)
{
free_custom_wave
(
custom_wave
);
free_custom_wave
(
custom_wave
);
return
NULL
;
return
NULL
;
}
}
if
((
custom_wave
->
init_cond_tree
=
if
((
custom_wave
->
init_cond_tree
=
create_splaytree
(
compare_string
,
copy_string
,
free_string
))
==
NULL
)
{
create_splaytree
(
compare_string
,
copy_string
,
free_string
))
==
NULL
)
{
free_custom_wave
(
custom_wave
);
free_custom_wave
(
custom_wave
);
return
NULL
;
return
NULL
;
}
}
if
((
custom_wave
->
per_frame_init_eqn_tree
=
if
((
custom_wave
->
per_frame_init_eqn_tree
=
create_splaytree
(
compare_string
,
copy_string
,
free_string
))
==
NULL
)
{
create_splaytree
(
compare_string
,
copy_string
,
free_string
))
==
NULL
)
{
free_custom_wave
(
custom_wave
);
free_custom_wave
(
custom_wave
);
return
NULL
;
return
NULL
;
}
}
/* Start: Load custom wave parameters */
/* Start: Load custom wave parameters */
if
((
param
=
new_param_double
(
"r"
,
P_FLAG_DONT_FREE_MATRIX
|
P_FLAG_PER_POINT
,
&
custom_wave
->
r
,
custom_wave
->
r_mesh
,
1
.
0
,
0
.
0
,
.
5
))
==
NULL
)
{
if
((
param
=
new_param_double
(
"r"
,
P_FLAG_DONT_FREE_MATRIX
|
P_FLAG_PER_POINT
,
&
custom_wave
->
r
,
custom_wave
->
r_mesh
,
1
.
0
,
0
.
0
,
.
5
))
==
NULL
)
{
...
@@ -159,7 +159,7 @@ custom_wave_t * new_custom_wave(int id) {
...
@@ -159,7 +159,7 @@ custom_wave_t * new_custom_wave(int id) {
if
((
param
=
new_param_double
(
"b"
,
P_FLAG_DONT_FREE_MATRIX
|
P_FLAG_PER_POINT
,
&
custom_wave
->
b
,
custom_wave
->
b_mesh
,
1
.
0
,
0
.
0
,
.
5
))
==
NULL
){
if
((
param
=
new_param_double
(
"b"
,
P_FLAG_DONT_FREE_MATRIX
|
P_FLAG_PER_POINT
,
&
custom_wave
->
b
,
custom_wave
->
b_mesh
,
1
.
0
,
0
.
0
,
.
5
))
==
NULL
){
free_custom_wave
(
custom_wave
);
free_custom_wave
(
custom_wave
);
return
NULL
;
return
NULL
;
}
}
if
(
insert_param
(
param
,
custom_wave
->
param_tree
)
<
0
)
{
if
(
insert_param
(
param
,
custom_wave
->
param_tree
)
<
0
)
{
...
@@ -171,7 +171,7 @@ custom_wave_t * new_custom_wave(int id) {
...
@@ -171,7 +171,7 @@ custom_wave_t * new_custom_wave(int id) {
free_custom_wave
(
custom_wave
);
free_custom_wave
(
custom_wave
);
return
NULL
;
return
NULL
;
}
}
if
(
insert_param
(
param
,
custom_wave
->
param_tree
)
<
0
)
{
if
(
insert_param
(
param
,
custom_wave
->
param_tree
)
<
0
)
{
free_custom_wave
(
custom_wave
);
free_custom_wave
(
custom_wave
);
return
NULL
;
return
NULL
;
...
@@ -268,7 +268,7 @@ custom_wave_t * new_custom_wave(int id) {
...
@@ -268,7 +268,7 @@ custom_wave_t * new_custom_wave(int id) {
}
}
if
((
param
=
new_param_double
(
"sample"
,
P_FLAG_READONLY
|
P_FLAG_DONT_FREE_MATRIX
|
P_FLAG_ALWAYS_MATRIX
|
P_FLAG_PER_POINT
,
if
((
param
=
new_param_double
(
"sample"
,
P_FLAG_READONLY
|
P_FLAG_DONT_FREE_MATRIX
|
P_FLAG_ALWAYS_MATRIX
|
P_FLAG_PER_POINT
,
&
custom_wave
->
sample
,
custom_wave
->
sample_mesh
,
1
.
0
,
0
.
0
,
0
.
0
))
==
NULL
)
{
&
custom_wave
->
sample
,
custom_wave
->
sample_mesh
,
1
.
0
,
0
.
0
,
0
.
0
))
==
NULL
)
{
free_custom_wave
(
custom_wave
);
free_custom_wave
(
custom_wave
);
return
NULL
;
return
NULL
;
}
}
...
@@ -394,9 +394,9 @@ custom_wave_t * new_custom_wave(int id) {
...
@@ -394,9 +394,9 @@ custom_wave_t * new_custom_wave(int id) {
free_custom_wave
(
custom_wave
);
free_custom_wave
(
custom_wave
);
return
NULL
;
return
NULL
;
}
}
/* End of parameter loading. Note that the read only parameters associated
/* End of parameter loading. Note that the read only parameters associated
with custom waves (ie, sample) are global variables, and not specific to
with custom waves (ie, sample) are global variables, and not specific to
the custom wave datastructure. */
the custom wave datastructure. */
...
@@ -498,12 +498,12 @@ int add_per_point_eqn(char * name, gen_expr_t * gen_expr, custom_wave_t * custom
...
@@ -498,12 +498,12 @@ int add_per_point_eqn(char * name, gen_expr_t * gen_expr, custom_wave_t * custom
/* Argument checks */
/* Argument checks */
if
(
custom_wave
==
NULL
)
if
(
custom_wave
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
gen_expr
==
NULL
)
if
(
gen_expr
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
name
==
NULL
)
if
(
name
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
CUSTOM_WAVE_DEBUG
)
printf
(
"add_per_point_eqn: per pixel equation (name =
\"
%s
\"
)
\n
"
,
name
);
if
(
CUSTOM_WAVE_DEBUG
)
printf
(
"add_per_point_eqn: per pixel equation (name =
\"
%s
\"
)
\n
"
,
name
);
/* Search for the parameter so we know what matrix the per pixel equation is referencing */
/* Search for the parameter so we know what matrix the per pixel equation is referencing */
...
@@ -512,7 +512,7 @@ int add_per_point_eqn(char * name, gen_expr_t * gen_expr, custom_wave_t * custom
...
@@ -512,7 +512,7 @@ int add_per_point_eqn(char * name, gen_expr_t * gen_expr, custom_wave_t * custom
if
(
CUSTOM_WAVE_DEBUG
)
printf
(
"add_per_point_eqn: failed to allocate a new parameter!
\n
"
);
if
(
CUSTOM_WAVE_DEBUG
)
printf
(
"add_per_point_eqn: failed to allocate a new parameter!
\n
"
);
return
FAILURE
;
return
FAILURE
;
}
}
/* Find most largest index in the splaytree */
/* Find most largest index in the splaytree */
if
((
per_point_eqn
=
splay_find_max
(
custom_wave
->
per_point_eqn_tree
))
==
NULL
)
if
((
per_point_eqn
=
splay_find_max
(
custom_wave
->
per_point_eqn_tree
))
==
NULL
)
...
@@ -522,49 +522,49 @@ int add_per_point_eqn(char * name, gen_expr_t * gen_expr, custom_wave_t * custom
...
@@ -522,49 +522,49 @@ int add_per_point_eqn(char * name, gen_expr_t * gen_expr, custom_wave_t * custom
/* Create the per pixel equation given the index, parameter, and general expression */
/* Create the per pixel equation given the index, parameter, and general expression */
if
((
per_point_eqn
=
new_per_point_eqn
(
index
,
param
,
gen_expr
))
==
NULL
)
if
((
per_point_eqn
=
new_per_point_eqn
(
index
,
param
,
gen_expr
))
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
CUSTOM_WAVE_DEBUG
)
if
(
CUSTOM_WAVE_DEBUG
)
printf
(
"add_per_point_eqn: created new equation (index = %d) (name =
\"
%s
\"
)
\n
"
,
per_point_eqn
->
index
,
per_point_eqn
->
param
->
name
);
printf
(
"add_per_point_eqn: created new equation (index = %d) (name =
\"
%s
\"
)
\n
"
,
per_point_eqn
->
index
,
per_point_eqn
->
param
->
name
);
/* Insert the per pixel equation into the preset per pixel database */
/* Insert the per pixel equation into the preset per pixel database */
if
(
splay_insert
(
per_point_eqn
,
&
per_point_eqn
->
index
,
custom_wave
->
per_point_eqn_tree
)
<
0
)
{
if
(
splay_insert
(
per_point_eqn
,
&
per_point_eqn
->
index
,
custom_wave
->
per_point_eqn_tree
)
<
0
)
{
free_per_point_eqn
(
per_point_eqn
);
free_per_point_eqn
(
per_point_eqn
);
return
FAILURE
;
return
FAILURE
;
}
}
/* Done */
/* Done */
return
SUCCESS
;
return
SUCCESS
;
}
}
per_point_eqn_t
*
new_per_point_eqn
(
int
index
,
param_t
*
param
,
gen_expr_t
*
gen_expr
)
{
per_point_eqn_t
*
new_per_point_eqn
(
int
index
,
param_t
*
param
,
gen_expr_t
*
gen_expr
)
{
per_point_eqn_t
*
per_point_eqn
;
per_point_eqn_t
*
per_point_eqn
;
if
(
param
==
NULL
)
if
(
param
==
NULL
)
return
NULL
;
return
NULL
;
if
(
gen_expr
==
NULL
)
if
(
gen_expr
==
NULL
)
return
NULL
;
return
NULL
;
if
((
per_point_eqn
=
(
per_point_eqn_t
*
)
malloc
(
sizeof
(
per_point_eqn_t
)))
==
NULL
)
if
((
per_point_eqn
=
(
per_point_eqn_t
*
)
malloc
(
sizeof
(
per_point_eqn_t
)))
==
NULL
)
return
NULL
;
return
NULL
;
per_point_eqn
->
index
=
index
;
per_point_eqn
->
index
=
index
;
per_point_eqn
->
gen_expr
=
gen_expr
;
per_point_eqn
->
gen_expr
=
gen_expr
;
per_point_eqn
->
param
=
param
;
per_point_eqn
->
param
=
param
;
return
per_point_eqn
;
return
per_point_eqn
;
}
}
void
free_per_point_eqn
(
per_point_eqn_t
*
per_point_eqn
)
{
void
free_per_point_eqn
(
per_point_eqn_t
*
per_point_eqn
)
{
if
(
per_point_eqn
==
NULL
)
if
(
per_point_eqn
==
NULL
)
return
;
return
;
free_gen_expr
(
per_point_eqn
->
gen_expr
);
free_gen_expr
(
per_point_eqn
->
gen_expr
);
free
(
per_point_eqn
);
free
(
per_point_eqn
);
return
;
return
;
}
}
custom_wave_t
*
find_custom_wave
(
int
id
,
preset_t
*
preset
,
int
create_flag
)
{
custom_wave_t
*
find_custom_wave
(
int
id
,
preset_t
*
preset
,
int
create_flag
)
{
...
@@ -573,7 +573,7 @@ custom_wave_t * find_custom_wave(int id, preset_t * preset, int create_flag) {
...
@@ -573,7 +573,7 @@ custom_wave_t * find_custom_wave(int id, preset_t * preset, int create_flag) {
if
(
preset
==
NULL
)
if
(
preset
==
NULL
)
return
NULL
;
return
NULL
;
if
((
custom_wave
=
splay_find
(
&
id
,
preset
->
custom_wave_tree
))
==
NULL
)
{
if
((
custom_wave
=
splay_find
(
&
id
,
preset
->
custom_wave_tree
))
==
NULL
)
{
if
(
CUSTOM_WAVE_DEBUG
)
{
printf
(
"find_custom_wave: creating custom wave (id = %d)..."
,
id
);
fflush
(
stdout
);}
if
(
CUSTOM_WAVE_DEBUG
)
{
printf
(
"find_custom_wave: creating custom wave (id = %d)..."
,
id
);
fflush
(
stdout
);}
...
@@ -628,7 +628,7 @@ inline custom_wave_t * nextCustomWave() {
...
@@ -628,7 +628,7 @@ inline custom_wave_t * nextCustomWave() {
}
}
inline
void
evalPerPointEqns
()
{
inline
void
evalPerPointEqns
()
{
int
x
;
int
x
;
...
@@ -655,8 +655,8 @@ inline void evalPerPointEqns() {
...
@@ -655,8 +655,8 @@ inline void evalPerPointEqns() {
/* Evaluates a per point equation for the current custom wave given by interface_wave ptr */
/* Evaluates a per point equation for the current custom wave given by interface_wave ptr */
inline
void
evalPerPointEqn
(
per_point_eqn_t
*
per_point_eqn
)
{
inline
void
evalPerPointEqn
(
per_point_eqn_t
*
per_point_eqn
)
{
int
samples
,
size
;
int
samples
,
size
;
double
*
param_matrix
;
double
*
param_matrix
;
gen_expr_t
*
eqn_ptr
;
gen_expr_t
*
eqn_ptr
;
...
@@ -669,17 +669,17 @@ inline void evalPerPointEqn(per_point_eqn_t * per_point_eqn) {
...
@@ -669,17 +669,17 @@ inline void evalPerPointEqn(per_point_eqn_t * per_point_eqn) {
return
;
return
;
memset
(
param_matrix
,
0
,
size
);
memset
(
param_matrix
,
0
,
size
);
}
}
else
else
param_matrix
=
(
double
*
)
per_point_eqn
->
param
->
matrix
;
param_matrix
=
(
double
*
)
per_point_eqn
->
param
->
matrix
;
for
(
mesh_i
=
0
;
mesh_i
<
samples
;
mesh_i
++
)
{
for
(
mesh_i
=
0
;
mesh_i
<
samples
;
mesh_i
++
)
{
param_matrix
[
mesh_i
]
=
eval_gen_expr
(
eqn_ptr
);
param_matrix
[
mesh_i
]
=
eval_gen_expr
(
eqn_ptr
);
}
}
/* Now that this parameter has been referenced with a per
/* Now that this parameter has been referenced with a per
point equation, we let the evaluator know by setting
point equation, we let the evaluator know by setting
this flag */
this flag */
per_point_eqn
->
param
->
matrix_flag
=
1
;
per_point_eqn
->
param
->
matrix_flag
=
1
;
}
}
...
@@ -710,14 +710,14 @@ void load_unspec_init_cond(param_t * param) {
...
@@ -710,14 +710,14 @@ void load_unspec_init_cond(param_t * param) {
/* If initial condition was not defined by the preset file, force a default one
/* If initial condition was not defined by the preset file, force a default one
with the following code */
with the following code */
if
((
init_cond
=
splay_find
(
param
->
name
,
interface_wave
->
init_cond_tree
))
==
NULL
)
{
if
((
init_cond
=
splay_find
(
param
->
name
,
interface_wave
->
init_cond_tree
))
==
NULL
)
{
/* Make sure initial condition does not exist in the set of per frame initial equations */
/* Make sure initial condition does not exist in the set of per frame initial equations */
if
((
init_cond
=
splay_find
(
param
->
name
,
interface_wave
->
per_frame_init_eqn_tree
))
!=
NULL
)
if
((
init_cond
=
splay_find
(
param
->
name
,
interface_wave
->
per_frame_init_eqn_tree
))
!=
NULL
)
return
;
return
;
if
(
param
->
type
==
P_TYPE_BOOL
)
if
(
param
->
type
==
P_TYPE_BOOL
)
init_val
.
bool_val
=
0
;
init_val
.
bool_val
=
0
;
else
if
(
param
->
type
==
P_TYPE_INT
)
else
if
(
param
->
type
==
P_TYPE_INT
)
init_val
.
int_val
=
*
(
int
*
)
param
->
engine_val
;
init_val
.
int_val
=
*
(
int
*
)
param
->
engine_val
;
...
@@ -728,13 +728,13 @@ void load_unspec_init_cond(param_t * param) {
...
@@ -728,13 +728,13 @@ void load_unspec_init_cond(param_t * param) {
/* Create new initial condition */
/* Create new initial condition */
if
((
init_cond
=
new_init_cond
(
param
,
init_val
))
==
NULL
)
if
((
init_cond
=
new_init_cond
(
param
,
init_val
))
==
NULL
)
return
;
return
;
/* Insert the initial condition into this presets tree */
/* Insert the initial condition into this presets tree */
if
(
splay_insert
(
init_cond
,
init_cond
->
param
->
name
,
interface_wave
->
init_cond_tree
)
<
0
)
{
if
(
splay_insert
(
init_cond
,
init_cond
->
param
->
name
,
interface_wave
->
init_cond_tree
)
<
0
)
{
free_init_cond
(
init_cond
);
free_init_cond
(
init_cond
);
return
;
return
;
}
}
}
}
}
}
modules/visualization/galaktos/custom_wave_types.h
View file @
d6008a8b
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
typedef
struct
PER_POINT_EQN_T
{
typedef
struct
PER_POINT_EQN_T
{
int
index
;
int
index
;
param_t
*
param
;
param_t
*
param
;
gen_expr_t
*
gen_expr
;
gen_expr_t
*
gen_expr
;
}
per_point_eqn_t
;
}
per_point_eqn_t
;
typedef
struct
CUSTOM_WAVE_T
{
typedef
struct
CUSTOM_WAVE_T
{
...
@@ -85,7 +85,7 @@ typedef struct CUSTOM_WAVE_T {
...
@@ -85,7 +85,7 @@ typedef struct CUSTOM_WAVE_T {
char
per_frame_init_eqn_string_buffer
[
STRING_BUFFER_SIZE
];
char
per_frame_init_eqn_string_buffer
[
STRING_BUFFER_SIZE
];
/* Per point equation array */
/* Per point equation array */
gen_expr_t
*
per_point_eqn_array
[
NUM_POINT_OPS
];
gen_expr_t
*
per_point_eqn_array
[
NUM_POINT_OPS
];
}
custom_wave_t
;
}
custom_wave_t
;
...
...
modules/visualization/galaktos/engine_vars.c
View file @
d6008a8b
...
@@ -72,7 +72,7 @@
...
@@ -72,7 +72,7 @@
double
mv_y
=
12
.
0
;
double
mv_y
=
12
.
0
;
double
mv_dy
=
0
.
02
;
double
mv_dy
=
0
.
02
;
double
mv_dx
=
0
.
02
;
double
mv_dx
=
0
.
02
;
int
meshx
=
0
;
int
meshx
=
0
;
int
meshy
=
0
;
int
meshy
=
0
;
...
...
modules/visualization/galaktos/engine_vars.h
View file @
d6008a8b
...
@@ -96,7 +96,7 @@ extern int bDarken;
...
@@ -96,7 +96,7 @@ extern int bDarken;
extern
int
bSolarize
;
extern
int
bSolarize
;
extern
int
bInvert
;
extern
int
bInvert
;
extern
int
bMotionVectorsOn
;
extern
int
bMotionVectorsOn
;
extern
int
fps
;
extern
int
fps
;
extern
double
fWaveAlpha
;
extern
double
fWaveAlpha
;
extern
double
fWaveScale
;
extern
double
fWaveScale
;
...
...
modules/visualization/galaktos/eval.c
View file @
d6008a8b
...
@@ -50,16 +50,16 @@ static inline double eval_val_expr(val_expr_t * val_expr);
...
@@ -50,16 +50,16 @@ static inline double eval_val_expr(val_expr_t * val_expr);
inline
double
eval_gen_expr
(
gen_expr_t
*
gen_expr
)
{
inline
double
eval_gen_expr
(
gen_expr_t
*
gen_expr
)
{
double
l
;
double
l
;
if
(
gen_expr
==
NULL
)
if
(
gen_expr
==
NULL
)
return
0
;
return
0
;
switch
(
gen_expr
->
type
)
{
switch
(
gen_expr
->
type
)
{
case
VAL_T
:
case
VAL_T
:
return
eval_val_expr
(
gen_expr
->
item
);
return
eval_val_expr
(
gen_expr
->
item
);
case
PREFUN_T
:
case
PREFUN_T
:
l
=
eval_prefun_expr
(
gen_expr
->
item
);
l
=
eval_prefun_expr
(
gen_expr
->
item
);
//if (EVAL_DEBUG) printf("eval_gen_expr: prefix function return value: %f\n", l);
//if (EVAL_DEBUG) printf("eval_gen_expr: prefix function return value: %f\n", l);
return
l
;
return
l
;
case
TREE_T
:
case
TREE_T
:
return
eval_tree_expr
(
gen_expr
->
item
);
return
eval_tree_expr
(
gen_expr
->
item
);
default:
default:
...
@@ -67,46 +67,46 @@ inline double eval_gen_expr(gen_expr_t * gen_expr) {
...
@@ -67,46 +67,46 @@ inline double eval_gen_expr(gen_expr_t * gen_expr) {
printf
(
"eval_gen_expr: general expression matched no cases!
\n
"
);
printf
(
"eval_gen_expr: general expression matched no cases!
\n
"
);
#endif
#endif
return
EVAL_ERROR
;
return
EVAL_ERROR
;
}
}
}
}
/* Evaluates functions in prefix form */
/* Evaluates functions in prefix form */
static
inline
double
eval_prefun_expr
(
prefun_expr_t
*
prefun_expr
)
{
static
inline
double
eval_prefun_expr
(
prefun_expr_t
*
prefun_expr
)
{
int
i
;
int
i
;
/* This is slightly less than safe, since
/* This is slightly less than safe, since
who knows if the passed argument is valid. For
who knows if the passed argument is valid. For
speed purposes we'll go with this */
speed purposes we'll go with this */
double
arg_list
[
prefun_expr
->
num_args
];
double
arg_list
[
prefun_expr
->
num_args
];
#ifdef EVAL_DEBUG
#ifdef EVAL_DEBUG
printf
(
"fn["
);
printf
(
"fn["
);
fflush
(
stdout
);
fflush
(
stdout
);
#endif
#endif
/* Evaluate each argument before calling the function itself */
/* Evaluate each argument before calling the function itself */
for
(
i
=
0
;
i
<
prefun_expr
->
num_args
;
i
++
)
{
for
(
i
=
0
;
i
<
prefun_expr
->
num_args
;
i
++
)
{
arg_list
[
i
]
=
eval_gen_expr
(
prefun_expr
->
expr_list
[
i
]);
arg_list
[
i
]
=
eval_gen_expr
(
prefun_expr
->
expr_list
[
i
]);
#ifdef EVAL_DEBUG
#ifdef EVAL_DEBUG
if
(
i
<
(
prefun_expr
->
num_args
-
1
))
if
(
i
<
(
prefun_expr
->
num_args
-
1
))
printf
(
", "
);
printf
(
", "
);
fflush
(
stdout
);
fflush
(
stdout
);
#endif
#endif
}
}
#ifdef EVAL_DEBUG
#ifdef EVAL_DEBUG
printf
(
"]"
);
printf
(
"]"
);
fflush
(
stdout
);
fflush
(
stdout
);
#endif
#endif
/* Now we call the function, passing a list of
/* Now we call the function, passing a list of
doubles as its argument */
doubles as its argument */
return
(
prefun_expr
->
func_ptr
)(
arg_list
);
return
(
prefun_expr
->
func_ptr
)(
arg_list
);
}
}
/* Evaluates a value expression */
/* Evaluates a value expression */
static
inline
double
eval_val_expr
(
val_expr_t
*
val_expr
)
{
static
inline
double
eval_val_expr
(
val_expr_t
*
val_expr
)
{
...
@@ -117,50 +117,50 @@ static inline double eval_val_expr(val_expr_t * val_expr) {
...
@@ -117,50 +117,50 @@ static inline double eval_val_expr(val_expr_t * val_expr) {
/* Value is a constant, return the double value */
/* Value is a constant, return the double value */
if
(
val_expr
->
type
==
CONSTANT_TERM_T
)
{
if
(
val_expr
->
type
==
CONSTANT_TERM_T
)
{
#ifdef EVAL_DEBUG
#ifdef EVAL_DEBUG
printf
(
"%.4f"
,
val_expr
->
term
.
constant
);
printf
(
"%.4f"
,
val_expr
->
term
.
constant
);
fflush
(
stdout
);
fflush
(
stdout
);
#endif
#endif
return
(
val_expr
->
term
.
constant
);
return
(
val_expr
->
term
.
constant
);
}
}
/* Value is variable, dereference it */
/* Value is variable, dereference it */
if
(
val_expr
->
type
==
PARAM_TERM_T
)
{
if
(
val_expr
->
type
==
PARAM_TERM_T
)
{
switch
(
val_expr
->
term
.
param
->
type
)
{
switch
(
val_expr
->
term
.
param
->
type
)
{
case
P_TYPE_BOOL
:
case
P_TYPE_BOOL
:
#ifdef EVAL_DEBUG
#ifdef EVAL_DEBUG
printf
(
"(%s:%.4f)"
,
val_expr
->
term
.
param
->
name
,
(
double
)(
*
((
int
*
)(
val_expr
->
term
.
param
->
engine_val
))));
printf
(
"(%s:%.4f)"
,
val_expr
->
term
.
param
->
name
,
(
double
)(
*
((
int
*
)(
val_expr
->
term
.
param
->
engine_val
))));
fflush
(
stdout
);
fflush
(
stdout
);
#endif
#endif
return
(
double
)(
*
((
int
*
)(
val_expr
->
term
.
param
->
engine_val
)));
return
(
double
)(
*
((
int
*
)(
val_expr
->
term
.
param
->
engine_val
)));
case
P_TYPE_INT
:
case
P_TYPE_INT
:
#ifdef EVAL_DEBUG
#ifdef EVAL_DEBUG
printf
(
"(%s:%.4f)"
,
val_expr
->
term
.
param
->
name
,
(
double
)(
*
((
int
*
)(
val_expr
->
term
.
param
->
engine_val
))));
printf
(
"(%s:%.4f)"
,
val_expr
->
term
.
param
->
name
,
(
double
)(
*
((
int
*
)(
val_expr
->
term
.
param
->
engine_val
))));
fflush
(
stdout
);
fflush
(
stdout
);
#endif
#endif
return
(
double
)(
*
((
int
*
)(
val_expr
->
term
.
param
->
engine_val
)));
return
(
double
)(
*
((
int
*
)(
val_expr
->
term
.
param
->
engine_val
)));
case
P_TYPE_DOUBLE
:
case
P_TYPE_DOUBLE
:
#ifdef EVAL_DEBUG
#ifdef EVAL_DEBUG
printf
(
"(%s:%.4f)"
,
val_expr
->
term
.
param
->
name
,
(
*
((
double
*
)
val_expr
->
term
.
param
->
engine_val
)));
printf
(
"(%s:%.4f)"
,
val_expr
->
term
.
param
->
name
,
(
*
((
double
*
)
val_expr
->
term
.
param
->
engine_val
)));
fflush
(
stdout
);
fflush
(
stdout
);
#endif
#endif
if
(
val_expr
->
term
.
param
->
matrix_flag
|
(
val_expr
->
term
.
param
->
flags
&
P_FLAG_ALWAYS_MATRIX
))
{
if
(
val_expr
->
term
.
param
->
matrix_flag
|
(
val_expr
->
term
.
param
->
flags
&
P_FLAG_ALWAYS_MATRIX
))
{
if
(
mesh_j
>=
0
)
{
if
(
mesh_j
>=
0
)
{
return
(((
double
**
)
val_expr
->
term
.
param
->
matrix
)[
mesh_i
][
mesh_j
]);
return
(((
double
**
)
val_expr
->
term
.
param
->
matrix
)[
mesh_i
][
mesh_j
]);
}
}
else
{
else
{
return
(((
double
*
)
val_expr
->
term
.
param
->
matrix
)[
mesh_i
]);
return
(((
double
*
)
val_expr
->
term
.
param
->
matrix
)[
mesh_i
]);
}
}
}
}
return
*
((
double
*
)(
val_expr
->
term
.
param
->
engine_val
));
return
*
((
double
*
)(
val_expr
->
term
.
param
->
engine_val
));
default:
default:
return
ERROR
;
return
ERROR
;
}
}
}
}
/* Unknown type, return failure */
/* Unknown type, return failure */
...
@@ -169,107 +169,107 @@ static inline double eval_val_expr(val_expr_t * val_expr) {
...
@@ -169,107 +169,107 @@ static inline double eval_val_expr(val_expr_t * val_expr) {
/* Evaluates an expression tree */
/* Evaluates an expression tree */
static
inline
double
eval_tree_expr
(
tree_expr_t
*
tree_expr
)
{
static
inline
double
eval_tree_expr
(
tree_expr_t
*
tree_expr
)
{
double
left_arg
,
right_arg
;
double
left_arg
,
right_arg
;
infix_op_t
*
infix_op
;
infix_op_t
*
infix_op
;
/* Shouldn't happen */
/* Shouldn't happen */
if
(
tree_expr
==
NULL
)
if
(
tree_expr
==
NULL
)
return
EVAL_ERROR
;
return
EVAL_ERROR
;
/* A leaf node, evaluate the general expression. If the expression is null as well, return zero */
/* A leaf node, evaluate the general expression. If the expression is null as well, return zero */
if
(
tree_expr
->
infix_op
==
NULL
)
{
if
(
tree_expr
->
infix_op
==
NULL
)
{
if
(
tree_expr
->
gen_expr
==
NULL
)
if
(
tree_expr
->
gen_expr
==
NULL
)
return
0
;
return
0
;
else
else
return
eval_gen_expr
(
tree_expr
->
gen_expr
);
return
eval_gen_expr
(
tree_expr
->
gen_expr
);
}
}
/* Otherwise, this node is an infix operator. Evaluate
/* Otherwise, this node is an infix operator. Evaluate
accordingly */
accordingly */
infix_op
=
(
infix_op_t
*
)
tree_expr
->
infix_op
;
infix_op
=
(
infix_op_t
*
)
tree_expr
->
infix_op
;
#ifdef EVAL_DEBUG
#ifdef EVAL_DEBUG
printf
(
"("
);
printf
(
"("
);
fflush
(
stdout
);
fflush
(
stdout
);
#endif
#endif
left_arg
=
eval_tree_expr
(
tree_expr
->
left
);
left_arg
=
eval_tree_expr
(
tree_expr
->
left
);
#ifdef EVAL_DEBUG
#ifdef EVAL_DEBUG
switch
(
infix_op
->
type
)
{
switch
(
infix_op
->
type
)
{
case
INFIX_ADD
:
case
INFIX_ADD
:
printf
(
"+"
);
printf
(
"+"
);
break
;
break
;
case
INFIX_MINUS
:
case
INFIX_MINUS
:
printf
(
"-"
);
printf
(
"-"
);
break
;
break
;
case
INFIX_MULT
:
case
INFIX_MULT
:
printf
(
"*"
);
printf
(
"*"
);
break
;
break
;
case
INFIX_MOD
:
case
INFIX_MOD
:
printf
(
"%%"
);
printf
(
"%%"
);
break
;
break
;
case
INFIX_OR
:
case
INFIX_OR
:
printf
(
"|"
);
printf
(
"|"
);
break
;
break
;
case
INFIX_AND
:
case
INFIX_AND
:
printf
(
"&"
);
printf
(
"&"
);
break
;
break
;
case
INFIX_DIV
:
case
INFIX_DIV
:
printf
(
"/"
);
printf
(
"/"
);
break
;
break
;
default:
default:
printf
(
"?"
);
printf
(
"?"
);
}
}
fflush
(
stdout
);
fflush
(
stdout
);
#endif
#endif
right_arg
=
eval_tree_expr
(
tree_expr
->
right
);
right_arg
=
eval_tree_expr
(
tree_expr
->
right
);
#ifdef EVAL_DEBUG
#ifdef EVAL_DEBUG
printf
(
")"
);
printf
(
")"
);
fflush
(
stdout
);
fflush
(
stdout
);
#endif
#endif
switch
(
infix_op
->
type
)
{
switch
(
infix_op
->
type
)
{
case
INFIX_ADD
:
case
INFIX_ADD
:
return
(
left_arg
+
right_arg
);
return
(
left_arg
+
right_arg
);
case
INFIX_MINUS
:
case
INFIX_MINUS
:
return
(
left_arg
-
right_arg
);
return
(
left_arg
-
right_arg
);
case
INFIX_MULT
:
case
INFIX_MULT
:
return
(
left_arg
*
right_arg
);
return
(
left_arg
*
right_arg
);
case
INFIX_MOD
:
case
INFIX_MOD
:
if
((
int
)
right_arg
==
0
)
{
if
((
int
)
right_arg
==
0
)
{
#ifdef EVAL_DEBUG
#ifdef EVAL_DEBUG
printf
(
"eval_tree_expr: modulo zero!
\n
"
);
printf
(
"eval_tree_expr: modulo zero!
\n
"
);
#endif
#endif
return
DIV_BY_ZERO
;
return
DIV_BY_ZERO
;
}
}
return
((
int
)
left_arg
%
(
int
)
right_arg
);
return
((
int
)
left_arg
%
(
int
)
right_arg
);
case
INFIX_OR
:
case
INFIX_OR
:
return
((
int
)
left_arg
|
(
int
)
right_arg
);
return
((
int
)
left_arg
|
(
int
)
right_arg
);
case
INFIX_AND
:
case
INFIX_AND
:
return
((
int
)
left_arg
&
(
int
)
right_arg
);
return
((
int
)
left_arg
&
(
int
)
right_arg
);
case
INFIX_DIV
:
case
INFIX_DIV
:
if
(
right_arg
==
0
)
{
if
(
right_arg
==
0
)
{
#ifdef EVAL_DEBUG
#ifdef EVAL_DEBUG
printf
(
"eval_tree_expr: division by zero!
\n
"
);
printf
(
"eval_tree_expr: division by zero!
\n
"
);
#endif
#endif
return
MAX_DOUBLE_SIZE
;
return
MAX_DOUBLE_SIZE
;
}
}
return
(
left_arg
/
right_arg
);
return
(
left_arg
/
right_arg
);
default:
default:
#ifdef EVAL_DEBUG
#ifdef EVAL_DEBUG
printf
(
"eval_tree_expr: unknown infix operator!
\n
"
);
printf
(
"eval_tree_expr: unknown infix operator!
\n
"
);
#endif
#endif
return
ERROR
;
return
ERROR
;
}
}
return
ERROR
;
return
ERROR
;
}
}
/* Converts a double value to a general expression */
/* Converts a double value to a general expression */
gen_expr_t
*
const_to_expr
(
double
val
)
{
gen_expr_t
*
const_to_expr
(
double
val
)
{
...
@@ -277,18 +277,18 @@ gen_expr_t * const_to_expr(double val) {
...
@@ -277,18 +277,18 @@ gen_expr_t * const_to_expr(double val) {
gen_expr_t
*
gen_expr
;
gen_expr_t
*
gen_expr
;
val_expr_t
*
val_expr
;
val_expr_t
*
val_expr
;
term_t
term
;
term_t
term
;
term
.
constant
=
val
;
term
.
constant
=
val
;
if
((
val_expr
=
new_val_expr
(
CONSTANT_TERM_T
,
term
))
==
NULL
)
if
((
val_expr
=
new_val_expr
(
CONSTANT_TERM_T
,
term
))
==
NULL
)
return
NULL
;
return
NULL
;
gen_expr
=
new_gen_expr
(
VAL_T
,
(
void
*
)
val_expr
);
gen_expr
=
new_gen_expr
(
VAL_T
,
(
void
*
)
val_expr
);
if
(
gen_expr
==
NULL
)
{
if
(
gen_expr
==
NULL
)
{
free_val_expr
(
val_expr
);
free_val_expr
(
val_expr
);
}
}
return
gen_expr
;
return
gen_expr
;
}
}
...
@@ -303,27 +303,27 @@ gen_expr_t * param_to_expr(param_t * param) {
...
@@ -303,27 +303,27 @@ gen_expr_t * param_to_expr(param_t * param) {
return
NULL
;
return
NULL
;
/* This code is still a work in progress. We need
/* This code is still a work in progress. We need
to figure out if the initial condition is used for
to figure out if the initial condition is used for
each per frame equation or not. I am guessing that
each per frame equation or not. I am guessing that
it isn't, and it is thusly implemented this way */
it isn't, and it is thusly implemented this way */
/* Current guess of true behavior (08/01/03) note from carm
/* Current guess of true behavior (08/01/03) note from carm
First try to use the per_pixel_expr (with cloning).
First try to use the per_pixel_expr (with cloning).
If it is null however, use the engine variable instead. */
If it is null however, use the engine variable instead. */
/* 08/20/03 : Presets are now objects, as well as per pixel equations. This ends up
/* 08/20/03 : Presets are now objects, as well as per pixel equations. This ends up
making the parser handle the case where parameters are essentially per pixel equation
making the parser handle the case where parameters are essentially per pixel equation
substitutions */
substitutions */
term
.
param
=
param
;
term
.
param
=
param
;
if
((
val_expr
=
new_val_expr
(
PARAM_TERM_T
,
term
))
==
NULL
)
if
((
val_expr
=
new_val_expr
(
PARAM_TERM_T
,
term
))
==
NULL
)
return
NULL
;
return
NULL
;
if
((
gen_expr
=
new_gen_expr
(
VAL_T
,
(
void
*
)
val_expr
))
==
NULL
)
{
if
((
gen_expr
=
new_gen_expr
(
VAL_T
,
(
void
*
)
val_expr
))
==
NULL
)
{
free_val_expr
(
val_expr
);
free_val_expr
(
val_expr
);
return
NULL
;
return
NULL
;
}
}
return
gen_expr
;
return
gen_expr
;
}
}
...
@@ -332,14 +332,14 @@ gen_expr_t * prefun_to_expr(double (*func_ptr)(), gen_expr_t ** expr_list, int n
...
@@ -332,14 +332,14 @@ gen_expr_t * prefun_to_expr(double (*func_ptr)(), gen_expr_t ** expr_list, int n
gen_expr_t
*
gen_expr
;
gen_expr_t
*
gen_expr
;
prefun_expr_t
*
prefun_expr
;
prefun_expr_t
*
prefun_expr
;
/* Malloc a new prefix function expression */
/* Malloc a new prefix function expression */
prefun_expr
=
(
prefun_expr_t
*
)
malloc
(
sizeof
(
prefun_expr_t
));
prefun_expr
=
(
prefun_expr_t
*
)
malloc
(
sizeof
(
prefun_expr_t
));
if
(
prefun_expr
==
NULL
)
if
(
prefun_expr
==
NULL
)
return
NULL
;
return
NULL
;
prefun_expr
->
num_args
=
num_args
;
prefun_expr
->
num_args
=
num_args
;
prefun_expr
->
func_ptr
=
func_ptr
;
prefun_expr
->
func_ptr
=
func_ptr
;
prefun_expr
->
expr_list
=
expr_list
;
prefun_expr
->
expr_list
=
expr_list
;
...
@@ -347,24 +347,24 @@ gen_expr_t * prefun_to_expr(double (*func_ptr)(), gen_expr_t ** expr_list, int n
...
@@ -347,24 +347,24 @@ gen_expr_t * prefun_to_expr(double (*func_ptr)(), gen_expr_t ** expr_list, int n
gen_expr
=
new_gen_expr
(
PREFUN_T
,
(
void
*
)
prefun_expr
);
gen_expr
=
new_gen_expr
(
PREFUN_T
,
(
void
*
)
prefun_expr
);
if
(
gen_expr
==
NULL
)
if
(
gen_expr
==
NULL
)
free_prefun_expr
(
prefun_expr
);
free_prefun_expr
(
prefun_expr
);
return
gen_expr
;
return
gen_expr
;
}
}
/* Creates a new tree expression */
/* Creates a new tree expression */
tree_expr_t
*
new_tree_expr
(
infix_op_t
*
infix_op
,
gen_expr_t
*
gen_expr
,
tree_expr_t
*
left
,
tree_expr_t
*
right
)
{
tree_expr_t
*
new_tree_expr
(
infix_op_t
*
infix_op
,
gen_expr_t
*
gen_expr
,
tree_expr_t
*
left
,
tree_expr_t
*
right
)
{
tree_expr_t
*
tree_expr
;
tree_expr_t
*
tree_expr
;
tree_expr
=
(
tree_expr_t
*
)
malloc
(
sizeof
(
tree_expr_t
));
tree_expr
=
(
tree_expr_t
*
)
malloc
(
sizeof
(
tree_expr_t
));
if
(
tree_expr
==
NULL
)
if
(
tree_expr
==
NULL
)
return
NULL
;
return
NULL
;
tree_expr
->
infix_op
=
infix_op
;
tree_expr
->
infix_op
=
infix_op
;
tree_expr
->
gen_expr
=
gen_expr
;
tree_expr
->
gen_expr
=
gen_expr
;
tree_expr
->
left
=
left
;
tree_expr
->
left
=
left
;
tree_expr
->
right
=
right
;
tree_expr
->
right
=
right
;
return
tree_expr
;
return
tree_expr
;
}
}
...
@@ -386,39 +386,39 @@ val_expr_t * new_val_expr(int type, term_t term) {
...
@@ -386,39 +386,39 @@ val_expr_t * new_val_expr(int type, term_t term) {
/* Creates a new general expression */
/* Creates a new general expression */
gen_expr_t
*
new_gen_expr
(
int
type
,
void
*
item
)
{
gen_expr_t
*
new_gen_expr
(
int
type
,
void
*
item
)
{
gen_expr_t
*
gen_expr
;
gen_expr_t
*
gen_expr
;
gen_expr
=
(
gen_expr_t
*
)
malloc
(
sizeof
(
gen_expr_t
));
gen_expr
=
(
gen_expr_t
*
)
malloc
(
sizeof
(
gen_expr_t
));
if
(
gen_expr
==
NULL
)
if
(
gen_expr
==
NULL
)
return
NULL
;
return
NULL
;
gen_expr
->
type
=
type
;
gen_expr
->
type
=
type
;
gen_expr
->
item
=
item
;
gen_expr
->
item
=
item
;
return
gen_expr
;
return
gen_expr
;
}
}
/* Frees a general expression */
/* Frees a general expression */
int
free_gen_expr
(
gen_expr_t
*
gen_expr
)
{
int
free_gen_expr
(
gen_expr_t
*
gen_expr
)
{
if
(
gen_expr
==
NULL
)
if
(
gen_expr
==
NULL
)
return
SUCCESS
;
return
SUCCESS
;
switch
(
gen_expr
->
type
)
{
switch
(
gen_expr
->
type
)
{
case
VAL_T
:
case
VAL_T
:
free_val_expr
(
gen_expr
->
item
);
free_val_expr
(
gen_expr
->
item
);
break
;
break
;
case
PREFUN_T
:
case
PREFUN_T
:
free_prefun_expr
(
gen_expr
->
item
);
free_prefun_expr
(
gen_expr
->
item
);
break
;
break
;
case
TREE_T
:
case
TREE_T
:
free_tree_expr
(
gen_expr
->
item
);
free_tree_expr
(
gen_expr
->
item
);
break
;
break
;
default:
default:
return
FAILURE
;
return
FAILURE
;
}
}
free
(
gen_expr
);
free
(
gen_expr
);
return
SUCCESS
;
return
SUCCESS
;
}
}
...
@@ -426,52 +426,52 @@ int free_gen_expr(gen_expr_t * gen_expr) {
...
@@ -426,52 +426,52 @@ int free_gen_expr(gen_expr_t * gen_expr) {
/* Frees a function in prefix notation */
/* Frees a function in prefix notation */
int
free_prefun_expr
(
prefun_expr_t
*
prefun_expr
)
{
int
free_prefun_expr
(
prefun_expr_t
*
prefun_expr
)
{
int
i
;
int
i
;
if
(
prefun_expr
==
NULL
)
if
(
prefun_expr
==
NULL
)
return
SUCCESS
;
return
SUCCESS
;
/* Free every element in expression list */
/* Free every element in expression list */
for
(
i
=
0
;
i
<
prefun_expr
->
num_args
;
i
++
)
{
for
(
i
=
0
;
i
<
prefun_expr
->
num_args
;
i
++
)
{
free_gen_expr
(
prefun_expr
->
expr_list
[
i
]);
free_gen_expr
(
prefun_expr
->
expr_list
[
i
]);
}
}
free
(
prefun_expr
);
free
(
prefun_expr
);
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Frees values of type VARIABLE and CONSTANT */
/* Frees values of type VARIABLE and CONSTANT */
int
free_val_expr
(
val_expr_t
*
val_expr
)
{
int
free_val_expr
(
val_expr_t
*
val_expr
)
{
if
(
val_expr
==
NULL
)
if
(
val_expr
==
NULL
)
return
SUCCESS
;
return
SUCCESS
;
free
(
val_expr
);
free
(
val_expr
);
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Frees a tree expression */
/* Frees a tree expression */
int
free_tree_expr
(
tree_expr_t
*
tree_expr
)
{
int
free_tree_expr
(
tree_expr_t
*
tree_expr
)
{
if
(
tree_expr
==
NULL
)
if
(
tree_expr
==
NULL
)
return
SUCCESS
;
return
SUCCESS
;
/* free left tree */
/* free left tree */
free_tree_expr
(
tree_expr
->
left
);
free_tree_expr
(
tree_expr
->
left
);
/* free general expression object */
/* free general expression object */
free_gen_expr
(
tree_expr
->
gen_expr
);
free_gen_expr
(
tree_expr
->
gen_expr
);
/* Note that infix operators are always
/* Note that infix operators are always
stored in memory unless the program
stored in memory unless the program
exits, so we don't remove them here */
exits, so we don't remove them here */
/* free right tree */
/* free right tree */
free_tree_expr
(
tree_expr
->
right
);
free_tree_expr
(
tree_expr
->
right
);
/* finally, free the struct itself */
/* finally, free the struct itself */
free
(
tree_expr
);
free
(
tree_expr
);
return
SUCCESS
;
return
SUCCESS
;
}
}
...
@@ -479,19 +479,19 @@ int free_tree_expr(tree_expr_t * tree_expr) {
...
@@ -479,19 +479,19 @@ int free_tree_expr(tree_expr_t * tree_expr) {
/* Initializes all infix operators */
/* Initializes all infix operators */
int
init_infix_ops
()
{
int
init_infix_ops
()
{
infix_add
=
new_infix_op
(
INFIX_ADD
,
4
);
infix_add
=
new_infix_op
(
INFIX_ADD
,
4
);
infix_minus
=
new_infix_op
(
INFIX_MINUS
,
3
);
infix_minus
=
new_infix_op
(
INFIX_MINUS
,
3
);
infix_div
=
new_infix_op
(
INFIX_DIV
,
2
);
infix_div
=
new_infix_op
(
INFIX_DIV
,
2
);
infix_or
=
new_infix_op
(
INFIX_OR
,
5
);
infix_or
=
new_infix_op
(
INFIX_OR
,
5
);
infix_and
=
new_infix_op
(
INFIX_AND
,
4
);
infix_and
=
new_infix_op
(
INFIX_AND
,
4
);
infix_mod
=
new_infix_op
(
INFIX_MOD
,
1
);
infix_mod
=
new_infix_op
(
INFIX_MOD
,
1
);
infix_mult
=
new_infix_op
(
INFIX_MULT
,
2
);
infix_mult
=
new_infix_op
(
INFIX_MULT
,
2
);
/* Prefix operators */
/* Prefix operators */
infix_positive
=
new_infix_op
(
INFIX_ADD
,
0
);
infix_positive
=
new_infix_op
(
INFIX_ADD
,
0
);
infix_negative
=
new_infix_op
(
INFIX_MINUS
,
0
);
infix_negative
=
new_infix_op
(
INFIX_MINUS
,
0
);
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Destroys the infix operator list. This should
/* Destroys the infix operator list. This should
...
@@ -515,17 +515,17 @@ int destroy_infix_ops()
...
@@ -515,17 +515,17 @@ int destroy_infix_ops()
/* Initializes an infix operator */
/* Initializes an infix operator */
infix_op_t
*
new_infix_op
(
int
type
,
int
precedence
)
{
infix_op_t
*
new_infix_op
(
int
type
,
int
precedence
)
{
infix_op_t
*
infix_op
;
infix_op_t
*
infix_op
;
infix_op
=
(
infix_op_t
*
)
malloc
(
sizeof
(
infix_op_t
));
infix_op
=
(
infix_op_t
*
)
malloc
(
sizeof
(
infix_op_t
));
if
(
infix_op
==
NULL
)
if
(
infix_op
==
NULL
)
return
NULL
;
return
NULL
;
infix_op
->
type
=
type
;
infix_op
->
type
=
type
;
infix_op
->
precedence
=
precedence
;
infix_op
->
precedence
=
precedence
;
return
infix_op
;
return
infix_op
;
}
}
...
@@ -557,7 +557,7 @@ gen_expr_t * clone_gen_expr(gen_expr_t * gen_expr) {
...
@@ -557,7 +557,7 @@ gen_expr_t * clone_gen_expr(gen_expr_t * gen_expr) {
}
}
new_gen_expr
->
item
=
(
void
*
)
val_expr
;
new_gen_expr
->
item
=
(
void
*
)
val_expr
;
break
;
break
;
case
PREFUN_T
:
/* prefix function expression */
case
PREFUN_T
:
/* prefix function expression */
if
((
prefun_expr
=
clone_prefun_expr
((
prefun_expr_t
*
)
gen_expr
->
item
))
==
NULL
)
{
if
((
prefun_expr
=
clone_prefun_expr
((
prefun_expr_t
*
)
gen_expr
->
item
))
==
NULL
)
{
free
(
new_gen_expr
);
free
(
new_gen_expr
);
...
@@ -565,7 +565,7 @@ gen_expr_t * clone_gen_expr(gen_expr_t * gen_expr) {
...
@@ -565,7 +565,7 @@ gen_expr_t * clone_gen_expr(gen_expr_t * gen_expr) {
}
}
new_gen_expr
->
item
=
(
void
*
)
prefun_expr
;
new_gen_expr
->
item
=
(
void
*
)
prefun_expr
;
break
;
break
;
case
TREE_T
:
/* tree expression */
case
TREE_T
:
/* tree expression */
if
((
tree_expr
=
clone_tree_expr
((
tree_expr_t
*
)
gen_expr
->
item
))
==
NULL
)
{
if
((
tree_expr
=
clone_tree_expr
((
tree_expr_t
*
)
gen_expr
->
item
))
==
NULL
)
{
free
(
new_gen_expr
);
free
(
new_gen_expr
);
...
@@ -573,12 +573,12 @@ gen_expr_t * clone_gen_expr(gen_expr_t * gen_expr) {
...
@@ -573,12 +573,12 @@ gen_expr_t * clone_gen_expr(gen_expr_t * gen_expr) {
}
}
new_gen_expr
->
item
=
(
void
*
)
tree_expr
;
new_gen_expr
->
item
=
(
void
*
)
tree_expr
;
break
;
break
;
default:
/* unknown type, ut oh.. */
default:
/* unknown type, ut oh.. */
free
(
new_gen_expr
);
free
(
new_gen_expr
);
return
NULL
;
return
NULL
;
}
}
return
new_gen_expr
;
/* Return the new (cloned) general expression */
return
new_gen_expr
;
/* Return the new (cloned) general expression */
}
}
...
@@ -591,11 +591,11 @@ tree_expr_t * clone_tree_expr(tree_expr_t * tree_expr) {
...
@@ -591,11 +591,11 @@ tree_expr_t * clone_tree_expr(tree_expr_t * tree_expr) {
/* Null argument */
/* Null argument */
if
(
tree_expr
==
NULL
)
if
(
tree_expr
==
NULL
)
return
NULL
;
return
NULL
;
/* Out of memory */
/* Out of memory */
if
((
new_tree_expr
=
(
tree_expr_t
*
)
malloc
(
sizeof
(
tree_expr_t
)))
==
NULL
)
if
((
new_tree_expr
=
(
tree_expr_t
*
)
malloc
(
sizeof
(
tree_expr_t
)))
==
NULL
)
return
NULL
;
return
NULL
;
/* Set each argument in tree_expr_t struct */
/* Set each argument in tree_expr_t struct */
new_tree_expr
->
infix_op
=
tree_expr
->
infix_op
;
/* infix operators are in shared memory */
new_tree_expr
->
infix_op
=
tree_expr
->
infix_op
;
/* infix operators are in shared memory */
new_tree_expr
->
gen_expr
=
clone_gen_expr
(
tree_expr
->
gen_expr
);
/* clone the general expression */
new_tree_expr
->
gen_expr
=
clone_gen_expr
(
tree_expr
->
gen_expr
);
/* clone the general expression */
...
@@ -605,7 +605,7 @@ tree_expr_t * clone_tree_expr(tree_expr_t * tree_expr) {
...
@@ -605,7 +605,7 @@ tree_expr_t * clone_tree_expr(tree_expr_t * tree_expr) {
return
new_tree_expr
;
/* Return the new (cloned) tree expression */
return
new_tree_expr
;
/* Return the new (cloned) tree expression */
}
}
/* Clones a value expression, currently only passes the pointer to
/* Clones a value expression, currently only passes the pointer to
the value that this object represents, not a pointer to a copy of the value */
the value that this object represents, not a pointer to a copy of the value */
val_expr_t
*
clone_val_expr
(
val_expr_t
*
val_expr
)
{
val_expr_t
*
clone_val_expr
(
val_expr_t
*
val_expr
)
{
...
@@ -614,15 +614,15 @@ val_expr_t * clone_val_expr(val_expr_t * val_expr) {
...
@@ -614,15 +614,15 @@ val_expr_t * clone_val_expr(val_expr_t * val_expr) {
/* Null argument */
/* Null argument */
if
(
val_expr
==
NULL
)
if
(
val_expr
==
NULL
)
return
NULL
;
return
NULL
;
/* Allocate space, check for out of memory */
/* Allocate space, check for out of memory */
if
((
new_val_expr
=
(
val_expr_t
*
)
malloc
(
sizeof
(
val_expr_t
)))
==
NULL
)
if
((
new_val_expr
=
(
val_expr_t
*
)
malloc
(
sizeof
(
val_expr_t
)))
==
NULL
)
return
NULL
;
return
NULL
;
/* Set the values in the val_expr_t struct */
/* Set the values in the val_expr_t struct */
new_val_expr
->
type
=
val_expr
->
type
;
new_val_expr
->
type
=
val_expr
->
type
;
new_val_expr
->
term
=
val_expr
->
term
;
new_val_expr
->
term
=
val_expr
->
term
;
/* Return the new (cloned) value expression */
/* Return the new (cloned) value expression */
return
new_val_expr
;
return
new_val_expr
;
}
}
...
@@ -632,15 +632,15 @@ prefun_expr_t * clone_prefun_expr(prefun_expr_t * prefun_expr) {
...
@@ -632,15 +632,15 @@ prefun_expr_t * clone_prefun_expr(prefun_expr_t * prefun_expr) {
int
i
;
int
i
;
prefun_expr_t
*
new_prefun_expr
;
prefun_expr_t
*
new_prefun_expr
;
/* Null argument */
/* Null argument */
if
(
prefun_expr
==
NULL
)
if
(
prefun_expr
==
NULL
)
return
NULL
;
return
NULL
;
/* Out of memory */
/* Out of memory */
if
((
new_prefun_expr
=
(
prefun_expr_t
*
)
malloc
(
sizeof
(
prefun_expr_t
)))
==
NULL
)
if
((
new_prefun_expr
=
(
prefun_expr_t
*
)
malloc
(
sizeof
(
prefun_expr_t
)))
==
NULL
)
return
NULL
;
return
NULL
;
/* Set the function argument paired with its number of arguments */
/* Set the function argument paired with its number of arguments */
new_prefun_expr
->
num_args
=
prefun_expr
->
num_args
;
new_prefun_expr
->
num_args
=
prefun_expr
->
num_args
;
new_prefun_expr
->
func_ptr
=
prefun_expr
->
func_ptr
;
new_prefun_expr
->
func_ptr
=
prefun_expr
->
func_ptr
;
...
@@ -652,9 +652,9 @@ prefun_expr_t * clone_prefun_expr(prefun_expr_t * prefun_expr) {
...
@@ -652,9 +652,9 @@ prefun_expr_t * clone_prefun_expr(prefun_expr_t * prefun_expr) {
}
}
/* Now copy each general expression from the argument expression list */
/* Now copy each general expression from the argument expression list */
for
(
i
=
0
;
i
<
new_prefun_expr
->
num_args
;
i
++
)
for
(
i
=
0
;
i
<
new_prefun_expr
->
num_args
;
i
++
)
new_prefun_expr
->
expr_list
[
i
]
=
clone_gen_expr
(
prefun_expr
->
expr_list
[
i
]);
new_prefun_expr
->
expr_list
[
i
]
=
clone_gen_expr
(
prefun_expr
->
expr_list
[
i
]);
/* Finally, return the new (cloned) prefix function expression */
/* Finally, return the new (cloned) prefix function expression */
return
new_prefun_expr
;
return
new_prefun_expr
;
}
}
...
@@ -666,7 +666,7 @@ void reset_engine_vars() {
...
@@ -666,7 +666,7 @@ void reset_engine_vars() {
zoomexp
=
1
.
0
;
zoomexp
=
1
.
0
;
rot
=
0
.
0
;
rot
=
0
.
0
;
warp
=
0
.
0
;
warp
=
0
.
0
;
sx
=
1
.
0
;
sx
=
1
.
0
;
sy
=
1
.
0
;
sy
=
1
.
0
;
dx
=
0
.
0
;
dx
=
0
.
0
;
...
@@ -674,9 +674,9 @@ void reset_engine_vars() {
...
@@ -674,9 +674,9 @@ void reset_engine_vars() {
cx
=
0
.
5
;
cx
=
0
.
5
;
cy
=
0
.
5
;
cy
=
0
.
5
;
decay
=
.
98
;
decay
=
.
98
;
wave_r
=
1
.
0
;
wave_r
=
1
.
0
;
wave_g
=
0
.
2
;
wave_g
=
0
.
2
;
wave_b
=
0
.
0
;
wave_b
=
0
.
0
;
...
@@ -705,7 +705,7 @@ void reset_engine_vars() {
...
@@ -705,7 +705,7 @@ void reset_engine_vars() {
mv_y
=
12
.
0
;
mv_y
=
12
.
0
;
mv_dy
=
0
.
02
;
mv_dy
=
0
.
02
;
mv_dx
=
0
.
02
;
mv_dx
=
0
.
02
;
meshx
=
0
;
meshx
=
0
;
meshy
=
0
;
meshy
=
0
;
...
...
modules/visualization/galaktos/eval.h
View file @
d6008a8b
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
#define INFIX_OR 5
#define INFIX_OR 5
#define INFIX_AND 6
#define INFIX_AND 6
//#define EVAL_DEBUG
//#define EVAL_DEBUG
inline
double
eval_gen_expr
(
gen_expr_t
*
gen_expr
);
inline
double
eval_gen_expr
(
gen_expr_t
*
gen_expr
);
...
...
modules/visualization/galaktos/expr_types.h
View file @
d6008a8b
...
@@ -25,7 +25,7 @@ typedef struct VAL_EXPR_T {
...
@@ -25,7 +25,7 @@ typedef struct VAL_EXPR_T {
/* Infix Operator Function */
/* Infix Operator Function */
typedef
struct
INFIX_OP_T
{
typedef
struct
INFIX_OP_T
{
int
type
;
int
type
;
int
precedence
;
int
precedence
;
}
infix_op_t
;
}
infix_op_t
;
/* A binary expression tree ordered by operator precedence */
/* A binary expression tree ordered by operator precedence */
...
...
modules/visualization/galaktos/fftsg.c
View file @
d6008a8b
...
@@ -74,23 +74,23 @@ macro definitions
...
@@ -74,23 +74,23 @@ macro definitions
n >= 1, n = power of 2
n >= 1, n = power of 2
a[0...2*n-1] :input/output data (double *)
a[0...2*n-1] :input/output data (double *)
input data
input data
a[2*j] = Re(x[j]),
a[2*j] = Re(x[j]),
a[2*j+1] = Im(x[j]), 0<=j<n
a[2*j+1] = Im(x[j]), 0<=j<n
output data
output data
a[2*k] = Re(X[k]),
a[2*k] = Re(X[k]),
a[2*k+1] = Im(X[k]), 0<=k<n
a[2*k+1] = Im(X[k]), 0<=k<n
ip[0...*] :work area for bit reversal (int *)
ip[0...*] :work area for bit reversal (int *)
length of ip >= 2+sqrt(n)
length of ip >= 2+sqrt(n)
strictly,
strictly,
length of ip >=
length of ip >=
2+(1<<(int)(log(n+0.5)/log(2))/2).
2+(1<<(int)(log(n+0.5)/log(2))/2).
ip[0],ip[1] are pointers of the cos/sin table.
ip[0],ip[1] are pointers of the cos/sin table.
w[0...n/2-1] :cos/sin table (double *)
w[0...n/2-1] :cos/sin table (double *)
w[],ip[] are initialized if ip[0] == 0.
w[],ip[] are initialized if ip[0] == 0.
[remark]
[remark]
Inverse of
Inverse of
cdft(2*n, -1, a, ip, w);
cdft(2*n, -1, a, ip, w);
is
is
cdft(2*n, 1, a, ip, w);
cdft(2*n, 1, a, ip, w);
for (j = 0; j <= 2 * n - 1; j++) {
for (j = 0; j <= 2 * n - 1; j++) {
a[j] *= 1.0 / n;
a[j] *= 1.0 / n;
...
@@ -104,8 +104,8 @@ macro definitions
...
@@ -104,8 +104,8 @@ macro definitions
R[k] = sum_j=0^n-1 a[j]*cos(2*pi*j*k/n), 0<=k<=n/2
R[k] = sum_j=0^n-1 a[j]*cos(2*pi*j*k/n), 0<=k<=n/2
I[k] = sum_j=0^n-1 a[j]*sin(2*pi*j*k/n), 0<k<n/2
I[k] = sum_j=0^n-1 a[j]*sin(2*pi*j*k/n), 0<k<n/2
<case2> IRDFT (excluding scale)
<case2> IRDFT (excluding scale)
a[k] = (R[0] + R[n/2]*cos(pi*k))/2 +
a[k] = (R[0] + R[n/2]*cos(pi*k))/2 +
sum_j=1^n/2-1 R[j]*cos(2*pi*j*k/n) +
sum_j=1^n/2-1 R[j]*cos(2*pi*j*k/n) +
sum_j=1^n/2-1 I[j]*sin(2*pi*j*k/n), 0<=k<n
sum_j=1^n/2-1 I[j]*sin(2*pi*j*k/n), 0<=k<n
[usage]
[usage]
<case1>
<case1>
...
@@ -130,16 +130,16 @@ macro definitions
...
@@ -130,16 +130,16 @@ macro definitions
a[1] = R[n/2]
a[1] = R[n/2]
ip[0...*] :work area for bit reversal (int *)
ip[0...*] :work area for bit reversal (int *)
length of ip >= 2+sqrt(n/2)
length of ip >= 2+sqrt(n/2)
strictly,
strictly,
length of ip >=
length of ip >=
2+(1<<(int)(log(n/2+0.5)/log(2))/2).
2+(1<<(int)(log(n/2+0.5)/log(2))/2).
ip[0],ip[1] are pointers of the cos/sin table.
ip[0],ip[1] are pointers of the cos/sin table.
w[0...n/2-1] :cos/sin table (double *)
w[0...n/2-1] :cos/sin table (double *)
w[],ip[] are initialized if ip[0] == 0.
w[],ip[] are initialized if ip[0] == 0.
[remark]
[remark]
Inverse of
Inverse of
rdft(n, 1, a, ip, w);
rdft(n, 1, a, ip, w);
is
is
rdft(n, -1, a, ip, w);
rdft(n, -1, a, ip, w);
for (j = 0; j <= n - 1; j++) {
for (j = 0; j <= n - 1; j++) {
a[j] *= 2.0 / n;
a[j] *= 2.0 / n;
...
@@ -168,16 +168,16 @@ macro definitions
...
@@ -168,16 +168,16 @@ macro definitions
a[k] = C[k], 0<=k<n
a[k] = C[k], 0<=k<n
ip[0...*] :work area for bit reversal (int *)
ip[0...*] :work area for bit reversal (int *)
length of ip >= 2+sqrt(n/2)
length of ip >= 2+sqrt(n/2)
strictly,
strictly,
length of ip >=
length of ip >=
2+(1<<(int)(log(n/2+0.5)/log(2))/2).
2+(1<<(int)(log(n/2+0.5)/log(2))/2).
ip[0],ip[1] are pointers of the cos/sin table.
ip[0],ip[1] are pointers of the cos/sin table.
w[0...n*5/4-1] :cos/sin table (double *)
w[0...n*5/4-1] :cos/sin table (double *)
w[],ip[] are initialized if ip[0] == 0.
w[],ip[] are initialized if ip[0] == 0.
[remark]
[remark]
Inverse of
Inverse of
ddct(n, -1, a, ip, w);
ddct(n, -1, a, ip, w);
is
is
a[0] *= 0.5;
a[0] *= 0.5;
ddct(n, 1, a, ip, w);
ddct(n, 1, a, ip, w);
for (j = 0; j <= n - 1; j++) {
for (j = 0; j <= n - 1; j++) {
...
@@ -215,16 +215,16 @@ macro definitions
...
@@ -215,16 +215,16 @@ macro definitions
a[0] = S[n]
a[0] = S[n]
ip[0...*] :work area for bit reversal (int *)
ip[0...*] :work area for bit reversal (int *)
length of ip >= 2+sqrt(n/2)
length of ip >= 2+sqrt(n/2)
strictly,
strictly,
length of ip >=
length of ip >=
2+(1<<(int)(log(n/2+0.5)/log(2))/2).
2+(1<<(int)(log(n/2+0.5)/log(2))/2).
ip[0],ip[1] are pointers of the cos/sin table.
ip[0],ip[1] are pointers of the cos/sin table.
w[0...n*5/4-1] :cos/sin table (double *)
w[0...n*5/4-1] :cos/sin table (double *)
w[],ip[] are initialized if ip[0] == 0.
w[],ip[] are initialized if ip[0] == 0.
[remark]
[remark]
Inverse of
Inverse of
ddst(n, -1, a, ip, w);
ddst(n, -1, a, ip, w);
is
is
a[0] *= 0.5;
a[0] *= 0.5;
ddst(n, 1, a, ip, w);
ddst(n, 1, a, ip, w);
for (j = 0; j <= n - 1; j++) {
for (j = 0; j <= n - 1; j++) {
...
@@ -248,18 +248,18 @@ macro definitions
...
@@ -248,18 +248,18 @@ macro definitions
t[0...n/2] :work area (double *)
t[0...n/2] :work area (double *)
ip[0...*] :work area for bit reversal (int *)
ip[0...*] :work area for bit reversal (int *)
length of ip >= 2+sqrt(n/4)
length of ip >= 2+sqrt(n/4)
strictly,
strictly,
length of ip >=
length of ip >=
2+(1<<(int)(log(n/4+0.5)/log(2))/2).
2+(1<<(int)(log(n/4+0.5)/log(2))/2).
ip[0],ip[1] are pointers of the cos/sin table.
ip[0],ip[1] are pointers of the cos/sin table.
w[0...n*5/8-1] :cos/sin table (double *)
w[0...n*5/8-1] :cos/sin table (double *)
w[],ip[] are initialized if ip[0] == 0.
w[],ip[] are initialized if ip[0] == 0.
[remark]
[remark]
Inverse of
Inverse of
a[0] *= 0.5;
a[0] *= 0.5;
a[n] *= 0.5;
a[n] *= 0.5;
dfct(n, a, t, ip, w);
dfct(n, a, t, ip, w);
is
is
a[0] *= 0.5;
a[0] *= 0.5;
a[n] *= 0.5;
a[n] *= 0.5;
dfct(n, a, t, ip, w);
dfct(n, a, t, ip, w);
...
@@ -285,16 +285,16 @@ macro definitions
...
@@ -285,16 +285,16 @@ macro definitions
t[0...n/2-1] :work area (double *)
t[0...n/2-1] :work area (double *)
ip[0...*] :work area for bit reversal (int *)
ip[0...*] :work area for bit reversal (int *)
length of ip >= 2+sqrt(n/4)
length of ip >= 2+sqrt(n/4)
strictly,
strictly,
length of ip >=
length of ip >=
2+(1<<(int)(log(n/4+0.5)/log(2))/2).
2+(1<<(int)(log(n/4+0.5)/log(2))/2).
ip[0],ip[1] are pointers of the cos/sin table.
ip[0],ip[1] are pointers of the cos/sin table.
w[0...n*5/8-1] :cos/sin table (double *)
w[0...n*5/8-1] :cos/sin table (double *)
w[],ip[] are initialized if ip[0] == 0.
w[],ip[] are initialized if ip[0] == 0.
[remark]
[remark]
Inverse of
Inverse of
dfst(n, a, t, ip, w);
dfst(n, a, t, ip, w);
is
is
dfst(n, a, t, ip, w);
dfst(n, a, t, ip, w);
for (j = 1; j <= n - 1; j++) {
for (j = 1; j <= n - 1; j++) {
a[j] *= 2.0 / n;
a[j] *= 2.0 / n;
...
@@ -314,7 +314,7 @@ void cdft(int n, int isgn, double *a, int *ip, double *w)
...
@@ -314,7 +314,7 @@ void cdft(int n, int isgn, double *a, int *ip, double *w)
void
cftfsub
(
int
n
,
double
*
a
,
int
*
ip
,
int
nw
,
double
*
w
);
void
cftfsub
(
int
n
,
double
*
a
,
int
*
ip
,
int
nw
,
double
*
w
);
void
cftbsub
(
int
n
,
double
*
a
,
int
*
ip
,
int
nw
,
double
*
w
);
void
cftbsub
(
int
n
,
double
*
a
,
int
*
ip
,
int
nw
,
double
*
w
);
int
nw
;
int
nw
;
nw
=
ip
[
0
];
nw
=
ip
[
0
];
if
(
n
>
(
nw
<<
2
))
{
if
(
n
>
(
nw
<<
2
))
{
nw
=
n
>>
2
;
nw
=
n
>>
2
;
...
@@ -338,7 +338,7 @@ void rdft(int n, int isgn, double *a, int *ip, double *w)
...
@@ -338,7 +338,7 @@ void rdft(int n, int isgn, double *a, int *ip, double *w)
void
rftbsub
(
int
n
,
double
*
a
,
int
nc
,
double
*
c
);
void
rftbsub
(
int
n
,
double
*
a
,
int
nc
,
double
*
c
);
int
nw
,
nc
;
int
nw
,
nc
;
double
xi
;
double
xi
;
nw
=
ip
[
0
];
nw
=
ip
[
0
];
if
(
n
>
(
nw
<<
2
))
{
if
(
n
>
(
nw
<<
2
))
{
nw
=
n
>>
2
;
nw
=
n
>>
2
;
...
@@ -383,7 +383,7 @@ void ddct(int n, int isgn, double *a, int *ip, double *w)
...
@@ -383,7 +383,7 @@ void ddct(int n, int isgn, double *a, int *ip, double *w)
void
dctsub
(
int
n
,
double
*
a
,
int
nc
,
double
*
c
);
void
dctsub
(
int
n
,
double
*
a
,
int
nc
,
double
*
c
);
int
j
,
nw
,
nc
;
int
j
,
nw
,
nc
;
double
xr
;
double
xr
;
nw
=
ip
[
0
];
nw
=
ip
[
0
];
if
(
n
>
(
nw
<<
2
))
{
if
(
n
>
(
nw
<<
2
))
{
nw
=
n
>>
2
;
nw
=
n
>>
2
;
...
@@ -439,7 +439,7 @@ void ddst(int n, int isgn, double *a, int *ip, double *w)
...
@@ -439,7 +439,7 @@ void ddst(int n, int isgn, double *a, int *ip, double *w)
void
dstsub
(
int
n
,
double
*
a
,
int
nc
,
double
*
c
);
void
dstsub
(
int
n
,
double
*
a
,
int
nc
,
double
*
c
);
int
j
,
nw
,
nc
;
int
j
,
nw
,
nc
;
double
xr
;
double
xr
;
nw
=
ip
[
0
];
nw
=
ip
[
0
];
if
(
n
>
(
nw
<<
2
))
{
if
(
n
>
(
nw
<<
2
))
{
nw
=
n
>>
2
;
nw
=
n
>>
2
;
...
@@ -493,7 +493,7 @@ void dfct(int n, double *a, double *t, int *ip, double *w)
...
@@ -493,7 +493,7 @@ void dfct(int n, double *a, double *t, int *ip, double *w)
void
dctsub
(
int
n
,
double
*
a
,
int
nc
,
double
*
c
);
void
dctsub
(
int
n
,
double
*
a
,
int
nc
,
double
*
c
);
int
j
,
k
,
l
,
m
,
mh
,
nw
,
nc
;
int
j
,
k
,
l
,
m
,
mh
,
nw
,
nc
;
double
xr
,
xi
,
yr
,
yi
;
double
xr
,
xi
,
yr
,
yi
;
nw
=
ip
[
0
];
nw
=
ip
[
0
];
if
(
n
>
(
nw
<<
3
))
{
if
(
n
>
(
nw
<<
3
))
{
nw
=
n
>>
3
;
nw
=
n
>>
3
;
...
@@ -586,7 +586,7 @@ void dfst(int n, double *a, double *t, int *ip, double *w)
...
@@ -586,7 +586,7 @@ void dfst(int n, double *a, double *t, int *ip, double *w)
void
dstsub
(
int
n
,
double
*
a
,
int
nc
,
double
*
c
);
void
dstsub
(
int
n
,
double
*
a
,
int
nc
,
double
*
c
);
int
j
,
k
,
l
,
m
,
mh
,
nw
,
nc
;
int
j
,
k
,
l
,
m
,
mh
,
nw
,
nc
;
double
xr
,
xi
,
yr
,
yi
;
double
xr
,
xi
,
yr
,
yi
;
nw
=
ip
[
0
];
nw
=
ip
[
0
];
if
(
n
>
(
nw
<<
3
))
{
if
(
n
>
(
nw
<<
3
))
{
nw
=
n
>>
3
;
nw
=
n
>>
3
;
...
@@ -671,7 +671,7 @@ void makewt(int nw, int *ip, double *w)
...
@@ -671,7 +671,7 @@ void makewt(int nw, int *ip, double *w)
void
makeipt
(
int
nw
,
int
*
ip
);
void
makeipt
(
int
nw
,
int
*
ip
);
int
j
,
nwh
,
nw0
,
nw1
;
int
j
,
nwh
,
nw0
,
nw1
;
double
delta
,
wn4r
,
wk1r
,
wk1i
,
wk3r
,
wk3i
;
double
delta
,
wn4r
,
wk1r
,
wk1i
,
wk3r
,
wk3i
;
ip
[
0
]
=
nw
;
ip
[
0
]
=
nw
;
ip
[
1
]
=
1
;
ip
[
1
]
=
1
;
if
(
nw
>
2
)
{
if
(
nw
>
2
)
{
...
@@ -730,7 +730,7 @@ void makewt(int nw, int *ip, double *w)
...
@@ -730,7 +730,7 @@ void makewt(int nw, int *ip, double *w)
void
makeipt
(
int
nw
,
int
*
ip
)
void
makeipt
(
int
nw
,
int
*
ip
)
{
{
int
j
,
l
,
m
,
m2
,
p
,
q
;
int
j
,
l
,
m
,
m2
,
p
,
q
;
ip
[
2
]
=
0
;
ip
[
2
]
=
0
;
ip
[
3
]
=
16
;
ip
[
3
]
=
16
;
m
=
2
;
m
=
2
;
...
@@ -751,7 +751,7 @@ void makect(int nc, int *ip, double *c)
...
@@ -751,7 +751,7 @@ void makect(int nc, int *ip, double *c)
{
{
int
j
,
nch
;
int
j
,
nch
;
double
delta
;
double
delta
;
ip
[
1
]
=
nc
;
ip
[
1
]
=
nc
;
if
(
nc
>
1
)
{
if
(
nc
>
1
)
{
nch
=
nc
>>
1
;
nch
=
nc
>>
1
;
...
@@ -835,14 +835,14 @@ void cftfsub(int n, double *a, int *ip, int nw, double *w)
...
@@ -835,14 +835,14 @@ void cftfsub(int n, double *a, int *ip, int nw, double *w)
#ifdef USE_CDFT_THREADS
#ifdef USE_CDFT_THREADS
void
cftrec4_th
(
int
n
,
double
*
a
,
int
nw
,
double
*
w
);
void
cftrec4_th
(
int
n
,
double
*
a
,
int
nw
,
double
*
w
);
#endif
/* USE_CDFT_THREADS */
#endif
/* USE_CDFT_THREADS */
if
(
n
>
8
)
{
if
(
n
>
8
)
{
if
(
n
>
32
)
{
if
(
n
>
32
)
{
cftf1st
(
n
,
a
,
&
w
[
nw
-
(
n
>>
2
)]);
cftf1st
(
n
,
a
,
&
w
[
nw
-
(
n
>>
2
)]);
#ifdef USE_CDFT_THREADS
#ifdef USE_CDFT_THREADS
if
(
n
>
CDFT_THREADS_BEGIN_N
)
{
if
(
n
>
CDFT_THREADS_BEGIN_N
)
{
cftrec4_th
(
n
,
a
,
nw
,
w
);
cftrec4_th
(
n
,
a
,
nw
,
w
);
}
else
}
else
#endif
/* USE_CDFT_THREADS */
#endif
/* USE_CDFT_THREADS */
if
(
n
>
512
)
{
if
(
n
>
512
)
{
cftrec4
(
n
,
a
,
nw
,
w
);
cftrec4
(
n
,
a
,
nw
,
w
);
...
@@ -883,14 +883,14 @@ void cftbsub(int n, double *a, int *ip, int nw, double *w)
...
@@ -883,14 +883,14 @@ void cftbsub(int n, double *a, int *ip, int nw, double *w)
#ifdef USE_CDFT_THREADS
#ifdef USE_CDFT_THREADS
void
cftrec4_th
(
int
n
,
double
*
a
,
int
nw
,
double
*
w
);
void
cftrec4_th
(
int
n
,
double
*
a
,
int
nw
,
double
*
w
);
#endif
/* USE_CDFT_THREADS */
#endif
/* USE_CDFT_THREADS */
if
(
n
>
8
)
{
if
(
n
>
8
)
{
if
(
n
>
32
)
{
if
(
n
>
32
)
{
cftb1st
(
n
,
a
,
&
w
[
nw
-
(
n
>>
2
)]);
cftb1st
(
n
,
a
,
&
w
[
nw
-
(
n
>>
2
)]);
#ifdef USE_CDFT_THREADS
#ifdef USE_CDFT_THREADS
if
(
n
>
CDFT_THREADS_BEGIN_N
)
{
if
(
n
>
CDFT_THREADS_BEGIN_N
)
{
cftrec4_th
(
n
,
a
,
nw
,
w
);
cftrec4_th
(
n
,
a
,
nw
,
w
);
}
else
}
else
#endif
/* USE_CDFT_THREADS */
#endif
/* USE_CDFT_THREADS */
if
(
n
>
512
)
{
if
(
n
>
512
)
{
cftrec4
(
n
,
a
,
nw
,
w
);
cftrec4
(
n
,
a
,
nw
,
w
);
...
@@ -919,7 +919,7 @@ void bitrv2(int n, int *ip, double *a)
...
@@ -919,7 +919,7 @@ void bitrv2(int n, int *ip, double *a)
{
{
int
j
,
j1
,
k
,
k1
,
l
,
m
,
nh
,
nm
;
int
j
,
j1
,
k
,
k1
,
l
,
m
,
nh
,
nm
;
double
xr
,
xi
,
yr
,
yi
;
double
xr
,
xi
,
yr
,
yi
;
m
=
1
;
m
=
1
;
for
(
l
=
n
>>
2
;
l
>
8
;
l
>>=
2
)
{
for
(
l
=
n
>>
2
;
l
>
8
;
l
>>=
2
)
{
m
<<=
1
;
m
<<=
1
;
...
@@ -1266,7 +1266,7 @@ void bitrv2conj(int n, int *ip, double *a)
...
@@ -1266,7 +1266,7 @@ void bitrv2conj(int n, int *ip, double *a)
{
{
int
j
,
j1
,
k
,
k1
,
l
,
m
,
nh
,
nm
;
int
j
,
j1
,
k
,
k1
,
l
,
m
,
nh
,
nm
;
double
xr
,
xi
,
yr
,
yi
;
double
xr
,
xi
,
yr
,
yi
;
m
=
1
;
m
=
1
;
for
(
l
=
n
>>
2
;
l
>
8
;
l
>>=
2
)
{
for
(
l
=
n
>>
2
;
l
>
8
;
l
>>=
2
)
{
m
<<=
1
;
m
<<=
1
;
...
@@ -1619,10 +1619,10 @@ void bitrv2conj(int n, int *ip, double *a)
...
@@ -1619,10 +1619,10 @@ void bitrv2conj(int n, int *ip, double *a)
void
bitrv216
(
double
*
a
)
void
bitrv216
(
double
*
a
)
{
{
double
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
x4r
,
x4i
,
double
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
x4r
,
x4i
,
x5r
,
x5i
,
x7r
,
x7i
,
x8r
,
x8i
,
x10r
,
x10i
,
x5r
,
x5i
,
x7r
,
x7i
,
x8r
,
x8i
,
x10r
,
x10i
,
x11r
,
x11i
,
x12r
,
x12i
,
x13r
,
x13i
,
x14r
,
x14i
;
x11r
,
x11i
,
x12r
,
x12i
,
x13r
,
x13i
,
x14r
,
x14i
;
x1r
=
a
[
2
];
x1r
=
a
[
2
];
x1i
=
a
[
3
];
x1i
=
a
[
3
];
x2r
=
a
[
4
];
x2r
=
a
[
4
];
...
@@ -1676,11 +1676,11 @@ void bitrv216(double *a)
...
@@ -1676,11 +1676,11 @@ void bitrv216(double *a)
void
bitrv216neg
(
double
*
a
)
void
bitrv216neg
(
double
*
a
)
{
{
double
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
x4r
,
x4i
,
double
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
x4r
,
x4i
,
x5r
,
x5i
,
x6r
,
x6i
,
x7r
,
x7i
,
x8r
,
x8i
,
x5r
,
x5i
,
x6r
,
x6i
,
x7r
,
x7i
,
x8r
,
x8i
,
x9r
,
x9i
,
x10r
,
x10i
,
x11r
,
x11i
,
x12r
,
x12i
,
x9r
,
x9i
,
x10r
,
x10i
,
x11r
,
x11i
,
x12r
,
x12i
,
x13r
,
x13i
,
x14r
,
x14i
,
x15r
,
x15i
;
x13r
,
x13i
,
x14r
,
x14i
,
x15r
,
x15i
;
x1r
=
a
[
2
];
x1r
=
a
[
2
];
x1i
=
a
[
3
];
x1i
=
a
[
3
];
x2r
=
a
[
4
];
x2r
=
a
[
4
];
...
@@ -1747,7 +1747,7 @@ void bitrv216neg(double *a)
...
@@ -1747,7 +1747,7 @@ void bitrv216neg(double *a)
void
bitrv208
(
double
*
a
)
void
bitrv208
(
double
*
a
)
{
{
double
x1r
,
x1i
,
x3r
,
x3i
,
x4r
,
x4i
,
x6r
,
x6i
;
double
x1r
,
x1i
,
x3r
,
x3i
,
x4r
,
x4i
,
x6r
,
x6i
;
x1r
=
a
[
2
];
x1r
=
a
[
2
];
x1i
=
a
[
3
];
x1i
=
a
[
3
];
x3r
=
a
[
6
];
x3r
=
a
[
6
];
...
@@ -1769,9 +1769,9 @@ void bitrv208(double *a)
...
@@ -1769,9 +1769,9 @@ void bitrv208(double *a)
void
bitrv208neg
(
double
*
a
)
void
bitrv208neg
(
double
*
a
)
{
{
double
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
x4r
,
x4i
,
double
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
x4r
,
x4i
,
x5r
,
x5i
,
x6r
,
x6i
,
x7r
,
x7i
;
x5r
,
x5i
,
x6r
,
x6i
,
x7r
,
x7i
;
x1r
=
a
[
2
];
x1r
=
a
[
2
];
x1i
=
a
[
3
];
x1i
=
a
[
3
];
x2r
=
a
[
4
];
x2r
=
a
[
4
];
...
@@ -1806,11 +1806,11 @@ void bitrv208neg(double *a)
...
@@ -1806,11 +1806,11 @@ void bitrv208neg(double *a)
void
cftf1st
(
int
n
,
double
*
a
,
double
*
w
)
void
cftf1st
(
int
n
,
double
*
a
,
double
*
w
)
{
{
int
j
,
j0
,
j1
,
j2
,
j3
,
k
,
m
,
mh
;
int
j
,
j0
,
j1
,
j2
,
j3
,
k
,
m
,
mh
;
double
wn4r
,
csc1
,
csc3
,
wk1r
,
wk1i
,
wk3r
,
wk3i
,
double
wn4r
,
csc1
,
csc3
,
wk1r
,
wk1i
,
wk3r
,
wk3i
,
wd1r
,
wd1i
,
wd3r
,
wd3i
;
wd1r
,
wd1i
,
wd3r
,
wd3i
;
double
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
double
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
y0r
,
y0i
,
y1r
,
y1i
,
y2r
,
y2i
,
y3r
,
y3i
;
y0r
,
y0i
,
y1r
,
y1i
,
y2r
,
y2i
,
y3r
,
y3i
;
mh
=
n
>>
3
;
mh
=
n
>>
3
;
m
=
2
*
mh
;
m
=
2
*
mh
;
j1
=
m
;
j1
=
m
;
...
@@ -2012,11 +2012,11 @@ void cftf1st(int n, double *a, double *w)
...
@@ -2012,11 +2012,11 @@ void cftf1st(int n, double *a, double *w)
void
cftb1st
(
int
n
,
double
*
a
,
double
*
w
)
void
cftb1st
(
int
n
,
double
*
a
,
double
*
w
)
{
{
int
j
,
j0
,
j1
,
j2
,
j3
,
k
,
m
,
mh
;
int
j
,
j0
,
j1
,
j2
,
j3
,
k
,
m
,
mh
;
double
wn4r
,
csc1
,
csc3
,
wk1r
,
wk1i
,
wk3r
,
wk3i
,
double
wn4r
,
csc1
,
csc3
,
wk1r
,
wk1i
,
wk3r
,
wk3i
,
wd1r
,
wd1i
,
wd3r
,
wd3i
;
wd1r
,
wd1i
,
wd3r
,
wd3i
;
double
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
double
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
y0r
,
y0i
,
y1r
,
y1i
,
y2r
,
y2i
,
y3r
,
y3i
;
y0r
,
y0i
,
y1r
,
y1i
,
y2r
,
y2i
,
y3r
,
y3i
;
mh
=
n
>>
3
;
mh
=
n
>>
3
;
m
=
2
*
mh
;
m
=
2
*
mh
;
j1
=
m
;
j1
=
m
;
...
@@ -2233,7 +2233,7 @@ void cftrec4_th(int n, double *a, int nw, double *w)
...
@@ -2233,7 +2233,7 @@ void cftrec4_th(int n, double *a, int nw, double *w)
int
i
,
idiv4
,
m
,
nthread
;
int
i
,
idiv4
,
m
,
nthread
;
cdft_thread_t
th
[
4
];
cdft_thread_t
th
[
4
];
cdft_arg_t
ag
[
4
];
cdft_arg_t
ag
[
4
];
nthread
=
2
;
nthread
=
2
;
idiv4
=
0
;
idiv4
=
0
;
m
=
n
>>
1
;
m
=
n
>>
1
;
...
@@ -2267,7 +2267,7 @@ void *cftrec1_th(void *p)
...
@@ -2267,7 +2267,7 @@ void *cftrec1_th(void *p)
void
cftmdl1
(
int
n
,
double
*
a
,
double
*
w
);
void
cftmdl1
(
int
n
,
double
*
a
,
double
*
w
);
int
isplt
,
j
,
k
,
m
,
n
,
n0
,
nw
;
int
isplt
,
j
,
k
,
m
,
n
,
n0
,
nw
;
double
*
a
,
*
w
;
double
*
a
,
*
w
;
n0
=
((
cdft_arg_t
*
)
p
)
->
n0
;
n0
=
((
cdft_arg_t
*
)
p
)
->
n0
;
n
=
((
cdft_arg_t
*
)
p
)
->
n
;
n
=
((
cdft_arg_t
*
)
p
)
->
n
;
a
=
((
cdft_arg_t
*
)
p
)
->
a
;
a
=
((
cdft_arg_t
*
)
p
)
->
a
;
...
@@ -2296,7 +2296,7 @@ void *cftrec2_th(void *p)
...
@@ -2296,7 +2296,7 @@ void *cftrec2_th(void *p)
void
cftmdl2
(
int
n
,
double
*
a
,
double
*
w
);
void
cftmdl2
(
int
n
,
double
*
a
,
double
*
w
);
int
isplt
,
j
,
k
,
m
,
n
,
n0
,
nw
;
int
isplt
,
j
,
k
,
m
,
n
,
n0
,
nw
;
double
*
a
,
*
w
;
double
*
a
,
*
w
;
n0
=
((
cdft_arg_t
*
)
p
)
->
n0
;
n0
=
((
cdft_arg_t
*
)
p
)
->
n0
;
n
=
((
cdft_arg_t
*
)
p
)
->
n
;
n
=
((
cdft_arg_t
*
)
p
)
->
n
;
a
=
((
cdft_arg_t
*
)
p
)
->
a
;
a
=
((
cdft_arg_t
*
)
p
)
->
a
;
...
@@ -2327,7 +2327,7 @@ void cftrec4(int n, double *a, int nw, double *w)
...
@@ -2327,7 +2327,7 @@ void cftrec4(int n, double *a, int nw, double *w)
void
cftleaf
(
int
n
,
int
isplt
,
double
*
a
,
int
nw
,
double
*
w
);
void
cftleaf
(
int
n
,
int
isplt
,
double
*
a
,
int
nw
,
double
*
w
);
void
cftmdl1
(
int
n
,
double
*
a
,
double
*
w
);
void
cftmdl1
(
int
n
,
double
*
a
,
double
*
w
);
int
isplt
,
j
,
k
,
m
;
int
isplt
,
j
,
k
,
m
;
m
=
n
;
m
=
n
;
while
(
m
>
512
)
{
while
(
m
>
512
)
{
m
>>=
2
;
m
>>=
2
;
...
@@ -2348,7 +2348,7 @@ int cfttree(int n, int j, int k, double *a, int nw, double *w)
...
@@ -2348,7 +2348,7 @@ int cfttree(int n, int j, int k, double *a, int nw, double *w)
void
cftmdl1
(
int
n
,
double
*
a
,
double
*
w
);
void
cftmdl1
(
int
n
,
double
*
a
,
double
*
w
);
void
cftmdl2
(
int
n
,
double
*
a
,
double
*
w
);
void
cftmdl2
(
int
n
,
double
*
a
,
double
*
w
);
int
i
,
isplt
,
m
;
int
i
,
isplt
,
m
;
if
((
k
&
3
)
!=
0
)
{
if
((
k
&
3
)
!=
0
)
{
isplt
=
k
&
1
;
isplt
=
k
&
1
;
if
(
isplt
!=
0
)
{
if
(
isplt
!=
0
)
{
...
@@ -2386,7 +2386,7 @@ void cftleaf(int n, int isplt, double *a, int nw, double *w)
...
@@ -2386,7 +2386,7 @@ void cftleaf(int n, int isplt, double *a, int nw, double *w)
void
cftf162
(
double
*
a
,
double
*
w
);
void
cftf162
(
double
*
a
,
double
*
w
);
void
cftf081
(
double
*
a
,
double
*
w
);
void
cftf081
(
double
*
a
,
double
*
w
);
void
cftf082
(
double
*
a
,
double
*
w
);
void
cftf082
(
double
*
a
,
double
*
w
);
if
(
n
==
512
)
{
if
(
n
==
512
)
{
cftmdl1
(
128
,
a
,
&
w
[
nw
-
64
]);
cftmdl1
(
128
,
a
,
&
w
[
nw
-
64
]);
cftf161
(
a
,
&
w
[
nw
-
8
]);
cftf161
(
a
,
&
w
[
nw
-
8
]);
...
@@ -2448,7 +2448,7 @@ void cftmdl1(int n, double *a, double *w)
...
@@ -2448,7 +2448,7 @@ void cftmdl1(int n, double *a, double *w)
int
j
,
j0
,
j1
,
j2
,
j3
,
k
,
m
,
mh
;
int
j
,
j0
,
j1
,
j2
,
j3
,
k
,
m
,
mh
;
double
wn4r
,
wk1r
,
wk1i
,
wk3r
,
wk3i
;
double
wn4r
,
wk1r
,
wk1i
,
wk3r
,
wk3i
;
double
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
;
double
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
;
mh
=
n
>>
3
;
mh
=
n
>>
3
;
m
=
2
*
mh
;
m
=
2
*
mh
;
j1
=
m
;
j1
=
m
;
...
@@ -2558,7 +2558,7 @@ void cftmdl2(int n, double *a, double *w)
...
@@ -2558,7 +2558,7 @@ void cftmdl2(int n, double *a, double *w)
int
j
,
j0
,
j1
,
j2
,
j3
,
k
,
kr
,
m
,
mh
;
int
j
,
j0
,
j1
,
j2
,
j3
,
k
,
kr
,
m
,
mh
;
double
wn4r
,
wk1r
,
wk1i
,
wk3r
,
wk3i
,
wd1r
,
wd1i
,
wd3r
,
wd3i
;
double
wn4r
,
wk1r
,
wk1i
,
wk3r
,
wk3i
,
wd1r
,
wd1i
,
wd3r
,
wd3i
;
double
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
y0r
,
y0i
,
y2r
,
y2i
;
double
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
y0r
,
y0i
,
y2r
,
y2i
;
mh
=
n
>>
3
;
mh
=
n
>>
3
;
m
=
2
*
mh
;
m
=
2
*
mh
;
wn4r
=
w
[
1
];
wn4r
=
w
[
1
];
...
@@ -2693,7 +2693,7 @@ void cftfx41(int n, double *a, int nw, double *w)
...
@@ -2693,7 +2693,7 @@ void cftfx41(int n, double *a, int nw, double *w)
void
cftf162
(
double
*
a
,
double
*
w
);
void
cftf162
(
double
*
a
,
double
*
w
);
void
cftf081
(
double
*
a
,
double
*
w
);
void
cftf081
(
double
*
a
,
double
*
w
);
void
cftf082
(
double
*
a
,
double
*
w
);
void
cftf082
(
double
*
a
,
double
*
w
);
if
(
n
==
128
)
{
if
(
n
==
128
)
{
cftf161
(
a
,
&
w
[
nw
-
8
]);
cftf161
(
a
,
&
w
[
nw
-
8
]);
cftf162
(
&
a
[
32
],
&
w
[
nw
-
32
]);
cftf162
(
&
a
[
32
],
&
w
[
nw
-
32
]);
...
@@ -2710,13 +2710,13 @@ void cftfx41(int n, double *a, int nw, double *w)
...
@@ -2710,13 +2710,13 @@ void cftfx41(int n, double *a, int nw, double *w)
void
cftf161
(
double
*
a
,
double
*
w
)
void
cftf161
(
double
*
a
,
double
*
w
)
{
{
double
wn4r
,
wk1r
,
wk1i
,
double
wn4r
,
wk1r
,
wk1i
,
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
y0r
,
y0i
,
y1r
,
y1i
,
y2r
,
y2i
,
y3r
,
y3i
,
y0r
,
y0i
,
y1r
,
y1i
,
y2r
,
y2i
,
y3r
,
y3i
,
y4r
,
y4i
,
y5r
,
y5i
,
y6r
,
y6i
,
y7r
,
y7i
,
y4r
,
y4i
,
y5r
,
y5i
,
y6r
,
y6i
,
y7r
,
y7i
,
y8r
,
y8i
,
y9r
,
y9i
,
y10r
,
y10i
,
y11r
,
y11i
,
y8r
,
y8i
,
y9r
,
y9i
,
y10r
,
y10i
,
y11r
,
y11i
,
y12r
,
y12i
,
y13r
,
y13i
,
y14r
,
y14i
,
y15r
,
y15i
;
y12r
,
y12i
,
y13r
,
y13i
,
y14r
,
y14i
,
y15r
,
y15i
;
wn4r
=
w
[
1
];
wn4r
=
w
[
1
];
wk1r
=
w
[
2
];
wk1r
=
w
[
2
];
wk1i
=
w
[
3
];
wk1i
=
w
[
3
];
...
@@ -2869,13 +2869,13 @@ void cftf161(double *a, double *w)
...
@@ -2869,13 +2869,13 @@ void cftf161(double *a, double *w)
void
cftf162
(
double
*
a
,
double
*
w
)
void
cftf162
(
double
*
a
,
double
*
w
)
{
{
double
wn4r
,
wk1r
,
wk1i
,
wk2r
,
wk2i
,
wk3r
,
wk3i
,
double
wn4r
,
wk1r
,
wk1i
,
wk2r
,
wk2i
,
wk3r
,
wk3i
,
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
y0r
,
y0i
,
y1r
,
y1i
,
y2r
,
y2i
,
y3r
,
y3i
,
y0r
,
y0i
,
y1r
,
y1i
,
y2r
,
y2i
,
y3r
,
y3i
,
y4r
,
y4i
,
y5r
,
y5i
,
y6r
,
y6i
,
y7r
,
y7i
,
y4r
,
y4i
,
y5r
,
y5i
,
y6r
,
y6i
,
y7r
,
y7i
,
y8r
,
y8i
,
y9r
,
y9i
,
y10r
,
y10i
,
y11r
,
y11i
,
y8r
,
y8i
,
y9r
,
y9i
,
y10r
,
y10i
,
y11r
,
y11i
,
y12r
,
y12i
,
y13r
,
y13i
,
y14r
,
y14i
,
y15r
,
y15i
;
y12r
,
y12i
,
y13r
,
y13i
,
y14r
,
y14i
,
y15r
,
y15i
;
wn4r
=
w
[
1
];
wn4r
=
w
[
1
];
wk1r
=
w
[
4
];
wk1r
=
w
[
4
];
wk1i
=
w
[
5
];
wk1i
=
w
[
5
];
...
@@ -3052,10 +3052,10 @@ void cftf162(double *a, double *w)
...
@@ -3052,10 +3052,10 @@ void cftf162(double *a, double *w)
void
cftf081
(
double
*
a
,
double
*
w
)
void
cftf081
(
double
*
a
,
double
*
w
)
{
{
double
wn4r
,
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
double
wn4r
,
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
,
y0r
,
y0i
,
y1r
,
y1i
,
y2r
,
y2i
,
y3r
,
y3i
,
y0r
,
y0i
,
y1r
,
y1i
,
y2r
,
y2i
,
y3r
,
y3i
,
y4r
,
y4i
,
y5r
,
y5i
,
y6r
,
y6i
,
y7r
,
y7i
;
y4r
,
y4i
,
y5r
,
y5i
,
y6r
,
y6i
,
y7r
,
y7i
;
wn4r
=
w
[
1
];
wn4r
=
w
[
1
];
x0r
=
a
[
0
]
+
a
[
8
];
x0r
=
a
[
0
]
+
a
[
8
];
x0i
=
a
[
1
]
+
a
[
9
];
x0i
=
a
[
1
]
+
a
[
9
];
...
@@ -3114,10 +3114,10 @@ void cftf081(double *a, double *w)
...
@@ -3114,10 +3114,10 @@ void cftf081(double *a, double *w)
void
cftf082
(
double
*
a
,
double
*
w
)
void
cftf082
(
double
*
a
,
double
*
w
)
{
{
double
wn4r
,
wk1r
,
wk1i
,
x0r
,
x0i
,
x1r
,
x1i
,
double
wn4r
,
wk1r
,
wk1i
,
x0r
,
x0i
,
x1r
,
x1i
,
y0r
,
y0i
,
y1r
,
y1i
,
y2r
,
y2i
,
y3r
,
y3i
,
y0r
,
y0i
,
y1r
,
y1i
,
y2r
,
y2i
,
y3r
,
y3i
,
y4r
,
y4i
,
y5r
,
y5i
,
y6r
,
y6i
,
y7r
,
y7i
;
y4r
,
y4i
,
y5r
,
y5i
,
y6r
,
y6i
,
y7r
,
y7i
;
wn4r
=
w
[
1
];
wn4r
=
w
[
1
];
wk1r
=
w
[
2
];
wk1r
=
w
[
2
];
wk1i
=
w
[
3
];
wk1i
=
w
[
3
];
...
@@ -3187,7 +3187,7 @@ void cftf082(double *a, double *w)
...
@@ -3187,7 +3187,7 @@ void cftf082(double *a, double *w)
void
cftf040
(
double
*
a
)
void
cftf040
(
double
*
a
)
{
{
double
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
;
double
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
;
x0r
=
a
[
0
]
+
a
[
4
];
x0r
=
a
[
0
]
+
a
[
4
];
x0i
=
a
[
1
]
+
a
[
5
];
x0i
=
a
[
1
]
+
a
[
5
];
x1r
=
a
[
0
]
-
a
[
4
];
x1r
=
a
[
0
]
-
a
[
4
];
...
@@ -3210,7 +3210,7 @@ void cftf040(double *a)
...
@@ -3210,7 +3210,7 @@ void cftf040(double *a)
void
cftb040
(
double
*
a
)
void
cftb040
(
double
*
a
)
{
{
double
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
;
double
x0r
,
x0i
,
x1r
,
x1i
,
x2r
,
x2i
,
x3r
,
x3i
;
x0r
=
a
[
0
]
+
a
[
4
];
x0r
=
a
[
0
]
+
a
[
4
];
x0i
=
a
[
1
]
+
a
[
5
];
x0i
=
a
[
1
]
+
a
[
5
];
x1r
=
a
[
0
]
-
a
[
4
];
x1r
=
a
[
0
]
-
a
[
4
];
...
@@ -3233,7 +3233,7 @@ void cftb040(double *a)
...
@@ -3233,7 +3233,7 @@ void cftb040(double *a)
void
cftx020
(
double
*
a
)
void
cftx020
(
double
*
a
)
{
{
double
x0r
,
x0i
;
double
x0r
,
x0i
;
x0r
=
a
[
0
]
-
a
[
2
];
x0r
=
a
[
0
]
-
a
[
2
];
x0i
=
a
[
1
]
-
a
[
3
];
x0i
=
a
[
1
]
-
a
[
3
];
a
[
0
]
+=
a
[
2
];
a
[
0
]
+=
a
[
2
];
...
@@ -3247,7 +3247,7 @@ void rftfsub(int n, double *a, int nc, double *c)
...
@@ -3247,7 +3247,7 @@ void rftfsub(int n, double *a, int nc, double *c)
{
{
int
j
,
k
,
kk
,
ks
,
m
;
int
j
,
k
,
kk
,
ks
,
m
;
double
wkr
,
wki
,
xr
,
xi
,
yr
,
yi
;
double
wkr
,
wki
,
xr
,
xi
,
yr
,
yi
;
m
=
n
>>
1
;
m
=
n
>>
1
;
ks
=
2
*
nc
/
m
;
ks
=
2
*
nc
/
m
;
kk
=
0
;
kk
=
0
;
...
@@ -3272,7 +3272,7 @@ void rftbsub(int n, double *a, int nc, double *c)
...
@@ -3272,7 +3272,7 @@ void rftbsub(int n, double *a, int nc, double *c)
{
{
int
j
,
k
,
kk
,
ks
,
m
;
int
j
,
k
,
kk
,
ks
,
m
;
double
wkr
,
wki
,
xr
,
xi
,
yr
,
yi
;
double
wkr
,
wki
,
xr
,
xi
,
yr
,
yi
;
m
=
n
>>
1
;
m
=
n
>>
1
;
ks
=
2
*
nc
/
m
;
ks
=
2
*
nc
/
m
;
kk
=
0
;
kk
=
0
;
...
@@ -3297,7 +3297,7 @@ void dctsub(int n, double *a, int nc, double *c)
...
@@ -3297,7 +3297,7 @@ void dctsub(int n, double *a, int nc, double *c)
{
{
int
j
,
k
,
kk
,
ks
,
m
;
int
j
,
k
,
kk
,
ks
,
m
;
double
wkr
,
wki
,
xr
;
double
wkr
,
wki
,
xr
;
m
=
n
>>
1
;
m
=
n
>>
1
;
ks
=
nc
/
n
;
ks
=
nc
/
n
;
kk
=
0
;
kk
=
0
;
...
@@ -3318,7 +3318,7 @@ void dstsub(int n, double *a, int nc, double *c)
...
@@ -3318,7 +3318,7 @@ void dstsub(int n, double *a, int nc, double *c)
{
{
int
j
,
k
,
kk
,
ks
,
m
;
int
j
,
k
,
kk
,
ks
,
m
;
double
wkr
,
wki
,
xr
;
double
wkr
,
wki
,
xr
;
m
=
n
>>
1
;
m
=
n
>>
1
;
ks
=
nc
/
n
;
ks
=
nc
/
n
;
kk
=
0
;
kk
=
0
;
...
...
modules/visualization/galaktos/func.c
View file @
d6008a8b
...
@@ -24,16 +24,16 @@ void * copy_func_key(char * string);
...
@@ -24,16 +24,16 @@ void * copy_func_key(char * string);
void
*
copy_func_key
(
char
*
string
)
{
void
*
copy_func_key
(
char
*
string
)
{
char
*
clone_string
;
char
*
clone_string
;
if
((
clone_string
=
malloc
(
MAX_TOKEN_SIZE
))
==
NULL
)
if
((
clone_string
=
malloc
(
MAX_TOKEN_SIZE
))
==
NULL
)
return
NULL
;
return
NULL
;
strncpy
(
clone_string
,
string
,
MAX_TOKEN_SIZE
-
1
);
strncpy
(
clone_string
,
string
,
MAX_TOKEN_SIZE
-
1
);
return
(
void
*
)
clone_string
;
return
(
void
*
)
clone_string
;
}
}
func_t
*
create_func
(
char
*
name
,
double
(
*
func_ptr
)(),
int
num_args
)
{
func_t
*
create_func
(
char
*
name
,
double
(
*
func_ptr
)(),
int
num_args
)
{
...
@@ -44,12 +44,12 @@ func_t * create_func (char * name, double (*func_ptr)(), int num_args) {
...
@@ -44,12 +44,12 @@ func_t * create_func (char * name, double (*func_ptr)(), int num_args) {
if
(
func
==
NULL
)
if
(
func
==
NULL
)
return
NULL
;
return
NULL
;
/* Clear name space */
/* Clear name space */
memset
(
func
->
name
,
0
,
MAX_TOKEN_SIZE
);
memset
(
func
->
name
,
0
,
MAX_TOKEN_SIZE
);
/* Copy given name into function structure */
/* Copy given name into function structure */
strncpy
(
func
->
name
,
name
,
MAX_TOKEN_SIZE
);
strncpy
(
func
->
name
,
name
,
MAX_TOKEN_SIZE
);
/* Assign value pointer */
/* Assign value pointer */
func
->
func_ptr
=
func_ptr
;
func
->
func_ptr
=
func_ptr
;
...
@@ -118,7 +118,7 @@ func_t * find_func(char * name) {
...
@@ -118,7 +118,7 @@ func_t * find_func(char * name) {
/* First look in the builtin database */
/* First look in the builtin database */
func
=
(
func_t
*
)
splay_find
(
name
,
builtin_func_tree
);
func
=
(
func_t
*
)
splay_find
(
name
,
builtin_func_tree
);
return
func
;
return
func
;
}
}
...
@@ -130,15 +130,15 @@ int compare_func(char * name, char * name2) {
...
@@ -130,15 +130,15 @@ int compare_func(char * name, char * name2) {
/* Uses string comparison function */
/* Uses string comparison function */
cmpval
=
strncmp
(
name
,
name2
,
MAX_TOKEN_SIZE
-
1
);
cmpval
=
strncmp
(
name
,
name2
,
MAX_TOKEN_SIZE
-
1
);
return
cmpval
;
return
cmpval
;
}
}
/* Loads a builtin function */
/* Loads a builtin function */
int
load_builtin_func
(
char
*
name
,
double
(
*
func_ptr
)(),
int
num_args
)
{
int
load_builtin_func
(
char
*
name
,
double
(
*
func_ptr
)(),
int
num_args
)
{
func_t
*
func
;
func_t
*
func
;
int
retval
;
int
retval
;
/* Create new function */
/* Create new function */
func
=
create_func
(
name
,
func_ptr
,
num_args
);
func
=
create_func
(
name
,
func_ptr
,
num_args
);
...
@@ -155,7 +155,7 @@ int load_builtin_func(char * name, double (*func_ptr)(), int num_args) {
...
@@ -155,7 +155,7 @@ int load_builtin_func(char * name, double (*func_ptr)(), int num_args) {
/* Loads all builtin functions */
/* Loads all builtin functions */
int
load_all_builtin_func
()
{
int
load_all_builtin_func
()
{
if
(
load_builtin_func
(
"int"
,
int_wrapper
,
1
)
<
0
)
if
(
load_builtin_func
(
"int"
,
int_wrapper
,
1
)
<
0
)
return
ERROR
;
return
ERROR
;
if
(
load_builtin_func
(
"abs"
,
abs_wrapper
,
1
)
<
0
)
if
(
load_builtin_func
(
"abs"
,
abs_wrapper
,
1
)
<
0
)
...
...
modules/visualization/galaktos/func_types.h
View file @
d6008a8b
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
/* Function Type */
/* Function Type */
typedef
struct
FUNC_T
{
typedef
struct
FUNC_T
{
char
name
[
MAX_TOKEN_SIZE
];
char
name
[
MAX_TOKEN_SIZE
];
double
(
*
func_ptr
)();
double
(
*
func_ptr
)();
int
num_args
;
int
num_args
;
}
func_t
;
}
func_t
;
...
...
modules/visualization/galaktos/init_cond.c
View file @
d6008a8b
...
@@ -57,28 +57,28 @@ void eval_init_cond(init_cond_t * init_cond) {
...
@@ -57,28 +57,28 @@ void eval_init_cond(init_cond_t * init_cond) {
/* Parameter is of boolean type, either a 1 or 0 value integer */
/* Parameter is of boolean type, either a 1 or 0 value integer */
/* Set matrix flag to zero. This ensures
/* Set matrix flag to zero. This ensures
its constant value will be used rather than a matrix value
its constant value will be used rather than a matrix value
*/
*/
init_cond
->
param
->
matrix_flag
=
0
;
init_cond
->
param
->
matrix_flag
=
0
;
if
(
init_cond
->
param
->
type
==
P_TYPE_BOOL
)
{
if
(
init_cond
->
param
->
type
==
P_TYPE_BOOL
)
{
if
(
INIT_COND_DEBUG
)
printf
(
"init_cond: %s = %d (TYPE BOOL)
\n
"
,
init_cond
->
param
->
name
,
init_cond
->
init_val
.
bool_val
);
if
(
INIT_COND_DEBUG
)
printf
(
"init_cond: %s = %d (TYPE BOOL)
\n
"
,
init_cond
->
param
->
name
,
init_cond
->
init_val
.
bool_val
);
*
((
int
*
)
init_cond
->
param
->
engine_val
)
=
init_cond
->
init_val
.
bool_val
;
*
((
int
*
)
init_cond
->
param
->
engine_val
)
=
init_cond
->
init_val
.
bool_val
;
return
;
return
;
}
}
/* Parameter is an integer type, just like C */
/* Parameter is an integer type, just like C */
if
(
init_cond
->
param
->
type
==
P_TYPE_INT
)
{
if
(
init_cond
->
param
->
type
==
P_TYPE_INT
)
{
if
(
INIT_COND_DEBUG
)
printf
(
"init_cond: %s = %d (TYPE INT)
\n
"
,
init_cond
->
param
->
name
,
init_cond
->
init_val
.
int_val
);
if
(
INIT_COND_DEBUG
)
printf
(
"init_cond: %s = %d (TYPE INT)
\n
"
,
init_cond
->
param
->
name
,
init_cond
->
init_val
.
int_val
);
*
((
int
*
)
init_cond
->
param
->
engine_val
)
=
init_cond
->
init_val
.
int_val
;
*
((
int
*
)
init_cond
->
param
->
engine_val
)
=
init_cond
->
init_val
.
int_val
;
return
;
return
;
}
}
/* Parameter is of a double type, just like C */
/* Parameter is of a double type, just like C */
if
(
init_cond
->
param
->
type
==
P_TYPE_DOUBLE
)
{
if
(
init_cond
->
param
->
type
==
P_TYPE_DOUBLE
)
{
if
(
INIT_COND_DEBUG
)
printf
(
"init_cond: %s = %f (TYPE DOUBLE)
\n
"
,
init_cond
->
param
->
name
,
init_cond
->
init_val
.
double_val
);
if
(
INIT_COND_DEBUG
)
printf
(
"init_cond: %s = %f (TYPE DOUBLE)
\n
"
,
init_cond
->
param
->
name
,
init_cond
->
init_val
.
double_val
);
*
((
double
*
)
init_cond
->
param
->
engine_val
)
=
init_cond
->
init_val
.
double_val
;
*
((
double
*
)
init_cond
->
param
->
engine_val
)
=
init_cond
->
init_val
.
double_val
;
return
;
return
;
}
}
...
@@ -92,7 +92,7 @@ init_cond_t * new_init_cond(param_t * param, value_t init_val) {
...
@@ -92,7 +92,7 @@ init_cond_t * new_init_cond(param_t * param, value_t init_val) {
init_cond_t
*
init_cond
;
init_cond_t
*
init_cond
;
init_cond
=
(
init_cond_t
*
)
malloc
(
sizeof
(
init_cond_t
));
init_cond
=
(
init_cond_t
*
)
malloc
(
sizeof
(
init_cond_t
));
if
(
init_cond
==
NULL
)
if
(
init_cond
==
NULL
)
return
NULL
;
return
NULL
;
...
@@ -103,59 +103,59 @@ init_cond_t * new_init_cond(param_t * param, value_t init_val) {
...
@@ -103,59 +103,59 @@ init_cond_t * new_init_cond(param_t * param, value_t init_val) {
/* WIP */
/* WIP */
void
init_cond_to_string
(
init_cond_t
*
init_cond
)
{
void
init_cond_to_string
(
init_cond_t
*
init_cond
)
{
int
string_length
;
int
string_length
;
char
string
[
MAX_TOKEN_SIZE
];
char
string
[
MAX_TOKEN_SIZE
];
if
(
init_cond
==
NULL
)
if
(
init_cond
==
NULL
)
return
;
return
;
/* Create a string "param_name=val" */
/* Create a string "param_name=val" */
switch
(
init_cond
->
param
->
type
)
{
switch
(
init_cond
->
param
->
type
)
{
lldiv_t
div
;
lldiv_t
div
;
case
P_TYPE_BOOL
:
case
P_TYPE_BOOL
:
sprintf
(
string
,
"%s=%d
\n
"
,
init_cond
->
param
->
name
,
init_cond
->
init_val
.
bool_val
);
sprintf
(
string
,
"%s=%d
\n
"
,
init_cond
->
param
->
name
,
init_cond
->
init_val
.
bool_val
);
break
;
break
;
case
P_TYPE_INT
:
case
P_TYPE_INT
:
sprintf
(
string
,
"%s=%d
\n
"
,
init_cond
->
param
->
name
,
init_cond
->
init_val
.
int_val
);
sprintf
(
string
,
"%s=%d
\n
"
,
init_cond
->
param
->
name
,
init_cond
->
init_val
.
int_val
);
break
;
break
;
case
P_TYPE_DOUBLE
:
case
P_TYPE_DOUBLE
:
div
=
lldiv
(
init_cond
->
init_val
.
double_val
*
1000000
,
div
=
lldiv
(
init_cond
->
init_val
.
double_val
*
1000000
,
1000000
);
1000000
);
sprintf
(
string
,
"%s="
I64Fd
".%06u
\n
"
,
init_cond
->
param
->
name
,
div
.
quot
,
(
unsigned
int
)
div
.
rem
);
sprintf
(
string
,
"%s="
I64Fd
".%06u
\n
"
,
init_cond
->
param
->
name
,
div
.
quot
,
(
unsigned
int
)
div
.
rem
);
break
;
break
;
default:
default:
return
;
return
;
}
}
/* Compute the length of the string */
/* Compute the length of the string */
string_length
=
strlen
(
string
);
string_length
=
strlen
(
string
);
/* Buffer overflow check */
/* Buffer overflow check */
if
((
init_cond_string_buffer_index
+
string_length
+
1
)
>
(
STRING_BUFFER_SIZE
-
1
))
if
((
init_cond_string_buffer_index
+
string_length
+
1
)
>
(
STRING_BUFFER_SIZE
-
1
))
return
;
return
;
/* Copy the string into the initial condition string buffer */
/* Copy the string into the initial condition string buffer */
strncpy
(
init_cond_string_buffer
+
init_cond_string_buffer_index
,
string
,
string_length
);
strncpy
(
init_cond_string_buffer
+
init_cond_string_buffer_index
,
string
,
string_length
);
/* Increment the string buffer, offset by one for the null terminator, which will be
/* Increment the string buffer, offset by one for the null terminator, which will be
overwritten by the next call to this function */
overwritten by the next call to this function */
init_cond_string_buffer_index
+=
string_length
+
1
;
init_cond_string_buffer_index
+=
string_length
+
1
;
}
}
char
*
create_init_cond_string_buffer
(
splaytree_t
*
init_cond_tree
)
{
char
*
create_init_cond_string_buffer
(
splaytree_t
*
init_cond_tree
)
{
if
(
init_cond_tree
==
NULL
)
if
(
init_cond_tree
==
NULL
)
return
NULL
;
return
NULL
;
init_cond_string_buffer_index
=
0
;
init_cond_string_buffer_index
=
0
;
splay_traverse
(
init_cond_to_string
,
init_cond_tree
);
splay_traverse
(
init_cond_to_string
,
init_cond_tree
);
return
init_cond_string_buffer
;
return
init_cond_string_buffer
;
}
}
modules/visualization/galaktos/param.c
View file @
d6008a8b
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
#include "expr_types.h"
#include "expr_types.h"
#include "eval.h"
#include "eval.h"
#include "engine_vars.h"
#include "engine_vars.h"
void
reset_param
(
param_t
*
param
);
void
reset_param
(
param_t
*
param
);
...
@@ -59,35 +59,35 @@ int insert_builtin_param(param_t * param);
...
@@ -59,35 +59,35 @@ int insert_builtin_param(param_t * param);
/* Private function prototypes */
/* Private function prototypes */
int
compare_param
(
char
*
name
,
char
*
name2
);
int
compare_param
(
char
*
name
,
char
*
name2
);
int
load_builtin_param_double
(
char
*
name
,
void
*
engine_val
,
void
*
matrix
,
short
int
flags
,
int
load_builtin_param_double
(
char
*
name
,
void
*
engine_val
,
void
*
matrix
,
short
int
flags
,
double
init_val
,
double
upper_bound
,
double
lower_bound
,
char
*
alt_name
);
double
init_val
,
double
upper_bound
,
double
lower_bound
,
char
*
alt_name
);
int
load_builtin_param_int
(
char
*
name
,
void
*
engine_val
,
short
int
flags
,
int
load_builtin_param_int
(
char
*
name
,
void
*
engine_val
,
short
int
flags
,
int
init_val
,
int
upper_bound
,
int
lower_bound
,
char
*
alt_name
);
int
init_val
,
int
upper_bound
,
int
lower_bound
,
char
*
alt_name
);
int
load_builtin_param_bool
(
char
*
name
,
void
*
engine_val
,
short
int
flags
,
int
load_builtin_param_bool
(
char
*
name
,
void
*
engine_val
,
short
int
flags
,
int
init_val
,
char
*
alt_name
);
int
init_val
,
char
*
alt_name
);
param_t
*
create_param
(
char
*
name
,
short
int
type
,
short
int
flags
,
void
*
engine_val
,
void
*
matrix
,
param_t
*
create_param
(
char
*
name
,
short
int
type
,
short
int
flags
,
void
*
engine_val
,
void
*
matrix
,
value_t
default_init_val
,
value_t
upper_bound
,
value_t
lower_bound
)
{
value_t
default_init_val
,
value_t
upper_bound
,
value_t
lower_bound
)
{
param_t
*
param
=
NULL
;
param_t
*
param
=
NULL
;
param
=
(
param_t
*
)
malloc
(
sizeof
(
param_t
));
param
=
(
param_t
*
)
malloc
(
sizeof
(
param_t
));
if
(
param
==
NULL
)
{
if
(
param
==
NULL
)
{
printf
(
"create_param: out of memory!!!
\n
"
);
printf
(
"create_param: out of memory!!!
\n
"
);
return
NULL
;
return
NULL
;
}
}
/* Clear name space, think the strncpy statement makes this redundant */
/* Clear name space, think the strncpy statement makes this redundant */
//memset(param->name, 0, MAX_TOKEN_SIZE);
//memset(param->name, 0, MAX_TOKEN_SIZE);
/* Copy given name into parameter structure */
/* Copy given name into parameter structure */
strncpy
(
param
->
name
,
name
,
MAX_TOKEN_SIZE
-
1
);
strncpy
(
param
->
name
,
name
,
MAX_TOKEN_SIZE
-
1
);
/* Assign other entries in a constructor like fashion */
/* Assign other entries in a constructor like fashion */
param
->
type
=
type
;
param
->
type
=
type
;
param
->
flags
=
flags
;
param
->
flags
=
flags
;
...
@@ -98,7 +98,7 @@ param_t * create_param (char * name, short int type, short int flags, void * eng
...
@@ -98,7 +98,7 @@ param_t * create_param (char * name, short int type, short int flags, void * eng
//*param->init_val = default_init_val;
//*param->init_val = default_init_val;
param
->
upper_bound
=
upper_bound
;
param
->
upper_bound
=
upper_bound
;
param
->
lower_bound
=
lower_bound
;
param
->
lower_bound
=
lower_bound
;
/* Return instantiated parameter */
/* Return instantiated parameter */
return
param
;
return
param
;
...
@@ -112,7 +112,7 @@ param_t * create_user_param(char * name) {
...
@@ -112,7 +112,7 @@ param_t * create_user_param(char * name) {
value_t
ub
;
value_t
ub
;
value_t
lb
;
value_t
lb
;
double
*
engine_val
;
double
*
engine_val
;
/* Set initial values to default */
/* Set initial values to default */
iv
.
double_val
=
DEFAULT_DOUBLE_IV
;
iv
.
double_val
=
DEFAULT_DOUBLE_IV
;
ub
.
double_val
=
DEFAULT_DOUBLE_UB
;
ub
.
double_val
=
DEFAULT_DOUBLE_UB
;
...
@@ -127,7 +127,7 @@ param_t * create_user_param(char * name) {
...
@@ -127,7 +127,7 @@ param_t * create_user_param(char * name) {
return
NULL
;
return
NULL
;
(
*
engine_val
)
=
iv
.
double_val
;
/* set some default init value */
(
*
engine_val
)
=
iv
.
double_val
;
/* set some default init value */
/* Create the new user parameter */
/* Create the new user parameter */
if
((
param
=
create_param
(
name
,
P_TYPE_DOUBLE
,
P_FLAG_USERDEF
,
engine_val
,
NULL
,
iv
,
ub
,
lb
))
==
NULL
)
{
if
((
param
=
create_param
(
name
,
P_TYPE_DOUBLE
,
P_FLAG_USERDEF
,
engine_val
,
NULL
,
iv
,
ub
,
lb
))
==
NULL
)
{
free
(
engine_val
);
free
(
engine_val
);
...
@@ -141,26 +141,26 @@ param_t * create_user_param(char * name) {
...
@@ -141,26 +141,26 @@ param_t * create_user_param(char * name) {
/* Initialize the builtin parameter database.
/* Initialize the builtin parameter database.
Should only be necessary once */
Should only be necessary once */
int
init_builtin_param_db
()
{
int
init_builtin_param_db
()
{
/* Create the builtin parameter splay tree (go Sleator...) */
/* Create the builtin parameter splay tree (go Sleator...) */
if
((
builtin_param_tree
=
create_splaytree
(
compare_string
,
copy_string
,
free_string
))
==
NULL
)
{
if
((
builtin_param_tree
=
create_splaytree
(
compare_string
,
copy_string
,
free_string
))
==
NULL
)
{
if
(
PARAM_DEBUG
)
printf
(
"init_builtin_param_db: failed to initialize database (FATAL)
\n
"
);
if
(
PARAM_DEBUG
)
printf
(
"init_builtin_param_db: failed to initialize database (FATAL)
\n
"
);
return
OUTOFMEM_ERROR
;
return
OUTOFMEM_ERROR
;
}
}
if
(
PARAM_DEBUG
)
{
if
(
PARAM_DEBUG
)
{
printf
(
"init_builtin_param: loading database..."
);
printf
(
"init_builtin_param: loading database..."
);
fflush
(
stdout
);
fflush
(
stdout
);
}
}
/* Loads all builtin parameters into the database */
/* Loads all builtin parameters into the database */
if
(
load_all_builtin_param
()
<
0
)
{
if
(
load_all_builtin_param
()
<
0
)
{
if
(
PARAM_DEBUG
)
printf
(
"failed loading builtin parameters (FATAL)
\n
"
);
if
(
PARAM_DEBUG
)
printf
(
"failed loading builtin parameters (FATAL)
\n
"
);
return
ERROR
;
return
ERROR
;
}
}
if
(
PARAM_DEBUG
)
printf
(
"success!
\n
"
);
if
(
PARAM_DEBUG
)
printf
(
"success!
\n
"
);
/* Finished, no errors */
/* Finished, no errors */
return
SUCCESS
;
return
SUCCESS
;
}
}
...
@@ -168,23 +168,23 @@ int init_builtin_param_db() {
...
@@ -168,23 +168,23 @@ int init_builtin_param_db() {
/* Destroy the builtin parameter database.
/* Destroy the builtin parameter database.
Generally, do this on projectm exit */
Generally, do this on projectm exit */
int
destroy_builtin_param_db
()
{
int
destroy_builtin_param_db
()
{
splay_traverse
(
free_param
,
builtin_param_tree
);
splay_traverse
(
free_param
,
builtin_param_tree
);
destroy_splaytree
(
builtin_param_tree
);
destroy_splaytree
(
builtin_param_tree
);
builtin_param_tree
=
NULL
;
builtin_param_tree
=
NULL
;
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Insert a parameter into the database with an alternate name */
/* Insert a parameter into the database with an alternate name */
int
insert_param_alt_name
(
param_t
*
param
,
char
*
alt_name
)
{
int
insert_param_alt_name
(
param_t
*
param
,
char
*
alt_name
)
{
if
(
param
==
NULL
)
if
(
param
==
NULL
)
return
ERROR
;
return
ERROR
;
if
(
alt_name
==
NULL
)
if
(
alt_name
==
NULL
)
return
ERROR
;
return
ERROR
;
splay_insert_link
(
alt_name
,
param
->
name
,
builtin_param_tree
);
splay_insert_link
(
alt_name
,
param
->
name
,
builtin_param_tree
);
return
SUCCESS
;
return
SUCCESS
;
...
@@ -195,8 +195,8 @@ param_t * find_builtin_param(char * name) {
...
@@ -195,8 +195,8 @@ param_t * find_builtin_param(char * name) {
/* Null argument checks */
/* Null argument checks */
if
(
name
==
NULL
)
if
(
name
==
NULL
)
return
NULL
;
return
NULL
;
return
splay_find
(
name
,
builtin_param_tree
);
return
splay_find
(
name
,
builtin_param_tree
);
}
}
...
@@ -208,10 +208,10 @@ param_t * find_param(char * name, preset_t * preset, int flags) {
...
@@ -208,10 +208,10 @@ param_t * find_param(char * name, preset_t * preset, int flags) {
/* Null argument checks */
/* Null argument checks */
if
(
name
==
NULL
)
if
(
name
==
NULL
)
return
NULL
;
return
NULL
;
if
(
preset
==
NULL
)
if
(
preset
==
NULL
)
return
NULL
;
return
NULL
;
/* First look in the builtin database */
/* First look in the builtin database */
param
=
(
param_t
*
)
splay_find
(
name
,
builtin_param_tree
);
param
=
(
param_t
*
)
splay_find
(
name
,
builtin_param_tree
);
...
@@ -219,13 +219,13 @@ param_t * find_param(char * name, preset_t * preset, int flags) {
...
@@ -219,13 +219,13 @@ param_t * find_param(char * name, preset_t * preset, int flags) {
if
(
param
==
NULL
)
{
if
(
param
==
NULL
)
{
param
=
(
param_t
*
)
splay_find
(
name
,
preset
->
user_param_tree
);
param
=
(
param_t
*
)
splay_find
(
name
,
preset
->
user_param_tree
);
}
}
/* If it doesn't exist in the user (or builtin) database and
/* If it doesn't exist in the user (or builtin) database and
create_flag is set, then make it and insert into the database
create_flag is set, then make it and insert into the database
*/
*/
if
((
param
==
NULL
)
&&
(
flags
&
P_CREATE
))
{
if
((
param
==
NULL
)
&&
(
flags
&
P_CREATE
))
{
/* Check if string is valid */
/* Check if string is valid */
if
(
!
is_valid_param_string
(
name
))
{
if
(
!
is_valid_param_string
(
name
))
{
if
(
PARAM_DEBUG
)
printf
(
"find_param: invalid parameter name:
\"
%s
\"\n
"
,
name
);
if
(
PARAM_DEBUG
)
printf
(
"find_param: invalid parameter name:
\"
%s
\"\n
"
,
name
);
return
NULL
;
return
NULL
;
...
@@ -240,13 +240,13 @@ param_t * find_param(char * name, preset_t * preset, int flags) {
...
@@ -240,13 +240,13 @@ param_t * find_param(char * name, preset_t * preset, int flags) {
if
(
PARAM_DEBUG
)
printf
(
"PARAM
\"
%s
\"
already exists in user parameter tree!
\n
"
,
param
->
name
);
if
(
PARAM_DEBUG
)
printf
(
"PARAM
\"
%s
\"
already exists in user parameter tree!
\n
"
,
param
->
name
);
free_param
(
param
);
free_param
(
param
);
return
NULL
;
return
NULL
;
}
}
}
}
/* Return the found (or created) parameter. Note that if P_CREATE is not set, this could be null */
/* Return the found (or created) parameter. Note that if P_CREATE is not set, this could be null */
return
param
;
return
param
;
}
}
/* Compare string name with parameter name */
/* Compare string name with parameter name */
...
@@ -256,7 +256,7 @@ int compare_param(char * name, char * name2) {
...
@@ -256,7 +256,7 @@ int compare_param(char * name, char * name2) {
printf
(
"am i used
\n
"
);
printf
(
"am i used
\n
"
);
/* Uses string comparison function */
/* Uses string comparison function */
cmpval
=
strncmp
(
name
,
name2
,
MAX_TOKEN_SIZE
-
1
);
cmpval
=
strncmp
(
name
,
name2
,
MAX_TOKEN_SIZE
-
1
);
return
cmpval
;
return
cmpval
;
}
}
...
@@ -269,18 +269,18 @@ int load_all_builtin_param() {
...
@@ -269,18 +269,18 @@ int load_all_builtin_param() {
load_builtin_param_double
(
"echo_zoom"
,
(
void
*
)
&
fVideoEchoZoom
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
"fVideoEchoZoom"
);
load_builtin_param_double
(
"echo_zoom"
,
(
void
*
)
&
fVideoEchoZoom
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
"fVideoEchoZoom"
);
load_builtin_param_double
(
"echo_alpha"
,
(
void
*
)
&
fVideoEchoAlpha
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
"fVideoEchoAlpha"
);
load_builtin_param_double
(
"echo_alpha"
,
(
void
*
)
&
fVideoEchoAlpha
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
"fVideoEchoAlpha"
);
load_builtin_param_double
(
"wave_a"
,
(
void
*
)
&
fWaveAlpha
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
0
,
"fWaveAlpha"
);
load_builtin_param_double
(
"wave_a"
,
(
void
*
)
&
fWaveAlpha
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
0
,
"fWaveAlpha"
);
load_builtin_param_double
(
"fWaveSmoothing"
,
(
void
*
)
&
fWaveSmoothing
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
-
1
.
0
,
NULL
);
load_builtin_param_double
(
"fWaveSmoothing"
,
(
void
*
)
&
fWaveSmoothing
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
-
1
.
0
,
NULL
);
load_builtin_param_double
(
"fModWaveAlphaStart"
,
(
void
*
)
&
fModWaveAlphaStart
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
-
1
.
0
,
NULL
);
load_builtin_param_double
(
"fModWaveAlphaStart"
,
(
void
*
)
&
fModWaveAlphaStart
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
-
1
.
0
,
NULL
);
load_builtin_param_double
(
"fModWaveAlphaEnd"
,
(
void
*
)
&
fModWaveAlphaEnd
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
-
1
.
0
,
NULL
);
load_builtin_param_double
(
"fModWaveAlphaEnd"
,
(
void
*
)
&
fModWaveAlphaEnd
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
-
1
.
0
,
NULL
);
load_builtin_param_double
(
"fWarpAnimSpeed"
,
(
void
*
)
&
fWarpAnimSpeed
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
-
1
.
0
,
NULL
);
load_builtin_param_double
(
"fWarpAnimSpeed"
,
(
void
*
)
&
fWarpAnimSpeed
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
-
1
.
0
,
NULL
);
// load_builtin_param_double("warp", (void*)&warp, warp_mesh, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, NULL);
// load_builtin_param_double("warp", (void*)&warp, warp_mesh, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, NULL);
load_builtin_param_double
(
"fShader"
,
(
void
*
)
&
fShader
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
-
1
.
0
,
NULL
);
load_builtin_param_double
(
"fShader"
,
(
void
*
)
&
fShader
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
-
1
.
0
,
NULL
);
load_builtin_param_double
(
"decay"
,
(
void
*
)
&
decay
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
0
,
"fDecay"
);
load_builtin_param_double
(
"decay"
,
(
void
*
)
&
decay
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
0
,
"fDecay"
);
load_builtin_param_int
(
"echo_orient"
,
(
void
*
)
&
nVideoEchoOrientation
,
P_FLAG_NONE
,
0
,
3
,
0
,
"nVideoEchoOrientation"
);
load_builtin_param_int
(
"echo_orient"
,
(
void
*
)
&
nVideoEchoOrientation
,
P_FLAG_NONE
,
0
,
3
,
0
,
"nVideoEchoOrientation"
);
load_builtin_param_int
(
"wave_mode"
,
(
void
*
)
&
nWaveMode
,
P_FLAG_NONE
,
0
,
7
,
0
,
"nWaveMode"
);
load_builtin_param_int
(
"wave_mode"
,
(
void
*
)
&
nWaveMode
,
P_FLAG_NONE
,
0
,
7
,
0
,
"nWaveMode"
);
load_builtin_param_bool
(
"wave_additive"
,
(
void
*
)
&
bAdditiveWaves
,
P_FLAG_NONE
,
FALSE
,
"bAdditiveWaves"
);
load_builtin_param_bool
(
"wave_additive"
,
(
void
*
)
&
bAdditiveWaves
,
P_FLAG_NONE
,
FALSE
,
"bAdditiveWaves"
);
load_builtin_param_bool
(
"bModWaveAlphaByVolume"
,
(
void
*
)
&
bModWaveAlphaByVolume
,
P_FLAG_NONE
,
FALSE
,
NULL
);
load_builtin_param_bool
(
"bModWaveAlphaByVolume"
,
(
void
*
)
&
bModWaveAlphaByVolume
,
P_FLAG_NONE
,
FALSE
,
NULL
);
load_builtin_param_bool
(
"wave_brighten"
,
(
void
*
)
&
bMaximizeWaveColor
,
P_FLAG_NONE
,
FALSE
,
"bMaximizeWaveColor"
);
load_builtin_param_bool
(
"wave_brighten"
,
(
void
*
)
&
bMaximizeWaveColor
,
P_FLAG_NONE
,
FALSE
,
"bMaximizeWaveColor"
);
...
@@ -295,8 +295,8 @@ int load_all_builtin_param() {
...
@@ -295,8 +295,8 @@ int load_all_builtin_param() {
load_builtin_param_bool
(
"wave_dots"
,
(
void
*
)
&
bWaveDots
,
P_FLAG_NONE
,
FALSE
,
"bWaveDots"
);
load_builtin_param_bool
(
"wave_dots"
,
(
void
*
)
&
bWaveDots
,
P_FLAG_NONE
,
FALSE
,
"bWaveDots"
);
load_builtin_param_bool
(
"wave_thick"
,
(
void
*
)
&
bWaveThick
,
P_FLAG_NONE
,
FALSE
,
"bWaveThick"
);
load_builtin_param_bool
(
"wave_thick"
,
(
void
*
)
&
bWaveThick
,
P_FLAG_NONE
,
FALSE
,
"bWaveThick"
);
load_builtin_param_double
(
"zoom"
,
(
void
*
)
&
zoom
,
zoom_mesh
,
P_FLAG_PER_PIXEL
|
P_FLAG_DONT_FREE_MATRIX
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
NULL
);
load_builtin_param_double
(
"zoom"
,
(
void
*
)
&
zoom
,
zoom_mesh
,
P_FLAG_PER_PIXEL
|
P_FLAG_DONT_FREE_MATRIX
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
NULL
);
load_builtin_param_double
(
"rot"
,
(
void
*
)
&
rot
,
rot_mesh
,
P_FLAG_PER_PIXEL
|
P_FLAG_DONT_FREE_MATRIX
,
0
.
0
,
MAX_DOUBLE_SIZE
,
MIN_DOUBLE_SIZE
,
NULL
);
load_builtin_param_double
(
"rot"
,
(
void
*
)
&
rot
,
rot_mesh
,
P_FLAG_PER_PIXEL
|
P_FLAG_DONT_FREE_MATRIX
,
0
.
0
,
MAX_DOUBLE_SIZE
,
MIN_DOUBLE_SIZE
,
NULL
);
load_builtin_param_double
(
"zoomexp"
,
(
void
*
)
&
zoomexp
,
zoomexp_mesh
,
P_FLAG_PER_PIXEL
|
P_FLAG_NONE
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
"fZoomExponent"
);
load_builtin_param_double
(
"zoomexp"
,
(
void
*
)
&
zoomexp
,
zoomexp_mesh
,
P_FLAG_PER_PIXEL
|
P_FLAG_NONE
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
"fZoomExponent"
);
...
@@ -314,7 +314,7 @@ int load_all_builtin_param() {
...
@@ -314,7 +314,7 @@ int load_all_builtin_param() {
load_builtin_param_double
(
"wave_x"
,
(
void
*
)
&
wave_x
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
0
.
0
,
NULL
);
load_builtin_param_double
(
"wave_x"
,
(
void
*
)
&
wave_x
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
0
.
0
,
NULL
);
load_builtin_param_double
(
"wave_y"
,
(
void
*
)
&
wave_y
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
0
.
0
,
NULL
);
load_builtin_param_double
(
"wave_y"
,
(
void
*
)
&
wave_y
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
0
.
0
,
NULL
);
load_builtin_param_double
(
"wave_mystery"
,
(
void
*
)
&
wave_mystery
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
-
1
.
0
,
"fWaveParam"
);
load_builtin_param_double
(
"wave_mystery"
,
(
void
*
)
&
wave_mystery
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
-
1
.
0
,
"fWaveParam"
);
load_builtin_param_double
(
"ob_size"
,
(
void
*
)
&
ob_size
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
0
.
5
,
0
,
NULL
);
load_builtin_param_double
(
"ob_size"
,
(
void
*
)
&
ob_size
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
0
.
5
,
0
,
NULL
);
load_builtin_param_double
(
"ob_r"
,
(
void
*
)
&
ob_r
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
0
.
0
,
NULL
);
load_builtin_param_double
(
"ob_r"
,
(
void
*
)
&
ob_r
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
0
.
0
,
NULL
);
load_builtin_param_double
(
"ob_g"
,
(
void
*
)
&
ob_g
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
0
.
0
,
NULL
);
load_builtin_param_double
(
"ob_g"
,
(
void
*
)
&
ob_g
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
0
.
0
,
NULL
);
...
@@ -337,9 +337,9 @@ int load_all_builtin_param() {
...
@@ -337,9 +337,9 @@ int load_all_builtin_param() {
load_builtin_param_double
(
"mv_dx"
,
(
void
*
)
&
mv_dx
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
-
1
.
0
,
NULL
);
load_builtin_param_double
(
"mv_dx"
,
(
void
*
)
&
mv_dx
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
-
1
.
0
,
NULL
);
load_builtin_param_double
(
"mv_a"
,
(
void
*
)
&
mv_a
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
0
.
0
,
NULL
);
load_builtin_param_double
(
"mv_a"
,
(
void
*
)
&
mv_a
,
NULL
,
P_FLAG_NONE
,
0
.
0
,
1
.
0
,
0
.
0
,
NULL
);
load_builtin_param_double
(
"time"
,
(
void
*
)
&
Time
,
NULL
,
P_FLAG_READONLY
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
.
0
,
NULL
);
load_builtin_param_double
(
"time"
,
(
void
*
)
&
Time
,
NULL
,
P_FLAG_READONLY
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
.
0
,
NULL
);
load_builtin_param_double
(
"bass"
,
(
void
*
)
&
bass
,
NULL
,
P_FLAG_READONLY
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
.
0
,
NULL
);
load_builtin_param_double
(
"bass"
,
(
void
*
)
&
bass
,
NULL
,
P_FLAG_READONLY
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
.
0
,
NULL
);
load_builtin_param_double
(
"mid"
,
(
void
*
)
&
mid
,
NULL
,
P_FLAG_READONLY
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
NULL
);
load_builtin_param_double
(
"mid"
,
(
void
*
)
&
mid
,
NULL
,
P_FLAG_READONLY
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
NULL
);
load_builtin_param_double
(
"bass_att"
,
(
void
*
)
&
bass_att
,
NULL
,
P_FLAG_READONLY
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
NULL
);
load_builtin_param_double
(
"bass_att"
,
(
void
*
)
&
bass_att
,
NULL
,
P_FLAG_READONLY
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
NULL
);
load_builtin_param_double
(
"mid_att"
,
(
void
*
)
&
mid_att
,
NULL
,
P_FLAG_READONLY
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
NULL
);
load_builtin_param_double
(
"mid_att"
,
(
void
*
)
&
mid_att
,
NULL
,
P_FLAG_READONLY
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
NULL
);
load_builtin_param_double
(
"treb_att"
,
(
void
*
)
&
treb_att
,
NULL
,
P_FLAG_READONLY
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
NULL
);
load_builtin_param_double
(
"treb_att"
,
(
void
*
)
&
treb_att
,
NULL
,
P_FLAG_READONLY
,
0
.
0
,
MAX_DOUBLE_SIZE
,
0
,
NULL
);
...
@@ -349,14 +349,14 @@ int load_all_builtin_param() {
...
@@ -349,14 +349,14 @@ int load_all_builtin_param() {
load_builtin_param_double
(
"x"
,
(
void
*
)
&
x_per_pixel
,
x_mesh
,
P_FLAG_PER_PIXEL
|
P_FLAG_ALWAYS_MATRIX
|
P_FLAG_READONLY
|
P_FLAG_DONT_FREE_MATRIX
,
load_builtin_param_double
(
"x"
,
(
void
*
)
&
x_per_pixel
,
x_mesh
,
P_FLAG_PER_PIXEL
|
P_FLAG_ALWAYS_MATRIX
|
P_FLAG_READONLY
|
P_FLAG_DONT_FREE_MATRIX
,
0
,
MAX_DOUBLE_SIZE
,
-
MAX_DOUBLE_SIZE
,
NULL
);
0
,
MAX_DOUBLE_SIZE
,
-
MAX_DOUBLE_SIZE
,
NULL
);
load_builtin_param_double
(
"y"
,
(
void
*
)
&
y_per_pixel
,
y_mesh
,
P_FLAG_PER_PIXEL
|
P_FLAG_ALWAYS_MATRIX
|
P_FLAG_READONLY
|
P_FLAG_DONT_FREE_MATRIX
,
load_builtin_param_double
(
"y"
,
(
void
*
)
&
y_per_pixel
,
y_mesh
,
P_FLAG_PER_PIXEL
|
P_FLAG_ALWAYS_MATRIX
|
P_FLAG_READONLY
|
P_FLAG_DONT_FREE_MATRIX
,
0
,
MAX_DOUBLE_SIZE
,
-
MAX_DOUBLE_SIZE
,
NULL
);
0
,
MAX_DOUBLE_SIZE
,
-
MAX_DOUBLE_SIZE
,
NULL
);
load_builtin_param_double
(
"ang"
,
(
void
*
)
&
ang_per_pixel
,
theta_mesh
,
P_FLAG_PER_PIXEL
|
P_FLAG_ALWAYS_MATRIX
|
P_FLAG_READONLY
|
P_FLAG_DONT_FREE_MATRIX
,
load_builtin_param_double
(
"ang"
,
(
void
*
)
&
ang_per_pixel
,
theta_mesh
,
P_FLAG_PER_PIXEL
|
P_FLAG_ALWAYS_MATRIX
|
P_FLAG_READONLY
|
P_FLAG_DONT_FREE_MATRIX
,
0
,
MAX_DOUBLE_SIZE
,
-
MAX_DOUBLE_SIZE
,
NULL
);
0
,
MAX_DOUBLE_SIZE
,
-
MAX_DOUBLE_SIZE
,
NULL
);
load_builtin_param_double
(
"rad"
,
(
void
*
)
&
rad_per_pixel
,
rad_mesh
,
P_FLAG_PER_PIXEL
|
P_FLAG_ALWAYS_MATRIX
|
P_FLAG_READONLY
|
P_FLAG_DONT_FREE_MATRIX
,
load_builtin_param_double
(
"rad"
,
(
void
*
)
&
rad_per_pixel
,
rad_mesh
,
P_FLAG_PER_PIXEL
|
P_FLAG_ALWAYS_MATRIX
|
P_FLAG_READONLY
|
P_FLAG_DONT_FREE_MATRIX
,
0
,
MAX_DOUBLE_SIZE
,
-
MAX_DOUBLE_SIZE
,
NULL
);
0
,
MAX_DOUBLE_SIZE
,
-
MAX_DOUBLE_SIZE
,
NULL
);
load_builtin_param_double
(
"q1"
,
(
void
*
)
&
q1
,
NULL
,
P_FLAG_PER_PIXEL
|
P_FLAG_QVAR
,
0
,
MAX_DOUBLE_SIZE
,
-
MAX_DOUBLE_SIZE
,
NULL
);
load_builtin_param_double
(
"q1"
,
(
void
*
)
&
q1
,
NULL
,
P_FLAG_PER_PIXEL
|
P_FLAG_QVAR
,
0
,
MAX_DOUBLE_SIZE
,
-
MAX_DOUBLE_SIZE
,
NULL
);
...
@@ -374,16 +374,16 @@ int load_all_builtin_param() {
...
@@ -374,16 +374,16 @@ int load_all_builtin_param() {
load_builtin_param_int
(
"meshx"
,
(
void
*
)
&
gx
,
P_FLAG_READONLY
,
32
,
96
,
8
,
NULL
);
load_builtin_param_int
(
"meshx"
,
(
void
*
)
&
gx
,
P_FLAG_READONLY
,
32
,
96
,
8
,
NULL
);
load_builtin_param_int
(
"meshy"
,
(
void
*
)
&
gy
,
P_FLAG_READONLY
,
24
,
72
,
6
,
NULL
);
load_builtin_param_int
(
"meshy"
,
(
void
*
)
&
gy
,
P_FLAG_READONLY
,
24
,
72
,
6
,
NULL
);
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Free's a parameter type */
/* Free's a parameter type */
void
free_param
(
param_t
*
param
)
{
void
free_param
(
param_t
*
param
)
{
int
x
;
int
x
;
if
(
param
==
NULL
)
if
(
param
==
NULL
)
return
;
return
;
if
(
param
->
flags
&
P_FLAG_USERDEF
)
{
if
(
param
->
flags
&
P_FLAG_USERDEF
)
{
free
(
param
->
engine_val
);
free
(
param
->
engine_val
);
...
@@ -395,8 +395,8 @@ void free_param(param_t * param) {
...
@@ -395,8 +395,8 @@ void free_param(param_t * param) {
free
(
param
->
matrix
);
free
(
param
->
matrix
);
else
if
(
param
->
flags
&
P_FLAG_PER_PIXEL
)
{
else
if
(
param
->
flags
&
P_FLAG_PER_PIXEL
)
{
for
(
x
=
0
;
x
<
gx
;
x
++
)
for
(
x
=
0
;
x
<
gx
;
x
++
)
free
(((
double
**
)
param
->
matrix
)[
x
]);
free
(((
double
**
)
param
->
matrix
)[
x
]);
free
(
param
->
matrix
);
free
(
param
->
matrix
);
}
}
}
}
...
@@ -407,8 +407,8 @@ void free_param(param_t * param) {
...
@@ -407,8 +407,8 @@ void free_param(param_t * param) {
}
}
/* Loads a double parameter into the builtin database */
/* Loads a double parameter into the builtin database */
int
load_builtin_param_double
(
char
*
name
,
void
*
engine_val
,
void
*
matrix
,
short
int
flags
,
int
load_builtin_param_double
(
char
*
name
,
void
*
engine_val
,
void
*
matrix
,
short
int
flags
,
double
init_val
,
double
upper_bound
,
double
lower_bound
,
char
*
alt_name
)
{
double
init_val
,
double
upper_bound
,
double
lower_bound
,
char
*
alt_name
)
{
param_t
*
param
=
NULL
;
param_t
*
param
=
NULL
;
value_t
iv
,
ub
,
lb
;
value_t
iv
,
ub
,
lb
;
...
@@ -416,48 +416,48 @@ int load_builtin_param_double(char * name, void * engine_val, void * matrix, sho
...
@@ -416,48 +416,48 @@ int load_builtin_param_double(char * name, void * engine_val, void * matrix, sho
iv
.
double_val
=
init_val
;
iv
.
double_val
=
init_val
;
ub
.
double_val
=
upper_bound
;
ub
.
double_val
=
upper_bound
;
lb
.
double_val
=
lower_bound
;
lb
.
double_val
=
lower_bound
;
/* Create new parameter of type double */
/* Create new parameter of type double */
if
(
PARAM_DEBUG
==
2
)
{
if
(
PARAM_DEBUG
==
2
)
{
printf
(
"load_builtin_param_double: (name
\"
%s
\"
) (alt_name =
\"
%s
\"
) "
,
name
,
alt_name
);
printf
(
"load_builtin_param_double: (name
\"
%s
\"
) (alt_name =
\"
%s
\"
) "
,
name
,
alt_name
);
fflush
(
stdout
);
fflush
(
stdout
);
}
}
if
((
param
=
create_param
(
name
,
P_TYPE_DOUBLE
,
flags
,
engine_val
,
matrix
,
iv
,
ub
,
lb
))
==
NULL
)
{
if
((
param
=
create_param
(
name
,
P_TYPE_DOUBLE
,
flags
,
engine_val
,
matrix
,
iv
,
ub
,
lb
))
==
NULL
)
{
return
OUTOFMEM_ERROR
;
return
OUTOFMEM_ERROR
;
}
}
if
(
PARAM_DEBUG
==
2
)
{
if
(
PARAM_DEBUG
==
2
)
{
printf
(
"created..."
);
printf
(
"created..."
);
fflush
(
stdout
);
fflush
(
stdout
);
}
}
/* Insert the paremeter into the database */
/* Insert the paremeter into the database */
if
(
insert_builtin_param
(
param
)
<
0
)
{
if
(
insert_builtin_param
(
param
)
<
0
)
{
free_param
(
param
);
free_param
(
param
);
return
ERROR
;
return
ERROR
;
}
}
if
(
PARAM_DEBUG
==
2
)
{
if
(
PARAM_DEBUG
==
2
)
{
printf
(
"inserted..."
);
printf
(
"inserted..."
);
fflush
(
stdout
);
fflush
(
stdout
);
}
}
/* If this parameter has an alternate name, insert it into the database as link */
/* If this parameter has an alternate name, insert it into the database as link */
if
(
alt_name
!=
NULL
)
{
if
(
alt_name
!=
NULL
)
{
insert_param_alt_name
(
param
,
alt_name
);
insert_param_alt_name
(
param
,
alt_name
);
if
(
PARAM_DEBUG
==
2
)
{
if
(
PARAM_DEBUG
==
2
)
{
printf
(
"alt_name inserted..."
);
printf
(
"alt_name inserted..."
);
fflush
(
stdout
);
fflush
(
stdout
);
}
}
}
}
if
(
PARAM_DEBUG
==
2
)
printf
(
"finished
\n
"
);
if
(
PARAM_DEBUG
==
2
)
printf
(
"finished
\n
"
);
/* Finished, return success */
/* Finished, return success */
return
SUCCESS
;
return
SUCCESS
;
}
}
...
@@ -466,7 +466,7 @@ int load_builtin_param_double(char * name, void * engine_val, void * matrix, sho
...
@@ -466,7 +466,7 @@ int load_builtin_param_double(char * name, void * engine_val, void * matrix, sho
/* Loads a double parameter into the builtin database */
/* Loads a double parameter into the builtin database */
param_t
*
new_param_double
(
char
*
name
,
short
int
flags
,
void
*
engine_val
,
void
*
matrix
,
param_t
*
new_param_double
(
char
*
name
,
short
int
flags
,
void
*
engine_val
,
void
*
matrix
,
double
upper_bound
,
double
lower_bound
,
double
init_val
)
{
double
upper_bound
,
double
lower_bound
,
double
init_val
)
{
param_t
*
param
;
param_t
*
param
;
value_t
iv
,
ub
,
lb
;
value_t
iv
,
ub
,
lb
;
...
@@ -474,11 +474,11 @@ param_t * new_param_double(char * name, short int flags, void * engine_val, void
...
@@ -474,11 +474,11 @@ param_t * new_param_double(char * name, short int flags, void * engine_val, void
iv
.
double_val
=
init_val
;
iv
.
double_val
=
init_val
;
ub
.
double_val
=
upper_bound
;
ub
.
double_val
=
upper_bound
;
lb
.
double_val
=
lower_bound
;
lb
.
double_val
=
lower_bound
;
if
((
param
=
create_param
(
name
,
P_TYPE_DOUBLE
,
flags
,
engine_val
,
matrix
,
iv
,
ub
,
lb
))
==
NULL
)
if
((
param
=
create_param
(
name
,
P_TYPE_DOUBLE
,
flags
,
engine_val
,
matrix
,
iv
,
ub
,
lb
))
==
NULL
)
return
NULL
;
return
NULL
;
/* Finished, return success */
/* Finished, return success */
return
param
;
return
param
;
}
}
...
@@ -486,7 +486,7 @@ param_t * new_param_double(char * name, short int flags, void * engine_val, void
...
@@ -486,7 +486,7 @@ param_t * new_param_double(char * name, short int flags, void * engine_val, void
/* Creates a new parameter of type int */
/* Creates a new parameter of type int */
param_t
*
new_param_int
(
char
*
name
,
short
int
flags
,
void
*
engine_val
,
param_t
*
new_param_int
(
char
*
name
,
short
int
flags
,
void
*
engine_val
,
int
upper_bound
,
int
lower_bound
,
int
init_val
)
{
int
upper_bound
,
int
lower_bound
,
int
init_val
)
{
param_t
*
param
;
param_t
*
param
;
value_t
iv
,
ub
,
lb
;
value_t
iv
,
ub
,
lb
;
...
@@ -494,10 +494,10 @@ param_t * new_param_int(char * name, short int flags, void * engine_val,
...
@@ -494,10 +494,10 @@ param_t * new_param_int(char * name, short int flags, void * engine_val,
iv
.
int_val
=
init_val
;
iv
.
int_val
=
init_val
;
ub
.
int_val
=
upper_bound
;
ub
.
int_val
=
upper_bound
;
lb
.
int_val
=
lower_bound
;
lb
.
int_val
=
lower_bound
;
if
((
param
=
create_param
(
name
,
P_TYPE_INT
,
flags
,
engine_val
,
NULL
,
iv
,
ub
,
lb
))
==
NULL
)
if
((
param
=
create_param
(
name
,
P_TYPE_INT
,
flags
,
engine_val
,
NULL
,
iv
,
ub
,
lb
))
==
NULL
)
return
NULL
;
return
NULL
;
/* Finished, return success */
/* Finished, return success */
return
param
;
return
param
;
...
@@ -505,7 +505,7 @@ param_t * new_param_int(char * name, short int flags, void * engine_val,
...
@@ -505,7 +505,7 @@ param_t * new_param_int(char * name, short int flags, void * engine_val,
/* Creates a new parameter of type bool */
/* Creates a new parameter of type bool */
param_t
*
new_param_bool
(
char
*
name
,
short
int
flags
,
void
*
engine_val
,
param_t
*
new_param_bool
(
char
*
name
,
short
int
flags
,
void
*
engine_val
,
int
upper_bound
,
int
lower_bound
,
int
init_val
)
{
int
upper_bound
,
int
lower_bound
,
int
init_val
)
{
param_t
*
param
;
param_t
*
param
;
value_t
iv
,
ub
,
lb
;
value_t
iv
,
ub
,
lb
;
...
@@ -513,10 +513,10 @@ param_t * new_param_bool(char * name, short int flags, void * engine_val,
...
@@ -513,10 +513,10 @@ param_t * new_param_bool(char * name, short int flags, void * engine_val,
iv
.
bool_val
=
init_val
;
iv
.
bool_val
=
init_val
;
ub
.
bool_val
=
upper_bound
;
ub
.
bool_val
=
upper_bound
;
lb
.
bool_val
=
lower_bound
;
lb
.
bool_val
=
lower_bound
;
if
((
param
=
create_param
(
name
,
P_TYPE_BOOL
,
flags
,
engine_val
,
NULL
,
iv
,
ub
,
lb
))
==
NULL
)
if
((
param
=
create_param
(
name
,
P_TYPE_BOOL
,
flags
,
engine_val
,
NULL
,
iv
,
ub
,
lb
))
==
NULL
)
return
NULL
;
return
NULL
;
/* Finished, return success */
/* Finished, return success */
return
param
;
return
param
;
...
@@ -525,15 +525,15 @@ param_t * new_param_bool(char * name, short int flags, void * engine_val,
...
@@ -525,15 +525,15 @@ param_t * new_param_bool(char * name, short int flags, void * engine_val,
/* Loads a integer parameter into the builtin database */
/* Loads a integer parameter into the builtin database */
int
load_builtin_param_int
(
char
*
name
,
void
*
engine_val
,
short
int
flags
,
int
load_builtin_param_int
(
char
*
name
,
void
*
engine_val
,
short
int
flags
,
int
init_val
,
int
upper_bound
,
int
lower_bound
,
char
*
alt_name
)
{
int
init_val
,
int
upper_bound
,
int
lower_bound
,
char
*
alt_name
)
{
param_t
*
param
;
param_t
*
param
;
value_t
iv
,
ub
,
lb
;
value_t
iv
,
ub
,
lb
;
iv
.
int_val
=
init_val
;
iv
.
int_val
=
init_val
;
ub
.
int_val
=
upper_bound
;
ub
.
int_val
=
upper_bound
;
lb
.
int_val
=
lower_bound
;
lb
.
int_val
=
lower_bound
;
param
=
create_param
(
name
,
P_TYPE_INT
,
flags
,
engine_val
,
NULL
,
iv
,
ub
,
lb
);
param
=
create_param
(
name
,
P_TYPE_INT
,
flags
,
engine_val
,
NULL
,
iv
,
ub
,
lb
);
if
(
param
==
NULL
)
{
if
(
param
==
NULL
)
{
...
@@ -541,29 +541,29 @@ int load_builtin_param_int(char * name, void * engine_val, short int flags,
...
@@ -541,29 +541,29 @@ int load_builtin_param_int(char * name, void * engine_val, short int flags,
}
}
if
(
insert_builtin_param
(
param
)
<
0
)
{
if
(
insert_builtin_param
(
param
)
<
0
)
{
free_param
(
param
);
free_param
(
param
);
return
ERROR
;
return
ERROR
;
}
}
if
(
alt_name
!=
NULL
)
{
if
(
alt_name
!=
NULL
)
{
insert_param_alt_name
(
param
,
alt_name
);
insert_param_alt_name
(
param
,
alt_name
);
}
}
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Loads a boolean parameter */
/* Loads a boolean parameter */
int
load_builtin_param_bool
(
char
*
name
,
void
*
engine_val
,
short
int
flags
,
int
load_builtin_param_bool
(
char
*
name
,
void
*
engine_val
,
short
int
flags
,
int
init_val
,
char
*
alt_name
)
{
int
init_val
,
char
*
alt_name
)
{
param_t
*
param
;
param_t
*
param
;
value_t
iv
,
ub
,
lb
;
value_t
iv
,
ub
,
lb
;
iv
.
int_val
=
init_val
;
iv
.
int_val
=
init_val
;
ub
.
int_val
=
TRUE
;
ub
.
int_val
=
TRUE
;
lb
.
int_val
=
FALSE
;
lb
.
int_val
=
FALSE
;
param
=
create_param
(
name
,
P_TYPE_BOOL
,
flags
,
engine_val
,
NULL
,
iv
,
ub
,
lb
);
param
=
create_param
(
name
,
P_TYPE_BOOL
,
flags
,
engine_val
,
NULL
,
iv
,
ub
,
lb
);
if
(
param
==
NULL
)
{
if
(
param
==
NULL
)
{
...
@@ -571,115 +571,115 @@ int load_builtin_param_bool(char * name, void * engine_val, short int flags,
...
@@ -571,115 +571,115 @@ int load_builtin_param_bool(char * name, void * engine_val, short int flags,
}
}
if
(
insert_builtin_param
(
param
)
<
0
)
{
if
(
insert_builtin_param
(
param
)
<
0
)
{
free_param
(
param
);
free_param
(
param
);
return
ERROR
;
return
ERROR
;
}
}
if
(
alt_name
!=
NULL
)
{
if
(
alt_name
!=
NULL
)
{
insert_param_alt_name
(
param
,
alt_name
);
insert_param_alt_name
(
param
,
alt_name
);
}
}
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Returns nonzero if the string is valid parameter name */
/* Returns nonzero if the string is valid parameter name */
int
is_valid_param_string
(
char
*
string
)
{
int
is_valid_param_string
(
char
*
string
)
{
if
(
string
==
NULL
)
if
(
string
==
NULL
)
return
FALSE
;
return
FALSE
;
/* This ensures the first character is non numeric */
/* This ensures the first character is non numeric */
if
(
((
*
string
)
>=
48
)
&&
((
*
string
)
<=
57
))
if
(
((
*
string
)
>=
48
)
&&
((
*
string
)
<=
57
))
return
FALSE
;
return
FALSE
;
/* These probably should never happen */
/* These probably should never happen */
if
(
*
string
==
'.'
)
if
(
*
string
==
'.'
)
return
FALSE
;
return
FALSE
;
if
(
*
string
==
'+'
)
if
(
*
string
==
'+'
)
return
FALSE
;
return
FALSE
;
if
(
*
string
==
'-'
)
if
(
*
string
==
'-'
)
return
FALSE
;
return
FALSE
;
/* Could also add checks for other symbols. May do later */
/* Could also add checks for other symbols. May do later */
return
TRUE
;
return
TRUE
;
}
}
/* Inserts a parameter into the builtin database */
/* Inserts a parameter into the builtin database */
int
insert_builtin_param
(
param_t
*
param
)
{
int
insert_builtin_param
(
param_t
*
param
)
{
if
(
param
==
NULL
)
if
(
param
==
NULL
)
return
FAILURE
;
return
FAILURE
;
return
splay_insert
(
param
,
param
->
name
,
builtin_param_tree
);
return
splay_insert
(
param
,
param
->
name
,
builtin_param_tree
);
}
}
/* Inserts a parameter into the builtin database */
/* Inserts a parameter into the builtin database */
int
insert_param
(
param_t
*
param
,
splaytree_t
*
database
)
{
int
insert_param
(
param_t
*
param
,
splaytree_t
*
database
)
{
if
(
param
==
NULL
)
if
(
param
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
database
==
NULL
)
if
(
database
==
NULL
)
return
FAILURE
;
return
FAILURE
;
return
splay_insert
(
param
,
param
->
name
,
database
);
return
splay_insert
(
param
,
param
->
name
,
database
);
}
}
/* Sets the parameter engine value to value val.
/* Sets the parameter engine value to value val.
clipping occurs if necessary */
clipping occurs if necessary */
void
set_param
(
param_t
*
param
,
double
val
)
{
void
set_param
(
param_t
*
param
,
double
val
)
{
switch
(
param
->
type
)
{
switch
(
param
->
type
)
{
case
P_TYPE_BOOL
:
case
P_TYPE_BOOL
:
if
(
val
<
0
)
if
(
val
<
0
)
*
((
int
*
)
param
->
engine_val
)
=
0
;
*
((
int
*
)
param
->
engine_val
)
=
0
;
else
if
(
val
>
0
)
else
if
(
val
>
0
)
*
((
int
*
)
param
->
engine_val
)
=
1
;
*
((
int
*
)
param
->
engine_val
)
=
1
;
else
else
*
((
int
*
)
param
->
engine_val
)
=
0
;
*
((
int
*
)
param
->
engine_val
)
=
0
;
break
;
break
;
case
P_TYPE_INT
:
case
P_TYPE_INT
:
/* Make sure value is an integer */
/* Make sure value is an integer */
val
=
floor
(
val
);
val
=
floor
(
val
);
if
(
val
<
param
->
lower_bound
.
int_val
)
if
(
val
<
param
->
lower_bound
.
int_val
)
*
((
int
*
)
param
->
engine_val
)
=
param
->
lower_bound
.
int_val
;
*
((
int
*
)
param
->
engine_val
)
=
param
->
lower_bound
.
int_val
;
else
if
(
val
>
param
->
upper_bound
.
int_val
)
else
if
(
val
>
param
->
upper_bound
.
int_val
)
*
((
int
*
)
param
->
engine_val
)
=
param
->
upper_bound
.
int_val
;
*
((
int
*
)
param
->
engine_val
)
=
param
->
upper_bound
.
int_val
;
else
else
*
((
int
*
)
param
->
engine_val
)
=
val
;
*
((
int
*
)
param
->
engine_val
)
=
val
;
break
;
break
;
case
P_TYPE_DOUBLE
:
case
P_TYPE_DOUBLE
:
/* Make sure value is an integer */
/* Make sure value is an integer */
if
(
val
<
param
->
lower_bound
.
double_val
)
if
(
val
<
param
->
lower_bound
.
double_val
)
*
((
double
*
)
param
->
engine_val
)
=
param
->
lower_bound
.
double_val
;
*
((
double
*
)
param
->
engine_val
)
=
param
->
lower_bound
.
double_val
;
else
if
(
val
>
param
->
upper_bound
.
double_val
)
else
if
(
val
>
param
->
upper_bound
.
double_val
)
*
((
double
*
)
param
->
engine_val
)
=
param
->
upper_bound
.
double_val
;
*
((
double
*
)
param
->
engine_val
)
=
param
->
upper_bound
.
double_val
;
else
else
*
((
double
*
)
param
->
engine_val
)
=
val
;
*
((
double
*
)
param
->
engine_val
)
=
val
;
break
;
break
;
default:
default:
break
;
break
;
}
}
return
;
return
;
}
}
/* Search for parameter 'name' in 'database', if create_flag is true, then generate the parameter
/* Search for parameter 'name' in 'database', if create_flag is true, then generate the parameter
and insert it into 'database' */
and insert it into 'database' */
param_t
*
find_param_db
(
char
*
name
,
splaytree_t
*
database
,
int
create_flag
)
{
param_t
*
find_param_db
(
char
*
name
,
splaytree_t
*
database
,
int
create_flag
)
{
...
@@ -690,29 +690,29 @@ param_t * find_param_db(char * name, splaytree_t * database, int create_flag) {
...
@@ -690,29 +690,29 @@ param_t * find_param_db(char * name, splaytree_t * database, int create_flag) {
return
NULL
;
return
NULL
;
if
(
database
==
NULL
)
if
(
database
==
NULL
)
return
NULL
;
return
NULL
;
/* First look in the builtin database */
/* First look in the builtin database */
param
=
(
param_t
*
)
splay_find
(
name
,
database
);
param
=
(
param_t
*
)
splay_find
(
name
,
database
);
if
(((
param
=
(
param_t
*
)
splay_find
(
name
,
database
))
==
NULL
)
&&
(
create_flag
==
TRUE
))
{
if
(((
param
=
(
param_t
*
)
splay_find
(
name
,
database
))
==
NULL
)
&&
(
create_flag
==
TRUE
))
{
/* Check if string is valid */
/* Check if string is valid */
if
(
!
is_valid_param_string
(
name
))
if
(
!
is_valid_param_string
(
name
))
return
NULL
;
return
NULL
;
/* Now, create the user defined parameter given the passed name */
/* Now, create the user defined parameter given the passed name */
if
((
param
=
create_user_param
(
name
))
==
NULL
)
if
((
param
=
create_user_param
(
name
))
==
NULL
)
return
NULL
;
return
NULL
;
/* Finally, insert the new parameter into this preset's proper splaytree */
/* Finally, insert the new parameter into this preset's proper splaytree */
if
(
splay_insert
(
param
,
param
->
name
,
database
)
<
0
)
{
if
(
splay_insert
(
param
,
param
->
name
,
database
)
<
0
)
{
free_param
(
param
);
free_param
(
param
);
return
NULL
;
return
NULL
;
}
}
}
}
/* Return the found (or created) parameter. Note that this could be null */
/* Return the found (or created) parameter. Note that this could be null */
return
param
;
return
param
;
...
...
modules/visualization/galaktos/param.h
View file @
d6008a8b
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
/* Function prototypes */
/* Function prototypes */
param_t
*
create_param
(
char
*
name
,
short
int
type
,
short
int
flags
,
void
*
eqn_val
,
void
*
matrix
,
param_t
*
create_param
(
char
*
name
,
short
int
type
,
short
int
flags
,
void
*
eqn_val
,
void
*
matrix
,
value_t
default_init_val
,
value_t
upper_bound
,
value_t
lower_bound
);
value_t
default_init_val
,
value_t
upper_bound
,
value_t
lower_bound
);
param_t
*
create_user_param
(
char
*
name
);
param_t
*
create_user_param
(
char
*
name
);
int
init_builtin_param_db
();
int
init_builtin_param_db
();
int
init_user_param_db
();
int
init_user_param_db
();
...
@@ -23,13 +23,13 @@ int load_all_builtin_param();
...
@@ -23,13 +23,13 @@ int load_all_builtin_param();
int
insert_param
(
param_t
*
param
,
splaytree_t
*
database
);
int
insert_param
(
param_t
*
param
,
splaytree_t
*
database
);
param_t
*
find_builtin_param
(
char
*
name
);
param_t
*
find_builtin_param
(
char
*
name
);
param_t
*
new_param_double
(
char
*
name
,
short
int
flags
,
void
*
engine_val
,
void
*
matrix
,
param_t
*
new_param_double
(
char
*
name
,
short
int
flags
,
void
*
engine_val
,
void
*
matrix
,
double
upper_bound
,
double
lower_bound
,
double
init_val
);
double
upper_bound
,
double
lower_bound
,
double
init_val
);
param_t
*
new_param_int
(
char
*
name
,
short
int
flags
,
void
*
engine_val
,
param_t
*
new_param_int
(
char
*
name
,
short
int
flags
,
void
*
engine_val
,
int
upper_bound
,
int
lower_bound
,
int
init_val
);
int
upper_bound
,
int
lower_bound
,
int
init_val
);
param_t
*
new_param_bool
(
char
*
name
,
short
int
flags
,
void
*
engine_val
,
param_t
*
new_param_bool
(
char
*
name
,
short
int
flags
,
void
*
engine_val
,
int
upper_bound
,
int
lower_bound
,
int
init_val
);
int
upper_bound
,
int
lower_bound
,
int
init_val
);
param_t
*
find_param_db
(
char
*
name
,
splaytree_t
*
database
,
int
create_flag
);
param_t
*
find_param_db
(
char
*
name
,
splaytree_t
*
database
,
int
create_flag
);
...
...
modules/visualization/galaktos/param_types.h
View file @
d6008a8b
...
@@ -21,14 +21,14 @@
...
@@ -21,14 +21,14 @@
typedef
union
VALUE_T
{
typedef
union
VALUE_T
{
int
bool_val
;
int
bool_val
;
int
int_val
;
int
int_val
;
double
double_val
;
double
double_val
;
}
value_t
;
}
value_t
;
/* Parameter Type */
/* Parameter Type */
typedef
struct
PARAM_T
{
typedef
struct
PARAM_T
{
char
name
[
MAX_TOKEN_SIZE
];
/* name of the parameter, not necessary but useful neverthless */
char
name
[
MAX_TOKEN_SIZE
];
/* name of the parameter, not necessary but useful neverthless */
short
int
type
;
/* parameter number type (int, bool, or double) */
short
int
type
;
/* parameter number type (int, bool, or double) */
short
int
flags
;
/* read, write, user defined, etc */
short
int
flags
;
/* read, write, user defined, etc */
short
int
matrix_flag
;
/* for optimization purposes */
short
int
matrix_flag
;
/* for optimization purposes */
void
*
engine_val
;
/* pointer to the engine variable */
void
*
engine_val
;
/* pointer to the engine variable */
void
*
matrix
;
/* per pixel / per point matrix for this variable */
void
*
matrix
;
/* per pixel / per point matrix for this variable */
...
...
modules/visualization/galaktos/parser.c
View file @
d6008a8b
...
@@ -102,7 +102,7 @@
...
@@ -102,7 +102,7 @@
#define WAVE_INIT_STRING_LENGTH 4
#define WAVE_INIT_STRING_LENGTH 4
/* Stores a line of a file as its being parsed */
/* Stores a line of a file as its being parsed */
char
string_line_buffer
[
STRING_LINE_SIZE
];
char
string_line_buffer
[
STRING_LINE_SIZE
];
/* The current position of the string line buffer (see above) */
/* The current position of the string line buffer (see above) */
int
string_line_buffer_index
=
0
;
int
string_line_buffer_index
=
0
;
...
@@ -191,69 +191,69 @@ int string_to_float(char * string, double * float_ptr);
...
@@ -191,69 +191,69 @@ int string_to_float(char * string, double * float_ptr);
to the raw string */
to the raw string */
token_t
parseToken
(
FILE
*
fs
,
char
*
string
)
{
token_t
parseToken
(
FILE
*
fs
,
char
*
string
)
{
char
c
;
char
c
;
int
i
;
int
i
;
if
(
string
!=
NULL
)
if
(
string
!=
NULL
)
memset
(
string
,
0
,
MAX_TOKEN_SIZE
);
memset
(
string
,
0
,
MAX_TOKEN_SIZE
);
/* Loop until a delimiter is found, or the maximum string size is found */
/* Loop until a delimiter is found, or the maximum string size is found */
for
(
i
=
0
;
i
<
MAX_TOKEN_SIZE
;
i
++
)
{
for
(
i
=
0
;
i
<
MAX_TOKEN_SIZE
;
i
++
)
{
c
=
fgetc
(
fs
);
c
=
fgetc
(
fs
);
/* If the string line buffer is full, quit */
/* If the string line buffer is full, quit */
if
(
string_line_buffer_index
==
(
STRING_LINE_SIZE
-
1
))
if
(
string_line_buffer_index
==
(
STRING_LINE_SIZE
-
1
))
return
tStringBufferFilled
;
return
tStringBufferFilled
;
/* Otherwise add this character to the string line buffer */
/* Otherwise add this character to the string line buffer */
string_line_buffer
[
string_line_buffer_index
++
]
=
c
;
string_line_buffer
[
string_line_buffer_index
++
]
=
c
;
/* Now interpret the character */
/* Now interpret the character */
switch
(
c
)
{
switch
(
c
)
{
case
'+'
:
case
'+'
:
return
tPlus
;
return
tPlus
;
case
'-'
:
case
'-'
:
return
tMinus
;
return
tMinus
;
case
'%'
:
case
'%'
:
return
tMod
;
return
tMod
;
case
'/'
:
case
'/'
:
/* check for line comment here */
/* check for line comment here */
if
((
c
=
fgetc
(
fs
))
==
'/'
)
{
if
((
c
=
fgetc
(
fs
))
==
'/'
)
{
while
(
1
)
{
while
(
1
)
{
c
=
fgetc
(
fs
);
c
=
fgetc
(
fs
);
if
(
c
==
EOF
)
{
if
(
c
==
EOF
)
{
line_mode
=
NORMAL_LINE_MODE
;
line_mode
=
NORMAL_LINE_MODE
;
return
tEOF
;
return
tEOF
;
}
}
if
(
c
==
'\n'
)
{
if
(
c
==
'\n'
)
{
line_mode
=
NORMAL_LINE_MODE
;
line_mode
=
NORMAL_LINE_MODE
;
return
tEOL
;
return
tEOL
;
}
}
}
}
}
}
/* Otherwise, just a regular division operator */
/* Otherwise, just a regular division operator */
ungetc
(
c
,
fs
);
ungetc
(
c
,
fs
);
return
tDiv
;
return
tDiv
;
case
'*'
:
case
'*'
:
return
tMult
;
return
tMult
;
case
'|'
:
case
'|'
:
return
tOr
;
return
tOr
;
case
'&'
:
case
'&'
:
return
tAnd
;
return
tAnd
;
case
'('
:
case
'('
:
return
tLPr
;
return
tLPr
;
case
')'
:
case
')'
:
return
tRPr
;
return
tRPr
;
case
'['
:
case
'['
:
return
tLBr
;
return
tLBr
;
case
']'
:
case
']'
:
return
tRBr
;
return
tRBr
;
case
'='
:
case
'='
:
return
tEq
;
return
tEq
;
// case '\r':
// case '\r':
//break;
//break;
...
@@ -272,20 +272,20 @@ token_t parseToken(FILE * fs, char * string) {
...
@@ -272,20 +272,20 @@ token_t parseToken(FILE * fs, char * string) {
line_count
=
1
;
line_count
=
1
;
line_mode
=
NORMAL_LINE_MODE
;
line_mode
=
NORMAL_LINE_MODE
;
return
tEOF
;
return
tEOF
;
default:
default:
if
(
string
!=
NULL
)
if
(
string
!=
NULL
)
string
[
i
]
=
c
;
string
[
i
]
=
c
;
}
}
}
}
/* String reached maximum length, return special token error */
/* String reached maximum length, return special token error */
return
tStringTooLong
;
return
tStringTooLong
;
}
}
/* Parse input in the form of "exp, exp, exp, ...)"
/* Parse input in the form of "exp, exp, exp, ...)"
Returns a general expression list */
Returns a general expression list */
gen_expr_t
**
parse_prefix_args
(
FILE
*
fs
,
int
num_args
,
struct
PRESET_T
*
preset
)
{
gen_expr_t
**
parse_prefix_args
(
FILE
*
fs
,
int
num_args
,
struct
PRESET_T
*
preset
)
{
...
@@ -293,15 +293,15 @@ gen_expr_t ** parse_prefix_args(FILE * fs, int num_args, struct PRESET_T * prese
...
@@ -293,15 +293,15 @@ gen_expr_t ** parse_prefix_args(FILE * fs, int num_args, struct PRESET_T * prese
int
i
,
j
;
int
i
,
j
;
gen_expr_t
**
expr_list
;
/* List of arguments to function */
gen_expr_t
**
expr_list
;
/* List of arguments to function */
gen_expr_t
*
gen_expr
;
gen_expr_t
*
gen_expr
;
/* Malloc the expression list */
/* Malloc the expression list */
expr_list
=
(
gen_expr_t
**
)
malloc
(
sizeof
(
gen_expr_t
*
)
*
num_args
);
expr_list
=
(
gen_expr_t
**
)
malloc
(
sizeof
(
gen_expr_t
*
)
*
num_args
);
/* Malloc failed */
/* Malloc failed */
if
(
expr_list
==
NULL
)
if
(
expr_list
==
NULL
)
return
NULL
;
return
NULL
;
i
=
0
;
i
=
0
;
while
(
i
<
num_args
)
{
while
(
i
<
num_args
)
{
...
@@ -309,19 +309,19 @@ gen_expr_t ** parse_prefix_args(FILE * fs, int num_args, struct PRESET_T * prese
...
@@ -309,19 +309,19 @@ gen_expr_t ** parse_prefix_args(FILE * fs, int num_args, struct PRESET_T * prese
/* Parse the ith expression in the list */
/* Parse the ith expression in the list */
if
((
gen_expr
=
parse_gen_expr
(
fs
,
NULL
,
preset
))
==
NULL
)
{
if
((
gen_expr
=
parse_gen_expr
(
fs
,
NULL
,
preset
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_prefix_args: failed to get parameter # %d for function (LINE %d)\n", i+1, line_count);
//if (PARSE_DEBUG) printf("parse_prefix_args: failed to get parameter # %d for function (LINE %d)\n", i+1, line_count);
for
(
j
=
0
;
j
<
i
;
j
++
)
for
(
j
=
0
;
j
<
i
;
j
++
)
free_gen_expr
(
expr_list
[
j
]);
free_gen_expr
(
expr_list
[
j
]);
free
(
expr_list
);
free
(
expr_list
);
return
NULL
;
return
NULL
;
}
}
/* Assign entry in expression list */
/* Assign entry in expression list */
expr_list
[
i
++
]
=
gen_expr
;
expr_list
[
i
++
]
=
gen_expr
;
}
}
//if (PARSE_DEBUG) printf("parse_prefix_args: finished parsing %d arguments (LINE %d)\n", num_args, line_count);
//if (PARSE_DEBUG) printf("parse_prefix_args: finished parsing %d arguments (LINE %d)\n", num_args, line_count);
/* Finally, return the resulting expression list */
/* Finally, return the resulting expression list */
return
expr_list
;
return
expr_list
;
}
}
/* Parses a comment at the top of the file. Stops when left bracket is found */
/* Parses a comment at the top of the file. Stops when left bracket is found */
...
@@ -329,16 +329,16 @@ int parse_top_comment(FILE * fs) {
...
@@ -329,16 +329,16 @@ int parse_top_comment(FILE * fs) {
char
string
[
MAX_TOKEN_SIZE
];
char
string
[
MAX_TOKEN_SIZE
];
token_t
token
;
token_t
token
;
/* Process tokens until left bracket is found */
/* Process tokens until left bracket is found */
while
((
token
=
parseToken
(
fs
,
string
))
!=
tLBr
)
{
while
((
token
=
parseToken
(
fs
,
string
))
!=
tLBr
)
{
if
(
token
==
tEOF
)
if
(
token
==
tEOF
)
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Done, return success */
/* Done, return success */
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Right Bracket is parsed by this function.
/* Right Bracket is parsed by this function.
puts a new string into name */
puts a new string into name */
...
@@ -347,13 +347,13 @@ int parse_preset_name(FILE * fs, char * name) {
...
@@ -347,13 +347,13 @@ int parse_preset_name(FILE * fs, char * name) {
token_t
token
;
token_t
token
;
if
(
name
==
NULL
)
if
(
name
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
((
token
=
parseToken
(
fs
,
name
))
!=
tRBr
)
if
((
token
=
parseToken
(
fs
,
name
))
!=
tRBr
)
return
PARSE_ERROR
;
return
PARSE_ERROR
;
//if (PARSE_DEBUG) printf("parse_preset_name: parsed preset (name = \"%s\")\n", name);
//if (PARSE_DEBUG) printf("parse_preset_name: parsed preset (name = \"%s\")\n", name);
return
SUCCESS
;
return
SUCCESS
;
}
}
...
@@ -368,17 +368,17 @@ int parse_per_pixel_eqn(FILE * fs, preset_t * preset) {
...
@@ -368,17 +368,17 @@ int parse_per_pixel_eqn(FILE * fs, preset_t * preset) {
if
(
PARSE_DEBUG
)
printf
(
"parse_per_pixel: per_pixel equation parsing start...(LINE %d)
\n
"
,
line_count
);
if
(
PARSE_DEBUG
)
printf
(
"parse_per_pixel: per_pixel equation parsing start...(LINE %d)
\n
"
,
line_count
);
if
(
parseToken
(
fs
,
string
)
!=
tEq
)
{
/* parse per pixel operator name */
if
(
parseToken
(
fs
,
string
)
!=
tEq
)
{
/* parse per pixel operator name */
if
(
PARSE_DEBUG
)
printf
(
"parse_per_pixel: equal operator expected after per pixel operator
\"
%s
\"
, but not found (LINE %d)
\n
"
,
if
(
PARSE_DEBUG
)
printf
(
"parse_per_pixel: equal operator expected after per pixel operator
\"
%s
\"
, but not found (LINE %d)
\n
"
,
string
,
line_count
);
string
,
line_count
);
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Parse right side of equation as an expression */
/* Parse right side of equation as an expression */
if
((
gen_expr
=
parse_gen_expr
(
fs
,
NULL
,
preset
))
==
NULL
)
{
if
((
gen_expr
=
parse_gen_expr
(
fs
,
NULL
,
preset
))
==
NULL
)
{
if
(
PARSE_DEBUG
)
printf
(
"parse_per_pixel: equation evaluated to null? (LINE %d)
\n
"
,
line_count
);
if
(
PARSE_DEBUG
)
printf
(
"parse_per_pixel: equation evaluated to null? (LINE %d)
\n
"
,
line_count
);
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Add the per pixel equation */
/* Add the per pixel equation */
if
(
add_per_pixel_eqn
(
string
,
gen_expr
,
preset
)
<
0
)
{
if
(
add_per_pixel_eqn
(
string
,
gen_expr
,
preset
)
<
0
)
{
free_gen_expr
(
gen_expr
);
free_gen_expr
(
gen_expr
);
...
@@ -395,14 +395,14 @@ int parse_line(FILE * fs, struct PRESET_T * preset) {
...
@@ -395,14 +395,14 @@ int parse_line(FILE * fs, struct PRESET_T * preset) {
token_t
token
;
token_t
token
;
init_cond_t
*
init_cond
;
init_cond_t
*
init_cond
;
per_frame_eqn_t
*
per_frame_eqn
;
per_frame_eqn_t
*
per_frame_eqn
;
/* Clear the string line buffer */
/* Clear the string line buffer */
memset
(
string_line_buffer
,
0
,
STRING_LINE_SIZE
);
memset
(
string_line_buffer
,
0
,
STRING_LINE_SIZE
);
string_line_buffer_index
=
0
;
string_line_buffer_index
=
0
;
switch
(
token
=
parseToken
(
fs
,
eqn_string
))
{
switch
(
token
=
parseToken
(
fs
,
eqn_string
))
{
/* Invalid Cases */
/* Invalid Cases */
case
tRBr
:
case
tRBr
:
case
tLPr
:
case
tLPr
:
...
@@ -416,222 +416,222 @@ int parse_line(FILE * fs, struct PRESET_T * preset) {
...
@@ -416,222 +416,222 @@ int parse_line(FILE * fs, struct PRESET_T * preset) {
case
tOr
:
case
tOr
:
case
tAnd
:
case
tAnd
:
case
tDiv
:
case
tDiv
:
// if (PARSE_DEBUG) printf("parse_line: invalid token found at start of line (LINE %d)\n", line_count);
// if (PARSE_DEBUG) printf("parse_line: invalid token found at start of line (LINE %d)\n", line_count);
/* Invalid token found, return a parse error */
/* Invalid token found, return a parse error */
return
PARSE_ERROR
;
return
PARSE_ERROR
;
case
tEOL
:
/* Empty line */
case
tEOL
:
/* Empty line */
line_mode
=
NORMAL_LINE_MODE
;
line_mode
=
NORMAL_LINE_MODE
;
return
SUCCESS
;
return
SUCCESS
;
case
tEOF
:
/* End of File */
case
tEOF
:
/* End of File */
line_mode
=
NORMAL_LINE_MODE
;
line_mode
=
NORMAL_LINE_MODE
;
line_count
=
1
;
line_count
=
1
;
return
EOF
;
return
EOF
;
case
tSemiColon
:
/* Indicates end of expression */
case
tSemiColon
:
/* Indicates end of expression */
return
SUCCESS
;
return
SUCCESS
;
/* Valid Case, either an initial condition or equation should follow */
/* Valid Case, either an initial condition or equation should follow */
case
tEq
:
case
tEq
:
/* CASE: PER FRAME INIT EQUATION */
/* CASE: PER FRAME INIT EQUATION */
if
(
!
strncmp
(
eqn_string
,
PER_FRAME_INIT_STRING
,
PER_FRAME_INIT_STRING_LENGTH
))
{
if
(
!
strncmp
(
eqn_string
,
PER_FRAME_INIT_STRING
,
PER_FRAME_INIT_STRING_LENGTH
))
{
//if (PARSE_DEBUG) printf("parse_line: per frame init equation found...(LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_line: per frame init equation found...(LINE %d)\n", line_count);
/* Set the line mode to normal */
/* Set the line mode to normal */
line_mode
=
NORMAL_LINE_MODE
;
line_mode
=
NORMAL_LINE_MODE
;
/* Parse the per frame equation */
/* Parse the per frame equation */
if
((
init_cond
=
parse_per_frame_init_eqn
(
fs
,
preset
,
NULL
))
==
NULL
)
{
if
((
init_cond
=
parse_per_frame_init_eqn
(
fs
,
preset
,
NULL
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_line: per frame init equation parsing failed (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_line: per frame init equation parsing failed (LINE %d)\n", line_count);
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Insert the equation in the per frame equation tree */
/* Insert the equation in the per frame equation tree */
if
(
splay_insert
(
init_cond
,
init_cond
->
param
->
name
,
preset
->
per_frame_init_eqn_tree
)
<
0
)
{
if
(
splay_insert
(
init_cond
,
init_cond
->
param
->
name
,
preset
->
per_frame_init_eqn_tree
)
<
0
)
{
//if (PARSE_DEBUG) printf("parse_line: failed to add a perframe equation (ERROR)\n");
//if (PARSE_DEBUG) printf("parse_line: failed to add a perframe equation (ERROR)\n");
free_init_cond
(
init_cond
);
/* will free the gen expr too */
free_init_cond
(
init_cond
);
/* will free the gen expr too */
return
ERROR
;
return
ERROR
;
}
}
if
(
update_string_buffer
(
preset
->
per_frame_init_eqn_string_buffer
,
if
(
update_string_buffer
(
preset
->
per_frame_init_eqn_string_buffer
,
&
preset
->
per_frame_init_eqn_string_index
)
<
0
)
&
preset
->
per_frame_init_eqn_string_index
)
<
0
)
{
return
FAILURE
;}
{
return
FAILURE
;}
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Per frame equation case */
/* Per frame equation case */
if
(
!
strncmp
(
eqn_string
,
PER_FRAME_STRING
,
PER_FRAME_STRING_LENGTH
))
{
if
(
!
strncmp
(
eqn_string
,
PER_FRAME_STRING
,
PER_FRAME_STRING_LENGTH
))
{
/* Sometimes per frame equations are implicitly defined without the
/* Sometimes per frame equations are implicitly defined without the
per_frame_ prefix. This informs the parser that one could follow */
per_frame_ prefix. This informs the parser that one could follow */
line_mode
=
PER_FRAME_LINE_MODE
;
line_mode
=
PER_FRAME_LINE_MODE
;
//if (PARSE_DEBUG) printf("parse_line: per frame equation found...(LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_line: per frame equation found...(LINE %d)\n", line_count);
/* Parse the per frame equation */
/* Parse the per frame equation */
if
((
per_frame_eqn
=
parse_per_frame_eqn
(
fs
,
++
per_frame_eqn_count
,
preset
))
==
NULL
)
{
if
((
per_frame_eqn
=
parse_per_frame_eqn
(
fs
,
++
per_frame_eqn_count
,
preset
))
==
NULL
)
{
if
(
PARSE_DEBUG
)
printf
(
"parse_line: per frame equation parsing failed (LINE %d)
\n
"
,
line_count
);
if
(
PARSE_DEBUG
)
printf
(
"parse_line: per frame equation parsing failed (LINE %d)
\n
"
,
line_count
);
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Insert the equation in the per frame equation tree */
/* Insert the equation in the per frame equation tree */
if
(
splay_insert
(
per_frame_eqn
,
&
per_frame_eqn_count
,
preset
->
per_frame_eqn_tree
)
<
0
)
{
if
(
splay_insert
(
per_frame_eqn
,
&
per_frame_eqn_count
,
preset
->
per_frame_eqn_tree
)
<
0
)
{
if
(
PARSE_DEBUG
)
printf
(
"parse_line: failed to add a perframe equation (ERROR)
\n
"
);
if
(
PARSE_DEBUG
)
printf
(
"parse_line: failed to add a perframe equation (ERROR)
\n
"
);
free_per_frame_eqn
(
per_frame_eqn
);
/* will free the gen expr too */
free_per_frame_eqn
(
per_frame_eqn
);
/* will free the gen expr too */
return
ERROR
;
return
ERROR
;
}
}
if
(
update_string_buffer
(
preset
->
per_frame_eqn_string_buffer
,
if
(
update_string_buffer
(
preset
->
per_frame_eqn_string_buffer
,
&
preset
->
per_frame_eqn_string_index
)
<
0
)
&
preset
->
per_frame_eqn_string_index
)
<
0
)
return
FAILURE
;
return
FAILURE
;
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Wavecode initial condition case */
/* Wavecode initial condition case */
if
(
!
strncmp
(
eqn_string
,
WAVECODE_STRING
,
WAVECODE_STRING_LENGTH
))
{
if
(
!
strncmp
(
eqn_string
,
WAVECODE_STRING
,
WAVECODE_STRING_LENGTH
))
{
line_mode
=
CUSTOM_WAVE_WAVECODE_LINE_MODE
;
line_mode
=
CUSTOM_WAVE_WAVECODE_LINE_MODE
;
//if (PARSE_DEBUG)
//if (PARSE_DEBUG)
// printf("parse_line: wavecode prefix found: \"%s\"\n", eqn_string);
// printf("parse_line: wavecode prefix found: \"%s\"\n", eqn_string);
// printf("string:%d\n", 5);
// printf("string:%d\n", 5);
//SUPER MYSTERIO-BUG - Don't Remove
//SUPER MYSTERIO-BUG - Don't Remove
printf
(
""
);
printf
(
""
);
return
parse_wavecode
(
eqn_string
,
fs
,
preset
);
return
parse_wavecode
(
eqn_string
,
fs
,
preset
);
}
}
/* Custom Wave Prefix */
/* Custom Wave Prefix */
if
((
!
strncmp
(
eqn_string
,
WAVE_STRING
,
WAVE_STRING_LENGTH
))
&&
if
((
!
strncmp
(
eqn_string
,
WAVE_STRING
,
WAVE_STRING_LENGTH
))
&&
((
eqn_string
[
5
]
>=
48
)
&&
(
eqn_string
[
5
]
<=
57
)))
{
((
eqn_string
[
5
]
>=
48
)
&&
(
eqn_string
[
5
]
<=
57
)))
{
// if (PARSE_DEBUG) printf("parse_line wave prefix found: \"%s\"\n", eqn_string);
// if (PARSE_DEBUG) printf("parse_line wave prefix found: \"%s\"\n", eqn_string);
return
parse_wave
(
eqn_string
,
fs
,
preset
);
return
parse_wave
(
eqn_string
,
fs
,
preset
);
}
}
/* Shapecode initial condition case */
/* Shapecode initial condition case */
if
(
!
strncmp
(
eqn_string
,
SHAPECODE_STRING
,
SHAPECODE_STRING_LENGTH
))
{
if
(
!
strncmp
(
eqn_string
,
SHAPECODE_STRING
,
SHAPECODE_STRING_LENGTH
))
{
line_mode
=
CUSTOM_SHAPE_SHAPECODE_LINE_MODE
;
line_mode
=
CUSTOM_SHAPE_SHAPECODE_LINE_MODE
;
if
(
PARSE_DEBUG
)
printf
(
"parse_line: shapecode prefix found:
\"
%s
\"\n
"
,
eqn_string
);
if
(
PARSE_DEBUG
)
printf
(
"parse_line: shapecode prefix found:
\"
%s
\"\n
"
,
eqn_string
);
return
parse_shapecode
(
eqn_string
,
fs
,
preset
);
return
parse_shapecode
(
eqn_string
,
fs
,
preset
);
}
}
/* Custom Shape Prefix */
/* Custom Shape Prefix */
if
((
!
strncmp
(
eqn_string
,
SHAPE_STRING
,
SHAPE_STRING_LENGTH
))
&&
if
((
!
strncmp
(
eqn_string
,
SHAPE_STRING
,
SHAPE_STRING_LENGTH
))
&&
((
eqn_string
[
6
]
>=
48
)
&&
(
eqn_string
[
6
]
<=
57
)))
{
((
eqn_string
[
6
]
>=
48
)
&&
(
eqn_string
[
6
]
<=
57
)))
{
if
(
PARSE_DEBUG
)
printf
(
"parse_line shape prefix found:
\"
%s
\"\n
"
,
eqn_string
);
if
(
PARSE_DEBUG
)
printf
(
"parse_line shape prefix found:
\"
%s
\"\n
"
,
eqn_string
);
return
parse_shape
(
eqn_string
,
fs
,
preset
);
return
parse_shape
(
eqn_string
,
fs
,
preset
);
}
}
/* Per pixel equation case */
/* Per pixel equation case */
if
(
!
strncmp
(
eqn_string
,
PER_PIXEL_STRING
,
PER_PIXEL_STRING_LENGTH
))
{
if
(
!
strncmp
(
eqn_string
,
PER_PIXEL_STRING
,
PER_PIXEL_STRING_LENGTH
))
{
line_mode
=
PER_PIXEL_LINE_MODE
;
line_mode
=
PER_PIXEL_LINE_MODE
;
if
(
parse_per_pixel_eqn
(
fs
,
preset
)
<
0
)
if
(
parse_per_pixel_eqn
(
fs
,
preset
)
<
0
)
return
PARSE_ERROR
;
return
PARSE_ERROR
;
if
(
update_string_buffer
(
preset
->
per_pixel_eqn_string_buffer
,
if
(
update_string_buffer
(
preset
->
per_pixel_eqn_string_buffer
,
&
preset
->
per_pixel_eqn_string_index
)
<
0
)
&
preset
->
per_pixel_eqn_string_index
)
<
0
)
return
FAILURE
;
return
FAILURE
;
if
(
PARSE_DEBUG
)
printf
(
"parse_line: finished parsing per pixel equation (LINE %d)
\n
"
,
line_count
);
if
(
PARSE_DEBUG
)
printf
(
"parse_line: finished parsing per pixel equation (LINE %d)
\n
"
,
line_count
);
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Sometimes equations are written implicitly in milkdrop files, in the form
/* Sometimes equations are written implicitly in milkdrop files, in the form
per_frame_1 = p1 = eqn1; p2 = eqn2; p3 = eqn3;..;
per_frame_1 = p1 = eqn1; p2 = eqn2; p3 = eqn3;..;
which is analagous to:
which is analagous to:
per_frame_1 = p1 = eqn1; per_frame_2 = p2 = eqn2; per_frame_3 = p3 = eqn3; ...;
per_frame_1 = p1 = eqn1; per_frame_2 = p2 = eqn2; per_frame_3 = p3 = eqn3; ...;
The following line mode hack allows such implicit declaration of the
The following line mode hack allows such implicit declaration of the
prefix that specifies the equation type. An alternative method
prefix that specifies the equation type. An alternative method
may be to associate each equation line as list of equations separated
may be to associate each equation line as list of equations separated
by semicolons (and a new line ends the list). Instead, however, a global
by semicolons (and a new line ends the list). Instead, however, a global
variable called "line_mode" specifies the last type of equation found,
variable called "line_mode" specifies the last type of equation found,
and bases any implicitly typed input on this fact
and bases any implicitly typed input on this fact
Note added by Carmelo Piccione (cep@andrew.cmu.edu) 10/19/03
Note added by Carmelo Piccione (cep@andrew.cmu.edu) 10/19/03
*/
*/
/* Per frame line mode previously, try to parse the equation implicitly */
/* Per frame line mode previously, try to parse the equation implicitly */
if
(
line_mode
==
PER_FRAME_LINE_MODE
)
{
if
(
line_mode
==
PER_FRAME_LINE_MODE
)
{
if
((
per_frame_eqn
=
parse_implicit_per_frame_eqn
(
fs
,
eqn_string
,
++
per_frame_eqn_count
,
preset
))
==
NULL
)
if
((
per_frame_eqn
=
parse_implicit_per_frame_eqn
(
fs
,
eqn_string
,
++
per_frame_eqn_count
,
preset
))
==
NULL
)
return
PARSE_ERROR
;
return
PARSE_ERROR
;
/* Insert the equation in the per frame equation tree */
/* Insert the equation in the per frame equation tree */
if
(
splay_insert
(
per_frame_eqn
,
&
per_frame_eqn_count
,
preset
->
per_frame_eqn_tree
)
<
0
)
{
if
(
splay_insert
(
per_frame_eqn
,
&
per_frame_eqn_count
,
preset
->
per_frame_eqn_tree
)
<
0
)
{
if
(
PARSE_DEBUG
)
printf
(
"parse_line: failed to add a perframe equation (ERROR)
\n
"
);
if
(
PARSE_DEBUG
)
printf
(
"parse_line: failed to add a perframe equation (ERROR)
\n
"
);
free_per_frame_eqn
(
per_frame_eqn
);
/* will free the gen expr too */
free_per_frame_eqn
(
per_frame_eqn
);
/* will free the gen expr too */
return
ERROR
;
return
ERROR
;
}
}
if
(
update_string_buffer
(
preset
->
per_frame_eqn_string_buffer
,
if
(
update_string_buffer
(
preset
->
per_frame_eqn_string_buffer
,
&
preset
->
per_frame_eqn_string_index
)
<
0
)
&
preset
->
per_frame_eqn_string_index
)
<
0
)
return
FAILURE
;
return
FAILURE
;
return
SUCCESS
;
return
SUCCESS
;
}
}
//if (PARSE_DEBUG) printf("parse_line: found initial condition: name = \"%s\" (LINE %d)\n", eqn_string, line_count);
//if (PARSE_DEBUG) printf("parse_line: found initial condition: name = \"%s\" (LINE %d)\n", eqn_string, line_count);
/* Evaluate the initial condition */
/* Evaluate the initial condition */
if
((
init_cond
=
parse_init_cond
(
fs
,
eqn_string
,
preset
))
==
NULL
)
{
if
((
init_cond
=
parse_init_cond
(
fs
,
eqn_string
,
preset
))
==
NULL
)
{
if
(
PARSE_DEBUG
)
printf
(
"parse_line: failed to parse initial condition (LINE %d)
\n
"
,
line_count
);
if
(
PARSE_DEBUG
)
printf
(
"parse_line: failed to parse initial condition (LINE %d)
\n
"
,
line_count
);
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Add equation to initial condition tree */
/* Add equation to initial condition tree */
if
(
splay_insert
(
init_cond
,
init_cond
->
param
->
name
,
preset
->
init_cond_tree
)
<
0
)
{
if
(
splay_insert
(
init_cond
,
init_cond
->
param
->
name
,
preset
->
init_cond_tree
)
<
0
)
{
if
(
PARSE_DEBUG
)
printf
(
"parse_line: failed to add initial condition
\"
%s
\"
to equation tree (LINE %d)
\n
"
,
if
(
PARSE_DEBUG
)
printf
(
"parse_line: failed to add initial condition
\"
%s
\"
to equation tree (LINE %d)
\n
"
,
init_cond
->
param
->
name
,
line_count
);
init_cond
->
param
->
name
,
line_count
);
free_init_cond
(
init_cond
);
free_init_cond
(
init_cond
);
return
FAILURE
;
return
FAILURE
;
}
}
/* Finished with initial condition line */
/* Finished with initial condition line */
// if (PARSE_DEBUG) printf("parse_line: initial condition parsed successfully\n");
// if (PARSE_DEBUG) printf("parse_line: initial condition parsed successfully\n");
return
SUCCESS
;
return
SUCCESS
;
/* END INITIAL CONDITIONING PARSING */
/* END INITIAL CONDITIONING PARSING */
default:
/* an uncaught type or an error has occurred */
default:
/* an uncaught type or an error has occurred */
if
(
PARSE_DEBUG
)
printf
(
"parse_line: uncaught case, token val = %d
\n
"
,
token
);
if
(
PARSE_DEBUG
)
printf
(
"parse_line: uncaught case, token val = %d
\n
"
,
token
);
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Because of the default in the case statement,
/* Because of the default in the case statement,
control flow should never actually reach here */
control flow should never actually reach here */
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
...
@@ -639,7 +639,7 @@ int parse_line(FILE * fs, struct PRESET_T * preset) {
...
@@ -639,7 +639,7 @@ int parse_line(FILE * fs, struct PRESET_T * preset) {
/* Parses a general expression, this function is the meat of the parser */
/* Parses a general expression, this function is the meat of the parser */
gen_expr_t
*
parse_gen_expr
(
FILE
*
fs
,
tree_expr_t
*
tree_expr
,
struct
PRESET_T
*
preset
)
{
gen_expr_t
*
parse_gen_expr
(
FILE
*
fs
,
tree_expr_t
*
tree_expr
,
struct
PRESET_T
*
preset
)
{
int
i
;
int
i
;
char
string
[
MAX_TOKEN_SIZE
];
char
string
[
MAX_TOKEN_SIZE
];
token_t
token
;
token_t
token
;
...
@@ -652,101 +652,101 @@ gen_expr_t * parse_gen_expr (FILE * fs, tree_expr_t * tree_expr, struct PRESET_T
...
@@ -652,101 +652,101 @@ gen_expr_t * parse_gen_expr (FILE * fs, tree_expr_t * tree_expr, struct PRESET_T
switch
(
token
=
parseToken
(
fs
,
string
))
{
switch
(
token
=
parseToken
(
fs
,
string
))
{
/* Left Parentice Case */
/* Left Parentice Case */
case
tLPr
:
case
tLPr
:
/* CASE 1 (Left Parentice): See if the previous string before this parentice is a function name */
/* CASE 1 (Left Parentice): See if the previous string before this parentice is a function name */
if
((
func
=
find_func
(
string
))
!=
NULL
)
{
if
((
func
=
find_func
(
string
))
!=
NULL
)
{
if
(
PARSE_DEBUG
)
printf
(
"parse_gen_expr: found prefix function (name = %s) (LINE %d)
\n
"
,
func
->
name
,
line_count
);
if
(
PARSE_DEBUG
)
printf
(
"parse_gen_expr: found prefix function (name = %s) (LINE %d)
\n
"
,
func
->
name
,
line_count
);
/* Parse the functions arguments */
/* Parse the functions arguments */
if
((
expr_list
=
parse_prefix_args
(
fs
,
func
->
num_args
,
preset
))
==
NULL
)
{
if
((
expr_list
=
parse_prefix_args
(
fs
,
func
->
num_args
,
preset
))
==
NULL
)
{
if
(
PARSE_DEBUG
)
printf
(
"parse_prefix_args: failed to generate an expresion list! (LINE %d)
\n
"
,
line_count
);
if
(
PARSE_DEBUG
)
printf
(
"parse_prefix_args: failed to generate an expresion list! (LINE %d)
\n
"
,
line_count
);
free_tree_expr
(
tree_expr
);
free_tree_expr
(
tree_expr
);
return
NULL
;
return
NULL
;
}
}
/* Convert function to expression */
/* Convert function to expression */
if
((
gen_expr
=
prefun_to_expr
((
void
*
)
func
->
func_ptr
,
expr_list
,
func
->
num_args
))
==
NULL
)
{
if
((
gen_expr
=
prefun_to_expr
((
void
*
)
func
->
func_ptr
,
expr_list
,
func
->
num_args
))
==
NULL
)
{
if
(
PARSE_DEBUG
)
printf
(
"parse_prefix_args: failed to convert prefix function to general expression (LINE %d)
\n
"
,
if
(
PARSE_DEBUG
)
printf
(
"parse_prefix_args: failed to convert prefix function to general expression (LINE %d)
\n
"
,
line_count
);
line_count
);
free_tree_expr
(
tree_expr
);
free_tree_expr
(
tree_expr
);
for
(
i
=
0
;
i
<
func
->
num_args
;
i
++
)
for
(
i
=
0
;
i
<
func
->
num_args
;
i
++
)
free_gen_expr
(
expr_list
[
i
]);
free_gen_expr
(
expr_list
[
i
]);
free
(
expr_list
);
free
(
expr_list
);
return
NULL
;
return
NULL
;
}
}
token
=
parseToken
(
fs
,
string
);
token
=
parseToken
(
fs
,
string
);
if
(
*
string
!=
0
)
{
if
(
*
string
!=
0
)
{
if
(
PARSE_DEBUG
)
printf
(
"parse_prefix_args: empty string expected, but not found...(LINE %d)
\n
"
,
line_count
);
if
(
PARSE_DEBUG
)
printf
(
"parse_prefix_args: empty string expected, but not found...(LINE %d)
\n
"
,
line_count
);
/* continue anyway for now, could be implicit multiplication */
/* continue anyway for now, could be implicit multiplication */
}
}
return
parse_infix_op
(
fs
,
token
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
return
parse_infix_op
(
fs
,
token
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
}
}
/* Case 2: (Left Parentice), a string coupled with a left parentice. Either an error or implicit
/* Case 2: (Left Parentice), a string coupled with a left parentice. Either an error or implicit
multiplication operator. For now treat it as an error */
multiplication operator. For now treat it as an error */
if
(
*
string
!=
0
)
{
if
(
*
string
!=
0
)
{
if
(
PARSE_DEBUG
)
printf
(
"parse_gen_expr: implicit multiplication case unimplemented!
\n
"
);
if
(
PARSE_DEBUG
)
printf
(
"parse_gen_expr: implicit multiplication case unimplemented!
\n
"
);
free_tree_expr
(
tree_expr
);
free_tree_expr
(
tree_expr
);
return
NULL
;
return
NULL
;
}
}
/* CASE 3 (Left Parentice): the following is enclosed parentices to change order
/* CASE 3 (Left Parentice): the following is enclosed parentices to change order
of operations. So we create a new expression tree */
of operations. So we create a new expression tree */
if
((
gen_expr
=
parse_gen_expr
(
fs
,
NULL
,
preset
))
==
NULL
)
{
if
((
gen_expr
=
parse_gen_expr
(
fs
,
NULL
,
preset
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_gen_expr: found left parentice, but failed to create new expression tree \n");
//if (PARSE_DEBUG) printf("parse_gen_expr: found left parentice, but failed to create new expression tree \n");
free_tree_expr
(
tree_expr
);
free_tree_expr
(
tree_expr
);
return
NULL
;
return
NULL
;
}
}
if
(
PARSE_DEBUG
)
printf
(
"parse_gen_expr: finished enclosed expression tree...
\n
"
);
if
(
PARSE_DEBUG
)
printf
(
"parse_gen_expr: finished enclosed expression tree...
\n
"
);
token
=
parseToken
(
fs
,
string
);
token
=
parseToken
(
fs
,
string
);
return
parse_infix_op
(
fs
,
token
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
return
parse_infix_op
(
fs
,
token
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
/* Plus is a prefix operator check */
/* Plus is a prefix operator check */
case
tPlus
:
case
tPlus
:
if
(
*
string
==
0
)
{
if
(
*
string
==
0
)
{
//if (PARSE_DEBUG) printf("parse_gen_expr: plus used as prefix (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_gen_expr: plus used as prefix (LINE %d)\n", line_count);
/* Treat prefix plus as implict 0 preceding operator */
/* Treat prefix plus as implict 0 preceding operator */
gen_expr
=
const_to_expr
(
0
);
gen_expr
=
const_to_expr
(
0
);
return
parse_infix_op
(
fs
,
tPositive
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
return
parse_infix_op
(
fs
,
tPositive
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
}
}
/* Minus is a prefix operator check */
/* Minus is a prefix operator check */
case
tMinus
:
case
tMinus
:
if
(
*
string
==
0
)
{
if
(
*
string
==
0
)
{
/* Use the negative infix operator, but first add an implicit zero to the operator tree */
/* Use the negative infix operator, but first add an implicit zero to the operator tree */
gen_expr
=
const_to_expr
(
0
);
gen_expr
=
const_to_expr
(
0
);
//return parse_gen_expr(fs, insert_gen_expr(gen_expr, &tree_expr), preset);
//return parse_gen_expr(fs, insert_gen_expr(gen_expr, &tree_expr), preset);
return
parse_infix_op
(
fs
,
tNegative
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
return
parse_infix_op
(
fs
,
tNegative
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
}
}
/* All the following cases are strings followed by an infix operator or terminal */
/* All the following cases are strings followed by an infix operator or terminal */
case
tRPr
:
case
tRPr
:
case
tEOL
:
case
tEOL
:
case
tEOF
:
case
tEOF
:
case
tSemiColon
:
case
tSemiColon
:
case
tComma
:
case
tComma
:
/* CASE 1 (terminal): string is empty, but not null. Not sure if this will actually happen
/* CASE 1 (terminal): string is empty, but not null. Not sure if this will actually happen
any more. */
any more. */
if
(
*
string
==
0
)
{
if
(
*
string
==
0
)
{
//if (PARSE_DEBUG) printf("parse_gen_expr: empty string coupled with terminal (LINE %d) \n", line_count);
//if (PARSE_DEBUG) printf("parse_gen_expr: empty string coupled with terminal (LINE %d) \n", line_count);
return
parse_infix_op
(
fs
,
token
,
tree_expr
,
preset
);
return
parse_infix_op
(
fs
,
token
,
tree_expr
,
preset
);
}
}
default:
default:
/* CASE 0: Empty string, parse error */
/* CASE 0: Empty string, parse error */
if
(
*
string
==
0
)
{
if
(
*
string
==
0
)
{
...
@@ -758,100 +758,100 @@ gen_expr_t * parse_gen_expr (FILE * fs, tree_expr_t * tree_expr, struct PRESET_T
...
@@ -758,100 +758,100 @@ gen_expr_t * parse_gen_expr (FILE * fs, tree_expr_t * tree_expr, struct PRESET_T
/* CASE 1: Check if string is a just a floating point number */
/* CASE 1: Check if string is a just a floating point number */
if
(
string_to_float
(
string
,
&
val
)
!=
PARSE_ERROR
)
{
if
(
string_to_float
(
string
,
&
val
)
!=
PARSE_ERROR
)
{
if
((
gen_expr
=
const_to_expr
(
val
))
==
NULL
)
{
if
((
gen_expr
=
const_to_expr
(
val
))
==
NULL
)
{
free_tree_expr
(
tree_expr
);
free_tree_expr
(
tree_expr
);
return
NULL
;
return
NULL
;
}
}
/* Parse the rest of the line */
/* Parse the rest of the line */
return
parse_infix_op
(
fs
,
token
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
return
parse_infix_op
(
fs
,
token
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
}
}
/* CASE 4: custom shape variable */
/* CASE 4: custom shape variable */
if
(
current_shape
!=
NULL
)
{
if
(
current_shape
!=
NULL
)
{
if
((
param
=
find_param_db
(
string
,
current_shape
->
param_tree
,
FALSE
))
==
NULL
)
{
if
((
param
=
find_param_db
(
string
,
current_shape
->
param_tree
,
FALSE
))
==
NULL
)
{
if
((
param
=
find_builtin_param
(
string
))
==
NULL
)
if
((
param
=
find_builtin_param
(
string
))
==
NULL
)
if
((
param
=
find_param_db
(
string
,
current_shape
->
param_tree
,
TRUE
))
==
NULL
)
{
if
((
param
=
find_param_db
(
string
,
current_shape
->
param_tree
,
TRUE
))
==
NULL
)
{
free_tree_expr
(
tree_expr
);
free_tree_expr
(
tree_expr
);
return
NULL
;
return
NULL
;
}
}
}
}
if
(
PARSE_DEBUG
)
{
if
(
PARSE_DEBUG
)
{
printf
(
"parse_gen_expr: custom shape parameter (name = %s)... "
,
param
->
name
);
printf
(
"parse_gen_expr: custom shape parameter (name = %s)... "
,
param
->
name
);
fflush
(
stdout
);
fflush
(
stdout
);
}
}
/* Convert parameter to an expression */
/* Convert parameter to an expression */
if
((
gen_expr
=
param_to_expr
(
param
))
==
NULL
)
{
if
((
gen_expr
=
param_to_expr
(
param
))
==
NULL
)
{
free_tree_expr
(
tree_expr
);
free_tree_expr
(
tree_expr
);
return
NULL
;
return
NULL
;
}
}
//if (PARSE_DEBUG) printf("converted to expression (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("converted to expression (LINE %d)\n", line_count);
/* Parse the rest of the line */
/* Parse the rest of the line */
return
parse_infix_op
(
fs
,
token
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
return
parse_infix_op
(
fs
,
token
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
}
}
/* CASE 5: custom wave variable */
/* CASE 5: custom wave variable */
if
(
current_wave
!=
NULL
)
{
if
(
current_wave
!=
NULL
)
{
if
((
param
=
find_param_db
(
string
,
current_wave
->
param_tree
,
FALSE
))
==
NULL
)
{
if
((
param
=
find_param_db
(
string
,
current_wave
->
param_tree
,
FALSE
))
==
NULL
)
{
if
((
param
=
find_builtin_param
(
string
))
==
NULL
)
if
((
param
=
find_builtin_param
(
string
))
==
NULL
)
if
((
param
=
find_param_db
(
string
,
current_wave
->
param_tree
,
TRUE
))
==
NULL
)
{
if
((
param
=
find_param_db
(
string
,
current_wave
->
param_tree
,
TRUE
))
==
NULL
)
{
free_tree_expr
(
tree_expr
);
free_tree_expr
(
tree_expr
);
return
NULL
;
return
NULL
;
}
}
}
}
if
(
PARSE_DEBUG
)
{
if
(
PARSE_DEBUG
)
{
printf
(
"parse_gen_expr: custom wave parameter (name = %s)... "
,
param
->
name
);
printf
(
"parse_gen_expr: custom wave parameter (name = %s)... "
,
param
->
name
);
fflush
(
stdout
);
fflush
(
stdout
);
}
}
/* Convert parameter to an expression */
/* Convert parameter to an expression */
if
((
gen_expr
=
param_to_expr
(
param
))
==
NULL
)
{
if
((
gen_expr
=
param_to_expr
(
param
))
==
NULL
)
{
free_tree_expr
(
tree_expr
);
free_tree_expr
(
tree_expr
);
return
NULL
;
return
NULL
;
}
}
if
(
PARSE_DEBUG
)
printf
(
"converted to expression (LINE %d)
\n
"
,
line_count
);
if
(
PARSE_DEBUG
)
printf
(
"converted to expression (LINE %d)
\n
"
,
line_count
);
/* Parse the rest of the line */
/* Parse the rest of the line */
return
parse_infix_op
(
fs
,
token
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
return
parse_infix_op
(
fs
,
token
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
}
}
/* CASE 6: regular parameter. Will be created if necessary and the string has no invalid characters */
/* CASE 6: regular parameter. Will be created if necessary and the string has no invalid characters */
if
((
param
=
find_param
(
string
,
preset
,
P_CREATE
))
!=
NULL
)
{
if
((
param
=
find_param
(
string
,
preset
,
P_CREATE
))
!=
NULL
)
{
if
(
PARSE_DEBUG
)
{
if
(
PARSE_DEBUG
)
{
printf
(
"parse_gen_expr: parameter (name = %s)... "
,
param
->
name
);
printf
(
"parse_gen_expr: parameter (name = %s)... "
,
param
->
name
);
fflush
(
stdout
);
fflush
(
stdout
);
}
}
/* Convert parameter to an expression */
/* Convert parameter to an expression */
if
((
gen_expr
=
param_to_expr
(
param
))
==
NULL
)
{
if
((
gen_expr
=
param_to_expr
(
param
))
==
NULL
)
{
free_tree_expr
(
tree_expr
);
free_tree_expr
(
tree_expr
);
return
NULL
;
return
NULL
;
}
}
if
(
PARSE_DEBUG
)
printf
(
"converted to expression (LINE %d)
\n
"
,
line_count
);
if
(
PARSE_DEBUG
)
printf
(
"converted to expression (LINE %d)
\n
"
,
line_count
);
/* Parse the rest of the line */
/* Parse the rest of the line */
return
parse_infix_op
(
fs
,
token
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
return
parse_infix_op
(
fs
,
token
,
insert_gen_expr
(
gen_expr
,
&
tree_expr
),
preset
);
}
}
/* CASE 7: Bad string, give up */
/* CASE 7: Bad string, give up */
if
(
PARSE_DEBUG
)
printf
(
"parse_gen_expr: syntax error [string =
\"
%s
\"
] (LINE %d)
\n
"
,
string
,
line_count
);
if
(
PARSE_DEBUG
)
printf
(
"parse_gen_expr: syntax error [string =
\"
%s
\"
] (LINE %d)
\n
"
,
string
,
line_count
);
free_tree_expr
(
tree_expr
);
free_tree_expr
(
tree_expr
);
return
NULL
;
return
NULL
;
}
}
}
}
/* Inserts expressions into tree according to operator precedence.
/* Inserts expressions into tree according to operator precedence.
...
@@ -860,70 +860,70 @@ gen_expr_t * parse_gen_expr (FILE * fs, tree_expr_t * tree_expr, struct PRESET_T
...
@@ -860,70 +860,70 @@ gen_expr_t * parse_gen_expr (FILE * fs, tree_expr_t * tree_expr, struct PRESET_T
tree_expr_t
*
insert_infix_op
(
infix_op_t
*
infix_op
,
tree_expr_t
**
root
)
{
tree_expr_t
*
insert_infix_op
(
infix_op_t
*
infix_op
,
tree_expr_t
**
root
)
{
tree_expr_t
*
new_root
;
tree_expr_t
*
new_root
;
/* Sanity check */
/* Sanity check */
if
(
infix_op
==
NULL
)
if
(
infix_op
==
NULL
)
return
NULL
;
return
NULL
;
/* The root is null, so make this operator
/* The root is null, so make this operator
the new root */
the new root */
if
(
*
root
==
NULL
)
{
if
(
*
root
==
NULL
)
{
new_root
=
new_tree_expr
(
infix_op
,
NULL
,
NULL
,
NULL
);
new_root
=
new_tree_expr
(
infix_op
,
NULL
,
NULL
,
NULL
);
*
root
=
new_root
;
*
root
=
new_root
;
return
new_root
;
return
new_root
;
}
}
/* The root node is not an infix function,
/* The root node is not an infix function,
so we make this infix operator the new root */
so we make this infix operator the new root */
if
((
*
root
)
->
infix_op
==
NULL
)
{
if
((
*
root
)
->
infix_op
==
NULL
)
{
new_root
=
new_tree_expr
(
infix_op
,
NULL
,
*
root
,
NULL
);
new_root
=
new_tree_expr
(
infix_op
,
NULL
,
*
root
,
NULL
);
(
*
root
)
=
new_root
;
(
*
root
)
=
new_root
;
return
new_root
;
return
new_root
;
}
}
/* The root is an infix function. If the precedence
/* The root is an infix function. If the precedence
of the item to be inserted is greater than the root's
of the item to be inserted is greater than the root's
precedence, then make gen_expr the root */
precedence, then make gen_expr the root */
if
(
infix_op
->
precedence
>
(
*
root
)
->
infix_op
->
precedence
)
{
if
(
infix_op
->
precedence
>
(
*
root
)
->
infix_op
->
precedence
)
{
new_root
=
new_tree_expr
(
infix_op
,
NULL
,
*
root
,
NULL
);
new_root
=
new_tree_expr
(
infix_op
,
NULL
,
*
root
,
NULL
);
(
*
root
)
=
new_root
;
(
*
root
)
=
new_root
;
return
new_root
;
return
new_root
;
}
}
/* If control flow reaches here, use a recursive helper
/* If control flow reaches here, use a recursive helper
with the knowledge that the root is higher precedence
with the knowledge that the root is higher precedence
than the item to be inserted */
than the item to be inserted */
insert_infix_rec
(
infix_op
,
*
root
);
insert_infix_rec
(
infix_op
,
*
root
);
return
*
root
;
return
*
root
;
}
}
tree_expr_t
*
insert_gen_expr
(
gen_expr_t
*
gen_expr
,
tree_expr_t
**
root
)
{
tree_expr_t
*
insert_gen_expr
(
gen_expr_t
*
gen_expr
,
tree_expr_t
**
root
)
{
tree_expr_t
*
new_root
;
tree_expr_t
*
new_root
;
/* If someone foolishly passes a null
/* If someone foolishly passes a null
pointer to insert, return the original tree */
pointer to insert, return the original tree */
if
(
gen_expr
==
NULL
)
{
if
(
gen_expr
==
NULL
)
{
return
*
root
;
return
*
root
;
}
}
/* If the root is null, generate a new expression tree,
/* If the root is null, generate a new expression tree,
using the passed expression as the root element */
using the passed expression as the root element */
if
(
*
root
==
NULL
)
{
if
(
*
root
==
NULL
)
{
new_root
=
new_tree_expr
(
NULL
,
gen_expr
,
NULL
,
NULL
);
new_root
=
new_tree_expr
(
NULL
,
gen_expr
,
NULL
,
NULL
);
*
root
=
new_root
;
*
root
=
new_root
;
return
new_root
;
return
new_root
;
}
}
/* Otherwise. the new element definitely will not replace the current root.
/* Otherwise. the new element definitely will not replace the current root.
Use a recursive helper function to do insertion */
Use a recursive helper function to do insertion */
...
@@ -933,45 +933,45 @@ tree_expr_t * insert_gen_expr(gen_expr_t * gen_expr, tree_expr_t ** root) {
...
@@ -933,45 +933,45 @@ tree_expr_t * insert_gen_expr(gen_expr_t * gen_expr, tree_expr_t ** root) {
/* A recursive helper function to insert general expression elements into the operator tree */
/* A recursive helper function to insert general expression elements into the operator tree */
int
insert_gen_rec
(
gen_expr_t
*
gen_expr
,
tree_expr_t
*
root
)
{
int
insert_gen_rec
(
gen_expr_t
*
gen_expr
,
tree_expr_t
*
root
)
{
/* Trivial Case: root is null */
/* Trivial Case: root is null */
if
(
root
==
NULL
)
{
if
(
root
==
NULL
)
{
////if (PARSE_DEBUG) printf("insert_gen_rec: root is null, returning failure\n");
////if (PARSE_DEBUG) printf("insert_gen_rec: root is null, returning failure\n");
return
FAILURE
;
return
FAILURE
;
}
}
/* The current node's left pointer is null, and this
/* The current node's left pointer is null, and this
current node is an infix operator, so insert the
current node is an infix operator, so insert the
general expression at the left pointer */
general expression at the left pointer */
if
((
root
->
left
==
NULL
)
&&
(
root
->
infix_op
!=
NULL
))
{
if
((
root
->
left
==
NULL
)
&&
(
root
->
infix_op
!=
NULL
))
{
root
->
left
=
new_tree_expr
(
NULL
,
gen_expr
,
NULL
,
NULL
);
root
->
left
=
new_tree_expr
(
NULL
,
gen_expr
,
NULL
,
NULL
);
return
SUCCESS
;
return
SUCCESS
;
}
}
/* The current node's right pointer is null, and this
/* The current node's right pointer is null, and this
current node is an infix operator, so insert the
current node is an infix operator, so insert the
general expression at the right pointer */
general expression at the right pointer */
if
((
root
->
right
==
NULL
)
&&
(
root
->
infix_op
!=
NULL
))
{
if
((
root
->
right
==
NULL
)
&&
(
root
->
infix_op
!=
NULL
))
{
root
->
right
=
new_tree_expr
(
NULL
,
gen_expr
,
NULL
,
NULL
);
root
->
right
=
new_tree_expr
(
NULL
,
gen_expr
,
NULL
,
NULL
);
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Otherwise recurse down to the left. If
/* Otherwise recurse down to the left. If
this succeeds then return. If it fails, try
this succeeds then return. If it fails, try
recursing down to the right */
recursing down to the right */
if
(
insert_gen_rec
(
gen_expr
,
root
->
left
)
==
FAILURE
)
if
(
insert_gen_rec
(
gen_expr
,
root
->
left
)
==
FAILURE
)
return
insert_gen_rec
(
gen_expr
,
root
->
right
);
return
insert_gen_rec
(
gen_expr
,
root
->
right
);
/* Impossible for control flow to reach here, but in
/* Impossible for control flow to reach here, but in
the world of C programming, who knows... */
the world of C programming, who knows... */
//if (PARSE_DEBUG) printf("insert_gen_rec: should never reach here!\n");
//if (PARSE_DEBUG) printf("insert_gen_rec: should never reach here!\n");
return
FAILURE
;
return
FAILURE
;
}
}
/* A recursive helper function to insert infix arguments by operator precedence */
/* A recursive helper function to insert infix arguments by operator precedence */
...
@@ -981,13 +981,13 @@ int insert_infix_rec(infix_op_t * infix_op, tree_expr_t * root) {
...
@@ -981,13 +981,13 @@ int insert_infix_rec(infix_op_t * infix_op, tree_expr_t * root) {
if
(
root
==
NULL
)
if
(
root
==
NULL
)
return
FAILURE
;
return
FAILURE
;
/* Also shouldn't happen, also implies a (different) parse error */
/* Also shouldn't happen, also implies a (different) parse error */
if
(
root
->
infix_op
==
NULL
)
if
(
root
->
infix_op
==
NULL
)
return
FAILURE
;
return
FAILURE
;
/* Left tree is empty, attach this operator to it.
/* Left tree is empty, attach this operator to it.
I don't think this will ever happen */
I don't think this will ever happen */
if
(
root
->
left
==
NULL
)
{
if
(
root
->
left
==
NULL
)
{
root
->
left
=
new_tree_expr
(
infix_op
,
NULL
,
root
->
left
,
NULL
);
root
->
left
=
new_tree_expr
(
infix_op
,
NULL
,
root
->
left
,
NULL
);
...
@@ -1011,14 +1011,14 @@ int insert_infix_rec(infix_op_t * infix_op, tree_expr_t * root) {
...
@@ -1011,14 +1011,14 @@ int insert_infix_rec(infix_op_t * infix_op, tree_expr_t * root) {
root
->
right
=
new_tree_expr
(
infix_op
,
NULL
,
root
->
right
,
NULL
);
root
->
right
=
new_tree_expr
(
infix_op
,
NULL
,
root
->
right
,
NULL
);
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Traverse deeper if the inserting operator precedence is less than the
/* Traverse deeper if the inserting operator precedence is less than the
the root's right operator precedence */
the root's right operator precedence */
if
(
infix_op
->
precedence
<
root
->
right
->
infix_op
->
precedence
)
if
(
infix_op
->
precedence
<
root
->
right
->
infix_op
->
precedence
)
return
insert_infix_rec
(
infix_op
,
root
->
right
);
return
insert_infix_rec
(
infix_op
,
root
->
right
);
/* Otherwise, insert the operator here */
/* Otherwise, insert the operator here */
root
->
right
=
new_tree_expr
(
infix_op
,
NULL
,
root
->
right
,
NULL
);
root
->
right
=
new_tree_expr
(
infix_op
,
NULL
,
root
->
right
,
NULL
);
return
SUCCESS
;
return
SUCCESS
;
...
@@ -1026,11 +1026,11 @@ int insert_infix_rec(infix_op_t * infix_op, tree_expr_t * root) {
...
@@ -1026,11 +1026,11 @@ int insert_infix_rec(infix_op_t * infix_op, tree_expr_t * root) {
/* Parses an infix operator */
/* Parses an infix operator */
gen_expr_t
*
parse_infix_op
(
FILE
*
fs
,
token_t
token
,
tree_expr_t
*
tree_expr
,
struct
PRESET_T
*
preset
)
{
gen_expr_t
*
parse_infix_op
(
FILE
*
fs
,
token_t
token
,
tree_expr_t
*
tree_expr
,
struct
PRESET_T
*
preset
)
{
gen_expr_t
*
gen_expr
;
gen_expr_t
*
gen_expr
;
switch
(
token
)
{
switch
(
token
)
{
/* All the infix operators */
/* All the infix operators */
case
tPlus
:
case
tPlus
:
//if (PARSE_DEBUG) printf("parse_infix_op: found addition operator (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_infix_op: found addition operator (LINE %d)\n", line_count);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_add
,
&
tree_expr
),
preset
);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_add
,
&
tree_expr
),
preset
);
...
@@ -1041,41 +1041,41 @@ gen_expr_t * parse_infix_op(FILE * fs, token_t token, tree_expr_t * tree_expr, s
...
@@ -1041,41 +1041,41 @@ gen_expr_t * parse_infix_op(FILE * fs, token_t token, tree_expr_t * tree_expr, s
//if (PARSE_DEBUG) printf("parse_infix_op: found multiplication operator (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_infix_op: found multiplication operator (LINE %d)\n", line_count);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_mult
,
&
tree_expr
),
preset
);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_mult
,
&
tree_expr
),
preset
);
case
tDiv
:
case
tDiv
:
//if (PARSE_DEBUG) printf("parse_infix_op: found division operator (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_infix_op: found division operator (LINE %d)\n", line_count);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_div
,
&
tree_expr
),
preset
);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_div
,
&
tree_expr
),
preset
);
case
tMod
:
case
tMod
:
//if (PARSE_DEBUG) printf("parse_infix_op: found modulo operator (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_infix_op: found modulo operator (LINE %d)\n", line_count);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_mod
,
&
tree_expr
),
preset
);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_mod
,
&
tree_expr
),
preset
);
case
tOr
:
case
tOr
:
//if (PARSE_DEBUG) printf("parse_infix_op: found bitwise or operator (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_infix_op: found bitwise or operator (LINE %d)\n", line_count);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_or
,
&
tree_expr
),
preset
);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_or
,
&
tree_expr
),
preset
);
case
tAnd
:
case
tAnd
:
//if (PARSE_DEBUG) printf("parse_infix_op: found bitwise and operator (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_infix_op: found bitwise and operator (LINE %d)\n", line_count);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_and
,
&
tree_expr
),
preset
);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_and
,
&
tree_expr
),
preset
);
case
tPositive
:
case
tPositive
:
//if (PARSE_DEBUG) printf("parse_infix_op: found positive operator (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_infix_op: found positive operator (LINE %d)\n", line_count);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_positive
,
&
tree_expr
),
preset
);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_positive
,
&
tree_expr
),
preset
);
case
tNegative
:
case
tNegative
:
//if (PARSE_DEBUG) printf("parse_infix_op: found negative operator (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_infix_op: found negative operator (LINE %d)\n", line_count);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_negative
,
&
tree_expr
),
preset
);
return
parse_gen_expr
(
fs
,
insert_infix_op
(
infix_negative
,
&
tree_expr
),
preset
);
case
tEOL
:
case
tEOL
:
case
tEOF
:
case
tEOF
:
case
tSemiColon
:
case
tSemiColon
:
case
tRPr
:
case
tRPr
:
case
tComma
:
case
tComma
:
//if (PARSE_DEBUG) printf("parse_infix_op: terminal found (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_infix_op: terminal found (LINE %d)\n", line_count);
gen_expr
=
new_gen_expr
(
TREE_T
,
(
void
*
)
tree_expr
);
gen_expr
=
new_gen_expr
(
TREE_T
,
(
void
*
)
tree_expr
);
return
gen_expr
;
return
gen_expr
;
default:
default:
//if (PARSE_DEBUG) printf("parse_infix_op: operator or terminal expected, but not found (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_infix_op: operator or terminal expected, but not found (LINE %d)\n", line_count);
free_tree_expr
(
tree_expr
);
free_tree_expr
(
tree_expr
);
return
NULL
;
return
NULL
;
}
}
/* Will never happen */
/* Will never happen */
return
NULL
;
return
NULL
;
}
}
/* Parses an integer, checks for +/- prefix */
/* Parses an integer, checks for +/- prefix */
...
@@ -1085,41 +1085,41 @@ char string[MAX_TOKEN_SIZE];
...
@@ -1085,41 +1085,41 @@ char string[MAX_TOKEN_SIZE];
token_t
token
;
token_t
token
;
int
sign
;
int
sign
;
char
*
end_ptr
=
" "
;
char
*
end_ptr
=
" "
;
token
=
parseToken
(
fs
,
string
);
token
=
parseToken
(
fs
,
string
);
switch
(
token
)
{
switch
(
token
)
{
case
tMinus
:
case
tMinus
:
sign
=
-
1
;
sign
=
-
1
;
token
=
parseToken
(
fs
,
string
);
token
=
parseToken
(
fs
,
string
);
break
;
break
;
case
tPlus
:
case
tPlus
:
sign
=
1
;
sign
=
1
;
token
=
parseToken
(
fs
,
string
);
token
=
parseToken
(
fs
,
string
);
break
;
break
;
default:
default:
sign
=
1
;
sign
=
1
;
break
;
break
;
}
}
if
(
string
[
0
]
==
0
)
if
(
string
[
0
]
==
0
)
return
PARSE_ERROR
;
return
PARSE_ERROR
;
/* Convert the string to an integer. *end_ptr
/* Convert the string to an integer. *end_ptr
should end up pointing to null terminator of 'string'
should end up pointing to null terminator of 'string'
if the conversion was successful. */
if the conversion was successful. */
// printf("STRING: \"%s\"\n", string);
// printf("STRING: \"%s\"\n", string);
(
*
int_ptr
)
=
sign
*
strtol
(
string
,
&
end_ptr
,
10
);
(
*
int_ptr
)
=
sign
*
strtol
(
string
,
&
end_ptr
,
10
);
/* If end pointer is a return character or null terminator, all is well */
/* If end pointer is a return character or null terminator, all is well */
if
((
*
end_ptr
==
'\r'
)
||
(
*
end_ptr
==
'\0'
))
if
((
*
end_ptr
==
'\r'
)
||
(
*
end_ptr
==
'\0'
))
return
SUCCESS
;
return
SUCCESS
;
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Parses a floating point number */
/* Parses a floating point number */
int
string_to_float
(
char
*
string
,
double
*
float_ptr
)
{
int
string_to_float
(
char
*
string
,
double
*
float_ptr
)
{
...
@@ -1130,7 +1130,7 @@ int string_to_float(char * string, double * float_ptr) {
...
@@ -1130,7 +1130,7 @@ int string_to_float(char * string, double * float_ptr) {
return
PARSE_ERROR
;
return
PARSE_ERROR
;
error_ptr
=
malloc
(
sizeof
(
char
**
));
error_ptr
=
malloc
(
sizeof
(
char
**
));
(
*
float_ptr
)
=
strtod
(
string
,
error_ptr
);
(
*
float_ptr
)
=
strtod
(
string
,
error_ptr
);
/* These imply a succesful parse of the string */
/* These imply a succesful parse of the string */
...
@@ -1138,10 +1138,10 @@ int string_to_float(char * string, double * float_ptr) {
...
@@ -1138,10 +1138,10 @@ int string_to_float(char * string, double * float_ptr) {
free
(
error_ptr
);
free
(
error_ptr
);
return
SUCCESS
;
return
SUCCESS
;
}
}
(
*
float_ptr
)
=
0
;
(
*
float_ptr
)
=
0
;
free
(
error_ptr
);
free
(
error_ptr
);
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Parses a floating point number */
/* Parses a floating point number */
...
@@ -1151,7 +1151,7 @@ int parse_float(FILE * fs, double * float_ptr) {
...
@@ -1151,7 +1151,7 @@ int parse_float(FILE * fs, double * float_ptr) {
char
**
error_ptr
;
char
**
error_ptr
;
token_t
token
;
token_t
token
;
int
sign
;
int
sign
;
error_ptr
=
malloc
(
sizeof
(
char
**
));
error_ptr
=
malloc
(
sizeof
(
char
**
));
token
=
parseToken
(
fs
,
string
);
token
=
parseToken
(
fs
,
string
);
...
@@ -1159,14 +1159,14 @@ int parse_float(FILE * fs, double * float_ptr) {
...
@@ -1159,14 +1159,14 @@ int parse_float(FILE * fs, double * float_ptr) {
switch
(
token
)
{
switch
(
token
)
{
case
tMinus
:
case
tMinus
:
sign
=
-
1
;
sign
=
-
1
;
token
=
parseToken
(
fs
,
string
);
token
=
parseToken
(
fs
,
string
);
break
;
break
;
case
tPlus
:
case
tPlus
:
sign
=
1
;
sign
=
1
;
token
=
parseToken
(
fs
,
string
);
token
=
parseToken
(
fs
,
string
);
break
;
break
;
default:
default:
sign
=
1
;
sign
=
1
;
}
}
if
(
string
[
0
]
==
0
)
{
if
(
string
[
0
]
==
0
)
{
...
@@ -1181,68 +1181,68 @@ int parse_float(FILE * fs, double * float_ptr) {
...
@@ -1181,68 +1181,68 @@ int parse_float(FILE * fs, double * float_ptr) {
free
(
error_ptr
);
free
(
error_ptr
);
return
SUCCESS
;
return
SUCCESS
;
}
}
//if (PARSE_DEBUG) printf("parse_float: double conversion failed for string \"%s\"\n", string);
//if (PARSE_DEBUG) printf("parse_float: double conversion failed for string \"%s\"\n", string);
(
*
float_ptr
)
=
0
;
(
*
float_ptr
)
=
0
;
free
(
error_ptr
);
free
(
error_ptr
);
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Parses a per frame equation. That is, interprets a stream of data as a per frame equation */
/* Parses a per frame equation. That is, interprets a stream of data as a per frame equation */
per_frame_eqn_t
*
parse_per_frame_eqn
(
FILE
*
fs
,
int
index
,
struct
PRESET_T
*
preset
)
{
per_frame_eqn_t
*
parse_per_frame_eqn
(
FILE
*
fs
,
int
index
,
struct
PRESET_T
*
preset
)
{
char
string
[
MAX_TOKEN_SIZE
];
char
string
[
MAX_TOKEN_SIZE
];
param_t
*
param
;
param_t
*
param
;
per_frame_eqn_t
*
per_frame_eqn
;
per_frame_eqn_t
*
per_frame_eqn
;
gen_expr_t
*
gen_expr
;
gen_expr_t
*
gen_expr
;
if
(
parseToken
(
fs
,
string
)
!=
tEq
)
{
if
(
parseToken
(
fs
,
string
)
!=
tEq
)
{
//if (PARSE_DEBUG) printf("parse_per_frame_eqn: no equal sign after string \"%s\" (LINE %d)\n", string, line_count);
//if (PARSE_DEBUG) printf("parse_per_frame_eqn: no equal sign after string \"%s\" (LINE %d)\n", string, line_count);
return
NULL
;
return
NULL
;
}
}
/* Find the parameter associated with the string, create one if necessary */
/* Find the parameter associated with the string, create one if necessary */
if
((
param
=
find_param
(
string
,
preset
,
P_CREATE
))
==
NULL
)
{
if
((
param
=
find_param
(
string
,
preset
,
P_CREATE
))
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
/* Make sure parameter is writable */
/* Make sure parameter is writable */
if
(
param
->
flags
&
P_FLAG_READONLY
)
{
if
(
param
->
flags
&
P_FLAG_READONLY
)
{
//if (PARSE_DEBUG) printf("parse_per_frame_eqn: parameter %s is marked as read only (LINE %d)\n", param->name, line_count);
//if (PARSE_DEBUG) printf("parse_per_frame_eqn: parameter %s is marked as read only (LINE %d)\n", param->name, line_count);
return
NULL
;
return
NULL
;
}
}
/* Parse right side of equation as an expression */
/* Parse right side of equation as an expression */
if
((
gen_expr
=
parse_gen_expr
(
fs
,
NULL
,
preset
))
==
NULL
)
{
if
((
gen_expr
=
parse_gen_expr
(
fs
,
NULL
,
preset
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_per_frame_eqn: equation evaluated to null (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_per_frame_eqn: equation evaluated to null (LINE %d)\n", line_count);
return
NULL
;
return
NULL
;
}
}
//if (PARSE_DEBUG) printf("parse_per_frame_eqn: finished per frame equation evaluation (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_per_frame_eqn: finished per frame equation evaluation (LINE %d)\n", line_count);
/* Create a new per frame equation */
/* Create a new per frame equation */
if
((
per_frame_eqn
=
new_per_frame_eqn
(
index
,
param
,
gen_expr
))
==
NULL
)
{
if
((
per_frame_eqn
=
new_per_frame_eqn
(
index
,
param
,
gen_expr
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_per_frame_eqn: failed to create a new per frame eqn, out of memory?\n");
//if (PARSE_DEBUG) printf("parse_per_frame_eqn: failed to create a new per frame eqn, out of memory?\n");
free_gen_expr
(
gen_expr
);
free_gen_expr
(
gen_expr
);
return
NULL
;
return
NULL
;
}
}
//if (PARSE_DEBUG) printf("parse_per_frame_eqn: per_frame eqn parsed succesfully\n");
//if (PARSE_DEBUG) printf("parse_per_frame_eqn: per_frame eqn parsed succesfully\n");
return
per_frame_eqn
;
return
per_frame_eqn
;
}
}
/* Parses an 'implicit' per frame equation. That is, interprets a stream of data as a per frame equation without a prefix */
/* Parses an 'implicit' per frame equation. That is, interprets a stream of data as a per frame equation without a prefix */
per_frame_eqn_t
*
parse_implicit_per_frame_eqn
(
FILE
*
fs
,
char
*
param_string
,
int
index
,
struct
PRESET_T
*
preset
)
{
per_frame_eqn_t
*
parse_implicit_per_frame_eqn
(
FILE
*
fs
,
char
*
param_string
,
int
index
,
struct
PRESET_T
*
preset
)
{
param_t
*
param
;
param_t
*
param
;
per_frame_eqn_t
*
per_frame_eqn
;
per_frame_eqn_t
*
per_frame_eqn
;
gen_expr_t
*
gen_expr
;
gen_expr_t
*
gen_expr
;
if
(
fs
==
NULL
)
if
(
fs
==
NULL
)
return
NULL
;
return
NULL
;
if
(
param_string
==
NULL
)
if
(
param_string
==
NULL
)
...
@@ -1252,35 +1252,35 @@ per_frame_eqn_t * parse_implicit_per_frame_eqn(FILE * fs, char * param_string, i
...
@@ -1252,35 +1252,35 @@ per_frame_eqn_t * parse_implicit_per_frame_eqn(FILE * fs, char * param_string, i
//rintf("param string: %s\n", param_string);
//rintf("param string: %s\n", param_string);
/* Find the parameter associated with the string, create one if necessary */
/* Find the parameter associated with the string, create one if necessary */
if
((
param
=
find_param
(
param_string
,
preset
,
P_CREATE
))
==
NULL
)
{
if
((
param
=
find_param
(
param_string
,
preset
,
P_CREATE
))
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
//printf("parse_implicit_per_frame_eqn: param is %s\n", param->name);
//printf("parse_implicit_per_frame_eqn: param is %s\n", param->name);
/* Make sure parameter is writable */
/* Make sure parameter is writable */
if
(
param
->
flags
&
P_FLAG_READONLY
)
{
if
(
param
->
flags
&
P_FLAG_READONLY
)
{
//if (PARSE_DEBUG) printf("parse_implicit_per_frame_eqn: parameter %s is marked as read only (LINE %d)\n", param->name, line_count);
//if (PARSE_DEBUG) printf("parse_implicit_per_frame_eqn: parameter %s is marked as read only (LINE %d)\n", param->name, line_count);
return
NULL
;
return
NULL
;
}
}
/* Parse right side of equation as an expression */
/* Parse right side of equation as an expression */
if
((
gen_expr
=
parse_gen_expr
(
fs
,
NULL
,
preset
))
==
NULL
)
{
if
((
gen_expr
=
parse_gen_expr
(
fs
,
NULL
,
preset
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_implicit_per_frame_eqn: equation evaluated to null (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_implicit_per_frame_eqn: equation evaluated to null (LINE %d)\n", line_count);
return
NULL
;
return
NULL
;
}
}
//if (PARSE_DEBUG) printf("parse_implicit_per_frame_eqn: finished per frame equation evaluation (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_implicit_per_frame_eqn: finished per frame equation evaluation (LINE %d)\n", line_count);
/* Create a new per frame equation */
/* Create a new per frame equation */
if
((
per_frame_eqn
=
new_per_frame_eqn
(
index
,
param
,
gen_expr
))
==
NULL
)
{
if
((
per_frame_eqn
=
new_per_frame_eqn
(
index
,
param
,
gen_expr
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_implicit_per_frame_eqn: failed to create a new per frame eqn, out of memory?\n");
//if (PARSE_DEBUG) printf("parse_implicit_per_frame_eqn: failed to create a new per frame eqn, out of memory?\n");
free_gen_expr
(
gen_expr
);
free_gen_expr
(
gen_expr
);
return
NULL
;
return
NULL
;
}
}
//if (PARSE_DEBUG) printf("parse_implicit_per_frame_eqn: per_frame eqn parsed succesfully\n");
//if (PARSE_DEBUG) printf("parse_implicit_per_frame_eqn: per_frame eqn parsed succesfully\n");
return
per_frame_eqn
;
return
per_frame_eqn
;
}
}
...
@@ -1290,37 +1290,37 @@ init_cond_t * parse_init_cond(FILE * fs, char * name, struct PRESET_T * preset)
...
@@ -1290,37 +1290,37 @@ init_cond_t * parse_init_cond(FILE * fs, char * name, struct PRESET_T * preset)
param_t
*
param
;
param_t
*
param
;
value_t
init_val
;
value_t
init_val
;
init_cond_t
*
init_cond
;
init_cond_t
*
init_cond
;
if
(
name
==
NULL
)
if
(
name
==
NULL
)
return
NULL
;
return
NULL
;
if
(
preset
==
NULL
)
if
(
preset
==
NULL
)
return
NULL
;
return
NULL
;
/* Search for the paramater in the database, creating it if necessary */
/* Search for the paramater in the database, creating it if necessary */
if
((
param
=
find_param
(
name
,
preset
,
P_CREATE
))
==
NULL
)
{
if
((
param
=
find_param
(
name
,
preset
,
P_CREATE
))
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
//if (PARSE_DEBUG) printf("parse_init_cond: parameter = \"%s\" (LINE %d)\n", param->name, line_count);
//if (PARSE_DEBUG) printf("parse_init_cond: parameter = \"%s\" (LINE %d)\n", param->name, line_count);
if
(
param
->
flags
&
P_FLAG_READONLY
)
{
if
(
param
->
flags
&
P_FLAG_READONLY
)
{
//if (PARSE_DEBUG) printf("parse_init_cond: builtin parameter \"%s\" marked as read only!\n", param->name);
//if (PARSE_DEBUG) printf("parse_init_cond: builtin parameter \"%s\" marked as read only!\n", param->name);
return
NULL
;
return
NULL
;
}
}
/* At this point, a parameter has been created or was found
/* At this point, a parameter has been created or was found
in the database. */
in the database. */
//if (PARSE_DEBUG) printf("parse_init_cond: parsing initial condition value... (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_init_cond: parsing initial condition value... (LINE %d)\n", line_count);
/* integer value (boolean is an integer in C) */
/* integer value (boolean is an integer in C) */
if
((
param
->
type
==
P_TYPE_INT
)
||
(
param
->
type
==
P_TYPE_BOOL
))
{
if
((
param
->
type
==
P_TYPE_INT
)
||
(
param
->
type
==
P_TYPE_BOOL
))
{
if
((
parse_int
(
fs
,
(
int
*
)
&
init_val
.
int_val
))
==
PARSE_ERROR
)
{
if
((
parse_int
(
fs
,
(
int
*
)
&
init_val
.
int_val
))
==
PARSE_ERROR
)
{
//if (PARSE_DEBUG) printf("parse_init_cond: error parsing integer!\n");
//if (PARSE_DEBUG) printf("parse_init_cond: error parsing integer!\n");
return
NULL
;
return
NULL
;
}
}
}
}
/* double value */
/* double value */
else
if
(
param
->
type
==
P_TYPE_DOUBLE
)
{
else
if
(
param
->
type
==
P_TYPE_DOUBLE
)
{
if
((
parse_float
(
fs
,
(
double
*
)
&
init_val
.
double_val
))
==
PARSE_ERROR
)
{
if
((
parse_float
(
fs
,
(
double
*
)
&
init_val
.
double_val
))
==
PARSE_ERROR
)
{
...
@@ -1328,26 +1328,26 @@ init_cond_t * parse_init_cond(FILE * fs, char * name, struct PRESET_T * preset)
...
@@ -1328,26 +1328,26 @@ init_cond_t * parse_init_cond(FILE * fs, char * name, struct PRESET_T * preset)
return
NULL
;
return
NULL
;
}
}
}
}
/* Unknown value */
/* Unknown value */
else
{
else
{
//if (PARSE_DEBUG) printf("parse_init_cond: unknown parameter type!\n");
//if (PARSE_DEBUG) printf("parse_init_cond: unknown parameter type!\n");
return
NULL
;
return
NULL
;
}
}
/* Create new initial condition */
/* Create new initial condition */
if
((
init_cond
=
new_init_cond
(
param
,
init_val
))
==
NULL
)
{
if
((
init_cond
=
new_init_cond
(
param
,
init_val
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_init_cond: new_init_cond failed!\n");
//if (PARSE_DEBUG) printf("parse_init_cond: new_init_cond failed!\n");
return
NULL
;
return
NULL
;
}
}
/* Finished */
/* Finished */
return
init_cond
;
return
init_cond
;
}
}
/* Parses a per frame init equation, not sure if this works right now */
/* Parses a per frame init equation, not sure if this works right now */
init_cond_t
*
parse_per_frame_init_eqn
(
FILE
*
fs
,
struct
PRESET_T
*
preset
,
splaytree_t
*
database
)
{
init_cond_t
*
parse_per_frame_init_eqn
(
FILE
*
fs
,
struct
PRESET_T
*
preset
,
splaytree_t
*
database
)
{
char
name
[
MAX_TOKEN_SIZE
];
char
name
[
MAX_TOKEN_SIZE
];
param_t
*
param
=
NULL
;
param_t
*
param
=
NULL
;
value_t
init_val
;
value_t
init_val
;
...
@@ -1364,7 +1364,7 @@ init_cond_t * parse_per_frame_init_eqn(FILE * fs, struct PRESET_T * preset, spla
...
@@ -1364,7 +1364,7 @@ init_cond_t * parse_per_frame_init_eqn(FILE * fs, struct PRESET_T * preset, spla
if
((
token
=
parseToken
(
fs
,
name
))
!=
tEq
)
if
((
token
=
parseToken
(
fs
,
name
))
!=
tEq
)
return
NULL
;
return
NULL
;
/* If a database was specified,then use find_param_db instead */
/* If a database was specified,then use find_param_db instead */
if
((
database
!=
NULL
)
&&
((
param
=
find_param_db
(
name
,
database
,
TRUE
))
==
NULL
))
{
if
((
database
!=
NULL
)
&&
((
param
=
find_param_db
(
name
,
database
,
TRUE
))
==
NULL
))
{
...
@@ -1375,19 +1375,19 @@ init_cond_t * parse_per_frame_init_eqn(FILE * fs, struct PRESET_T * preset, spla
...
@@ -1375,19 +1375,19 @@ init_cond_t * parse_per_frame_init_eqn(FILE * fs, struct PRESET_T * preset, spla
if
((
param
==
NULL
)
&&
((
param
=
find_param
(
name
,
preset
,
P_CREATE
))
==
NULL
))
{
if
((
param
==
NULL
)
&&
((
param
=
find_param
(
name
,
preset
,
P_CREATE
))
==
NULL
))
{
return
NULL
;
return
NULL
;
}
}
//if (PARSE_DEBUG) printf("parse_per_frame_init_eqn: parameter = \"%s\" (LINE %d)\n", param->name, line_count);
//if (PARSE_DEBUG) printf("parse_per_frame_init_eqn: parameter = \"%s\" (LINE %d)\n", param->name, line_count);
if
(
param
->
flags
&
P_FLAG_READONLY
)
{
if
(
param
->
flags
&
P_FLAG_READONLY
)
{
//if (PARSE_DEBUG) printf("pars_per_frame_init_eqn: builtin parameter \"%s\" marked as read only!\n", param->name);
//if (PARSE_DEBUG) printf("pars_per_frame_init_eqn: builtin parameter \"%s\" marked as read only!\n", param->name);
return
NULL
;
return
NULL
;
}
}
/* At this point, a parameter has been created or was found
/* At this point, a parameter has been created or was found
in the database. */
in the database. */
//if (PARSE_DEBUG) printf("parse_per_frame_init_eqn: parsing right hand side of per frame init equation.. (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_per_frame_init_eqn: parsing right hand side of per frame init equation.. (LINE %d)\n", line_count);
if
((
gen_expr
=
parse_gen_expr
(
fs
,
NULL
,
preset
))
==
NULL
)
{
if
((
gen_expr
=
parse_gen_expr
(
fs
,
NULL
,
preset
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_per_frame_init_eqn: failed to parse general expresion!\n");
//if (PARSE_DEBUG) printf("parse_per_frame_init_eqn: failed to parse general expresion!\n");
return
NULL
;
return
NULL
;
...
@@ -1395,7 +1395,7 @@ init_cond_t * parse_per_frame_init_eqn(FILE * fs, struct PRESET_T * preset, spla
...
@@ -1395,7 +1395,7 @@ init_cond_t * parse_per_frame_init_eqn(FILE * fs, struct PRESET_T * preset, spla
/* Compute initial condition value */
/* Compute initial condition value */
val
=
eval_gen_expr
(
gen_expr
);
val
=
eval_gen_expr
(
gen_expr
);
/* Free the general expression now that we are done with it */
/* Free the general expression now that we are done with it */
free_gen_expr
(
gen_expr
);
free_gen_expr
(
gen_expr
);
...
@@ -1403,18 +1403,18 @@ init_cond_t * parse_per_frame_init_eqn(FILE * fs, struct PRESET_T * preset, spla
...
@@ -1403,18 +1403,18 @@ init_cond_t * parse_per_frame_init_eqn(FILE * fs, struct PRESET_T * preset, spla
if
((
param
->
type
==
P_TYPE_INT
)
||
(
param
->
type
==
P_TYPE_BOOL
))
{
if
((
param
->
type
==
P_TYPE_INT
)
||
(
param
->
type
==
P_TYPE_BOOL
))
{
init_val
.
int_val
=
(
int
)
val
;
init_val
.
int_val
=
(
int
)
val
;
}
}
/* double value */
/* double value */
else
if
(
param
->
type
==
P_TYPE_DOUBLE
)
{
else
if
(
param
->
type
==
P_TYPE_DOUBLE
)
{
init_val
.
double_val
=
val
;
init_val
.
double_val
=
val
;
}
}
/* Unknown value */
/* Unknown value */
else
{
else
{
//if (PARSE_DEBUG) printf("parse_per_frame_init_eqn: unknown parameter type!\n");
//if (PARSE_DEBUG) printf("parse_per_frame_init_eqn: unknown parameter type!\n");
return
NULL
;
return
NULL
;
}
}
/* Create new initial condition */
/* Create new initial condition */
if
((
init_cond
=
new_init_cond
(
param
,
init_val
))
==
NULL
)
{
if
((
init_cond
=
new_init_cond
(
param
,
init_val
))
==
NULL
)
{
...
@@ -1445,11 +1445,11 @@ int parse_wavecode(char * token, FILE * fs, preset_t * preset) {
...
@@ -1445,11 +1445,11 @@ int parse_wavecode(char * token, FILE * fs, preset_t * preset) {
return
FAILURE
;
return
FAILURE
;
/* token should be in the form wavecode_N_var, such as wavecode_1_samples */
/* token should be in the form wavecode_N_var, such as wavecode_1_samples */
/* Get id and variable name from token string */
/* Get id and variable name from token string */
if
(
parse_wavecode_prefix
(
token
,
&
id
,
&
var_string
)
<
0
)
if
(
parse_wavecode_prefix
(
token
,
&
id
,
&
var_string
)
<
0
)
return
PARSE_ERROR
;
return
PARSE_ERROR
;
//if (PARSE_DEBUG) printf("parse_wavecode: wavecode id = %d, parameter = \"%s\"\n", id, var_string);
//if (PARSE_DEBUG) printf("parse_wavecode: wavecode id = %d, parameter = \"%s\"\n", id, var_string);
/* Retrieve custom wave information from preset. The 3rd argument
/* Retrieve custom wave information from preset. The 3rd argument
...
@@ -1468,12 +1468,12 @@ int parse_wavecode(char * token, FILE * fs, preset_t * preset) {
...
@@ -1468,12 +1468,12 @@ int parse_wavecode(char * token, FILE * fs, preset_t * preset) {
/* integer value (boolean is an integer in C) */
/* integer value (boolean is an integer in C) */
if
((
param
->
type
==
P_TYPE_INT
)
||
(
param
->
type
==
P_TYPE_BOOL
))
{
if
((
param
->
type
==
P_TYPE_INT
)
||
(
param
->
type
==
P_TYPE_BOOL
))
{
if
((
parse_int
(
fs
,
(
int
*
)
&
init_val
.
int_val
))
==
PARSE_ERROR
)
{
if
((
parse_int
(
fs
,
(
int
*
)
&
init_val
.
int_val
))
==
PARSE_ERROR
)
{
//if (PARSE_DEBUG) printf("parse_wavecode: error parsing integer!\n");
//if (PARSE_DEBUG) printf("parse_wavecode: error parsing integer!\n");
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
}
}
/* double value */
/* double value */
else
if
(
param
->
type
==
P_TYPE_DOUBLE
)
{
else
if
(
param
->
type
==
P_TYPE_DOUBLE
)
{
if
((
parse_float
(
fs
,
(
double
*
)
&
init_val
.
double_val
))
==
PARSE_ERROR
)
{
if
((
parse_float
(
fs
,
(
double
*
)
&
init_val
.
double_val
))
==
PARSE_ERROR
)
{
...
@@ -1481,19 +1481,19 @@ int parse_wavecode(char * token, FILE * fs, preset_t * preset) {
...
@@ -1481,19 +1481,19 @@ int parse_wavecode(char * token, FILE * fs, preset_t * preset) {
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
}
}
/* Unknown value */
/* Unknown value */
else
{
else
{
//if (PARSE_DEBUG) printf("parse_wavecode: unknown parameter type!\n");
//if (PARSE_DEBUG) printf("parse_wavecode: unknown parameter type!\n");
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Create new initial condition */
/* Create new initial condition */
if
((
init_cond
=
new_init_cond
(
param
,
init_val
))
==
NULL
)
{
if
((
init_cond
=
new_init_cond
(
param
,
init_val
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_wavecode: new_init_cond failed!\n");
//if (PARSE_DEBUG) printf("parse_wavecode: new_init_cond failed!\n");
return
FAILURE
;
return
FAILURE
;
}
}
if
(
splay_insert
(
init_cond
,
param
->
name
,
custom_wave
->
init_cond_tree
)
<
0
)
{
if
(
splay_insert
(
init_cond
,
param
->
name
,
custom_wave
->
init_cond_tree
)
<
0
)
{
free_init_cond
(
init_cond
);
free_init_cond
(
init_cond
);
return
PARSE_ERROR
;
return
PARSE_ERROR
;
...
@@ -1521,11 +1521,11 @@ int parse_shapecode(char * token, FILE * fs, preset_t * preset) {
...
@@ -1521,11 +1521,11 @@ int parse_shapecode(char * token, FILE * fs, preset_t * preset) {
return
FAILURE
;
return
FAILURE
;
/* token should be in the form shapecode_N_var, such as shapecode_1_samples */
/* token should be in the form shapecode_N_var, such as shapecode_1_samples */
/* Get id and variable name from token string */
/* Get id and variable name from token string */
if
(
parse_shapecode_prefix
(
token
,
&
id
,
&
var_string
)
<
0
)
if
(
parse_shapecode_prefix
(
token
,
&
id
,
&
var_string
)
<
0
)
return
PARSE_ERROR
;
return
PARSE_ERROR
;
//if (PARSE_DEBUG) printf("parse_shapecode: shapecode id = %d, parameter = \"%s\"\n", id, var_string);
//if (PARSE_DEBUG) printf("parse_shapecode: shapecode id = %d, parameter = \"%s\"\n", id, var_string);
/* Retrieve custom shape information from preset. The 3rd argument
/* Retrieve custom shape information from preset. The 3rd argument
...
@@ -1545,12 +1545,12 @@ int parse_shapecode(char * token, FILE * fs, preset_t * preset) {
...
@@ -1545,12 +1545,12 @@ int parse_shapecode(char * token, FILE * fs, preset_t * preset) {
/* integer value (boolean is an integer in C) */
/* integer value (boolean is an integer in C) */
if
((
param
->
type
==
P_TYPE_INT
)
||
(
param
->
type
==
P_TYPE_BOOL
))
{
if
((
param
->
type
==
P_TYPE_INT
)
||
(
param
->
type
==
P_TYPE_BOOL
))
{
if
((
parse_int
(
fs
,
(
int
*
)
&
init_val
.
int_val
))
==
PARSE_ERROR
)
{
if
((
parse_int
(
fs
,
(
int
*
)
&
init_val
.
int_val
))
==
PARSE_ERROR
)
{
//if (PARSE_DEBUG) printf("parse_shapecode: error parsing integer!\n");
//if (PARSE_DEBUG) printf("parse_shapecode: error parsing integer!\n");
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
}
}
/* double value */
/* double value */
else
if
(
param
->
type
==
P_TYPE_DOUBLE
)
{
else
if
(
param
->
type
==
P_TYPE_DOUBLE
)
{
if
((
parse_float
(
fs
,
(
double
*
)
&
init_val
.
double_val
))
==
PARSE_ERROR
)
{
if
((
parse_float
(
fs
,
(
double
*
)
&
init_val
.
double_val
))
==
PARSE_ERROR
)
{
...
@@ -1558,13 +1558,13 @@ int parse_shapecode(char * token, FILE * fs, preset_t * preset) {
...
@@ -1558,13 +1558,13 @@ int parse_shapecode(char * token, FILE * fs, preset_t * preset) {
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
}
}
/* Unknown value */
/* Unknown value */
else
{
else
{
//if (PARSE_DEBUG) printf("parse_shapecode: unknown parameter type!\n");
//if (PARSE_DEBUG) printf("parse_shapecode: unknown parameter type!\n");
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Create new initial condition */
/* Create new initial condition */
if
((
init_cond
=
new_init_cond
(
param
,
init_val
))
==
NULL
)
{
if
((
init_cond
=
new_init_cond
(
param
,
init_val
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_shapecode: new_init_cond failed!\n");
//if (PARSE_DEBUG) printf("parse_shapecode: new_init_cond failed!\n");
...
@@ -1585,14 +1585,14 @@ int parse_shapecode(char * token, FILE * fs, preset_t * preset) {
...
@@ -1585,14 +1585,14 @@ int parse_shapecode(char * token, FILE * fs, preset_t * preset) {
int
parse_wavecode_prefix
(
char
*
token
,
int
*
id
,
char
**
var_string
)
{
int
parse_wavecode_prefix
(
char
*
token
,
int
*
id
,
char
**
var_string
)
{
int
len
,
i
,
j
;
int
len
,
i
,
j
;
if
(
token
==
NULL
)
if
(
token
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
*
var_string
==
NULL
)
if
(
*
var_string
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
id
==
NULL
)
if
(
id
==
NULL
)
return
FAILURE
;
return
FAILURE
;
len
=
strlen
(
token
);
len
=
strlen
(
token
);
/* Move pointer passed "wavecode_" prefix */
/* Move pointer passed "wavecode_" prefix */
...
@@ -1601,12 +1601,12 @@ int parse_wavecode_prefix(char * token, int * id, char ** var_string) {
...
@@ -1601,12 +1601,12 @@ int parse_wavecode_prefix(char * token, int * id, char ** var_string) {
i
=
WAVECODE_STRING_LENGTH
;
i
=
WAVECODE_STRING_LENGTH
;
j
=
0
;
j
=
0
;
(
*
id
)
=
0
;
(
*
id
)
=
0
;
/* This loop grabs the integer id for this custom wave */
/* This loop grabs the integer id for this custom wave */
while
((
i
<
len
)
&&
(
token
[
i
]
>=
48
)
&&
(
token
[
i
]
<=
57
))
{
while
((
i
<
len
)
&&
(
token
[
i
]
>=
48
)
&&
(
token
[
i
]
<=
57
))
{
if
(
j
>=
MAX_TOKEN_SIZE
)
if
(
j
>=
MAX_TOKEN_SIZE
)
return
FAILURE
;
return
FAILURE
;
(
*
id
)
=
10
*
(
*
id
)
+
(
token
[
i
]
-
48
);
(
*
id
)
=
10
*
(
*
id
)
+
(
token
[
i
]
-
48
);
j
++
;
j
++
;
i
++
;
i
++
;
...
@@ -1615,7 +1615,7 @@ int parse_wavecode_prefix(char * token, int * id, char ** var_string) {
...
@@ -1615,7 +1615,7 @@ int parse_wavecode_prefix(char * token, int * id, char ** var_string) {
if
(
i
>
(
len
-
2
))
if
(
i
>
(
len
-
2
))
return
FAILURE
;
return
FAILURE
;
*
var_string
=
token
+
i
+
1
;
*
var_string
=
token
+
i
+
1
;
return
SUCCESS
;
return
SUCCESS
;
...
@@ -1626,14 +1626,14 @@ int parse_wavecode_prefix(char * token, int * id, char ** var_string) {
...
@@ -1626,14 +1626,14 @@ int parse_wavecode_prefix(char * token, int * id, char ** var_string) {
int
parse_shapecode_prefix
(
char
*
token
,
int
*
id
,
char
**
var_string
)
{
int
parse_shapecode_prefix
(
char
*
token
,
int
*
id
,
char
**
var_string
)
{
int
len
,
i
,
j
;
int
len
,
i
,
j
;
if
(
token
==
NULL
)
if
(
token
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
*
var_string
==
NULL
)
if
(
*
var_string
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
id
==
NULL
)
if
(
id
==
NULL
)
return
FAILURE
;
return
FAILURE
;
len
=
strlen
(
token
);
len
=
strlen
(
token
);
/* Move pointer passed "shapecode_" prefix */
/* Move pointer passed "shapecode_" prefix */
...
@@ -1642,12 +1642,12 @@ int parse_shapecode_prefix(char * token, int * id, char ** var_string) {
...
@@ -1642,12 +1642,12 @@ int parse_shapecode_prefix(char * token, int * id, char ** var_string) {
i
=
SHAPECODE_STRING_LENGTH
;
i
=
SHAPECODE_STRING_LENGTH
;
j
=
0
;
j
=
0
;
(
*
id
)
=
0
;
(
*
id
)
=
0
;
/* This loop grabs the integer id for this custom shape */
/* This loop grabs the integer id for this custom shape */
while
((
i
<
len
)
&&
(
token
[
i
]
>=
48
)
&&
(
token
[
i
]
<=
57
))
{
while
((
i
<
len
)
&&
(
token
[
i
]
>=
48
)
&&
(
token
[
i
]
<=
57
))
{
if
(
j
>=
MAX_TOKEN_SIZE
)
if
(
j
>=
MAX_TOKEN_SIZE
)
return
FAILURE
;
return
FAILURE
;
(
*
id
)
=
10
*
(
*
id
)
+
(
token
[
i
]
-
48
);
(
*
id
)
=
10
*
(
*
id
)
+
(
token
[
i
]
-
48
);
j
++
;
j
++
;
i
++
;
i
++
;
...
@@ -1656,7 +1656,7 @@ int parse_shapecode_prefix(char * token, int * id, char ** var_string) {
...
@@ -1656,7 +1656,7 @@ int parse_shapecode_prefix(char * token, int * id, char ** var_string) {
if
(
i
>
(
len
-
2
))
if
(
i
>
(
len
-
2
))
return
FAILURE
;
return
FAILURE
;
*
var_string
=
token
+
i
+
1
;
*
var_string
=
token
+
i
+
1
;
return
SUCCESS
;
return
SUCCESS
;
...
@@ -1666,14 +1666,14 @@ int parse_shapecode_prefix(char * token, int * id, char ** var_string) {
...
@@ -1666,14 +1666,14 @@ int parse_shapecode_prefix(char * token, int * id, char ** var_string) {
int
parse_wave_prefix
(
char
*
token
,
int
*
id
,
char
**
eqn_string
)
{
int
parse_wave_prefix
(
char
*
token
,
int
*
id
,
char
**
eqn_string
)
{
int
len
,
i
,
j
;
int
len
,
i
,
j
;
if
(
token
==
NULL
)
if
(
token
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
eqn_string
==
NULL
)
if
(
eqn_string
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
id
==
NULL
)
if
(
id
==
NULL
)
return
FAILURE
;
return
FAILURE
;
len
=
strlen
(
token
);
len
=
strlen
(
token
);
if
(
len
<=
WAVE_STRING_LENGTH
)
if
(
len
<=
WAVE_STRING_LENGTH
)
...
@@ -1683,12 +1683,12 @@ int parse_wave_prefix(char * token, int * id, char ** eqn_string) {
...
@@ -1683,12 +1683,12 @@ int parse_wave_prefix(char * token, int * id, char ** eqn_string) {
i
=
WAVE_STRING_LENGTH
;
i
=
WAVE_STRING_LENGTH
;
j
=
0
;
j
=
0
;
(
*
id
)
=
0
;
(
*
id
)
=
0
;
/* This loop grabs the integer id for this custom wave */
/* This loop grabs the integer id for this custom wave */
while
((
i
<
len
)
&&
(
token
[
i
]
>=
48
)
&&
(
token
[
i
]
<=
57
))
{
while
((
i
<
len
)
&&
(
token
[
i
]
>=
48
)
&&
(
token
[
i
]
<=
57
))
{
if
(
j
>=
MAX_TOKEN_SIZE
)
if
(
j
>=
MAX_TOKEN_SIZE
)
return
FAILURE
;
return
FAILURE
;
(
*
id
)
=
10
*
(
*
id
)
+
(
token
[
i
]
-
48
);
(
*
id
)
=
10
*
(
*
id
)
+
(
token
[
i
]
-
48
);
j
++
;
j
++
;
i
++
;
i
++
;
...
@@ -1706,14 +1706,14 @@ int parse_wave_prefix(char * token, int * id, char ** eqn_string) {
...
@@ -1706,14 +1706,14 @@ int parse_wave_prefix(char * token, int * id, char ** eqn_string) {
int
parse_shape_prefix
(
char
*
token
,
int
*
id
,
char
**
eqn_string
)
{
int
parse_shape_prefix
(
char
*
token
,
int
*
id
,
char
**
eqn_string
)
{
int
len
,
i
,
j
;
int
len
,
i
,
j
;
if
(
token
==
NULL
)
if
(
token
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
eqn_string
==
NULL
)
if
(
eqn_string
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
id
==
NULL
)
if
(
id
==
NULL
)
return
FAILURE
;
return
FAILURE
;
len
=
strlen
(
token
);
len
=
strlen
(
token
);
if
(
len
<=
SHAPE_STRING_LENGTH
)
if
(
len
<=
SHAPE_STRING_LENGTH
)
...
@@ -1723,12 +1723,12 @@ int parse_shape_prefix(char * token, int * id, char ** eqn_string) {
...
@@ -1723,12 +1723,12 @@ int parse_shape_prefix(char * token, int * id, char ** eqn_string) {
i
=
SHAPE_STRING_LENGTH
;
i
=
SHAPE_STRING_LENGTH
;
j
=
0
;
j
=
0
;
(
*
id
)
=
0
;
(
*
id
)
=
0
;
/* This loop grabs the integer id for this custom wave */
/* This loop grabs the integer id for this custom wave */
while
((
i
<
len
)
&&
(
token
[
i
]
>=
48
)
&&
(
token
[
i
]
<=
57
))
{
while
((
i
<
len
)
&&
(
token
[
i
]
>=
48
)
&&
(
token
[
i
]
<=
57
))
{
if
(
j
>=
MAX_TOKEN_SIZE
)
if
(
j
>=
MAX_TOKEN_SIZE
)
return
FAILURE
;
return
FAILURE
;
(
*
id
)
=
10
*
(
*
id
)
+
(
token
[
i
]
-
48
);
(
*
id
)
=
10
*
(
*
id
)
+
(
token
[
i
]
-
48
);
j
++
;
j
++
;
i
++
;
i
++
;
...
@@ -1745,7 +1745,7 @@ int parse_shape_prefix(char * token, int * id, char ** eqn_string) {
...
@@ -1745,7 +1745,7 @@ int parse_shape_prefix(char * token, int * id, char ** eqn_string) {
/* Parses custom wave equations */
/* Parses custom wave equations */
int
parse_wave
(
char
*
token
,
FILE
*
fs
,
preset_t
*
preset
)
{
int
parse_wave
(
char
*
token
,
FILE
*
fs
,
preset_t
*
preset
)
{
int
id
;
int
id
;
char
*
eqn_type
;
char
*
eqn_type
;
char
string
[
MAX_TOKEN_SIZE
];
char
string
[
MAX_TOKEN_SIZE
];
...
@@ -1761,7 +1761,7 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
...
@@ -1761,7 +1761,7 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
return
FAILURE
;
return
FAILURE
;
if
(
preset
==
NULL
)
if
(
preset
==
NULL
)
return
FAILURE
;
return
FAILURE
;
/* Grab custom wave id and equation type (per frame or per point) from string token */
/* Grab custom wave id and equation type (per frame or per point) from string token */
if
(
parse_wave_prefix
(
token
,
&
id
,
&
eqn_type
)
<
0
)
{
if
(
parse_wave_prefix
(
token
,
&
id
,
&
eqn_type
)
<
0
)
{
//if (PARSE_DEBUG) printf("parse_wave: syntax error in custom wave prefix!\n");
//if (PARSE_DEBUG) printf("parse_wave: syntax error in custom wave prefix!\n");
...
@@ -1772,7 +1772,7 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
...
@@ -1772,7 +1772,7 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
return
FAILURE
;
return
FAILURE
;
/* per frame init equation case */
/* per frame init equation case */
if
(
!
strncmp
(
eqn_type
,
WAVE_INIT_STRING
,
WAVE_INIT_STRING_LENGTH
))
{
if
(
!
strncmp
(
eqn_type
,
WAVE_INIT_STRING
,
WAVE_INIT_STRING_LENGTH
))
{
//if (PARSE_DEBUG) printf("parse_wave (per frame init): [begin] (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_wave (per frame init): [begin] (LINE %d)\n", line_count);
...
@@ -1781,46 +1781,46 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
...
@@ -1781,46 +1781,46 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
if
((
init_cond
=
parse_per_frame_init_eqn
(
fs
,
preset
,
custom_wave
->
param_tree
))
==
NULL
)
{
if
((
init_cond
=
parse_per_frame_init_eqn
(
fs
,
preset
,
custom_wave
->
param_tree
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_wave (per frame init): equation parsing failed (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_wave (per frame init): equation parsing failed (LINE %d)\n", line_count);
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Insert the equation in the per frame equation tree */
/* Insert the equation in the per frame equation tree */
if
(
splay_insert
(
init_cond
,
init_cond
->
param
->
name
,
custom_wave
->
per_frame_init_eqn_tree
)
<
0
)
{
if
(
splay_insert
(
init_cond
,
init_cond
->
param
->
name
,
custom_wave
->
per_frame_init_eqn_tree
)
<
0
)
{
//if (PARSE_DEBUG) printf("parse_wave (per frame init): failed to add equation (ERROR)\n");
//if (PARSE_DEBUG) printf("parse_wave (per frame init): failed to add equation (ERROR)\n");
free_init_cond
(
init_cond
);
/* will free the gen expr too */
free_init_cond
(
init_cond
);
/* will free the gen expr too */
return
FAILURE
;
return
FAILURE
;
}
}
if
(
update_string_buffer
(
custom_wave
->
per_frame_init_eqn_string_buffer
,
if
(
update_string_buffer
(
custom_wave
->
per_frame_init_eqn_string_buffer
,
&
custom_wave
->
per_frame_init_eqn_string_index
)
<
0
)
&
custom_wave
->
per_frame_init_eqn_string_index
)
<
0
)
return
FAILURE
;
return
FAILURE
;
return
SUCCESS
;
return
SUCCESS
;
}
}
/* per frame equation case */
/* per frame equation case */
if
(
!
strncmp
(
eqn_type
,
PER_FRAME_STRING_NO_UNDERSCORE
,
PER_FRAME_STRING_NO_UNDERSCORE_LENGTH
))
{
if
(
!
strncmp
(
eqn_type
,
PER_FRAME_STRING_NO_UNDERSCORE
,
PER_FRAME_STRING_NO_UNDERSCORE_LENGTH
))
{
//if (PARSE_DEBUG) printf("parse_wave (per_frame): [start] (custom wave id = %d)\n", custom_wave->id);
//if (PARSE_DEBUG) printf("parse_wave (per_frame): [start] (custom wave id = %d)\n", custom_wave->id);
if
(
parseToken
(
fs
,
string
)
!=
tEq
)
{
if
(
parseToken
(
fs
,
string
)
!=
tEq
)
{
//if (PARSE_DEBUG) printf("parse_wave (per_frame): no equal sign after string \"%s\" (LINE %d)\n", string, line_count);
//if (PARSE_DEBUG) printf("parse_wave (per_frame): no equal sign after string \"%s\" (LINE %d)\n", string, line_count);
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Find the parameter associated with the string in the custom wave database */
/* Find the parameter associated with the string in the custom wave database */
if
((
param
=
find_param_db
(
string
,
custom_wave
->
param_tree
,
TRUE
))
==
NULL
)
{
if
((
param
=
find_param_db
(
string
,
custom_wave
->
param_tree
,
TRUE
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_wave (per_frame): parameter \"%s\" not found or cannot be malloc'ed!!\n", string);
//if (PARSE_DEBUG) printf("parse_wave (per_frame): parameter \"%s\" not found or cannot be malloc'ed!!\n", string);
return
FAILURE
;
return
FAILURE
;
}
}
/* Make sure parameter is writable */
/* Make sure parameter is writable */
if
(
param
->
flags
&
P_FLAG_READONLY
)
{
if
(
param
->
flags
&
P_FLAG_READONLY
)
{
//if (PARSE_DEBUG) printf("parse_wave (per_frame): parameter %s is marked as read only (LINE %d)\n", param->name, line_count);
//if (PARSE_DEBUG) printf("parse_wave (per_frame): parameter %s is marked as read only (LINE %d)\n", param->name, line_count);
return
FAILURE
;
return
FAILURE
;
}
}
/* Parse right side of equation as an expression */
/* Parse right side of equation as an expression */
current_wave
=
custom_wave
;
current_wave
=
custom_wave
;
...
@@ -1833,7 +1833,7 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
...
@@ -1833,7 +1833,7 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
current_wave
=
NULL
;
current_wave
=
NULL
;
//if (PARSE_DEBUG) printf("parse_wave (per_frame): [finished parsing equation] (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_wave (per_frame): [finished parsing equation] (LINE %d)\n", line_count);
/* Create a new per frame equation */
/* Create a new per frame equation */
if
((
per_frame_eqn
=
new_per_frame_eqn
(
custom_wave
->
per_frame_count
++
,
param
,
gen_expr
))
==
NULL
)
{
if
((
per_frame_eqn
=
new_per_frame_eqn
(
custom_wave
->
per_frame_count
++
,
param
,
gen_expr
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_wave (per_frame): failed to create a new per frame eqn, out of memory?\n");
//if (PARSE_DEBUG) printf("parse_wave (per_frame): failed to create a new per frame eqn, out of memory?\n");
...
@@ -1845,15 +1845,15 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
...
@@ -1845,15 +1845,15 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
free_per_frame_eqn
(
per_frame_eqn
);
free_per_frame_eqn
(
per_frame_eqn
);
return
FAILURE
;
return
FAILURE
;
}
}
//if (PARSE_DEBUG) printf("parse_wave (per_frame): equation %d associated with custom wave %d [success]\n",
//if (PARSE_DEBUG) printf("parse_wave (per_frame): equation %d associated with custom wave %d [success]\n",
//
per_frame_eqn->index, custom_wave->id);
//
per_frame_eqn->index, custom_wave->id);
/* Need to add stuff to string buffer so the editor can read the equations.
/* Need to add stuff to string buffer so the editor can read the equations.
Why not make a nice little helper function for this? - here it is: */
Why not make a nice little helper function for this? - here it is: */
if
(
update_string_buffer
(
custom_wave
->
per_frame_eqn_string_buffer
,
&
custom_wave
->
per_frame_eqn_string_index
)
<
0
)
if
(
update_string_buffer
(
custom_wave
->
per_frame_eqn_string_buffer
,
&
custom_wave
->
per_frame_eqn_string_index
)
<
0
)
return
FAILURE
;
return
FAILURE
;
...
@@ -1871,7 +1871,7 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
...
@@ -1871,7 +1871,7 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
//if (PARSE_DEBUG) printf("parse_wave (per_point): equal operator missing after per pixel operator! (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_wave (per_point): equal operator missing after per pixel operator! (LINE %d)\n", line_count);
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Parse right side of equation as an expression */
/* Parse right side of equation as an expression */
current_wave
=
custom_wave
;
current_wave
=
custom_wave
;
if
((
gen_expr
=
parse_gen_expr
(
fs
,
NULL
,
preset
))
==
NULL
)
{
if
((
gen_expr
=
parse_gen_expr
(
fs
,
NULL
,
preset
))
==
NULL
)
{
...
@@ -1886,7 +1886,7 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
...
@@ -1886,7 +1886,7 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
if
(
update_string_buffer
(
custom_wave
->
per_point_eqn_string_buffer
,
&
custom_wave
->
per_point_eqn_string_index
)
<
0
)
if
(
update_string_buffer
(
custom_wave
->
per_point_eqn_string_buffer
,
&
custom_wave
->
per_point_eqn_string_index
)
<
0
)
return
FAILURE
;
return
FAILURE
;
...
@@ -1903,7 +1903,7 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
...
@@ -1903,7 +1903,7 @@ int parse_wave(char * token, FILE * fs, preset_t * preset) {
/* Parses custom shape equations */
/* Parses custom shape equations */
int
parse_shape
(
char
*
token
,
FILE
*
fs
,
preset_t
*
preset
)
{
int
parse_shape
(
char
*
token
,
FILE
*
fs
,
preset_t
*
preset
)
{
int
id
;
int
id
;
char
*
eqn_type
;
char
*
eqn_type
;
char
string
[
MAX_TOKEN_SIZE
];
char
string
[
MAX_TOKEN_SIZE
];
...
@@ -1920,7 +1920,7 @@ int parse_shape(char * token, FILE * fs, preset_t * preset) {
...
@@ -1920,7 +1920,7 @@ int parse_shape(char * token, FILE * fs, preset_t * preset) {
return
FAILURE
;
return
FAILURE
;
if
(
preset
==
NULL
)
if
(
preset
==
NULL
)
return
FAILURE
;
return
FAILURE
;
/* Grab custom shape id and equation type (per frame or per point) from string token */
/* Grab custom shape id and equation type (per frame or per point) from string token */
if
(
parse_shape_prefix
(
token
,
&
id
,
&
eqn_type
)
<
0
)
{
if
(
parse_shape_prefix
(
token
,
&
id
,
&
eqn_type
)
<
0
)
{
//if (PARSE_DEBUG) printf("parse_shape: syntax error in custom shape prefix!\n");
//if (PARSE_DEBUG) printf("parse_shape: syntax error in custom shape prefix!\n");
...
@@ -1931,7 +1931,7 @@ int parse_shape(char * token, FILE * fs, preset_t * preset) {
...
@@ -1931,7 +1931,7 @@ int parse_shape(char * token, FILE * fs, preset_t * preset) {
return
FAILURE
;
return
FAILURE
;
/* per frame init equation case */
/* per frame init equation case */
if
(
!
strncmp
(
eqn_type
,
SHAPE_INIT_STRING
,
SHAPE_INIT_STRING_LENGTH
))
{
if
(
!
strncmp
(
eqn_type
,
SHAPE_INIT_STRING
,
SHAPE_INIT_STRING_LENGTH
))
{
//if (PARSE_DEBUG) printf("parse_shape (per frame init): [begin] (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_shape (per frame init): [begin] (LINE %d)\n", line_count);
...
@@ -1940,46 +1940,46 @@ int parse_shape(char * token, FILE * fs, preset_t * preset) {
...
@@ -1940,46 +1940,46 @@ int parse_shape(char * token, FILE * fs, preset_t * preset) {
if
((
init_cond
=
parse_per_frame_init_eqn
(
fs
,
preset
,
custom_shape
->
param_tree
))
==
NULL
)
{
if
((
init_cond
=
parse_per_frame_init_eqn
(
fs
,
preset
,
custom_shape
->
param_tree
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_shape (per frame init): equation parsing failed (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_shape (per frame init): equation parsing failed (LINE %d)\n", line_count);
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Insert the equation in the per frame equation tree */
/* Insert the equation in the per frame equation tree */
if
(
splay_insert
(
init_cond
,
init_cond
->
param
->
name
,
custom_shape
->
per_frame_init_eqn_tree
)
<
0
)
{
if
(
splay_insert
(
init_cond
,
init_cond
->
param
->
name
,
custom_shape
->
per_frame_init_eqn_tree
)
<
0
)
{
//if (PARSE_DEBUG) printf("parse_shape (per frame init): failed to add equation (ERROR)\n");
//if (PARSE_DEBUG) printf("parse_shape (per frame init): failed to add equation (ERROR)\n");
free_init_cond
(
init_cond
);
/* will free the gen expr too */
free_init_cond
(
init_cond
);
/* will free the gen expr too */
return
ERROR
;
return
ERROR
;
}
}
if
(
update_string_buffer
(
custom_shape
->
per_frame_init_eqn_string_buffer
,
if
(
update_string_buffer
(
custom_shape
->
per_frame_init_eqn_string_buffer
,
&
custom_shape
->
per_frame_init_eqn_string_index
)
<
0
)
&
custom_shape
->
per_frame_init_eqn_string_index
)
<
0
)
return
FAILURE
;
return
FAILURE
;
return
SUCCESS
;
return
SUCCESS
;
}
}
/* per frame equation case */
/* per frame equation case */
if
(
!
strncmp
(
eqn_type
,
PER_FRAME_STRING_NO_UNDERSCORE
,
PER_FRAME_STRING_NO_UNDERSCORE_LENGTH
))
{
if
(
!
strncmp
(
eqn_type
,
PER_FRAME_STRING_NO_UNDERSCORE
,
PER_FRAME_STRING_NO_UNDERSCORE_LENGTH
))
{
//if (PARSE_DEBUG) printf("parse_shape (per_frame): [start] (custom shape id = %d)\n", custom_shape->id);
//if (PARSE_DEBUG) printf("parse_shape (per_frame): [start] (custom shape id = %d)\n", custom_shape->id);
if
(
parseToken
(
fs
,
string
)
!=
tEq
)
{
if
(
parseToken
(
fs
,
string
)
!=
tEq
)
{
//if (PARSE_DEBUG) printf("parse_shape (per_frame): no equal sign after string \"%s\" (LINE %d)\n", string, line_count);
//if (PARSE_DEBUG) printf("parse_shape (per_frame): no equal sign after string \"%s\" (LINE %d)\n", string, line_count);
return
PARSE_ERROR
;
return
PARSE_ERROR
;
}
}
/* Find the parameter associated with the string in the custom shape database */
/* Find the parameter associated with the string in the custom shape database */
if
((
param
=
find_param_db
(
string
,
custom_shape
->
param_tree
,
TRUE
))
==
NULL
)
{
if
((
param
=
find_param_db
(
string
,
custom_shape
->
param_tree
,
TRUE
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_shape (per_frame): parameter \"%s\" not found or cannot be malloc'ed!!\n", string);
//if (PARSE_DEBUG) printf("parse_shape (per_frame): parameter \"%s\" not found or cannot be malloc'ed!!\n", string);
return
FAILURE
;
return
FAILURE
;
}
}
/* Make sure parameter is writable */
/* Make sure parameter is writable */
if
(
param
->
flags
&
P_FLAG_READONLY
)
{
if
(
param
->
flags
&
P_FLAG_READONLY
)
{
//if (PARSE_DEBUG) printf("parse_shape (per_frame): parameter %s is marked as read only (LINE %d)\n", param->name, line_count);
//if (PARSE_DEBUG) printf("parse_shape (per_frame): parameter %s is marked as read only (LINE %d)\n", param->name, line_count);
return
FAILURE
;
return
FAILURE
;
}
}
/* Parse right side of equation as an expression */
/* Parse right side of equation as an expression */
current_shape
=
custom_shape
;
current_shape
=
custom_shape
;
...
@@ -1992,7 +1992,7 @@ int parse_shape(char * token, FILE * fs, preset_t * preset) {
...
@@ -1992,7 +1992,7 @@ int parse_shape(char * token, FILE * fs, preset_t * preset) {
current_shape
=
NULL
;
current_shape
=
NULL
;
//if (PARSE_DEBUG) printf("parse_shape (per_frame): [finished parsing equation] (LINE %d)\n", line_count);
//if (PARSE_DEBUG) printf("parse_shape (per_frame): [finished parsing equation] (LINE %d)\n", line_count);
/* Create a new per frame equation */
/* Create a new per frame equation */
if
((
per_frame_eqn
=
new_per_frame_eqn
(
custom_shape
->
per_frame_count
++
,
param
,
gen_expr
))
==
NULL
)
{
if
((
per_frame_eqn
=
new_per_frame_eqn
(
custom_shape
->
per_frame_count
++
,
param
,
gen_expr
))
==
NULL
)
{
//if (PARSE_DEBUG) printf("parse_shape (per_frame): failed to create a new per frame eqn, out of memory?\n");
//if (PARSE_DEBUG) printf("parse_shape (per_frame): failed to create a new per frame eqn, out of memory?\n");
...
@@ -2004,14 +2004,14 @@ int parse_shape(char * token, FILE * fs, preset_t * preset) {
...
@@ -2004,14 +2004,14 @@ int parse_shape(char * token, FILE * fs, preset_t * preset) {
free_per_frame_eqn
(
per_frame_eqn
);
free_per_frame_eqn
(
per_frame_eqn
);
return
FAILURE
;
return
FAILURE
;
}
}
//if (PARSE_DEBUG) printf("parse_shape (per_frame): equation %d associated with custom shape %d [success]\n",
//if (PARSE_DEBUG) printf("parse_shape (per_frame): equation %d associated with custom shape %d [success]\n",
//
per_frame_eqn->index, custom_shape->id);
//
per_frame_eqn->index, custom_shape->id);
/* Need to add stuff to string buffer so the editor can read the equations.
/* Need to add stuff to string buffer so the editor can read the equations.
Why not make a nice little helper function for this? - here it is: */
Why not make a nice little helper function for this? - here it is: */
if
(
update_string_buffer
(
custom_shape
->
per_frame_eqn_string_buffer
,
&
custom_shape
->
per_frame_eqn_string_index
)
<
0
)
if
(
update_string_buffer
(
custom_shape
->
per_frame_eqn_string_buffer
,
&
custom_shape
->
per_frame_eqn_string_index
)
<
0
)
return
FAILURE
;
return
FAILURE
;
...
@@ -2035,7 +2035,7 @@ int update_string_buffer(char * buffer, int * index) {
...
@@ -2035,7 +2035,7 @@ int update_string_buffer(char * buffer, int * index) {
if
(
!
index
)
if
(
!
index
)
return
FAILURE
;
return
FAILURE
;
/* If the string line buffer used by the parser is already full then quit */
/* If the string line buffer used by the parser is already full then quit */
if
(
string_line_buffer_index
==
(
STRING_LINE_SIZE
-
1
))
if
(
string_line_buffer_index
==
(
STRING_LINE_SIZE
-
1
))
return
FAILURE
;
return
FAILURE
;
...
@@ -2055,20 +2055,20 @@ int update_string_buffer(char * buffer, int * index) {
...
@@ -2055,20 +2055,20 @@ int update_string_buffer(char * buffer, int * index) {
return
FAILURE
;
return
FAILURE
;
/* Add line to string buffer */
/* Add line to string buffer */
strncpy
(
buffer
+
(
*
index
),
strncpy
(
buffer
+
(
*
index
),
string_line_buffer
+
skip_size
,
string_length
);
string_line_buffer
+
skip_size
,
string_length
);
/* Buffer full, quit */
/* Buffer full, quit */
if
((
*
index
)
>
(
STRING_BUFFER_SIZE
-
1
))
{
if
((
*
index
)
>
(
STRING_BUFFER_SIZE
-
1
))
{
//if (PARSE_DEBUG) printf("update_string_buffer: string buffer full!\n");
//if (PARSE_DEBUG) printf("update_string_buffer: string buffer full!\n");
return
FAILURE
;
return
FAILURE
;
}
}
/* Otherwise, increment string index by the added string length */
/* Otherwise, increment string index by the added string length */
(
*
index
)
+=
string_length
;
(
*
index
)
+=
string_length
;
return
SUCCESS
;
return
SUCCESS
;
}
}
...
@@ -2079,14 +2079,14 @@ int update_string_buffer(char * buffer, int * index) {
...
@@ -2079,14 +2079,14 @@ int update_string_buffer(char * buffer, int * index) {
*/
*/
int
get_string_prefix_len
(
char
*
string
)
{
int
get_string_prefix_len
(
char
*
string
)
{
int
i
=
0
;
int
i
=
0
;
/* Null argument check */
/* Null argument check */
if
(
string
==
NULL
)
if
(
string
==
NULL
)
return
FAILURE
;
return
FAILURE
;
/* First find the equal sign */
/* First find the equal sign */
while
(
string
[
i
]
!=
'='
)
{
while
(
string
[
i
]
!=
'='
)
{
if
(
string
[
i
]
==
0
)
if
(
string
[
i
]
==
0
)
...
...
modules/visualization/galaktos/per_frame_eqn.c
View file @
d6008a8b
...
@@ -39,15 +39,15 @@ void eval_per_frame_eqn(per_frame_eqn_t * per_frame_eqn) {
...
@@ -39,15 +39,15 @@ void eval_per_frame_eqn(per_frame_eqn_t * per_frame_eqn) {
if
(
per_frame_eqn
==
NULL
)
if
(
per_frame_eqn
==
NULL
)
return
;
return
;
if
(
PER_FRAME_EQN_DEBUG
)
{
if
(
PER_FRAME_EQN_DEBUG
)
{
printf
(
"per_frame_%d=%s= "
,
per_frame_eqn
->
index
,
per_frame_eqn
->
param
->
name
);
printf
(
"per_frame_%d=%s= "
,
per_frame_eqn
->
index
,
per_frame_eqn
->
param
->
name
);
fflush
(
stdout
);
fflush
(
stdout
);
}
}
//*((double*)per_frame_eqn->param->engine_val) = eval_gen_expr(per_frame_eqn->gen_expr);
//*((double*)per_frame_eqn->param->engine_val) = eval_gen_expr(per_frame_eqn->gen_expr);
set_param
(
per_frame_eqn
->
param
,
eval_gen_expr
(
per_frame_eqn
->
gen_expr
));
set_param
(
per_frame_eqn
->
param
,
eval_gen_expr
(
per_frame_eqn
->
gen_expr
));
if
(
PER_FRAME_EQN_DEBUG
)
printf
(
" = %.4f
\n
"
,
*
((
double
*
)
per_frame_eqn
->
param
->
engine_val
));
if
(
PER_FRAME_EQN_DEBUG
)
printf
(
" = %.4f
\n
"
,
*
((
double
*
)
per_frame_eqn
->
param
->
engine_val
));
}
}
/*
/*
...
@@ -58,25 +58,25 @@ void eval_per_frame_init_eqn(per_frame_eqn_t * per_frame_eqn) {
...
@@ -58,25 +58,25 @@ void eval_per_frame_init_eqn(per_frame_eqn_t * per_frame_eqn) {
if (per_frame_eqn == NULL)
if (per_frame_eqn == NULL)
return;
return;
if (PER_FRAME_EQN_DEBUG) {
if (PER_FRAME_EQN_DEBUG) {
printf("per_frame_init: %s = ", per_frame_eqn->param->name);
printf("per_frame_init: %s = ", per_frame_eqn->param->name);
fflush(stdout);
fflush(stdout);
}
}
val = *((double*)per_frame_eqn->param->engine_val) = eval_gen_expr(per_frame_eqn->gen_expr);
val = *((double*)per_frame_eqn->param->engine_val) = eval_gen_expr(per_frame_eqn->gen_expr);
if (PER_FRAME_EQN_DEBUG) printf(" = %f\n", *((double*)per_frame_eqn->param->engine_val));
if (PER_FRAME_EQN_DEBUG) printf(" = %f\n", *((double*)per_frame_eqn->param->engine_val));
if (per_frame_eqn->param->flags & P_FLAG_QVAR) {
if (per_frame_eqn->param->flags & P_FLAG_QVAR) {
per_frame_eqn->param->init_val.double_val = val;
per_frame_eqn->param->init_val.double_val = val;
if ((init_cond = new_init_cond(per_frame_eqn->param)) == NULL)
if ((init_cond = new_init_cond(per_frame_eqn->param)) == NULL)
return;
return;
if ((list_append(init_cond_list, init_cond)) < 0) {
if ((list_append(init_cond_list, init_cond)) < 0) {
free_init_cond(init_cond);
free_init_cond(init_cond);
return;
return;
}
}
}
}
}
}
*/
*/
...
@@ -84,9 +84,9 @@ void eval_per_frame_init_eqn(per_frame_eqn_t * per_frame_eqn) {
...
@@ -84,9 +84,9 @@ void eval_per_frame_init_eqn(per_frame_eqn_t * per_frame_eqn) {
/* Frees perframe equation structure */
/* Frees perframe equation structure */
void
free_per_frame_eqn
(
per_frame_eqn_t
*
per_frame_eqn
)
{
void
free_per_frame_eqn
(
per_frame_eqn_t
*
per_frame_eqn
)
{
if
(
per_frame_eqn
==
NULL
)
if
(
per_frame_eqn
==
NULL
)
return
;
return
;
free_gen_expr
(
per_frame_eqn
->
gen_expr
);
free_gen_expr
(
per_frame_eqn
->
gen_expr
);
free
(
per_frame_eqn
);
free
(
per_frame_eqn
);
}
}
...
...
modules/visualization/galaktos/per_pixel_eqn.c
View file @
d6008a8b
...
@@ -56,40 +56,40 @@ inline void evalPerPixelEqn(per_pixel_eqn_t * per_pixel_eqn) {
...
@@ -56,40 +56,40 @@ inline void evalPerPixelEqn(per_pixel_eqn_t * per_pixel_eqn) {
gen_expr_t
*
eqn_ptr
=
NULL
;
gen_expr_t
*
eqn_ptr
=
NULL
;
int
x
,
y
;
int
x
,
y
;
eqn_ptr
=
per_pixel_eqn
->
gen_expr
;
eqn_ptr
=
per_pixel_eqn
->
gen_expr
;
if
(
per_pixel_eqn
->
param
->
matrix
==
NULL
)
{
if
(
per_pixel_eqn
->
param
->
matrix
==
NULL
)
{
if
(
PER_PIXEL_EQN_DEBUG
)
printf
(
"evalPerPixelEqn: [begin initializing matrix] (index = %d) (name = %s)
\n
"
,
if
(
PER_PIXEL_EQN_DEBUG
)
printf
(
"evalPerPixelEqn: [begin initializing matrix] (index = %d) (name = %s)
\n
"
,
per_pixel_eqn
->
index
,
per_pixel_eqn
->
param
->
name
);
per_pixel_eqn
->
index
,
per_pixel_eqn
->
param
->
name
);
param_matrix
=
per_pixel_eqn
->
param
->
matrix
=
(
double
**
)
malloc
(
gx
*
sizeof
(
double
*
));
param_matrix
=
per_pixel_eqn
->
param
->
matrix
=
(
double
**
)
malloc
(
gx
*
sizeof
(
double
*
));
for
(
x
=
0
;
x
<
gx
;
x
++
)
for
(
x
=
0
;
x
<
gx
;
x
++
)
param_matrix
[
x
]
=
(
double
*
)
malloc
(
gy
*
sizeof
(
double
));
param_matrix
[
x
]
=
(
double
*
)
malloc
(
gy
*
sizeof
(
double
));
for
(
x
=
0
;
x
<
gx
;
x
++
)
for
(
x
=
0
;
x
<
gx
;
x
++
)
for
(
y
=
0
;
y
<
gy
;
y
++
)
for
(
y
=
0
;
y
<
gy
;
y
++
)
param_matrix
[
x
][
y
]
=
0
.
0
;
param_matrix
[
x
][
y
]
=
0
.
0
;
if
(
per_pixel_eqn
->
param
->
name
==
NULL
)
if
(
per_pixel_eqn
->
param
->
name
==
NULL
)
printf
(
"null parameter?
\n
"
);
printf
(
"null parameter?
\n
"
);
// printf("PARAM MATRIX: \"%s\" initialized.\n", per_pixel_eqn->param->name);
// printf("PARAM MATRIX: \"%s\" initialized.\n", per_pixel_eqn->param->name);
}
}
else
else
param_matrix
=
(
double
**
)
per_pixel_eqn
->
param
->
matrix
;
param_matrix
=
(
double
**
)
per_pixel_eqn
->
param
->
matrix
;
if
(
eqn_ptr
==
NULL
)
if
(
eqn_ptr
==
NULL
)
printf
(
"something is seriously wrong...
\n
"
);
printf
(
"something is seriously wrong...
\n
"
);
for
(
mesh_i
=
0
;
mesh_i
<
gx
;
mesh_i
++
)
{
for
(
mesh_i
=
0
;
mesh_i
<
gx
;
mesh_i
++
)
{
for
(
mesh_j
=
0
;
mesh_j
<
gy
;
mesh_j
++
)
{
for
(
mesh_j
=
0
;
mesh_j
<
gy
;
mesh_j
++
)
{
param_matrix
[
mesh_i
][
mesh_j
]
=
eval_gen_expr
(
eqn_ptr
);
param_matrix
[
mesh_i
][
mesh_j
]
=
eval_gen_expr
(
eqn_ptr
);
}
}
}
}
/* Now that this parameter has been referenced with a per
/* Now that this parameter has been referenced with a per
pixel equation, we let the evaluator know by setting
pixel equation, we let the evaluator know by setting
this flag */
this flag */
per_pixel_eqn
->
param
->
matrix_flag
=
1
;
per_pixel_eqn
->
param
->
matrix_flag
=
1
;
}
}
inline
void
evalPerPixelEqns
()
{
inline
void
evalPerPixelEqns
()
{
...
@@ -112,25 +112,25 @@ int add_per_pixel_eqn(char * name, gen_expr_t * gen_expr, preset_t * preset) {
...
@@ -112,25 +112,25 @@ int add_per_pixel_eqn(char * name, gen_expr_t * gen_expr, preset_t * preset) {
/* Argument checks */
/* Argument checks */
if
(
preset
==
NULL
)
if
(
preset
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
gen_expr
==
NULL
)
if
(
gen_expr
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
name
==
NULL
)
if
(
name
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
PER_PIXEL_EQN_DEBUG
)
printf
(
"add_per_pixel_eqn: per pixel equation (name =
\"
%s
\"
)
\n
"
,
name
);
if
(
PER_PIXEL_EQN_DEBUG
)
printf
(
"add_per_pixel_eqn: per pixel equation (name =
\"
%s
\"
)
\n
"
,
name
);
if
(
!
strncmp
(
name
,
"dx"
,
strlen
(
"dx"
)))
if
(
!
strncmp
(
name
,
"dx"
,
strlen
(
"dx"
)))
preset
->
per_pixel_flag
[
DX_OP
]
=
TRUE
;
preset
->
per_pixel_flag
[
DX_OP
]
=
TRUE
;
else
if
(
!
strncmp
(
name
,
"dy"
,
strlen
(
"dy"
)))
else
if
(
!
strncmp
(
name
,
"dy"
,
strlen
(
"dy"
)))
preset
->
per_pixel_flag
[
DY_OP
]
=
TRUE
;
preset
->
per_pixel_flag
[
DY_OP
]
=
TRUE
;
else
if
(
!
strncmp
(
name
,
"cx"
,
strlen
(
"cx"
)))
else
if
(
!
strncmp
(
name
,
"cx"
,
strlen
(
"cx"
)))
preset
->
per_pixel_flag
[
CX_OP
]
=
TRUE
;
preset
->
per_pixel_flag
[
CX_OP
]
=
TRUE
;
else
if
(
!
strncmp
(
name
,
"cy"
,
strlen
(
"cy"
)))
else
if
(
!
strncmp
(
name
,
"cy"
,
strlen
(
"cy"
)))
preset
->
per_pixel_flag
[
CX_OP
]
=
TRUE
;
preset
->
per_pixel_flag
[
CX_OP
]
=
TRUE
;
else
if
(
!
strncmp
(
name
,
"zoom"
,
strlen
(
"zoom"
)))
else
if
(
!
strncmp
(
name
,
"zoom"
,
strlen
(
"zoom"
)))
preset
->
per_pixel_flag
[
ZOOM_OP
]
=
TRUE
;
preset
->
per_pixel_flag
[
ZOOM_OP
]
=
TRUE
;
else
if
(
!
strncmp
(
name
,
"zoomexp"
,
strlen
(
"zoomexp"
)))
else
if
(
!
strncmp
(
name
,
"zoomexp"
,
strlen
(
"zoomexp"
)))
preset
->
per_pixel_flag
[
ZOOMEXP_OP
]
=
TRUE
;
preset
->
per_pixel_flag
[
ZOOMEXP_OP
]
=
TRUE
;
else
if
(
!
strncmp
(
name
,
"rot"
,
strlen
(
"rot"
)))
else
if
(
!
strncmp
(
name
,
"rot"
,
strlen
(
"rot"
)))
preset
->
per_pixel_flag
[
ROT_OP
]
=
TRUE
;
preset
->
per_pixel_flag
[
ROT_OP
]
=
TRUE
;
...
@@ -146,14 +146,14 @@ int add_per_pixel_eqn(char * name, gen_expr_t * gen_expr, preset_t * preset) {
...
@@ -146,14 +146,14 @@ int add_per_pixel_eqn(char * name, gen_expr_t * gen_expr, preset_t * preset) {
if
(
PER_PIXEL_EQN_DEBUG
)
printf
(
"add_per_pixel_eqn: failed to allocate a new parameter!
\n
"
);
if
(
PER_PIXEL_EQN_DEBUG
)
printf
(
"add_per_pixel_eqn: failed to allocate a new parameter!
\n
"
);
return
FAILURE
;
return
FAILURE
;
}
}
/* Find most largest index in the splaytree */
/* Find most largest index in the splaytree */
// if ((per_pixel_eqn = splay_find_max(active_preset->per_pixel_eqn_tree)) == NULL)
// if ((per_pixel_eqn = splay_find_max(active_preset->per_pixel_eqn_tree)) == NULL)
// index = 0;
// index = 0;
// else
// else
index
=
splay_size
(
preset
->
per_pixel_eqn_tree
);
index
=
splay_size
(
preset
->
per_pixel_eqn_tree
);
/* Create the per pixel equation given the index, parameter, and general expression */
/* Create the per pixel equation given the index, parameter, and general expression */
if
((
per_pixel_eqn
=
new_per_pixel_eqn
(
index
,
param
,
gen_expr
))
==
NULL
)
{
if
((
per_pixel_eqn
=
new_per_pixel_eqn
(
index
,
param
,
gen_expr
))
==
NULL
)
{
if
(
PER_PIXEL_EQN_DEBUG
)
printf
(
"add_per_pixel_eqn: failed to create new per pixel equation!
\n
"
);
if
(
PER_PIXEL_EQN_DEBUG
)
printf
(
"add_per_pixel_eqn: failed to create new per pixel equation!
\n
"
);
...
@@ -161,56 +161,56 @@ int add_per_pixel_eqn(char * name, gen_expr_t * gen_expr, preset_t * preset) {
...
@@ -161,56 +161,56 @@ int add_per_pixel_eqn(char * name, gen_expr_t * gen_expr, preset_t * preset) {
}
}
if
(
PER_PIXEL_EQN_DEBUG
)
printf
(
"add_per_pixel_eqn: new equation (index = %d) (param =
\"
%s
\"
)
\n
"
,
if
(
PER_PIXEL_EQN_DEBUG
)
printf
(
"add_per_pixel_eqn: new equation (index = %d) (param =
\"
%s
\"
)
\n
"
,
per_pixel_eqn
->
index
,
per_pixel_eqn
->
param
->
name
);
per_pixel_eqn
->
index
,
per_pixel_eqn
->
param
->
name
);
/* Insert the per pixel equation into the preset per pixel database */
/* Insert the per pixel equation into the preset per pixel database */
if
(
splay_insert
(
per_pixel_eqn
,
&
per_pixel_eqn
->
index
,
preset
->
per_pixel_eqn_tree
)
<
0
)
{
if
(
splay_insert
(
per_pixel_eqn
,
&
per_pixel_eqn
->
index
,
preset
->
per_pixel_eqn_tree
)
<
0
)
{
free_per_pixel_eqn
(
per_pixel_eqn
);
free_per_pixel_eqn
(
per_pixel_eqn
);
printf
(
"failed to add per pixel eqn!
\n
"
);
printf
(
"failed to add per pixel eqn!
\n
"
);
return
FAILURE
;
return
FAILURE
;
}
}
/* Done */
/* Done */
return
SUCCESS
;
return
SUCCESS
;
}
}
per_pixel_eqn_t
*
new_per_pixel_eqn
(
int
index
,
param_t
*
param
,
gen_expr_t
*
gen_expr
)
{
per_pixel_eqn_t
*
new_per_pixel_eqn
(
int
index
,
param_t
*
param
,
gen_expr_t
*
gen_expr
)
{
per_pixel_eqn_t
*
per_pixel_eqn
;
per_pixel_eqn_t
*
per_pixel_eqn
;
if
(
index
<
0
)
if
(
index
<
0
)
return
NULL
;
return
NULL
;
if
(
param
==
NULL
)
if
(
param
==
NULL
)
return
NULL
;
return
NULL
;
if
(
gen_expr
==
NULL
)
if
(
gen_expr
==
NULL
)
return
NULL
;
return
NULL
;
if
((
per_pixel_eqn
=
(
per_pixel_eqn_t
*
)
malloc
(
sizeof
(
per_pixel_eqn_t
)))
==
NULL
)
if
((
per_pixel_eqn
=
(
per_pixel_eqn_t
*
)
malloc
(
sizeof
(
per_pixel_eqn_t
)))
==
NULL
)
return
NULL
;
return
NULL
;
per_pixel_eqn
->
index
=
index
;
per_pixel_eqn
->
index
=
index
;
per_pixel_eqn
->
param
=
param
;
per_pixel_eqn
->
param
=
param
;
per_pixel_eqn
->
gen_expr
=
gen_expr
;
per_pixel_eqn
->
gen_expr
=
gen_expr
;
return
per_pixel_eqn
;
return
per_pixel_eqn
;
}
}
void
free_per_pixel_eqn
(
per_pixel_eqn_t
*
per_pixel_eqn
)
{
void
free_per_pixel_eqn
(
per_pixel_eqn_t
*
per_pixel_eqn
)
{
if
(
per_pixel_eqn
==
NULL
)
if
(
per_pixel_eqn
==
NULL
)
return
;
return
;
free_gen_expr
(
per_pixel_eqn
->
gen_expr
);
free_gen_expr
(
per_pixel_eqn
->
gen_expr
);
free
(
per_pixel_eqn
);
free
(
per_pixel_eqn
);
return
;
return
;
}
}
inline
int
isPerPixelEqn
(
int
op
)
{
inline
int
isPerPixelEqn
(
int
op
)
{
return
active_preset
->
per_pixel_flag
[
op
];
return
active_preset
->
per_pixel_flag
[
op
];
}
}
...
...
modules/visualization/galaktos/per_pixel_eqn_types.h
View file @
d6008a8b
...
@@ -7,8 +7,8 @@
...
@@ -7,8 +7,8 @@
typedef
struct
PER_PIXEL_EQN_T
{
typedef
struct
PER_PIXEL_EQN_T
{
int
index
;
/* used for splay tree ordering. */
int
index
;
/* used for splay tree ordering. */
int
flags
;
/* primarily to specify if this variable is user-defined */
int
flags
;
/* primarily to specify if this variable is user-defined */
param_t
*
param
;
param_t
*
param
;
gen_expr_t
*
gen_expr
;
gen_expr_t
*
gen_expr
;
}
per_pixel_eqn_t
;
}
per_pixel_eqn_t
;
...
...
modules/visualization/galaktos/per_point_types.h
View file @
d6008a8b
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
typedef
struct
PER_POINT_EQN
{
typedef
struct
PER_POINT_EQN
{
custom_wave_t
*
custom_wave
;
custom_wave_t
*
custom_wave
;
}
per_point_eqn_t
;
}
per_point_eqn_t
;
...
...
modules/visualization/galaktos/preset.c
View file @
d6008a8b
...
@@ -83,7 +83,7 @@ int preset_name_buffer_size = 0;
...
@@ -83,7 +83,7 @@ int preset_name_buffer_size = 0;
splaytree_t
*
chrono_order_preset_name_tree
=
NULL
;
splaytree_t
*
chrono_order_preset_name_tree
=
NULL
;
int
get_preset_path
(
char
**
preset_path_ptr
,
char
*
filepath
,
char
*
filename
);
int
get_preset_path
(
char
**
preset_path_ptr
,
char
*
filepath
,
char
*
filename
);
preset_t
*
load_preset
(
char
*
pathname
);
preset_t
*
load_preset
(
char
*
pathname
);
int
is_valid_extension
(
char
*
name
);
int
is_valid_extension
(
char
*
name
);
int
load_preset_file
(
char
*
pathname
,
preset_t
*
preset
);
int
load_preset_file
(
char
*
pathname
,
preset_t
*
preset
);
int
close_preset
(
preset_t
*
preset
);
int
close_preset
(
preset_t
*
preset
);
...
@@ -105,90 +105,90 @@ void load_custom_shape_init(custom_shape_t * custom_shape);
...
@@ -105,90 +105,90 @@ void load_custom_shape_init(custom_shape_t * custom_shape);
/* loadPresetDir: opens the directory buffer
/* loadPresetDir: opens the directory buffer
denoted by 'dir' to load presets */
denoted by 'dir' to load presets */
int
loadPresetDir
(
char
*
dir
)
{
int
loadPresetDir
(
char
*
dir
)
{
struct
dirent
**
name_list
;
struct
dirent
**
name_list
;
char
*
preset_name
;
char
*
preset_name
;
int
i
,
j
,
dir_size
;
int
i
,
j
,
dir_size
;
if
(
dir
==
NULL
)
if
(
dir
==
NULL
)
return
ERROR
;
return
ERROR
;
if
(
chrono_order_preset_name_tree
!=
NULL
)
{
if
(
chrono_order_preset_name_tree
!=
NULL
)
{
if
(
PRESET_DEBUG
)
printf
(
"loadPresetDir: previous directory doesn't appear to be closed!
\n
"
);
if
(
PRESET_DEBUG
)
printf
(
"loadPresetDir: previous directory doesn't appear to be closed!
\n
"
);
/* Let this slide for now */
/* Let this slide for now */
}
}
/* Scan the entire directory, storing each entry in a dirent struct array that needs
/* Scan the entire directory, storing each entry in a dirent struct array that needs
to be freed later. For more information, consult scandir(3) in the man pages */
to be freed later. For more information, consult scandir(3) in the man pages */
if
((
dir_size
=
scandir
(
dir
,
&
name_list
,
0
,
alphasort
))
<
0
)
{
if
((
dir_size
=
scandir
(
dir
,
&
name_list
,
0
,
alphasort
))
<
0
)
{
if
(
PRESET_DEBUG
)
printf
(
"loadPresetDir: failed to open directory
\"
%s
\"\n
"
,
dir
);
if
(
PRESET_DEBUG
)
printf
(
"loadPresetDir: failed to open directory
\"
%s
\"\n
"
,
dir
);
return
ERROR
;
return
ERROR
;
}
}
chrono_order_preset_name_tree
=
create_splaytree
(
compare_int
,
copy_int
,
free_int
);
chrono_order_preset_name_tree
=
create_splaytree
(
compare_int
,
copy_int
,
free_int
);
/* Iterate through entire dirent name list, adding to the preset name list if it
/* Iterate through entire dirent name list, adding to the preset name list if it
is valid */
is valid */
for
(
i
=
0
;
((
i
<
dir_size
)
&&
(
i
<
MAX_PRESETS_IN_DIR
));
i
++
)
{
for
(
i
=
0
;
((
i
<
dir_size
)
&&
(
i
<
MAX_PRESETS_IN_DIR
));
i
++
)
{
/* Only perform the next set of operations if the preset name
/* Only perform the next set of operations if the preset name
contains a valid extension */
contains a valid extension */
if
(
is_valid_extension
(
name_list
[
i
]
->
d_name
))
{
if
(
is_valid_extension
(
name_list
[
i
]
->
d_name
))
{
/* Handle the out of memory case. My guess is xmms would
/* Handle the out of memory case. My guess is xmms would
crash before this program would, but whatever...*/
crash before this program would, but whatever...*/
if
((
preset_name
=
(
char
*
)
malloc
(
MAX_PATH_SIZE
))
==
NULL
)
{
if
((
preset_name
=
(
char
*
)
malloc
(
MAX_PATH_SIZE
))
==
NULL
)
{
if
(
PRESET_DEBUG
)
printf
(
"loadPresetDir: out of memory!
\n
"
);
if
(
PRESET_DEBUG
)
printf
(
"loadPresetDir: out of memory!
\n
"
);
/* Free the rest of the dirent name list */
/* Free the rest of the dirent name list */
for
(
j
=
i
;
j
<
dir_size
;
j
++
)
for
(
j
=
i
;
j
<
dir_size
;
j
++
)
free
(
name_list
[
j
]);
free
(
name_list
[
j
]);
destroy_splaytree
(
chrono_order_preset_name_tree
);
destroy_splaytree
(
chrono_order_preset_name_tree
);
return
OUTOFMEM_ERROR
;
return
OUTOFMEM_ERROR
;
}
}
/* Now create the full path */
/* Now create the full path */
if
(
get_preset_path
(
&
preset_name
,
dir
,
name_list
[
i
]
->
d_name
)
<
0
)
{
if
(
get_preset_path
(
&
preset_name
,
dir
,
name_list
[
i
]
->
d_name
)
<
0
)
{
if
(
PRESET_DEBUG
)
printf
(
"loadPresetDir: failed to generate full preset path name!
\n
"
);
if
(
PRESET_DEBUG
)
printf
(
"loadPresetDir: failed to generate full preset path name!
\n
"
);
/* Free the rest of the dirent name list */
/* Free the rest of the dirent name list */
for
(
j
=
i
;
j
<
dir_size
;
j
++
)
for
(
j
=
i
;
j
<
dir_size
;
j
++
)
free
(
name_list
[
j
]);
free
(
name_list
[
j
]);
destroy_splaytree
(
chrono_order_preset_name_tree
);
destroy_splaytree
(
chrono_order_preset_name_tree
);
return
OUTOFMEM_ERROR
;
return
OUTOFMEM_ERROR
;
}
}
/* Insert the character string into the splay tree, with the key being its sequence number */
/* Insert the character string into the splay tree, with the key being its sequence number */
splay_insert
(
preset_name
,
&
preset_name_buffer_size
,
chrono_order_preset_name_tree
);
splay_insert
(
preset_name
,
&
preset_name_buffer_size
,
chrono_order_preset_name_tree
);
preset_name_buffer_size
++
;
preset_name_buffer_size
++
;
}
}
/* Free the dirent struct */
/* Free the dirent struct */
free
(
name_list
[
i
]);
free
(
name_list
[
i
]);
}
}
free
(
name_list
);
free
(
name_list
);
/* No valid files in directory! */
/* No valid files in directory! */
if
(
chrono_order_preset_name_tree
->
root
==
NULL
)
{
if
(
chrono_order_preset_name_tree
->
root
==
NULL
)
{
if
(
PRESET_DEBUG
)
printf
(
"loadPresetDir: no valid files in directory
\"
%s
\"\n
"
,
dir
);
if
(
PRESET_DEBUG
)
printf
(
"loadPresetDir: no valid files in directory
\"
%s
\"\n
"
,
dir
);
destroy_splaytree
(
chrono_order_preset_name_tree
);
destroy_splaytree
(
chrono_order_preset_name_tree
);
chrono_order_preset_name_tree
=
NULL
;
chrono_order_preset_name_tree
=
NULL
;
return
FAILURE
;
return
FAILURE
;
}
}
/* Start the prefix index right before the first entry, so next preset
/* Start the prefix index right before the first entry, so next preset
starts at the top of the list */
starts at the top of the list */
preset_index
=
-
1
;
preset_index
=
-
1
;
/* Start the first preset */
/* Start the first preset */
switchPreset
(
ALPHA_NEXT
,
HARD_CUT
);
switchPreset
(
ALPHA_NEXT
,
HARD_CUT
);
return
SUCCESS
;
return
SUCCESS
;
}
}
...
@@ -197,63 +197,63 @@ int loadPresetDir(char * dir) {
...
@@ -197,63 +197,63 @@ int loadPresetDir(char * dir) {
int
closePresetDir
()
{
int
closePresetDir
()
{
/* No preset director appears to be loaded */
/* No preset director appears to be loaded */
if
(
chrono_order_preset_name_tree
==
NULL
)
if
(
chrono_order_preset_name_tree
==
NULL
)
return
SUCCESS
;
return
SUCCESS
;
if
(
PRESET_DEBUG
)
{
if
(
PRESET_DEBUG
)
{
printf
(
"closePresetDir: freeing directory buffer..."
);
printf
(
"closePresetDir: freeing directory buffer..."
);
fflush
(
stdout
);
fflush
(
stdout
);
}
}
/* Free each entry in the directory preset name tree */
/* Free each entry in the directory preset name tree */
splay_traverse
(
free_int
,
chrono_order_preset_name_tree
);
splay_traverse
(
free_int
,
chrono_order_preset_name_tree
);
/* Destroy the chronological order splay tree */
/* Destroy the chronological order splay tree */
destroy_splaytree
(
chrono_order_preset_name_tree
);
destroy_splaytree
(
chrono_order_preset_name_tree
);
chrono_order_preset_name_tree
=
NULL
;
chrono_order_preset_name_tree
=
NULL
;
preset_name_buffer_size
=
0
;
preset_name_buffer_size
=
0
;
if
(
PRESET_DEBUG
)
printf
(
"finished
\n
"
);
if
(
PRESET_DEBUG
)
printf
(
"finished
\n
"
);
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Converts a preset file name to a full path */
/* Converts a preset file name to a full path */
int
get_preset_path
(
char
**
preset_path_ptr
,
char
*
filepath
,
char
*
filename
)
{
int
get_preset_path
(
char
**
preset_path_ptr
,
char
*
filepath
,
char
*
filename
)
{
char
*
preset_path
;
char
*
preset_path
;
/* An insanely paranoid sequence of argument checks */
/* An insanely paranoid sequence of argument checks */
if
(
preset_path_ptr
==
NULL
)
if
(
preset_path_ptr
==
NULL
)
return
ERROR
;
return
ERROR
;
if
(
*
preset_path_ptr
==
NULL
)
if
(
*
preset_path_ptr
==
NULL
)
return
ERROR
;
return
ERROR
;
if
(
filename
==
NULL
)
if
(
filename
==
NULL
)
return
ERROR
;
return
ERROR
;
if
(
filepath
==
NULL
)
if
(
filepath
==
NULL
)
return
ERROR
;
return
ERROR
;
/* Mostly here for looks */
/* Mostly here for looks */
preset_path
=
*
preset_path_ptr
;
preset_path
=
*
preset_path_ptr
;
/* Clear the name space first */
/* Clear the name space first */
memset
(
preset_path
,
0
,
MAX_PATH_SIZE
);
memset
(
preset_path
,
0
,
MAX_PATH_SIZE
);
/* Now create the string "PATH/FILENAME", where path is either absolute or relative location
/* Now create the string "PATH/FILENAME", where path is either absolute or relative location
of the .milk file, and filename is the name of the preset file itself */
of the .milk file, and filename is the name of the preset file itself */
strcat
(
strcat
(
strcat
(
strcat
(
strncpy
(
strncpy
(
preset_path
,
preset_path
,
filepath
,
filepath
,
MAX_PATH_SIZE
-
1
),
MAX_PATH_SIZE
-
1
),
"/"
),
"/"
),
filename
);
filename
);
return
SUCCESS
;
return
SUCCESS
;
}
}
/* switchPreset: loads the next preset from the directory stream.
/* switchPreset: loads the next preset from the directory stream.
loadPresetDir() must be called first. This is a
loadPresetDir() must be called first. This is a
...
@@ -262,52 +262,52 @@ int get_preset_path(char ** preset_path_ptr, char * filepath, char * filename) {
...
@@ -262,52 +262,52 @@ int get_preset_path(char ** preset_path_ptr, char * filepath, char * filename) {
int
switchPreset
(
switch_mode_t
switch_mode
,
int
cut_type
)
{
int
switchPreset
(
switch_mode_t
switch_mode
,
int
cut_type
)
{
preset_t
*
new_preset
;
preset_t
*
new_preset
;
int
switch_index
;
int
switch_index
;
/* Make sure a preset directory list is in the buffer */
/* Make sure a preset directory list is in the buffer */
if
(
chrono_order_preset_name_tree
==
NULL
)
{
if
(
chrono_order_preset_name_tree
==
NULL
)
{
if
(
PRESET_DEBUG
)
printf
(
"switchPreset: it helps if you open a directory first with a loadPresetDir() call
\n
"
);
if
(
PRESET_DEBUG
)
printf
(
"switchPreset: it helps if you open a directory first with a loadPresetDir() call
\n
"
);
return
ERROR
;
return
ERROR
;
}
}
switch
(
switch_mode
)
{
switch
(
switch_mode
)
{
case
ALPHA_NEXT
:
case
ALPHA_NEXT
:
/* An index variable that iterates through the directory
/* An index variable that iterates through the directory
buffer, doing wrap around when it reaches the end of
buffer, doing wrap around when it reaches the end of
the buffer */
the buffer */
if
(
preset_index
==
(
preset_name_buffer_size
-
1
))
if
(
preset_index
==
(
preset_name_buffer_size
-
1
))
switch_index
=
preset_index
=
0
;
switch_index
=
preset_index
=
0
;
else
else
switch_index
=
++
preset_index
;
switch_index
=
++
preset_index
;
break
;
break
;
case
ALPHA_PREVIOUS
:
case
ALPHA_PREVIOUS
:
if
(
preset_index
==
0
)
if
(
preset_index
==
0
)
switch_index
=
preset_index
=
preset_name_buffer_size
-
1
;
switch_index
=
preset_index
=
preset_name_buffer_size
-
1
;
else
else
switch_index
=
--
preset_index
;
switch_index
=
--
preset_index
;
break
;
break
;
case
RANDOM_NEXT
:
case
RANDOM_NEXT
:
switch_index
=
(
int
)
(
preset_name_buffer_size
*
(
rand
()
/
(
RAND_MAX
+
1
.
0
)));
switch_index
=
(
int
)
(
preset_name_buffer_size
*
(
rand
()
/
(
RAND_MAX
+
1
.
0
)));
break
;
break
;
case
RESTART_ACTIVE
:
case
RESTART_ACTIVE
:
switch_index
=
preset_index
;
switch_index
=
preset_index
;
break
;
break
;
default:
default:
return
FAILURE
;
return
FAILURE
;
}
}
/* Finally, load the preset using its actual path */
/* Finally, load the preset using its actual path */
if
((
new_preset
=
load_preset
((
char
*
)
splay_find
(
&
switch_index
,
chrono_order_preset_name_tree
)))
==
NULL
)
{
if
((
new_preset
=
load_preset
((
char
*
)
splay_find
(
&
switch_index
,
chrono_order_preset_name_tree
)))
==
NULL
)
{
if
(
PRESET_DEBUG
)
printf
(
"switchPreset: failed to load preset
\n
"
);
if
(
PRESET_DEBUG
)
printf
(
"switchPreset: failed to load preset
\n
"
);
return
ERROR
;
return
ERROR
;
}
}
/* Closes a preset currently loaded, if any */
/* Closes a preset currently loaded, if any */
...
@@ -345,13 +345,13 @@ int loadPresetByFile(char * filename) {
...
@@ -345,13 +345,13 @@ int loadPresetByFile(char * filename) {
/* Finally, load the preset using its actual path */
/* Finally, load the preset using its actual path */
if
((
new_preset
=
load_preset
(
filename
))
==
NULL
)
{
if
((
new_preset
=
load_preset
(
filename
))
==
NULL
)
{
if
(
PRESET_DEBUG
)
printf
(
"loadPresetByFile: failed to load preset!
\n
"
);
if
(
PRESET_DEBUG
)
printf
(
"loadPresetByFile: failed to load preset!
\n
"
);
return
ERROR
;
return
ERROR
;
}
}
/* Closes a preset currently loaded, if any */
/* Closes a preset currently loaded, if any */
if
((
active_preset
!=
NULL
)
&&
(
active_preset
!=
idle_preset
))
if
((
active_preset
!=
NULL
)
&&
(
active_preset
!=
idle_preset
))
close_preset
(
active_preset
);
close_preset
(
active_preset
);
/* Sets active preset global pointer */
/* Sets active preset global pointer */
active_preset
=
new_preset
;
active_preset
=
new_preset
;
...
@@ -368,7 +368,7 @@ int loadPresetByFile(char * filename) {
...
@@ -368,7 +368,7 @@ int loadPresetByFile(char * filename) {
/* Add any missing initial conditions */
/* Add any missing initial conditions */
load_init_conditions
();
load_init_conditions
();
/* Need to do this once for menu */
/* Need to do this once for menu */
evalInitConditions
();
evalInitConditions
();
// evalPerFrameInitEquations();
// evalPerFrameInitEquations();
...
@@ -385,7 +385,7 @@ int init_idle_preset() {
...
@@ -385,7 +385,7 @@ int init_idle_preset() {
if
((
preset
=
(
preset_t
*
)
malloc
(
sizeof
(
preset_t
)))
==
NULL
)
if
((
preset
=
(
preset_t
*
)
malloc
(
sizeof
(
preset_t
)))
==
NULL
)
return
FAILURE
;
return
FAILURE
;
strncpy
(
preset
->
name
,
"idlepreset"
,
strlen
(
"idlepreset"
));
strncpy
(
preset
->
name
,
"idlepreset"
,
strlen
(
"idlepreset"
));
/* Initialize equation trees */
/* Initialize equation trees */
...
@@ -397,29 +397,29 @@ int init_idle_preset() {
...
@@ -397,29 +397,29 @@ int init_idle_preset() {
preset
->
custom_wave_tree
=
create_splaytree
(
compare_int
,
copy_int
,
free_int
);
preset
->
custom_wave_tree
=
create_splaytree
(
compare_int
,
copy_int
,
free_int
);
preset
->
custom_shape_tree
=
create_splaytree
(
compare_int
,
copy_int
,
free_int
);
preset
->
custom_shape_tree
=
create_splaytree
(
compare_int
,
copy_int
,
free_int
);
/* Set file path to dummy name */
/* Set file path to dummy name */
strncpy
(
preset
->
file_path
,
"IDLE PRESET"
,
MAX_PATH_SIZE
-
1
);
strncpy
(
preset
->
file_path
,
"IDLE PRESET"
,
MAX_PATH_SIZE
-
1
);
/* Set initial index values */
/* Set initial index values */
preset
->
per_pixel_eqn_string_index
=
0
;
preset
->
per_pixel_eqn_string_index
=
0
;
preset
->
per_frame_eqn_string_index
=
0
;
preset
->
per_frame_eqn_string_index
=
0
;
preset
->
per_frame_init_eqn_string_index
=
0
;
preset
->
per_frame_init_eqn_string_index
=
0
;
memset
(
preset
->
per_pixel_flag
,
0
,
sizeof
(
int
)
*
NUM_OPS
);
memset
(
preset
->
per_pixel_flag
,
0
,
sizeof
(
int
)
*
NUM_OPS
);
/* Clear string buffers */
/* Clear string buffers */
memset
(
preset
->
per_pixel_eqn_string_buffer
,
0
,
STRING_BUFFER_SIZE
);
memset
(
preset
->
per_pixel_eqn_string_buffer
,
0
,
STRING_BUFFER_SIZE
);
memset
(
preset
->
per_frame_eqn_string_buffer
,
0
,
STRING_BUFFER_SIZE
);
memset
(
preset
->
per_frame_eqn_string_buffer
,
0
,
STRING_BUFFER_SIZE
);
memset
(
preset
->
per_frame_init_eqn_string_buffer
,
0
,
STRING_BUFFER_SIZE
);
memset
(
preset
->
per_frame_init_eqn_string_buffer
,
0
,
STRING_BUFFER_SIZE
);
idle_preset
=
preset
;
idle_preset
=
preset
;
return
SUCCESS
;
return
SUCCESS
;
}
}
int
destroy_idle_preset
()
{
int
destroy_idle_preset
()
{
return
close_preset
(
idle_preset
);
return
close_preset
(
idle_preset
);
}
}
/* initPresetLoader: initializes the preset
/* initPresetLoader: initializes the preset
...
@@ -432,7 +432,7 @@ int initPresetLoader() {
...
@@ -432,7 +432,7 @@ int initPresetLoader() {
/* Initializes the builtin function database */
/* Initializes the builtin function database */
init_builtin_func_db
();
init_builtin_func_db
();
/* Initializes all infix operators */
/* Initializes all infix operators */
init_infix_ops
();
init_infix_ops
();
...
@@ -485,17 +485,17 @@ void switchToIdlePreset() {
...
@@ -485,17 +485,17 @@ void switchToIdlePreset() {
}
}
/* destroyPresetLoader: closes the preset
/* destroyPresetLoader: closes the preset
loading library. This should be done when
loading library. This should be done when
projectM does cleanup */
projectM does cleanup */
int
destroyPresetLoader
()
{
int
destroyPresetLoader
()
{
if
((
active_preset
!=
NULL
)
&&
(
active_preset
!=
idle_preset
))
{
if
((
active_preset
!=
NULL
)
&&
(
active_preset
!=
idle_preset
))
{
close_preset
(
active_preset
);
close_preset
(
active_preset
);
}
}
active_preset
=
NULL
;
active_preset
=
NULL
;
destroy_idle_preset
();
destroy_idle_preset
();
destroy_builtin_param_db
();
destroy_builtin_param_db
();
destroy_builtin_func_db
();
destroy_builtin_func_db
();
...
@@ -507,19 +507,19 @@ int destroyPresetLoader() {
...
@@ -507,19 +507,19 @@ int destroyPresetLoader() {
/* load_preset_file: private function that loads a specific preset denoted
/* load_preset_file: private function that loads a specific preset denoted
by the given pathname */
by the given pathname */
int
load_preset_file
(
char
*
pathname
,
preset_t
*
preset
)
{
int
load_preset_file
(
char
*
pathname
,
preset_t
*
preset
)
{
FILE
*
fs
;
FILE
*
fs
;
int
retval
;
int
retval
;
if
(
pathname
==
NULL
)
if
(
pathname
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
preset
==
NULL
)
if
(
preset
==
NULL
)
return
FAILURE
;
return
FAILURE
;
/* Open the file corresponding to pathname */
/* Open the file corresponding to pathname */
if
((
fs
=
utf8_fopen
(
pathname
,
"r"
))
==
0
)
{
if
((
fs
=
utf8_fopen
(
pathname
,
"r"
))
==
0
)
{
if
(
PRESET_DEBUG
)
printf
(
"load_preset_file: loading of file %s failed!
\n
"
,
pathname
);
if
(
PRESET_DEBUG
)
printf
(
"load_preset_file: loading of file %s failed!
\n
"
,
pathname
);
return
ERROR
;
return
ERROR
;
}
}
if
(
PRESET_DEBUG
)
printf
(
"load_preset_file: file stream
\"
%s
\"
opened successfully
\n
"
,
pathname
);
if
(
PRESET_DEBUG
)
printf
(
"load_preset_file: file stream
\"
%s
\"
opened successfully
\n
"
,
pathname
);
...
@@ -530,14 +530,14 @@ int load_preset_file(char * pathname, preset_t * preset) {
...
@@ -530,14 +530,14 @@ int load_preset_file(char * pathname, preset_t * preset) {
fclose
(
fs
);
fclose
(
fs
);
return
FAILURE
;
return
FAILURE
;
}
}
/* Parse the preset name and a left bracket */
/* Parse the preset name and a left bracket */
if
(
parse_preset_name
(
fs
,
preset
->
name
)
<
0
)
{
if
(
parse_preset_name
(
fs
,
preset
->
name
)
<
0
)
{
if
(
PRESET_DEBUG
)
printf
(
"load_preset_file: loading of preset name in file
\"
%s
\"
failed
\n
"
,
pathname
);
if
(
PRESET_DEBUG
)
printf
(
"load_preset_file: loading of preset name in file
\"
%s
\"
failed
\n
"
,
pathname
);
fclose
(
fs
);
fclose
(
fs
);
return
ERROR
;
return
ERROR
;
}
}
if
(
PRESET_DEBUG
)
printf
(
"load_preset_file: preset
\"
%s
\"
parsed
\n
"
,
preset
->
name
);
if
(
PRESET_DEBUG
)
printf
(
"load_preset_file: preset
\"
%s
\"
parsed
\n
"
,
preset
->
name
);
/* Parse each line until end of file */
/* Parse each line until end of file */
...
@@ -547,18 +547,18 @@ int load_preset_file(char * pathname, preset_t * preset) {
...
@@ -547,18 +547,18 @@ int load_preset_file(char * pathname, preset_t * preset) {
if
(
PRESET_DEBUG
>
1
)
printf
(
"load_preset_file: parse error in file
\"
%s
\"\n
"
,
pathname
);
if
(
PRESET_DEBUG
>
1
)
printf
(
"load_preset_file: parse error in file
\"
%s
\"\n
"
,
pathname
);
}
}
}
}
if
(
PRESET_DEBUG
)
printf
(
"load_preset_file: finished line parsing successfully
\n
"
);
if
(
PRESET_DEBUG
)
printf
(
"load_preset_file: finished line parsing successfully
\n
"
);
/* Now the preset has been loaded.
/* Now the preset has been loaded.
Evaluation calls can be made at appropiate
Evaluation calls can be made at appropiate
times in the frame loop */
times in the frame loop */
fclose
(
fs
);
fclose
(
fs
);
if
(
PRESET_DEBUG
)
printf
(
"load_preset_file: file
\"
%s
\"
closed, preset ready
\n
"
,
pathname
);
if
(
PRESET_DEBUG
)
printf
(
"load_preset_file: file
\"
%s
\"
closed, preset ready
\n
"
,
pathname
);
return
SUCCESS
;
return
SUCCESS
;
}
}
void
evalInitConditions
()
{
void
evalInitConditions
()
{
...
@@ -573,29 +573,29 @@ void evalPerFrameEquations() {
...
@@ -573,29 +573,29 @@ void evalPerFrameEquations() {
void
evalPerFrameInitEquations
()
{
void
evalPerFrameInitEquations
()
{
//printf("evalPerFrameInitEquations: per frame init unimplemented!\n");
//printf("evalPerFrameInitEquations: per frame init unimplemented!\n");
// splay_traverse(eval_per_frame_eqn, active_preset->per_frame_init_eqn_tree);
// splay_traverse(eval_per_frame_eqn, active_preset->per_frame_init_eqn_tree);
}
}
/* Returns nonzero if string 'name' contains .milk or
/* Returns nonzero if string 'name' contains .milk or
(the better) .prjm extension. Not a very strong function currently */
(the better) .prjm extension. Not a very strong function currently */
int
is_valid_extension
(
char
*
name
)
{
int
is_valid_extension
(
char
*
name
)
{
if
(
PRESET_DEBUG
>
1
)
{
if
(
PRESET_DEBUG
>
1
)
{
printf
(
"is_valid_extension: scanning string
\"
%s
\"
..."
,
name
);
printf
(
"is_valid_extension: scanning string
\"
%s
\"
..."
,
name
);
fflush
(
stdout
);
fflush
(
stdout
);
}
}
if
(
strstr
(
name
,
MILKDROP_FILE_EXTENSION
))
{
if
(
strstr
(
name
,
MILKDROP_FILE_EXTENSION
))
{
if
(
PRESET_DEBUG
>
1
)
printf
(
"
\"
.milk
\"
extension found in string [true]
\n
"
);
if
(
PRESET_DEBUG
>
1
)
printf
(
"
\"
.milk
\"
extension found in string [true]
\n
"
);
return
TRUE
;
return
TRUE
;
}
}
if
(
strstr
(
name
,
PROJECTM_FILE_EXTENSION
))
{
if
(
strstr
(
name
,
PROJECTM_FILE_EXTENSION
))
{
if
(
PRESET_DEBUG
>
1
)
printf
(
"
\"
.prjm
\"
extension found in string [true]
\n
"
);
if
(
PRESET_DEBUG
>
1
)
printf
(
"
\"
.prjm
\"
extension found in string [true]
\n
"
);
return
TRUE
;
return
TRUE
;
}
}
if
(
PRESET_DEBUG
>
1
)
printf
(
"no valid extension found [false]
\n
"
);
if
(
PRESET_DEBUG
>
1
)
printf
(
"no valid extension found [false]
\n
"
);
return
FALSE
;
return
FALSE
;
}
}
/* Private function to close a preset file */
/* Private function to close a preset file */
...
@@ -607,33 +607,33 @@ int close_preset(preset_t * preset) {
...
@@ -607,33 +607,33 @@ int close_preset(preset_t * preset) {
splay_traverse
(
free_init_cond
,
preset
->
init_cond_tree
);
splay_traverse
(
free_init_cond
,
preset
->
init_cond_tree
);
destroy_splaytree
(
preset
->
init_cond_tree
);
destroy_splaytree
(
preset
->
init_cond_tree
);
splay_traverse
(
free_init_cond
,
preset
->
per_frame_init_eqn_tree
);
splay_traverse
(
free_init_cond
,
preset
->
per_frame_init_eqn_tree
);
destroy_splaytree
(
preset
->
per_frame_init_eqn_tree
);
destroy_splaytree
(
preset
->
per_frame_init_eqn_tree
);
splay_traverse
(
free_per_pixel_eqn
,
preset
->
per_pixel_eqn_tree
);
splay_traverse
(
free_per_pixel_eqn
,
preset
->
per_pixel_eqn_tree
);
destroy_splaytree
(
preset
->
per_pixel_eqn_tree
);
destroy_splaytree
(
preset
->
per_pixel_eqn_tree
);
splay_traverse
(
free_per_frame_eqn
,
preset
->
per_frame_eqn_tree
);
splay_traverse
(
free_per_frame_eqn
,
preset
->
per_frame_eqn_tree
);
destroy_splaytree
(
preset
->
per_frame_eqn_tree
);
destroy_splaytree
(
preset
->
per_frame_eqn_tree
);
splay_traverse
(
free_param
,
preset
->
user_param_tree
);
splay_traverse
(
free_param
,
preset
->
user_param_tree
);
destroy_splaytree
(
preset
->
user_param_tree
);
destroy_splaytree
(
preset
->
user_param_tree
);
splay_traverse
(
free_custom_wave
,
preset
->
custom_wave_tree
);
splay_traverse
(
free_custom_wave
,
preset
->
custom_wave_tree
);
destroy_splaytree
(
preset
->
custom_wave_tree
);
destroy_splaytree
(
preset
->
custom_wave_tree
);
splay_traverse
(
free_custom_shape
,
preset
->
custom_shape_tree
);
splay_traverse
(
free_custom_shape
,
preset
->
custom_shape_tree
);
destroy_splaytree
(
preset
->
custom_shape_tree
);
destroy_splaytree
(
preset
->
custom_shape_tree
);
free
(
preset
);
free
(
preset
);
return
SUCCESS
;
return
SUCCESS
;
}
}
void
reloadPerPixel
(
char
*
s
,
preset_t
*
preset
)
{
void
reloadPerPixel
(
char
*
s
,
preset_t
*
preset
)
{
FILE
*
fs
;
FILE
*
fs
;
int
slen
;
int
slen
;
char
c
;
char
c
;
...
@@ -740,7 +740,7 @@ preset_t * load_preset(char * pathname) {
...
@@ -740,7 +740,7 @@ preset_t * load_preset(char * pathname) {
/* Initialize preset struct */
/* Initialize preset struct */
if
((
preset
=
(
preset_t
*
)
malloc
(
sizeof
(
preset_t
)))
==
NULL
)
if
((
preset
=
(
preset_t
*
)
malloc
(
sizeof
(
preset_t
)))
==
NULL
)
return
NULL
;
return
NULL
;
/* Initialize equation trees */
/* Initialize equation trees */
preset
->
init_cond_tree
=
create_splaytree
(
compare_string
,
copy_string
,
free_string
);
preset
->
init_cond_tree
=
create_splaytree
(
compare_string
,
copy_string
,
free_string
);
preset
->
user_param_tree
=
create_splaytree
(
compare_string
,
copy_string
,
free_string
);
preset
->
user_param_tree
=
create_splaytree
(
compare_string
,
copy_string
,
free_string
);
...
@@ -752,25 +752,25 @@ preset_t * load_preset(char * pathname) {
...
@@ -752,25 +752,25 @@ preset_t * load_preset(char * pathname) {
memset
(
preset
->
per_pixel_flag
,
0
,
sizeof
(
int
)
*
NUM_OPS
);
memset
(
preset
->
per_pixel_flag
,
0
,
sizeof
(
int
)
*
NUM_OPS
);
/* Copy file path */
/* Copy file path */
strncpy
(
preset
->
file_path
,
pathname
,
MAX_PATH_SIZE
-
1
);
strncpy
(
preset
->
file_path
,
pathname
,
MAX_PATH_SIZE
-
1
);
/* Set initial index values */
/* Set initial index values */
preset
->
per_pixel_eqn_string_index
=
0
;
preset
->
per_pixel_eqn_string_index
=
0
;
preset
->
per_frame_eqn_string_index
=
0
;
preset
->
per_frame_eqn_string_index
=
0
;
preset
->
per_frame_init_eqn_string_index
=
0
;
preset
->
per_frame_init_eqn_string_index
=
0
;
/* Clear string buffers */
/* Clear string buffers */
memset
(
preset
->
per_pixel_eqn_string_buffer
,
0
,
STRING_BUFFER_SIZE
);
memset
(
preset
->
per_pixel_eqn_string_buffer
,
0
,
STRING_BUFFER_SIZE
);
memset
(
preset
->
per_frame_eqn_string_buffer
,
0
,
STRING_BUFFER_SIZE
);
memset
(
preset
->
per_frame_eqn_string_buffer
,
0
,
STRING_BUFFER_SIZE
);
memset
(
preset
->
per_frame_init_eqn_string_buffer
,
0
,
STRING_BUFFER_SIZE
);
memset
(
preset
->
per_frame_init_eqn_string_buffer
,
0
,
STRING_BUFFER_SIZE
);
if
(
load_preset_file
(
pathname
,
preset
)
<
0
)
{
if
(
load_preset_file
(
pathname
,
preset
)
<
0
)
{
if
(
PRESET_DEBUG
)
printf
(
"load_preset: failed to load file
\"
%s
\"\n
"
,
pathname
);
if
(
PRESET_DEBUG
)
printf
(
"load_preset: failed to load file
\"
%s
\"\n
"
,
pathname
);
close_preset
(
preset
);
close_preset
(
preset
);
return
NULL
;
return
NULL
;
}
}
/* It's kind of ugly to reset these values here. Should definitely be placed in the parser somewhere */
/* It's kind of ugly to reset these values here. Should definitely be placed in the parser somewhere */
...
@@ -787,11 +787,11 @@ void savePreset(char * filename) {
...
@@ -787,11 +787,11 @@ void savePreset(char * filename) {
if
(
filename
==
NULL
)
if
(
filename
==
NULL
)
return
;
return
;
/* Open the file corresponding to pathname */
/* Open the file corresponding to pathname */
if
((
fs
=
utf8_fopen
(
filename
,
"w+"
))
==
0
)
{
if
((
fs
=
utf8_fopen
(
filename
,
"w+"
))
==
0
)
{
if
(
PRESET_DEBUG
)
printf
(
"savePreset: failed to create filename
\"
%s
\"
!
\n
"
,
filename
);
if
(
PRESET_DEBUG
)
printf
(
"savePreset: failed to create filename
\"
%s
\"
!
\n
"
,
filename
);
return
;
return
;
}
}
write_stream
=
fs
;
write_stream
=
fs
;
...
@@ -863,7 +863,7 @@ int write_init_conditions(FILE * fs) {
...
@@ -863,7 +863,7 @@ int write_init_conditions(FILE * fs) {
splay_traverse
(
write_init
,
active_preset
->
init_cond_tree
);
splay_traverse
(
write_init
,
active_preset
->
init_cond_tree
);
return
SUCCESS
;
return
SUCCESS
;
}
}
...
@@ -880,7 +880,7 @@ void write_init(init_cond_t * init_cond) {
...
@@ -880,7 +880,7 @@ void write_init(init_cond_t * init_cond) {
if
(
init_cond
->
param
->
type
==
P_TYPE_BOOL
)
if
(
init_cond
->
param
->
type
==
P_TYPE_BOOL
)
sprintf
(
s
,
"%s=%d
\n
"
,
init_cond
->
param
->
name
,
init_cond
->
init_val
.
bool_val
);
sprintf
(
s
,
"%s=%d
\n
"
,
init_cond
->
param
->
name
,
init_cond
->
init_val
.
bool_val
);
else
if
(
init_cond
->
param
->
type
==
P_TYPE_INT
)
else
if
(
init_cond
->
param
->
type
==
P_TYPE_INT
)
sprintf
(
s
,
"%s=%d
\n
"
,
init_cond
->
param
->
name
,
init_cond
->
init_val
.
int_val
);
sprintf
(
s
,
"%s=%d
\n
"
,
init_cond
->
param
->
name
,
init_cond
->
init_val
.
int_val
);
else
if
(
init_cond
->
param
->
type
==
P_TYPE_DOUBLE
)
else
if
(
init_cond
->
param
->
type
==
P_TYPE_DOUBLE
)
...
@@ -908,7 +908,7 @@ int write_per_frame_init_equations(FILE * fs) {
...
@@ -908,7 +908,7 @@ int write_per_frame_init_equations(FILE * fs) {
return
FAILURE
;
return
FAILURE
;
if
(
active_preset
==
NULL
)
if
(
active_preset
==
NULL
)
return
FAILURE
;
return
FAILURE
;
len
=
strlen
(
active_preset
->
per_frame_init_eqn_string_buffer
);
len
=
strlen
(
active_preset
->
per_frame_init_eqn_string_buffer
);
if
(
fwrite
(
active_preset
->
per_frame_init_eqn_string_buffer
,
1
,
len
,
fs
)
!=
len
)
if
(
fwrite
(
active_preset
->
per_frame_init_eqn_string_buffer
,
1
,
len
,
fs
)
!=
len
)
...
@@ -973,14 +973,14 @@ void load_init_cond(param_t * param) {
...
@@ -973,14 +973,14 @@ void load_init_cond(param_t * param) {
/* If initial condition was not defined by the preset file, force a default one
/* If initial condition was not defined by the preset file, force a default one
with the following code */
with the following code */
if
((
init_cond
=
splay_find
(
param
->
name
,
active_preset
->
init_cond_tree
))
==
NULL
)
{
if
((
init_cond
=
splay_find
(
param
->
name
,
active_preset
->
init_cond_tree
))
==
NULL
)
{
/* Make sure initial condition does not exist in the set of per frame initial equations */
/* Make sure initial condition does not exist in the set of per frame initial equations */
if
((
init_cond
=
splay_find
(
param
->
name
,
active_preset
->
per_frame_init_eqn_tree
))
!=
NULL
)
if
((
init_cond
=
splay_find
(
param
->
name
,
active_preset
->
per_frame_init_eqn_tree
))
!=
NULL
)
return
;
return
;
if
(
param
->
type
==
P_TYPE_BOOL
)
if
(
param
->
type
==
P_TYPE_BOOL
)
init_val
.
bool_val
=
0
;
init_val
.
bool_val
=
0
;
else
if
(
param
->
type
==
P_TYPE_INT
)
else
if
(
param
->
type
==
P_TYPE_INT
)
init_val
.
int_val
=
*
(
int
*
)
param
->
engine_val
;
init_val
.
int_val
=
*
(
int
*
)
param
->
engine_val
;
...
@@ -991,13 +991,13 @@ void load_init_cond(param_t * param) {
...
@@ -991,13 +991,13 @@ void load_init_cond(param_t * param) {
/* Create new initial condition */
/* Create new initial condition */
if
((
init_cond
=
new_init_cond
(
param
,
init_val
))
==
NULL
)
if
((
init_cond
=
new_init_cond
(
param
,
init_val
))
==
NULL
)
return
;
return
;
/* Insert the initial condition into this presets tree */
/* Insert the initial condition into this presets tree */
if
(
splay_insert
(
init_cond
,
init_cond
->
param
->
name
,
active_preset
->
init_cond_tree
)
<
0
)
{
if
(
splay_insert
(
init_cond
,
init_cond
->
param
->
name
,
active_preset
->
init_cond_tree
)
<
0
)
{
free_init_cond
(
init_cond
);
free_init_cond
(
init_cond
);
return
;
return
;
}
}
}
}
}
}
...
...
modules/visualization/galaktos/preset_types.h
View file @
d6008a8b
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
#include "expr_types.h"
#include "expr_types.h"
#include "per_pixel_eqn_types.h"
#include "per_pixel_eqn_types.h"
typedef
enum
{
typedef
enum
{
ALPHA_NEXT
,
ALPHA_NEXT
,
ALPHA_PREVIOUS
,
ALPHA_PREVIOUS
,
RANDOM_NEXT
,
RANDOM_NEXT
,
...
@@ -13,14 +13,14 @@ typedef enum {
...
@@ -13,14 +13,14 @@ typedef enum {
}
switch_mode_t
;
}
switch_mode_t
;
typedef
struct
PRESET_T
{
typedef
struct
PRESET_T
{
char
name
[
MAX_TOKEN_SIZE
];
/* preset name as parsed in file */
char
name
[
MAX_TOKEN_SIZE
];
/* preset name as parsed in file */
char
file_path
[
MAX_PATH_SIZE
];
/* Points to the preset file name */
char
file_path
[
MAX_PATH_SIZE
];
/* Points to the preset file name */
int
per_pixel_eqn_string_index
;
int
per_pixel_eqn_string_index
;
int
per_frame_eqn_string_index
;
int
per_frame_eqn_string_index
;
int
per_frame_init_eqn_string_index
;
int
per_frame_init_eqn_string_index
;
int
per_pixel_flag
[
NUM_OPS
];
int
per_pixel_flag
[
NUM_OPS
];
char
per_pixel_eqn_string_buffer
[
STRING_BUFFER_SIZE
];
char
per_pixel_eqn_string_buffer
[
STRING_BUFFER_SIZE
];
char
per_frame_eqn_string_buffer
[
STRING_BUFFER_SIZE
];
char
per_frame_eqn_string_buffer
[
STRING_BUFFER_SIZE
];
...
...
modules/visualization/galaktos/splaytree.c
View file @
d6008a8b
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
/*
/*
An implementation of top-down splaying
An implementation of top-down splaying
D. Sleator <sleator@cs.cmu.edu>
D. Sleator <sleator@cs.cmu.edu>
March 1992
March 1992
"Splay trees", or "self-adjusting search trees" are a simple and
"Splay trees", or "self-adjusting search trees" are a simple and
efficient data structure for storing an ordered set. The data
efficient data structure for storing an ordered set. The data
...
@@ -69,7 +69,7 @@
...
@@ -69,7 +69,7 @@
The following code was written by Daniel Sleator, and is released
The following code was written by Daniel Sleator, and is released
in the public domain. It has been heavily modified by Carmelo Piccione,
in the public domain. It has been heavily modified by Carmelo Piccione,
(cep@andrew.cmu.edu), to suit personal needs,
(cep@andrew.cmu.edu), to suit personal needs,
*/
*/
#include <stdlib.h>
#include <stdlib.h>
...
@@ -107,7 +107,7 @@ inline splaytree_t * create_splaytree(int (*compare)(), void * (*copy_key)(), vo
...
@@ -107,7 +107,7 @@ inline splaytree_t * create_splaytree(int (*compare)(), void * (*copy_key)(), vo
splaytree
->
compare
=
compare
;
splaytree
->
compare
=
compare
;
splaytree
->
copy_key
=
copy_key
;
splaytree
->
copy_key
=
copy_key
;
splaytree
->
free_key
=
free_key
;
splaytree
->
free_key
=
free_key
;
/* Return instantiated splay tree */
/* Return instantiated splay tree */
return
splaytree
;
return
splaytree
;
}
}
...
@@ -124,7 +124,7 @@ inline int destroy_splaytree(splaytree_t * splaytree) {
...
@@ -124,7 +124,7 @@ inline int destroy_splaytree(splaytree_t * splaytree) {
/* Free the splaytree struct itself */
/* Free the splaytree struct itself */
free
(
splaytree
);
free
(
splaytree
);
/* Done, return success */
/* Done, return success */
return
SUCCESS
;
return
SUCCESS
;
...
@@ -139,16 +139,16 @@ static inline int free_splaynode(splaynode_t * splaynode, void (*free_key)()) {
...
@@ -139,16 +139,16 @@ static inline int free_splaynode(splaynode_t * splaynode, void (*free_key)()) {
/* Free left node */
/* Free left node */
free_splaynode
(
splaynode
->
left
,
free_key
);
free_splaynode
(
splaynode
->
left
,
free_key
);
/* Free right node */
/* Free right node */
free_splaynode
(
splaynode
->
right
,
free_key
);
free_splaynode
(
splaynode
->
right
,
free_key
);
/* Free this node's key */
/* Free this node's key */
free_key
(
splaynode
->
key
);
free_key
(
splaynode
->
key
);
/* Note that the data pointers are not freed here.
/* Note that the data pointers are not freed here.
Should be freed with a splay traversal function */
Should be freed with a splay traversal function */
/* Free the splaynode structure itself */
/* Free the splaynode structure itself */
free
(
splaynode
);
free
(
splaynode
);
...
@@ -163,10 +163,10 @@ inline void splay_traverse(void (*func_ptr)(), splaytree_t * splaytree) {
...
@@ -163,10 +163,10 @@ inline void splay_traverse(void (*func_ptr)(), splaytree_t * splaytree) {
/* Null argument check */
/* Null argument check */
if
(
splaytree
==
NULL
)
if
(
splaytree
==
NULL
)
return
;
return
;
if
(
func_ptr
==
NULL
)
if
(
func_ptr
==
NULL
)
return
;
return
;
/* Call recursive helper function */
/* Call recursive helper function */
splay_traverse_helper
(
func_ptr
,
splaytree
->
root
);
splay_traverse_helper
(
func_ptr
,
splaytree
->
root
);
...
@@ -174,7 +174,7 @@ inline void splay_traverse(void (*func_ptr)(), splaytree_t * splaytree) {
...
@@ -174,7 +174,7 @@ inline void splay_traverse(void (*func_ptr)(), splaytree_t * splaytree) {
}
}
/* Helper function to traverse the entire splaytree */
/* Helper function to traverse the entire splaytree */
static
inline
void
splay_traverse_helper
(
void
(
*
func_ptr
)(),
splaynode_t
*
splaynode
)
{
static
inline
void
splay_traverse_helper
(
void
(
*
func_ptr
)(),
splaynode_t
*
splaynode
)
{
/* Normal if this happens, its a base case of recursion */
/* Normal if this happens, its a base case of recursion */
if
(
splaynode
==
NULL
)
if
(
splaynode
==
NULL
)
...
@@ -182,20 +182,20 @@ static inline void splay_traverse_helper (void (*func_ptr)(), splaynode_t * spla
...
@@ -182,20 +182,20 @@ static inline void splay_traverse_helper (void (*func_ptr)(), splaynode_t * spla
/* Recursively traverse to the left */
/* Recursively traverse to the left */
splay_traverse_helper
(
func_ptr
,
splaynode
->
left
);
splay_traverse_helper
(
func_ptr
,
splaynode
->
left
);
/* Node is a of regular type, so its ok to perform the function on it */
/* Node is a of regular type, so its ok to perform the function on it */
if
(
splaynode
->
type
==
REGULAR_NODE_TYPE
)
if
(
splaynode
->
type
==
REGULAR_NODE_TYPE
)
func_ptr
(
splaynode
->
data
);
func_ptr
(
splaynode
->
data
);
/* Node is of symbolic link type, do nothing */
/* Node is of symbolic link type, do nothing */
else
if
(
splaynode
->
type
==
SYMBOLIC_NODE_TYPE
)
else
if
(
splaynode
->
type
==
SYMBOLIC_NODE_TYPE
)
;
;
/* Unknown node type */
/* Unknown node type */
else
else
;
;
/* Recursively traverse to the right */
/* Recursively traverse to the right */
splay_traverse_helper
(
func_ptr
,
splaynode
->
right
);
splay_traverse_helper
(
func_ptr
,
splaynode
->
right
);
...
@@ -210,35 +210,35 @@ inline void * splay_find(void * key, splaytree_t * splaytree) {
...
@@ -210,35 +210,35 @@ inline void * splay_find(void * key, splaytree_t * splaytree) {
int
match_type
;
int
match_type
;
if
(
key
==
NULL
)
if
(
key
==
NULL
)
return
NULL
;
return
NULL
;
if
(
splaytree
==
NULL
)
if
(
splaytree
==
NULL
)
return
NULL
;
return
NULL
;
splaynode
=
splaytree
->
root
;
splaynode
=
splaytree
->
root
;
/* Bring the targeted splay node to the top of the splaytree */
/* Bring the targeted splay node to the top of the splaytree */
splaynode
=
splay
(
key
,
splaynode
,
&
match_type
,
splaytree
->
compare
);
splaynode
=
splay
(
key
,
splaynode
,
&
match_type
,
splaytree
->
compare
);
splaytree
->
root
=
splaynode
;
splaytree
->
root
=
splaynode
;
/* We only want perfect matches, so return null when match isn't perfect */
/* We only want perfect matches, so return null when match isn't perfect */
if
(
match_type
==
CLOSEST_MATCH
)
if
(
match_type
==
CLOSEST_MATCH
)
return
NULL
;
return
NULL
;
/* This shouldn't happen because of the match type check, but whatever */
/* This shouldn't happen because of the match type check, but whatever */
if
(
splaytree
->
root
==
NULL
)
if
(
splaytree
->
root
==
NULL
)
return
NULL
;
return
NULL
;
/* Node is a regular type, return its data pointer */
/* Node is a regular type, return its data pointer */
if
(
splaytree
->
root
->
type
==
REGULAR_NODE_TYPE
)
/* regular node */
if
(
splaytree
->
root
->
type
==
REGULAR_NODE_TYPE
)
/* regular node */
return
splaytree
->
root
->
data
;
return
splaytree
->
root
->
data
;
/* If the node is a symlink, pursue one link */
/* If the node is a symlink, pursue one link */
if
(
splaytree
->
root
->
type
==
SYMBOLIC_NODE_TYPE
)
/* symbolic node */
if
(
splaytree
->
root
->
type
==
SYMBOLIC_NODE_TYPE
)
/* symbolic node */
return
((
splaynode_t
*
)
splaytree
->
root
->
data
)
->
data
;
return
((
splaynode_t
*
)
splaytree
->
root
->
data
)
->
data
;
/* Unknown type */
/* Unknown type */
return
NULL
;
return
NULL
;
}
}
...
@@ -248,14 +248,14 @@ inline splaynode_t * get_splaynode_of(void * key, splaytree_t * splaytree) {
...
@@ -248,14 +248,14 @@ inline splaynode_t * get_splaynode_of(void * key, splaytree_t * splaytree) {
splaynode_t
*
splaynode
;
splaynode_t
*
splaynode
;
int
match_type
;
int
match_type
;
/* Null argument checks */
/* Null argument checks */
if
(
splaytree
==
NULL
)
if
(
splaytree
==
NULL
)
return
NULL
;
return
NULL
;
if
(
key
==
NULL
)
if
(
key
==
NULL
)
return
NULL
;
return
NULL
;
splaynode
=
splaytree
->
root
;
splaynode
=
splaytree
->
root
;
/* Find the splaynode */
/* Find the splaynode */
...
@@ -272,52 +272,52 @@ inline splaynode_t * get_splaynode_of(void * key, splaytree_t * splaytree) {
...
@@ -272,52 +272,52 @@ inline splaynode_t * get_splaynode_of(void * key, splaytree_t * splaytree) {
/* Finds the desired node, and changes the tree such that it is the root */
/* Finds the desired node, and changes the tree such that it is the root */
static
inline
splaynode_t
*
splay
(
void
*
key
,
splaynode_t
*
t
,
int
*
match_type
,
int
(
*
compare
)())
{
static
inline
splaynode_t
*
splay
(
void
*
key
,
splaynode_t
*
t
,
int
*
match_type
,
int
(
*
compare
)())
{
/* Simple top down splay, not requiring key to be in the tree t.
/* Simple top down splay, not requiring key to be in the tree t.
What it does is described above. */
What it does is described above. */
splaynode_t
N
,
*
l
,
*
r
,
*
y
;
splaynode_t
N
,
*
l
,
*
r
,
*
y
;
*
match_type
=
CLOSEST_MATCH
;
*
match_type
=
CLOSEST_MATCH
;
if
(
t
==
NULL
)
return
t
;
if
(
t
==
NULL
)
return
t
;
N
.
left
=
N
.
right
=
NULL
;
N
.
left
=
N
.
right
=
NULL
;
l
=
r
=
&
N
;
l
=
r
=
&
N
;
for
(;;)
{
for
(;;)
{
if
(
compare
(
key
,
t
->
key
)
<
0
)
{
if
(
compare
(
key
,
t
->
key
)
<
0
)
{
if
(
t
->
left
==
NULL
)
break
;
if
(
t
->
left
==
NULL
)
break
;
if
(
compare
(
key
,
t
->
left
->
key
)
<
0
)
{
if
(
compare
(
key
,
t
->
left
->
key
)
<
0
)
{
y
=
t
->
left
;
/* rotate right */
y
=
t
->
left
;
/* rotate right */
t
->
left
=
y
->
right
;
t
->
left
=
y
->
right
;
y
->
right
=
t
;
y
->
right
=
t
;
t
=
y
;
t
=
y
;
if
(
t
->
left
==
NULL
)
break
;
if
(
t
->
left
==
NULL
)
break
;
}
}
r
->
left
=
t
;
/* link right */
r
->
left
=
t
;
/* link right */
r
=
t
;
r
=
t
;
t
=
t
->
left
;
t
=
t
->
left
;
}
else
if
(
compare
(
key
,
t
->
key
)
>
0
)
{
}
else
if
(
compare
(
key
,
t
->
key
)
>
0
)
{
if
(
t
->
right
==
NULL
)
break
;
if
(
t
->
right
==
NULL
)
break
;
if
(
compare
(
key
,
t
->
right
->
key
)
>
0
)
{
if
(
compare
(
key
,
t
->
right
->
key
)
>
0
)
{
y
=
t
->
right
;
/* rotate left */
y
=
t
->
right
;
/* rotate left */
t
->
right
=
y
->
left
;
t
->
right
=
y
->
left
;
y
->
left
=
t
;
y
->
left
=
t
;
t
=
y
;
t
=
y
;
if
(
t
->
right
==
NULL
)
break
;
if
(
t
->
right
==
NULL
)
break
;
}
}
l
->
right
=
t
;
/* link left */
l
->
right
=
t
;
/* link left */
l
=
t
;
l
=
t
;
t
=
t
->
right
;
t
=
t
->
right
;
}
else
{
}
else
{
*
match_type
=
PERFECT_MATCH
;
*
match_type
=
PERFECT_MATCH
;
break
;
break
;
}
}
}
}
l
->
right
=
t
->
left
;
/* assemble */
l
->
right
=
t
->
left
;
/* assemble */
r
->
left
=
t
->
right
;
r
->
left
=
t
->
right
;
t
->
left
=
N
.
right
;
t
->
left
=
N
.
right
;
t
->
right
=
N
.
left
;
t
->
right
=
N
.
left
;
return
t
;
return
t
;
//return NULL;
//return NULL;
...
@@ -326,79 +326,79 @@ static inline splaynode_t * splay (void * key, splaynode_t * t, int * match_type
...
@@ -326,79 +326,79 @@ static inline splaynode_t * splay (void * key, splaynode_t * t, int * match_type
/* Deletes a splay node from a splay tree. If the node doesn't exist
/* Deletes a splay node from a splay tree. If the node doesn't exist
then nothing happens */
then nothing happens */
inline
int
splay_delete
(
void
*
key
,
splaytree_t
*
splaytree
)
{
inline
int
splay_delete
(
void
*
key
,
splaytree_t
*
splaytree
)
{
splaynode_t
*
splaynode
;
splaynode_t
*
splaynode
;
/* Use helper function to delete the node and return the resulting tree */
/* Use helper function to delete the node and return the resulting tree */
if
((
splaynode
=
splay_delete_helper
(
key
,
splaytree
->
root
,
splaytree
->
compare
,
splaytree
->
free_key
))
==
NULL
)
if
((
splaynode
=
splay_delete_helper
(
key
,
splaytree
->
root
,
splaytree
->
compare
,
splaytree
->
free_key
))
==
NULL
)
return
FAILURE
;
return
FAILURE
;
/* Set new splaytree root equal to the returned splaynode after deletion */
/* Set new splaytree root equal to the returned splaynode after deletion */
splaytree
->
root
=
splaynode
;
splaytree
->
root
=
splaynode
;
/* Finished, no errors */
/* Finished, no errors */
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Deletes a splay node */
/* Deletes a splay node */
static
inline
splaynode_t
*
splay_delete_helper
(
void
*
key
,
splaynode_t
*
splaynode
,
int
(
*
compare
)(),
void
(
*
free_key
)())
{
static
inline
splaynode_t
*
splay_delete_helper
(
void
*
key
,
splaynode_t
*
splaynode
,
int
(
*
compare
)(),
void
(
*
free_key
)())
{
splaynode_t
*
new_root
;
splaynode_t
*
new_root
;
int
match_type
;
int
match_type
;
/* Argument check */
/* Argument check */
if
(
splaynode
==
NULL
)
if
(
splaynode
==
NULL
)
return
NULL
;
return
NULL
;
splaynode
=
splay
(
key
,
splaynode
,
&
match_type
,
compare
);
splaynode
=
splay
(
key
,
splaynode
,
&
match_type
,
compare
);
/* If entry wasn't found, quit here */
/* If entry wasn't found, quit here */
if
(
match_type
==
CLOSEST_MATCH
)
if
(
match_type
==
CLOSEST_MATCH
)
return
NULL
;
return
NULL
;
/* If the targeted node's left pointer is null, then set the new root
/* If the targeted node's left pointer is null, then set the new root
equal to the splaynode's right child */
equal to the splaynode's right child */
if
(
splaynode
->
left
==
NULL
)
{
if
(
splaynode
->
left
==
NULL
)
{
new_root
=
splaynode
->
right
;
new_root
=
splaynode
->
right
;
}
}
/* Otherwise, do something I don't currently understand */
/* Otherwise, do something I don't currently understand */
else
{
else
{
new_root
=
splay
(
key
,
splaynode
->
left
,
&
match_type
,
compare
);
new_root
=
splay
(
key
,
splaynode
->
left
,
&
match_type
,
compare
);
new_root
->
right
=
splaynode
->
right
;
new_root
->
right
=
splaynode
->
right
;
}
}
/* Set splay nodes children pointers to null */
/* Set splay nodes children pointers to null */
splaynode
->
left
=
splaynode
->
right
=
NULL
;
splaynode
->
left
=
splaynode
->
right
=
NULL
;
/* Free the splaynode (and only this node since its children are now empty */
/* Free the splaynode (and only this node since its children are now empty */
free_splaynode
(
splaynode
,
free_key
);
free_splaynode
(
splaynode
,
free_key
);
/* Return the resulting tree */
/* Return the resulting tree */
return
new_root
;
return
new_root
;
}
}
/* Create a new splay node type */
/* Create a new splay node type */
static
inline
splaynode_t
*
new_splaynode
(
int
type
,
void
*
key
,
void
*
data
)
{
static
inline
splaynode_t
*
new_splaynode
(
int
type
,
void
*
key
,
void
*
data
)
{
splaynode_t
*
splaynode
;
splaynode_t
*
splaynode
;
/* Argument checks */
/* Argument checks */
if
(
data
==
NULL
)
if
(
data
==
NULL
)
return
NULL
;
return
NULL
;
if
(
key
==
NULL
)
if
(
key
==
NULL
)
return
NULL
;
return
NULL
;
/* Creates the new splay node struct */
/* Creates the new splay node struct */
if
((
splaynode
=
(
splaynode_t
*
)
malloc
(
sizeof
(
splaynode_t
)))
==
NULL
)
if
((
splaynode
=
(
splaynode_t
*
)
malloc
(
sizeof
(
splaynode_t
)))
==
NULL
)
return
NULL
;
return
NULL
;
splaynode
->
data
=
data
;
splaynode
->
data
=
data
;
splaynode
->
type
=
type
;
splaynode
->
type
=
type
;
splaynode
->
key
=
key
;
splaynode
->
key
=
key
;
/* Return the new splay node */
/* Return the new splay node */
return
splaynode
;
return
splaynode
;
}
}
/* Inserts a link into the splay tree */
/* Inserts a link into the splay tree */
...
@@ -407,24 +407,24 @@ inline int splay_insert_link(void * alias_key, void * orig_key, splaytree_t * sp
...
@@ -407,24 +407,24 @@ inline int splay_insert_link(void * alias_key, void * orig_key, splaytree_t * sp
splaynode_t
*
splaynode
,
*
data_node
;
splaynode_t
*
splaynode
,
*
data_node
;
void
*
key_clone
;
void
*
key_clone
;
/* Null arguments */
/* Null arguments */
if
(
splaytree
==
NULL
)
if
(
splaytree
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
alias_key
==
NULL
)
if
(
alias_key
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
orig_key
==
NULL
)
if
(
orig_key
==
NULL
)
return
FAILURE
;
return
FAILURE
;
/* Find the splaynode corresponding to the original key */
/* Find the splaynode corresponding to the original key */
if
((
data_node
=
get_splaynode_of
(
orig_key
,
splaytree
))
==
NULL
)
if
((
data_node
=
get_splaynode_of
(
orig_key
,
splaytree
))
==
NULL
)
return
FAILURE
;
return
FAILURE
;
/* Create a new splay node of symbolic link type */
/* Create a new splay node of symbolic link type */
if
((
splaynode
=
new_splaynode
(
SYMBOLIC_NODE_TYPE
,
(
key_clone
=
splaytree
->
copy_key
(
alias_key
)),
data_node
))
==
NULL
)
{
if
((
splaynode
=
new_splaynode
(
SYMBOLIC_NODE_TYPE
,
(
key_clone
=
splaytree
->
copy_key
(
alias_key
)),
data_node
))
==
NULL
)
{
splaytree
->
free_key
(
key_clone
);
splaytree
->
free_key
(
key_clone
);
return
OUTOFMEM_ERROR
;
return
OUTOFMEM_ERROR
;
}
}
/* Insert the splaynode into the given splaytree */
/* Insert the splaynode into the given splaytree */
...
@@ -432,45 +432,45 @@ inline int splay_insert_link(void * alias_key, void * orig_key, splaytree_t * sp
...
@@ -432,45 +432,45 @@ inline int splay_insert_link(void * alias_key, void * orig_key, splaytree_t * sp
splaynode
->
left
=
splaynode
->
right
=
NULL
;
splaynode
->
left
=
splaynode
->
right
=
NULL
;
free_splaynode
(
splaynode
,
splaytree
->
free_key
);
free_splaynode
(
splaynode
,
splaytree
->
free_key
);
return
FAILURE
;
return
FAILURE
;
}
}
/* Done, return success */
/* Done, return success */
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Inserts 'data' into the 'splaytree' paired with the passed 'key' */
/* Inserts 'data' into the 'splaytree' paired with the passed 'key' */
inline
int
splay_insert
(
void
*
data
,
void
*
key
,
splaytree_t
*
splaytree
)
{
inline
int
splay_insert
(
void
*
data
,
void
*
key
,
splaytree_t
*
splaytree
)
{
splaynode_t
*
splaynode
;
splaynode_t
*
splaynode
;
void
*
key_clone
;
void
*
key_clone
;
/* Null argument checks */
/* Null argument checks */
if
(
splaytree
==
NULL
)
{
if
(
splaytree
==
NULL
)
{
return
FAILURE
;
return
FAILURE
;
}
}
if
(
key
==
NULL
)
if
(
key
==
NULL
)
return
FAILURE
;
return
FAILURE
;
/* Clone the key argument */
/* Clone the key argument */
key_clone
=
splaytree
->
copy_key
(
key
);
key_clone
=
splaytree
->
copy_key
(
key
);
/* Create a new splaynode (of regular type) */
/* Create a new splaynode (of regular type) */
if
((
splaynode
=
new_splaynode
(
REGULAR_NODE_TYPE
,
key_clone
,
data
))
==
NULL
)
{
if
((
splaynode
=
new_splaynode
(
REGULAR_NODE_TYPE
,
key_clone
,
data
))
==
NULL
)
{
splaytree
->
free_key
(
key_clone
);
splaytree
->
free_key
(
key_clone
);
return
OUTOFMEM_ERROR
;
return
OUTOFMEM_ERROR
;
}
}
/* Inserts the splaynode into the splaytree */
/* Inserts the splaynode into the splaytree */
if
(
splay_insert_node
(
splaynode
,
splaytree
)
<
0
)
{
if
(
splay_insert_node
(
splaynode
,
splaytree
)
<
0
)
{
splaynode
->
left
=
splaynode
->
right
=
NULL
;
splaynode
->
left
=
splaynode
->
right
=
NULL
;
free_splaynode
(
splaynode
,
splaytree
->
free_key
);
free_splaynode
(
splaynode
,
splaytree
->
free_key
);
return
FAILURE
;
return
FAILURE
;
}
}
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Helper function to insert splaynodes into the splaytree */
/* Helper function to insert splaynodes into the splaytree */
...
@@ -479,216 +479,216 @@ static inline int splay_insert_node(splaynode_t * splaynode, splaytree_t * splay
...
@@ -479,216 +479,216 @@ static inline int splay_insert_node(splaynode_t * splaynode, splaytree_t * splay
int
cmpval
;
int
cmpval
;
void
*
key
;
void
*
key
;
splaynode_t
*
t
;
splaynode_t
*
t
;
/* Null argument checks */
/* Null argument checks */
if
(
splaytree
==
NULL
)
if
(
splaytree
==
NULL
)
return
FAILURE
;
return
FAILURE
;
if
(
splaynode
==
NULL
)
if
(
splaynode
==
NULL
)
return
FAILURE
;
return
FAILURE
;
key
=
splaynode
->
key
;
key
=
splaynode
->
key
;
t
=
splaytree
->
root
;
t
=
splaytree
->
root
;
/* Root is null, insert splaynode here */
/* Root is null, insert splaynode here */
if
(
t
==
NULL
)
{
if
(
t
==
NULL
)
{
splaynode
->
left
=
splaynode
->
right
=
NULL
;
splaynode
->
left
=
splaynode
->
right
=
NULL
;
splaytree
->
root
=
splaynode
;
splaytree
->
root
=
splaynode
;
return
SUCCESS
;
return
SUCCESS
;
}
}
t
=
splay
(
key
,
t
,
&
match_type
,
splaytree
->
compare
);
t
=
splay
(
key
,
t
,
&
match_type
,
splaytree
->
compare
);
if
((
cmpval
=
splaytree
->
compare
(
key
,
t
->
key
))
<
0
)
{
if
((
cmpval
=
splaytree
->
compare
(
key
,
t
->
key
))
<
0
)
{
splaynode
->
left
=
t
->
left
;
splaynode
->
left
=
t
->
left
;
splaynode
->
right
=
t
;
splaynode
->
right
=
t
;
t
->
left
=
NULL
;
t
->
left
=
NULL
;
splaytree
->
root
=
splaynode
;
splaytree
->
root
=
splaynode
;
return
SUCCESS
;
return
SUCCESS
;
}
}
else
if
(
cmpval
>
0
)
{
else
if
(
cmpval
>
0
)
{
splaynode
->
right
=
t
->
right
;
splaynode
->
right
=
t
->
right
;
splaynode
->
left
=
t
;
splaynode
->
left
=
t
;
t
->
right
=
NULL
;
t
->
right
=
NULL
;
splaytree
->
root
=
splaynode
;
splaytree
->
root
=
splaynode
;
return
SUCCESS
;
return
SUCCESS
;
}
}
/* Item already exists in tree, don't reinsert */
/* Item already exists in tree, don't reinsert */
else
{
else
{
return
FAILURE
;
return
FAILURE
;
}
}
}
}
/* Returns the 'maximum' key that is less than the given key in the splaytree */
/* Returns the 'maximum' key that is less than the given key in the splaytree */
inline
void
*
splay_find_below_max
(
void
*
key
,
splaytree_t
*
splaytree
)
{
inline
void
*
splay_find_below_max
(
void
*
key
,
splaytree_t
*
splaytree
)
{
void
*
closest_key
;
void
*
closest_key
;
if
(
splaytree
==
NULL
)
if
(
splaytree
==
NULL
)
return
NULL
;
return
NULL
;
if
(
splaytree
->
root
==
NULL
)
if
(
splaytree
->
root
==
NULL
)
return
NULL
;
return
NULL
;
if
(
key
==
NULL
)
if
(
key
==
NULL
)
return
NULL
;
return
NULL
;
closest_key
=
NULL
;
closest_key
=
NULL
;
splay_find_below_max_helper
(
key
,
&
closest_key
,
splaytree
->
root
,
splaytree
->
compare
);
splay_find_below_max_helper
(
key
,
&
closest_key
,
splaytree
->
root
,
splaytree
->
compare
);
if
(
closest_key
==
NULL
)
return
NULL
;
if
(
closest_key
==
NULL
)
return
NULL
;
return
splay_find
(
closest_key
,
splaytree
);
return
splay_find
(
closest_key
,
splaytree
);
}
}
/* Returns the 'minimum' key that is greater than the given key in the splaytree */
/* Returns the 'minimum' key that is greater than the given key in the splaytree */
inline
void
*
splay_find_above_min
(
void
*
key
,
splaytree_t
*
splaytree
)
{
inline
void
*
splay_find_above_min
(
void
*
key
,
splaytree_t
*
splaytree
)
{
void
*
closest_key
;
void
*
closest_key
;
if
(
splaytree
==
NULL
)
if
(
splaytree
==
NULL
)
return
NULL
;
return
NULL
;
if
(
splaytree
->
root
==
NULL
)
if
(
splaytree
->
root
==
NULL
)
return
NULL
;
return
NULL
;
if
(
key
==
NULL
)
if
(
key
==
NULL
)
return
NULL
;
return
NULL
;
closest_key
=
NULL
;
closest_key
=
NULL
;
splay_find_above_min_helper
(
key
,
&
closest_key
,
splaytree
->
root
,
splaytree
->
compare
);
splay_find_above_min_helper
(
key
,
&
closest_key
,
splaytree
->
root
,
splaytree
->
compare
);
if
(
closest_key
==
NULL
)
{
if
(
closest_key
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
return
splay_find
(
closest_key
,
splaytree
);
return
splay_find
(
closest_key
,
splaytree
);
}
}
/* Helper function */
/* Helper function */
static
inline
void
splay_find_below_max_helper
(
void
*
min_key
,
void
**
closest_key
,
splaynode_t
*
root
,
int
(
*
compare
)())
{
static
inline
void
splay_find_below_max_helper
(
void
*
min_key
,
void
**
closest_key
,
splaynode_t
*
root
,
int
(
*
compare
)())
{
/* Empty root, return*/
/* Empty root, return*/
if
(
root
==
NULL
)
if
(
root
==
NULL
)
return
;
return
;
/* The root key is less than the previously found closest key.
/* The root key is less than the previously found closest key.
Also try to make the key non null if the value is less than the max key */
Also try to make the key non null if the value is less than the max key */
if
((
*
closest_key
==
NULL
)
||
(
compare
(
root
->
key
,
*
closest_key
)
<
0
))
{
if
((
*
closest_key
==
NULL
)
||
(
compare
(
root
->
key
,
*
closest_key
)
<
0
))
{
/* The root key is less than the given max key, so this is the
/* The root key is less than the given max key, so this is the
smallest change from the given max key */
smallest change from the given max key */
if
(
compare
(
root
->
key
,
min_key
)
>
0
)
{
if
(
compare
(
root
->
key
,
min_key
)
>
0
)
{
*
closest_key
=
root
->
key
;
*
closest_key
=
root
->
key
;
/* Look right again in case even a greater key exists that is
/* Look right again in case even a greater key exists that is
still less than the given max key */
still less than the given max key */
splay_find_below_max_helper
(
min_key
,
closest_key
,
root
->
left
,
compare
);
splay_find_below_max_helper
(
min_key
,
closest_key
,
root
->
left
,
compare
);
}
}
/* The root key is greater than the given max key, and greater than
/* The root key is greater than the given max key, and greater than
the closest key, so search left */
the closest key, so search left */
else
{
else
{
splay_find_below_max_helper
(
min_key
,
closest_key
,
root
->
right
,
compare
);
splay_find_below_max_helper
(
min_key
,
closest_key
,
root
->
right
,
compare
);
}
}
}
}
/* The root key is less than the found closest key, search right */
/* The root key is less than the found closest key, search right */
else
{
else
{
splay_find_below_max_helper
(
min_key
,
closest_key
,
root
->
left
,
compare
);
splay_find_below_max_helper
(
min_key
,
closest_key
,
root
->
left
,
compare
);
}
}
}
}
/* Helper function */
/* Helper function */
static
inline
void
splay_find_above_min_helper
(
void
*
max_key
,
void
**
closest_key
,
splaynode_t
*
root
,
int
(
*
compare
)())
{
static
inline
void
splay_find_above_min_helper
(
void
*
max_key
,
void
**
closest_key
,
splaynode_t
*
root
,
int
(
*
compare
)())
{
/* Empty root, stop */
/* Empty root, stop */
if
(
root
==
NULL
)
if
(
root
==
NULL
)
return
;
return
;
/* The root key is greater than the previously found closest key.
/* The root key is greater than the previously found closest key.
Also try to make the key non null if the value is less than the min key */
Also try to make the key non null if the value is less than the min key */
if
((
*
closest_key
==
NULL
)
||
(
compare
(
root
->
key
,
*
closest_key
)
>
0
))
{
if
((
*
closest_key
==
NULL
)
||
(
compare
(
root
->
key
,
*
closest_key
)
>
0
))
{
/* The root key is greater than the given min key, so this is the
/* The root key is greater than the given min key, so this is the
smallest change from the given min key */
smallest change from the given min key */
if
(
compare
(
root
->
key
,
max_key
)
<
0
)
{
if
(
compare
(
root
->
key
,
max_key
)
<
0
)
{
*
closest_key
=
root
->
key
;
*
closest_key
=
root
->
key
;
/* Look left again in case even a smaller key exists that is
/* Look left again in case even a smaller key exists that is
still greater than the given min key */
still greater than the given min key */
splay_find_above_min_helper
(
max_key
,
closest_key
,
root
->
right
,
compare
);
splay_find_above_min_helper
(
max_key
,
closest_key
,
root
->
right
,
compare
);
}
}
/* The root key is less than the given min key, and less than
/* The root key is less than the given min key, and less than
the closest key, so search right */
the closest key, so search right */
else
{
else
{
splay_find_above_min_helper
(
max_key
,
closest_key
,
root
->
left
,
compare
);
splay_find_above_min_helper
(
max_key
,
closest_key
,
root
->
left
,
compare
);
}
}
}
}
/* The root key is greater than the found closest key, search left */
/* The root key is greater than the found closest key, search left */
else
{
else
{
splay_find_above_min_helper
(
max_key
,
closest_key
,
root
->
right
,
compare
);
splay_find_above_min_helper
(
max_key
,
closest_key
,
root
->
right
,
compare
);
}
}
}
}
/* Find the minimum entry of the splay tree */
/* Find the minimum entry of the splay tree */
inline
void
*
splay_find_min
(
splaytree_t
*
t
)
{
inline
void
*
splay_find_min
(
splaytree_t
*
t
)
{
splaynode_t
*
splaynode
;
splaynode_t
*
splaynode
;
if
(
t
==
NULL
)
if
(
t
==
NULL
)
return
NULL
;
return
NULL
;
if
(
t
->
root
==
NULL
)
if
(
t
->
root
==
NULL
)
return
NULL
;
return
NULL
;
splaynode
=
t
->
root
;
splaynode
=
t
->
root
;
while
(
splaynode
->
left
!=
NULL
)
while
(
splaynode
->
left
!=
NULL
)
splaynode
=
splaynode
->
left
;
splaynode
=
splaynode
->
left
;
return
splaynode
->
data
;
return
splaynode
->
data
;
}
}
/* Find the maximum entry of the splay tree */
/* Find the maximum entry of the splay tree */
inline
void
*
splay_find_max
(
splaytree_t
*
t
)
{
inline
void
*
splay_find_max
(
splaytree_t
*
t
)
{
splaynode_t
*
splaynode
;
splaynode_t
*
splaynode
;
if
(
t
==
NULL
)
if
(
t
==
NULL
)
return
NULL
;
return
NULL
;
if
(
t
->
root
==
NULL
)
if
(
t
->
root
==
NULL
)
return
NULL
;
return
NULL
;
splaynode
=
t
->
root
;
splaynode
=
t
->
root
;
while
(
splaynode
->
right
!=
NULL
)
{
while
(
splaynode
->
right
!=
NULL
)
{
printf
(
"data:%d
\n
"
,
*
(
int
*
)
splaynode
->
key
);
printf
(
"data:%d
\n
"
,
*
(
int
*
)
splaynode
->
key
);
splaynode
=
splaynode
->
right
;
splaynode
=
splaynode
->
right
;
}
}
return
splaynode
->
data
;
return
splaynode
->
data
;
}
}
inline
int
splay_size
(
splaytree_t
*
t
)
{
inline
int
splay_size
(
splaytree_t
*
t
)
{
if
(
t
==
NULL
)
if
(
t
==
NULL
)
return
0
;
return
0
;
if
(
t
->
root
==
NULL
)
if
(
t
->
root
==
NULL
)
return
0
;
return
0
;
return
splay_rec_size
(
t
->
root
);
return
splay_rec_size
(
t
->
root
);
}
}
static
inline
int
splay_rec_size
(
splaynode_t
*
splaynode
)
{
static
inline
int
splay_rec_size
(
splaynode_t
*
splaynode
)
{
...
...
modules/visualization/galaktos/tree_types.c
View file @
d6008a8b
...
@@ -29,12 +29,12 @@
...
@@ -29,12 +29,12 @@
/* Compares integer value numbers in 32 bit range */
/* Compares integer value numbers in 32 bit range */
int
compare_int
(
int
*
num1
,
int
*
num2
)
{
int
compare_int
(
int
*
num1
,
int
*
num2
)
{
if
((
*
num1
)
<
(
*
num2
))
if
((
*
num1
)
<
(
*
num2
))
return
-
1
;
return
-
1
;
if
((
*
num1
)
>
(
*
num2
))
if
((
*
num1
)
>
(
*
num2
))
return
1
;
return
1
;
return
0
;
return
0
;
}
}
/* Compares strings in lexographical order */
/* Compares strings in lexographical order */
...
@@ -43,8 +43,8 @@ int compare_string(char * str1, char * str2) {
...
@@ -43,8 +43,8 @@ int compare_string(char * str1, char * str2) {
// printf("comparing \"%s\" to \"%s\"\n", str1, str2);
// printf("comparing \"%s\" to \"%s\"\n", str1, str2);
//return strcmp(str1, str2);
//return strcmp(str1, str2);
return
strncmp
(
str1
,
str2
,
MAX_TOKEN_SIZE
-
1
);
return
strncmp
(
str1
,
str2
,
MAX_TOKEN_SIZE
-
1
);
}
}
/* Compares a string in version order. That is, file1 < file2 < file10 */
/* Compares a string in version order. That is, file1 < file2 < file10 */
int
compare_string_version
(
char
*
str1
,
char
*
str2
)
{
int
compare_string_version
(
char
*
str1
,
char
*
str2
)
{
...
@@ -55,36 +55,36 @@ int compare_string_version(char * str1, char * str2) {
...
@@ -55,36 +55,36 @@ int compare_string_version(char * str1, char * str2) {
void
free_int
(
void
*
num
)
{
void
free_int
(
void
*
num
)
{
free
(
num
);
free
(
num
);
}
}
void
free_string
(
char
*
string
)
{
void
free_string
(
char
*
string
)
{
free
(
string
);
free
(
string
);
}
}
void
*
copy_int
(
int
*
num
)
{
void
*
copy_int
(
int
*
num
)
{
int
*
new_num
;
int
*
new_num
;
if
((
new_num
=
(
int
*
)
malloc
(
sizeof
(
int
)))
==
NULL
)
if
((
new_num
=
(
int
*
)
malloc
(
sizeof
(
int
)))
==
NULL
)
return
NULL
;
return
NULL
;
*
new_num
=
*
num
;
*
new_num
=
*
num
;
return
(
void
*
)
new_num
;
return
(
void
*
)
new_num
;
}
}
void
*
copy_string
(
char
*
string
)
{
void
*
copy_string
(
char
*
string
)
{
char
*
new_string
;
char
*
new_string
;
if
((
new_string
=
(
char
*
)
malloc
(
MAX_TOKEN_SIZE
))
==
NULL
)
if
((
new_string
=
(
char
*
)
malloc
(
MAX_TOKEN_SIZE
))
==
NULL
)
return
NULL
;
return
NULL
;
strncpy
(
new_string
,
string
,
MAX_TOKEN_SIZE
-
1
);
strncpy
(
new_string
,
string
,
MAX_TOKEN_SIZE
-
1
);
return
(
void
*
)
new_string
;
return
(
void
*
)
new_string
;
}
}
modules/visualization/galaktos/video_init.c
View file @
d6008a8b
...
@@ -43,7 +43,7 @@ extern char *buffer;
...
@@ -43,7 +43,7 @@ extern char *buffer;
void
setup_opengl
(
int
w
,
int
h
)
void
setup_opengl
(
int
w
,
int
h
)
{
{
/* Our shading model--Gouraud (smooth). */
/* Our shading model--Gouraud (smooth). */
glShadeModel
(
GL_SMOOTH
);
glShadeModel
(
GL_SMOOTH
);
/* Culling. */
/* Culling. */
...
@@ -60,21 +60,21 @@ void setup_opengl( int w, int h )
...
@@ -60,21 +60,21 @@ void setup_opengl( int w, int h )
*/
*/
glMatrixMode
(
GL_TEXTURE
);
glMatrixMode
(
GL_TEXTURE
);
glLoadIdentity
();
glLoadIdentity
();
// gluOrtho2D(0.0, (GLfloat) width, 0.0, (GLfloat) height);
// gluOrtho2D(0.0, (GLfloat) width, 0.0, (GLfloat) height);
glMatrixMode
(
GL_PROJECTION
);
glMatrixMode
(
GL_PROJECTION
);
glLoadIdentity
();
glLoadIdentity
();
// glFrustum(0.0, height, 0.0,width,10,40);
// glFrustum(0.0, height, 0.0,width,10,40);
glMatrixMode
(
GL_MODELVIEW
);
glMatrixMode
(
GL_MODELVIEW
);
glLoadIdentity
();
glLoadIdentity
();
glDrawBuffer
(
GL_BACK
);
glDrawBuffer
(
GL_BACK
);
glReadBuffer
(
GL_BACK
);
glReadBuffer
(
GL_BACK
);
glEnable
(
GL_BLEND
);
glEnable
(
GL_BLEND
);
glBlendFunc
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
);
glBlendFunc
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable
(
GL_LINE_SMOOTH
);
glEnable
(
GL_LINE_SMOOTH
);
glEnable
(
GL_POINT_SMOOTH
);
glEnable
(
GL_POINT_SMOOTH
);
glClearColor
(
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
);
glClearColor
(
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
);
...
@@ -83,8 +83,8 @@ glDrawBuffer(GL_BACK);
...
@@ -83,8 +83,8 @@ glDrawBuffer(GL_BACK);
// glCopyTexImage2D(GL_TEXTURE_2D,0,GL_RGB,0,0,texsize,texsize,0);
// glCopyTexImage2D(GL_TEXTURE_2D,0,GL_RGB,0,0,texsize,texsize,0);
//glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,texsize,texsize);
//glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,texsize,texsize);
glLineStipple
(
2
,
0xAAAA
);
glLineStipple
(
2
,
0xAAAA
);
}
}
void
CreateRenderTarget
(
int
texsize
,
int
*
RenderTargetTextureID
,
int
*
RenderTarget
)
void
CreateRenderTarget
(
int
texsize
,
int
*
RenderTargetTextureID
,
int
*
RenderTarget
)
...
@@ -98,23 +98,23 @@ void CreateRenderTarget(int texsize,int *RenderTargetTextureID, int *RenderTarge
...
@@ -98,23 +98,23 @@ void CreateRenderTarget(int texsize,int *RenderTargetTextureID, int *RenderTarge
/* Create the render target */
/* Create the render target */
*RenderTarget = SDL_GL_CreateRenderTarget(texsize,texsize, NULL);
*RenderTarget = SDL_GL_CreateRenderTarget(texsize,texsize, NULL);
if ( *RenderTarget ) {
if ( *RenderTarget ) {
int value;
int value;
//printf("Created render target:\n");
//printf("Created render target:\n");
SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_RED_SIZE, &value );
SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_RED_SIZE, &value );
//
printf( "SDL_GL_RED_SIZE: %d\n", value);
//
printf( "SDL_GL_RED_SIZE: %d\n", value);
SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_GREEN_SIZE, &value );
SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_GREEN_SIZE, &value );
//
printf( "SDL_GL_GREEN_SIZE: %d\n", value);
//
printf( "SDL_GL_GREEN_SIZE: %d\n", value);
SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_BLUE_SIZE, &value );
SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_BLUE_SIZE, &value );
//
printf( "SDL_GL_BLUE_SIZE: %d\n", value);
//
printf( "SDL_GL_BLUE_SIZE: %d\n", value);
SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_ALPHA_SIZE, &value );
SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_ALPHA_SIZE, &value );
//
printf( "SDL_GL_ALPHA_SIZE: %d\n", value);
//
printf( "SDL_GL_ALPHA_SIZE: %d\n", value);
SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_DEPTH_SIZE, &value );
SDL_GL_GetRenderTargetAttribute( *RenderTarget, SDL_GL_DEPTH_SIZE, &value );
//
printf( "SDL_GL_DEPTH_SIZE: %d\n", value );
//
printf( "SDL_GL_DEPTH_SIZE: %d\n", value );
SDL_GL_BindRenderTarget(*RenderTarget, *RenderTargetTextureID);
SDL_GL_BindRenderTarget(*RenderTarget, *RenderTargetTextureID);
} else {
} else {
#endif
#endif
/* We can fake a render target in this demo by rendering to the
/* We can fake a render target in this demo by rendering to the
...
@@ -124,13 +124,13 @@ void CreateRenderTarget(int texsize,int *RenderTargetTextureID, int *RenderTarge
...
@@ -124,13 +124,13 @@ void CreateRenderTarget(int texsize,int *RenderTargetTextureID, int *RenderTarge
glBindTexture
(
GL_TEXTURE_2D
,
*
RenderTargetTextureID
);
glBindTexture
(
GL_TEXTURE_2D
,
*
RenderTargetTextureID
);
glTexImage2D
(
GL_TEXTURE_2D
,
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
0
,
GL_RGB
,
GL_RGB
,
texsize
,
texsize
,
texsize
,
texsize
,
0
,
0
,
GL_RGB
,
GL_RGB
,
GL_UNSIGNED_BYTE
,
GL_UNSIGNED_BYTE
,
buffer
);
buffer
);
// }
// }
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment