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