summaryrefslogtreecommitdiff
path: root/modules/graphic_objects/includes/MeshFecDataDecomposer.hxx
blob: 6303eb69a5f17b2ee983470a03da4fa2cc4de4e9 (plain)
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
183
184
185
/*
 *  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 MESHFECDATA_DECOMPOSER_HXX
#define MESHFECDATA_DECOMPOSER_HXX

/**
 * TriangleMeshFecData decomposer class
 * Determines the vertices and the segments indices to be rendered
 * as a function of the decomposed TriangleMeshFecData object's properties.
 * It only has static member functions since it stores no actual state.
 */

class MeshFecDataDecomposer
{

private :

    /**
     * Computes and returns the minimum and maximum values of an array.
     * @param[in] the value array.
     * @param[in] the array's number of values.
     * @param[out] a pointer to the returned minimum value.
     * @param[out] a pointer to the returned maximum value.
     */
    static void computeMinMaxValues(double* values, int numValues, double* valueMin, double* valueMax);

    /**
     * Determines whether a face's vertices are valid or not.
     * @param[in] the coordinates array.
     * @param[in] the first vertex index.
     * @param[in] the second vertex index.
     * @param[in] the third vertex index.
     * @param[in] a flag specifying whether logarithmic coordinates are used.
     * @return 1 if the face is valid, 0 if it is not.
     */
    static int areFaceVerticesValid(double* coordinates, int v0, int v1, int v2, int logMask);

    /**
     * Determines whether a face's vertices are valid or not.
     * @param[in] the coordinates array.
     * @param[in] the first vertex index.
     * @param[in] the second vertex index.
     * @param[in] a flag specifying whether logarithmic coordinates are used.
     * @return 1 if the face is valid, 0 if it is not.
     */
    static int areSegmentVerticesValid(double* coordinates, int v0, int v1, int logMask);

    /**
     * Determines whether a face's vertex values are valid or not.
     * @param[in] the values array.
     * @param[in] the first vertex index.
     * @param[in] the second vertex index.
     * @param[in] the third vertex index.
     * @return 1 if all face values are valid, 0 if not.
     */
    static int areFaceValuesValid(double* values, int v0, int v1, int v2);

    /**
     * Determines whether a face's vertex values are valid or not.
     * @param[in] the values array.
     * @param[in] the first vertex index.
     * @param[in] the second vertex index.
     * @return 1 if all face values are valid, 0 if not.
     */
    static int areSegmentValuesValid(double* values, int v0, int v1);

    /**
     * Determines whether all the vertex indices making up a face are valid.
     * To be valid, an index must belong to the interval [0, numVertices-1]
     * @param[in] the number of vertices giving the largest valid vertex index.
     * @param[in] the first vertex index.
     * @param[in] the second vertex index.
     * @param[in] the third vertex index.
     * @return 1 if all indices are valid, 0 if not.
     */
    static int areFaceIndicesValid(int numVertices, int v0, int v1, int v2);

    /**
     * Determines whether all the vertex indices making up a face are valid.
     * To be valid, an index must belong to the interval [0, numVertices-1]
     * @param[in] the number of vertices giving the largest valid vertex index.
     * @param[in] the first vertex index.
     * @param[in] the second vertex index.
     * @return 1 if all indices are valid, 0 if not.
     */
    static int areSegmentIndicesValid(int numVertices, int v0, int v1);

    /**
     * Returns the coordinates of a single vertex.
     * @param[in] the coordinates array.
     * @param[in] the vertex index.
     * @param[out] a pointer to the returned coordinates {x, y, z}.
     */
    static void getVertexCoordinates(double* coordinates, int index, double* vertexCoordinates);

public :

    /**
     * Returns the number of data elements for the given object.
     * @param[in] the given object id.
     * @return the number of data elements.
     */
    static int getDataSize(int id);

    /**
     * Fills the given buffer with vertex data from the given object.
     * @param[in] the id of the given object.
     * @param[out] the buffer to fill.
     * @param[in] the buffer length in number of elements.
     * @param[in] the number of coordinates taken by one element in the buffer.
     * @param[in] the byte mask specifying which coordinates are filled (1 for X, 2 for Y, 4 for Z).
     * @param[in] the conversion scale factor to apply to data.
     * @param[in] the conversion translation factor to apply to data.
     * @param[in] the bit mask specifying whether logarithmic coordinates are used.
     */
    static void fillVertices(int id, float* buffer, int bufferLength, int elementsSize, int coordinateMask, double* scale, double* translation, int logMask);

    /**
     * Fills the given buffer with color data from the given object.
     * @param[in] the id of the given object.
     * @param[out] the buffer to fill.
     * @param[in] the buffer length in number of elements.
     * @param[in] the number of components taken by one element in the buffer (3 or 4).
     */
    static void fillColors(int id, float* buffer, int bufferLength, int elementsSize);

    /**
     * Fills the given buffer with texture coordinates data from the given object.
     * @param[in] the id of the given object.
     * @param[in] the buffer to fill.
     * @param[in] the buffer length in number of elements.
     */
    static void fillTextureCoordinates(int id, float* buffer, int bufferLength);

    /**
     * Returns the number of indices for the given object.
     * @param[in] the given object id.
     * @return the object's number of indices.
     */
    static int getIndicesSize(int id);

    /**
     * Fills the given buffer with indices data of the given object.
     * @param[in] the given object id.
     * @param[out] the buffer to fill.
     * @param[in] the buffer length.
     * @param[in] the bit mask specifying whether logarithmic coordinates are used.
     * @return the number of indices actually written.
     */
    static int fillIndices(int id, int* buffer, int bufferLength, int logMask);

    /**
     * Returns the number of wireframe indices for the given object.
     * It is equal to twice the number of segments that can be at most
     * drawn according to the Fec object's properties and therefore does not
     * take non-representable points into account.
     * @param[in] the given object id.
     * @return the object's number of indices.
     */
    static int getWireIndicesSize(int id);

    /**
     * Fills the given buffer with wireframe indices data of the given object.
     * The number of indices actually written is equal to or less than
     * the buffer length, which is the object's maximum number of indices.
     * @param[in] the id of the given object.
     * @param[out] the buffer to fill.
     * @param[in] the buffer length.
     * @param[in] the bit mask specifying whether logarithmic coordinates are used.
     * @return the number of indices actually written.
     */
    static int fillWireIndices(int id, int* buffer, int bufferLength, int logMask);
};

#endif