BRL-CAD
obj_shot.c
Go to the documentation of this file.
1 /* O B J _ S H O T . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2010-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 
21 #include "common.h"
22 
23 #include "raytrace.h"
24 
25 
26 int
27 rt_obj_shot(struct soltab *stp, struct xray *rp, struct application *ap, struct seg *seghead)
28 {
29  int id;
30  const struct rt_functab *ft;
31 
32  if (!stp || !rp)
33  return -1;
34 
35  RT_CK_SOLTAB(stp);
36  RT_CK_RAY(rp);
37  if (ap) RT_CK_APPLICATION(ap);
38 
39  id = stp->st_id;
40  if (id < 0)
41  return -2;
42 
43  ft = &OBJ[id];
44  if (!ft)
45  return -3;
46  if (!ft->ft_shot)
47  return -4;
48 
49  return ft->ft_shot(stp, rp, ap, seghead);
50 }
51 
52 
53 /*
54  * Local Variables:
55  * mode: C
56  * tab-width: 8
57  * indent-tabs-mode: t
58  * c-file-style: "stroustrup"
59  * End:
60  * ex: shiftwidth=4 tabstop=8
61  */
#define RT_CK_APPLICATION(_p)
Definition: raytrace.h:1675
int rt_obj_shot(struct soltab *stp, struct xray *rp, struct application *ap, struct seg *seghead)
Definition: obj_shot.c:27
Definition: raytrace.h:215
Definition: raytrace.h:368
Header file for the BRL-CAD common definitions.
#define RT_CK_RAY(_p)
Definition: raytrace.h:224
int(* ft_shot)(struct soltab *stp, struct xray *rp, struct application *ap, struct seg *seghead)
Definition: raytrace.h:2052
const struct rt_functab OBJ[]
Definition: table.c:159
#define RT_CK_SOLTAB(_p)
Definition: raytrace.h:453
int st_id
Solid ident.
Definition: raytrace.h:431