BRL-CAD
Loading...
Searching...
No Matches
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-2026 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
40
41struct rt_db_internal; /*forward declaration*/
43struct bu_ptbl;
44
45struct hitmiss {
46 struct bu_list l;
47 struct hit hit;
48 fastf_t dist_in_plane; /**< @brief distance from plane intersect */
49 int in_out; /**< @brief status of ray as it transitions
50 * this hit point.
51 */
56 int start_stop; /**< @brief is this a seg_in or seg_out */
57 struct hitmiss *other; /**< @brief for keeping track of the other
58 * end of the segment when we know
59 * it
60 */
61};
62
63
64
65/**
66 * Ray Data structure
67 *
68 * A) the hitmiss table has one element for each nmg structure in the
69 * nmgmodel. The table keeps track of which elements have been
70 * processed before and which haven't. Elements in this table will
71 * either be: (NULL) item not previously processed hitmiss ptr item
72 * previously processed
73 *
74 * the 0th item in the array is a pointer to the head of the "hit"
75 * list. The 1th item in the array is a pointer to the head of the
76 * "miss" list.
77 *
78 * B) If plane_pt is non-null then we are currently processing a face
79 * intersection. The plane_dist and ray_dist_to_plane are valid. The
80 * ray/edge intersector should check the distance from the plane
81 * intercept to the edge and update "plane_closest" if the current
82 * edge is closer to the intercept than the previous closest object.
83 */
84struct ray_data {
86 struct model *rd_m;
87 char *manifolds; /**< @brief structure 1-3manifold table */
89 struct xray *rp;
90 struct application *ap;
91 struct seg *seghead;
92 struct soltab *stp;
93 const struct bn_tol *tol;
94 struct hitmiss **hitmiss; /**< @brief 1 struct hitmiss ptr per elem. */
95 struct bu_list rd_hit; /**< @brief list of hit elements */
96 struct bu_list rd_miss; /**< @brief list of missed/sub-hit elements */
97
98/* The following are to support isect_ray_face() */
99
100 /**
101 * plane_pt is the intercept point of the ray with the plane of
102 * the face.
103 */
104 point_t plane_pt; /**< @brief ray/plane(face) intercept point */
105
106 /**
107 * ray_dist_to_plane is the parametric distance along the ray from
108 * the ray origin (rd->rp->r_pt) to the ray/plane intercept point
109 */
110 fastf_t ray_dist_to_plane; /**< @brief ray parametric dist to plane */
111
112 /**
113 * the "face_subhit" element is a boolean used by isect_ray_face
114 * and [e|v]u_touch_func to record the fact that the
115 * ray/(plane/face) intercept point was within tolerance of an
116 * edge/vertex of the face. In such instances, isect_ray_face
117 * does NOT need to generate a hit point for the face, as the hit
118 * point for the edge/vertex will suffice.
119 */
121
122 /**
123 * the "classifying_ray" flag indicates that this ray is being
124 * used to classify a point, so that the "eu_touch" and "vu_touch"
125 * functions should not be called.
126 */
128
129 struct bu_list *hitmiss_free; /**< @brief optional worker-local freelist */
130 struct nmg_class_scratch *class_scratch; /**< @brief optional point-classifier scratch */
131 struct bu_ptbl *hitstate[2]; /**< @brief optional state-transition scratch */
132};
133
134#define NMG_PCA_EDGE 1
135#define NMG_PCA_EDGE_VERTEX 2
136#define NMG_PCA_VERTEX 3
137
138/* From nmg_rt_isect.c */
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_tnurb(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 int nmg_bool_eval_silent; /* quell output from nmg_booltree_evaluate */
174RT_EXPORT extern union tree *nmg_booltree_evaluate(union tree *tp,
175 struct bu_list *vlfree,
176 const struct bn_tol *tol);
177RT_EXPORT extern int nmg_boolean(union tree *tp,
178 struct model *m,
179 struct bu_list *vlfree,
180 const struct bn_tol *tol);
181
182
183
184
185/* nmg_tri_mc.c */
186RT_EXPORT extern void nmg_triangulate_model_mc(struct model *m,
187 const struct bn_tol *tol);
188RT_EXPORT extern int nmg_mc_realize_cube(struct shell *s,
189 int pv,
190 point_t *edges,
191 const struct bn_tol *tol);
192RT_EXPORT extern int nmg_mc_evaluate(struct shell *s,
193 struct rt_i *rtip,
194 const struct db_full_path *pathp,
195 const struct bg_tess_tol *ttol,
196 const struct bn_tol *tol);
197
198
199/* nmg.c */
200RT_EXPORT extern void nmg_stash_model_to_file(const char *filename,
201 const struct model *m,
202 const char *title);
203
204
205#endif
206
208
209#endif /* RT_NMG__CONV_H */
210
211/*
212 * Local Variables:
213 * tab-width: 8
214 * mode: C
215 * indent-tabs-mode: t
216 * c-file-style: "stroustrup"
217 * End:
218 * ex: shiftwidth=4 tabstop=8
219 */
Definition dvec.h:74
Header file for the BRL-CAD common definitions.
fastf_t vect_t[ELEMENTS_PER_VECT]
3-tuple vector
Definition vmath.h:351
double fastf_t
fastest 64-bit (or larger) floating point type
Definition vmath.h:336
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition vmath.h:357
void rt_nmg_print_hitlist(struct bu_list *hd)
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 ptbl.h:53
Information about where a ray hits the surface.
Definition hit.h:61
long * inbound_use
Definition nmg_conv.h:52
struct hitmiss * other
for keeping track of the other end of the segment when we know it
Definition nmg_conv.h:57
vect_t inbound_norm
Definition nmg_conv.h:53
fastf_t dist_in_plane
distance from plane intersect
Definition nmg_conv.h:48
long * outbound_use
Definition nmg_conv.h:54
vect_t outbound_norm
Definition nmg_conv.h:55
int start_stop
is this a seg_in or seg_out
Definition nmg_conv.h:56
struct bu_list l
Definition nmg_conv.h:46
int in_out
status of ray as it transitions this hit point.
Definition nmg_conv.h:49
NMG topological model.
Definition topology.h:289
int face_subhit
Definition nmg_conv.h:120
struct model * rd_m
Definition nmg_conv.h:86
struct bu_list rd_hit
list of hit elements
Definition nmg_conv.h:95
struct bu_list * hitmiss_free
optional worker-local freelist
Definition nmg_conv.h:129
uint32_t magic
Definition nmg_conv.h:85
struct nmg_class_scratch * class_scratch
optional point-classifier scratch
Definition nmg_conv.h:130
struct seg * seghead
Definition nmg_conv.h:91
char * manifolds
structure 1-3manifold table
Definition nmg_conv.h:87
const struct bn_tol * tol
Definition nmg_conv.h:93
struct bu_list rd_miss
list of missed/sub-hit elements
Definition nmg_conv.h:96
struct soltab * stp
Definition nmg_conv.h:92
struct application * ap
Definition nmg_conv.h:90
struct bu_ptbl * hitstate[2]
optional state-transition scratch
Definition nmg_conv.h:131
struct xray * rp
Definition nmg_conv.h:89
fastf_t ray_dist_to_plane
ray parametric dist to plane
Definition nmg_conv.h:110
vect_t rd_invdir
Definition nmg_conv.h:88
int classifying_ray
Definition nmg_conv.h:127
point_t plane_pt
ray/plane(face) intercept point
Definition nmg_conv.h:104
struct hitmiss ** hitmiss
1 struct hitmiss ptr per elem.
Definition nmg_conv.h:94
Definition seg.h:59
NMG topological shell.
Definition topology.h:261
Primary ray data structure.
Definition xray.h:41
Definition tree.h:166
fundamental vector, matrix, quaternion math macros