vrshoot

view libs/assimp/VertexTriangleAdjacency.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 helper class to compute a vertex-triangle adjacency map */
42 #ifndef AI_VTADJACENCY_H_INC
43 #define AI_VTADJACENCY_H_INC
45 #include "BaseProcess.h"
46 #include "assimp/types.h"
47 #include "assimp/ai_assert.h"
49 struct aiMesh;
50 namespace Assimp {
52 // --------------------------------------------------------------------------------------------
53 /** @brief The VertexTriangleAdjacency class computes a vertex-triangle
54 * adjacency map from a given index buffer.
55 *
56 * @note Although it is called #VertexTriangleAdjacency, the current version does also
57 * support arbitrary polygons. */
58 // --------------------------------------------------------------------------------------------
59 class VertexTriangleAdjacency
60 {
61 public:
63 // ----------------------------------------------------------------------------
64 /** @brief Construction from an existing index buffer
65 * @param pcFaces Index buffer
66 * @param iNumFaces Number of faces in the buffer
67 * @param iNumVertices Number of referenced vertices. This value
68 * is computed automatically if 0 is specified.
69 * @param bComputeNumTriangles If you want the class to compute
70 * a list containing the number of referenced triangles per vertex
71 * per vertex - pass true. */
72 VertexTriangleAdjacency(aiFace* pcFaces,unsigned int iNumFaces,
73 unsigned int iNumVertices = 0,
74 bool bComputeNumTriangles = true);
77 // ----------------------------------------------------------------------------
78 /** @brief Destructor */
79 ~VertexTriangleAdjacency();
82 public:
84 // ----------------------------------------------------------------------------
85 /** @brief Get all triangles adjacent to a vertex
86 * @param iVertIndex Index of the vertex
87 * @return A pointer to the adjacency list. */
88 unsigned int* GetAdjacentTriangles(unsigned int iVertIndex) const
89 {
90 ai_assert(iVertIndex < iNumVertices);
91 return &mAdjacencyTable[ mOffsetTable[iVertIndex]];
92 }
95 // ----------------------------------------------------------------------------
96 /** @brief Get the number of triangles that are referenced by
97 * a vertex. This function returns a reference that can be modified
98 * @param iVertIndex Index of the vertex
99 * @return Number of referenced triangles */
100 unsigned int& GetNumTrianglesPtr(unsigned int iVertIndex)
101 {
102 ai_assert(iVertIndex < iNumVertices && NULL != mLiveTriangles);
103 return mLiveTriangles[iVertIndex];
104 }
107 public:
109 //! Offset table
110 unsigned int* mOffsetTable;
112 //! Adjacency table
113 unsigned int* mAdjacencyTable;
115 //! Table containing the number of referenced triangles per vertex
116 unsigned int* mLiveTriangles;
118 //! Debug: Number of referenced vertices
119 unsigned int iNumVertices;
121 };
122 }
124 #endif // !! AI_VTADJACENCY_H_INC