BRL-CAD
obj_make.c
Go to the documentation of this file.
1 /* O B J _ M A K E . 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_make(const struct rt_functab *ftp, struct rt_db_internal *ip)
28 {
29  int id;
30  const struct rt_functab *ft;
31 
32  if (!ftp || !ip)
33  return -1;
34 
35  RT_CK_FUNCTAB(ftp);
37 
38  id = ip->idb_minor_type;
39  if (id < 0)
40  return -2;
41 
42  ft = &OBJ[id];
43  if (!ft)
44  return -3;
45  if (!ft->ft_make)
46  return -4;
47 
48  /* extra insanity checking */
49  if (ft->ft_make != ftp->ft_make)
50  return -5;
51 
52  ft->ft_make(ftp, ip);
53  return 0;
54 }
55 
56 
57 /*
58  * Local Variables:
59  * mode: C
60  * tab-width: 8
61  * indent-tabs-mode: t
62  * c-file-style: "stroustrup"
63  * End:
64  * ex: shiftwidth=4 tabstop=8
65  */
#define RT_CK_FUNCTAB(_p)
Definition: raytrace.h:2242
int rt_obj_make(const struct rt_functab *ftp, struct rt_db_internal *ip)
Definition: obj_make.c:27
Header file for the BRL-CAD common definitions.
#define RT_CK_DB_INTERNAL(_p)
Definition: raytrace.h:207
const struct rt_functab OBJ[]
Definition: table.c:159
void(* ft_make)(const struct rt_functab *, struct rt_db_internal *)
Definition: raytrace.h:2189
int idb_minor_type
ID_xxx.
Definition: raytrace.h:193