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-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/** @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,
156RT_EXPORT extern size_t rt_bot_decimate_gct(struct rt_bot_internal *bot, fastf_t feature_size);
157
158/* Function to convert plate mode BoT to volumetric BoT */
160
161
163/* Container to hold various settings we may need to control the bot repair
164 * process. May also be updated in the future to contain diagnostic info
165 * to report back to the caller - this struct is expected to change in
166 * response to the evolving setting needs of the repair process as various
167 * algorithms are explored.
168 */
169struct rt_bot_repair_info {
175/* For now the default upper hole size limit will be 5 percent of the mesh
176 * area, but calling codes should not rely on that value to remain consistent
177 * between versions.
178 *
179 * By default, don't return a mesh that can't pass the lint solid raytracing
180 * tests. This isn't always desirable - sometimes manifold is enough even if
181 * the mesh is not otherwise well behaved - so it is an user settable param.
182 */
183#define RT_BOT_REPAIR_INFO_INIT {0.0, 5.0, 1};
184
185/* Function to attempt repairing a non-manifold BoT. Returns 1 if ibot was
186 * already manifold (obot will contain NULL), 0 if a manifold BoT was created
187 * (*obot will be the new manifold BoT) and -1 for other cases to indicate
188 * error.
189 */
190RT_EXPORT extern int rt_bot_repair(struct rt_bot_internal **obot, struct rt_bot_internal *ibot, struct rt_bot_repair_info *i);
191
192/* Test whether a bot is "inside-out". This function is aware of
193 * CCW vs CW BoT orientation settings, and will interpret the
194 * results of the test accordingly. The idea is for this function
195 * to return "1" in the same situations that would result in an
196 * OpenGL shaded drawing of the BoT showing black faces due to
197 * incorrect orientation. */
198RT_EXPORT extern int rt_bot_inside_out(struct rt_bot_internal *bot);
199
200/* Test whether a solid BoT has faces that are <tol distance away when shooting
201 * "into" the solid. This is (at the moment) a ray interrogation based test,
202 * so it is not absolutely guaranteed to find all near self-intersections.
203 *
204 * It is intended to catch situations such as boolean operations on meshes
205 * producing exceedingly thin volumes.
206 *
207 * Returns 1 if a problem is found, else 0. If ofaces is non-NULL, store the
208 * indices of the specific faces found to be problematic. */
209RT_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);
210
211/* Function to remove a set of faces from a BoT and produce a new BoT */
214
215/* Function to copy an rt_bot_internal structure */
217rt_bot_dup(const struct rt_bot_internal *bot);
218
219/** @} */
222
223#endif /* RT_PRIMITIVES_BOT_H */
224
225/*
226 * Local Variables:
227 * tab-width: 8
228 * mode: C
229 * indent-tabs-mode: t
230 * c-file-style: "stroustrup"
231 * End:
232 * ex: shiftwidth=4 tabstop=8
233 */
Definition dvec.h:74
Header file for the BRL-CAD common definitions.
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_plate_to_vol(struct rt_bot_internal **obot, struct rt_bot_internal *bot, int round_outer_edges, int quiet_mode)
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:349
double fastf_t
fastest 64-bit (or larger) floating point type
Definition vmath.h:334
fastf_t mat_t[ELEMENTS_PER_MAT]
4x4 matrix
Definition vmath.h:370
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition vmath.h:355
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 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:862
fastf_t max_hole_area_percent
Definition bot.h:174
fastf_t max_hole_area
Definition bot.h:173
fundamental vector, matrix, quaternion math macros