BRL-CAD
face.h
Go to the documentation of this file.
1/* F A C E . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2004-2023 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_face */
23/** @{ */
24/** @file nmg/face.h */
25
26#ifndef NMG_FACE_H
27#define NMG_FACE_H
28
29#include "common.h"
30
31#include "vmath.h"
32#include "bu/list.h"
33#include "nmg/defines.h"
34#include "nmg/topology.h"
35
36__BEGIN_DECLS
37
38#define NMG_CK_FACE(_p) NMG_CKMAG(_p, NMG_FACE_MAGIC, "face")
39#define NMG_CK_FACE_G_PLANE(_p) NMG_CKMAG(_p, NMG_FACE_G_PLANE_MAGIC, "face_g_plane")
40#define NMG_CK_FACE_G_SNURB(_p) NMG_CKMAG(_p, NMG_FACE_G_SNURB_MAGIC, "face_g_snurb")
41#define NMG_CK_FACE_G_EITHER(_p) NMG_CK2MAG(_p, NMG_FACE_G_PLANE_MAGIC, NMG_FACE_G_SNURB_MAGIC, "face_g_plane|face_g_snurb")
42#define NMG_CK_FACEUSE(_p) NMG_CKMAG(_p, NMG_FACEUSE_MAGIC, "faceuse")
43
44/**
45 * Returns a 4-tuple (plane_t), given faceuse and state of flip flags.
46 */
47#define NMG_GET_FU_PLANE(_N, _fu) { \
48 register const struct faceuse *_fu1 = (_fu); \
49 register const struct face_g_plane *_fg; \
50 NMG_CK_FACEUSE(_fu1); \
51 NMG_CK_FACE(_fu1->f_p); \
52 _fg = _fu1->f_p->g.plane_p; \
53 NMG_CK_FACE_G_PLANE(_fg); \
54 if ((_fu1->orientation != OT_SAME) != (_fu1->f_p->flip != 0)) { \
55 HREVERSE(_N, _fg->N); \
56 } else { \
57 HMOVE(_N, _fg->N); \
58 } }
59
60/** Returns a 3-tuple (vect_t), given faceuse and state of flip flags */
61#define NMG_GET_FU_NORMAL(_N, _fu) { \
62 register const struct faceuse *_fu1 = (_fu); \
63 register const struct face_g_plane *_fg; \
64 NMG_CK_FACEUSE(_fu1); \
65 NMG_CK_FACE(_fu1->f_p); \
66 _fg = _fu1->f_p->g.plane_p; \
67 NMG_CK_FACE_G_PLANE(_fg); \
68 if ((_fu1->orientation != OT_SAME) != (_fu1->f_p->flip != 0)) { \
69 VREVERSE(_N, _fg->N); \
70 } else { \
71 VMOVE(_N, _fg->N); \
72 } }
73
74/**
75 * Returns a 4-tuple (plane_t), given faceuse and state of flip flags.
76 */
77#define NMG_GET_FU_PLANE(_N, _fu) { \
78 register const struct faceuse *_fu1 = (_fu); \
79 register const struct face_g_plane *_fg; \
80 NMG_CK_FACEUSE(_fu1); \
81 NMG_CK_FACE(_fu1->f_p); \
82 _fg = _fu1->f_p->g.plane_p; \
83 NMG_CK_FACE_G_PLANE(_fg); \
84 if ((_fu1->orientation != OT_SAME) != (_fu1->f_p->flip != 0)) { \
85 HREVERSE(_N, _fg->N); \
86 } else { \
87 HMOVE(_N, _fg->N); \
88 } }
89
90#define GET_FACE(p, m) {NMG_GETSTRUCT(p, face); NMG_INCR_INDEX(p, m);}
91#define GET_FACE_G_PLANE(p, m) {NMG_GETSTRUCT(p, face_g_plane); NMG_INCR_INDEX(p, m);}
92#define GET_FACE_G_SNURB(p, m) {NMG_GETSTRUCT(p, face_g_snurb); NMG_INCR_INDEX(p, m);}
93#define GET_FACEUSE(p, m) {NMG_GETSTRUCT(p, faceuse); NMG_INCR_INDEX(p, m);}
94
95#define FREE_FACE(p) NMG_FREESTRUCT(p, face)
96#define FREE_FACE_G_PLANE(p) NMG_FREESTRUCT(p, face_g_plane)
97#define FREE_FACE_G_SNURB(p) NMG_FREESTRUCT(p, face_g_snurb)
98#define FREE_FACEUSE(p) NMG_FREESTRUCT(p, faceuse)
99
100NMG_EXPORT extern void nmg_face_g(struct faceuse *fu,
101 const plane_t p);
102NMG_EXPORT extern void nmg_face_new_g(struct faceuse *fu,
103 const plane_t pl);
104NMG_EXPORT extern void nmg_face_bb(struct face *f,
105 const struct bn_tol *tol);
106
107NMG_EXPORT extern void nmg_jfg(struct face *f1,
108 struct face *f2);
109
110NMG_EXPORT extern struct faceuse *nmg_find_fu_of_eu(const struct edgeuse *eu);
111NMG_EXPORT extern struct faceuse *nmg_find_fu_of_lu(const struct loopuse *lu);
112NMG_EXPORT extern struct faceuse *nmg_find_fu_of_vu(const struct vertexuse *vu);
113NMG_EXPORT extern struct faceuse *nmg_find_fu_with_fg_in_s(const struct shell *s1,
114 const struct faceuse *fu2);
115NMG_EXPORT extern double nmg_measure_fu_angle(const struct edgeuse *eu,
116 const vect_t xvec,
117 const vect_t yvec,
118 const vect_t zvec);
119
120NMG_EXPORT extern struct faceuse *nmg_mf(struct loopuse *lu1);
121NMG_EXPORT extern int nmg_kfu(struct faceuse *fu1);
122
123NMG_EXPORT extern struct faceuse *nmg_cmface(struct shell *s,
124 struct vertex **vt[],
125 int n);
126NMG_EXPORT extern struct faceuse *nmg_cface(struct shell *s,
127 struct vertex **vt,
128 int n);
129NMG_EXPORT extern struct faceuse *nmg_add_loop_to_face(struct shell *s,
130 struct faceuse *fu,
131 struct vertex **verts,
132 int n,
133 int dir);
134NMG_EXPORT extern int nmg_fu_planeeqn(struct faceuse *fu,
135 const struct bn_tol *tol);
136NMG_EXPORT extern void nmg_gluefaces(struct faceuse *fulist[],
137 int n,
138 struct bu_list *vlfree,
139 const struct bn_tol *tol);
140NMG_EXPORT extern int nmg_simplify_face(struct faceuse *fu, struct bu_list *vlfree);
141NMG_EXPORT extern void nmg_reverse_face(struct faceuse *fu);
142NMG_EXPORT extern void nmg_mv_fu_between_shells(struct shell *dest,
143 struct shell *src,
144 struct faceuse *fu);
145NMG_EXPORT extern void nmg_jf(struct faceuse *dest_fu,
146 struct faceuse *src_fu);
147NMG_EXPORT extern struct faceuse *nmg_dup_face(struct faceuse *fu,
148 struct shell *s);
149
150
151NMG_EXPORT extern struct vertexuse *nmg_find_v_in_face(const struct vertex *,
152 const struct faceuse *);
153
154NMG_EXPORT extern struct vertexuse *nmg_find_pnt_in_face(const struct faceuse *fu,
155 const point_t pt,
156 const struct bn_tol *tol);
157NMG_EXPORT extern struct vertexuse *nmg_is_vertex_in_face(const struct vertex *v,
158 const struct face *f);
159NMG_EXPORT extern int nmg_is_vertex_in_facelist(const struct vertex *v,
160 const struct bu_list *hd);
161
162NMG_EXPORT extern int nmg_is_edge_in_facelist(const struct edge *e,
163 const struct bu_list *hd);
164NMG_EXPORT extern int nmg_is_loop_in_facelist(const struct loop *l,
165 const struct bu_list *fu_hd);
166NMG_EXPORT extern void nmg_face_tabulate(struct bu_ptbl *tab,
167 const uint32_t *magic_p,
168 struct bu_list *vlfree);
169
170NMG_EXPORT extern void nmg_translate_face(struct faceuse *fu, const vect_t Vec, struct bu_list *vlfree);
171NMG_EXPORT extern int nmg_extrude_face(struct faceuse *fu, const vect_t Vec, struct bu_list *vlfree, const struct bn_tol *tol);
172
173NMG_EXPORT extern void nmg_tabulate_face_g_verts(struct bu_ptbl *tab,
174 const struct face_g_plane *fg);
175NMG_EXPORT extern int nmg_move_lu_between_fus(struct faceuse *dest,
176 struct faceuse *src,
177 struct loopuse *lu);
178NMG_EXPORT extern int nmg_calc_face_plane(struct faceuse *fu_in,
179 plane_t pl, struct bu_list *vlfree);
180NMG_EXPORT extern int nmg_calc_face_g(struct faceuse *fu, struct bu_list *vlfree);
181NMG_EXPORT extern fastf_t nmg_faceuse_area(const struct faceuse *fu);
182NMG_EXPORT extern void nmg_purge_unwanted_intersection_points(struct bu_ptbl *vert_list,
183 fastf_t *mag,
184 const struct faceuse *fu,
185 const struct bn_tol *tol);
186NMG_EXPORT extern void nmg_reverse_radials(struct faceuse *fu,
187 const struct bn_tol *tol);
188NMG_EXPORT extern void nmg_reverse_face_and_radials(struct faceuse *fu,
189 const struct bn_tol *tol);
190NMG_EXPORT extern void nmg_propagate_normals(struct faceuse *fu_in,
191 long *flags,
192 const struct bn_tol *tol);
193NMG_EXPORT extern struct faceuse *nmg_mk_new_face_from_loop(struct loopuse *lu);
194NMG_EXPORT extern int nmg_split_loops_into_faces(uint32_t *magic_p, struct bu_list *vlfree,
195 const struct bn_tol *tol);
196NMG_EXPORT extern int nmg_find_isect_faces(const struct vertex *new_v,
197 struct bu_ptbl *faces,
198 int *free_edges,
199 const struct bn_tol *tol);
200NMG_EXPORT extern void nmg_make_faces_at_vert(struct vertex *new_v,
201 struct bu_ptbl *int_faces,
202 struct bu_list *vlfree,
203 const struct bn_tol *tol);
204NMG_EXPORT extern void nmg_kill_cracks_at_vertex(const struct vertex *vp);
205NMG_EXPORT extern int nmg_complex_vertex_solve(struct vertex *new_v,
206 const struct bu_ptbl *faces,
207 const int free_edges,
208 const int approximate,
209 struct bu_list *vlfree,
210 const struct bn_tol *tol);
211NMG_EXPORT extern int nmg_faces_are_radial(const struct faceuse *fu1,
212 const struct faceuse *fu2);
213NMG_EXPORT extern int nmg_triangulate_fu(struct faceuse *fu,
214 struct bu_list *vlfree,
215 const struct bn_tol *tol);
216NMG_EXPORT extern int nmg_class_pnt_f(const point_t pt,
217 const struct faceuse *fu,
218 const struct bn_tol *tol);
219NMG_EXPORT extern int nmg_class_pnt_fu_except(const point_t pt,
220 const struct faceuse *fu,
221 const struct loopuse *ignore_lu,
222 void (*eu_func)(struct edgeuse *, point_t, const char *, struct bu_list *),
223 void (*vu_func)(struct vertexuse *, point_t, const char *),
224 const char *priv,
225 const int call_on_hits,
226 const int in_or_out_only,
227 struct bu_list *vlfree,
228 const struct bn_tol *tol);
229NMG_EXPORT extern int nmg_mesh_two_faces(struct faceuse *fu1,
230 struct faceuse *fu2,
231 const struct bn_tol *tol);
232NMG_EXPORT extern void nmg_mesh_faces(struct faceuse *fu1,
233 struct faceuse *fu2,
234 struct bu_list *vlfree,
235 const struct bn_tol *tol);
236NMG_EXPORT extern double nmg_measure_fu_angle(const struct edgeuse *eu,
237 const vect_t xvec,
238 const vect_t yvec,
239 const vect_t zvec);
240
241NMG_EXPORT extern int nmg_ck_vu_ptbl(struct bu_ptbl *p,
242 struct faceuse *fu);
243
244NMG_EXPORT extern void nmg_sanitize_fu(struct faceuse *fu);
245
246NMG_EXPORT extern struct edge_g_lseg *nmg_face_cutjoin(struct bu_ptbl *b1,
247 struct bu_ptbl *b2,
248 fastf_t *mag1,
249 fastf_t *mag2,
250 struct faceuse *fu1,
251 struct faceuse *fu2,
252 point_t pt,
253 vect_t dir,
254 struct edge_g_lseg *eg,
255 struct bu_list *vlfree,
256 const struct bn_tol *tol);
257
258NMG_EXPORT extern void nmg_fcut_face_2d(struct bu_ptbl *vu_list,
259 fastf_t *mag,
260 struct faceuse *fu1,
261 struct faceuse *fu2,
262 struct bu_list *vlfree,
263 struct bn_tol *tol);
264
265NMG_EXPORT extern int nmg_ck_vert_on_fus(const struct vertex *v,
266 const struct bn_tol *tol);
267
268NMG_EXPORT extern int nmg_dangling_face(const struct faceuse *fu,
269 const char *manifolds);
270
271NMG_EXPORT extern int nmg_is_common_bigloop(const struct face *f1,
272 const struct face *f2);
273
274NMG_EXPORT extern int nmg_ck_fu_verts(struct faceuse *fu1,
275 struct face *f2,
276 const struct bn_tol *tol);
277NMG_EXPORT extern int nmg_ck_fg_verts(struct faceuse *fu1,
278 struct face *f2,
279 const struct bn_tol *tol);
280NMG_EXPORT extern int nmg_two_face_fuse(struct face *f1,
281 struct face *f2,
282 const struct bn_tol *tol);
283
284
285__END_DECLS
286
287#endif /* NMG_FACE_H */
288/** @} */
289/*
290 * Local Variables:
291 * mode: C
292 * tab-width: 8
293 * indent-tabs-mode: t
294 * c-file-style: "stroustrup"
295 * End:
296 * ex: shiftwidth=4 tabstop=8
297 */
Header file for the BRL-CAD common definitions.
void float float int * n
Definition: tig.h:74
int nmg_split_loops_into_faces(uint32_t *magic_p, struct bu_list *vlfree, const struct bn_tol *tol)
void nmg_jfg(struct face *f1, struct face *f2)
int nmg_move_lu_between_fus(struct faceuse *dest, struct faceuse *src, struct loopuse *lu)
int nmg_is_edge_in_facelist(const struct edge *e, const struct bu_list *hd)
int nmg_ck_fg_verts(struct faceuse *fu1, struct face *f2, const struct bn_tol *tol)
struct faceuse * nmg_find_fu_of_vu(const struct vertexuse *vu)
void nmg_purge_unwanted_intersection_points(struct bu_ptbl *vert_list, fastf_t *mag, const struct faceuse *fu, const struct bn_tol *tol)
void nmg_face_new_g(struct faceuse *fu, const plane_t pl)
int nmg_fu_planeeqn(struct faceuse *fu, const struct bn_tol *tol)
int nmg_class_pnt_f(const point_t pt, const struct faceuse *fu, const struct bn_tol *tol)
int nmg_class_pnt_fu_except(const point_t pt, const struct faceuse *fu, const struct loopuse *ignore_lu, void(*eu_func)(struct edgeuse *, point_t, const char *, struct bu_list *), void(*vu_func)(struct vertexuse *, point_t, const char *), const char *priv, const int call_on_hits, const int in_or_out_only, struct bu_list *vlfree, const struct bn_tol *tol)
int nmg_dangling_face(const struct faceuse *fu, const char *manifolds)
void nmg_reverse_face(struct faceuse *fu)
int nmg_is_vertex_in_facelist(const struct vertex *v, const struct bu_list *hd)
void nmg_make_faces_at_vert(struct vertex *new_v, struct bu_ptbl *int_faces, struct bu_list *vlfree, const struct bn_tol *tol)
struct faceuse * nmg_find_fu_with_fg_in_s(const struct shell *s1, const struct faceuse *fu2)
int nmg_complex_vertex_solve(struct vertex *new_v, const struct bu_ptbl *faces, const int free_edges, const int approximate, struct bu_list *vlfree, const struct bn_tol *tol)
struct vertexuse * nmg_find_pnt_in_face(const struct faceuse *fu, const point_t pt, const struct bn_tol *tol)
struct faceuse * nmg_dup_face(struct faceuse *fu, struct shell *s)
int nmg_kfu(struct faceuse *fu1)
void nmg_reverse_radials(struct faceuse *fu, const struct bn_tol *tol)
int nmg_simplify_face(struct faceuse *fu, struct bu_list *vlfree)
int nmg_calc_face_plane(struct faceuse *fu_in, plane_t pl, struct bu_list *vlfree)
void nmg_fcut_face_2d(struct bu_ptbl *vu_list, fastf_t *mag, struct faceuse *fu1, struct faceuse *fu2, struct bu_list *vlfree, struct bn_tol *tol)
fastf_t nmg_faceuse_area(const struct faceuse *fu)
int nmg_triangulate_fu(struct faceuse *fu, struct bu_list *vlfree, const struct bn_tol *tol)
struct faceuse * nmg_cmface(struct shell *s, struct vertex **vt[], int n)
int nmg_ck_vu_ptbl(struct bu_ptbl *p, struct faceuse *fu)
int nmg_extrude_face(struct faceuse *fu, const vect_t Vec, struct bu_list *vlfree, const struct bn_tol *tol)
void nmg_gluefaces(struct faceuse *fulist[], int n, struct bu_list *vlfree, const struct bn_tol *tol)
void nmg_jf(struct faceuse *dest_fu, struct faceuse *src_fu)
void nmg_mv_fu_between_shells(struct shell *dest, struct shell *src, struct faceuse *fu)
void nmg_sanitize_fu(struct faceuse *fu)
int nmg_two_face_fuse(struct face *f1, struct face *f2, const struct bn_tol *tol)
void nmg_kill_cracks_at_vertex(const struct vertex *vp)
struct faceuse * nmg_find_fu_of_lu(const struct loopuse *lu)
int nmg_is_common_bigloop(const struct face *f1, const struct face *f2)
struct faceuse * nmg_mf(struct loopuse *lu1)
int nmg_ck_vert_on_fus(const struct vertex *v, const struct bn_tol *tol)
void nmg_face_bb(struct face *f, const struct bn_tol *tol)
struct vertexuse * nmg_is_vertex_in_face(const struct vertex *v, const struct face *f)
struct faceuse * nmg_find_fu_of_eu(const struct edgeuse *eu)
void nmg_propagate_normals(struct faceuse *fu_in, long *flags, const struct bn_tol *tol)
void nmg_translate_face(struct faceuse *fu, const vect_t Vec, struct bu_list *vlfree)
struct edge_g_lseg * nmg_face_cutjoin(struct bu_ptbl *b1, struct bu_ptbl *b2, fastf_t *mag1, fastf_t *mag2, struct faceuse *fu1, struct faceuse *fu2, point_t pt, vect_t dir, struct edge_g_lseg *eg, struct bu_list *vlfree, const struct bn_tol *tol)
int nmg_find_isect_faces(const struct vertex *new_v, struct bu_ptbl *faces, int *free_edges, const struct bn_tol *tol)
struct faceuse * nmg_cface(struct shell *s, struct vertex **vt, int n)
int nmg_ck_fu_verts(struct faceuse *fu1, struct face *f2, const struct bn_tol *tol)
void nmg_tabulate_face_g_verts(struct bu_ptbl *tab, const struct face_g_plane *fg)
void nmg_reverse_face_and_radials(struct faceuse *fu, const struct bn_tol *tol)
void nmg_mesh_faces(struct faceuse *fu1, struct faceuse *fu2, struct bu_list *vlfree, const struct bn_tol *tol)
struct vertexuse * nmg_find_v_in_face(const struct vertex *, const struct faceuse *)
int nmg_mesh_two_faces(struct faceuse *fu1, struct faceuse *fu2, const struct bn_tol *tol)
struct faceuse * nmg_add_loop_to_face(struct shell *s, struct faceuse *fu, struct vertex **verts, int n, int dir)
void nmg_face_g(struct faceuse *fu, const plane_t p)
struct faceuse * nmg_mk_new_face_from_loop(struct loopuse *lu)
int nmg_faces_are_radial(const struct faceuse *fu1, const struct faceuse *fu2)
void nmg_face_tabulate(struct bu_ptbl *tab, const uint32_t *magic_p, struct bu_list *vlfree)
int nmg_is_loop_in_facelist(const struct loop *l, const struct bu_list *fu_hd)
int nmg_calc_face_g(struct faceuse *fu, struct bu_list *vlfree)
double nmg_measure_fu_angle(const struct edgeuse *eu, const vect_t xvec, const vect_t yvec, const vect_t zvec)
fastf_t vect_t[ELEMENTS_PER_VECT]
3-tuple vector
Definition: vmath.h:345
double fastf_t
fastest 64-bit (or larger) floating point type
Definition: vmath.h:330
fastf_t plane_t[ELEMENTS_PER_PLANE]
Definition of a plane equation.
Definition: vmath.h:393
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition: vmath.h:351
Definition: tol.h:72
Definition: list.h:131
Definition: ptbl.h:53
Line in 3D space.
Definition: topology.h:326
NMG topological edge.
Definition: topology.h:144
NMG topological edge usage.
Definition: topology.h:155
Planar face geometry.
Definition: topology.h:341
NMG topological face.
Definition: topology.h:210
NMG topological face usage.
Definition: topology.h:230
NMG topological loop.
Definition: topology.h:181
NMG topological loop usage.
Definition: topology.h:192
NMG topological shell.
Definition: topology.h:261
NMG topological vertex - the simplest element of the topology system.
Definition: topology.h:98
NMG topological vertex usage.
Definition: topology.h:109
uint32_t * magic_p
for those times when we're not sure
Definition: topology.h:115
struct bu_list l
list of all vu's on a vertex
Definition: topology.h:110
fundamental vector, matrix, quaternion math macros