Coverage Report

Created: 2025-12-05 06:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/assimp/code/PostProcessing/SplitLargeMeshes.h
Line
Count
Source
1
/*
2
Open Asset Import Library (assimp)
3
----------------------------------------------------------------------
4
5
Copyright (c) 2006-2025, assimp team
6
7
All rights reserved.
8
9
Redistribution and use of this software in source and binary forms,
10
with or without modification, are permitted provided that the
11
following conditions are met:
12
13
* Redistributions of source code must retain the above
14
  copyright notice, this list of conditions and the
15
  following disclaimer.
16
17
* Redistributions in binary form must reproduce the above
18
  copyright notice, this list of conditions and the
19
  following disclaimer in the documentation and/or other
20
  materials provided with the distribution.
21
22
* Neither the name of the assimp team, nor the names of its
23
  contributors may be used to endorse or promote products
24
  derived from this software without specific prior
25
  written permission of the assimp team.
26
27
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
39
----------------------------------------------------------------------
40
*/
41
42
/** @file Defines a post processing step to split large meshes into sub-meshes
43
 */
44
#ifndef AI_SPLITLARGEMESHES_H_INC
45
#define AI_SPLITLARGEMESHES_H_INC
46
47
#include <vector>
48
#include "Common/BaseProcess.h"
49
50
#include <assimp/mesh.h>
51
#include <assimp/scene.h>
52
53
// Forward declarations
54
class SplitLargeMeshesTest;
55
56
namespace Assimp {
57
58
class SplitLargeMeshesProcess_Triangle;
59
class SplitLargeMeshesProcess_Vertex;
60
61
// NOTE: If you change these limits, don't forget to change the
62
// corresponding values in all Assimp ports
63
64
// **********************************************************
65
// Java: ConfigProperty.java,
66
//  ConfigProperty.DEFAULT_VERTEX_SPLIT_LIMIT
67
//  ConfigProperty.DEFAULT_TRIANGLE_SPLIT_LIMIT
68
// **********************************************************
69
70
// default limit for vertices
71
#if (!defined AI_SLM_DEFAULT_MAX_VERTICES)
72
#   define AI_SLM_DEFAULT_MAX_VERTICES      1000000
73
#endif
74
75
// default limit for triangles
76
#if (!defined AI_SLM_DEFAULT_MAX_TRIANGLES)
77
#   define AI_SLM_DEFAULT_MAX_TRIANGLES     1000000
78
#endif
79
80
// ---------------------------------------------------------------------------
81
/** Post-processing filter to split large meshes into sub-meshes
82
 *
83
 * Applied BEFORE the JoinVertices-Step occurs.
84
 * Returns NON-UNIQUE vertices, splits by triangle number.
85
*/
86
class ASSIMP_API SplitLargeMeshesProcess_Triangle : public BaseProcess {
87
    friend class SplitLargeMeshesProcess_Vertex;
88
89
public:
90
    // -------------------------------------------------------------------
91
    /// The default class constructor / destructor.
92
    SplitLargeMeshesProcess_Triangle();
93
    ~SplitLargeMeshesProcess_Triangle() override = default;
94
95
    // -------------------------------------------------------------------
96
    /** Returns whether the processing step is present in the given flag.
97
    * @param pFlags The processing flags the importer was called with. A
98
    *   bitwise combination of #aiPostProcessSteps.
99
    * @return true if the process is present in this flag fields,
100
    *   false if not.
101
    */
102
    bool IsActive( unsigned int pFlags) const override;
103
104
    // -------------------------------------------------------------------
105
    /** Called prior to ExecuteOnScene().
106
    * The function is a request to the process to update its configuration
107
    * basing on the Importer's configuration property list.
108
    */
109
    void SetupProperties(const Importer* pImp) override;
110
111
    //! Set the split limit - needed for unit testing
112
    inline void SetLimit(unsigned int l)
113
0
        {LIMIT = l;}
114
115
    //! Get the split limit
116
    inline unsigned int GetLimit() const
117
0
        {return LIMIT;}
118
119
    // -------------------------------------------------------------------
120
    /** Executes the post processing step on the given imported data.
121
    * At the moment a process is not supposed to fail.
122
    * @param pScene The imported data to work at.
123
    */
124
    void Execute( aiScene* pScene) override;
125
126
    // -------------------------------------------------------------------
127
    //! Apply the algorithm to a given mesh
128
    void SplitMesh (unsigned int a, aiMesh* pcMesh,
129
        std::vector<std::pair<aiMesh*, unsigned int> >& avList);
130
131
    // -------------------------------------------------------------------
132
    //! Update a node in the asset after a few of its meshes
133
    //! have been split
134
    static void UpdateNode(aiNode* pcNode,
135
        const std::vector<std::pair<aiMesh*, unsigned int> >& avList);
136
137
public:
138
    //! Triangle limit
139
    unsigned int LIMIT;
140
};
141
142
// ---------------------------------------------------------------------------
143
/** Post-processing filter to split large meshes into sub-meshes
144
 *
145
 * Applied AFTER the JoinVertices-Step occurs.
146
 * Returns UNIQUE vertices, splits by vertex number.
147
*/
148
class ASSIMP_API SplitLargeMeshesProcess_Vertex : public BaseProcess {
149
public:
150
    SplitLargeMeshesProcess_Vertex();
151
    ~SplitLargeMeshesProcess_Vertex() override = default;
152
153
    // -------------------------------------------------------------------
154
    /** Returns whether the processing step is present in the given flag field.
155
    * @param pFlags The processing flags the importer was called with. A bitwise
156
    *   combination of #aiPostProcessSteps.
157
    * @return true if the process is present in this flag fields, false if not.
158
    */
159
    bool IsActive( unsigned int pFlags) const override;
160
161
    // -------------------------------------------------------------------
162
    /** Called prior to ExecuteOnScene().
163
    * The function is a request to the process to update its configuration
164
    * basing on the Importer's configuration property list.
165
    */
166
    void SetupProperties(const Importer* pImp) override;
167
168
    //! Set the split limit - needed for unit testing
169
    inline void SetLimit(unsigned int l)
170
0
        {LIMIT = l;}
171
172
    //! Get the split limit
173
    inline unsigned int GetLimit() const
174
0
        {return LIMIT;}
175
176
    // -------------------------------------------------------------------
177
    /** Executes the post processing step on the given imported data.
178
    * At the moment a process is not supposed to fail.
179
    * @param pScene The imported data to work at.
180
    */
181
    void Execute( aiScene* pScene) override;
182
183
    // -------------------------------------------------------------------
184
    //! Apply the algorithm to a given mesh
185
    void SplitMesh (unsigned int a, aiMesh* pcMesh,
186
        std::vector<std::pair<aiMesh*, unsigned int> >& avList);
187
188
    // NOTE: Reuse SplitLargeMeshesProcess_Triangle::UpdateNode()
189
190
public:
191
    //! Triangle limit
192
    unsigned int LIMIT;
193
};
194
195
} // end of namespace Assimp
196
197
#endif // !!AI_SPLITLARGEMESHES_H_INC