BRL-CAD
rotate_tgc.c
Go to the documentation of this file.
1 /* R O T A T E _ T G 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/rotate_tgc.c
21  *
22  * The rotate_tgc command.
23  *
24  */
25 
26 #include "common.h"
27 
28 #include <string.h>
29 
30 #include "bu/cmd.h"
31 #include "rtgeom.h"
32 #include "raytrace.h"
33 
34 #include "./ged_private.h"
35 
36 
37 int
38 _ged_rotate_tgc(struct ged *gedp, struct rt_tgc_internal *tgc, const char *attribute, matp_t rmat)
39 {
40  RT_TGC_CK_MAGIC(tgc);
41 
42  switch (attribute[0]) {
43  case 'h':
44  case 'H':
45  switch (attribute[1]) {
46  case '\0':
47  MAT4X3VEC(tgc->h, rmat, tgc->h);
48  break;
49  case 'a':
50  case 'A':
51  if ((attribute[2] == 'b' || attribute[2] == 'B') &&
52  attribute[3] == '\0') {
53  MAT4X3VEC(tgc->a, rmat, tgc->a);
54  MAT4X3VEC(tgc->b, rmat, tgc->b);
55  MAT4X3VEC(tgc->c, rmat, tgc->c);
56  MAT4X3VEC(tgc->d, rmat, tgc->d);
57  } else {
58  bu_vls_printf(gedp->ged_result_str, "bad tgc attribute - %s", attribute);
59  return GED_ERROR;
60  }
61 
62  break;
63  default:
64  bu_vls_printf(gedp->ged_result_str, "bad tgc attribute - %s", attribute);
65  return GED_ERROR;
66  }
67 
68  break;
69  default:
70  bu_vls_printf(gedp->ged_result_str, "bad tgc attribute - %s", attribute);
71  return GED_ERROR;
72  }
73 
74  return GED_OK;
75 }
76 
77 
78 /*
79  * Local Variables:
80  * tab-width: 8
81  * mode: C
82  * indent-tabs-mode: t
83  * c-file-style: "stroustrup"
84  * End:
85  * ex: shiftwidth=4 tabstop=8
86  */
#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_rotate_tgc(struct ged *gedp, struct rt_tgc_internal *tgc, const char *attribute, matp_t rmat)
Definition: rotate_tgc.c:38
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