Coverage Report

Created: 2025-08-26 06:41

/src/assimp/contrib/Open3DGC/o3dgcIndexedFaceSet.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
Copyright (c) 2013 Khaled Mammou - Advanced Micro Devices, Inc.
3
4
Permission is hereby granted, free of charge, to any person obtaining a copy
5
of this software and associated documentation files (the "Software"), to deal
6
in the Software without restriction, including without limitation the rights
7
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
copies of the Software, and to permit persons to whom the Software is
9
furnished to do so, subject to the following conditions:
10
11
The above copyright notice and this permission notice shall be included in
12
all copies or substantial portions of the Software.
13
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
THE SOFTWARE.
21
*/
22
23
24
#pragma once
25
#ifndef O3DGC_INDEXED_FACE_SET_H
26
#define O3DGC_INDEXED_FACE_SET_H
27
28
#include "o3dgcCommon.h"
29
30
namespace o3dgc
31
{
32
    template<class T>
33
    class IndexedFaceSet
34
    {
35
    public:    
36
        //! Constructor.
37
                                         IndexedFaceSet(void)
38
0
                                         {
39
0
                                             memset(this, 0, sizeof(IndexedFaceSet));
40
0
                                             m_ccw              = true;
41
0
                                             m_solid            = true;
42
0
                                             m_convex           = true;
43
0
                                             m_isTriangularMesh = true;
44
0
                                             m_creaseAngle      = 30;
45
0
                                         };
46
        
47
0
        unsigned long                    GetNCoordIndex() const { return m_nCoordIndex     ;}
48
        // only coordIndex is supported
49
0
        unsigned long                    GetNCoord()           const { return m_nCoord         ;}
50
0
        unsigned long                    GetNNormal()          const { return m_nNormal        ;}
51
        unsigned long                    GetNFloatAttribute(unsigned long a)  const 
52
0
                                         { 
53
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES);
54
0
                                             return m_nFloatAttribute[a];
55
0
                                         }
56
        unsigned long                    GetNIntAttribute(unsigned long a)  const 
57
0
                                         { 
58
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES);
59
0
                                             return m_nIntAttribute[a];
60
0
                                         }
61
0
        unsigned long                    GetNumFloatAttributes()  const { return m_numFloatAttributes;}
62
0
        unsigned long                    GetNumIntAttributes()    const { return m_numIntAttributes  ;}
63
0
        const Real *                     GetCoordMin   () const { return m_coordMin;}
64
0
        const Real *                     GetCoordMax   () const { return m_coordMax;}
65
0
        const Real *                     GetNormalMin  () const { return m_normalMin;}
66
0
        const Real *                     GetNormalMax  () const { return m_normalMax;}
67
0
        Real                             GetCoordMin   (int j)  const { return m_coordMin[j]       ;}
68
0
        Real                             GetCoordMax   (int j)  const { return m_coordMax[j]       ;}
69
0
        Real                             GetNormalMin  (int j)  const { return m_normalMin[j]      ;}
70
0
        Real                             GetNormalMax  (int j)  const { return m_normalMax[j]      ;}
71
72
        O3DGCIFSFloatAttributeType       GetFloatAttributeType(unsigned long a) const
73
0
                                         { 
74
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES);
75
0
                                             return m_typeFloatAttribute[a];
76
0
                                         }
77
        O3DGCIFSIntAttributeType         GetIntAttributeType(unsigned long a) const
78
0
                                         { 
79
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES);
80
0
                                             return m_typeIntAttribute[a];
81
0
                                         }
82
        unsigned long                    GetFloatAttributeDim(unsigned long a) const
83
0
                                         { 
84
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES);
85
0
                                             return m_dimFloatAttribute[a];
86
0
                                         }
87
        unsigned long                    GetIntAttributeDim(unsigned long a) const
88
0
                                         { 
89
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES);
90
0
                                             return m_dimIntAttribute[a];
91
0
                                         }
92
        const Real *                     GetFloatAttributeMin(unsigned long a) const
93
0
                                         { 
94
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES);
95
0
                                             return &(m_minFloatAttribute[a * O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES]);
96
0
                                         }
97
        const Real *                     GetFloatAttributeMax(unsigned long a) const
98
0
                                         { 
99
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES);
100
0
                                             return &(m_maxFloatAttribute[a * O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES]);
101
0
                                         }
102
        Real                             GetFloatAttributeMin(unsigned long a, unsigned long dim) const
