1 /*   EXTRAITS DE LA LICENCE
2 	Copyright CEA, contributeurs : Luc BILLARD et Damien
3 	CALISTE, laboratoire L_Sim, (2001-2005)
4 
5 	Adresse mèl :
6 	BILLARD, non joignable par mèl ;
7 	CALISTE, damien P caliste AT cea P fr.
8 
9 	Ce logiciel est un programme informatique servant à visualiser des
10 	structures atomiques dans un rendu pseudo-3D.
11 
12 	Ce logiciel est régi par la licence CeCILL soumise au droit français et
13 	respectant les principes de diffusion des logiciels libres. Vous pouvez
14 	utiliser, modifier et/ou redistribuer ce programme sous les conditions
15 	de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
16 	sur le site "http://www.cecill.info".
17 
18 	Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
19 	pris connaissance de la licence CeCILL, et que vous en avez accepté les
20 	termes (cf. le fichier Documentation/licence.fr.txt fourni avec ce logiciel).
21 */
22 
23 /*   LICENCE SUM UP
24 	Copyright CEA, contributors : Luc BILLARD et Damien
25 	CALISTE, laboratoire L_Sim, (2001-2005)
26 
27 	E-mail address:
28 	BILLARD, not reachable any more ;
29 	CALISTE, damien P caliste AT cea P fr.
30 
31 	This software is a computer program whose purpose is to visualize atomic
32 	configurations in 3D.
33 
34 	This software is governed by the CeCILL  license under French law and
35 	abiding by the rules of distribution of free software.  You can  use,
36 	modify and/ or redistribute the software under the terms of the CeCILL
37 	license as circulated by CEA, CNRS and INRIA at the following URL
38 	"http://www.cecill.info".
39 
40 	The fact that you are presently reading this means that you have had
41 	knowledge of the CeCILL license and that you accept its terms. You can
42 	find a copy of this licence shipped with this software at Documentation/licence.en.txt.
43 */
44 #ifndef VISU_BOX_H
45 #define VISU_BOX_H
46 
47 #include <glib.h>
48 #include <glib-object.h>
49 
50 #include "visu_tools.h"
51 #include "coreTools/toolMatrix.h"
52 #include "coreTools/toolPhysic.h"
53 
54 G_BEGIN_DECLS
55 
56 /**
57  * VISU_TYPE_BOX:
58  *
59  * return the type of #VisuBox.
60  */
61 #define VISU_TYPE_BOX	     (visu_box_get_type ())
62 /**
63  * VISU_BOX:
64  * @obj: a #GObject to cast.
65  *
66  * Cast the given @obj into #VisuBox type.
67  */
68 #define VISU_BOX(obj)	        (G_TYPE_CHECK_INSTANCE_CAST(obj, VISU_TYPE_BOX, VisuBox))
69 /**
70  * VISU_BOX_CLASS:
71  * @klass: a #GObjectClass to cast.
72  *
73  * Cast the given @klass into #VisuBoxClass.
74  */
75 #define VISU_BOX_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST(klass, VISU_TYPE_BOX, VisuBoxClass))
76 /**
77  * VISU_IS_BOX:
78  * @obj: a #GObject to test.
79  *
80  * Test if the given @ogj is of the type of #VisuBox object.
81  */
82 #define VISU_IS_BOX(obj)    (G_TYPE_CHECK_INSTANCE_TYPE(obj, VISU_TYPE_BOX))
83 /**
84  * VISU_IS_BOX_CLASS:
85  * @klass: a #GObjectClass to test.
86  *
87  * Test if the given @klass is of the type of #VisuBoxClass class.
88  */
89 #define VISU_IS_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE(klass, VISU_TYPE_BOX))
90 /**
91  * VISU_BOX_GET_CLASS:
92  * @obj: a #GObject to get the class of.
93  *
94  * It returns the class of the given @obj.
95  */
96 #define VISU_BOX_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS(obj, VISU_TYPE_BOX, VisuBoxClass))
97 
98 typedef struct _VisuBoxClass VisuBoxClass;
99 typedef struct _VisuBox VisuBox;
100 typedef struct _VisuBoxPrivate VisuBoxPrivate;
101 
102 /**
103  * visu_box_get_type:
104  *
105  * This method returns the type of #VisuBox, use VISU_TYPE_BOX instead.
106  *
107  * Returns: the type of #VisuBox.
108  */
109 GType visu_box_get_type(void);
110 
111 /**
112  * VisuBox:
113  *
114  * Opaque structure to stores #VisuBox object.
115  */
116 struct _VisuBox
117 {
118   VisuObject parent;
119 
120   VisuBoxPrivate *priv;
121 };
122 
123 /**
124  * VisuBoxClass:
125  * @parent: private.
126  *
127  * Class structure of #VisuBox objects.
128  */
129 struct _VisuBoxClass
130 {
131   VisuObjectClass parent;
132 };
133 
134 /**
135  * VisuBoxVector:
136  * @VISU_BOX_DXX: x box vector along X;
137  * @VISU_BOX_DYX: y box vector along X;
138  * @VISU_BOX_DYY: y box vector along Y;
139  * @VISU_BOX_DZX: z box vector along X;
140  * @VISU_BOX_DZY: z box vector along Y;
141  * @VISU_BOX_DZZ: z box vector along Z;
142  * @VISU_BOX_N_VECTORS: number of elements.
143  *
144  * Identifier of every projection of the box super-cell on an
145  * orthogonal basis-set.
146  *
147  * Since: 3.7
148  **/
149 typedef enum
150   {
151     VISU_BOX_DXX,
152     VISU_BOX_DYX,
153     VISU_BOX_DYY,
154     VISU_BOX_DZX,
155     VISU_BOX_DZY,
156     VISU_BOX_DZZ,
157     VISU_BOX_N_VECTORS
158   } VisuBoxVector;
159 
160 /**
161  * VisuBoxBoundaries:
162  * @VISU_BOX_PERIODIC: the full 3D periodicity ;
163  * @VISU_BOX_SURFACE_XY: the Z axis is a free axis ;
164  * @VISU_BOX_SURFACE_YZ: the X axis is a free axis ;
165  * @VISU_BOX_SURFACE_ZX: the Y axis is a free axis ;
166  * @VISU_BOX_WIRE_X: the periodicity is along X axis only ;
167  * @VISU_BOX_WIRE_Y: the periodicity is along Y axis only ;
168  * @VISU_BOX_WIRE_Z: the periodicity is along Z axis only ;
169  * @VISU_BOX_FREE: the system is isolated.
170  *
171  * This describes the periodicity of the bounding box in the three directions.
172  */
173 typedef enum
174   {
175     VISU_BOX_PERIODIC   = 7,
176     VISU_BOX_SURFACE_XY = 3,
177     VISU_BOX_SURFACE_YZ = 6,
178     VISU_BOX_SURFACE_ZX = 5,
179     VISU_BOX_WIRE_X     = 1,
180     VISU_BOX_WIRE_Y     = 2,
181     VISU_BOX_WIRE_Z     = 4,
182     VISU_BOX_FREE       = 0
183   } VisuBoxBoundaries;
184 
185 /**
186  * VisuBoxHiddingStatus:
187  * @VISU_BOX_HIDE_NONE: don't apply masking.
188  * @VISU_BOX_HIDE_OUTSIDE: hide nodes outside the box.
189  * @VISU_BOX_HIDE_INSIDE: hide nodes inside the box.
190  *
191  * This describes the possibilty to use the box as a masking objects
192  * for nodes.
193  *
194  * Since: 3.8
195  */
196 typedef enum
197   {
198     VISU_BOX_HIDE_NONE,
199     VISU_BOX_HIDE_OUTSIDE,
200     VISU_BOX_HIDE_INSIDE
201   } VisuBoxHiddingStatus;
202 
203 /* These structures are used for bindings. */
204 typedef struct _VisuBoxVertices VisuBoxVertices;
205 struct _VisuBoxVertices
206 {
207   float vertices[8][3];
208 };
209 typedef struct _VisuBoxCell VisuBoxCell;
210 struct _VisuBoxCell
211 {
212   double box[VISU_BOX_N_VECTORS];
213 };
214 
215 VisuBox* visu_box_new(double geometry[VISU_BOX_N_VECTORS],
216                       VisuBoxBoundaries bc);
217 VisuBox* visu_box_new_full(double full[3][3], VisuBoxBoundaries bc);
218 
219 void visu_box_convertFullToCell(VisuBox *box, float cell[3], float full[3]);
220 void visu_box_convertXYZtoBoxCoordinates(const VisuBox *box, float boxCoord[3], float xyz[3]);
221 void visu_box_convertXYZToReduced(VisuBox *box, GArray *xyz,
222                                   float *u, float *v, float *w);
223 void visu_box_convertBoxCoordinatestoXYZ(VisuBox *box, float xyz[3], const float boxCoord[3]);
224 void visu_box_convertReducedToXYZ(VisuBox *box, GArray *red,
225                                   float *x, float *y, float *z);
226 
227 gboolean visu_box_constrainInside(VisuBox *box, float translat[3], float xyz[3],
228                                   gboolean withExt);
229 
230 void visu_box_getInvMatrix(VisuBox *box, double matrix[3][3]);
231 void visu_box_getCellMatrix(VisuBox *box, double matrix[3][3]);
232 void visu_box_getCellMatrixv(VisuBox *box, double *m11, double *m12, double *m13,
233                              double *m21, double *m22, double *m23,
234                              double *m31, double *m32, double *m33);
235 void visu_box_getVertices(VisuBox *box, float v[8][3],
236                           gboolean withExtension);
237 void visu_box_getExtension(const VisuBox *boxObj, float extension[3]);
238 VisuBoxBoundaries visu_box_getBoundary(VisuBox *box);
239 void visu_box_getPeriodicity(VisuBox *box, gboolean per[3]);
240 double visu_box_getGeometry(VisuBox *box, VisuBoxVector vector);
241 void visu_box_getCentre(VisuBox *box, float centre[3]);
242 float visu_box_getGlobalSize(VisuBox *box, gboolean withExt);
243 ToolUnits visu_box_getUnit(VisuBox *box);
244 gboolean visu_box_getInside(VisuBox *box, float vect[3], float ratio);
245 gboolean visu_box_getPeriodicVector(VisuBox *box, float vect[3]);
246 void visu_box_getPeriodicVectorv(VisuBox *box, float *x, float *y, float *z,
247                                   float vect[3]);
248 void visu_box_getPeriodicArray(VisuBox *box, float *array, guint nEle);
249 gboolean visu_box_getExtensionActive(VisuBox *box);
250 VisuBoxHiddingStatus visu_box_getHiddingStatus(const VisuBox *box);
251 float visu_box_getVolume(const VisuBox *box);
252 
253 gboolean visu_box_setExtensionActive(VisuBox *box, gboolean status);
254 gboolean visu_box_setBoundary(VisuBox *box, VisuBoxBoundaries bc);
255 gboolean visu_box_setGeometry(VisuBox *box, double geometry[VISU_BOX_N_VECTORS]);
256 gboolean visu_box_setGeometryFull(VisuBox *box, double full[3][3]);
257 gboolean visu_box_setMargin(VisuBox *box, gfloat margin, gboolean emit);
258 gboolean visu_box_setExtension(VisuBox *boxObj, float extension[3]);
259 gboolean visu_box_setUnit(VisuBox *box, ToolUnits unit);
260 gboolean visu_box_setOrigin(VisuBox *box, const float orig[3]);
261 gboolean visu_box_setHiddingStatus(VisuBox *box, VisuBoxHiddingStatus status);
262 
263 G_END_DECLS
264 
265 #endif
266