Hitmap 1.3
 All Data Structures Namespaces Files Functions Variables Typedefs Friends Macros Groups Pages
hit_sshape.h
Go to the documentation of this file.
1 
19 /*
20  * <license>
21  *
22  * Hitmap v1.2
23  *
24  * This software is provided to enhance knowledge and encourage progress in the scientific
25  * community. It should be used only for research and educational purposes. Any reproduction
26  * or use for commercial purpose, public redistribution, in source or binary forms, with or
27  * without modifications, is NOT ALLOWED without the previous authorization of the copyright
28  * holder. The origin of this software must not be misrepresented; you must not claim that you
29  * wrote the original software. If you use this software for any purpose (e.g. publication),
30  * a reference to the software package and the authors must be included.
31  *
32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND ANY
33  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
34  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
35  * THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
36  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
39  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41  *
42  * Copyright (c) 2007-2015, Trasgo Group, Universidad de Valladolid.
43  * All rights reserved.
44  *
45  * More information on http://trasgo.infor.uva.es/
46  *
47  * </license>
48 */
49 
50 #ifndef _HitSigShape_
51 #define _HitSigShape_
52 
53 #include "hit_sig.h"
54 #include "hit_shape.h"
55 
73 /* 1. Hit SHAPE SPECIAL VALUES */
74 // @cond INTERNAL
79 #define HIT_SIG_SHAPE_INTERNAL_NULL_STATIC { -1, { HIT_SIG_NULL_STATIC, HIT_SIG_NULL_STATIC, HIT_SIG_NULL_STATIC, HIT_SIG_NULL_STATIC } }
80 
82 #define HIT_SIG_SHAPE_NULL_STATIC { HIT_SIG_SHAPE, { HIT_SIG_SHAPE_INTERNAL_NULL_STATIC} }
83 
85 #define HIT_SIG_SHAPE_WHOLE_STATIC { 0, { HIT_SIG_NULL_STATIC, HIT_SIG_NULL_STATIC, HIT_SIG_NULL_STATIC, HIT_SIG_NULL_STATIC } }
86 
88 #define HIT_SHAPE_WHOLE_STATIC { HIT_SIG_SHAPE, { HIT_SIG_SHAPE_WHOLE_STATIC} }
89 // @endcond
90 
97 
98 
111 
126 
127 // @cond INTERNAL
128 /* 2. ACCESS METHOD TO THE SIGNATURE STRUCT */
134 #define hit_sShapeAccess(s) ((s).info.sig)
135 // @endcond
136 
137 
138 /* 3. Hit SHAPE GENERATING FUNCTIONS */
139 // @cond INTERNAL
140 /*
141  * Internal constructor, generating a shape from a internal HitSigShape structure
142  *
143  * @author arturo
144  * @date Feb 2013
145  */
146 static inline HitShape hit_shapeFromSigShape( HitSigShape s ) {
147  HitShape a = { HIT_SIG_SHAPE, { s } };
148  return a;
149 }
150 // @endcond
151 
158 /* 4.1 Hit Signature Shape generating functions */
175 #define hit_shape(nd, ...) hit_shape##nd(__VA_ARGS__)
176 
177 // @cond INTERNAL
181 static inline HitShape hit_shape1(HitSig s1) {
182  HitShape a = { HIT_SIG_SHAPE, { { 1, { s1 } }} };
183  return a;
184 }
188 static inline HitShape hit_shape2(HitSig s1, HitSig s2) {
189  HitShape a = { HIT_SIG_SHAPE, { { 2, { s1, s2 } }} };
190  return a;
191 }
195 static inline HitShape hit_shape3(HitSig s1, HitSig s2, HitSig s3) {
196  HitShape a = { HIT_SIG_SHAPE, { { 3, { s1, s2, s3 } }} };
197  return a;
198 }
202 static inline HitShape hit_shape4(HitSig s1, HitSig s2, HitSig s3, HitSig s4) {
203  HitShape a = { HIT_SIG_SHAPE, { { 4, { s1, s2, s3, s4 } }} };
204  return a;
205 }
206 // @endcond
207 
227 #define hit_shapeIndex(nd, ...) hit_shapeIndex##nd(__VA_ARGS__)
228 
229 // @cond INTERNAL
233 static inline HitShape hit_shapeIndex1( int idx ) {
234  HitShape a = { HIT_SIG_SHAPE, { { 1, { hit_sig( idx, idx, 1 ) } }} };
235  return a;
236 }
237 
241 static inline HitShape hit_shapeIndex2( int idx1, int idx2 ) {
242  HitShape a = { HIT_SIG_SHAPE, { { 2, {
243  hit_sig( idx1, idx1, 1 ),
244  hit_sig( idx2, idx2, 1 )
245  } }} };
246  return a;
247 }
248 
252 static inline HitShape hit_shapeIndex3( int idx1, int idx2, int idx3 ) {
253  HitShape a = { HIT_SIG_SHAPE, { { 3, {
254  hit_sig( idx1, idx1, 1 ),
255  hit_sig( idx2, idx2, 1 ),
256  hit_sig( idx3, idx3, 1 )
257  } }} };
258  return a;
259 }
260 
264 static inline HitShape hit_shapeIndex4( int idx1, int idx2, int idx3, int idx4 ) {
265  HitShape a = { HIT_SIG_SHAPE, { { 4, {
266  hit_sig( idx1, idx1, 1 ),
267  hit_sig( idx2, idx2, 1 ),
268  hit_sig( idx3, idx3, 1 ),
269  hit_sig( idx4, idx4, 1 )
270  } }} };
271  return a;
272 }
273 // @endcond
274 
275 
295 #define hit_shapeStd(nd, ...) hit_shapeStd##nd(__VA_ARGS__)
296 
297 
298 // @cond INTERNAL
302 static inline HitShape hit_shapeStd1( int _size ) {
303  HitShape a = { HIT_SIG_SHAPE, { { 1, { hit_sigStd( _size ) } } } };
304  return a;
305 }
306 
310 static inline HitShape hit_shapeStd2( int size1, int size2 ) {
311  HitShape a = { HIT_SIG_SHAPE, { { 2, {
312  hit_sigStd( size1 ),
313  hit_sigStd( size2 )
314  } }} };
315  return a;
316 }
317 
321 static inline HitShape hit_shapeStd3( int size1, int size2, int size3 ) {
322  HitShape a = { HIT_SIG_SHAPE, { { 3, {
323  hit_sigStd( size1 ),
324  hit_sigStd( size2 ),
325  hit_sigStd( size3 )
326  } }} };
327  return a;
328 }
329 
333 static inline HitShape hit_shapeStd4( int size1, int size2, int size3, int size4 ) {
334  HitShape a = { HIT_SIG_SHAPE, { { 4, {
335  hit_sigStd( size1 ),
336  hit_sigStd( size2 ),
337  hit_sigStd( size3 ),
338  hit_sigStd( size4 )
339  } }} };
340  return a;
341 }
342 // @endcond
343 
364 #define hit_shapeDims(shape) (((shape).type==HIT_SIG_SHAPE)?hit_sshapeDims(shape):(1))
365 
366 
367 /* 5.1 Hit Signature Shape access macros */
376 #define hit_sshapeDims(shape) (hit_sShapeAccess(shape).numDims)
377 
387 #define hit_shapeDimsSet(shape,value) (hit_sshapeDims(shape) = (value))
388 
389 
400 #define hit_shapeSig(shape,dim) ((hit_sShapeAccess((shape))).sig[(dim)])
401 
412 #define hit_shapeSigCard(shape,dim) hit_sigCard((hit_sShapeAccess((shape))).sig[(dim)])
413 
423 static inline int hit_shapeCard( HitShape shape ) {
424  int i;
425  int result = 1;
426  for ( i=0; i<hit_shapeDims( shape ); i++ )
427  result = result * hit_shapeSigCard( shape, i );
428  return result;
429 }
430 
438 /* 7. Hit SHAPE: COMPARISON OPERATOR */
449 int hit_shapeCmp(HitShape sh1, HitShape sh2);
450 
451 
452 /* 8. Hit INTERSECT SHAPES */
465 
466 /* 8.2. Hit SUBSELECT SHAPES */
482 
483 /* 8.3. Hit SHAPE: TILE TO ARRAY */
498 
506 /* 9. Hit Signature Shape operations */
507 /* 9.1 Hit SHAPE BORDER */
508 /* Values for hit_shapeBorder */
515 #define HIT_SHAPE_BEGIN 0
516 
522 #define HIT_SHAPE_END 1
523 
543 HitShape hit_shapeBorder(HitShape shape, int dim, int position, int offset);
544 
545 /* 9.2 Hit SHAPE EXPAND DIM */
564 HitShape hit_shapeDimExpand( HitShape shape, int dim, int position, int offset );
565 
566 /* 9.2 Hit SHAPE EXPAND */
582 HitShape hit_shapeExpand(HitShape shape,int dims,int offset);
583 
591 /* 11. Hit Shape Iterators */
603 #define hit_shapeIterator(var,shape,dim) for(var=hit_shapeSig((shape),(dim)).begin;var<=hit_shapeSig((shape),(dim)).end;var++)
604 
619 #define hit_shapeIteratorTileCoord(var,shape,dim) for(var=0; var<=hit_sigCard(hit_shapeSig((shape),(dim)))-1;var++)
620 
625 /* PRINT A SHAPE*/
626 void dumpShape (HitShape sh);
627 
628 /* END OF HEADER FILE _HitShape_ */
629 #endif
HitShape hit_shapeBorder(HitShape shape, int dim, int position, int offset)
Definition: hit_shape.c:241
HitShape hit_shapeExpand(HitShape shape, int dims, int offset)
Definition: hit_shape.c:210
HitShape hit_shapeIntersect(HitShape sh1, HitShape sh2)
Definition: hit_shape.c:123
HitShape HIT_SIG_SHAPE_NULL
Definition: hit_shape.c:62
int hit_shapeCmp(HitShape sh1, HitShape sh2)
Definition: hit_shape.c:109
HitShape HIT_SHAPE_WHOLE
Definition: hit_shape.c:75
HitShape hit_shapeTileToArray(HitShape sh1, HitShape sh2)
Definition: hit_shape.c:181
Definition: hit_sig.h:79
#define HIT_SIG_SHAPE
Definition: hit_shape.h:171
int dims[2]
Definition: SWpar_ref.c:187
#define hit_shapeDims(shape)
Definition: hit_sshape.h:364
HitShape shape
HitShape hit_shapeSubset(HitShape sh1, HitShape sh2)
Definition: hit_shape.c:157
#define hit_shapeSigCard(shape, dim)
Definition: hit_sshape.h:412
#define s
HitShape hit_shapeDimExpand(HitShape shape, int dim, int position, int offset)
Definition: hit_shape.c:226
void dumpShape(HitShape sh)
Definition: hit_shape.c:391
HitSigShape HIT_SIG_SHAPE_WHOLE
Definition: hit_shape.c:77