All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
types.h
Go to the documentation of this file.
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 VTR_TYPES_H
25 #define VTR_TYPES_H
26 
27 #include "../version.h"
28 
29 #include "../vtr/array.h"
30 
31 #include <vector>
32 
33 namespace OpenSubdiv {
34 namespace OPENSUBDIV_VERSION {
35 
36 namespace Vtr {
37 
38 //
39 // A few types (and constants) are declared here while Vtr is being
40 // developed. These tend to be used by more than one Vtr class, i.e.
41 // both Level and Refinement and are often present in their
42 // interfaces.
43 //
44 // Is the sharpness overkill -- perhaps sdc should define this...
45 //
46 typedef float Sharpness;
47 
48 //
49 // Indices -- note we can't use sized integer types like uint32_t, etc. as use of
50 // stdint is not portable.
51 //
52 // The convention throughout the OpenSubdiv code is to use "int" in most places,
53 // with "unsigned int" being limited to a few cases (why?). So we continue that
54 // trend here and use "int" for topological indices (with -1 indicating "invalid")
55 // despite the fact that we lose half the range compared to using "uint" (with ~0
56 // as invalid).
57 //
58 typedef int Index; // Used to index the vectors of components
59 typedef unsigned char LocalIndex; // Used to index one component within another
60 
61 static const Index INDEX_INVALID = -1;
62 
63 inline bool IndexIsValid(Index index) { return (index != INDEX_INVALID); }
64 
65 //
66 // Note for aggregate types the use of "vector" wraps an std:;vector (typically a
67 // member variable) and is fully resizable and owns its own storage, whereas "array"
68 // is typically used in index a fixed subset of pre-allocated memory:
69 //
70 typedef std::vector<Index> IndexVector;
71 
74 
75 
76 } // end namespace Vtr
77 
78 } // end namespace OPENSUBDIV_VERSION
79 
80 using namespace OPENSUBDIV_VERSION;
81 
82 } // end namespace OpenSubdiv
83 
84 #endif /* VTR_TYPES_H */
85 
std::vector< Index > IndexVector
Definition: types.h:70
bool IndexIsValid(Index index)
Definition: types.h:63
Array< LocalIndex > LocalIndexArray
Definition: types.h:73