- Main Page
- Namespaces
- Classes
- Files

- File List

topologyRefiner.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_FAR_TOPOLOGY_REFINER_H
25 #define OPENSUBDIV3_FAR_TOPOLOGY_REFINER_H
26
27 #include "../version.h"
28
29 #include "../sdc/types.h"
30 #include "../sdc/options.h"
31 #include "../far/types.h"
32 #include "../far/topologyLevel.h"
33
34 #include <vector>
35
36
37 namespace OpenSubdiv {
38 namespace OPENSUBDIV_VERSION {
39
40 namespace Vtr { namespace internal { class SparseSelector; } }
41
42 namespace Far {
43
44 template <class MESH> class TopologyRefinerFactory;
45
49 class TopologyRefiner {
50
51 public:
52
54 TopologyRefiner(Sdc::SchemeType type, Sdc::Options options = Sdc::Options());
55
57 ~TopologyRefiner();
58
60 Sdc::SchemeType GetSchemeType() const { return _subdivType; }
61
63 Sdc::Options GetSchemeOptions() const { return _subdivOptions; }
64
66 bool IsUniform() const { return _isUniform; }
67
69 int GetNumLevels() const { return (int)_levels.size(); }
70
72 int GetMaxLevel() const { return _maxLevel; }
73
75 int GetMaxValence() const { return _maxValence; }
76
78 bool HasHoles() const { return _hasHoles; }
79
81 int GetNumVerticesTotal() const { return _totalVertices; }
82
84 int GetNumEdgesTotal() const { return _totalEdges; }
85
87 int GetNumFacesTotal() const { return _totalFaces; }
88
90 int GetNumFaceVerticesTotal() const { return _totalFaceVertices; }
91
93 TopologyLevel const & GetLevel(int level) const { return _farLevels[level]; }
94
96
99 //
100 // Uniform refinement
101 //
102
104 struct UniformOptions {
105
106 UniformOptions(int level) :
107 refinementLevel(level),
108 orderVerticesFromFacesFirst(false),
109 fullTopologyInLastLevel(false) { }
110
111 unsigned int refinementLevel:4,
112 orderVerticesFromFacesFirst:1,
113 fullTopologyInLastLevel:1;
115 };
118
123 void RefineUniform(UniformOptions options);
124
126 UniformOptions GetUniformOptions() const { return _uniformOptions; }
127
128 //
129 // Adaptive refinement
130 //
131
133 struct AdaptiveOptions {
134
135 AdaptiveOptions(int level) :
136 isolationLevel(level),
137 useSingleCreasePatch(false),
138 orderVerticesFromFacesFirst(false) { }
139
140 unsigned int isolationLevel:4,
141 useSingleCreasePatch:1,
143 orderVerticesFromFacesFirst:1;
145 };
147
152 void RefineAdaptive(AdaptiveOptions options);
153
155 AdaptiveOptions GetAdaptiveOptions() const { return _adaptiveOptions; }
156
158 void Unrefine();
159
160
162
166 int GetNumFVarChannels() const;
167
169 Sdc::Options::FVarLinearInterpolation GetFVarLinearInterpolation(int channel = 0) const;
170
172 int GetNumFVarValuesTotal(int channel = 0) const;
173
175
176 protected:
177
178 //
179 // Lower level protected methods intended strictly for internal use:
180 //
181 template <class MESH>
182 friend class TopologyRefinerFactory;
183 friend class TopologyRefinerFactoryBase;
184 friend class PatchTableFactory;
185 friend class EndCapGregoryBasisPatchFactory;
186 friend class EndCapLegacyGregoryPatchFactory;
187 friend class PtexIndices;
188 friend class PrimvarRefiner;
189
190 Vtr::internal::Level & getLevel(int l) { return *_levels[l]; }
191 Vtr::internal::Level const & getLevel(int l) const { return *_levels[l]; }
192
193 Vtr::internal::Refinement & getRefinement(int l) { return *_refinements[l]; }
194 Vtr::internal::Refinement const & getRefinement(int l) const { return *_refinements[l]; }
195
196 private:
197 // Not default constructible or copyable:
198 TopologyRefiner() : _uniformOptions(0), _adaptiveOptions(0) { }
199 TopologyRefiner(TopologyRefiner const &) : _uniformOptions(0), _adaptiveOptions(0) { }
200 TopologyRefiner & operator=(TopologyRefiner const &) { return *this; }
201
202 void selectFeatureAdaptiveComponents(Vtr::internal::SparseSelector& selector);
203
204 void initializeInventory();
205 void updateInventory(Vtr::internal::Level const & newLevel);
206
207 void appendLevel(Vtr::internal::Level & newLevel);
208 void appendRefinement(Vtr::internal::Refinement & newRefinement);
209 void assembleFarLevels();
210
211 private:
212
213 Sdc::SchemeType _subdivType;
214 Sdc::Options _subdivOptions;
215
216 unsigned int _isUniform : 1,
217 _hasHoles : 1,
218 _maxLevel : 4;
219
220 // Options assigned on refinement:
221 UniformOptions _uniformOptions;
222 AdaptiveOptions _adaptiveOptions;
223
224 // Cumulative properties of all levels:
225 int _totalVertices;
226 int _totalEdges;
227 int _totalFaces;
228 int _totalFaceVertices;
229 int _maxValence;
230
231 // There is some redundancy here -- to be reduced later
232 std::vector<Vtr::internal::Level *> _levels;
233 std::vector<Vtr::internal::Refinement *> _refinements;
234
235 std::vector<TopologyLevel> _farLevels;
236 };
237
238
239 inline int
240 TopologyRefiner::GetNumFVarChannels() const {
241
242 return _levels[0]->getNumFVarChannels();
243 }
244 inline Sdc::Options::FVarLinearInterpolation
245 TopologyRefiner::GetFVarLinearInterpolation(int channel) const {
246
247 return _levels[0]->getFVarOptions(channel).GetFVarLinearInterpolation();
248 }
249
250 } // end namespace Far
251
252 } // end namespace OPENSUBDIV_VERSION
253 using namespace OPENSUBDIV_VERSION;
254 } // end namespace OpenSubdiv
255
256 #endif /* OPENSUBDIV3_FAR_TOPOLOGY_REFINER_H */
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::SchemeType
SchemeType
Enumerated type for all subdivisions schemes supported by OpenSubdiv.
Definition: types.h:37
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetMaxLevel
int GetMaxLevel() const
Returns the highest level of refinement.
Definition: topologyRefiner.h:72
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions
Adaptive refinement options.
Definition: topologyRefiner.h:133
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::Unrefine
void Unrefine()
Unrefine the topology (keep control cage)
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefinerFactoryBase
Private base class of Factories for constructing TopologyRefiners.
Definition: topologyRefinerFactory.h:47
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Options::FVarLinearInterpolation
FVarLinearInterpolation
Definition: options.h:58
OpenSubdiv
Definition: error.h:30
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumFVarChannels
int GetNumFVarChannels() const
Returns the number of face-varying channels in the tables.
Definition: topologyRefiner.h:240
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumFaceVerticesTotal
int GetNumFaceVerticesTotal() const
Returns the total number of face vertices in all levels.
Definition: topologyRefiner.h:90
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::IsUniform
bool IsUniform() const
Returns true if uniform subdivision has been applied.
Definition: topologyRefiner.h:66
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::UniformOptions::refinementLevel
unsigned int refinementLevel
Number of refinement iterations.
Definition: topologyRefiner.h:111
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::UniformOptions::orderVerticesFromFacesFirst
unsigned int orderVerticesFromFacesFirst
Definition: topologyRefiner.h:111
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::EndCapGregoryBasisPatchFactory
friend class EndCapGregoryBasisPatchFactory
Definition: topologyRefiner.h:185
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory
Definition: patchTableFactory.h:41
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumFVarValuesTotal
int GetNumFVarValuesTotal(int channel=0) const
Returns the total number of face-varying values in all levels.
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumFacesTotal
int GetNumFacesTotal() const
Returns the total number of edges in all levels.
Definition: topologyRefiner.h:87
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefinerFactory
Factory for constructing TopologyRefiners from specific mesh classes.
Definition: topologyRefiner.h:44
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::getRefinement
Vtr::internal::Refinement & getRefinement(int l)
Definition: topologyRefiner.h:193
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetMaxValence
int GetMaxValence() const
Returns the maximum vertex valence in all levels.
Definition: topologyRefiner.h:75
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::UniformOptions::UniformOptions
UniformOptions(int level)
Definition: topologyRefiner.h:106
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::EndCapLegacyGregoryPatchFactory
friend class EndCapLegacyGregoryPatchFactory
Definition: topologyRefiner.h:186
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::HasHoles
bool HasHoles() const
\ brief Returns true if faces have been tagged as holes
Definition: topologyRefiner.h:78
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::orderVerticesFromFacesFirst
unsigned int orderVerticesFromFacesFirst
Definition: topologyRefiner.h:141
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::RefineUniform
void RefineUniform(UniformOptions options)
Refine the topology uniformly.
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetLevel
TopologyLevel const & GetLevel(int level) const
Returns a handle to access data specific to a particular level.
Definition: topologyRefiner.h:93
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetUniformOptions
UniformOptions GetUniformOptions() const
Returns the options specified on refinement.
Definition: topologyRefiner.h:126
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetSchemeOptions
Sdc::Options GetSchemeOptions() const
Returns the subdivision options.
Definition: topologyRefiner.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Options
All supported options applying to subdivision scheme.
Definition: options.h:51
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::UniformOptions::fullTopologyInLastLevel
unsigned int fullTopologyInLastLevel
Definition: topologyRefiner.h:111
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::Level
Definition: level.h:83
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::AdaptiveOptions
AdaptiveOptions(int level)
Definition: topologyRefiner.h:135
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetAdaptiveOptions
AdaptiveOptions GetAdaptiveOptions() const
Returns the options specified on refinement.
Definition: topologyRefiner.h:155
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::getLevel
Vtr::internal::Level const & getLevel(int l) const
Definition: topologyRefiner.h:191
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetFVarLinearInterpolation
Sdc::Options::FVarLinearInterpolation GetFVarLinearInterpolation(int channel=0) const
Returns the face-varying interpolation rule-set for a given channel.
Definition: topologyRefiner.h:245
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::RefineAdaptive
void RefineAdaptive(AdaptiveOptions options)
Feature Adaptive topology refinement (restricted to scheme Catmark)
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumLevels
int GetNumLevels() const
Returns the number of refinement levels.
Definition: topologyRefiner.h:69
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::getLevel
Vtr::internal::Level & getLevel(int l)
Definition: topologyRefiner.h:190
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumEdgesTotal
int GetNumEdgesTotal() const
Returns the total number of edges in all levels.
Definition: topologyRefiner.h:84
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner
Stores topology data for a specified set of refinement options.
Definition: topologyRefiner.h:49
OpenSubdiv::OPENSUBDIV_VERSION::Far::PtexIndices
Object used to compute and query ptex face indices.
Definition: ptexIndices.h:46
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetSchemeType
Sdc::SchemeType GetSchemeType() const
Returns the subdivision scheme.
Definition: topologyRefiner.h:60
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::~TopologyRefiner
~TopologyRefiner()
Destructor.
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::useSingleCreasePatch
unsigned int useSingleCreasePatch
Definition: topologyRefiner.h:141
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::UniformOptions
Uniform refinement options.
Definition: topologyRefiner.h:104
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::SparseSelector
Definition: sparseSelector.h:57
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::isolationLevel
unsigned int isolationLevel
Definition: topologyRefiner.h:141
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::getRefinement
Vtr::internal::Refinement const & getRefinement(int l) const
Definition: topologyRefiner.h:194
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyLevel
TopologyLevel is an interface for accessing data in a specific level of a refined topology hierarchy...
Definition: topologyLevel.h:47
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::Refinement
Definition: refinement.h:69
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumVerticesTotal
int GetNumVerticesTotal() const
Returns the total number of vertices in all levels.
Definition: topologyRefiner.h:81
OpenSubdiv::OPENSUBDIV_VERSION::Far::PrimvarRefiner
Applies refinement operations to generic primvar data.
Definition: primvarRefiner.h:56