1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2011 - DIGITEO - Manuel Juliachs
*
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at
* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
*
*/
#ifndef DECOMPOSITION_UTILS_HXX
#define DECOMPOSITION_UTILS_HXX
/**
* Decomposition utility class
* A set of various static utility methods.
*/
class DecompositionUtils
{
public :
/**
* Tests whether a scalar value is a valid number,
* that is, not a NaN.
* @param[in] the scalar value to test.
* @return 1 if the value is not a Nan, 0 if it is.
*/
static int isANumber(double x);
static int isANumber(int x)
{
return 1;
}
static int isANumber(unsigned int x)
{
return 1;
}
static int isANumber(char x)
{
return 1;
}
static int isANumber(unsigned char x)
{
return 1;
}
static int isANumber(short x)
{
return 1;
}
static int isANumber(unsigned short x)
{
return 1;
}
/**
* Tests whether a scalar value is finite.
* @param[in] the scalar value to test.
* @return 1 if the value is finite, 0 if it is infinite.
*/
static int isFinite(double x);
/**
* Tests whether a scalar value is valid.
* The value is valid if it is neither infinite nor a NaN.
* @param[in] the scalar value to test.
* @return 1 if the value is valid, 0 if it is not.
*/
static int isValid(double x);
/**
* Tests whether a point is valid.
* The point is valid if none of its coordinates is infinite or a NaN.
* @param[in] the point's x-coordinate.
* @param[in] the point's y-coordinate.
* @param[in] the point's z-coordinate.
* @return 1 if the point is valid, 0 if it is not.
*/
static int isValid(double x, double y, double z);
/**
* Tests whether a point is valid.
* The point is valid if none of its coordinates is infinite or a NaN.
* @param[in] the point's x-coordinate.
* @param[in] the point's y-coordinate.
* @return 1 if the point is valid, 0 if it is not.
*/
static int isValid(double x, double y);
/**
* Returns the base-10 logarithm of the input value.
* @param[in] the input value.
* @return the base-10 logarithm of the input value.
*/
static double getLog10Value(double value);
/**
* Determines if a single-component point is valid in logarithmic scale.
* @param[in] the point's coordinate.
* @return 1 if the point is valid, 0 if it is not.
*/
static int isLogValid(double x);
/**
* Determines if a point is valid in logarithmic scale.
* It checks whether any of its coordinates is strictly less than 0 (if the
* logarithmic scale applies). In the event of the former, the point is
* determined as not valid.
* @param[in] the point's x-coordinate.
* @param[in] the point's y-coordinate.
* @param[in] the bit mask specifying for which coordinates the logarithmic scale is used.
* @return 1 if the point is valid, 0 if it is not.
*/
static int isLogValid(double x, double y, int logMask);
/**
* Determines if a point is valid in logarithmic scale.
* It checks whether any of its coordinates is strictly less than 0 (if the
* logarithmic scale applies). In the event of the former, the point is
* determined as not valid.
* @param[in] the point's x-coordinate.
* @param[in] the point's y-coordinate.
* @param[in] the point's z-coordinate.
* @param[in] the bit mask specifying for which coordinates the logarithmic scale is used.
* @return 1 if the point is valid, 0 if it is not.
*/
static int isLogValid(double x, double y, double z, int logMask);
/**
* Returns the maximum representable double value.
* @return the maximum representable double value.
*/
static double getMaxDoubleValue(void);
/**
* Returns the minimum representable double value.
* @return the minimum representable double value.
*/
static double getMinDoubleValue(void);
/**
* Returns the absolute value of its input value.
* @param[in] the value.
* @return the absolute value.
*/
static double getAbsoluteValue(double value);
/**
* Returns the square root of its input value.
* @param[in] the value.
* @return the value's square root.
*/
static double getSquareRoot(double value);
/**
* Utility function which outputs the triangle indices of a rectangle decomposed
* into 2 adjacent triangles. Decomposition is always performed the same way as it does not
* depend on input vertex values. This function should therefore be used only for rectangles.
* @param[out] the triangle indices (v0, v1, v2), (v3, v4, v5).
*/
static void getDecomposedRectangleTriangleIndices(int* indices);
/**
* Decomposes a quadrilateral facet into two triangles and outputs the resulting vertex indices.
* As there are two possible decompositions, it chooses the one which has the most coplanar triangles.
* The output triangles' vertex indices are in counter-clockwise order.
* @param[in] the facet vertices (4 (x,y,z) triplets, in counter-clockwise order).
* @param[in] the facet vertices' indices (4 elements, in counter-clockwise order).
* @param[out] the triangles' vertex indices (6 elements: two consecutive index triplets).
*/
static void getDecomposedQuadTriangleIndices(double vertices[4][3], int* facetVertexIndices, int* triangleVertexIndices);
};
#endif
|