BRL-CAD

Definitions for handling lists of vectors (really vertices, or points) and polygons in 3-space. Intended for common handling of wireframe display information, in the full resolution that is calculated in. More...

Collaboration diagram for Vector Lists:

Files

file  vlist.h
 

Data Structures

struct  bv_vlist
 
struct  bv_vlblock
 

Macros

#define BV_VLIST_CHUNK   35
 32-bit mach => just less than 1k More...
 
#define BV_VLIST_NULL   ((struct bv_vlist *)0)
 
#define BV_CK_VLIST(_p)   BU_CKMAG((_p), BV_VLIST_MAGIC, "bv_vlist")
 
#define BV_VLIST_LINE_MOVE   0
 specify new line More...
 
#define BV_VLIST_LINE_DRAW   1
 subsequent line vertex More...
 
#define BV_VLIST_POLY_START   2
 pt[] has surface normal More...
 
#define BV_VLIST_POLY_MOVE   3
 move to first poly vertex More...
 
#define BV_VLIST_POLY_DRAW   4
 subsequent poly vertex More...
 
#define BV_VLIST_POLY_END   5
 last vert (repeats 1st), draw poly More...
 
#define BV_VLIST_POLY_VERTNORM   6
 per-vertex normal, for interpolation More...
 
#define BV_VLIST_TRI_START   7
 pt[] has surface normal More...
 
#define BV_VLIST_TRI_MOVE   8
 move to first triangle vertex More...
 
#define BV_VLIST_TRI_DRAW   9
 subsequent triangle vertex More...
 
#define BV_VLIST_TRI_END   10
 last vert (repeats 1st), draw poly More...
 
#define BV_VLIST_TRI_VERTNORM   11
 per-vertex normal, for interpolation More...
 
#define BV_VLIST_POINT_DRAW   12
 Draw a single point. More...
 
#define BV_VLIST_POINT_SIZE   13
 specify point pixel size More...
 
#define BV_VLIST_LINE_WIDTH   14
 specify line pixel width More...
 
#define BV_VLIST_DISPLAY_MAT   15
 specify the model matrix More...
 
#define BV_VLIST_MODEL_MAT   16
 specify the display matrix More...
 
#define BV_VLIST_CMD_MAX   16
 Max command number. More...
 
#define BV_GET_VLIST(_free_hd, p)
 
#define BV_FREE_VLIST(_free_hd, hd)
 
#define BV_ADD_VLIST(_free_hd, _dest_hd, pnt, draw)
 
#define BV_VLIST_SET_DISP_MAT(_free_hd, _dest_hd, _ref_pt)
 
#define BV_VLIST_SET_MODEL_MAT(_free_hd, _dest_hd)
 
#define BV_VLIST_SET_POINT_SIZE(_free_hd, _dest_hd, _size)
 
#define BV_VLIST_SET_LINE_WIDTH(_free_hd, _dest_hd, _width)
 
#define BV_CK_VLBLOCK(_p)   BU_CKMAG((_p), BV_VLBLOCK_MAGIC, "bv_vlblock")
 

Functions

size_t bv_vlist_cmd_cnt (struct bv_vlist *vlist)
 
int bv_vlist_bbox (struct bu_list *vlistp, point_t *bmin, point_t *bmax, size_t *length, int *dispmode)
 
void bv_vlist_3string (struct bu_list *vhead, struct bu_list *free_hd, const char *string, const point_t origin, const mat_t rot, double scale)
 
void bv_vlist_2string (struct bu_list *vhead, struct bu_list *free_hd, const char *string, double x, double y, double scale, double theta)
 
const char * bv_vlist_get_cmd_description (int cmd)
 
size_t bv_ck_vlist (const struct bu_list *vhead)
 
void bv_vlist_copy (struct bu_list *vlists, struct bu_list *dest, const struct bu_list *src)
 
void bv_vlist_export (struct bu_vls *vls, struct bu_list *hp, const char *name)
 
void bv_vlist_import (struct bu_list *vlists, struct bu_list *hp, struct bu_vls *namevls, const unsigned char *buf)
 
