71# define DISPLAY_JS "http://basilisk.ida.upmc.fr/three.js/editor/index.html"
75# define DISPLAY_HOST "localhost"
79# define DISPLAY_RANGE "7100:7200"
82#define debug(...) do { if (Display.debug) fprintf (qerr, __VA_ARGS__), fflush(qerr); } while(0)
85#include <wsServer/include/ws.h>
86#pragma autolink -L$BASILISK/wsServer -lws
108 debug (
"**************************\n");
120 debug (
"--------------------------\n");
173 if (len > 0 &&
Display.error[len - 1] ==
'\n')
197 debug (
"position: %ld, normal: %ld, color: %ld, index: %ld, type: %d\n",
206 unsigned int * shift)
214 p =
a->p, len =
a->len;
226 shift[
pe] = (
pe > 0 ? shift[
pe - 1] : 0) + len/(3*
sizeof(
float));
227 else if (
type == 1 &&
pe > 0)
228 for (
unsigned int i = 0;
i < len/
sizeof(
unsigned int);
i++)
229 ((
unsigned int *)
p)[
i] += shift[
pe - 1];
276 len += 2*
sizeof(
int) +
282 ws_send (fd, &
errorlen,
sizeof(
unsigned int)) <
sizeof(
unsigned int) ||
295 if (pid() == 0 &&
status >= 0 &&
300 if (pid() == 0 &&
status >= 0 &&
303 ws_send (fd,
glens, 4*
sizeof (
unsigned int)) < 4*
sizeof (
unsigned int)))
305 unsigned int * shift =
malloc (
sizeof(
unsigned int)*
npe());
348#define JSON_BUILD(...) len += snprintf (build + len, 4096, __VA_ARGS__), \
349 build = realloc (build, len + 4096)
358 debug (
"array_remove(): error! found multiple %d in '%s'\n",
365 debug (
"array_remove(): error! could not find %d in '%s'\n",
373 for (
int j =
i;
j < len;
j++)
382 debug (
"display_remove(): error! could not find '%s' (%d)\n",
409 JSON_BUILD (
"\"type\": \"int\", \"value\": %d, \"min\": %g, \"max\": %g",
410 *((
int *)
d->ptr),
d->min,
d->max);
413 JSON_BUILD (
"\"type\": \"double\", \"value\": %g, "
414 "\"min\": %g, \"max\": %g",
415 *((
double *)
d->ptr),
d->min,
d->max);
437 char * name =
NULL,
char * tooltip =
NULL,
461#undef display_control
462#define display_control(val, ...) display_control_internal \
463 (&(val), __VA_ARGS__, size = sizeof(val), ptr_name = #val)
471 debug (
"display_control_update(): error! could not find '%s' (%d)\n",
479 case 4: *((
int *)
d->ptr) =
val;
break;
480 case 8: *((
double *)
d->ptr) =
val;
break;
514 debug (
"closing %d\n", fd);
527 else switch (
msg[0]) {
532 "display_onmessage: error: unknown message type '%s'\n",
538 fprintf (
stderr,
"display_onmessage: error: unexpected message type '%d'\n",
616 while (
msg &&
msg->fd >= 0) {
633 msg->msg[
msg->size] =
'\0';
673 while (
msg &&
msg->fd >= 0) {
705 "src/display.h:%d: warning: gethostbyname(\"%s\") returned NULL\n",
765 sprintf (
s,
"display(): could not open port '%s'",
port);
774 fputs (
"<head><meta http-equiv=\"refresh\" content=\"0;URL=",
fp);
791#ifndef DISPLAY_NO_CONTROLS
793 "maximum % of runtime used by display");
void array_free(Array *a)
void * array_append(Array *a, void *elem, size_t size)
if TRASH define &&NewPid *& val(newpid, 0, 0, 0)) -> pid > 0) @else @ define is_newpid()(((NewPid *)&val(newpid, 0, 0, 0)) ->pid > 0) @endif Array *linear_tree(size_t size, scalar newpid)
void free_solver_func_add(free_solver_func func)
double timer_elapsed(timer t)
static char * display_defaults
static number clamp(number x, number a, number b)
define sysmalloc malloc define syscalloc calloc define sysrealloc realloc define sysfree free define systrdup strdup define line line line line type
define sysmalloc malloc define syscalloc calloc define sysrealloc realloc define sysfree free define systrdup strdup define line calloc(n, s) @ define prealloc(p
define sysmalloc malloc define syscalloc calloc define sysrealloc realloc define sysfree free define systrdup strdup define line line realloc(p, s) @ define pfree(p
define sysmalloc malloc define syscalloc calloc define sysrealloc realloc define sysfree free define systrdup strdup define line line line line strdup(s) @ define tracing(...) @ define end_tracing(...) @define tid() 0 @define pid() 0 @define npe() 1 @define mpi_all_reduce(v
static int display_send(const char *command, int fd)
void display_url(FILE *fp)
static void display_command(const char *command)
void event_refresh_display(void)
Event: refresh_display (i++, last)
static void display_display()
init_solver void display_init()
static void display_control_update(const char *command, int fd)
static DisplayControl * display_control_lookup(const char *name)
void display_onopen(int fd)
static void display_destroy()
static char * read_file_into_buffer(FILE *fp)
void display_onmessage(int fd, const char *msg, size_t size, int type)
#define display_control(val,...)
void display_onclose(int fd)
static int ws_send_array(int fd, Array *a, int status, int type, unsigned int *shift)
int display_poll(int timeout)
static void display_update(int i)
static char * display_control_json()
static void array_remove(khiter_t k, int fd)
static char * bview_interface_json()
void display_control_internal(void *ptr, double min, double max, char *name=NULL, char *tooltip=NULL, char *ptr_name, int size)
static void display_add(const char *command, int fd)
static void display_remove(const char *command, int fd)
struct @2 bview_interface[]
int(* json)(char *s, int len)
*cs[i, 0, 0] a *[i -1, 0, 0] j
#define kh_del(name, h, k)
#define KHASH_MAP_INIT_STR(name, khval_t)
#define kh_get(name, h, k)
#define kh_destroy(name, h)
#define kh_put(name, h, k, r)
define n sizeof(Cell))) @define fine(a
void vertex_buffer_free()
void vertex_buffer_setup()
bool process_line(char *line)