BRL-CAD
id.c
Go to the documentation of this file.
1 /* I D . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1987-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/id.c
21  *
22  * An ID record must be the first granule in the database.
23  *
24  * Return codes of 0 are OK, -1 signal an error.
25  *
26  */
27 
28 #include "common.h"
29 
30 #include <math.h>
31 #include "bio.h"
32 
33 #include "db.h"
34 #include "vmath.h"
35 #include "bu/units.h"
36 #include "bn.h"
37 #include "rtgeom.h"
38 #include "raytrace.h"
39 #include "wdb.h"
40 
41 
42 int
43 mk_id(struct rt_wdb *fp, const char *title)
44 {
45  return mk_id_editunits(fp, title, 1.0);
46 }
47 
48 
49 int
50 mk_id_units(struct rt_wdb *fp, const char *title, const char *units)
51 {
52  return mk_id_editunits(fp, title, bu_units_conversion(units));
53 }
54 
55 
56 int
58  struct rt_wdb *wdbp,
59  const char *title,
60  double local2mm)
61 {
62  RT_CK_WDB(wdbp);
63  return db_update_ident(wdbp->dbip, title, local2mm);
64 }
65 
66 
67 /*
68  * Local Variables:
69  * mode: C
70  * tab-width: 8
71  * indent-tabs-mode: t
72  * c-file-style: "stroustrup"
73  * End:
74  * ex: shiftwidth=4 tabstop=8
75  */
struct db_i * dbip
Definition: raytrace.h:1266
Header file for the BRL-CAD common definitions.
#define RT_CK_WDB(_p)
Definition: raytrace.h:1292
double bu_units_conversion(const char *str)
Definition: units.c:234
int db_update_ident(struct db_i *dbip, const char *title, double local2mm)
Definition: db_scan.c:367
int mk_id_units(struct rt_wdb *fp, const char *title, const char *units)
Definition: id.c:50
int mk_id(struct rt_wdb *fp, const char *title)
Definition: id.c:43
int mk_id_editunits(struct rt_wdb *wdbp, const char *title, double local2mm)
Definition: id.c:57