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
/*----------------------------------------------------------------------*/
22
/** @addtogroup bg_defines
23
* @brief
24
* Common definitions for the headers used in bg.h (i.e. the headers found in include/bg)
25
*/
26
/** @{ */
27
/** @file bg/defines.h */
28
29
#ifndef BG_DEFINES_H
30
#define BG_DEFINES_H
31
32
#include "
common.h
"
33
34
#ifndef BG_EXPORT
35
# if defined(BG_DLL_EXPORTS) && defined(BG_DLL_IMPORTS)
36
# error "Only BG_DLL_EXPORTS or BG_DLL_IMPORTS can be defined, not both."
37
# elif defined(BG_DLL_EXPORTS)
38
# define BG_EXPORT COMPILER_DLLEXPORT
39
# elif defined(BG_DLL_IMPORTS)
40
# define BG_EXPORT COMPILER_DLLIMPORT
41
# else
42
# define BG_EXPORT
43
# endif
44
#endif
45
46
/* Definitions for clockwise and counter-clockwise loop directions */
47
#define BG_CW 1
48
#define BG_CCW -1
49
50
/**
51
* Tessellation (geometric) tolerances, different beasts than the
52
* calculation tolerance in bn_tol.
53
54
* norm - angle between adjacent sampling normals may be no greater than norm degrees
55
* absmax - triangle edge must be no larger than length abs
56
* absmin - triangle edge may be no smaller than length absmin
57
* relmax - triangle edge must be no larger than rel % of object bbox diagonal len
58
* relmin - triangle edge may be no smaller than relmin % of object bbox diagonal len.
59
* relfacemax - triangle edge must be no larger than rel % of the smaller of
60
* the two bbox diagonal lengths of the faces associated with the edge (edge
61
* curves) or the bbox diagonal length of the current face (surfaces)
62
* relfacemin - triangle edge may be no smaller than rel % of the smaller of
63
* the two bbox diagonal lengths of the faces associated with the edge (edge
64
* curves) or the bbox diagonal length of the current face (surfaces)
65
*
66
* For the min parameters, they will be specified with the caveot that any surface
67
* will have at least one midpt breakdown (more for closed surfaces), even if that
68
* produces smaller triangles than mins specifies. I.e. the min lengths are a
69
* goal, but not an absolute guarantee. Triangle aspect ratio constraints will
70
* also override these parameters.
71
*
72
* With the above caveot, the first limit hit of any set limits will hault refinement.
73
* Need to track go/no-go refinement decisions so we can report on what the important
74
* parameters are for a given operation - this will give users some idea of how to
75
* modify settings to change behavior.
76
*
77
* For the max parameters, we may need to warn on objects where they would produce
78
* a huge number of triangles if tiny maxes are specified - this is generally not
79
* user intent and will not work in extreme cases due to resource exhaustion.
80
*
81
* All triangles must satisfy an aspect ratio parameter (smallest height may be no less than
82
* .1x the longest edge length) to prevent wildly distorted triangles.) For triangles near
83
* edges, surface points may be removed if necessary to satisfy this criteria.
84
*
85
* All operations must satisfy above criteria first. Additional constraints are
86
* defined below. These are intended, among other things, to prevent aspect ratio
87
* problems when extremely long edge segments and fine surface meshes combine to
88
* produce extremely distorted triangles near edges):
89
*
90
* For non-linear edges, max edge seg len may be no greater than 5x the smallest
91
* avg line segment length of any non-linear edge breakdowns in either loop
92
* associated with that edge. This will require a two-pass operation - an initial
93
* breakdown of all non-linear edge curves, and a refinement pass to break down
94
* those segments which don't meet the above criteria.
95
*
96
* For linear edges, max edge seg len may be no greater than 10x the smallest
97
* avg line segment length of any non-linear edge breakdowns in either
98
* loop associated with that edge. This will require a third edge pass, once
99
* the above curved edge breakdown is complete.
100
*
101
* For any surface, max edge length may be no greater than .1 times the shorter
102
* of the surface's length/width (we shrink surfaces so this number has
103
* some relation to the trimmed face size).
104
*
105
* For a non-planar surface, max edge length may be no greater than 10 times the
106
* shortest average line segment length in the face's loops' edges (curved or
107
* linear). (e.g. triangles in curved surfaces may not be enormously large
108
* compared to the edges' fidelity.) We don't impose this restriction on
109
* planar surfaces on the theory that any valid CDT will accurate represent the
110
* surface, so we don't need to enforce any particular edge length on interior
111
* triangles. However...
112
*
113
*/
114
struct
bg_tess_tol
{
115
uint32_t
magic
;
116
double
abs
;
/**< @brief absolute dist tol */
117
double
rel
;
/**< @brief rel dist tol */
118
double
norm
;
/**< @brief normal tol */
119
120
/* Parameters specialized for breps */
121
double
absmax
;
122
double
absmin
;
123
double
relmax
;
124
double
relmin
;
125
double
rel_lmax
;
/* local relative maximum */
126
double
rel_lmin
;
/* local relative minimum */
127
};
128
#define BG_CK_TESS_TOL(_p) BU_CKMAG(_p, BG_TESS_TOL_MAGIC, "bg_tess_tol"
)
129
#define BG_TESS_TOL_INIT_ZERO {BG_TESS_TOL_MAGIC, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
130
#define BG_TESS_TOL_INIT_TOL {BG_TESS_TOL_MAGIC, 0.0, 0.01, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
131
#define BG_TESS_TOL_INIT_SET_TOL(_p) { \
132
(_p)->magic = BG_TESS_TOL_MAGIC; \
133
(_p)->abs = 0.0; \
134
(_p)->rel = 0.01; \
135
(_p)->norm = 0.0; \
136
(_p)->absmax = 0.0; \
137
(_p)->absmin = 0.0; \
138
(_p)->relmax = 0.0; \
139
(_p)->relmin = 0.0; \
140
(_p)->rel_lmax = 0.0; \
141
(_p)->rel_lmin = 0.0; \
142
}
143
144
145
146
#endif
/* BG_DEFINES_H */
147
/** @} */
148
/*
149
* Local Variables:
150
* mode: C
151
* tab-width: 8
152
* indent-tabs-mode: t
153
* c-file-style: "stroustrup"
154
* End:
155
* ex: shiftwidth=4 tabstop=8
156
*/
common.h
Header file for the BRL-CAD common definitions.
bg_tess_tol
Definition:
defines.h:114
bg_tess_tol::relmin
double relmin
Definition:
defines.h:124
bg_tess_tol::rel_lmax
double rel_lmax
Definition:
defines.h:125
bg_tess_tol::rel_lmin
double rel_lmin
Definition:
defines.h:126
bg_tess_tol::rel
double rel
rel dist tol
Definition:
defines.h:117
bg_tess_tol::absmax
double absmax
Definition:
defines.h:121
bg_tess_tol::magic
uint32_t magic
Definition:
defines.h:115
bg_tess_tol::norm
double norm
normal tol
Definition:
defines.h:118
bg_tess_tol::relmax
double relmax
Definition:
defines.h:123
bg_tess_tol::abs
double abs
absolute dist tol
Definition:
defines.h:116
bg_tess_tol::absmin
double absmin
Definition:
defines.h:122
include
bg
defines.h
Generated on Tue Mar 7 2023 23:41:50 for BRL-CAD by
1.9.3