1 // 2 // Copyright 2014 DreamWorks Animation LLC. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "Apache License") 5 // with the following modification; you may not use this file except in 6 // compliance with the Apache License and the following modification to it: 7 // Section 6. Trademarks. is deleted and replaced with: 8 // 9 // 6. Trademarks. This License does not grant permission to use the trade 10 // names, trademarks, service marks, or product names of the Licensor 11 // and its affiliates, except as required to comply with Section 4(c) of 12 // the License and to reproduce the content of the NOTICE file. 13 // 14 // You may obtain a copy of the Apache License at 15 // 16 // http://www.apache.org/licenses/LICENSE-2.0 17 // 18 // Unless required by applicable law or agreed to in writing, software 19 // distributed under the Apache License with the above modification is 20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21 // KIND, either express or implied. See the Apache License for the specific 22 // language governing permissions and limitations under the Apache License. 23 // 24 #ifndef OPENSUBDIV3_SDC_OPTIONS_H 25 #define OPENSUBDIV3_SDC_OPTIONS_H 26 27 #include "../version.h" 28 29 namespace OpenSubdiv { 30 namespace OPENSUBDIV_VERSION { 31 32 namespace Sdc { 33 34 /// 35 /// \brief All supported options applying to subdivision scheme. 36 /// 37 /// The Options class contains all supported options that can be applied to a 38 /// subdivision scheme to affect the shape of the limit surface. These differ from 39 /// approximations that may be applied at a higher level, i.e. options to limit the 40 /// level of feature adaptive subdivision, options to ignore fractional creasing, 41 /// or creasing entirely, etc. These options define the shape of a particular 42 /// limit surface, including the "shape" of primitive variable data associated with 43 /// it. 44 /// 45 /// The intent is that these sets of options be defined at a high level and 46 /// propagated into the lowest-level computation in support of each subdivision 47 /// scheme. Ideally it remains a set of bit-fields (essentially an int) and so 48 /// remains light weight and easily passed around by value. 49 /// 50 51 class Options { 52 public: 53 enum VtxBoundaryInterpolation { 54 VTX_BOUNDARY_NONE = 0, ///< no boundary interpolation, except where 55 ///< boundary edges were explicitly sharpened 56 VTX_BOUNDARY_EDGE_ONLY, ///< all boundary edges sharpened and interpolated 57 VTX_BOUNDARY_EDGE_AND_CORNER ///< all boundary edges and corner vertices 58 ///< sharpened and interpolated 59 }; 60 enum FVarLinearInterpolation { 61 FVAR_LINEAR_NONE = 0, ///< smooth everywhere ("edge only") 62 FVAR_LINEAR_CORNERS_ONLY, ///< sharpen corners only 63 FVAR_LINEAR_CORNERS_PLUS1, ///< ("edge corner") 64 FVAR_LINEAR_CORNERS_PLUS2, ///< ("edge and corner + propagate corner") 65 FVAR_LINEAR_BOUNDARIES, ///< sharpen all boundaries ("always sharp") 66 FVAR_LINEAR_ALL ///< bilinear interpolation ("bilinear") 67 }; 68 enum CreasingMethod { 69 CREASE_UNIFORM = 0, ///< Catmark rule 70 CREASE_CHAIKIN ///< Chaikin rule 71 }; 72 enum TriangleSubdivision { 73 TRI_SUB_CATMARK = 0, ///< Catmark weights (Catmark scheme only) 74 TRI_SUB_SMOOTH ///< "smooth triangle" weights (Catmark scheme only) 75 }; 76 77 public: 78 Options()79 Options() : _vtxBoundInterp(VTX_BOUNDARY_NONE), 80 _fvarLinInterp(FVAR_LINEAR_ALL), 81 _creasingMethod(CREASE_UNIFORM), 82 _triangleSub(TRI_SUB_CATMARK) { } 83 84 // 85 // Trivial get/set methods: 86 // 87 88 /// \brief Get vertex boundary interpolation rule GetVtxBoundaryInterpolation()89 VtxBoundaryInterpolation GetVtxBoundaryInterpolation() const { return (VtxBoundaryInterpolation) _vtxBoundInterp; } 90 91 /// \brief Set vertex boundary interpolation rule SetVtxBoundaryInterpolation(VtxBoundaryInterpolation b)92 void SetVtxBoundaryInterpolation(VtxBoundaryInterpolation b) { _vtxBoundInterp = b; } 93 94 /// \brief Get face-varying interpolation rule GetFVarLinearInterpolation()95 FVarLinearInterpolation GetFVarLinearInterpolation() const { return (FVarLinearInterpolation) _fvarLinInterp; } 96 97 /// \brief Set face-varying interpolation rule SetFVarLinearInterpolation(FVarLinearInterpolation b)98 void SetFVarLinearInterpolation(FVarLinearInterpolation b) { _fvarLinInterp = b; } 99 100 /// \brief Get edge crease rule GetCreasingMethod()101 CreasingMethod GetCreasingMethod() const { return (CreasingMethod) _creasingMethod; } 102 103 /// \brief Set edge crease rule SetCreasingMethod(CreasingMethod c)104 void SetCreasingMethod(CreasingMethod c) { _creasingMethod = c; } 105 106 /// \brief Get triangle subdivision weights rule (Catmark scheme only !) GetTriangleSubdivision()107 TriangleSubdivision GetTriangleSubdivision() const { return (TriangleSubdivision) _triangleSub; } 108 109 /// \brief Set triangle subdivision weights rule (Catmark scheme only !) SetTriangleSubdivision(TriangleSubdivision t)110 void SetTriangleSubdivision(TriangleSubdivision t) { _triangleSub = t; } 111 112 private: 113 114 // Bitfield members: 115 unsigned int _vtxBoundInterp : 2, 116 _fvarLinInterp : 3, 117 _creasingMethod : 2, 118 _triangleSub : 2; 119 }; 120 121 } // end namespace sdc 122 123 } // end namespace OPENSUBDIV_VERSION 124 using namespace OPENSUBDIV_VERSION; 125 } // end namespace OpenSubdiv 126 127 #endif /* OPENSUBDIV3_SDC_OPTIONS_H */ 128