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