BRL-CAD
pc.h
Go to the documentation of this file.
1 /* P C . H
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 libpc */
21 /** @{ */
22 /** @file pc.h
23  *
24  * Structures required for implementing Parametrics and constraints
25  *
26  */
27 #ifndef PC_H
28 #define PC_H
29 
30 #include "common.h"
31 
32 #include "bu/list.h"
33 #include "bu/vls.h"
34 #include "bn.h"
35 
37 
38 #ifndef PC_EXPORT
39 # if defined(PC_DLL_EXPORTS) && defined(PC_DLL_IMPORTS)
40 # error "Only PC_DLL_EXPORTS or PC_DLL_IMPORTS can be defined, not both."
41 # elif defined(PC_DLL_EXPORTS)
42 # define PC_EXPORT __declspec(dllexport)
43 # elif defined(PC_DLL_IMPORTS)
44 # define PC_EXPORT __declspec(dllimport)
45 # else
46 # define PC_EXPORT
47 # endif
48 #endif
49 
50 /*
51  * Macros for providing function prototypes, regardless of whether the
52  * compiler understands them or not. It is vital that the argument
53  * list given for "args" be enclosed in parens.
54  */
55 
56 #define PC_PCSET_PUSHP(_pcsp,_par) \
57  BU_LIST_PUSH(&(_pcsp->ps->l),&(_par->l));
58 #define PC_PCSET_PUSHC(_pcsp,_con) \
59  BU_LIST_PUSH(&(_pcsp->cs->l),&(_con->l));
60 
61 /** Definitions for data storage and transfer type information */
62 #define PC_DB_FASTF_T 1
63 #define PC_DB_POINT_T 2
64 #define PC_DB_VECTOR_T 3
65 
66 #define PC_DB_BYSTRUCT 1
67 #define PC_DB_BYEXPR 2
68 
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72 
73 /**
74  * A composite set of parameters constraints with respect to those
75  * parameters. Used for declaration by each geometry object
76  */
77 struct pc_param {
78  struct bu_list l;
79  struct bu_vls name; /** Name of the parameter */
80 
81  /** @todo convert to enum after pc becomes a dependency of rt */
82  int ctype; /** Container type used for storing data */
83  int dtype; /** Data type of the data pointed to */
84 
85  union { /** The Actual data / pointer */
87  void * ptr;
88  } data;
89 };
90 
92  int nargs;
93  int dimension;
94  int (*fp) (double ** a);
95 };
96 
97 struct pc_constrnt {
98  struct bu_list l;
99  struct bu_vls name;
100  int ctype;
101  union {
104  } data;
105  const char **args;
106 };
107 
108 struct pc_pc_set {
109  struct pc_param * ps;
110  struct pc_constrnt * cs;
111 };
112 
113 /* functions defined in pc_main.c */
114 
115 PC_EXPORT extern void pc_init_pcset(struct pc_pc_set * pcs);
116 PC_EXPORT extern void pc_free_pcset(struct pc_pc_set * pcs);
117 PC_EXPORT extern void pc_free_constraint(struct pc_constrnt * c);
118 PC_EXPORT extern void pc_getparameter(struct pc_param **p, int t);
119 PC_EXPORT extern void pc_pushparam_expr(struct pc_pc_set * pcsp, const char *name, const char *str);
120 PC_EXPORT extern void pc_pushparam_struct(struct pc_pc_set * pcs, const char * name, int type, void * ptr);
121 PC_EXPORT extern void pc_getconstraint_expr(struct pc_constrnt ** c);
122 PC_EXPORT extern void pc_getconstraint_struct(struct pc_constrnt **c, int nargs);
123 PC_EXPORT extern void pc_pushconstraint_expr(struct pc_pc_set * pcsp, const char * name, const char * str);
124 PC_EXPORT extern void pc_pushconstraint_struct(struct pc_pc_set * pcs, const char * name, int nargs, int dimension, int (*fp) (double ** args), const char ** args);
125 PC_EXPORT extern void pc_pushconstraint_struct1(struct pc_pc_set * pcs, struct pc_constrnt * c);
126 PC_EXPORT extern void pc_pushconstraint(struct pc_pc_set * pcs, const char * str);
127 
128 /* constraint eval functions defined in pc_constraints.c */
129 
130 PC_EXPORT extern int pc_isperpendicular(double ** v);
131 PC_EXPORT extern void pc_mk_isperpendicular(struct pc_constrnt ** c, const char * name, const char **args);
132 PC_EXPORT extern int pc_ismodpositive(double ** v);
133 PC_EXPORT extern void pc_mk_ismodpositive(struct pc_constrnt ** c, const char * name, const char **args);
134 
135 #ifdef __cplusplus
136 }
137 #endif
138 
140 #endif
141 /** @} */
142 /*
143  * Local Variables:
144  * mode: C
145  * tab-width: 8
146  * indent-tabs-mode: t
147  * c-file-style: "stroustrup"
148  * End:
149  * ex: shiftwidth=4 tabstop=8
150  */
union pc_constrnt::@35 data
int dtype
Definition: pc.h:83
Definition: list.h:118
struct pc_constrnt * cs
Definition: pc.h:110
struct bu_list l
Definition: pc.h:78
Definition: clone.c:90
Definition: pc.h:108
struct pc_param * ps
Definition: pc.h:109
union pc_param::@34 data
void pc_getparameter(struct pc_param **p, int t)
void pc_pushconstraint_struct(struct pc_pc_set *pcs, const char *name, int nargs, int dimension, int(*fp)(double **args), const char **args)
Header file for the BRL-CAD common definitions.
struct bu_list l
Definition: pc.h:98
void pc_init_pcset(struct pc_pc_set *pcs)
void pc_free_pcset(struct pc_pc_set *pcs)
void pc_pushparam_expr(struct pc_pc_set *pcsp, const char *name, const char *str)
Definition: pc.h:97
#define __BEGIN_DECLS
Definition: common.h:73
struct bu_vls expression
Definition: pc.h:102
int dimension
Definition: pc.h:93
void pc_pushconstraint(struct pc_pc_set *pcs, const char *str)
void * ptr
Definition: pc.h:87
int pc_ismodpositive(double **v)
struct pc_constraint_fp cf
Definition: pc.h:103
int(* fp)(double **a)
Definition: pc.h:94
void pc_getconstraint_struct(struct pc_constrnt **c, int nargs)
int ctype
Definition: pc.h:82
int pc_isperpendicular(double **v)
void pc_free_constraint(struct pc_constrnt *c)
void pc_pushconstraint_struct1(struct pc_pc_set *pcs, struct pc_constrnt *c)
Definition: pc.h:77
struct bu_vls expression
Definition: pc.h:86
int ctype
Definition: pc.h:100
#define __END_DECLS
Definition: common.h:74
void pc_mk_isperpendicular(struct pc_constrnt **c, const char *name, const char **args)
int nargs
Definition: pc.h:92
void pc_pushparam_struct(struct pc_pc_set *pcs, const char *name, int type, void *ptr)
void pc_pushconstraint_expr(struct pc_pc_set *pcsp, const char *name, const char *str)
Definition: vls.h:56
void pc_getconstraint_expr(struct pc_constrnt **c)
const char ** args
Definition: pc.h:105
void pc_mk_ismodpositive(struct pc_constrnt **c, const char *name, const char **args)