void bv_vlist_cleanup (struct bu_list *hd)
 
struct bv_vlblockbv_vlblock_init (struct bu_list *free_vlist_hd, int max_ent)
 
void bv_vlblock_free (struct bv_vlblock *vbp)
 
struct bu_listbv_vlblock_find (struct bv_vlblock *vbp, int r, int g, int b)
 
void bv_vlist_rpp (struct bu_list *vlists, struct bu_list *hd, const point_t minn, const point_t maxx)
 
void bv_plot_vlblock (FILE *fp, const struct bv_vlblock *vbp)
 
void bv_vlblock_to_objs (struct bu_ptbl *out, const char *name_root, struct bv_vlblock *vbp, struct bview *v, struct bv_scene_obj *f, struct bu_list *vlfree)
 
struct bv_scene_objbv_vlblock_obj (struct bv_vlblock *vbp, struct bview *v, const char *name)
 
void bv_vlist_to_uplot (FILE *fp, const struct bu_list *vhead)
 

Detailed Description

Definitions for handling lists of vectors (really vertices, or points) and polygons in 3-space. Intended for common handling of wireframe display information, in the full resolution that is calculated in.

On 32-bit machines, BV_VLIST_CHUNK of 35 results in bv_vlist structures just less than 1k bytes.

The head of the doubly linked list can be just a "struct bu_list" head.

To visit all the elements in the vlist: for (BU_LIST_FOR(vp, bv_vlist, hp)) { int i; int nused = vp->nused; int *cmd = vp->cmd; point_t *pt = vp->pt; for (i = 0; i < nused; i++, cmd++, pt++) { access(*cmd, *pt); access(vp->cmd[i], vp->pt[i]); } }

Macro Definition Documentation

◆ BV_VLIST_CHUNK

#define BV_VLIST_CHUNK   35

32-bit mach => just less than 1k

Definition at line 62 of file vlist.h.

◆ BV_VLIST_NULL

#define BV_VLIST_NULL   ((struct bv_vlist *)0)

Definition at line 70 of file vlist.h.

◆ BV_CK_VLIST

#define BV_CK_VLIST (   _p)    BU_CKMAG((_p), BV_VLIST_MAGIC, "bv_vlist")

Definition at line 71 of file vlist.h.

◆ BV_VLIST_LINE_MOVE

#define BV_VLIST_LINE_MOVE   0

specify new line

Definition at line 75 of file vlist.h.

◆ BV_VLIST_LINE_DRAW

#define BV_VLIST_LINE_DRAW   1

subsequent line vertex

Definition at line 76 of file vlist.h.

◆ BV_VLIST_POLY_START

#define BV_VLIST_POLY_START   2

pt[] has surface normal

Definition at line 77 of file vlist.h.

◆ BV_VLIST_POLY_MOVE

#define BV_VLIST_POLY_MOVE   3

move to first poly vertex

Definition at line 78 of file vlist.h.

◆ BV_VLIST_POLY_DRAW

#define BV_VLIST_POLY_DRAW   4

subsequent poly vertex

Definition at line 79 of file vlist.h.

◆ BV_VLIST_POLY_END

#define BV_VLIST_POLY_END   5

last vert (repeats 1st), draw poly

Definition at line 80 of file vlist.h.

◆ BV_VLIST_POLY_VERTNORM

#define BV_VLIST_POLY_VERTNORM   6

per-vertex normal, for interpolation

Definition at line 81 of file vlist.h.

◆ BV_VLIST_TRI_START

#define BV_VLIST_TRI_START   7

pt[] has surface normal

Definition at line 82 of file vlist.h.

◆ BV_VLIST_TRI_MOVE

#define BV_VLIST_TRI_MOVE   8

move to first triangle vertex

Definition at line 83 of file vlist.h.

◆ BV_VLIST_TRI_DRAW

#define BV_VLIST_TRI_DRAW   9

subsequent triangle vertex

Definition at line 84 of file vlist.h.

◆ BV_VLIST_TRI_END

#define BV_VLIST_TRI_END   10

