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