OpenSubdiv
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1//
2// Copyright 2014 DreamWorks Animation LLC.
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://opensubdiv.org/license.
6//
7#ifndef OPENSUBDIV3_VTR_TYPES_H
8#define OPENSUBDIV3_VTR_TYPES_H
9
10#include "../version.h"
11
12#include "../vtr/array.h"
13
14#include <limits>
15#include <vector>
16
17namespace OpenSubdiv {
18namespace OPENSUBDIV_VERSION {
19
20namespace Vtr {
21
22//
23// A few types (and constants) for use within Vtr and potentially by its
24// clients (appropriately exported and retyped)
25//
26
27//
28// Integer type and constants to index the vectors of components. Note that we
29// can't use specific width integer types like uint32_t, etc. as use of stdint
30// is not portable.
31//
32// The convention throughout the OpenSubdiv code is to use "int" in most places,
33// with "unsigned int" being limited to a few cases (why?). So we continue that
34// trend here and use "int" for topological indices (with -1 indicating "invalid")
35// despite the fact that we lose half the range compared to using "uint" (with ~0
36// as invalid).
37//
38typedef int Index;
39
40inline Index constexpr INDEX_INVALID = -1;
41
42inline bool IndexIsValid(Index index) { return (index != INDEX_INVALID); }
43
44//
45// Integer type and constants used to index one component within another. Ideally
46// this is just 2 bits once refinement reduces faces to tris or quads -- and so
47// could potentially be combined with an Index -- but we need something larger for
48// the N-sided face.
49//
50typedef unsigned short LocalIndex;
51
52// Declared as "int" since it's intended for more general use
53inline int constexpr VALENCE_LIMIT = std::numeric_limits<LocalIndex>::max();
54
55//
56// Collections of integer types in variable or fixed sized arrays. Note that the use
57// of "vector" in the name indicates a class that wraps an std::vector (typically a
58// member variable) which is fully resizable and owns its own storage, whereas "array"
59// wraps a vtr::Array which uses a fixed block of pre-allocated memory.
60//
61typedef std::vector<Index> IndexVector;
62
65
68
69
70} // end namespace Vtr
71
72} // end namespace OPENSUBDIV_VERSION
73using namespace OPENSUBDIV_VERSION;
74} // end namespace OpenSubdiv
75
76#endif /* OPENSUBDIV3_VTR_TYPES_H */
ConstArray< LocalIndex > ConstLocalIndexArray
Definition types.h:67
Array< LocalIndex > LocalIndexArray
Definition types.h:66
Index constexpr INDEX_INVALID
Definition types.h:40
std::vector< Index > IndexVector
Definition types.h:61
ConstArray< Index > ConstIndexArray
Definition types.h:64
bool IndexIsValid(Index index)
Definition types.h:42