BRL-CAD
units.c
Go to the documentation of this file.
1 /* U N I T S . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1990-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/units.c
21  *
22  * Module of libwdb to handle units conversion.
23  *
24  */
25 
26 #include "common.h"
27 
28 #include <ctype.h>
29 #include "bio.h"
30 
31 #include "vmath.h"
32 #include "bu/units.h"
33 #include "bn.h"
34 #include "raytrace.h"
35 #include "wdb.h"
36 
37 double mk_conv2mm = 1.0; /* Conversion factor to mm */
38 
39 
40 int
41 mk_conversion(char *str)
42 {
43  double d;
44 
45  if ((d = bu_units_conversion(str)) <= 0.0) return -1;
46  return mk_set_conversion(d);
47 }
48 
49 
50 int
52 {
53  if (val <= 0.0) return -1;
54  mk_conv2mm = val;
55  return 0;
56 }
57 
58 
59 /*
60  * Local Variables:
61  * mode: C
62  * tab-width: 8
63  * indent-tabs-mode: t
64  * c-file-style: "stroustrup"
65  * End:
66  * ex: shiftwidth=4 tabstop=8
67  */
Definition: db_flip.c:35
Header file for the BRL-CAD common definitions.
double val
Definition: units.c:42
double bu_units_conversion(const char *str)
Definition: units.c:234
int mk_conversion(char *str)
Definition: units.c:41
double mk_conv2mm
Conversion factor to mm.
Definition: units.c:37
int mk_set_conversion(double val)
Definition: units.c:51