[contrib][haskell] Hkl.Xrd.OneD
[hkl.git] / hkl3d / hkl3d.h
blob2f8005b1f17d395eae1db33d057065f358521137
1 /* This file is part of the hkl3d library.
3 * The hkl library is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * The hkl library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with the hkl library. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright (C) 2010-2017 Synchrotron SOLEIL
17 * L'Orme des Merisiers Saint-Aubin
18 * BP 48 91192 GIF-sur-YVETTE CEDEX
20 * Authors: Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>
21 * Oussama SBOUI <oussama.sboui@synchrotron-soleil.fr>
24 #ifndef __HKL3D_H__
25 #define __HKL3D_H__
27 #include <g3d/types.h>
28 #include "hkl.h"
30 // forward declaration due to bullet static linking
31 struct btCollisionObject;
32 struct btCollisionWorld;
33 struct btCollisionConfiguration;
34 struct btBroadphaseInterface;
35 struct btCollisionDispatcher;
36 struct btCollisionShape;
37 struct btVector3;
38 struct btTriangleMesh;
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
44 typedef struct _Hkl3DStats Hkl3DStats;
45 typedef struct _Hkl3DObject Hkl3DObject;
46 typedef struct _Hkl3DModel Hkl3DModel;
47 typedef struct _Hkl3DConfig Hkl3DConfig;
48 typedef struct _Hkl3DAxis Hkl3DAxis;
49 typedef struct _Hkl3DGeometry Hkl3DGeometry;
50 typedef struct _Hkl3D Hkl3D;
52 /**************/
53 /* Hkl3DStats */
54 /**************/
56 struct _Hkl3DStats
58 struct timeval collision;
59 struct timeval transformation;
62 extern double hkl3d_stats_get_collision_ms(const Hkl3DStats *self);
63 extern void hkl3d_stats_fprintf(FILE *f, Hkl3DStats *self);
65 /***************/
66 /* Hkl3DObject */
67 /***************/
69 struct _Hkl3DObject
71 Hkl3DModel *model; /* weak reference */
72 int id;
73 Hkl3DAxis *axis; /* weak reference */
74 G3DObject *g3d; /* weak reference */
75 struct btCollisionObject *btObject;
76 struct btCollisionShape *btShape;
77 struct btTriangleMesh *meshes;
78 struct btVector3 *color;
79 int is_colliding;
80 int hide;
81 int added;
82 int selected;
83 int movable;
84 char *axis_name;
85 float transformation[16];
88 extern void hkl3d_object_aabb_get(const Hkl3DObject *self, float from[3], float to[3]);
89 extern void hkl3d_object_fprintf(FILE *f, const Hkl3DObject *self);
91 /**************/
92 /* Hkl3DModel */
93 /**************/
95 struct _Hkl3DModel
97 char *filename;
98 G3DModel *g3d;
99 Hkl3DObject **objects;
100 size_t len;
103 extern void hkl3d_model_fprintf(FILE *f, const Hkl3DModel *self);
105 /***************/
106 /* Hkl3DConfig */
107 /***************/
109 struct _Hkl3DConfig
111 Hkl3DModel **models;
112 size_t len;
115 extern void hkl3d_config_fprintf(FILE *f, const Hkl3DConfig *self);
117 /*************/
118 /* Hkl3DAxis */
119 /*************/
121 struct _Hkl3DAxis
123 Hkl3DObject **objects; /* connected object */
124 size_t len;
127 /*****************/
128 /* HKL3DGeometry */
129 /*****************/
131 struct _Hkl3DGeometry
133 HklGeometry *geometry; /* weak reference */
134 Hkl3DAxis **axes;
137 /*********/
138 /* HKL3D */
139 /*********/
141 struct _Hkl3D
143 char const *filename; /* config filename */
144 Hkl3DGeometry *geometry;
145 G3DModel *model;
146 Hkl3DStats stats;
147 Hkl3DConfig *config;
149 struct btCollisionConfiguration *_btCollisionConfiguration;
150 struct btBroadphaseInterface *_btBroadphase;
151 struct btCollisionWorld *_btWorld;
152 struct btCollisionDispatcher *_btDispatcher;
153 #ifdef USE_PARALLEL_DISPATCHER
154 struct btThreadSupportInterface *_btThreadSupportInterface;
155 #endif
158 extern Hkl3D* hkl3d_new(const char *filename, HklGeometry *geometry);
159 extern void hkl3d_free(Hkl3D *self);
161 extern int hkl3d_is_colliding(Hkl3D *self);
162 extern void hkl3d_load_config(Hkl3D *self, const char *filename);
163 extern void hkl3d_save_config(Hkl3D *self, const char *filename);
164 extern Hkl3DModel *hkl3d_add_model_from_file(Hkl3D *self,
165 const char *filename, const char *directory);
167 extern void hkl3d_connect_all_axes(Hkl3D *self);
168 extern void hkl3d_hide_object(Hkl3D *self, Hkl3DObject *object, int hide);
169 extern void hkl3d_remove_object(Hkl3D *self, Hkl3DObject *object);
171 extern void hkl3d_get_bounding_boxes(Hkl3D *self,
172 struct btVector3 *min, struct btVector3 *max);
173 extern int hkl3d_get_nb_manifolds(Hkl3D *self);
174 extern int hkl3d_get_nb_contacts(Hkl3D *self, int manifold);
175 extern void hkl3d_get_collision_coordinates(Hkl3D *self, int manifold, int contact,
176 double *xa, double *ya, double *za,
177 double *xb, double *yb, double *zb);
178 extern void hkl3d_connect_object_to_axis(Hkl3D *self,
179 Hkl3DObject *object, const char *name);
181 extern void hkl3d_fprintf(FILE *f, const Hkl3D *self);
183 #ifdef __cplusplus
185 #endif
187 #endif