From 15725d28e8f417d25d16c73b7f4d098beba3cb4f Mon Sep 17 00:00:00 2001 From: manuelk Date: Tue, 11 Nov 2014 11:28:39 -0800 Subject: [PATCH] Fix VtrViewer to display Gregory patch basis (debugging) --- examples/vtrViewer/gl_mesh.cpp | 2 + examples/vtrViewer/hbr_refine.cpp | 4 +- examples/vtrViewer/vtrViewer.cpp | 84 ++++++++++++++++++------------- 3 files changed, 53 insertions(+), 37 deletions(-) diff --git a/examples/vtrViewer/gl_mesh.cpp b/examples/vtrViewer/gl_mesh.cpp index 9564276e..c29b7b0b 100644 --- a/examples/vtrViewer/gl_mesh.cpp +++ b/examples/vtrViewer/gl_mesh.cpp @@ -404,6 +404,7 @@ getNumEdges(int numCVs) { case 12: return 4; // case 16: return 24; case 16: return 4; + case 20: return 4; default: assert(0); } @@ -451,6 +452,7 @@ getEdgeList(int numCVs) { case 9: return edgeList9; break; case 12: return edgeList12; break; case 16: return edgeList16; break; + case 20: return edgeList4; break; default: assert(0); } diff --git a/examples/vtrViewer/hbr_refine.cpp b/examples/vtrViewer/hbr_refine.cpp index fedce4fb..1ffdfe22 100644 --- a/examples/vtrViewer/hbr_refine.cpp +++ b/examples/vtrViewer/hbr_refine.cpp @@ -458,7 +458,8 @@ private: B[NUM_TRANSITIONS][NUM_ROTATIONS], // boundary patch (4 rotations) C[NUM_TRANSITIONS][NUM_ROTATIONS], // corner patch (4 rotations) G, // gregory patch - GB; // gregory boundary patch + GB, // gregory boundary patch + GP; // gregory basis PatchTypes() { memset(this, 0, sizeof(PatchTypes)); } @@ -494,6 +495,7 @@ Far::PatchTablesFactory::PatchTypes::getValue( Far::PatchTables::Descripto case Far::PatchTables::CORNER : return C[desc.GetPattern()][desc.GetRotation()]; case Far::PatchTables::GREGORY : return G; case Far::PatchTables::GREGORY_BOUNDARY : return GB; + case Far::PatchTables::GREGORY_BASIS : return GP; default : assert(0); } // can't be reached (suppress compiler warning) diff --git a/examples/vtrViewer/vtrViewer.cpp b/examples/vtrViewer/vtrViewer.cpp index 50c68549..3ba38dbe 100644 --- a/examples/vtrViewer/vtrViewer.cpp +++ b/examples/vtrViewer/vtrViewer.cpp @@ -546,43 +546,38 @@ createPatchNumbers(OpenSubdiv::Far::PatchTables const & patchTables, static GLMesh gregoryWire; static void -createGregoryBasis(OpenSubdiv::Far::TopologyRefiner const & refiner, - OpenSubdiv::Far::StencilTables const & stencils, int maxvalence, +createGregoryBasis(OpenSubdiv::Far::PatchTables const & patchTables, std::vector const & vertexBuffer) { - int level = refiner.GetMaxLevel(), - nfaces = refiner.GetNumFaces(level); + typedef OpenSubdiv::Far::PatchTables FPatchTables; - std::vector gpatches(nfaces); - for (int face=0; face vertsperedge(nedges), edgeindices(nedges*2); std::vector edgeverts(npatches*20); + + OpenSubdiv::Far::StencilTables const * gstencils = + patchTables.GetEndCapStencilTables(); + assert(gstencils); + gstencils->UpdateValues(&vertexBuffer[0], &edgeverts[0]); for (int patch=0; patch::Create(sdctype, sdcoptions, *shape); - OpenSubdiv::Far::PatchTables * patchTables = 0; - if (g_Adaptive) { - refiner->RefineAdaptive(maxlevel, /*fullTopology*/true); - - patchTables = OpenSubdiv::Far::PatchTablesFactory::Create(*refiner); - - g_numPatches = patchTables->GetNumPatchesTotal(); - g_maxValence = patchTables->GetMaxValence(); } else { refiner->RefineUniform(maxlevel, /*fullTopology*/true); } - s.Stop(); + + // + // Stencils + // // create vertex primvar data buffer std::vector vertexBuffer(refiner->GetNumVerticesTotal()); Vertex * verts = &vertexBuffer[0]; - //printf("Vtr time: %f ms (topology)\n", float(s.GetElapsed())*1000.0f); - // copy coarse vertices positions int ncoarseverts = shape->GetNumVertices(); for (int i=0; iGetNumPatchesTotal(); + g_maxValence = patchTables->GetMaxValence(); + } + s.Stop(); + + // + // Misc display + // + + //printf("Vtr time: %f ms (topology)\n", float(s.GetElapsed())*1000.0f); + if (g_VtrDrawVertIDs) { createVertNumbers(*refiner, vertexBuffer); } @@ -758,7 +770,7 @@ createVtrMesh(Shape * shape, int maxlevel) { } if (g_Adaptive and g_drawGregoryBasis) { - createGregoryBasis(*refiner, *stencilTables, g_maxValence, vertexBuffer); + createGregoryBasis(*patchTables, vertexBuffer); } createEdgeNumbers(*refiner, vertexBuffer, g_VtrDrawEdgeIDs!=0, g_VtrDrawEdgeSharpness!=0);