BRL-CAD
scale_rpc.c
Go to the documentation of this file.
1 /* S C A L E _ R P C . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2008-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 libged/scale_rpc.c
21  *
22  * The scale_rpc command.
23  */
24 
25 #include "common.h"
26 
27 #include <string.h>
28 
29 #include "bu/cmd.h"
30 #include "rtgeom.h"
31 #include "raytrace.h"
32 
33 #include "./ged_private.h"
34 
35 int
36 _ged_scale_rpc(struct ged *gedp, struct rt_rpc_internal *rpc, const char *attribute, fastf_t sf, int rflag)
37 {
38  RT_RPC_CK_MAGIC(rpc);
39 
40  switch (attribute[0]) {
41  case 'b':
42  case 'B':
43  if (!rflag)
44  sf /= MAGNITUDE(rpc->rpc_B);
45 
46  VSCALE(rpc->rpc_B, rpc->rpc_B, sf);
47  break;
48  case 'h':
49  case 'H':
50  if (!rflag)
51  sf /= MAGNITUDE(rpc->rpc_H);
52 
53  VSCALE(rpc->rpc_H, rpc->rpc_H, sf);
54  break;
55  case 'r':
56  case 'R':
57  if (rflag)
58  rpc->rpc_r *= sf;
59  else
60  rpc->rpc_r = sf;
61 
62  break;
63  default:
64  bu_vls_printf(gedp->ged_result_str, "bad rpc attribute - %s", attribute);
65  return GED_ERROR;
66  }
67 
68  return GED_OK;
69 }
70 
71 
72 /*
73  * Local Variables:
74  * tab-width: 8
75  * mode: C
76  * indent-tabs-mode: t
77  * c-file-style: "stroustrup"
78  * End:
79  * ex: shiftwidth=4 tabstop=8
80  */
#define GED_OK
Definition: ged.h:55
Definition: ged.h:338
Header file for the BRL-CAD common definitions.
#define GED_ERROR
Definition: ged.h:61
int _ged_scale_rpc(struct ged *gedp, struct rt_rpc_internal *rpc, const char *attribute, fastf_t sf, int rflag)
Definition: scale_rpc.c:36
struct bu_vls * ged_result_str
Definition: ged.h:357
void bu_vls_printf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
Definition: vls.c:694
double fastf_t
Definition: defines.h:300