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-2019 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>
27 #include <g3d/types.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
;
38 struct btTriangleMesh
;
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
;
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
);
71 Hkl3DModel
*model
; /* weak reference */
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
;
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
);
99 Hkl3DObject
**objects
;
103 extern void hkl3d_model_fprintf(FILE *f
, const Hkl3DModel
*self
);
115 extern void hkl3d_config_fprintf(FILE *f
, const Hkl3DConfig
*self
);
123 Hkl3DObject
**objects
; /* connected object */
131 struct _Hkl3DGeometry
133 HklGeometry
*geometry
; /* weak reference */
143 char const *filename
; /* config filename */
144 Hkl3DGeometry
*geometry
;
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
;
158 HKLAPI
extern Hkl3D
* hkl3d_new(const char *filename
, HklGeometry
*geometry
) HKL_ARG_NONNULL(2);
159 HKLAPI
extern void hkl3d_free(Hkl3D
*self
) HKL_ARG_NONNULL(1);
161 HKLAPI
extern int hkl3d_is_colliding(Hkl3D
*self
) HKL_ARG_NONNULL(1);
162 HKLAPI
extern void hkl3d_load_config(Hkl3D
*self
, const char *filename
) HKL_ARG_NONNULL(1, 2);
163 HKLAPI
extern void hkl3d_save_config(Hkl3D
*self
, const char *filename
) HKL_ARG_NONNULL(1, 2);
164 HKLAPI
extern Hkl3DModel
*hkl3d_add_model_from_file(Hkl3D
*self
,
165 const char *filename
,
166 const char *directory
) HKL_ARG_NONNULL(1, 2, 3);
168 HKLAPI
extern void hkl3d_connect_all_axes(Hkl3D
*self
) HKL_ARG_NONNULL(1);
169 HKLAPI
extern void hkl3d_hide_object(Hkl3D
*self
, Hkl3DObject
*object
, int hide
) HKL_ARG_NONNULL(1, 2);
170 HKLAPI
extern void hkl3d_remove_object(Hkl3D
*self
, Hkl3DObject
*object
) HKL_ARG_NONNULL(1, 2);
172 HKLAPI
extern void hkl3d_get_bounding_boxes(Hkl3D
*self
,
173 struct btVector3
*min
,
174 struct btVector3
*max
) HKL_ARG_NONNULL(1, 2, 3);
175 HKLAPI
extern int hkl3d_get_nb_manifolds(Hkl3D
*self
) HKL_ARG_NONNULL(1);
176 HKLAPI
extern int hkl3d_get_nb_contacts(Hkl3D
*self
, int manifold
) HKL_ARG_NONNULL(1);
177 HKLAPI
extern void hkl3d_get_collision_coordinates(Hkl3D
*self
, int manifold
, int contact
,
178 double *xa
, double *ya
, double *za
,
179 double *xb
, double *yb
, double *zb
) HKL_ARG_NONNULL(1);
180 HKLAPI
extern void hkl3d_connect_object_to_axis(Hkl3D
*self
,
182 const char *name
) HKL_ARG_NONNULL(1, 2, 3);
184 HKLAPI
extern void hkl3d_fprintf(FILE *f
, const Hkl3D
*self
) HKL_ARG_NONNULL(1, 2);