Coverage Report

Created: 2024-08-02 07:04

/src/assimp/code/Common/ImporterRegistry.cpp
Line
Count
Source
1
/*
2
---------------------------------------------------------------------------
3
Open Asset Import Library (assimp)
4
---------------------------------------------------------------------------
5
6
Copyright (c) 2006-2024, 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
33
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
33
    const char *envStr = { "0" };
225
33
#endif
226
33
    bool devImportersEnabled = envStr && strcmp(envStr, "0");
227
228
    // Ensure no unused var warnings if all uses are #ifndef'd away below:
229
33
    (void)devImportersEnabled;
230
231
    // ----------------------------------------------------------------------------
232
    // Add an instance of each worker class here
233
    // (register_new_importers_here)
234
    // ----------------------------------------------------------------------------
235
33
    out.reserve(64);
236
#if !defined(ASSIMP_BUILD_NO_USD_IMPORTER)
237
    out.push_back(new USDImporter());
238
#endif
239
33
#if (!defined ASSIMP_BUILD_NO_X_IMPORTER)
240
33
    out.push_back(new XFileImporter());
241
33
#endif
242
33
#if (!defined ASSIMP_BUILD_NO_OBJ_IMPORTER)
243
33
    out.push_back(new ObjFileImporter());
244
33
#endif
245
33
#ifndef ASSIMP_BUILD_NO_AMF_IMPORTER
246
33
    out.push_back(new AMFImporter());
247
33
#endif
248
33
#if (!defined ASSIMP_BUILD_NO_3DS_IMPORTER)
249
33
    out.push_back(new Discreet3DSImporter());
250
33
#endif
251
#if (!defined ASSIMP_BUILD_NO_M3D_IMPORTER)
252
    out.push_back(new M3DImporter());
253
#endif
254
33
#if (!defined ASSIMP_BUILD_NO_MD3_IMPORTER)
255
33
    out.push_back(new MD3Importer());
256
33
#endif
257
33
#if (!defined ASSIMP_BUILD_NO_MD2_IMPORTER)
258
33
    out.push_back(new MD2Importer());
259
33
#endif
260
33
#if (!defined ASSIMP_BUILD_NO_PLY_IMPORTER)
261
33
    out.push_back(new PLYImporter());
262
33
#endif
263
33
#if (!defined ASSIMP_BUILD_NO_MDL_IMPORTER)
264
33
    out.push_back(new MDLImporter());
265
33
#endif
266
33
#if (!defined ASSIMP_BUILD_NO_ASE_IMPORTER)
267
33
#if (!defined ASSIMP_BUILD_NO_3DS_IMPORTER)
268
33
    out.push_back(new ASEImporter());
269
33
#endif
270
33
#endif
271
33
#if (!defined ASSIMP_BUILD_NO_HMP_IMPORTER)
272
33
    out.push_back(new HMPImporter());
273
33
#endif
274
33
#if (!defined ASSIMP_BUILD_NO_SMD_IMPORTER)
275
33
    out.push_back(new SMDImporter());
276
33
#endif
277
33
#if (!defined ASSIMP_BUILD_NO_MDC_IMPORTER)
278
33
    out.push_back(new MDCImporter());
279
33
#endif
280
33
#if (!defined ASSIMP_BUILD_NO_MD5_IMPORTER)
281
33
    out.push_back(new MD5Importer());
282
33
#endif
283
33
#if (!defined ASSIMP_BUILD_NO_STL_IMPORTER)
284
33
    out.push_back(new STLImporter());
285
33
#endif
286
33
#if (!defined ASSIMP_BUILD_NO_LWO_IMPORTER)
287
33
    out.push_back(new LWOImporter());
288
33
#endif
289
33
#if (!defined ASSIMP_BUILD_NO_DXF_IMPORTER)
290
33
    out.push_back(new DXFImporter());
291
33
#endif
292
33
#if (!defined ASSIMP_BUILD_NO_NFF_IMPORTER)
293
33
    out.push_back(new NFFImporter());
294
33
#endif
295
33
#if (!defined ASSIMP_BUILD_NO_RAW_IMPORTER)
296
33
    out.push_back(new RAWImporter());
297
33
#endif
298
33
#if (!defined ASSIMP_BUILD_NO_SIB_IMPORTER)
299
33
    out.push_back(new SIBImporter());
300
33
#endif
301
33
#if (!defined ASSIMP_BUILD_NO_OFF_IMPORTER)
302
33
    out.push_back(new OFFImporter());
303
33
#endif
304
33
#if (!defined ASSIMP_BUILD_NO_AC_IMPORTER)
305
33
    out.push_back(new AC3DImporter());
306
33
#endif
307
33
#if (!defined ASSIMP_BUILD_NO_BVH_IMPORTER)
308
33
    out.push_back(new BVHLoader());
309
33
#endif
310
33
#if (!defined ASSIMP_BUILD_NO_IRRMESH_IMPORTER)
311
33
    out.push_back(new IRRMeshImporter());
312
33
#endif
313
33
#if (!defined ASSIMP_BUILD_NO_IRR_IMPORTER)
314
33
    out.push_back(new IRRImporter());
315
33
#endif
316
33
#if (!defined ASSIMP_BUILD_NO_Q3D_IMPORTER)
317
33
    out.push_back(new Q3DImporter());
318
33
#endif
319
33
#if (!defined ASSIMP_BUILD_NO_B3D_IMPORTER)
320
33
    out.push_back(new B3DImporter());
321
33
#endif
322
33
#if (!defined ASSIMP_BUILD_NO_COLLADA_IMPORTER)
323
33
    out.push_back(new ColladaLoader());
324
33
#endif
325
33
#if (!defined ASSIMP_BUILD_NO_TERRAGEN_IMPORTER)
326
33
    out.push_back(new TerragenImporter());
327
33
#endif
328
33
#if (!defined ASSIMP_BUILD_NO_CSM_IMPORTER)
329
33
    out.push_back(new CSMImporter());
330
33
#endif
331
33
#if (!defined ASSIMP_BUILD_NO_3D_IMPORTER)
332
33
    out.push_back(new UnrealImporter());
333
33
#endif
334
33
#if (!defined ASSIMP_BUILD_NO_LWS_IMPORTER)
335
33
    out.push_back(new LWSImporter());
336
33
#endif
337
33
#if (!defined ASSIMP_BUILD_NO_OGRE_IMPORTER)
338
33
    out.push_back(new Ogre::OgreImporter());
339
33
#endif
340
33
#if (!defined ASSIMP_BUILD_NO_OPENGEX_IMPORTER)
341
33
    out.push_back(new OpenGEX::OpenGEXImporter());
342
33
#endif
343
33
#if (!defined ASSIMP_BUILD_NO_MS3D_IMPORTER)
344
33
    out.push_back(new MS3DImporter());
345
33
#endif
346
33
#if (!defined ASSIMP_BUILD_NO_COB_IMPORTER)
347
33
    out.push_back(new COBImporter());
348
33
#endif
349
33
#if (!defined ASSIMP_BUILD_NO_BLEND_IMPORTER)
350
33
    out.push_back(new BlenderImporter());
351
33
#endif
352
33
#if (!defined ASSIMP_BUILD_NO_Q3BSP_IMPORTER)
353
33
    out.push_back(new Q3BSPFileImporter());
354
33
#endif
355
33
#if (!defined ASSIMP_BUILD_NO_NDO_IMPORTER)
356
33
    out.push_back(new NDOImporter());
357
33
#endif
358
33
#if (!defined ASSIMP_BUILD_NO_IFC_IMPORTER)
359
33
    out.push_back(new IFCImporter());
360
33
#endif
361
33
#if (!defined ASSIMP_BUILD_NO_XGL_IMPORTER)
362
33
    out.push_back(new XGLImporter());
363
33
#endif
364
33
#if (!defined ASSIMP_BUILD_NO_FBX_IMPORTER)
365
33
    out.push_back(new FBXImporter());
366
33
#endif
367
33
#if (!defined ASSIMP_BUILD_NO_ASSBIN_IMPORTER)
368
33
    out.push_back(new AssbinImporter());
369
33
#endif
370
33
#if (!defined ASSIMP_BUILD_NO_GLTF_IMPORTER && !defined ASSIMP_BUILD_NO_GLTF1_IMPORTER)
371
33
    out.push_back(new glTFImporter());
372
33
#endif
373
33
#if (!defined ASSIMP_BUILD_NO_GLTF_IMPORTER && !defined ASSIMP_BUILD_NO_GLTF2_IMPORTER)
374
33
    out.push_back(new glTF2Importer());
375
33
#endif
376
#if (!defined ASSIMP_BUILD_NO_C4D_IMPORTER)
377
    out.push_back(new C4DImporter());
378
#endif
379
33
#if (!defined ASSIMP_BUILD_NO_3MF_IMPORTER)
380
33
    out.push_back(new D3MFImporter());
381
33
#endif
382
33
#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
383
33
    out.push_back(new X3DImporter());
384
33
#endif
385
33
#ifndef ASSIMP_BUILD_NO_MMD_IMPORTER
386
33
    out.push_back(new MMDImporter());
387
33
#endif
388
33
#ifndef ASSIMP_BUILD_NO_IQM_IMPORTER
389
33
    out.push_back(new IQMImporter());
390
33
#endif
391
33
}
392
393
/** will delete all registered importers. */
394
33
void DeleteImporterInstanceList(std::vector<BaseImporter *> &deleteList) {
395
1.61k
    for (size_t i = 0; i < deleteList.size(); ++i) {
396
1.58k
        delete deleteList[i];
397
1.58k
        deleteList[i] = nullptr;
398
1.58k
    } //for
399
33
}
400
401
} // namespace Assimp