BRL-CAD
pc.h
Go to the documentation of this file.
1 /* P C . H
2  * BRL-CAD
3  *
4  * Copyright (c) 2008-2024 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 
36 __BEGIN_DECLS
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 COMPILER_DLLEXPORT
43 # elif defined(PC_DLL_IMPORTS)
44 # define PC_EXPORT COMPILER_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 
70 /**
71  * A composite set of parameters constraints with respect to those
72  * parameters. Used for declaration by each geometry object
73  */
74 struct pc_param {
75  struct bu_list l;
76  struct bu_vls name; /** Name of the parameter */
77 
78  /** @todo convert to enum after pc becomes a dependency of rt */
79  int ctype; /** Container type used for storing data */
80  int dtype; /** Data type of the data pointed to */
81 
82  union { /** The Actual data / pointer */
83  struct bu_vls expression;
84  void * ptr;
85  } data;
86 };
87 
88 struct pc_constraint_fp {
89  int nargs;
90  int dimension;
91  int (*fp) (double ** a);
92 };
93 
94 struct pc_constrnt {
95  struct bu_list l;
96  struct bu_vls name;
97  int ctype;
98  union {
99  struct bu_vls expression;
100  struct pc_constraint_fp cf;
101  } data;
102  const char **args;
103 };
104 
105 struct pc_pc_set {
106  struct pc_param * ps;
107  struct pc_constrnt * cs;
108 };
109 
110 /* functions defined in pc_main.c */
111 
112 PC_EXPORT extern void pc_init_pcset(struct pc_pc_set * pcs);
113 PC_EXPORT extern void pc_free_pcset(struct pc_pc_set * pcs);
114 PC_EXPORT extern void pc_free_constraint(struct pc_constrnt * c);
115 PC_EXPORT extern void pc_getparameter(struct pc_param **p, int t);
116 PC_EXPORT extern void pc_pushparam_expr(struct pc_pc_set * pcsp, const char *name, const char *str);
117 PC_EXPORT extern void pc_pushparam_struct(struct pc_pc_set * pcs, const char * name, int type, void * ptr);
118 PC_EXPORT extern void pc_getconstraint_expr(struct pc_constrnt ** c);
119 PC_EXPORT extern void pc_getconstraint_struct(struct pc_constrnt **c, int nargs);
120 PC_EXPORT extern void pc_pushconstraint_expr(struct pc_pc_set * pcsp, const char * name, const char * str);
121 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);
122 PC_EXPORT extern void pc_pushconstraint_struct1(struct pc_pc_set * pcs, struct pc_constrnt * c);
123 PC_EXPORT extern void pc_pushconstraint(struct pc_pc_set * pcs, const char * str);
124 
125 /* constraint eval functions defined in pc_constraints.c */
126 
127 PC_EXPORT extern int pc_isperpendicular(double ** v);
128 PC_EXPORT extern void pc_mk_isperpendicular(struct pc_constrnt ** c, const char * name, const char **args);
129 PC_EXPORT extern int pc_ismodpositive(double ** v);
130 PC_EXPORT extern void pc_mk_ismodpositive(struct pc_constrnt ** c, const char * name, const char **args);
131 
132 __END_DECLS
133 
134 #endif
135 /** @} */
136 /*
137  * Local Variables:
138  * mode: C
139  * tab-width: 8
140  * indent-tabs-mode: t
141  * c-file-style: "stroustrup"
142  * End:
143  * ex: shiftwidth=4 tabstop=8
144  */
Header file for the BRL-CAD Numerical Computation Library, LIBBN.
Header file for the BRL-CAD common definitions.
void int * c
Definition: tig.h:139
void pc_mk_isperpendicular(struct pc_constrnt **c, const char *name, const char **args)
void pc_free_pcset(struct pc_pc_set *pcs)
void pc_getconstraint_expr(struct pc_constrnt **c)
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)
void pc_pushparam_expr(struct pc_pc_set *pcsp, const char *name, const char *str)
void pc_pushconstraint_expr(struct pc_pc_set *pcsp, const char *name, const char *str)
void pc_init_pcset(struct pc_pc_set *pcs)
int pc_isperpendicular(double **v)
int pc_ismodpositive(double **v)
void pc_getconstraint_struct(struct pc_constrnt **c, int nargs)
void pc_mk_ismodpositive(struct pc_constrnt **c, const char *name, const char **args)
void pc_pushconstraint(struct pc_pc_set *pcs, const char *str)
void pc_pushconstraint_struct1(struct pc_pc_set *pcs, struct pc_constrnt *c)
void pc_pushparam_struct(struct pc_pc_set *pcs, const char *name, int type, void *ptr)
void pc_free_constraint(struct pc_constrnt *c)
Definition: list.h:132
Definition: vls.h:53
int nargs
Definition: pc.h:90
int dimension
Definition: pc.h:91
int(* fp)(double **a)
Definition: pc.h:92
Definition: pc.h:95
int ctype
Definition: pc.h:98
struct bu_vls name
Definition: pc.h:97
const char ** args
Definition: pc.h:103
struct bu_vls expression
Definition: pc.h:100
struct bu_list l
Definition: pc.h:96
struct pc_constraint_fp cf
Definition: pc.h:101
union pc_constrnt::@8 data
Definition: pc.h:74
int ctype
Definition: pc.h:80
struct bu_vls name
Definition: pc.h:76
union pc_param::@7 data
struct bu_vls expression
Definition: pc.h:84
struct bu_list l
Definition: pc.h:75
int dtype
Definition: pc.h:81
void * ptr
Definition: pc.h:85
Definition: pc.h:106
struct pc_constrnt * cs
Definition: pc.h:108
struct pc_param * ps
Definition: pc.h:107