BRL-CAD
nmg_conv.h
Go to the documentation of this file.
1/* N M G _ C O N V . H
2 * BRL-CAD
3 *
4 * Copyright (c) 1993-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/** @file rt/nmg_conv.h */
21
22#ifndef RT_NMG_CONV_H
23#define RT_NMG_CONV_H
24
25#include "common.h"
26#include "vmath.h"
27#include "bu/list.h"
28#include "bu/ptbl.h"
29#include "bn/tol.h"
30#include "bv/vlist.h"
31#include "bg/defines.h"
32#include "rt/geom.h"
33#include "rt/hit.h"
34#include "rt/seg.h"
35#include "rt/application.h"
36#include "rt/soltab.h"
37#include "nmg.h"
38
39__BEGIN_DECLS
40
41struct rt_db_internal; /*forward declaration*/
42
43struct hitmiss {
44 struct bu_list l;
45 struct hit hit;
46 fastf_t dist_in_plane; /**< @brief distance from plane intersect */
47 int in_out; /**< @brief status of ray as it transitions
48 * this hit point.
49 */
54 int start_stop; /**< @brief is this a seg_in or seg_out */
55 struct hitmiss *other; /**< @brief for keeping track of the other
56 * end of the segment when we know
57 * it
58 */
59};
60
61
62
63/**
64 * Ray Data structure
65 *
66 * A) the hitmiss table has one element for each nmg structure in the
67 * nmgmodel. The table keeps track of which elements have been
68 * processed before and which haven't. Elements in this table will
69 * either be: (NULL) item not previously processed hitmiss ptr item
70 * previously processed
71 *
72 * the 0th item in the array is a pointer to the head of the "hit"
73 * list. The 1th item in the array is a pointer to the head of the
74 * "miss" list.
75 *
76 * B) If plane_pt is non-null then we are currently processing a face
77 * intersection. The plane_dist and ray_dist_to_plane are valid. The
78 * ray/edge intersector should check the distance from the plane
79 * intercept to the edge and update "plane_closest" if the current
80 * edge is closer to the intercept than the previous closest object.
81 */
82struct ray_data {
83 uint32_t magic;
84 struct model *rd_m;
85 char *manifolds; /**< @brief structure 1-3manifold table */
87 struct xray *rp;
88 struct application *ap;
89 struct seg *seghead;
90 struct soltab *stp;
91 const struct bn_tol *tol;
92 struct hitmiss **hitmiss; /**< @brief 1 struct hitmiss ptr per elem. */
93 struct bu_list rd_hit; /**< @brief list of hit elements */
94 struct bu_list rd_miss; /**< @brief list of missed/sub-hit elements */
95
96/* The following are to support isect_ray_face() */
97
98 /**
99 * plane_pt is the intercept point of the ray with the plane of
100 * the face.
101 */
102 point_t plane_pt; /**< @brief ray/plane(face) intercept point */
103
104 /**
105 * ray_dist_to_plane is the parametric distance along the ray from
106 * the ray origin (rd->rp->r_pt) to the ray/plane intercept point
107 */
108 fastf_t ray_dist_to_plane; /**< @brief ray parametric dist to plane */
109
110 /**
111 * the "face_subhit" element is a boolean used by isect_ray_face
112 * and [e|v]u_touch_func to record the fact that the
113 * ray/(plane/face) intercept point was within tolerance of an
114 * edge/vertex of the face. In such instances, isect_ray_face
115 * does NOT need to generate a hit point for the face, as the hit
116 * point for the edge/vertex will suffice.
117 */
119
120 /**
121 * the "classifying_ray" flag indicates that this ray is being
122 * used to classify a point, so that the "eu_touch" and "vu_touch"
123 * functions should not be called.
124 */
126};
127
128#define NMG_PCA_EDGE 1
129#define NMG_PCA_EDGE_VERTEX 2
130#define NMG_PCA_VERTEX 3
131
132/**
133 * global nmg animation plot callback
134 */
135RT_EXPORT extern void (*nmg_plot_anim_upcall)(void);
136
137
138/* From nmg_rt_isect.c */
139RT_EXPORT extern void rt_nmg_print_hitlist(struct bu_list *hd);
140RT_EXPORT extern void rt_nmg_print_hitmiss(struct hitmiss *a_hit);
141RT_EXPORT extern void rt_isect_ray_model(struct ray_data *rd, struct bu_list *vlfree);
142
143/************************************************************************
144 * *
145 * NMG Support Function Declarations *
146 * *
147 ************************************************************************/
148#if defined(NMG_H)
149
150/* nmg.c */
151RT_EXPORT extern int nmg_ray_segs(struct ray_data *rd, struct bu_list *vlfree);
152
153RT_EXPORT extern int nmg_to_arb(const struct model *m,
154 struct rt_arb_internal *arb_int);
155RT_EXPORT extern int nmg_to_tgc(const struct model *m,
156 struct rt_tgc_internal *tgc_int,
157 const struct bn_tol *tol);
158RT_EXPORT extern int nmg_to_poly(const struct model *m,
159 struct rt_pg_internal *poly_int,
160 struct bu_list *vlfree,
161 const struct bn_tol *tol);
162RT_EXPORT extern struct rt_bot_internal *nmg_bot(struct shell *s,
163 struct bu_list *vlfree,
164 const struct bn_tol *tol);
165RT_EXPORT extern struct rt_bot_internal *nmg_mdl_to_bot(struct model *m,
166 struct bu_list *vlfree,
167 const struct bn_tol *tol);
168struct db_tree_state; /* forward declaration */
169RT_EXPORT extern union tree *nmg_booltree_leaf_tess(struct db_tree_state *tsp,
170 const struct db_full_path *pathp,
171 struct rt_db_internal *ip,
172 void *client_data);
173RT_EXPORT extern union tree *nmg_booltree_leaf_tnurb(struct db_tree_state *tsp,
174 const struct db_full_path *pathp,
175 struct rt_db_internal *ip,
176 void *client_data);
177RT_EXPORT extern int nmg_bool_eval_silent; /* quell output from nmg_booltree_evaluate */
178RT_EXPORT extern union tree *nmg_booltree_evaluate(union tree *tp,
179 struct bu_list *vlfree,
180 const struct bn_tol *tol,
181 struct resource *resp);
182RT_EXPORT extern int nmg_boolean(union tree *tp,
183 struct model *m,
184 struct bu_list *vlfree,
185 const struct bn_tol *tol,
186 struct resource *resp);
187
188
189
190
191/* nmg_tri_mc.c */
192RT_EXPORT extern void nmg_triangulate_model_mc(struct model *m,
193 const struct bn_tol *tol);
194RT_EXPORT extern int nmg_mc_realize_cube(struct shell *s,
195 int pv,
196 point_t *edges,
197 const struct bn_tol *tol);
198RT_EXPORT extern int nmg_mc_evaluate(struct shell *s,
199 struct rt_i *rtip,
200 const struct db_full_path *pathp,
201 const struct bg_tess_tol *ttol,
202 const struct bn_tol *tol);
203
204
205/* nmg.c */
206RT_EXPORT extern void nmg_stash_model_to_file(const char *filename,
207 const struct model *m,
208 const char *title);
209
210
211#endif
212
213__END_DECLS
214
215#endif /* RT_NMG__CONV_H */
216
217/*
218 * Local Variables:
219 * tab-width: 8
220 * mode: C
221 * indent-tabs-mode: t
222 * c-file-style: "stroustrup"
223 * End:
224 * ex: shiftwidth=4 tabstop=8
225 */
Header file for the BRL-CAD common definitions.
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 point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition: vmath.h:351
Main header file for the BRL-CAD Non-Manifold Geometry Library, LIBNMG.
void rt_nmg_print_hitlist(struct bu_list *hd)
void(* nmg_plot_anim_upcall)(void)
void rt_isect_ray_model(struct ray_data *rd, struct bu_list *vlfree)
void rt_nmg_print_hitmiss(struct hitmiss *a_hit)
Definition: tol.h:72
Definition: list.h:131
Information about where a ray hits the surface.
Definition: hit.h:61
long * inbound_use
Definition: nmg_conv.h:50
struct hitmiss * other
for keeping track of the other end of the segment when we know it
Definition: nmg_conv.h:55
vect_t inbound_norm
Definition: nmg_conv.h:51
fastf_t dist_in_plane
distance from plane intersect
Definition: nmg_conv.h:46
long * outbound_use
Definition: nmg_conv.h:52
vect_t outbound_norm
Definition: nmg_conv.h:53
int start_stop
is this a seg_in or seg_out
Definition: nmg_conv.h:54
struct bu_list l
Definition: nmg_conv.h:44
int in_out
status of ray as it transitions this hit point.
Definition: nmg_conv.h:47
NMG topological model.
Definition: topology.h:289
int face_subhit
Definition: nmg_conv.h:118
struct model * rd_m
Definition: nmg_conv.h:84
struct bu_list rd_hit
list of hit elements
Definition: nmg_conv.h:93
uint32_t magic
Definition: nmg_conv.h:83
struct seg * seghead
Definition: nmg_conv.h:89
char * manifolds
structure 1-3manifold table
Definition: nmg_conv.h:85
const struct bn_tol * tol
Definition: nmg_conv.h:91
struct bu_list rd_miss
list of missed/sub-hit elements
Definition: nmg_conv.h:94
struct soltab * stp
Definition: nmg_conv.h:90
struct application * ap
Definition: nmg_conv.h:88
struct xray * rp
Definition: nmg_conv.h:87
fastf_t ray_dist_to_plane
ray parametric dist to plane
Definition: nmg_conv.h:108
vect_t rd_invdir
Definition: nmg_conv.h:86
int classifying_ray
Definition: nmg_conv.h:125
point_t plane_pt
ray/plane(face) intercept point
Definition: nmg_conv.h:102
struct hitmiss ** hitmiss
1 struct hitmiss ptr per elem.
Definition: nmg_conv.h:92
Definition: seg.h:59
NMG topological shell.
Definition: topology.h:261
Definition: soltab.h:56
Primary ray data structure.
Definition: xray.h:41
Definition: tree.h:147
fundamental vector, matrix, quaternion math macros