103
0
                                         { 
104
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES);
105
0
                                             assert(dim < O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES);
106
0
                                             return m_minFloatAttribute[a * O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES + dim];
107
0
                                         }
108
        Real                             GetFloatAttributeMax(unsigned long a, unsigned long dim) const
109
0
                                         { 
110
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES);
111
0
                                             assert(dim < O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES);
112
0
                                             return m_maxFloatAttribute[a * O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES + dim];
113
0
                                         }
114
0
        Real                             GetCreaseAngle()      const { return m_creaseAngle     ;}
115
0
        bool                             GetCCW()              const { return m_ccw             ;}
116
0
        bool                             GetSolid()            const { return m_solid           ;}
117
0
        bool                             GetConvex()           const { return m_convex          ;}
118
0
        bool                             GetIsTriangularMesh() const { return m_isTriangularMesh;}
119
0
        const unsigned long *            GetIndexBufferID()    const { return m_indexBufferID   ;}
120
0
        const T *                        GetCoordIndex()       const { return m_coordIndex;}
121
0
        T *                              GetCoordIndex()             { return m_coordIndex;}
122
0
        Real *                           GetCoord()            const { return m_coord     ;}
123
0
        Real *                           GetNormal()           const { return m_normal    ;}
124
        Real *                           GetFloatAttribute(unsigned long a)  const
125
0
                                         {
126
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES);
127
0
                                             return m_floatAttribute[a];
128
0
                                         }
129
        long *                           GetIntAttribute(unsigned long a)   const
130
0
                                         {
131
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES);
132
0
                                             return m_intAttribute[a]  ;
133
0
                                         }
134
        // only coordIndex is supported
135
0
        void                             SetNNormalIndex(unsigned long)      {}
136
        void                             SetNTexCoordIndex(unsigned long)    {}
137
0
        void                             SetNFloatAttributeIndex(int, unsigned long) {}
138
0
        void                             SetNIntAttributeIndex (int, unsigned long) {}
139
        // per triangle attributes not supported
140
0
        void                             SetNormalPerVertex(bool)   {} 
141
        void                             SetColorPerVertex(bool)    {}
142
0
        void                             SetFloatAttributePerVertex(int, bool){}
143
0
        void                             SetIntAttributePerVertex  (int, bool){}
144
0
        void                             SetNCoordIndex     (unsigned long nCoordIndex)     { m_nCoordIndex = nCoordIndex;}
145
0
        void                             SetNCoord          (unsigned long nCoord)          { m_nCoord      = nCoord     ;}
146
0
        void                             SetNNormal         (unsigned long nNormal)         { m_nNormal     = nNormal    ;}
147
        void                             SetNumFloatAttributes(unsigned long numFloatAttributes) 
148
0
                                         { 
149
0
                                             assert(numFloatAttributes < O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES);
150
0
                                             m_numFloatAttributes = numFloatAttributes;
151
0
                                         }
152
        void                             SetNumIntAttributes  (unsigned long numIntAttributes)
153
0
                                         { 
154
0
                                             assert(numIntAttributes < O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES);
155
0
                                             m_numIntAttributes = numIntAttributes;
156
0
                                         }
157
0
        void                             SetCreaseAngle      (Real creaseAngle)      { m_creaseAngle      = creaseAngle     ;}
158
0
        void                             SetCCW              (bool ccw)              { m_ccw              = ccw             ;}
159
0
        void                             SetSolid            (bool solid)            { m_solid            = solid           ;}
160
0
        void                             SetConvex           (bool convex)           { m_convex           = convex          ;}
161
0
        void                             SetIsTriangularMesh (bool isTriangularMesh) { m_isTriangularMesh = isTriangularMesh;}
162
0
        void                             SetCoordMin        (int j, Real min) { m_coordMin[j]    = min;}
163
0
        void                             SetCoordMax        (int j, Real max) { m_coordMax[j]    = max;}
164
0
        void                             SetNormalMin       (int j, Real min) { m_normalMin[j]   = min;}
165
0
        void                             SetNormalMax       (int j, Real max) { m_normalMax[j]   = max;}
166
        void                             SetNFloatAttribute(unsigned long a, unsigned long nFloatAttribute) 
167
0
                                         { 
168
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES);
169
0
                                             m_nFloatAttribute[a] = nFloatAttribute;
170
0
                                         }
171
        void                             SetNIntAttribute(unsigned long a, unsigned long nIntAttribute) 
