sphore 0.0.1
SPH openGL rendering engine

src/sphore.c File Reference

Access ports into the sphore library. More...

#include "settings.h"
#include "render.h"
#include "sphore.h"
#include "data-points.h"
#include "data-lines.h"
#include "data-column-int.h"
#include "warning.h"
#include "glut-device.h"

Defines

#define DEFAULT_WIDTH   512
 The default width of a device in pixels.
#define DEFAULT_HEIGHT   512
 The default height of a device in pixels.

Functions

SREbool SRE_open_device (SREdeviceType type)
 Creates a new SRE device.
void SRE_close_device ()
 frees the memory associated with the open device.
void SRE_enter_main_loop ()
 Enters the main interactive loop.
void SRE_get_device_size (unsigned int *width, unsigned int *height)
 Gets the size of the current device.
void SRE_set_device_size (unsigned int width, unsigned int height)
 Adds the given data to the currently selected device.
void SRE_render_column_int (unsigned int n, float *x, float *y, float *z, float *h, float *weight, float *data, float data_min, float data_max)
 Renders the given SPH data by performing column integrals through the data.
void SRE_plot_points (unsigned int n, float *x, float *y, float *z)
 Add data to be drawn as points.
void SRE_plot_line (int n, float *x, float *y, float *z)
 Plots the line consisting of straight segments connecting the given control points.
SREbool SRE_device_open (void)
SREbool SRE_set_camera_position (float x, float y, float z)
 Set the absolute position of the camera (i.e. in the same coordinate system as the data).
SREbool SRE_translate_camera (float x, float y, float z)
 Translates the camera by the vector provided.
SREbool SRE_set_colour (float red, float green, float blue)
 Sets the colour to be used for subsequent calls to SRE_plot_points and SRE_plot_line.
SREbool SRE_set_viewing_volume (float width, float height, float depth)
 Set the volume in front of the camera in which data is to be rendered.
void SRE_get_viewing_volume (float *width, float *height, float *depth)
 Get the current viewing volume.
void SRE_set_colour_ramp (int n, float *controlPoints, float *red, float *green, float *blue)

Detailed Description

Access ports into the sphore library.


Define Documentation

#define DEFAULT_HEIGHT   512

The default height of a device in pixels.

#define DEFAULT_WIDTH   512

The default width of a device in pixels.


Function Documentation

void SRE_close_device ( )

frees the memory associated with the open device.

Need to free lists of data!

SREbool SRE_device_open ( void  )

Query if a device is currently open.

Returns:
SRE_TRUE if a device is open, SRE_FALSE otherwise.
void SRE_enter_main_loop ( void  )

Enters the main interactive loop.

void SRE_get_device_size ( unsigned int *  width,
unsigned int *  height 
)

Gets the size of the current device.

SREdataID SRE_add_data (unsigned int n, float *x, float *y, float *z, float *h, float *data) { if (device_open == SRE_FALSE) { print_warning ("SRE_add_data", "No device open."); return SRE_DATA_ID_INVALID; } data_t *new_data = data_create (n, x, y, z, h, data); return (SREdataID) list_add_first (current_device->data, new_data); } SREbool SRE_remove_data (SREdataID id) { if (device_open == SRE_FALSE) { print_warning ("SRE_add_data", "No device open."); return SRE_FALSE; }

return list_remove_data (current_device->data, id, data_destroy); } SREbool SRE_use_data (SREdataID id) { if (device_open == SRE_FALSE) return SRE_FALSE;

find the data list_iterator_t *it = list_iterator_create (current_device->data); if (list_iterator_find (it, id) == SRE_FALSE) { Not found list_iterator_destroy (it); return SRE_FALSE; }

Update the current plots data pointer plot_set_data (device_get_current_plot (current_device), list_iterator_get_data (it)); return SRE_TRUE; }

void SRE_get_viewing_volume ( float *  width,
float *  height,
float *  depth 
)

Get the current viewing volume.

Parameters:
[out]widthGets set to the width of the viewing volume.
[out]heightGets set to the height of the viewing volume.
[out]depthGets set to the depth of the viewing volume.
SREbool SRE_open_device ( SREdeviceType  type)

