BRL-CAD
Loading...
Searching...
No Matches
defines.h
Go to the documentation of this file.
1/* D E F I N E S . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2004-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
21/** @addtogroup brep_defines
22 *
23 * @brief
24 * These are definitions specific to libbrep, used throughout the library.
25 *
26 */
27#ifndef BREP_DEFINES_H
28#define BREP_DEFINES_H
29
30#include "common.h"
31
32/* We need a guarded windows.h inclusion, so use bio.h to get it before
33 * opennurbs.h pulls it in */
34#include "bio.h"
35
36#ifdef __cplusplus
37
38/* Note - We aren't (yet) including opennurbs in our Doxygen output. Until we
39 * do, use cond to hide the opennurbs header from Doxygen. */
40/* @cond */
41extern "C++" {
42
43
44#if defined(__GNUC__) && !defined(__clang__)
45# pragma GCC diagnostic push
46#endif
47#if defined(__clang__)
48# pragma clang diagnostic push
49#endif
50#if defined(__GNUC__) && !defined(__clang__)
51# if (__GNUC__ < 13)
52 // There seems to be a problem with multiple pragma diagnostic
53 // calls in GCC 12... try https://stackoverflow.com/a/56887760
54# if GCC_PREREQ(8,0)
55# pragma GCC system_header
56# endif
57# else
58# pragma GCC diagnostic ignored "-Wclass-memaccess"
59# pragma GCC diagnostic ignored "-Wunknown-pragmas"
60# pragma GCC diagnostic ignored "-Wcomment"
61# pragma GCC diagnostic ignored "-Wignored-qualifiers"
62# pragma GCC diagnostic ignored "-Woverloaded-virtual"
63# endif
64#endif
65#if defined(__clang__)
66# pragma clang diagnostic ignored "-Wunknown-pragmas"
67# pragma clang diagnostic ignored "-Wignored-qualifiers"
68# pragma clang diagnostic ignored "-Woverloaded-virtual"
69# pragma clang diagnostic ignored "-Wshadow"
70#endif
71
72/* don't let opennurbs include windows.h */
73#define ON_NO_WINDOWS 1
74
75// TODO - need a compile time test that can tell whether this is required or
76// not - needed for building with Xcode 16, apparently. My first attempt at a
77// configure time test didn't work - need someone who can debug interactively
78// in OSX. In the meantime add this as a temporary measure.
79#ifndef _DARWIN_C_SOURCE
80# define _DARWIN_C_SOURCE
81#endif
82
83#include "opennurbs.h"
84
85#if defined(__GNUC__) && !defined(__clang__)
86# pragma GCC diagnostic pop
87#endif
88#if defined(__clang__)
89# pragma clang diagnostic pop
90#endif
91
92}
93/* @endcond */
94
95#endif
96
97#include "vmath.h"
98
99/** @{ */
100/** @file brep/defines.h */
101
102#ifndef BREP_EXPORT
103# if defined(BREP_DLL_EXPORTS) && defined(BREP_DLL_IMPORTS)
104# error "Only BREP_DLL_EXPORTS or BREP_DLL_IMPORTS can be defined, not both."
105# elif defined(BREP_DLL_EXPORTS)
106# define BREP_EXPORT COMPILER_DLLEXPORT
107# elif defined(BREP_DLL_IMPORTS)
108# define BREP_EXPORT COMPILER_DLLIMPORT
109# else
110# define BREP_EXPORT
111# endif
112#endif
113
114#ifndef __cplusplus
115/**
116 * @brief Placeholder for ON_Brep to allow brep.h to compile when we're
117 * compiling with a C compiler
118 */
119typedef struct _on_brep_placeholder {
120 int dummy; /* MS Visual C hack which can be removed if the struct contains something meaningful */
121} ON_Brep;
122#endif
123
124/** Maximum number of newton iterations on root finding */
125#define BREP_MAX_ITERATIONS 100
127/** Root finding threshold */
128#define BREP_INTERSECTION_ROOT_EPSILON 1e-6
130/* if threshold not reached what will we settle for close enough */
131#define BREP_INTERSECTION_ROOT_SETTLE 1e-2
133/** Jungle Gym epsilon */
134
135/** tighten BREP grazing tolerance to 0.000017453(0.001 degrees) was using RT_DOT_TOL at 0.001 (0.05 degrees) **/
136#define BREP_GRAZING_DOT_TOL 0.000017453
138/** Use vector operations? For debugging */
139#define DO_VECTOR 1
141/** Maximum per-surface BVH depth */
142#define BREP_MAX_FT_DEPTH 8
143#define BREP_MAX_LN_DEPTH 20
145#define SIGN(x) ((x) >= 0 ? 1 : -1)
147/** Surface flatness parameter, Abert says between 0.8-0.9 */
148#define BREP_SURFACE_FLATNESS 0.85
149#define BREP_SURFACE_STRAIGHTNESS 0.75
151/** Max newton iterations when finding closest point */
152#define BREP_MAX_FCP_ITERATIONS 50
154/** Root finding epsilon */
155#define BREP_FCP_ROOT_EPSILON 1e-5
157/** trim curve point sampling count for isLinear() check and possibly
158 * * growing bounding box
159 * */
160#define BREP_BB_CRV_PNT_CNT 10
162#define BREP_CURVE_FLATNESS 0.95
164/** subdivision size factors */
165#define BREP_SURF_SUB_FACTOR 1
166#define BREP_TRIM_SUB_FACTOR 1
168/**
169 * The EDGE_MISS_TOLERANCE setting is critical in a couple of ways -
170 * too small and the allowed uncertainty region near edges will be
171 * smaller than the actual uncertainty needed for accurate solid
172 * raytracing, too large and trimming will not be adequate. May need
173 * to adapt this to the scale of the model, perhaps using bounding box
174 * size to key off of.
175 */
176/* #define BREP_EDGE_MISS_TOLERANCE 5e-2 */
177#define BREP_EDGE_MISS_TOLERANCE 5e-3
179#define BREP_SAME_POINT_TOLERANCE 1e-6
181/* arbitrary calculation tolerance */
182#define BREP_UV_DIST_FUZZ 0.000001
184/* @todo: debugging crapola (clean up later) */
185#define ON_PRINT4(p) "[" << (p)[0] << ", " << (p)[1] << ", " << (p)[2] << ", " << (p)[3] << "]"
186#define ON_PRINT3(p) "(" << (p)[0] << ", " << (p)[1] << ", " << (p)[2] << ")"
187#define ON_PRINT2(p) "(" << (p)[0] << ", " << (p)[1] << ")"
188#define PT(p) ON_PRINT3(p)
189#define PT2(p) ON_PRINT2(p)
190#define IVAL(_ival) "[" << (_ival).m_t[0] << ", " << (_ival).m_t[1] << "]"
191#define TRACE(s)
192#define TRACE1(s)
193#define TRACE2(s)
194/* #define TRACE(s) std::cerr << s << std::endl; */
195/* #define TRACE1(s) std::cerr << s << std::endl; */
196/* #define TRACE2(s) std::cerr << s << std::endl; */
197
198#ifdef __cplusplus
199extern "C++" {
200struct BrepTrimPoint
201{
203 double e; /* corresponding edge curve parameter (ON_UNSET_VALUE if using trim not edge) */
204 ON_3dPoint *p3d; /* 3d edge/trim point depending on whether we're using the 3d edge to generate points or the trims */
205 ON_3dPoint *n3d; /* normal on edge, average of the normals from the two surfaces at this point, or of all surface points associated with a vertex if this is a vertex point. */
206 ON_3dVector tangent; /* Tangent from the curve, or from the surfaces if the curve wasn't usable at this point. */
209 double t; /* corresponding trim curve parameter (ON_UNSET_VALUE if unknown or not pulled back) */
210 ON_2dPoint p2d; /* 2d surface parameter space point */
211 ON_3dVector normal; /* normal as calculated by this trim */
214 int from_singular;
215};}
216#endif
217
218
219
220/** @} */
221
222#endif /* BREP_DEFINES_H */
223
224/*
225 * Local Variables:
226 * mode: C
227 * tab-width: 8
228 * indent-tabs-mode: t
229 * c-file-style: "stroustrup"
230 * End:
231 * ex: shiftwidth=4 tabstop=8
232 */
Definition dvec.h:74
Header file for the BRL-CAD common definitions.
ON_2dPoint p2d
Definition defines.h:212
ON_3dPoint * n3d
Definition defines.h:207
int from_singular
Definition defines.h:216
ON_3dPoint * p3d
Definition defines.h:206
ON_3dVector normal
Definition defines.h:213
ON_3dVector tangent
Definition defines.h:208
BrepTrimPoint * other_face_trim_pnt
Definition defines.h:215
fundamental vector, matrix, quaternion math macros