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 int (*is_point_in_region)(struct gmi_model* m, struct gmi_ent* e,
00098 double p[3]);
00100 int (*is_in_closure_of)(struct gmi_model* m, struct gmi_ent* e,
00101 struct gmi_ent* et);
00103 int (*is_discrete_ent)(struct gmi_model* m, struct gmi_ent* e);
00105 void (*destroy)(struct gmi_model* m);
00106 };
00107
00109 struct gmi_model {
00111 struct gmi_model_ops const* ops;
00113 int n[4];
00114 };
00115
00117 typedef struct gmi_model* (*gmi_creator)(const char* filename);
00118
00119 #ifdef __cplusplus
00120 extern "C" {
00121 #endif
00122
00124 struct gmi_set* gmi_make_set(int n);
00126 void gmi_free_set(struct gmi_set* s);
00127
00130 struct gmi_iter* gmi_begin(struct gmi_model* m, int dim);
00133 struct gmi_ent* gmi_next(struct gmi_model* m, struct gmi_iter* i);
00135 void gmi_end(struct gmi_model* m, struct gmi_iter* i);
00137 int gmi_dim(struct gmi_model* m, struct gmi_ent* e);
00139 int gmi_tag(struct gmi_model* m, struct gmi_ent* e);
00141 struct gmi_ent* gmi_find(struct gmi_model* m, int dim, int tag);
00145 struct gmi_set* gmi_adjacent(struct gmi_model* m, struct gmi_ent* e, int dim);
00147 int gmi_can_eval(struct gmi_model* m);
00153 void gmi_eval(struct gmi_model* m, struct gmi_ent* e,
00154 double const p[2], double x[3]);
00162 void gmi_reparam(struct gmi_model* m, struct gmi_ent* from,
00163 double const from_p[2], struct gmi_ent* to, double to_p[2]);
00165 int gmi_periodic(struct gmi_model* m, struct gmi_ent* e, int dim);
00167 void gmi_range(struct gmi_model* m, struct gmi_ent* e, int dim,
00168 double r[2]);
00170 void gmi_closest_point(struct gmi_model* m, struct gmi_ent* e,
00171 double const from[3], double to[3], double to_p[2]);
00173 void gmi_normal(struct gmi_model* m, struct gmi_ent* e,
00174 double const p[2], double n[3]);
00176 void gmi_first_derivative(struct gmi_model* m, struct gmi_ent* e,
00177 double const p[2], double t0[3], double t1[3]);
00179 int gmi_is_point_in_region(struct gmi_model* m, struct gmi_ent* e,
00180 double point[3]);
00182 int gmi_is_in_closure_of(struct gmi_model* m, struct gmi_ent* e,
00183 struct gmi_ent* et);
00185 int gmi_is_discrete_ent(struct gmi_model* m, struct gmi_ent* e);
00187 void gmi_destroy(struct gmi_model* m);
00188
00198 void gmi_register(gmi_creator f, const char* ext);
00205 struct gmi_model* gmi_load(const char* filename);
00206
00214 void gmi_write_dmg(struct gmi_model* m, const char* filename);
00215
00218 void gmi_fail(const char* why) __attribute__((noreturn));
00219
00225 void gmi_fscanf(FILE* f, int n, const char* format, ...);
00226
00227 int gmi_getline(char** line, size_t* cap, FILE* f);
00228 int gmi_has_ext(const char* filename, const char* ext);
00229
00230 #ifdef __cplusplus
00231 }
00232 #endif
00233
00234 #endif