00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef GMI_H
00011 #define GMI_H
00012
00027 #include <stdio.h>
00028
00029 struct gmi_ent;
00030
00031 struct gmi_iter;
00032
00033 struct gmi_model;
00034
00038 struct gmi_set {
00040 int n;
00044 struct gmi_ent* e[1];
00045 };
00046
00059 struct gmi_model_ops {
00061 struct gmi_iter* (*begin)(struct gmi_model* m, int dim);
00063 struct gmi_ent* (*next)(struct gmi_model* m, struct gmi_iter* i);
00065 void (*end)(struct gmi_model* m, struct gmi_iter* i);
00067 int (*dim)(struct gmi_model* m, struct gmi_ent* e);
00069 int (*tag)(struct gmi_model* m, struct gmi_ent* e);
00071 struct gmi_ent* (*find)(struct gmi_model* m, int dim, int tag);
00074 struct gmi_set* (*adjacent)(struct gmi_model* m, struct gmi_ent* e, int dim);
00077 void (*eval)(struct gmi_model* m, struct gmi_ent* e,
00078 double const p[2], double x[3]);
00080 void (*reparam)(struct gmi_model* m, struct gmi_ent* from,
00081 double const from_p[2], struct gmi_ent* to, double to_p[2]);
00083 int (*periodic)(struct gmi_model* m, struct gmi_ent* e, int dim);
00085 void (*range)(struct gmi_model* m, struct gmi_ent* e, int dim,
00086 double r[2]);
00088 void (*closest_point)(struct gmi_model* m, struct gmi_ent* e,
00089 double const from[3], double to[3], double to_p[2]);
00091 void (*normal)(struct gmi_model* m, struct gmi_ent* e,
00092 double const p[2], double n[3]);
00094 void (*first_derivative)(struct gmi_model* m, struct gmi_ent* e,
00095 double const p[2], double t0[3], double t1[3]);
00097 void (*destroy)(struct gmi_model* m);
00098 };
00099
00101 struct gmi_model {
00103 struct gmi_model_ops const* ops;
00105 int n[4];
00106 };
00107
00109 typedef struct gmi_model* (*gmi_creator)(const char* filename);
00110
00111 #ifdef __cplusplus
00112 extern "C" {
00113 #endif
00114
00116 struct gmi_set* gmi_make_set(int n);
00118 void gmi_free_set(struct gmi_set* s);
00119
00122 struct gmi_iter* gmi_begin(struct gmi_model* m, int dim);
00125 struct gmi_ent* gmi_next(struct gmi_model* m, struct gmi_iter* i);
00127 void gmi_end(struct gmi_model* m, struct gmi_iter* i);
00129 int gmi_dim(struct gmi_model* m, struct gmi_ent* e);
00131 int gmi_tag(struct gmi_model* m, struct gmi_ent* e);
00133 struct gmi_ent* gmi_find(struct gmi_model* m, int dim, int tag);
00137 struct gmi_set* gmi_adjacent(struct gmi_model* m, struct gmi_ent* e, int dim);
00139 int gmi_can_eval(struct gmi_model* m);
00145 void gmi_eval(struct gmi_model* m, struct gmi_ent* e,
00146 double const p[2], double x[3]);
00154 void gmi_reparam(struct gmi_model* m, struct gmi_ent* from,
00155 double const from_p[2], struct gmi_ent* to, double to_p[2]);
00157 int gmi_periodic(struct gmi_model* m, struct gmi_ent* e, int dim);
00159 void gmi_range(struct gmi_model* m, struct gmi_ent* e, int dim,
00160 double r[2]);
00162 void gmi_closest_point(struct gmi_model* m, struct gmi_ent* e,
00163 double const from[3], double to[3], double to_p[2]);
00165 void gmi_normal(struct gmi_model* m, struct gmi_ent* e,
00166 double const p[2], double n[3]);
00168 void gmi_first_derivative(struct gmi_model* m, struct gmi_ent* e,
00169 double const p[2], double t0[3], double t1[3]);
00171 void gmi_destroy(struct gmi_model* m);
00172
00182 void gmi_register(gmi_creator f, const char* ext);
00189 struct gmi_model* gmi_load(const char* filename);
00190
00198 void gmi_write_dmg(struct gmi_model* m, const char* filename);
00199
00202 void gmi_fail(const char* why) __attribute__((noreturn));
00203
00209 void gmi_fscanf(FILE* f, int n, const char* format, ...);
00210
00211 int gmi_getline(char** line, size_t* cap, FILE* f);
00212 int gmi_has_ext(const char* filename, const char* ext);
00213
00214 #ifdef __cplusplus
00215 }
00216 #endif
00217
00218 #endif