BRL-CAD
scale_part.c
Go to the documentation of this file.
1 /* S C A L E _ P A R T . 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_part.c
21  *
22  * The scale_part 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_part(struct ged *gedp, struct rt_part_internal *part, const char *attribute, fastf_t sf, int rflag)
37 {
38  RT_PART_CK_MAGIC(part);
39 
40  switch (attribute[0]) {
41  case 'H':
42  if (!rflag)
43  sf /= MAGNITUDE(part->part_H);
44 
45  VSCALE(part->part_H, part->part_H, sf);
46  break;
47  case 'v':
48  if (rflag)
49  part->part_vrad *= sf;
50  else
51  part->part_vrad = sf;
52 
53  break;
54  case 'h':
55  if (rflag)
56  part->part_hrad *= sf;
57  else
58  part->part_hrad = sf;
59 
60  break;
61  default:
62  bu_vls_printf(gedp->ged_result_str, "bad part attribute - %s", attribute);
63  return GED_ERROR;
64  }
65 
66  return GED_OK;
67 }
68 
69 
70 /*
71  * Local Variables:
72  * tab-width: 8
73  * mode: C
74  * indent-tabs-mode: t
75  * c-file-style: "stroustrup"
76  * End:
77  * ex: shiftwidth=4 tabstop=8
78  */
#define GED_OK
Definition: ged.h:55
int _ged_scale_part(struct ged *gedp, struct rt_part_internal *part, const char *attribute, fastf_t sf, int rflag)
Definition: scale_part.c:36
Definition: ged.h:338
Header file for the BRL-CAD common definitions.
#define GED_ERROR
Definition: ged.h:61
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