last vert (repeats 1st), draw poly

Definition at line 85 of file vlist.h.

◆ BV_VLIST_TRI_VERTNORM

#define BV_VLIST_TRI_VERTNORM   11

per-vertex normal, for interpolation

Definition at line 86 of file vlist.h.

◆ BV_VLIST_POINT_DRAW

#define BV_VLIST_POINT_DRAW   12

Draw a single point.

Definition at line 87 of file vlist.h.

◆ BV_VLIST_POINT_SIZE

#define BV_VLIST_POINT_SIZE   13

specify point pixel size

Definition at line 88 of file vlist.h.

◆ BV_VLIST_LINE_WIDTH

#define BV_VLIST_LINE_WIDTH   14

specify line pixel width

Definition at line 89 of file vlist.h.

◆ BV_VLIST_DISPLAY_MAT

#define BV_VLIST_DISPLAY_MAT   15

specify the model matrix

Definition at line 90 of file vlist.h.

◆ BV_VLIST_MODEL_MAT

#define BV_VLIST_MODEL_MAT   16

specify the display matrix

Definition at line 91 of file vlist.h.

◆ BV_VLIST_CMD_MAX

#define BV_VLIST_CMD_MAX   16

Max command number.

Definition at line 92 of file vlist.h.

◆ BV_GET_VLIST

#define BV_GET_VLIST (   _free_hd,
 
)
Value:
do {\
(p) = BU_LIST_FIRST(bv_vlist, (_free_hd)); \
if (BU_LIST_IS_HEAD((p), (_free_hd))) { \
BU_ALLOC((p), struct bv_vlist); \
(p)->l.magic = BV_VLIST_MAGIC; \
} else { \
BU_LIST_DEQUEUE(&((p)->l)); \
} \
(p)->nused = 0; \
} while (0)
#define BU_LIST_FIRST(structure, headp)
Definition: list.h:326
#define BU_LIST_IS_HEAD(p, headp)
Definition: list.h:336
#define BV_VLIST_MAGIC
Definition: magic.h:87
Definition: vlist.h:64

Applications that are going to use BV_ADD_VLIST and BV_GET_VLIST are required to execute this macro once, on their _free_hd: BU_LIST_INIT(&_free_hd);

Note that BV_GET_VLIST and BV_FREE_VLIST are non-PARALLEL.

Definition at line 100 of file vlist.h.

◆ BV_FREE_VLIST

#define BV_FREE_VLIST (   _free_hd,
  hd 
)
Value:
do { \
BU_CK_LIST_HEAD((hd)); \
BU_LIST_APPEND_LIST((_free_hd), (hd)); \
} while (0)

Place an entire chain of bv_vlist structs on the freelist _free_hd

Definition at line 112 of file vlist.h.

◆ BV_ADD_VLIST

#define BV_ADD_VLIST (   _free_hd,
  _dest_hd,
  pnt,
  draw 
)
Value:
do { \
struct bv_vlist *_vp; \
BU_CK_LIST_HEAD(_dest_hd); \
_vp = BU_LIST_LAST(bv_vlist, (_dest_hd)); \
if (BU_LIST_IS_HEAD(_vp, (_dest_hd)) || _vp->nused >= BV_VLIST_CHUNK) { \
BV_GET_VLIST(_free_hd, _vp); \
BU_LIST_INSERT((_dest_hd), &(_vp->l)); \
} \
VMOVE(_vp->pt[_vp->nused], (pnt)); \
_vp->cmd[_vp->nused++] = (draw); \
} while (0)
#define BU_LIST_LAST(structure, headp)
Definition: list.h:320
#define BV_VLIST_CHUNK
32-bit mach => just less than 1k
Definition: vlist.h:62
Definition: geom.h:906

Definition at line 117 of file vlist.h.

◆ BV_VLIST_SET_DISP_MAT

