BRL-CAD
constraint.c
Go to the documentation of this file.
1 /* C O N S T R A I N 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 /** @addtogroup pcdbio */
21 /** @{ */
22 /** @file libwdb/constraint.c
23  *
24  * @brief External C Routines of Parametrics and Constraints API
25  *
26  */
27 
28 #include "common.h"
29 
30 #include <stdlib.h>
31 
32 #include "raytrace.h"
33 #include "wdb.h"
34 
35 
36 int
37 mk_constraint(struct rt_wdb *wdbp, const char *name, const char *UNUSED(expr))
38 {
39  struct rt_db_internal intern;
40  struct rt_constraint_internal *constraint;
41 
42  RT_CK_WDB(wdbp);
43 
44  RT_DB_INTERNAL_INIT(&intern);
45 
46  /* Create a fresh new object for export */
47  BU_ALLOC(constraint, struct rt_constraint_internal);
48  constraint->magic = RT_CONSTRAINT_MAGIC;
49  constraint->id = constraint->type = 0;
50  BU_VLS_INIT(&constraint->expression);
51 
52  intern.idb_major_type = DB5_MAJORTYPE_BRLCAD;
53  intern.idb_type = ID_CONSTRAINT;
54  intern.idb_ptr = (void *)constraint;
55  intern.idb_meth = &OBJ[ID_CONSTRAINT];
56 
57  /* Add data */
58  constraint->id=1432;
59  constraint->type=323;
60 
61  /* The internal representation will be freed */
62  return wdb_put_internal(wdbp, name, &intern, mk_conv2mm);
63 }
64 
65 
66 /** @} */
67 /*
68  * Local Variables:
69  * mode: C
70  * tab-width: 8
71  * indent-tabs-mode: t
72  * c-file-style: "stroustrup"
73  * End:
74  * ex: shiftwidth=4 tabstop=8
75  */
Definition: clone.c:90
Header file for the BRL-CAD common definitions.
int wdb_put_internal(struct rt_wdb *wdbp, const char *name, struct rt_db_internal *ip, double local2mm)
Definition: wdb.c:218
#define RT_CK_WDB(_p)
Definition: raytrace.h:1292
int idb_major_type
Definition: raytrace.h:192
struct bu_vls expression
Definition: raytrace.h:1026
#define ID_CONSTRAINT
Constraint object.
Definition: raytrace.h:503
#define BU_ALLOC(_ptr, _type)
Definition: malloc.h:223
#define RT_DB_INTERNAL_INIT(_p)
Definition: raytrace.h:199
const struct rt_functab * idb_meth
for ft_ifree(), etc.
Definition: raytrace.h:194
#define UNUSED(parameter)
Definition: common.h:239
double mk_conv2mm
Conversion factor to mm.
Definition: units.c:37
void * idb_ptr
Definition: raytrace.h:195
int mk_constraint(struct rt_wdb *wdbp, const char *name, const char *expr)
Definition: constraint.c:37
const struct rt_functab OBJ[]
Definition: table.c:159
#define RT_CONSTRAINT_MAGIC
Definition: magic.h:154
#define BU_VLS_INIT(_vp)
Definition: vls.h:74