Coverage Report

Created: 2026-01-07 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/assimp/code/Common/ImporterRegistry.cpp
Line
Count
Source
1
/*
2
---------------------------------------------------------------------------
3
Open Asset Import Library (assimp)
4
---------------------------------------------------------------------------
5
6
Copyright (c) 2006-2025, assimp team
7
8
All rights reserved.
9
10
Redistribution and use of this software in source and binary forms,
11
with or without modification, are permitted provided that the following
12
conditions are met:
13
14
* Redistributions of source code must retain the above
15
  copyright notice, this list of conditions and the
16
  following disclaimer.
17
18
* Redistributions in binary form must reproduce the above
19
  copyright notice, this list of conditions and the
20
  following disclaimer in the documentation and/or other
21
  materials provided with the distribution.
22
23
* Neither the name of the assimp team, nor the names of its
24
  contributors may be used to endorse or promote products
25
  derived from this software without specific prior
26
  written permission of the assimp team.
27
28
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
---------------------------------------------------------------------------
40
*/
41
42
/** @file ImporterRegistry.cpp
43
44
Central registry for all importers available. Do not edit this file
45
directly (unless you are adding new loaders), instead use the
46
corresponding preprocessor flag to selectively disable formats.
47
*/
48
49
#include <assimp/anim.h>
50
#include <assimp/BaseImporter.h>
51
#include <vector>
52
#include <cstdlib>
53
54
// ------------------------------------------------------------------------------------------------
55
// Importers
56
// (include_new_importers_here)
57
// ------------------------------------------------------------------------------------------------
58
#if !defined(ASSIMP_BUILD_NO_USD_IMPORTER)
59
#include "AssetLib/USD/USDLoader.h"
60
#endif
61
#ifndef ASSIMP_BUILD_NO_X_IMPORTER
62
#include "AssetLib/X/XFileImporter.h"
63
#endif
64
#ifndef ASSIMP_BUILD_NO_AMF_IMPORTER
65
#include "AssetLib/AMF/AMFImporter.hpp"
66
#endif
67
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
68
#include "AssetLib/3DS/3DSLoader.h"
69
#endif
70
#ifndef ASSIMP_BUILD_NO_MD3_IMPORTER
71
#include "AssetLib/MD3/MD3Loader.h"
72
#endif
73
#ifndef ASSIMP_BUILD_NO_MDL_IMPORTER
74
#include "AssetLib/MDL/MDLLoader.h"
75
#endif
76
#ifndef ASSIMP_BUILD_NO_MD2_IMPORTER
77
#include "AssetLib/MD2/MD2Loader.h"
78
#endif
79
#ifndef ASSIMP_BUILD_NO_PLY_IMPORTER
80
#include "AssetLib/Ply/PlyLoader.h"
81
#endif
82
#ifndef ASSIMP_BUILD_NO_ASE_IMPORTER
83
#include "AssetLib/ASE/ASELoader.h"
84
#endif
85
#ifndef ASSIMP_BUILD_NO_OBJ_IMPORTER
86
#include "AssetLib/Obj/ObjFileImporter.h"
87
#endif
88
#ifndef ASSIMP_BUILD_NO_HMP_IMPORTER
89
#include "AssetLib/HMP/HMPLoader.h"
90
#endif
91
#ifndef ASSIMP_BUILD_NO_SMD_IMPORTER
92
#include "AssetLib/SMD/SMDLoader.h"
93
#endif
94
#ifndef ASSIMP_BUILD_NO_MDC_IMPORTER
95
#include "AssetLib/MDC/MDCLoader.h"
96
#endif
97
#ifndef ASSIMP_BUILD_NO_MD5_IMPORTER
98
#include "AssetLib/MD5/MD5Loader.h"
99
#endif
100
#ifndef ASSIMP_BUILD_NO_STL_IMPORTER
101
#include "AssetLib/STL/STLLoader.h"
102
#endif
103
#ifndef ASSIMP_BUILD_NO_LWO_IMPORTER
104
#include "AssetLib/LWO/LWOLoader.h"
105
#endif
106
#ifndef ASSIMP_BUILD_NO_DXF_IMPORTER
107
#include "AssetLib/DXF/DXFLoader.h"
108
#endif
109
#ifndef ASSIMP_BUILD_NO_NFF_IMPORTER
110
#include "AssetLib/NFF/NFFLoader.h"
111
#endif
112
#ifndef ASSIMP_BUILD_NO_RAW_IMPORTER
113
#include "AssetLib/Raw/RawLoader.h"
114
#endif
115
#ifndef ASSIMP_BUILD_NO_SIB_IMPORTER
116
#include "AssetLib/SIB/SIBImporter.h"
117
#endif
118
#ifndef ASSIMP_BUILD_NO_OFF_IMPORTER
119
#include "AssetLib/OFF/OFFLoader.h"
120
#endif
121
#ifndef ASSIMP_BUILD_NO_AC_IMPORTER
122
#include "AssetLib/AC/ACLoader.h"
123
#endif
124
#ifndef ASSIMP_BUILD_NO_BVH_IMPORTER
125
#include "AssetLib/BVH/BVHLoader.h"
126
#endif
127
#ifndef ASSIMP_BUILD_NO_IRRMESH_IMPORTER
128
#include "AssetLib/Irr/IRRMeshLoader.h"
129
#endif
130
#ifndef ASSIMP_BUILD_NO_IRR_IMPORTER
131
#include "AssetLib/Irr/IRRLoader.h"
132
#endif
133
#ifndef ASSIMP_BUILD_NO_Q3D_IMPORTER
134
#include "AssetLib/Q3D/Q3DLoader.h"
135
#endif
136
#ifndef ASSIMP_BUILD_NO_B3D_IMPORTER
137
#include "AssetLib/B3D/B3DImporter.h"
138
#endif
139
#ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER
140
#include "AssetLib/Collada/ColladaLoader.h"
141
#endif
142
#ifndef ASSIMP_BUILD_NO_TERRAGEN_IMPORTER
143
#include "AssetLib/Terragen/TerragenLoader.h"
144
#endif
145
#ifndef ASSIMP_BUILD_NO_CSM_IMPORTER
146
#include "AssetLib/CSM/CSMLoader.h"
147
#endif
148
#ifndef ASSIMP_BUILD_NO_3D_IMPORTER
149
#include "AssetLib/Unreal/UnrealLoader.h"
150
#endif
151
#ifndef ASSIMP_BUILD_NO_LWS_IMPORTER
152
#include "AssetLib/LWS/LWSLoader.h"
153
#endif
154
#ifndef ASSIMP_BUILD_NO_OGRE_IMPORTER
155
#include "AssetLib/Ogre/OgreImporter.h"
156
#endif
157
#ifndef ASSIMP_BUILD_NO_OPENGEX_IMPORTER
158
#include "AssetLib/OpenGEX/OpenGEXImporter.h"
159
#endif
160
#ifndef ASSIMP_BUILD_NO_MS3D_IMPORTER
161
#include "AssetLib/MS3D/MS3DLoader.h"
162
#endif
163
#ifndef ASSIMP_BUILD_NO_COB_IMPORTER
164
#include "AssetLib/COB/COBLoader.h"
165
#endif
166
#ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER
167
#include "AssetLib/Blender/BlenderLoader.h"
168
#endif
169
#ifndef ASSIMP_BUILD_NO_Q3BSP_IMPORTER
170
#include "AssetLib/Q3BSP/Q3BSPFileImporter.h"
171
#endif
172
#ifndef ASSIMP_BUILD_NO_NDO_IMPORTER
173
#include "AssetLib/NDO/NDOLoader.h"
174
#endif
175
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
176
#include "AssetLib/IFC/IFCLoader.h"
177
#endif
178
#ifndef ASSIMP_BUILD_NO_XGL_IMPORTER
179
#include "AssetLib/XGL/XGLLoader.h"
180
#endif
181
#ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
182
#include "AssetLib/FBX/FBXImporter.h"
183
#endif
184
#ifndef ASSIMP_BUILD_NO_ASSBIN_IMPORTER
185
#include "AssetLib/Assbin/AssbinLoader.h"
186
#endif
187
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF1_IMPORTER)
188
#include "AssetLib/glTF/glTFImporter.h"
189
#endif
190
#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_IMPORTER)
191
#include "AssetLib/glTF2/glTF2Importer.h"
192
#endif
193
#ifndef ASSIMP_BUILD_NO_C4D_IMPORTER
194
#include "AssetLib/C4D/C4DImporter.h"
195
#endif
196
#ifndef ASSIMP_BUILD_NO_3MF_IMPORTER
197
#include "AssetLib/3MF/D3MFImporter.h"
198
#endif
199
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
200
#include "AssetLib/X3D/X3DImporter.hpp"
201
#endif
202
#ifndef ASSIMP_BUILD_NO_MMD_IMPORTER
203
#include "AssetLib/MMD/MMDImporter.h"
204
#endif
205
#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
206
#include "AssetLib/M3D/M3DImporter.h"
207
#endif
208
#ifndef ASSIMP_BUILD_NO_IQM_IMPORTER
209
#include "AssetLib/IQM/IQMImporter.h"
210
#endif
211
212
namespace Assimp {
213
214
// ------------------------------------------------------------------------------------------------
215
327
void GetImporterInstanceList(std::vector<BaseImporter *> &out) {
216
217
    // Some importers may be unimplemented or otherwise unsuitable for general use
218
    // in their current state. Devs can set ASSIMP_ENABLE_DEV_IMPORTERS in their
219
    // local environment to enable them, otherwise they're left out of the registry.
220
#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
221
    // not supported under uwp
222
    const char *envStr = std::getenv("ASSIMP_ENABLE_DEV_IMPORTERS");
223
#else
224
327
    const char *envStr = { "0" };
225
327
#endif
226
327
    bool devImportersEnabled = envStr && strcmp(envStr, "0");
227
228
    // Ensure no unused var warnings if all uses are #ifndef'd away below:
229
327
    (void)devImportersEnabled;
230
231
    // ----------------------------------------------------------------------------
232
    // Add an instance of each worker class here
233
    // (register_new_importers_here)
234
    // ----------------------------------------------------------------------------
235
327
    out.reserve(64);
236
#if !defined(ASSIMP_BUILD_NO_USD_IMPORTER)
237
    out.push_back(new USDImporter());
238
#endif
239
327
#if (!defined ASSIMP_BUILD_NO_X_IMPORTER)
240
327
    out.push_back(new XFileImporter());
241
327
#endif
242
327
#if (!defined ASSIMP_BUILD_NO_OBJ_IMPORTER)
243
327
    out.push_back(new ObjFileImporter());
244
327
#endif
245
327
#ifndef ASSIMP_BUILD_NO_AMF_IMPORTER
246
327
    out.push_back(new AMFImporter());
247
327
#endif
248
327
#if (!defined ASSIMP_BUILD_NO_3DS_IMPORTER)
249
327
    out.push_back(new Discreet3DSImporter());
250
327
#endif
251
#if (!defined ASSIMP_BUILD_NO_M3D_IMPORTER)
252
    out.push_back(new M3DImporter());
253
#endif
254
327
#if (!defined ASSIMP_BUILD_NO_MD3_IMPORTER)
255
327
    out.push_back(new MD3Importer());
256
327
#endif
257
327
#if (!defined ASSIMP_BUILD_NO_MD2_IMPORTER)
258
327
    out.push_back(new MD2Importer());
259
327
#endif
260
327
#if (!defined ASSIMP_BUILD_NO_PLY_IMPORTER)
261
327
    out.push_back(new PLYImporter());
262
327
#endif
263
327
#if (!defined ASSIMP_BUILD_NO_MDL_IMPORTER)
264
327
    out.push_back(new MDLImporter());
265
327
#endif
266
327
#if (!defined ASSIMP_BUILD_NO_ASE_IMPORTER)
267
327
#if (!defined ASSIMP_BUILD_NO_3DS_IMPORTER)
268
327
    out.push_back(new ASEImporter());
269
327
#endif
270
327
#endif
271
327
#if (!defined ASSIMP_BUILD_NO_HMP_IMPORTER)
272
327
    out.push_back(new HMPImporter());
273
327
#endif
274
327
#if (!defined ASSIMP_BUILD_NO_SMD_IMPORTER)
275
327
    out.push_back(new SMDImporter());
276
327
#endif
277
327
#if (!defined ASSIMP_BUILD_NO_MDC_IMPORTER)
278
327
    out.push_back(new MDCImporter());
279
327
#endif
280
327
#if (!defined ASSIMP_BUILD_NO_MD5_IMPORTER)
281
327
    out.push_back(new MD5Importer());
282
327
#endif
283
327
#if (!defined ASSIMP_BUILD_NO_STL_IMPORTER)
284
327
    out.push_back(new STLImporter());
285
327
#endif
286
327
#if (!defined ASSIMP_BUILD_NO_LWO_IMPORTER)
287
327
    out.push_back(new LWOImporter());
288
327
#endif
289
327
#if (!defined ASSIMP_BUILD_NO_DXF_IMPORTER)
290
327
    out.push_back(new DXFImporter());
291
327
#endif
292
327
#if (!defined ASSIMP_BUILD_NO_NFF_IMPORTER)
293
327
    out.push_back(new NFFImporter());
294
327
#endif
295
327
#if (!defined ASSIMP_BUILD_NO_RAW_IMPORTER)
296
327
    out.push_back(new RAWImporter());
297
327
#endif
298
327
#if (!defined ASSIMP_BUILD_NO_SIB_IMPORTER)
299
327
    out.push_back(new SIBImporter());
300
327
#endif
301
327
#if (!defined ASSIMP_BUILD_NO_OFF_IMPORTER)
302
327
    out.push_back(new OFFImporter());
303
327
#endif
304
327
#if (!defined ASSIMP_BUILD_NO_AC_IMPORTER)
305
327
    out.push_back(new AC3DImporter());
306
327
#endif
307
327
#if (!defined ASSIMP_BUILD_NO_BVH_IMPORTER)
308
327
    out.push_back(new BVHLoader());
309
327
#endif
310
327
#if (!defined ASSIMP_BUILD_NO_IRRMESH_IMPORTER)
311
327
    out.push_back(new IRRMeshImporter());
312
327
#endif
313
327
#if (!defined ASSIMP_BUILD_NO_IRR_IMPORTER)
314
327
    out.push_back(new IRRImporter());
315
327
#endif
316
327
#if (!defined ASSIMP_BUILD_NO_Q3D_IMPORTER)
317
327
    out.push_back(new Q3DImporter());
318
327
#endif
319
327
#if (!defined ASSIMP_BUILD_NO_B3D_IMPORTER)
320
327
    out.push_back(new B3DImporter());
321
327
#endif
322
327
#if (!defined ASSIMP_BUILD_NO_COLLADA_IMPORTER)
323
327
    out.push_back(new ColladaLoader());
324
327
#endif
325
327
#if (!defined ASSIMP_BUILD_NO_TERRAGEN_IMPORTER)
326
327
    out.push_back(new TerragenImporter());
327
327
#endif
328
327
#if (!defined ASSIMP_BUILD_NO_CSM_IMPORTER)
329
327
    out.push_back(new CSMImporter());
330
327
#endif
331
327
#if (!defined ASSIMP_BUILD_NO_3D_IMPORTER)
332
327
    out.push_back(new UnrealImporter());
333
327
#endif
334
327
#if (!defined ASSIMP_BUILD_NO_LWS_IMPORTER)
335
327
    out.push_back(new LWSImporter());
336
327
#endif
337
327
#if (!defined ASSIMP_BUILD_NO_OGRE_IMPORTER)
338
327
    out.push_back(new Ogre::OgreImporter());
339
327
#endif
340
327
#if (!defined ASSIMP_BUILD_NO_OPENGEX_IMPORTER)
341
327
    out.push_back(new OpenGEX::OpenGEXImporter());
342
327
#endif
343
327
#if (!defined ASSIMP_BUILD_NO_MS3D_IMPORTER)
344
327
    out.push_back(new MS3DImporter());
345
327
#endif
346
327
#if (!defined ASSIMP_BUILD_NO_COB_IMPORTER)
347
327
    out.push_back(new COBImporter());
348
327
#endif
349
327
#if (!defined ASSIMP_BUILD_NO_BLEND_IMPORTER)
350
327
    out.push_back(new BlenderImporter());
351
327
#endif
352
327
#if (!defined ASSIMP_BUILD_NO_Q3BSP_IMPORTER)
353
327
    out.push_back(new Q3BSPFileImporter());
354
327
#endif
355
327
#if (!defined ASSIMP_BUILD_NO_NDO_IMPORTER)
356
327
    out.push_back(new NDOImporter());
357
327
#endif
358
327
#if (!defined ASSIMP_BUILD_NO_IFC_IMPORTER)
359
327
    out.push_back(new IFCImporter());
360
327
#endif
361
327
#if (!defined ASSIMP_BUILD_NO_XGL_IMPORTER)
362
327
    out.push_back(new XGLImporter());
363
327
#endif
364
327
#if (!defined ASSIMP_BUILD_NO_FBX_IMPORTER)
365
327
    out.push_back(new FBXImporter());
366
327
#endif
367
327
#if (!defined ASSIMP_BUILD_NO_ASSBIN_IMPORTER)
368
327
    out.push_back(new AssbinImporter());
369
327
#endif
370
327
#if (!defined ASSIMP_BUILD_NO_GLTF_IMPORTER && !defined ASSIMP_BUILD_NO_GLTF1_IMPORTER)
371
327
    out.push_back(new glTFImporter());
372
327
#endif
373
327
#if (!defined ASSIMP_BUILD_NO_GLTF_IMPORTER && !defined ASSIMP_BUILD_NO_GLTF2_IMPORTER)
374
327
    out.push_back(new glTF2Importer());
375
327
#endif
376
#if (!defined ASSIMP_BUILD_NO_C4D_IMPORTER)
377
    out.push_back(new C4DImporter());
378
#endif
379
327
#if (!defined ASSIMP_BUILD_NO_3MF_IMPORTER)
380
327
    out.push_back(new D3MFImporter());
381
327
#endif
382
327
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
383
327
    out.push_back(new X3DImporter());
384
327
#endif
385
327
#ifndef ASSIMP_BUILD_NO_MMD_IMPORTER
386
327
    out.push_back(new MMDImporter());
387
327
#endif
388
327
#ifndef ASSIMP_BUILD_NO_IQM_IMPORTER
389
327
    out.push_back(new IQMImporter());
390
327
#endif
391
327
}
392
393
/** will delete all registered importers. */
394
327
void DeleteImporterInstanceList(std::vector<BaseImporter *> &deleteList) {
395
16.0k
    for (size_t i = 0; i < deleteList.size(); ++i) {
396
15.6k
        delete deleteList[i];
397
15.6k
        deleteList[i] = nullptr;
398
15.6k
    } //for
399
327
}
400
401
} // namespace Assimp