Creates a new SRE device.

Currently sphore only supports a single device open at a time. If you try to open a second device the call will be ignored.

Parameters:
[in]typeThe type of device to be opened.
Returns:
The success of the device creation.
void SRE_plot_line ( int  n,
float *  x,
float *  y,
float *  z 
)

Plots the line consisting of straight segments connecting the given control points.

Parameters:
[in]nThe number of control points.
[in]xThe x coordinates of the control points.
[in]yThe y coordinates of the control points.
[in]zThe z coordinates of the control points.
void SRE_plot_points ( unsigned int  n,
float *  x,
float *  y,
float *  z 
)

Add data to be drawn as points.

The colour of the points is determined by the most recent call to SRE_set_colour.

Parameters:
[in]nThe number of points
[in]xThe x coordinate of each point.
[in]yThe y coordinate of each point.
[in]zThe z coordinate of each point.
void SRE_render_column_int ( unsigned int  n,
float *  x,
float *  y,
float *  z,
float *  h,
float *  weight,
float *  data,
float  data_min,
float  data_max 
)

Renders the given SPH data by performing column integrals through the data.

Parameters:
[in]nThe number of particles.
[in]xThe x coordinates of the particles.
[in]yThe y coordinates of the particles.
[in]zThe z coordinates of the particles.
[in]hThe smoothing lengths of the particle.
[in]weightThe 'weight' of the particles - should be pmass / (rho*h^3).
[in]dataThe value of the quantity being smoothed at each particle.
[in]data_minThe value of data that will be assigned the lowest position on the colour ramp.
[in]data_maxThe value of data that will be assigned the highest position on the colour ramp.
SREbool SRE_set_camera_position ( float  x,
float  y,
float  z 
)

Set the absolute position of the camera (i.e. in the same coordinate system as the data).

Parameters:
[in]xThe x coordinate of the camera.
[in]yThe y coordinate of the camera.
[in]zThe z coordinate of the camera.
Returns:
The success of the repositioning of the camera.
SREbool SRE_set_colour ( float  red,
float  green,
float  blue 
)

Sets the colour to be used for subsequent calls to SRE_plot_points and SRE_plot_line.

Parameters:
[in]redThe red component of the colour.
[in]greenThe green component of the colour.
[in]blueThe blue component of the colour.
void SRE_set_colour_ramp ( int  n,
float *  controlPoints,
float *  red,
float *  green,
float *  blue 
)
void SRE_set_device_size ( unsigned int  width,
unsigned int  height 
)

Adds the given data to the currently selected device.

Makes a copy of the data, so your original copy can be destroyed.

Parameters:
[in]nthe number of points.
[in]xthe x coordinantes of the points.
[in]ythe y coordinantes of the points.
[in]zthe z coordinantes of the points.
[in]hthe smoothing length of the particles.
[in]datathe value of the data at each point.
Returns:
The ID of the new data SREdataID SRE_add_data (unsigned int n, float *x, float *y, float *z, float *h, float *data); Destroys the data associated to id from the current device, freeing the used memory.
Parameters:
[in]idThe id of the data to be deleted.
Returns:
The success of the deletion. Sets the current plot to use the given data.
Parameters:
[in]idThe id of the data to use.
Returns:
If the plot was updated successfully. Sets the size of the current device. THIS NEEDS TO BE IMPLEMENTED!
Parameters:
[in]widthThe new width of the device in pixels.
[in]heightThe new height of the device in pixels.
SREbool SRE_set_viewing_volume ( float  width,
float  height,
float  depth 
)

Set the volume in front of the camera in which data is to be rendered.

Parameters:
[in]widthThe new width for the volume.
[in]heightThe new height for the volume.
[in]depthThe new depth for the viewing volume.
Returns:
The success of setting the new volume.
SREbool SRE_translate_camera ( float  x,
float  y,
float  z 
)

Translates the camera by the vector provided.

The translation is in the frame of reference of the camera.

Parameters:
[in]xThe x coordinate of the translation.
[in]yThe y coordinate of the translation.
[in]zThe z coordinate of the translation.
Returns:
The success of the translation.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines