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