BRL-CAD
Loading...
Searching...
No Matches
bot.h
Go to the documentation of this file.
1/* B O T . 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/** @addtogroup rt_bot */
21/** @{ */
22/** @file rt/primitives/bot.h */
23
24#ifndef RT_PRIMITIVES_BOT_H
25#define RT_PRIMITIVES_BOT_H
26
27#include "common.h"
28#include "vmath.h"
29#include "bu/ptbl.h"
30#include "bn/tol.h"
31#include "nmg.h"
32#include "rt/geom.h"
33#include "rt/defines.h"
34#include "rt/tol.h"
35#include "rt/view.h"
36#include "rt/soltab.h"
37
39#ifdef USE_OPENCL
40/* largest data members first */
41struct clt_bot_specific {
42 cl_ulong offsets[5]; /* header, bvh, tris, norms. */
44 cl_uchar orientation;
45 cl_uchar flags;
46 cl_uchar pad[2];
47};
48
49struct clt_tri_specific {
50 cl_double v0[3];
51 cl_double v1[3];
52 cl_double v2[3];
54 cl_uchar pad[4];
55};
56#endif
57
58/* Shared between bot and ars at the moment */
60 unsigned char bot_mode;
61 unsigned char bot_orientation;
62 unsigned char bot_flags;
63 size_t bot_ntri;
66 void *bot_facelist; /* head of linked list */
67 void **bot_facearray; /* head of face array */
68 void *tie; /* FIXME: horrible blind cast, points to one in rt_bot_internal */
69
70#ifdef USE_OPENCL
74#endif
75};
76
77
78// this is really close to struct tri_specific in plane.h
79// TODO: see if that ever gets serialized, and if it doesn't
80// then change that to this - memory coherency win
81// sizeof(triangle_s) should be 15/16 * (4/8) bytes
82typedef struct _triangle_s {
83 point_t A;
93struct rt_bot_edit {
94 int bot_verts[3]; /* vertices for the BOT solid */
95};
97/* bot.c */
98RT_EXPORT extern size_t rt_bot_get_edge_list(const struct rt_bot_internal *bot,
99 size_t **edge_list);
100RT_EXPORT extern int rt_bot_edge_in_list(const size_t v1,
101 const size_t v2,
102 const size_t edge_list[],
103 const size_t edge_count0);
104RT_EXPORT extern int rt_bot_plot(struct bu_list *vhead,
105 struct rt_db_internal *ip,
106 const struct bg_tess_tol *ttol,
107 const struct bn_tol *tol,
108 const struct bview *info);
109RT_EXPORT extern int rt_bot_plot_poly(struct bu_list *vhead,
110 struct rt_db_internal *ip,
111 const struct bg_tess_tol *ttol,
112 const struct bn_tol *tol);
113RT_EXPORT extern int rt_bot_find_v_nearest_pt2(const struct rt_bot_internal *bot,
114 const point_t pt2,
115 const mat_t mat);
116RT_EXPORT extern int rt_bot_find_e_nearest_pt2(int *vert1, int *vert2, const struct rt_bot_internal *bot, const point_t pt2, const mat_t mat);
118 const char *property);
120 const struct bn_tol *tol);
122RT_EXPORT extern int rt_bot_condense(struct rt_bot_internal *bot);
124 const char *bot_name,
125 struct db_i *dbip,
127RT_EXPORT extern int rt_bot_flip(struct rt_bot_internal *bot);
128RT_EXPORT extern int rt_bot_sync(struct rt_bot_internal *bot);
132 int fbflag);
135
136RT_EXPORT extern int rt_bot_same_orientation(const int *a,
137 const int *b);
139RT_EXPORT extern int rt_bot_tess(struct nmgregion **r,
140 struct model *m,
142 const struct bg_tess_tol *ttol,
143 const struct bn_tol *tol);
144
145RT_EXPORT extern struct rt_bot_internal * rt_bot_merge(size_t num_bots, const struct rt_bot_internal * const *bots);
146
148/* defined in bot.c */
149/* TODO - these global variables need to be rolled in to the rt_i structure */
150RT_EXPORT extern int rt_bot_sort_faces(struct rt_bot_internal *bot,
151 size_t tris_per_piece);
152RT_EXPORT extern int rt_bot_decimate(struct rt_bot_internal *bot,
155 fastf_t min_edge_length);
156
157
158/* Decimate the input Bot using feature_size to determine the target scale of
159 * geometric detail that is preserved in the output mesh.
160 *
161 * Geometrically, it represents the smallest meaningful feature or minimum
162 * detail size that should be retained. During decimation, edges, vertices, and
163 * triangles representing features smaller than feature_size are candidates for
164 * removal or simplification, while larger features are preserved. Thus,
165 * increasing feature_size produces a coarser mesh with fewer, larger
166 * triangles, removing fine details; decreasing it retains more of the original
167 * geometry and fine features. In essence, feature_size acts as a filter for
168 * the geometric fidelity of the simplified mesh.
169 *
170 * Note that feature_size is NOT a direct geometric measure, but is transformed
171 * internally into a collapse cost threshold. The detailed geometric
172 * consequences of the feature_size parameter on the output are an
173 * implementation detail, so calling codes may see differences in output meshes
174 * between different library versions for the same feature_size parameter.
175 */
176RT_EXPORT extern size_t rt_bot_decimate_gct(struct rt_bot_internal *bot, fastf_t feature_size);
177
178/* Function to convert plate mode BoT to volumetric BoT */
180
181
183/* Container to hold various settings we may need to control the bot repair
184 * process. May also be updated in the future to contain diagnostic info
185 * to report back to the caller - this struct is expected to change in
186 * response to the evolving setting needs of the repair process as various
187 * algorithms are explored.
188 */
189struct rt_bot_repair_info {
194 // Info about generated output
200/* For now the default upper hole size limit will be 5 percent of the mesh
201 * area, but calling codes should not rely on that value to remain consistent
202 * between versions.
203 *
204 * By default, don't return a mesh that can't pass the lint solid raytracing
205 * tests. This isn't always desirable - sometimes manifold is enough even if
206 * the mesh is not otherwise well behaved - so it is an user settable param.
207 */
208#define RT_BOT_REPAIR_INFO_INIT {0.0, 5.0, 1, 0, 0, 0.0};
209
210/* Function to attempt repairing a non-manifold BoT. Returns 1 if ibot was
211 * already manifold (obot will contain NULL), 0 if a manifold BoT was created
212 * (*obot will be the new manifold BoT) and -1 for other cases to indicate
213 * error.
214 */
215RT_EXPORT extern int rt_bot_repair(struct rt_bot_internal **obot, struct rt_bot_internal *ibot, struct rt_bot_repair_info *i);
216
217/* Test whether a bot is "inside-out". This function is aware of
218 * CCW vs CW BoT orientation settings, and will interpret the
219 * results of the test accordingly. The idea is for this function
220 * to return "1" in the same situations that would result in an
221 * OpenGL shaded drawing of the BoT showing black faces due to
222 * incorrect orientation. */
223RT_EXPORT extern int rt_bot_inside_out(struct rt_bot_internal *bot);
224
225/* Test whether a solid BoT has faces that are <tol distance away when shooting
226 * "into" the solid. This is (at the moment) a ray interrogation based test,
227 * so it is not absolutely guaranteed to find all near self-intersections.
228 *
229 * It is intended to catch situations such as boolean operations on meshes
230 * producing exceedingly thin volumes.
231 *
232 * Returns 1 if a problem is found, else 0. If ofaces is non-NULL, store the
233 * indices of the specific faces found to be problematic. */
234RT_EXPORT extern int rt_bot_thin_check(struct bu_ptbl *ofaces, struct rt_bot_internal *bot, struct rt_i *rtip, fastf_t tol, int verbose);
235
236/* Test whether a solid BoT has faces that produce raytrace segments with
237 * thickness in the range [VUNITIZE_TOL, BN_TOL_DIST). Such segments are
238 * returned by the BoT raytracer but would be discarded by the CSG boolweave
239 * tolerance filter, indicating a potential divergence between the BoT and
240 * the original CSG description (the CSG raytracer would report MISS while
241 * the BoT solid reports HIT).
242 *
243 * The typical cause is a subtractor primitive that protrudes just a sub-
244 * tolerance distance past a base face, creating a phantom thin cap in the
245 * facetized mesh that is too thin to survive the CSG boolweave.
246 *
247 * Faces already flagged by rt_bot_thin_check (segment thickness < VUNITIZE_TOL,
248 * i.e. true mesh degeneracies) are in a disjoint thickness range and are not
249 * reported here.
250 *
251 * Returns 1 if a problem is found, else 0. If ofaces is non-NULL, store the
252 * indices of the specific faces found to be problematic. */
253RT_EXPORT extern int rt_bot_csg_miss_check(struct bu_ptbl *ofaces, struct rt_bot_internal *bot, struct rt_i *rtip, int verbose);
254
255/* Function to remove a set of faces from a BoT and produce a new BoT */
258
259/* Function to copy an rt_bot_internal structure */
261rt_bot_dup(const struct rt_bot_internal *bot);
262
263/** @} */
266
267#endif /* RT_PRIMITIVES_BOT_H */
268
269/*
270 * Local Variables:
271 * tab-width: 8
272 * mode: C
273 * indent-tabs-mode: t
274 * c-file-style: "stroustrup"
275 * End:
276 * ex: shiftwidth=4 tabstop=8
277 */
Definition dvec.h:74
Header file for the BRL-CAD common definitions.
int rt_bot_csg_miss_check(struct bu_ptbl *ofaces, struct rt_bot_internal *bot, struct rt_i *rtip, int verbose)
int rt_bot_plate_to_vol(struct rt_bot_internal **obot, struct rt_bot_internal *bot, int round_outer_edges, int quiet_mode, fastf_t max_area_delta, fastf_t min_tri_threshold)
int rt_bot_sync(struct rt_bot_internal *bot)
int rt_bot_repair(struct rt_bot_internal **obot, struct rt_bot_internal *ibot, struct rt_bot_repair_info *i)
fastf_t rt_bot_propget(struct rt_bot_internal *bot, const char *property)
int rt_bot_edge_in_list(const size_t v1, const size_t v2, const size_t edge_list[], const size_t edge_count0)
int rt_bot_decimate(struct rt_bot_internal *bot, fastf_t max_chord_error, fastf_t max_normal_error, fastf_t min_edge_length)
size_t rt_bot_get_edge_list(const struct rt_bot_internal *bot, size_t **edge_list)
int rt_bot_tess(struct nmgregion **r, struct model *m, struct rt_db_internal *ip, const struct bg_tess_tol *ttol, const struct bn_tol *tol)
todo see if that ever gets and if it doesn t struct _triangle_s triangle_s
int rt_bot_sort_faces(struct rt_bot_internal *bot, size_t tris_per_piece)
struct rt_bot_internal * rt_bot_remove_faces(struct bu_ptbl *rm_face_indices, const struct rt_bot_internal *obot)
int rt_bot_smooth(struct rt_bot_internal *bot, const char *bot_name, struct db_i *dbip, fastf_t normal_tolerance_angle)
int rt_bot_condense(struct rt_bot_internal *bot)
struct rt_bot_internal * rt_bot_merge(size_t num_bots, const struct rt_bot_internal *const *bots)
int rt_bot_flip(struct rt_bot_internal *bot)
int rt_bot_plot(struct bu_list *vhead, struct rt_db_internal *ip, const struct bg_tess_tol *ttol, const struct bn_tol *tol, const struct bview *info)
int rt_bot_inside_out(struct rt_bot_internal *bot)
int rt_bot_find_e_nearest_pt2(int *vert1, int *vert2, const struct rt_bot_internal *bot, const point_t pt2, const mat_t mat)
void rt_bot_internal_free(struct rt_bot_internal *bot)
void rt_bot_list_free(struct rt_bot_list *headRblp, int fbflag)
int rt_bot_thin_check(struct bu_ptbl *ofaces, struct rt_bot_internal *bot, struct rt_i *rtip, fastf_t tol, int verbose)
struct rt_bot_list * rt_bot_split(struct rt_bot_internal *bot)
int rt_bot_vertex_fuse(struct rt_bot_internal *bot, const struct bn_tol *tol)
int rt_bot_face_fuse(struct rt_bot_internal *bot)
struct rt_bot_internal * rt_bot_dup(const struct rt_bot_internal *bot)
int rt_bot_same_orientation(const int *a, const int *b)
struct rt_bot_list * rt_bot_patches(struct rt_bot_internal *bot)
int rt_bot_plot_poly(struct bu_list *vhead, struct rt_db_internal *ip, const struct bg_tess_tol *ttol, const struct bn_tol *tol)
int rt_bot_find_v_nearest_pt2(const struct rt_bot_internal *bot, const point_t pt2, const mat_t mat)
size_t rt_bot_decimate_gct(struct rt_bot_internal *bot, fastf_t feature_size)
todo see if that ever gets serialized
Definition bot.h:81
fastf_t vect_t[ELEMENTS_PER_VECT]
3-tuple vector
Definition vmath.h:348
double fastf_t
fastest 64-bit (or larger) floating point type
Definition vmath.h:333
fastf_t mat_t[ELEMENTS_PER_MAT]
4x4 matrix
Definition vmath.h:369
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition vmath.h:354
vect_t face_norm
Definition bot.h:88
fastf_t * norms
Definition bot.h:90
point_t A
Definition bot.h:85
size_t face_id
Definition bot.h:91
vect_t AC
Definition bot.h:87
fastf_t face_norm_scalar
Definition bot.h:89
vect_t AB
Definition bot.h:86
Definition tol.h:72
fastf_t * bot_thickness
Definition bot.h:64
unsigned char bot_flags
Definition bot.h:62
void * bot_facelist
Definition bot.h:66
void * tie
Definition bot.h:68
unsigned char bot_orientation
Definition bot.h:61
size_t bot_ntri
Definition bot.h:63
unsigned char bot_mode
Definition bot.h:60
void ** bot_facearray
Definition bot.h:67
struct bu_bitv * bot_facemode
Definition bot.h:65
Definition bitv.h:95
Definition ptbl.h:53
NMG topological model.
Definition topology.h:289
NMG topological region.
Definition topology.h:277
int bot_verts[3]
Definition bot.h:96
struct rt_bot_internal * bot
Definition geom.h:859
fastf_t max_hole_area_percent
Definition bot.h:194
int output_nonmanifold
Definition bot.h:198
fastf_t output_volume
Definition bot.h:200
fastf_t max_hole_area
Definition bot.h:193
int output_lint_fail
Definition bot.h:199
fundamental vector, matrix, quaternion math macros