Main Page Class List Class Members

NvBlastExtAuthoringTriangulator.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed to you
2 // under a form of NVIDIA software license agreement provided separately to you.
3 //
4 // Notice
5 // NVIDIA Corporation and its licensors retain all intellectual property and
6 // proprietary rights in and to this software and related documentation and
7 // any modifications thereto. Any use, reproduction, disclosure, or
8 // distribution of this software and related documentation without an express
9 // license agreement from NVIDIA Corporation is strictly prohibited.
10 //
11 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
12 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
13 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
14 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // Information and code furnished is believed to be accurate and reliable.
17 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
18 // information or for any infringement of patents or other rights of third parties that may
19 // result from its use. No license is granted by implication or otherwise under any patent
20 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
21 // This code supersedes and replaces all information previously supplied.
22 // NVIDIA Corporation products are not authorized for use as critical
23 // components in life support devices or systems without express written approval of
24 // NVIDIA Corporation.
25 //
26 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
27
28
29 #ifndef NVBLASTEXTAUTHORINGTRIANGULATOR_H
30 #define NVBLASTEXTAUTHORINGTRIANGULATOR_H
31
32
33 #include <vector>
34 #include <map>
35 #include "NvBlastExtAuthoringTypes.h"
36 #include "NvBlastExtAuthoringMesh.h"
37 #include "NvBlastExtAuthoringInternalCommon.h"
38
39 namespace Nv
40 {
41 namespace Blast
42 {
43
44
48 class Triangulator
49 {
50 public:
55 void triangulate(const Mesh* mesh);
56
60 std::vector<Triangle>& getBaseMesh()
61 {
62 return mBaseMeshUVFittedTriangles;
63 }
64
65 std::vector<Triangle>& getBaseMeshNotFitted()
66 {
67 return mBaseMeshResultTriangles;
68 }
69
70
74 std::vector<TriangleIndexed>& getBaseMeshIndexed()
75 {
76 return mBaseMeshTriangles;
77 }
81 std::vector<uint32_t>& getBaseMapping()
82 {
83 return mBaseMapping;
84 };
88 std::vector<int32_t>& getPositionedMapping()
89 {
90 return mPositionMappedVrt;
91 };
95 uint32_t getWeldedVerticesCount()
96 {
97 return static_cast<uint32_t>(mVertices.size());
98 }
99
103 void reset();
104
105 int32_t& getParentChunkId() { return parentChunkId; };
106
107 private:
108
109 int32_t parentChunkId;
110
111 int32_t addVerticeIfNotExist(const Vertex& p);
112 void addEdgeIfValid(EdgeWithParent& ed);
113
114 /* Data used before triangulation to build polygon loops*/
115
116 std::vector<Vertex> mVertices;
117 std::vector<EdgeWithParent> mBaseMeshEdges;
118 std::map<Vertex, int32_t, VrtComp> mVertMap;
119 std::map<EdgeWithParent, int32_t, EdgeComparator> mEdgeMap;
120 std::vector<uint32_t> mBaseMapping;
121 std::vector<int32_t> mPositionMappedVrt;
122 /* ------------------------------------------------------------ */
123
124
128 void prepare(const Mesh* mesh);
129
130
131
132 void triangulatePolygonWithEarClipping(std::vector<uint32_t>& inputPolygon, Vertex* vert, ProjectionDirections dir);
133 void buildPolygonAndTriangulate(std::vector<Edge>& edges, Vertex* vertices, int32_t userData, int32_t materialId, int32_t smoothingGroup);
134 void computePositionedMapping();
135
136 std::vector<TriangleIndexed> mBaseMeshTriangles;
140 std::vector<Triangle> mBaseMeshResultTriangles;
141 std::vector<Triangle> mBaseMeshUVFittedTriangles;
142 };
143
144 } // namespace Blast
145 } // namespace Nv
146
147
148 #endif // ifndef NVBLASTEXTAUTHORINGTRIANGULATOR_H
Nv::Blast::ProjectionDirections
ProjectionDirections
Definition: NvBlastExtAuthoringInternalCommon.h:93
Nv::Blast::Triangulator::getPositionedMapping
std::vector< int32_t > & getPositionedMapping()
Definition: NvBlastExtAuthoringTriangulator.h:88
Nv::Blast::Triangulator::getBaseMeshNotFitted
std::vector< Triangle > & getBaseMeshNotFitted()
Definition: NvBlastExtAuthoringTriangulator.h:65
Nv::Blast::EdgeWithParent
Definition: NvBlastExtAuthoringInternalCommon.h:48
Nv::Blast::Triangulator::getBaseMapping
std::vector< uint32_t > & getBaseMapping()
Definition: NvBlastExtAuthoringTriangulator.h:81
NvBlastExtAuthoringTypes.h
Nv::Blast::Triangulator::getWeldedVerticesCount
uint32_t getWeldedVerticesCount()
Definition: NvBlastExtAuthoringTriangulator.h:95
Nv::Blast::Mesh
Definition: NvBlastExtAuthoringMesh.h:42
Nv::Blast::Triangulator::getParentChunkId
int32_t & getParentChunkId()
Definition: NvBlastExtAuthoringTriangulator.h:105
NvBlastExtAuthoringMesh.h
Nv::Blast::Triangulator::triangulate
void triangulate(const Mesh *mesh)
Nv::Blast::Triangulator::reset
void reset()
Nv::Blast::Triangulator::getBaseMeshIndexed
std::vector< TriangleIndexed > & getBaseMeshIndexed()
Definition: NvBlastExtAuthoringTriangulator.h:74
Nv::Blast::Triangulator
Definition: NvBlastExtAuthoringTriangulator.h:48
NvBlastExtAuthoringInternalCommon.h
Nv::Blast::Triangulator::getBaseMesh
std::vector< Triangle > & getBaseMesh()
Definition: NvBlastExtAuthoringTriangulator.h:60
Nv::Blast::Vertex
Definition: NvBlastExtAuthoringTypes.h:67
Nv
Definition: NvBlastArray.h:37