IMP  2.0.1
The Integrative Modeling Platform
geometric_primitive_macros.h
Go to the documentation of this file.
1 /**
2  * \file IMP/algebra/geometric_primitive_macros.h
3  * \brief Various important macros
4  * for implementing geometry.
5  *
6  * Copyright 2007-2013 IMP Inventors. All rights reserved.
7  *
8  */
9 
10 #ifndef IMPALGEBRA_GEOMETRIC_PRIMITIVE_MACROS_H
11 #define IMPALGEBRA_GEOMETRIC_PRIMITIVE_MACROS_H
12 
13 
14 //! implement the needed namespace methods for a geometry type
15 /** These are
16  - IMP::algebra::get_surface_area()
17  - IMP::algebra::get_volume()
18  - IMP::algebra::get_bounding_box()
19  - output to a stream
20 
21  The name of the argument is g and the code snipets should return
22  the expected value.
23 */
24 #define IMP_VOLUME_GEOMETRY_METHODS(Name, name, area, volume, bounding_box) \
25  IMP_VALUES(Name, Name##s); \
26  /** \relates Name */ \
27  inline double get_surface_area(const Name &g) { \
28  area; \
29  } \
30  /** \relates Name */ \
31  inline double get_volume(const Name &g) { \
32  volume; \
33  } \
34  /** \relates Name */ \
35  inline BoundingBoxD<3> get_bounding_box(const Name &g) { \
36  bounding_box; \
37  } \
38  /** \relates Name */ \
39  inline const Name &get_##name##_geometry(const Name &g) {return g;} \
40  /** \relates Name */ \
41  IMP_NO_SWIG(inline void set_##name##_geometry(Name &g, const Name &v) {g=v;})
42 
43 //! implement the needed namespace methods for a geometry type
44 /** These are
45  - IMP::algebra::get_surface_area()
46  - IMP::algebra::get_volume()
47  - IMP::algebra::get_bounding_box()
48  - output to a stream
49 
50  The name of the argument is g and the code snipets should return
51  the expected value.
52 */
53 #define IMP_VOLUME_GEOMETRY_METHODS_D(Name, name, area, volume, bounding_box) \
54  /** \relates Name */ \
55  inline double get_surface_area(const Name##D<3> &g) { \
56  area; \
57  } \
58  /** \relates Name */ \
59  inline double get_volume(const Name##D<3> &g) { \
60  volume; \
61  } \
62  /** \relates Name */ \
63  template <int D> \
64  inline BoundingBoxD<D> get_bounding_box(const Name##D<D> &g) { \
65  bounding_box; \
66  } \
67  /** \relates Name */ \
68  IMP_NO_SWIG(template <int D> \
69  inline void set_##name##_d_geometry(Name##D<D> &g, \
70  const Name##D<D> &v) { \
71  g=v; \
72  } \
73  /** \relates Name */ \
74  template <int D> \
75  inline const Name##D<D> &get_##name##_d_geometry(const Name##D<D> &g) { \
76  return g; \
77  }) \
78  /** Typedef for python. */ \
79  typedef Name##D<1> Name##1D; \
80  IMP_VALUES(Name##1D, Name##1Ds); \
81  /** Typedef for python. */ \
82  typedef Name##D<2> Name##2D; \
83  IMP_VALUES(Name##2D, Name##2Ds); \
84  /** Typedef for python. */ \
85  typedef Name##D<3> Name##3D; \
86  IMP_VALUES(Name##3D, Name##3Ds); \
87  /** Typedef for python. */ \
88  typedef Name##D<4> Name##4D; \
89  IMP_VALUES(Name##4D, Name##4Ds); \
90  /** Typedef for python. */ \
91  typedef Name##D<5> Name##5D; \
92  IMP_VALUES(Name##5D, Name##5Ds); \
93  /** Typedef for python. */ \
94  typedef Name##D<6> Name##6D; \
95  IMP_VALUES(Name##6D, Name##6Ds); \
96  /** Typedef for python. */ \
97  typedef Name##D<-1> Name##KD; \
98  IMP_VALUES(Name##KD, Name##KDs)
99 
100 
101 //! implement the needed namespace methods for a geometry type
102 /** These are
103  - IMP::algebra::get_bounding_box()
104  - output to a stream
105 
106  The name should not include the D.
107 
108  The name of the argument is g and the code snipets should return
109  the expected value.
110 */
111 #define IMP_LINEAR_GEOMETRY_METHODS(Name, name, bounding_box) \
112  IMP_VALUES(Name, Name##s); \
113  /** \relates Name */ \
114  inline BoundingBoxD<3> get_bounding_box(const Name &g) { \
115  bounding_box; \
116  } \
117  /** \relates Name */ \
118  inline const Name &get_##name##_geometry(const Name &g) {return g;} \
119  IMP_NO_SWIG(inline void set_##name##_geometry( Name &g, const Name &gi)\
120  {g=gi;}) \
121 
122 //! implement the needed namespace methods for a geometry type
123 /** These are
124  - IMP::algebra::get_surface_area()
125  - IMP::algebra::get_bounding_box()
126  - output to a stream
127 
128  The name of the argument is g and the code snipets should return
129  the expected value.
130 */
131 #define IMP_AREA_GEOMETRY_METHODS(Name, name, area, bounding_box) \
132  IMP_VALUES(Name, Name##s); \
133  /** \relates Name */ \
134  inline double get_area(const Name &g) { \
135  area; \
136  } \
137  /** \relates Name */ \
138  inline BoundingBoxD<3> get_bounding_box(const Name &g) { \
139  bounding_box; \
140  } \
141  /** \relates Name */ \
142  inline const Name &get_##name##_geometry(const Name &g) {return g;} \
143  /** \relates Name */ \
144  IMP_NO_SWIG(inline void set_##name##_geometry(Name &g, const Name &v) {g=v;})\
145 
146 
147 //! implement the needed namespace methods for a geometry type
148 /** These are
149  - IMP::algebra::get_surface_area()
150  - IMP::algebra::get_bounding_box()
151  - output to a stream
152 
153  The name of the argument is g and the code snipets should return
154  the expected value.
155 */
156 #define IMP_AREA_GEOMETRY_METHODS_D(Name, name, area, bounding_box) \
157  /** \relates Name */ \
158  template <int D> \
159  inline double get_area(const Name##D<D> &g) { \
160  area; \
161  } \
162  /** \relates Name */ \
163  template <int D> \
164  inline BoundingBoxD<D> get_bounding_box(const Name##D<D> &g) { \
165  bounding_box; \
166  } \
167  /** \relates Name */ \
168  template <int D> \
169  inline const Name &get_##name##_d_geometry(const Name##D<D> &g) { \
170  return g;} \
171  /** \relates Name */ \
172  IMP_NO_SWIG(template <int D> \
173  inline void set_##name##_d_geometry(Name &g, const Name##D<D> &v) { \
174  g=v;}) \
175  /** Typedef for python. */ \
176  typedef Name##D<1> Name##1D; \
177  IMP_VALUES(Name##1D, Name##1Ds); \
178  /** Typedef for python. */ \
179  typedef Name##D<2> Name##2D; \
180  IMP_VALUES(Name##2D, Name##2Ds); \
181  /** Typedef for python. */ \
182  typedef Name##D<3> Name##3D; \
183  IMP_VALUES(Name##3D, Name##3Ds); \
184  /** Typedef for python. */ \
185  typedef Name##D<4> Name##4D; \
186  IMP_VALUES(Name##4D, Name##4Ds); \
187  /** Typedef for python. */ \
188  typedef Name##D<5> Name##5D; \
189  IMP_VALUES(Name##5D, Name##5Ds); \
190  /** Typedef for python.*/ \
191  typedef Name##D<6> Name##6D; \
192  IMP_VALUES(Name##6D, Name##6Ds); \
193  /** Typedef for python. */ \
194  typedef Name##D<-1> Name##KD; \
195  IMP_VALUES(Name##KD, Name##KDs)
196 
197 
198 #endif /* IMPALGEBRA_GEOMETRIC_PRIMITIVE_MACROS_H */