BRL-CAD
index.h
Go to the documentation of this file.
1 /* I N D E X . H
2  * BRL-CAD
3  *
4  * Copyright (c) 2004-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 
21 /*----------------------------------------------------------------------*/
22 /** @addtogroup nmg_index
23  */
24 /** @{ */
25 /** @file nmg/index.h */
26 
27 #ifndef NMG_INDEX_H
28 #define NMG_INDEX_H
29 
30 #include "common.h"
31 
32 #include "vmath.h"
33 #include "bu/list.h"
34 #include "nmg/defines.h"
35 
36 __BEGIN_DECLS
37 
39  /* Actual structure counts (Xuse, then X) */
40  long model;
41  long region;
42  long region_a;
43  long shell;
44  long shell_a;
45  long faceuse;
46  long face;
49  long loopuse;
50  long loop;
51  long loop_a;
52  long edgeuse;
53  long edge;
56  long vertexuse;
59  long vertex;
60  long vertex_g;
61  /* Abstractions */
63  long face_loops;
64  long face_edges;
66  long wire_loops;
68  long wire_edges;
71 };
72 
73 /*
74  * For use with tables subscripted by NMG structure "index" values,
75  * traditional test and set macros.
76  *
77  * A value of zero indicates unset, a value of one indicates set.
78  * test-and-set returns TRUE if value was unset; in the process, value
79  * has become set. This is often used to detect the first time an
80  * item is used, so an alternative name is given, for clarity.
81  *
82  * Note that the somewhat simpler auto-increment form:
83  * ((tab)[(p)->index]++ == 0)
84  * is not used, to avoid the possibility of integer overflow from
85  * repeated test-and-set operations on one item.
86  */
87 #define NMG_INDEX_VALUE(_tab, _index) ((_tab)[_index])
88 #define NMG_INDEX_TEST(_tab, _p) ((_tab)[(_p)->index])
89 #define NMG_INDEX_SET(_tab, _p) {(_tab)[(_p)->index] = 1;}
90 #define NMG_INDEX_CLEAR(_tab, _p) {(_tab)[(_p)->index] = 0;}
91 #define NMG_INDEX_TEST_AND_SET(_tab, _p) ((_tab)[(_p)->index] == 0 ? ((_tab)[(_p)->index] = 1) : 0)
92 #define NMG_INDEX_IS_SET(_tab, _p) NMG_INDEX_TEST(_tab, _p)
93 #define NMG_INDEX_FIRST_TIME(_tab, _p) NMG_INDEX_TEST_AND_SET(_tab, _p)
94 #define NMG_INDEX_ASSIGN(_tab, _p, _val) {(_tab)[(_p)->index] = _val;}
95 #define NMG_INDEX_GET(_tab, _p) ((_tab)[(_p)->index])
96 #define NMG_INDEX_GETP(_ty, _tab, _p) ((struct _ty *)((_tab)[(_p)->index]))
97 #define NMG_INDEX_OR(_tab, _p, _val) {(_tab)[(_p)->index] |= _val;}
98 #define NMG_INDEX_AND(_tab, _p, _val) {(_tab)[(_p)->index] &= _val;}
99 #define NMG_INDEX_RETURN_IF_SET_ELSE_SET(_tab, _index) { \
100  if ((_tab)[_index]) return; \
101  else (_tab)[_index] = 1; \
102  }
103 
104 /* flags for manifold-ness */
105 #define NMG_0MANIFOLD 1
106 #define NMG_1MANIFOLD 2
107 #define NMG_2MANIFOLD 4
108 #define NMG_DANGLING 8 /* NMG_2MANIFOLD + 4th bit for special cond (UNUSED) */
109 #define NMG_3MANIFOLD 16
110 
111 #define NMG_SET_MANIFOLD(_t, _p, _v) NMG_INDEX_OR(_t, _p, _v)
112 #define NMG_MANIFOLDS(_t, _p) NMG_INDEX_VALUE(_t, (_p)->index)
113 #define NMG_CP_MANIFOLD(_t, _p, _q) (_t)[(_p)->index] = (_t)[(_q)->index]
114 
115 NMG_EXPORT extern int nmg_index_of_struct(const uint32_t *p);
116 
117 NMG_EXPORT extern uint32_t **nmg_m_struct_count(struct nmg_struct_counts *ctr,
118  const struct model *m);
119 NMG_EXPORT extern void nmg_pr_m_struct_counts(const struct model *m,
120  const char *str);
121 
122 NMG_EXPORT extern void nmg_vls_struct_counts(struct bu_vls *str,
123  const struct nmg_struct_counts *ctr);
124 NMG_EXPORT extern void nmg_pr_struct_counts(const struct nmg_struct_counts *ctr,
125  const char *str);
126 __END_DECLS
127 
128 #endif /* NMG_INDEX_H */
129 /** @} */
130 /*
131  * Local Variables:
132  * mode: C
133  * tab-width: 8
134  * indent-tabs-mode: t
135  * c-file-style: "stroustrup"
136  * End:
137  * ex: shiftwidth=4 tabstop=8
138  */
Header file for the BRL-CAD common definitions.
int nmg_index_of_struct(const uint32_t *p)
void nmg_vls_struct_counts(struct bu_vls *str, const struct nmg_struct_counts *ctr)
void nmg_pr_struct_counts(const struct nmg_struct_counts *ctr, const char *str)
void nmg_pr_m_struct_counts(const struct model *m, const char *str)
uint32_t ** nmg_m_struct_count(struct nmg_struct_counts *ctr, const struct model *m)
Definition: vls.h:53
NMG topological model.
Definition: topology.h:289
long wire_lone_verts
Definition: index.h:69
long edge_g_cnurb
Definition: index.h:55
long shell_a
Definition: index.h:44
long face_loops
Definition: index.h:63
long edgeuse
Definition: index.h:52
long wire_edges
Definition: index.h:68
long loopuse
Definition: index.h:49
long face_lone_verts
Definition: index.h:65
long region_a
Definition: index.h:42
long vertexuse_a_plane
Definition: index.h:57
long faceuse
Definition: index.h:45
long vertex_g
Definition: index.h:60
long shells_of_lone_vert
Definition: index.h:70
long max_structs
Definition: index.h:62
long face_edges
Definition: index.h:64
long vertexuse
Definition: index.h:56
long edge_g_lseg
Definition: index.h:54
long wire_loops
Definition: index.h:66
long wire_loop_edges
Definition: index.h:67
long face_g_plane
Definition: index.h:47
long vertexuse_a_cnurb
Definition: index.h:58
long face_g_snurb
Definition: index.h:48
fundamental vector, matrix, quaternion math macros