Blender V2.61 - r43446
Classes | Defines | Typedefs | Functions | Variables

boxpack2d.c File Reference

#include <stdlib.h>
#include "MEM_guardedalloc.h"
#include "BLI_boxpack2d.h"

Go to the source code of this file.

Classes

struct  boxVert

Defines

#define eps   0.0000001f
#define BLF   1
#define TRF   2
#define TLF   4
#define BRF   8
#define CORNERFLAGS   (BLF|TRF|TLF|BRF)
#define BL   0
#define TR   1
#define TL   2
#define BR   3
#define BOXLEFT(b)   b->v[BL]->x
#define BOXRIGHT(b)   b->v[TR]->x
#define BOXBOTTOM(b)   b->v[BL]->y
#define BOXTOP(b)   b->v[TR]->y
#define BOXAREA(b)   (b->w * b->h)
#define UPDATE_V34X(b)
#define UPDATE_V34Y(b)
#define UPDATE_V34(b)   UPDATE_V34X(b); UPDATE_V34Y(b)
#define SET_BOXLEFT(b, f)
#define SET_BOXRIGHT(b, f)
#define SET_BOXBOTTOM(b, f)
#define SET_BOXTOP(b, f)
#define BOXINTERSECT(b1, b2)
#define MIN2(x, y)   ( (x)<(y) ? (x) : (y) )
#define MAX2(x, y)   ( (x)>(y) ? (x) : (y) )

Typedefs

typedef struct boxVert boxVert

Functions

static int box_areasort (const void *p1, const void *p2)
static int vertex_sort (const void *p1, const void *p2)
void boxPack2D (boxPack *boxarray, const int len, float *tot_width, float *tot_height)

Variables

static float box_width
static float box_height
static boxVertvertarray

Detailed Description

Definition in file boxpack2d.c.


Define Documentation

#define BL   0

Definition at line 62 of file boxpack2d.c.

Referenced by boxPack2D().

#define BLF   1

Definition at line 56 of file boxpack2d.c.

Referenced by boxPack2D().

#define BOXAREA (   b)    (b->w * b->h)

Definition at line 71 of file boxpack2d.c.

Referenced by box_areasort().

#define BOXBOTTOM (   b)    b->v[BL]->y

Definition at line 69 of file boxpack2d.c.

Referenced by boxPack2D().

#define BOXINTERSECT (   b1,
  b2 
)
Value:
(!( BOXLEFT(b1)+eps>=BOXRIGHT(b2) ||\
        BOXBOTTOM(b1)+eps>=BOXTOP(b2) ||\
        BOXRIGHT(b1)-eps<=BOXLEFT(b2) ||\
        BOXTOP(b1)-eps<=BOXBOTTOM(b2) ))

Definition at line 91 of file boxpack2d.c.

Referenced by boxPack2D().

#define BOXLEFT (   b)    b->v[BL]->x

Definition at line 67 of file boxpack2d.c.

Referenced by boxPack2D().

#define BOXRIGHT (   b)    b->v[TR]->x

Definition at line 68 of file boxpack2d.c.

Referenced by boxPack2D().

#define BOXTOP (   b)    b->v[TR]->y

Definition at line 70 of file boxpack2d.c.

Referenced by boxPack2D().

#define BR   3

Definition at line 65 of file boxpack2d.c.

Referenced by boxPack2D().

#define BRF   8

Definition at line 59 of file boxpack2d.c.

Referenced by boxPack2D().

#define CORNERFLAGS   (BLF|TRF|TLF|BRF)

Definition at line 60 of file boxpack2d.c.

Referenced by boxPack2D().

#define eps   0.0000001f
#define MAX2 (   x,
 
)    ( (x)>(y) ? (x) : (y) )

Definition at line 98 of file boxpack2d.c.

Referenced by boxPack2D(), and vertex_sort().

#define MIN2 (   x,
 
)    ( (x)<(y) ? (x) : (y) )

Definition at line 97 of file boxpack2d.c.

#define SET_BOXBOTTOM (   b,
 
)
Value:
b->v[TR]->y = f + b->h;\
                            b->v[BL]->y = f;\
                            UPDATE_V34Y(b)

Definition at line 85 of file boxpack2d.c.

Referenced by boxPack2D().

#define SET_BOXLEFT (   b,
 
)
Value:
b->v[TR]->x = f + b->w;\
                            b->v[BL]->x = f;\
                            UPDATE_V34X(b)

Definition at line 79 of file boxpack2d.c.

Referenced by boxPack2D().

#define SET_BOXRIGHT (   b,
 
)
Value:
b->v[BL]->x = f - b->w;\
                            b->v[TR]->x = f;\
                            UPDATE_V34X(b)

Definition at line 82 of file boxpack2d.c.

Referenced by boxPack2D().

#define SET_BOXTOP (   b,
 
)
Value:
b->v[BL]->y = f - b->h;\
                            b->v[TR]->y = f;\
                            UPDATE_V34Y(b)

Definition at line 88 of file boxpack2d.c.

Referenced by boxPack2D().

#define TL   2

Definition at line 64 of file boxpack2d.c.

Referenced by boxPack2D().

#define TLF   4

Definition at line 58 of file boxpack2d.c.

Referenced by boxPack2D().

#define TR   1

Definition at line 63 of file boxpack2d.c.

Referenced by boxPack2D().

#define TRF   2

Definition at line 57 of file boxpack2d.c.

Referenced by boxPack2D().

#define UPDATE_V34 (   b)    UPDATE_V34X(b); UPDATE_V34Y(b)

Definition at line 77 of file boxpack2d.c.

#define UPDATE_V34X (   b)
Value:
b->v[TL]->x = b->v[BL]->x;\
                        b->v[BR]->x = b->v[TR]->x

Definition at line 73 of file boxpack2d.c.

#define UPDATE_V34Y (   b)
Value:
b->v[TL]->y = b->v[TR]->y;\
                        b->v[BR]->y = b->v[BL]->y

Definition at line 75 of file boxpack2d.c.


Typedef Documentation

typedef struct boxVert boxVert

Function Documentation

static int box_areasort ( const void *  p1,
const void *  p2 
) [static]

Definition at line 105 of file boxpack2d.c.

References BOXAREA.

Referenced by boxPack2D().

void boxPack2D ( boxPack boxarray,
const int  len,
float *  tot_width,
float *  tot_height 
)
static int vertex_sort ( const void *  p1,
const void *  p2 
) [static]

Definition at line 125 of file boxpack2d.c.

References box_height, box_width, MAX2, boxVert::x, and boxVert::y.

Referenced by boxPack2D().


Variable Documentation

float box_height [static]

Definition at line 122 of file boxpack2d.c.

Referenced by boxPack2D(), and vertex_sort().

float box_width [static]

Definition at line 121 of file boxpack2d.c.

Referenced by boxPack2D(), and vertex_sort().

boxVert* vertarray [static]

Definition at line 123 of file boxpack2d.c.