|
@@ -24,7 +24,7 @@
|
|
|
* The writer node writes each incoming buffer as an EDF file to disk.
|
|
|
* Each file is prefixed with #UfoFilter3DEdfWriter:prefix and written into
|
|
|
* #UfoFilter3DEdfWriter:path.
|
|
|
-*/
|
|
|
+ */
|
|
|
|
|
|
struct _UfoFilter3DEdfWriterPrivate {
|
|
|
gchar *path;
|
|
@@ -47,50 +47,44 @@ enum {
|
|
|
|
|
|
static GParamSpec * edfwriter3d_properties[N_PROPERTIES] = { NULL, };
|
|
|
|
|
|
-static gboolean filter_3d_edf_write_header(FILE * file,
|
|
|
- const guint32 xs,
|
|
|
- const guint32 ys,
|
|
|
- const guint32 zs )
|
|
|
+static gboolean
|
|
|
+filter_3d_edf_write_header(FILE * file, const guint32 xs, const guint32 ys, const guint32 zs)
|
|
|
{
|
|
|
-/*
|
|
|
- {
|
|
|
- ByteOrder = LowByteFirst;
|
|
|
- DataType = FloatValue;
|
|
|
- Dim_1 = 1024;
|
|
|
- Dim_2 = 1024;
|
|
|
- Dim_3 = 256;
|
|
|
- Size = 268435456;
|
|
|
-*/
|
|
|
-
|
|
|
- const guint32 headsz = 512;
|
|
|
+ /*
|
|
|
+ {
|
|
|
+ ByteOrder = LowByteFirst;
|
|
|
+ DataType = FloatValue;
|
|
|
+ Dim_1 = 1024;
|
|
|
+ Dim_2 = 1024;
|
|
|
+ Dim_3 = 256;
|
|
|
+ Size = 268435456;
|
|
|
+ */
|
|
|
+
|
|
|
+ const guint32 headsz = 512;
|
|
|
gchar * header = g_strnfill (headsz, ' ');
|
|
|
|
|
|
sprintf(header, "{\nByteOrder = LowByteFirst;\nDataType = FloatValue;\nDim_1 = %i;\nDim_2 = %i;\nDim_3 = %i;\nSize = %li;\n",
|
|
|
- xs, ys, zs, xs*ys*zs*sizeof(float));
|
|
|
+ xs, ys, zs, xs*ys*zs*sizeof(float));
|
|
|
|
|
|
header[510] = '}';
|
|
|
header[511] = '\x0A';
|
|
|
|
|
|
fwrite(header, sizeof(char), headsz, file);
|
|
|
- return TRUE;
|
|
|
+ return TRUE;
|
|
|
}
|
|
|
|
|
|
-static gboolean filter_3d_edf_write_body(FILE * file,
|
|
|
- float * data,
|
|
|
- const guint32 sz)
|
|
|
+static gboolean
|
|
|
+filter_3d_edf_write_body(FILE * file, float * data, const guint32 sz)
|
|
|
{
|
|
|
- fwrite(data, sizeof(float), sz, file);
|
|
|
- return TRUE;
|
|
|
+ fwrite(data, sizeof(float), sz, file);
|
|
|
+ return TRUE;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-static void ufo_filter_3d_edf_writer_process(UfoFilter *self)
|
|
|
+static void
|
|
|
+ufo_filter_3d_edf_writer_consume (UfoFilterSink *self, UfoBuffer *input[], gpointer cmd_queue, GError **error)
|
|
|
{
|
|
|
g_return_if_fail(UFO_IS_FILTER(self));
|
|
|
UfoFilter3DEdfWriterPrivate *priv = UFO_FILTER_3D_EDF_WRITER_GET_PRIVATE(self);
|
|
|
- UfoChannel *input_channel = ufo_filter_get_input_channel(self);
|
|
|
- UfoBuffer *input = ufo_channel_get_input_buffer(input_channel);
|
|
|
- cl_command_queue command_queue = (cl_command_queue) ufo_filter_get_command_queue(self);
|
|
|
g_message("ufo_filter_3d_edf_writer_process");
|
|
|
|
|
|
guint num_dims = 0;
|
|
@@ -98,53 +92,41 @@ static void ufo_filter_3d_edf_writer_process(UfoFilter *self)
|
|
|
guint counter = 0;
|
|
|
GString *filename = g_string_new("");
|
|
|
|
|
|
- while (input != NULL)
|
|
|
- {
|
|
|
- ufo_buffer_get_dimensions(input, &num_dims, &dim_size);
|
|
|
- g_assert(num_dims == 3);
|
|
|
+ ufo_buffer_get_dimensions(input[0], &num_dims, &dim_size);
|
|
|
+ g_assert(num_dims == 3);
|
|
|
|
|
|
- const guint xs = dim_size[0];
|
|
|
- const guint ys = dim_size[1];
|
|
|
- const guint zs = dim_size[2];
|
|
|
+ const guint xs = dim_size[0];
|
|
|
+ const guint ys = dim_size[1];
|
|
|
+ const guint zs = dim_size[2];
|
|
|
|
|
|
- float *data = ufo_buffer_get_host_array(input, command_queue);
|
|
|
+ float *data = ufo_buffer_get_host_array(input[0], (cl_command_queue) cmd_queue);
|
|
|
|
|
|
- g_string_printf(filename, "%s/%s%05i.edf", priv->path, priv->prefix, counter++);
|
|
|
- //if (!filter_write_tiff(data, filename->str, width, height))
|
|
|
- // g_message("something went wrong")
|
|
|
- // write EDF header
|
|
|
- // write raw data
|
|
|
+ g_string_printf(filename, "%s/%s%05i.edf", priv->path, priv->prefix, counter++);
|
|
|
+ //if (!filter_write_tiff(data, filename->str, width, height))
|
|
|
+ // g_message("something went wrong")
|
|
|
+ // write EDF header
|
|
|
+ // write raw data
|
|
|
// temporal saving unless 3d writer is not ready
|
|
|
- FILE * idfile = fopen(filename->str,"wb");
|
|
|
-
|
|
|
- if(!filter_3d_edf_write_header(idfile, xs, ys, zs))
|
|
|
- g_message("cannot write edf header");
|
|
|
+ FILE * idfile = fopen(filename->str,"wb");
|
|
|
|
|
|
- if(!filter_3d_edf_write_body(idfile, data, xs*ys*zs))
|
|
|
- g_message("cannot write data");
|
|
|
+ if (!filter_3d_edf_write_header(idfile, xs, ys, zs))
|
|
|
+ g_message("cannot write edf header");
|
|
|
|
|
|
- fclose(idfile);
|
|
|
-
|
|
|
- ufo_channel_finalize_input_buffer(input_channel, input);
|
|
|
- input = ufo_channel_get_input_buffer(input_channel);
|
|
|
+ if (!filter_3d_edf_write_body(idfile, data, xs*ys*zs))
|
|
|
+ g_message("cannot write data");
|
|
|
|
|
|
- }
|
|
|
+ fclose(idfile);
|
|
|
|
|
|
g_string_free(filename, TRUE);
|
|
|
g_free(dim_size);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-static void ufo_filter_3d_edf_writer_set_property(GObject *object,
|
|
|
- guint property_id,
|
|
|
- const GValue *value,
|
|
|
- GParamSpec *pspec)
|
|
|
+static void
|
|
|
+ufo_filter_3d_edf_writer_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
|
|
|
{
|
|
|
UfoFilter3DEdfWriter *filter = UFO_FILTER_3D_EDF_WRITER(object);
|
|
|
|
|
|
- switch (property_id)
|
|
|
- {
|
|
|
+ switch (property_id) {
|
|
|
case PROP_PATH:
|
|
|
g_free(filter->priv->path);
|
|
|
filter->priv->path = g_strdup(g_value_get_string(value));
|
|
@@ -160,15 +142,12 @@ static void ufo_filter_3d_edf_writer_set_property(GObject *object,
|
|
|
}
|
|
|
|
|
|
|
|
|
-static void ufo_filter_3d_edf_writer_get_property(GObject *object,
|
|
|
- guint property_id,
|
|
|
- GValue *value,
|
|
|
- GParamSpec *pspec)
|
|
|
+static void
|
|
|
+ufo_filter_3d_edf_writer_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
|
|
|
{
|
|
|
UfoFilter3DEdfWriter *filter = UFO_FILTER_3D_EDF_WRITER(object);
|
|
|
|
|
|
- switch (property_id)
|
|
|
- {
|
|
|
+ switch (property_id) {
|
|
|
case PROP_PATH:
|
|
|
g_value_set_string(value, filter->priv->path);
|
|
|
break;
|
|
@@ -181,50 +160,48 @@ static void ufo_filter_3d_edf_writer_get_property(GObject *object,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void ufo_filter_3d_edf_writer_class_init(UfoFilter3DEdfWriterClass *klass)
|
|
|
+static void
|
|
|
+ufo_filter_3d_edf_writer_class_init(UfoFilter3DEdfWriterClass *klass)
|
|
|
{
|
|
|
- UfoFilterClass *filter_class = UFO_FILTER_CLASS(klass);
|
|
|
+ UfoFilterSinkClass *filter_class = UFO_FILTER_SINK_CLASS(klass);
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
|
|
|
|
|
|
gobject_class->set_property = ufo_filter_3d_edf_writer_set_property;
|
|
|
gobject_class->get_property = ufo_filter_3d_edf_writer_get_property;
|
|
|
- filter_class->process = ufo_filter_3d_edf_writer_process;
|
|
|
+ filter_class->consume = ufo_filter_3d_edf_writer_consume;
|
|
|
|
|
|
edfwriter3d_properties[PROP_PREFIX] =
|
|
|
g_param_spec_string("prefix",
|
|
|
- "Filename prefix",
|
|
|
- "Prefix of output filename.",
|
|
|
- "",
|
|
|
- G_PARAM_READWRITE);
|
|
|
+ "Filename prefix",
|
|
|
+ "Prefix of output filename.",
|
|
|
+ "",
|
|
|
+ G_PARAM_READWRITE);
|
|
|
|
|
|
- edfwriter3d_properties[PROP_PATH] =
|
|
|
+ edfwriter3d_properties[PROP_PATH] =
|
|
|
g_param_spec_string("path",
|
|
|
- "File path",
|
|
|
- "Path where to store files.",
|
|
|
- ".",
|
|
|
- G_PARAM_READWRITE);
|
|
|
+ "File path",
|
|
|
+ "Path where to store files.",
|
|
|
+ ".",
|
|
|
+ G_PARAM_READWRITE);
|
|
|
|
|
|
- g_object_class_install_property(gobject_class, PROP_PATH, edfwriter3d_properties[PROP_PATH]);
|
|
|
- g_object_class_install_property(gobject_class, PROP_PREFIX, edfwriter3d_properties[PROP_PREFIX]);
|
|
|
-
|
|
|
- g_type_class_add_private(gobject_class, sizeof(UfoFilter3DEdfWriterPrivate));
|
|
|
+ g_object_class_install_property(gobject_class, PROP_PATH, edfwriter3d_properties[PROP_PATH]);
|
|
|
+ g_object_class_install_property(gobject_class, PROP_PREFIX, edfwriter3d_properties[PROP_PREFIX]);
|
|
|
|
|
|
+ g_type_class_add_private(gobject_class, sizeof(UfoFilter3DEdfWriterPrivate));
|
|
|
}
|
|
|
|
|
|
-static void ufo_filter_3d_edf_writer_init(UfoFilter3DEdfWriter *self)
|
|
|
+static void
|
|
|
+ufo_filter_3d_edf_writer_init (UfoFilter3DEdfWriter *self)
|
|
|
{
|
|
|
self->priv = UFO_FILTER_3D_EDF_WRITER_GET_PRIVATE(self);
|
|
|
self->priv->path = g_strdup(".");
|
|
|
self->priv->prefix = NULL;
|
|
|
|
|
|
- ufo_filter_register_input(UFO_FILTER(self), "volume", 3);
|
|
|
+ ufo_filter_register_inputs (UFO_FILTER (self), 3, NULL);
|
|
|
}
|
|
|
|
|
|
-G_MODULE_EXPORT UfoFilter *ufo_filter_plugin_new(void)
|
|
|
+G_MODULE_EXPORT
|
|
|
+UfoFilter *ufo_filter_plugin_new(void)
|
|
|
{
|
|
|
return g_object_new(UFO_TYPE_FILTER_3D_EDF_WRITER, NULL);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|