172
0
                                         { 
173
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES);
174
0
                                             m_nIntAttribute[a] = nIntAttribute;
175
0
                                         }
176
        void                             SetFloatAttributeDim(unsigned long a, unsigned long d)
177
0
                                         { 
178
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES);
179
0
                                             m_dimFloatAttribute[a] = d;
180
0
                                         }
181
        void                             SetIntAttributeDim(unsigned long a, unsigned long d)
182
0
                                         { 
183
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES);
184
0
                                             m_dimIntAttribute[a] = d;
185
0
                                         }
186
        void                             SetFloatAttributeType(unsigned long a, O3DGCIFSFloatAttributeType t)
187
0
                                         { 
188
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES);
189
0
                                             m_typeFloatAttribute[a] = t;
190
0
                                         }
191
        void                             SetIntAttributeType(unsigned long a, O3DGCIFSIntAttributeType t)
192
0
                                         { 
193
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES);
194
0
                                             m_typeIntAttribute[a] = t;
195
0
                                         }
196
        void                             SetFloatAttributeMin(unsigned long a, unsigned long dim, Real min) 
197
0
                                         { 
198
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES);
199
0
                                             assert(dim < O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES);
200
0
                                             m_minFloatAttribute[a * O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES + dim] = min;
201
0
                                         }
202
        void                             SetFloatAttributeMax(unsigned long a, unsigned long dim, Real max) 
203
0
                                         { 
204
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES);
205
0
                                             assert(dim < O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES);
206
0
                                             m_maxFloatAttribute[a * O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES + dim] = max;
207
0
                                         }
208
        void                             SetIndexBufferID  (unsigned long * const indexBufferID) { m_indexBufferID = indexBufferID;}
209
0
        void                             SetCoordIndex     (T * const coordIndex)    { m_coordIndex = coordIndex;}
210
0
        void                             SetCoord          (Real * const coord     ) { m_coord      = coord    ;}
211
0
        void                             SetNormal         (Real * const normal    ) { m_normal     = normal   ;}
212
        void                             SetFloatAttribute (unsigned long a, Real * const floatAttribute) 
213
0
                                         {
214
0
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES);
215
0
                                             m_floatAttribute[a] = floatAttribute;
216
0
                                         }
217
        void                             SetIntAttribute   (unsigned long a, long * const intAttribute)
218
                                         {
219
                                             assert(a < O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES);
220
                                             m_intAttribute[a] = intAttribute ;
221
                                         }
222
        void                             ComputeMinMax(O3DGCSC3DMCQuantizationMode quantMode);
223
224
    private:
225
        // triangles list
226
        unsigned long                    m_nCoordIndex;
227
        T *                              m_coordIndex;
228
        unsigned long *                  m_indexBufferID;
229
        // coord, normals, texcoord and color
230
        unsigned long                    m_nCoord;
231
        unsigned long                    m_nNormal;
232
        Real                             m_coordMin   [3];
233
        Real                             m_coordMax   [3];
234
        Real                             m_normalMin  [3];
235
        Real                             m_normalMax  [3];
236
        Real *                           m_coord;
237
        Real *                           m_normal;
238
        // other attributes
239
        unsigned long                    m_numFloatAttributes;
240
        unsigned long                    m_numIntAttributes;
241
        O3DGCIFSFloatAttributeType       m_typeFloatAttribute [O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES];
242
        O3DGCIFSIntAttributeType         m_typeIntAttribute   [O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES  ];
243
        unsigned long                    m_nFloatAttribute    [O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES];
244
        unsigned long                    m_nIntAttribute      [O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES  ];
245
        unsigned long                    m_dimFloatAttribute  [O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES];
246
        unsigned long                    m_dimIntAttribute    [O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES  ];
247
        Real                             m_minFloatAttribute  [O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES * O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES];
248
        Real                             m_maxFloatAttribute  [O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES * O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES];
249
        Real *                           m_floatAttribute     [O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES];
250
        long *                           m_intAttribute       [O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES];
251
        // mesh info                     
252
        Real                             m_creaseAngle;
253
        bool                             m_ccw;
254
        bool                             m_solid;
255
        bool                             m_convex;
256
        bool                             m_isTriangularMesh;
257
    };
258
}
259
#include "o3dgcIndexedFaceSet.inl"    // template implementation
260
#endif // O3DGC_INDEXED_FACE_SET_H