Coverage Report

Created: 2026-04-01 06:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/assimp/code/Common/VertexTriangleAdjacency.h
Line
Count
Source
1
/*
2
Open Asset Import Library (assimp)
3
----------------------------------------------------------------------
4
5
Copyright (c) 2006-2026, 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 helper class to compute a vertex-triangle adjacency map */
43
#ifndef AI_VTADJACENCY_H_INC
44
#define AI_VTADJACENCY_H_INC
45
46
#include "BaseProcess.h"
47
#include <assimp/types.h>
48
#include <assimp/ai_assert.h>
49
50
struct aiMesh;
51
struct aiFace;
52
53
namespace Assimp {
54
55
// --------------------------------------------------------------------------------------------
56
/** @brief The VertexTriangleAdjacency class computes a vertex-triangle
57
 *  adjacency map from a given index buffer.
58
 *
59
 *  @note Although it is called #VertexTriangleAdjacency, the current version does also
60
 *    support arbitrary polygons. */
61
// --------------------------------------------------------------------------------------------
62
class ASSIMP_API VertexTriangleAdjacency {
63
public:
64
    // ----------------------------------------------------------------------------
65
    /** @brief Construction from an existing index buffer
66
     *  @param pcFaces Index buffer
67
     *  @param iNumFaces Number of faces in the buffer
68
     *  @param iNumVertices Number of referenced vertices. This value
69
     *    is computed automatically if 0 is specified.
70
     *  @param bComputeNumTriangles If you want the class to compute
71
     *    a list containing the number of referenced triangles per vertex
72
     *    per vertex - pass true.  */
73
    VertexTriangleAdjacency(aiFace* pcFaces,unsigned int iNumFaces,
74
        unsigned int iNumVertices = 0,
75
        bool bComputeNumTriangles = true);
76
77
    // ----------------------------------------------------------------------------
78
    /** @brief Destructor */
79
    ~VertexTriangleAdjacency();
80
81
    // ----------------------------------------------------------------------------
82
    /** @brief Get all triangles adjacent to a vertex
83
     *  @param iVertIndex Index of the vertex
84
     *  @return A pointer to the adjacency list. */
85
230k
    unsigned int* GetAdjacentTriangles(unsigned int iVertIndex) const {
86
230k
        ai_assert(iVertIndex < mNumVertices);
87
230k
        return &mAdjacencyTable[ mOffsetTable[iVertIndex]];
88
230k
    }
89
90
    // ----------------------------------------------------------------------------
91
    /** @brief Get the number of triangles that are referenced by
92
     *    a vertex. This function returns a reference that can be modified
93
     *  @param iVertIndex Index of the vertex
94
     *  @return Number of referenced triangles */
95
0
    unsigned int& GetNumTrianglesPtr(unsigned int iVertIndex) {
96
0
        ai_assert( iVertIndex < mNumVertices );
97
0
        ai_assert( nullptr != mLiveTriangles );
98
0
        return mLiveTriangles[iVertIndex];
99
0
    }
100
101
    //! Offset table
102
    unsigned int* mOffsetTable;
103
104
    //! Adjacency table
105
    unsigned int* mAdjacencyTable;
106
107
    //! Table containing the number of referenced triangles per vertex
108
    unsigned int* mLiveTriangles;
109
110
    //! Debug: Number of referenced vertices
111
    unsigned int mNumVertices;
112
};
113
114
} //! ns Assimp
115
116
#endif // !! AI_VTADJACENCY_H_INC