1/*
2Open Asset Import Library (assimp)
3----------------------------------------------------------------------
4
5Copyright (c) 2006-2017, assimp team
6
7All rights reserved.
8
9Redistribution and use of this software in source and binary forms,
10with or without modification, are permitted provided that the
11following 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
27THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37OF 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 submeshes
43 */
44#ifndef AI_SPLITLARGEMESHES_H_INC
45#define AI_SPLITLARGEMESHES_H_INC
46
47#include <vector>
48#include "BaseProcess.h"
49
50#include <assimp/mesh.h>
51#include <assimp/scene.h>
52
53class SplitLargeMeshesTest;
54
55namespace Assimp
56{
57
58class SplitLargeMeshesProcess_Triangle;
59class 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*/
86class ASSIMP_API SplitLargeMeshesProcess_Triangle : public BaseProcess
87{
88 friend class SplitLargeMeshesProcess_Vertex;
89
90public:
91
92 SplitLargeMeshesProcess_Triangle();
93 ~SplitLargeMeshesProcess_Triangle();
94
95public:
96 // -------------------------------------------------------------------
97 /** Returns whether the processing step is present in the given flag.
98 * @param pFlags The processing flags the importer was called with. A
99 * bitwise combination of #aiPostProcessSteps.
100 * @return true if the process is present in this flag fields,
101 * false if not.
102 */
103 bool IsActive( unsigned int pFlags) const;
104
105
106 // -------------------------------------------------------------------
107 /** Called prior to ExecuteOnScene().
108 * The function is a request to the process to update its configuration
109 * basing on the Importer's configuration property list.
110 */
111 virtual void SetupProperties(const Importer* pImp);
112
113
114 //! Set the split limit - needed for unit testing
115 inline void SetLimit(unsigned int l)
116 {LIMIT = l;}
117
118 //! Get the split limit
119 inline unsigned int GetLimit() const
120 {return LIMIT;}
121
122public:
123
124 // -------------------------------------------------------------------
125 /** Executes the post processing step on the given imported data.
126 * At the moment a process is not supposed to fail.
127 * @param pScene The imported data to work at.
128 */
129 void Execute( aiScene* pScene);
130
131 // -------------------------------------------------------------------
132 //! Apply the algorithm to a given mesh
133 void SplitMesh (unsigned int a, aiMesh* pcMesh,
134 std::vector<std::pair<aiMesh*, unsigned int> >& avList);
135
136 // -------------------------------------------------------------------
137 //! Update a node in the asset after a few of its meshes
138 //! have been split
139 static void UpdateNode(aiNode* pcNode,
140 const std::vector<std::pair<aiMesh*, unsigned int> >& avList);
141
142public:
143 //! Triangle limit
144 unsigned int LIMIT;
145};
146
147
148// ---------------------------------------------------------------------------
149/** Post-processing filter to split large meshes into sub-meshes
150 *
151 * Applied AFTER the JoinVertices-Step occurs.
152 * Returns UNIQUE vertices, splits by vertex number.
153*/
154class ASSIMP_API SplitLargeMeshesProcess_Vertex : public BaseProcess
155{
156public:
157
158 SplitLargeMeshesProcess_Vertex();
159 ~SplitLargeMeshesProcess_Vertex();
160
161public:
162 // -------------------------------------------------------------------
163 /** Returns whether the processing step is present in the given flag field.
164 * @param pFlags The processing flags the importer was called with. A bitwise
165 * combination of #aiPostProcessSteps.
166 * @return true if the process is present in this flag fields, false if not.
167 */
168 bool IsActive( unsigned int pFlags) const;
169
170 // -------------------------------------------------------------------
171 /** Called prior to ExecuteOnScene().
172 * The function is a request to the process to update its configuration
173 * basing on the Importer's configuration property list.
174 */
175 virtual void SetupProperties(const Importer* pImp);
176
177
178 //! Set the split limit - needed for unit testing
179 inline void SetLimit(unsigned int l)
180 {LIMIT = l;}
181
182 //! Get the split limit
183 inline unsigned int GetLimit() const
184 {return LIMIT;}
185
186public:
187
188 // -------------------------------------------------------------------
189 /** Executes the post processing step on the given imported data.
190 * At the moment a process is not supposed to fail.
191 * @param pScene The imported data to work at.
192 */
193 void Execute( aiScene* pScene);
194
195 // -------------------------------------------------------------------
196 //! Apply the algorithm to a given mesh
197 void SplitMesh (unsigned int a, aiMesh* pcMesh,
198 std::vector<std::pair<aiMesh*, unsigned int> >& avList);
199
200 // NOTE: Reuse SplitLargeMeshesProcess_Triangle::UpdateNode()
201
202public:
203 //! Triangle limit
204 unsigned int LIMIT;
205};
206
207} // end of namespace Assimp
208
209#endif // !!AI_SPLITLARGEMESHES_H_INC
210