BRL-CAD
obj_export.c
Go to the documentation of this file.
1 /* O B J _ E X P O R 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 "bn.h"
24 #include "raytrace.h"
25 
26 
27 int
28 rt_obj_export(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip, struct resource *resp)
29 {
30  int id;
31  const struct rt_functab *ft;
32  int (*export_func)(struct bu_external *, const struct rt_db_internal *, double, const struct db_i *, struct resource *);
33 
34  if (!ep || !ip || !dbip || local2mm < 0.0)
35  return -1;
36 
37  BU_CK_EXTERNAL(ep);
39  RT_CK_DBI(dbip);
40  if (resp) RT_CK_RESOURCE(resp);
41 
42  id = ip->idb_minor_type;
43  if (id < 0)
44  return -2;
45 
46  ft = &OBJ[id];
47  if (!ft)
48  return -3;
49 
50  if (dbip->dbi_version < 5) {
51  export_func = ft->ft_export4;
52  } else {
53  export_func = ft->ft_export5;
54  }
55 
56  if (!export_func)
57  return -4;
58 
59  return export_func(ep, ip, local2mm, dbip, resp);
60 }
61 
62 
63 /*
64  * Local Variables:
65  * mode: C
66  * tab-width: 8
67  * indent-tabs-mode: t
68  * c-file-style: "stroustrup"
69  * End:
70  * ex: shiftwidth=4 tabstop=8
71  */
Definition: raytrace.h:800
Header file for the BRL-CAD common definitions.
int rt_obj_export(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip, struct resource *resp)
Definition: obj_export.c:28
int(* ft_export4)(struct bu_external *, const struct rt_db_internal *, double, const struct db_i *, struct resource *)
Definition: raytrace.h:2152
#define RT_CK_DB_INTERNAL(_p)
Definition: raytrace.h:207
#define RT_CK_DBI(_p)
Definition: raytrace.h:829
const struct rt_functab OBJ[]
Definition: table.c:159
#define RT_CK_RESOURCE(_p)
Definition: raytrace.h:1490
int idb_minor_type
ID_xxx.
Definition: raytrace.h:193
int dbi_version
PRIVATE: use db_version()
Definition: raytrace.h:824
#define BU_CK_EXTERNAL(_p)
Definition: parse.h:224
int(* ft_export5)(struct bu_external *, const struct rt_db_internal *, double, const struct db_i *, struct resource *)
Definition: raytrace.h:2138