vrshoot

view libs/assimp/SplitLargeMeshes.h @ 0:b2f14e535253

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