// // Copyright 2015 Pixar // // Licensed under the Apache License, Version 2.0 (the "Apache License") // with the following modification; you may not use this file except in // compliance with the Apache License and the following modification to it: // Section 6. Trademarks. is deleted and replaced with: // // 6. Trademarks. This License does not grant permission to use the trade // names, trademarks, service marks, or product names of the Licensor // and its affiliates, except as required to comply with Section 4(c) of // the License and to reproduce the content of the NOTICE file. // // You may obtain a copy of the Apache License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the Apache License with the above modification is // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the Apache License for the specific // language governing permissions and limitations under the Apache License. // #include "../far/ptexIndices.h" #include "../far/error.h" #include "../vtr/level.h" #include namespace OpenSubdiv { namespace OPENSUBDIV_VERSION { namespace Far { PtexIndices::PtexIndices(TopologyRefiner const &refiner) { initializePtexIndices(refiner); } PtexIndices::~PtexIndices() { } void PtexIndices::initializePtexIndices(TopologyRefiner const &refiner) { int regFaceSize = Sdc::SchemeTypeTraits::GetRegularFaceSize( refiner.GetSchemeType()); Vtr::internal::Level const & coarseLevel = refiner.getLevel(0); int nfaces = coarseLevel.getNumFaces(); _ptexIndices.resize(nfaces+1); int ptexID=0; for (int i = 0; i < nfaces; ++i) { _ptexIndices[i] = ptexID; Vtr::ConstIndexArray fverts = coarseLevel.getFaceVertices(i); ptexID += fverts.size()==regFaceSize ? 1 : fverts.size(); } // last entry contains the number of ptex texture faces _ptexIndices[nfaces]=ptexID; } int PtexIndices::GetNumFaces() const { return _ptexIndices.back(); } int PtexIndices::GetFaceId(Index f) const { assert(f<(int)_ptexIndices.size()); return _ptexIndices[f]; } namespace { // Returns the face adjacent to 'face' along edge 'edge' inline Index getAdjacentFace(Vtr::internal::Level const & level, Index edge, Index face) { Far::ConstIndexArray adjFaces = level.getEdgeFaces(edge); if (adjFaces.size()!=2) { return -1; } return (adjFaces[0]==face) ? adjFaces[1] : adjFaces[0]; } } void PtexIndices::GetAdjacency( TopologyRefiner const &refiner, int face, int quadrant, int adjFaces[4], int adjEdges[4]) const { int regFaceSize = Sdc::SchemeTypeTraits::GetRegularFaceSize(refiner.GetSchemeType()); Vtr::internal::Level const & level = refiner.getLevel(0); ConstIndexArray fedges = level.getFaceEdges(face); if (fedges.size() == regFaceSize) { // Regular ptex quad face for (int i=0; i=0 && quadrant