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-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
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#define _DARWIN_C_SOURCE
80
81#include "opennurbs.h"
82
83#if defined(__GNUC__) && !defined(__clang__)
84# pragma GCC diagnostic pop
85#endif
86#if defined(__clang__)
87# pragma clang diagnostic pop
88#endif
89
90}
91/* @endcond */
92
93#endif
94
95#include "vmath.h"
96
97/** @{ */
98/** @file brep/defines.h */
99
100#ifndef BREP_EXPORT
101# if defined(BREP_DLL_EXPORTS) && defined(BREP_DLL_IMPORTS)
102# error "Only BREP_DLL_EXPORTS or BREP_DLL_IMPORTS can be defined, not both."
103# elif defined(BREP_DLL_EXPORTS)
104# define BREP_EXPORT COMPILER_DLLEXPORT
105# elif defined(BREP_DLL_IMPORTS)
106# define BREP_EXPORT COMPILER_DLLIMPORT
107# else
108# define BREP_EXPORT
109# endif
110#endif
111
112#ifndef __cplusplus
113/**
114 * @brief Placeholder for ON_Brep to allow brep.h to compile when we're
115 * compiling with a C compiler
116 */
117typedef struct _on_brep_placeholder {
118 int dummy; /* MS Visual C hack which can be removed if the struct contains something meaningful */
119} ON_Brep;
120#endif
121
122/** Maximum number of newton iterations on root finding */
123#define BREP_MAX_ITERATIONS 100
125/** Root finding threshold */
126#define BREP_INTERSECTION_ROOT_EPSILON 1e-6
128/* if threshold not reached what will we settle for close enough */
129#define BREP_INTERSECTION_ROOT_SETTLE 1e-2
131/** Jungle Gym epsilon */
132
133/** tighten BREP grazing tolerance to 0.000017453(0.001 degrees) was using RT_DOT_TOL at 0.001 (0.05 degrees) **/
134#define BREP_GRAZING_DOT_TOL 0.000017453
136/** Use vector operations? For debugging */
137#define DO_VECTOR 1
139/** Maximum per-surface BVH depth */
140#define BREP_MAX_FT_DEPTH 8
141#define BREP_MAX_LN_DEPTH 20
143#define SIGN(x) ((x) >= 0 ? 1 : -1)
145/** Surface flatness parameter, Abert says between 0.8-0.9 */
146#define BREP_SURFACE_FLATNESS 0.85
147#define BREP_SURFACE_STRAIGHTNESS 0.75
149/** Max newton iterations when finding closest point */
150#define BREP_MAX_FCP_ITERATIONS 50
152/** Root finding epsilon */
153#define BREP_FCP_ROOT_EPSILON 1e-5
155/** trim curve point sampling count for isLinear() check and possibly
156 * * growing bounding box
157 * */
158#define BREP_BB_CRV_PNT_CNT 10
160#define BREP_CURVE_FLATNESS 0.95
162/** subdivision size factors */
163#define BREP_SURF_SUB_FACTOR 1
164#define BREP_TRIM_SUB_FACTOR 1
166/**
167 * The EDGE_MISS_TOLERANCE setting is critical in a couple of ways -
168 * too small and the allowed uncertainty region near edges will be
169 * smaller than the actual uncertainty needed for accurate solid
170 * raytracing, too large and trimming will not be adequate. May need
171 * to adapt this to the scale of the model, perhaps using bounding box
172 * size to key off of.
173 */
174/* #define BREP_EDGE_MISS_TOLERANCE 5e-2 */
175#define BREP_EDGE_MISS_TOLERANCE 5e-3
177#define BREP_SAME_POINT_TOLERANCE 1e-6
179/* arbitrary calculation tolerance */
180#define BREP_UV_DIST_FUZZ 0.000001
182/* @todo: debugging crapola (clean up later) */
183#define ON_PRINT4(p) "[" << (p)[0] << ", " << (p)[1] << ", " << (p)[2] << ", " << (p)[3] << "]"
184#define ON_PRINT3(p) "(" << (p)[0] << ", " << (p)[1] << ", " << (p)[2] << ")"
185#define ON_PRINT2(p) "(" << (p)[0] << ", " << (p)[1] << ")"
186#define PT(p) ON_PRINT3(p)
187#define PT2(p) ON_PRINT2(p)
188#define IVAL(_ival) "[" << (_ival).m_t[0] << ", " << (_ival).m_t[1] << "]"
189#define TRACE(s)
190#define TRACE1(s)
191#define TRACE2(s)
192/* #define TRACE(s) std::cerr << s << std::endl; */
193/* #define TRACE1(s) std::cerr << s << std::endl; */
194/* #define TRACE2(s) std::cerr << s << std::endl; */
195
196#ifdef __cplusplus
197extern "C++" {
198struct BrepTrimPoint
199{
201 double e; /* corresponding edge curve parameter (ON_UNSET_VALUE if using trim not edge) */
202 ON_3dPoint *p3d; /* 3d edge/trim point depending on whether we're using the 3d edge to generate points or the trims */
203 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. */
204 ON_3dVector tangent; /* Tangent from the curve, or from the surfaces if the curve wasn't usable at this point. */
207 double t; /* corresponding trim curve parameter (ON_UNSET_VALUE if unknown or not pulled back) */
208 ON_2dPoint p2d; /* 2d surface parameter space point */
209 ON_3dVector normal; /* normal as calculated by this trim */
212 int from_singular;
213};}
214#endif
215
216
217
218/** @} */
219
220#endif /* BREP_DEFINES_H */
221
222/*
223 * Local Variables:
224 * mode: C
225 * tab-width: 8
226 * indent-tabs-mode: t
227 * c-file-style: "stroustrup"
228 * End:
229 * ex: shiftwidth=4 tabstop=8
230 */
Definition dvec.h:74
Header file for the BRL-CAD common definitions.
ON_2dPoint p2d
Definition defines.h:210
ON_3dPoint * n3d
Definition defines.h:205
int from_singular
Definition defines.h:214
ON_3dPoint * p3d
Definition defines.h:204
ON_3dVector normal
Definition defines.h:211
ON_3dVector tangent
Definition defines.h:206
BrepTrimPoint * other_face_trim_pnt
Definition defines.h:213
fundamental vector, matrix, quaternion math macros