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-2025 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*/
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 {
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/* From nmg_rt_isect.c */
134RT_EXPORT extern void rt_nmg_print_hitmiss(struct hitmiss *a_hit);
135RT_EXPORT extern void rt_isect_ray_model(struct ray_data *rd, struct bu_list *vlfree);
136
137/************************************************************************
138 * *
139 * NMG Support Function Declarations *
140 * *
141 ************************************************************************/
142#if defined(NMG_H)
143
144/* nmg.c */
145RT_EXPORT extern int nmg_ray_segs(struct ray_data *rd, struct bu_list *vlfree);
146
147RT_EXPORT extern int nmg_to_arb(const struct model *m,
148 struct rt_arb_internal *arb_int);
149RT_EXPORT extern int nmg_to_tgc(const struct model *m,
150 struct rt_tgc_internal *tgc_int,
151 const struct bn_tol *tol);
152RT_EXPORT extern int nmg_to_poly(const struct model *m,
153 struct rt_pg_internal *poly_int,
154 struct bu_list *vlfree,
155 const struct bn_tol *tol);
156RT_EXPORT extern struct rt_bot_internal *nmg_bot(struct shell *s,
157 struct bu_list *vlfree,
158 const struct bn_tol *tol);
159RT_EXPORT extern struct rt_bot_internal *nmg_mdl_to_bot(struct model *m,
160 struct bu_list *vlfree,
161 const struct bn_tol *tol);
162struct db_tree_state; /* forward declaration */
163RT_EXPORT extern union tree *nmg_booltree_leaf_tnurb(struct db_tree_state *tsp,
164 const struct db_full_path *pathp,
165 struct rt_db_internal *ip,
166 void *client_data);
167RT_EXPORT extern int nmg_bool_eval_silent; /* quell output from nmg_booltree_evaluate */
168RT_EXPORT extern union tree *nmg_booltree_evaluate(union tree *tp,
169 struct bu_list *vlfree,
170 const struct bn_tol *tol,
171 struct resource *resp);
172RT_EXPORT extern int nmg_boolean(union tree *tp,
173 struct model *m,
174 struct bu_list *vlfree,
175 const struct bn_tol *tol,
176 struct resource *resp);
177
178
179
180
181/* nmg_tri_mc.c */
182RT_EXPORT extern void nmg_triangulate_model_mc(struct model *m,
183 const struct bn_tol *tol);
184RT_EXPORT extern int nmg_mc_realize_cube(struct shell *s,
185 int pv,
186 point_t *edges,
187 const struct bn_tol *tol);
188RT_EXPORT extern int nmg_mc_evaluate(struct shell *s,
189 struct rt_i *rtip,
190 const struct db_full_path *pathp,
191 const struct bg_tess_tol *ttol,
192 const struct bn_tol *tol);
193
194
195/* nmg.c */
196RT_EXPORT extern void nmg_stash_model_to_file(const char *filename,
197 const struct model *m,
198 const char *title);
199
200
201#endif
202
204
205#endif /* RT_NMG__CONV_H */
206
207/*
208 * Local Variables:
209 * tab-width: 8
210 * mode: C
211 * indent-tabs-mode: t
212 * c-file-style: "stroustrup"
213 * End:
214 * ex: shiftwidth=4 tabstop=8
215 */
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:349
double fastf_t
fastest 64-bit (or larger) floating point type
Definition vmath.h:334
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition vmath.h:355
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
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
Primary ray data structure.
Definition xray.h:41
Definition tree.h:169
fundamental vector, matrix, quaternion math macros