@@ -105,6 +105,7 @@ void HnMeshUtils::Triangulate(bool UseFaceVertexIndices,
105105
106106 // Count the number of triangles
107107 const size_t NumTriangles = GetNumTriangles ();
108+ VERIFY_EXPR (NumTriangles * 3 == GetTotalIndexCount (GET_TOTAL_INDEX_COUNT_FLAG_TRIANGLES));
108109
109110 // Triangulate faces
110111 TriangleIndices.reserve (NumTriangles);
@@ -296,6 +297,7 @@ pxr::VtIntArray HnMeshUtils::ComputeEdgeIndices(bool UseFaceVertexIndices, bool
296297 });
297298 VERIFY_EXPR (EdgeIndices.size () == NumEdges * 2 );
298299 }
300+ VERIFY_EXPR (EdgeIndices.size () == GetTotalIndexCount (UseLineStrip ? GET_TOTAL_INDEX_COUNT_FLAG_EDGES_STRIP : GET_TOTAL_INDEX_COUNT_FLAG_EDGES_LIST));
299301
300302 if (UseFaceVertexIndices)
301303 {
@@ -352,10 +354,38 @@ pxr::VtIntArray HnMeshUtils::ComputePointIndices(bool ConvertToFaceVarying) cons
352354 for (int i = 0 ; i < NumPoints; ++i)
353355 PointIndices[i] = i;
354356 }
357+ VERIFY_EXPR (PointIndices.size () == GetTotalIndexCount (GET_TOTAL_INDEX_COUNT_FLAG_POINTS));
355358
356359 return PointIndices;
357360}
358361
362+ size_t HnMeshUtils::GetTotalIndexCount (GET_TOTAL_INDEX_COUNT_FLAGS Flags) const
363+ {
364+ VERIFY ((Flags & (GET_TOTAL_INDEX_COUNT_FLAG_EDGES_LIST | GET_TOTAL_INDEX_COUNT_FLAG_EDGES_STRIP)) != (GET_TOTAL_INDEX_COUNT_FLAG_EDGES_LIST | GET_TOTAL_INDEX_COUNT_FLAG_EDGES_STRIP),
365+ " COUNT_EDGES_LIST and COUNT_EDGES_STRIP flags are mutually exclusive" );
366+
367+ size_t NumIndices = 0 ;
368+ if (Flags & GET_TOTAL_INDEX_COUNT_FLAG_TRIANGLES)
369+ {
370+ size_t NumTriangles = GetNumTriangles ();
371+ NumIndices += NumTriangles * 3 ;
372+ }
373+
374+ if (Flags & (GET_TOTAL_INDEX_COUNT_FLAG_EDGES_LIST | GET_TOTAL_INDEX_COUNT_FLAG_EDGES_STRIP))
375+ {
376+ size_t NumFaces = 0 ;
377+ size_t NumEdges = GetNumEdges (&NumFaces);
378+ NumIndices += (Flags & GET_TOTAL_INDEX_COUNT_FLAG_EDGES_STRIP) ? NumEdges + NumFaces * 2 : NumEdges * 2 ;
379+ }
380+
381+ if (Flags & GET_TOTAL_INDEX_COUNT_FLAG_POINTS)
382+ {
383+ NumIndices += m_Topology.GetNumPoints ();
384+ }
385+
386+ return NumIndices;
387+ }
388+
359389template <typename T>
360390pxr::VtValue ConvertVertexArrayToFaceVaryingArray (const pxr::VtIntArray& FaceVertexIndices, const pxr::VtArray<T>& VertexArray, size_t ValuesPerVertex)
361391{
0 commit comments