BRL-CAD
vol.c
Go to the documentation of this file.
1 /* V O L . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1994-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @file libwdb/vol.c
21  *
22  */
23 
24 #include "common.h"
25 
26 #include <string.h>
27 #include "bio.h"
28 
29 #include "vmath.h"
30 #include "bn.h"
31 #include "rtgeom.h"
32 #include "raytrace.h"
33 #include "wdb.h"
34 #include "db.h"
35 
36 
37 int
38 mk_vol(struct rt_wdb *fp, const char *name, const char *file, size_t xdim, size_t ydim, size_t zdim, size_t lo, size_t hi, const fastf_t *cellsize, const matp_t mat)
39  /* name of file containing bitmap */
40  /* X dimension of file (w cells) */
41  /* Y dimension of file (n cells) */
42  /* Z dimension of file (d cells) */
43  /* Low threshold */
44  /* High threshold */
45  /* ideal coords: size of each cell */
46  /* convert local coords to model space */
47 {
48  struct rt_vol_internal *vol;
49 
50  BU_ALLOC(vol, struct rt_vol_internal);
51  vol->magic = RT_VOL_INTERNAL_MAGIC;
52  bu_strlcpy(vol->file, file, RT_VOL_NAME_LEN);
53  vol->xdim = xdim;
54  vol->ydim = ydim;
55  vol->zdim = zdim;
56  vol->lo = lo;
57  vol->hi = hi;
58  VMOVE(vol->cellsize, cellsize);
59  MAT_COPY(vol->mat, mat);
60 
61  return wdb_export(fp, name, (void *)vol, ID_VOL, mk_conv2mm);
62 }
63 
64 
65 /*
66  * Local Variables:
67  * mode: C
68  * tab-width: 8
69  * indent-tabs-mode: t
70  * c-file-style: "stroustrup"
71  * End:
72  * ex: shiftwidth=4 tabstop=8
73  */
Definition: clone.c:90
Header file for the BRL-CAD common definitions.
#define ID_VOL
3-D Volume
Definition: raytrace.h:471
int wdb_export(struct rt_wdb *wdbp, const char *name, void *gp, int id, double local2mm)
Definition: wdb.c:265
#define BU_ALLOC(_ptr, _type)
Definition: malloc.h:223
#define bu_strlcpy(dst, src, size)
Definition: str.h:60
#define RT_VOL_INTERNAL_MAGIC
Definition: magic.h:113
double mk_conv2mm
Conversion factor to mm.
Definition: units.c:37
int mk_vol(struct rt_wdb *fp, const char *name, const char *file, size_t xdim, size_t ydim, size_t zdim, size_t lo, size_t hi, const fastf_t *cellsize, const matp_t mat)
Definition: vol.c:38
double fastf_t
Definition: defines.h:300