51 #define HIT_BSHAPE_MATRIX 0
53 #define HIT_BSHAPE_GRAPH 1
63 #define HIT_BITMAP_SHAPE_INTERNAL_NULL_STATIC { {0, 0}, 0, NULL, {HIT_NAMELIST_NULL_STATIC,HIT_NAMELIST_NULL_STATIC} }
69 #define HIT_BITMAP_SHAPE_NULL_STATIC { HIT_BITMAP_SHAPE, { .bitmap = HIT_BITMAP_SHAPE_INTERNAL_NULL_STATIC } }
75 #define hit_bitmapShapeIndex(b) (((size_t)(b))/HIT_BITMAP_SIZE)
77 #define hit_bitmapShapeOffset(b) (((size_t)(b))%HIT_BITMAP_SIZE)
82 #define HIT_BITMAP_1 (((HIT_BITMAP_TYPE) 1) << (HIT_BITMAP_SIZE-1))
86 static inline const char * hit_bitmap_tostring(HIT_BITMAP_TYPE
element){
88 static char buffer[HIT_BITMAP_SIZE+1];
89 buffer[HIT_BITMAP_SIZE] =
'\0';
91 HIT_BITMAP_TYPE mask = HIT_BITMAP_1;
93 for(i=0;i<HIT_BITMAP_SIZE;i++){
95 if( (mask & element) == 0 ){
144 #define hit_bShapeCard(shape, dim) (hit_bShapeAccess(shape).cards[(dim)])
153 #define hit_bShapeNvertices(shape) (hit_bShapeCard(shape, 0))
162 #define hit_bShapeNedges(shape) (hit_bShapeAccess(shape).nz)
171 #define hit_bShapeNameList(shape,dim) (hit_bShapeAccess((shape)).names[(dim)])
180 #define hit_bShapeData(shape) (hit_bShapeAccess(shape).data)
191 #define hit_bShapeCoordToGlobal(s,dim,elem) (hit_nameListIndex2Name(hit_bShapeNameList((s),(dim)),(elem)))
201 #define hit_bShapeCoordToLocal(s,dim,elem) (hit_nameListName2Index(hit_bShapeNameList((s),(dim)),(elem)))
213 #define hit_bShapeEdgeTarget(s,edge) (edge)
223 #define hit_bShapeEdgeTargetSkip(s,edge) (edge%hit_bShapeCard(s,1))
236 #define hit_bShapeGet(bitshape,i,j) \
237 (hit_bShapeData(bitshape)[hit_bitmapShapeIndex((i)*hit_bShapeCard(bitshape,1)+(j))] \
239 ((HIT_BITMAP_1) >> hit_bitmapShapeOffset((i)*hit_bShapeCard(bitshape,1)+(j))))
249 #define hit_bShapeSet(bitshape,i,j) \
250 (hit_bShapeData(bitshape)[hit_bitmapShapeIndex((i)*hit_bShapeCard(bitshape,1)+(j))] \
253 ((HIT_BITMAP_1) >> hit_bitmapShapeOffset((i)*hit_bShapeCard(bitshape,1)+(j))))
263 #define hit_bShapeClear(bitshape,i,j) \
264 (hit_bShapeData(bitshape)[hit_bitmapShapeIndex((i)*hit_bShapeCard(bitshape,1)+(j))] \
267 ~((HIT_BITMAP_1) >> hit_bitmapShapeOffset((i)*hit_bShapeCard(bitshape,1)+(j))))
277 #define hit_bShapeSet2(bitshape,i,j) {hit_bShapeSet(bitshape,i,j); hit_bShapeSet(bitshape,j,i);}
288 #define hit_bShapeGetGlobal(bitshape,i,j) \
289 (hit_bShapeData(bitshape)[hit_bitmapShapeIndex((hit_bShapeCoordToLocal(bitshape,0, (i)))* \
290 hit_bShapeCard(bitshape,1)+(hit_bShapeCoordToLocal(bitshape,1, (j))))] \
292 ((HIT_BITMAP_1) >> hit_bitmapShapeOffset((hit_bShapeCoordToLocal(bitshape,0, (i)))* \
293 hit_bShapeCard(bitshape,1)+(hit_bShapeCoordToLocal(bitshape,1, (j))))))
303 #define hit_bShapeSetGlobal(bitshape,i,j) \
304 (hit_bShapeData(bitshape)[hit_bitmapShapeIndex((hit_bShapeCoordToLocal(bitshape,0, (i)))* \
305 hit_bShapeCard(bitshape,1)+(hit_bShapeCoordToLocal(bitshape,1, (j))))] \
308 ((HIT_BITMAP_1) >> hit_bitmapShapeOffset((hit_bShapeCoordToLocal(bitshape,0, (i)))* \
309 hit_bShapeCard(bitshape,1)+(hit_bShapeCoordToLocal(bitshape,1, (j))))))
319 #define hit_bShapeClearGlobal(bitshape,i,j) \
320 (hit_bShapeData(bitshape)[hit_bitmapShapeIndex((hit_bShapeCoordToLocal(bitshape,0, (i)))* \
321 hit_bShapeCard(bitshape,1)+(hit_bShapeCoordToLocal(bitshape,1, (j))))] \
324 ((HIT_BITMAP_1) >> hit_bitmapShapeOffset((hit_bShapeCoordToLocal(bitshape,0, (i)))* \
325 hit_bShapeCard(bitshape,1)+(hit_bShapeCoordToLocal(bitshape,1, (j))))))
335 #define hit_bShapeSetGlobal2(bitshape,i,j) {hit_bShapeSetGlobal(bitshape,i,j); hit_bShapeSetGlobal(bitshape,j,i);}
346 #define hit_bShapeVertexToGlobal(s,vertex) (hit_nameListIndex2Name(hit_bShapeNameList(s,0),vertex))
355 #define hit_bShapeVertexToLocal(s,vertex) (hit_nameListName2Index(hit_bShapeNameList(s,0),vertex))
364 #define hit_bShapeAddVertex(shapeP, x) hit_bShapeAddEmptyRow_or_Vertex(shapeP, x, HIT_BSHAPE_GRAPH)
421 #define hit_bShapeAddEdge(shapep, x, y) hit_bShapeAddElem_or_Edge(shapep, x, y, HIT_BSHAPE_GRAPH)
432 #define hit_bShapeAddEdge2(shape,x,y) {hit_bShapeAddEdge(shape,x,y); hit_bShapeAddEdge(shape,y,x);}
444 #define hit_bShapeRowIterator(var,shape) \
445 for(var=0; var<hit_bShapeCard(shape, 0); var++)
455 #define hit_bShapeVertexIterator(var,shape) hit_bShapeRowIterator(var,shape)
466 #define hit_bShapeColumnIterator(var,shape,row) \
467 for(var=hit_bShapeEdgeIteratorNextInternal(shape, -1, row);var<hit_bShapeCard(shape,1);var=hit_bShapeEdgeIteratorNextInternal(shape, var, row))
479 #define hit_bShapeColumnIteratorSkip(var,shape,row) \
480 for(var=hit_bShapeEdgeIteratorNextInternalSkip(shape, row * hit_bShapeCard(shape,1));var<(row+1) * hit_bShapeCard(shape,1);var = hit_bShapeEdgeIteratorNextInternalSkip(shape, var+1))
481 #define hit_bShapeColumnIteratorDense(var,shape,row) \
482 for(var=0;var<hit_bShapeCard(shape,1);var++)
494 #define hit_bShapeEdgeIterator(var,shape,vertex) hit_bShapeColumnIterator(var,shape,vertex)
504 #define hit_bShapeEdgeIteratorSkip(var,shape,vertex) hit_bShapeColumnIteratorSkip(var,shape,vertex)
514 #define hit_bShapeEdgeIteratorDense(var,shape,vertex) hit_bShapeColumnIteratorDense(var,shape,vertex)
528 static inline int hit_bShapeEdgeIteratorNextInternal(
HitShape shape,
int var,
int vertex){
544 static inline int hit_bShapeEdgeIteratorNextInternalSkip(
HitShape shape,
int var){
549 size_t xind = hit_bitmapShapeIndex(var);
550 size_t xoff = hit_bitmapShapeOffset(var);
557 HIT_BITMAP_TYPE mask = HIT_BITMAP_1 >> xoff;
558 for(i=0;i<HIT_BITMAP_SIZE-xoff;i++){
559 if( (mask & element) != 0 ){
560 return var + (int) i;
574 for(i=0;i<HIT_BITMAP_SIZE;i++){
575 if( (mask & element) != 0 ){
576 return (
int) (xind * HIT_BITMAP_SIZE + i);
612 #define hit_bShapeAddElem(shapep, x, y) hit_bShapeAddElem_or_Edge(shapep, x, y, HIT_BSHAPE_MATRIX)
639 #define hit_bitmapShapeVertexIterator(var,shape) for(var=0; var<hit_bitmapShapeNvertices(shape); var++)
HitShape hit_bShapeSelectRows(HitShape shape, int nNames, int *names)
HitShape hit_bShapeSelect(HitShape shape, int nvertices, int *vertices)
void hit_bShapeAddEmptyRow_or_Vertex(HitShape *shape, int x, int mode)
int hit_bShapeNColsRow(HitShape shape, int row)
#define hit_bShapeGet(bitshape, i, j)
#define hit_bShapeCard(shape, dim)
HitShape hit_bShapeExpand(HitShape shape, HitShape original, int amount)
HitShape hit_bitmapShape(int nvertices)
#define hit_bShapeData(shape)
void hit_bShapeFree(HitShape shape)
#define element(mat, idx1, idx2)
HitShape hit_bitmapShapeMatrix(int n, int m)
void hit_bShapeAddElem_or_Edge(HitShape *shape, int x, int y, int mode)
HitShape HIT_BITMAP_SHAPE_NULL
void hit_bShapeCreateInvNames(HitShape *shape)