#define BV_VLIST_SET_DISP_MAT (   _free_hd,
  _dest_hd,
  _ref_pt 
)
Value:
do { \
struct bv_vlist *_vp; \
BU_CK_LIST_HEAD(_dest_hd); \
_vp = BU_LIST_LAST(bv_vlist, (_dest_hd)); \
if (BU_LIST_IS_HEAD(_vp, (_dest_hd)) || _vp->nused >= BV_VLIST_CHUNK) { \
BV_GET_VLIST(_free_hd, _vp); \
BU_LIST_INSERT((_dest_hd), &(_vp->l)); \
} \
VMOVE(_vp->pt[_vp->nused], (_ref_pt)); \
_vp->cmd[_vp->nused++] = BV_VLIST_DISPLAY_MAT; \
} while (0)
#define BV_VLIST_DISPLAY_MAT
specify the model matrix
Definition: vlist.h:90

Change the transformation matrix to display

Definition at line 130 of file vlist.h.

◆ BV_VLIST_SET_MODEL_MAT

#define BV_VLIST_SET_MODEL_MAT (   _free_hd,
  _dest_hd 
)
Value:
do { \
struct bv_vlist *_vp; \
BU_CK_LIST_HEAD(_dest_hd); \
_vp = BU_LIST_LAST(bv_vlist, (_dest_hd)); \
if (BU_LIST_IS_HEAD(_vp, (_dest_hd)) || _vp->nused >= BV_VLIST_CHUNK) { \
BV_GET_VLIST(_free_hd, _vp); \
BU_LIST_INSERT((_dest_hd), &(_vp->l)); \
} \
_vp->cmd[_vp->nused++] = BV_VLIST_MODEL_MAT; \
} while (0)
#define BV_VLIST_MODEL_MAT
specify the display matrix
Definition: vlist.h:91

Change the transformation matrix to model

Definition at line 143 of file vlist.h.

◆ BV_VLIST_SET_POINT_SIZE

#define BV_VLIST_SET_POINT_SIZE (   _free_hd,
  _dest_hd,
  _size 
)
Value:
do { \
struct bv_vlist *_vp; \
BU_CK_LIST_HEAD(_dest_hd); \
_vp = BU_LIST_LAST(bv_vlist, (_dest_hd)); \
if (BU_LIST_IS_HEAD(_vp, (_dest_hd)) || _vp->nused >= BV_VLIST_CHUNK) { \
BV_GET_VLIST(_free_hd, _vp); \
BU_LIST_INSERT((_dest_hd), &(_vp->l)); \
} \
_vp->pt[_vp->nused][0] = (_size); \
_vp->cmd[_vp->nused++] = BV_VLIST_POINT_SIZE; \
} while (0)
#define BV_VLIST_POINT_SIZE
specify point pixel size
Definition: vlist.h:88

Set a point size to apply to the vlist elements that follow.

Definition at line 155 of file vlist.h.

◆ BV_VLIST_SET_LINE_WIDTH

#define BV_VLIST_SET_LINE_WIDTH (   _free_hd,
  _dest_hd,
  _width 
)
Value:
do { \
struct bv_vlist *_vp; \
BU_CK_LIST_HEAD(_dest_hd); \
_vp = BU_LIST_LAST(bv_vlist, (_dest_hd)); \
if (BU_LIST_IS_HEAD(_vp, (_dest_hd)) || _vp->nused >= BV_VLIST_CHUNK) { \
BV_GET_VLIST(_free_hd, _vp); \
BU_LIST_INSERT((_dest_hd), &(_vp->l)); \
} \
_vp->pt[_vp->nused][0] = (_width); \
_vp->cmd[_vp->nused++] = BV_VLIST_LINE_WIDTH; \
} while (0)
#define BV_VLIST_LINE_WIDTH
specify line pixel width
Definition: vlist.h:89

Set a line width to apply to the vlist elements that follow.

Definition at line 168 of file vlist.h.

◆ BV_CK_VLBLOCK

#define BV_CK_VLBLOCK (   _p)    BU_CKMAG((_p), BV_VLBLOCK_MAGIC, "bv_vlblock")

Definition at line 198 of file vlist.h.

Function Documentation

◆ bv_vlist_cmd_cnt()

size_t bv_vlist_cmd_cnt ( struct bv_vlist vlist)

