BRL-CAD
dsp.c
Go to the documentation of this file.
1 /* D S P . 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/dsp.c
21  *
22  */
23 
24 #include "common.h"
25 
26 #include "bio.h"
27 
28 #include "vmath.h"
29 #include "bn.h"
30 #include "rtgeom.h"
31 #include "raytrace.h"
32 #include "wdb.h"
33 #include "db.h"
34 
35 int
36 mk_dsp(struct rt_wdb *fp, const char *name, const char *file, size_t xdim, size_t ydim, const matp_t mat)
37  /* name of file containing elevation data */
38  /* X dimension of file (w cells) */
39  /* Y dimension of file (n cells) */
40  /* convert solid coords to model space */
41 {
42  struct rt_dsp_internal *dsp;
43 
44  BU_ALLOC(dsp, struct rt_dsp_internal);
45  dsp->magic = RT_DSP_INTERNAL_MAGIC;
46 
47  bu_vls_init(&dsp->dsp_name);
48  bu_vls_strcat(&dsp->dsp_name, file);
49 
50  dsp->dsp_xcnt = xdim;
51  dsp->dsp_ycnt = ydim;
52  MAT_COPY(dsp->dsp_stom, mat);
53 
54  return wdb_export(fp, name, (void *)dsp, ID_DSP, mk_conv2mm);
55 }
56 
57 
58 /*
59  * Local Variables:
60  * mode: C
61  * tab-width: 8
62  * indent-tabs-mode: t
63  * c-file-style: "stroustrup"
64  * End:
65  * ex: shiftwidth=4 tabstop=8
66  */
void bu_vls_init(struct bu_vls *vp)
Definition: vls.c:56
#define RT_DSP_INTERNAL_MAGIC
Definition: magic.h:88
Definition: clone.c:90
void bu_vls_strcat(struct bu_vls *vp, const char *s)
Definition: vls.c:368
Header file for the BRL-CAD common definitions.
#define ID_DSP
Displacement map.
Definition: raytrace.h:483
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
double mk_conv2mm
Conversion factor to mm.
Definition: units.c:37
int mk_dsp(struct rt_wdb *fp, const char *name, const char *file, size_t xdim, size_t ydim, const matp_t mat)
Definition: dsp.c:36