// // Copyright 2014 DreamWorks Animation LLC. // // 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/topologyDescriptor.h" #include "../far/topologyRefinerFactory.h" #include "../far/topologyRefiner.h" // Unfortunately necessary for error codes that should be more accessible... #include "../vtr/level.h" #include #ifdef _MSC_VER #define snprintf _snprintf #endif namespace OpenSubdiv { namespace OPENSUBDIV_VERSION { namespace Far { // // Definitions for TopologyDescriptor: // TopologyDescriptor::TopologyDescriptor() { memset(this, 0, sizeof(TopologyDescriptor)); } // // Definitions/specializations for its RefinerFactory: // template <> bool TopologyRefinerFactory::resizeComponentTopology( TopologyRefiner & refiner, TopologyDescriptor const & desc) { setNumBaseVertices(refiner, desc.numVertices); setNumBaseFaces(refiner, desc.numFaces); for (int face=0; face bool TopologyRefinerFactory::assignComponentTopology( TopologyRefiner & refiner, TopologyDescriptor const & desc) { for (int face=0, idx=0; face 0; --vert) { dstFaceVerts[vert] = desc.vertIndicesPerFace[idx++]; } } else { for (int vert=0; vert bool TopologyRefinerFactory::assignComponentTags( TopologyRefiner & refiner, TopologyDescriptor const & desc) { if ((desc.numCreases>0) and desc.creaseVertexIndexPairs and desc.creaseWeights) { int const * vertIndexPairs = desc.creaseVertexIndexPairs; for (int edge=0; edge0) and desc.cornerVertexIndices and desc.cornerWeights) { for (int vert=0; vert= 0 and idx < getNumBaseVertices(refiner)) { setBaseVertexSharpness(refiner, idx, desc.cornerWeights[vert]); } else { char msg[1024]; snprintf(msg, 1024, "Vertex %d specified to be sharp does not exist", idx); reportInvalidTopology(Vtr::internal::Level::TOPOLOGY_INVALID_CREASE_VERT, msg, desc); } } } if (desc.numHoles>0) { for (int i=0; i bool TopologyRefinerFactory::assignFaceVaryingTopology( TopologyRefiner & refiner, TopologyDescriptor const & desc) { if (desc.numFVarChannels>0) { for (int channel=0; channel 0; --vert) { dstFaceFVarValues[vert] = srcFVarValues[srcNext++]; } } else { for (int vert = 0; vert < dstFaceFVarValues.size(); ++vert) { dstFaceFVarValues[vert] = srcFVarValues[srcNext++]; } } } } } return true; } template <> void TopologyRefinerFactory::reportInvalidTopology( TopologyError /* errCode */, char const * msg, TopologyDescriptor const& /* mesh */) { Warning(msg); } } // end namespace Far } // end namespace OPENSUBDIV_VERSION } // end namespace OpenSubdiv