◆ bv_vlist_bbox()

int bv_vlist_bbox ( struct bu_list vlistp,
point_t bmin,
point_t bmax,
size_t *  length,
int *  dispmode 
)

◆ bv_vlist_3string()

void bv_vlist_3string ( struct bu_list vhead,
struct bu_list free_hd,
const char *  string,
const point_t  origin,
const mat_t  rot,
double  scale 
)

Convert a string to a vlist.

'scale' is the width, in mm, of one character.

Parameters
vheadvhead
free_hdsource of free vlists
stringstring of chars to be plotted
originlower left corner of 1st char
rotTransform matrix (WARNING: may xlate)
scalescale factor to change 1x1 char sz

◆ bv_vlist_2string()

void bv_vlist_2string ( struct bu_list vhead,
struct bu_list free_hd,
const char *  string,
double  x,
double  y,
double  scale,
double  theta 
)

Convert string to vlist in 2D

A simpler interface, for those cases where the text lies in the X-Y plane.

Parameters
vheadvhead
free_hdsource of free vlists
stringstring of chars to be plotted
xlower left corner of 1st char
ylower left corner of 1st char
scalescale factor to change 1x1 char sz
thetadegrees ccw from X-axis

◆ bv_vlist_get_cmd_description()

const char * bv_vlist_get_cmd_description ( int  cmd)

Returns the description of a vlist cmd. Caller is responsible for freeing the returned string.

◆ bv_ck_vlist()

size_t bv_ck_vlist ( const struct bu_list vhead)

Validate an bv_vlist chain for having reasonable values inside. Calls bu_bomb() if not.

Returns - npts Number of point/command sets in use.

◆ bv_vlist_copy()

void bv_vlist_copy ( struct bu_list vlists,
struct bu_list dest,
const struct bu_list src 
)

Duplicate the contents of a vlist. Note that the copy may be more densely packed than the source.

◆ bv_vlist_export()

void bv_vlist_export ( struct bu_vls vls,
struct bu_list hp,
const char *  name 
)

Convert a vlist chain into a blob of network-independent binary, for transmission to another machine.

The result is stored in a vls string, so that both the address and length are available conveniently.

◆ bv_vlist_import()

void bv_vlist_import ( struct bu_list vlists,
struct bu_list hp,
struct bu_vls namevls,
const unsigned char *  buf 
)

Convert a blob of network-independent binary prepared by vls_vlist() and received from another machine, into a vlist chain.

◆ bv_vlist_cleanup()

void bv_vlist_cleanup ( struct bu_list hd)

◆ bv_vlblock_init()

struct bv_vlblock * bv_vlblock_init ( struct bu_list free_vlist_hd,
int  max_ent 
)

◆ bv_vlblock_free()

void bv_vlblock_free ( struct bv_vlblock vbp)

◆ bv_vlblock_find()

struct bu_list * bv_vlblock_find ( struct bv_vlblock vbp,
int  r,
int  g,
int  b 
)

◆ bv_vlist_rpp()

void bv_vlist_rpp ( struct bu_list vlists,
struct bu_list hd,
const point_t  minn,
const point_t  maxx 
)

◆ bv_plot_vlblock()

void bv_plot_vlblock ( FILE *  fp,
const struct bv_vlblock vbp 
)

Output a bv_vlblock object in extended UNIX-plot format, including color.

◆ bv_vlblock_to_objs()

void bv_vlblock_to_objs ( struct bu_ptbl out,
const char *  name_root,
struct bv_vlblock vbp,
struct bview v,
struct bv_scene_obj f,
struct bu_list vlfree 
)

◆ bv_vlblock_obj()

struct bv_scene_obj * bv_vlblock_obj ( struct bv_vlblock vbp,
struct bview v,
const char *  name 
)

◆ bv_vlist_to_uplot()

void bv_vlist_to_uplot ( FILE *  fp,
const struct bu_list vhead 
)

Output a vlist as an extended 3-D floating point UNIX-Plot file. You provide the file. Uses libplot3 routines to create the UNIX-Plot output.