Coverage Report

Created: 2025-08-26 06:41

/src/assimp/code/PostProcessing/PretransformVertices.h
Line
Count
Source (jump to first uncovered line)
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 PretransformVertices.h
43
 *  @brief Defines a post processing step to pretransform all
44
 *    vertices in the scenegraph
45
 */
46
#ifndef AI_PRETRANSFORMVERTICES_H_INC
47
#define AI_PRETRANSFORMVERTICES_H_INC
48
49
#include "Common/BaseProcess.h"
50
51
#include <assimp/mesh.h>
52
53
#include <list>
54
#include <vector>
55
56
// Forward declarations
57
struct aiNode;
58
59
class PretransformVerticesTest;
60
61
namespace Assimp {
62
63
// ---------------------------------------------------------------------------
64
/** The PretransformVertices pre-transforms all vertices in the node tree
65
 *  and removes the whole graph. The output is a list of meshes, one for
66
 *  each material.
67
*/
68
class ASSIMP_API PretransformVertices : public BaseProcess {
69
public:
70
    // -------------------------------------------------------------------
71
    /// The default class constructor / destructor.
72
  PretransformVertices();
73
  ~PretransformVertices() override = default;
74
75
  // -------------------------------------------------------------------
76
  // Check whether step is active
77
  bool IsActive(unsigned int pFlags) const override;
78
79
  // -------------------------------------------------------------------
80
  // Execute step on a given scene
81
  void Execute(aiScene *pScene) override;
82
83
  // -------------------------------------------------------------------
84
  // Setup import settings
85
  void SetupProperties(const Importer *pImp) override;
86
87
  // -------------------------------------------------------------------
88
  /** @brief Toggle the 'keep hierarchy' option
89
     *  @param keep    true for keep configuration.
90
     */
91
0
  void KeepHierarchy(bool keep) {
92
0
    mConfigKeepHierarchy = keep;
93
0
  }
94
95
  // -------------------------------------------------------------------
96
  /** @brief Check whether 'keep hierarchy' is currently enabled.
97
     *  @return ...
98
     */
99
0
  bool IsHierarchyKept() const {
100
0
    return mConfigKeepHierarchy;
101
0
  }
102
103
private:
104
  // -------------------------------------------------------------------
105
  // Count the number of nodes
106
  unsigned int CountNodes(const aiNode *pcNode) const;
107
108
  // -------------------------------------------------------------------
109
  // Get a bitwise combination identifying the vertex format of a mesh
110
  //unsigned int GetMeshVFormat(aiMesh *pcMesh) const;
111
112
  // -------------------------------------------------------------------
113
  // Count the number of vertices in the whole scene and a given
114
  // material index
115
  void CountVerticesAndFaces(const aiScene *pcScene, const aiNode *pcNode,
116
      unsigned int iMat,
117
      unsigned int iVFormat,
118
      unsigned int *piFaces,
119
      unsigned int *piVertices) const;
120
121
  // -------------------------------------------------------------------
122
  // Collect vertex/face data
123
  void CollectData(const aiScene *pcScene, const aiNode *pcNode,
124
      unsigned int iMat,
125
      unsigned int iVFormat,
126
      aiMesh *pcMeshOut,
127
      unsigned int aiCurrent[2],
128
      unsigned int *num_refs) const;
129
130
  // -------------------------------------------------------------------
131
  // Get a list of all vertex formats that occur for a given material
132
  // The output list contains duplicate elements
133
  /*void GetVFormatList(const aiScene *pcScene, unsigned int iMat,
134
      std::list<unsigned int> &aiOut) const;*/
135
136
  // -------------------------------------------------------------------
137
  // Compute the absolute transformation matrices of each node
138
  void ComputeAbsoluteTransform(aiNode *pcNode);
139
140
  // -------------------------------------------------------------------
141
  // Simple routine to build meshes in worldspace, no further optimization
142
  void BuildWCSMeshes(MeshArray &out, aiMesh **in,
143
      unsigned int numIn, aiNode *node) const;
144
145
  // -------------------------------------------------------------------
146
  // Apply the node transformation to a mesh
147
  void ApplyTransform(aiMesh *mesh, const aiMatrix4x4 &mat) const;
148
149
  // -------------------------------------------------------------------
150
  // Reset transformation matrices to identity
151
  void MakeIdentityTransform(aiNode *nd) const;
152
153
  // -------------------------------------------------------------------
154
  // Build reference counters for all meshes
155
  void BuildMeshRefCountArray(const aiNode *nd, unsigned int *refs) const;
156
157
  //! Configuration option: keep scene hierarchy as long as possible
158
  bool mConfigKeepHierarchy;
159
  bool mConfigNormalize;
160
  bool mConfigTransform;
161
  aiMatrix4x4 mConfigTransformation;
162
  bool mConfigPointCloud;
163
};
164
165
} // end of namespace Assimp
166
167
#endif // !!AI_GENFACENORMALPROCESS_H_INC