| OpenSubdiv

Loading...
Searching...
No Matches
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 namespace Far { namespace internal { class FeatureMask; } }
42
43 namespace Far {
44
45 template <typename REAL> class PrimvarRefinerReal;
46 template <class MESH> class TopologyRefinerFactory;
47
51 class TopologyRefiner {
52
53 public:
54
56 TopologyRefiner(Sdc::SchemeType type, Sdc::Options options = Sdc::Options());
57
59 ~TopologyRefiner();
60
62 Sdc::SchemeType GetSchemeType() const { return _subdivType; }
63
65 Sdc::Options GetSchemeOptions() const { return _subdivOptions; }
66
68 bool IsUniform() const { return _isUniform; }
69
71 int GetNumLevels() const { return (int)_farLevels.size(); }
72
74 int GetMaxLevel() const { return _maxLevel; }
75
77 int GetMaxValence() const { return _maxValence; }
78
80 bool HasHoles() const { return _hasHoles; }
81
83 int GetNumVerticesTotal() const { return _totalVertices; }
84
86 int GetNumEdgesTotal() const { return _totalEdges; }
87
89 int GetNumFacesTotal() const { return _totalFaces; }
90
92 int GetNumFaceVerticesTotal() const { return _totalFaceVertices; }
93
95 TopologyLevel const & GetLevel(int level) const { return _farLevels[level]; }
96
98
100
101 //
102 // Uniform refinement
103 //
104
118 struct UniformOptions {
119
120 UniformOptions(int level) :
121 refinementLevel(level & 0xf),
122 orderVerticesFromFacesFirst(false),
123 fullTopologyInLastLevel(false) { }
124
126 void SetRefinementLevel(int level) { refinementLevel = level & 0xf; }
127
128 unsigned int refinementLevel:4,
129 orderVerticesFromFacesFirst:1,
131 fullTopologyInLastLevel:1;
134 };
135
146 void RefineUniform(UniformOptions options);
147
149 UniformOptions GetUniformOptions() const { return _uniformOptions; }
150
151 //
152 // Adaptive refinement
153 //
154
156 struct AdaptiveOptions {
157
158 AdaptiveOptions(int level) :
159 isolationLevel(level & 0xf),
160 secondaryLevel(0xf),
161 useSingleCreasePatch(false),
162 useInfSharpPatch(false),
163 considerFVarChannels(false),
164 orderVerticesFromFacesFirst(false) { }
165
167 void SetIsolationLevel(int level) { isolationLevel = level & 0xf; }
168
170 void SetSecondaryLevel(int level) { secondaryLevel = level & 0xf; }
171
172 unsigned int isolationLevel:4;
174 unsigned int secondaryLevel:4;
176 unsigned int useSingleCreasePatch:1;
178 unsigned int useInfSharpPatch:1;
180 unsigned int considerFVarChannels:1;
182 unsigned int orderVerticesFromFacesFirst:1;
184 };
185
192 void RefineAdaptive(AdaptiveOptions options,
193 ConstIndexArray selectedFaces = ConstIndexArray());
194
196 AdaptiveOptions GetAdaptiveOptions() const { return _adaptiveOptions; }
197
199 void Unrefine();
200
201
203
205
207 int GetNumFVarChannels() const;
208
210 Sdc::Options::FVarLinearInterpolation GetFVarLinearInterpolation(int channel = 0) const;
211
213 int GetNumFVarValuesTotal(int channel = 0) const;
214
216
217 protected:
218
219 //
220 // Lower level protected methods intended strictly for internal use:
221 //
222 template <class MESH>
223 friend class TopologyRefinerFactory;
224 friend class TopologyRefinerFactoryBase;
225 friend class PatchTableBuilder;
226 friend class PatchBuilder;
227 friend class PtexIndices;
228 template <typename REAL>
229 friend class PrimvarRefinerReal;
230
231 // Copy constructor exposed via the factory class:
232 TopologyRefiner(TopologyRefiner const & source);
233
234 public:
235 // Levels and Refinements available internally (avoids need for more friends)
236 Vtr::internal::Level & getLevel(int l) { return *_levels[l]; }
237 Vtr::internal::Level const & getLevel(int l) const { return *_levels[l]; }
238
239 Vtr::internal::Refinement & getRefinement(int l) { return *_refinements[l]; }
240 Vtr::internal::Refinement const & getRefinement(int l) const { return *_refinements[l]; }
241
242 private:
243 // Not default constructible or copyable:
244 TopologyRefiner() : _uniformOptions(0), _adaptiveOptions(0) { }
245 TopologyRefiner & operator=(TopologyRefiner const &) { return *this; }
246
247 void selectFeatureAdaptiveComponents(Vtr::internal::SparseSelector& selector,
248 internal::FeatureMask const & mask,
249 ConstIndexArray selectedFaces);
250 void selectLinearIrregularFaces(Vtr::internal::SparseSelector& selector,
251 ConstIndexArray selectedFaces);
252
253 void initializeInventory();
254 void updateInventory(Vtr::internal::Level const & newLevel);
255
256 void appendLevel(Vtr::internal::Level & newLevel);
257 void appendRefinement(Vtr::internal::Refinement & newRefinement);
258 void assembleFarLevels();
259
260 private:
261
262 Sdc::SchemeType _subdivType;
263 Sdc::Options _subdivOptions;
264
265 unsigned int _isUniform : 1;
266 unsigned int _hasHoles : 1;
267 unsigned int _hasIrregFaces : 1;
268 unsigned int _regFaceSize : 3;
269 unsigned int _maxLevel : 4;
270
271 // Options assigned on refinement:
272 UniformOptions _uniformOptions;
273 AdaptiveOptions _adaptiveOptions;
274
275 // Cumulative properties of all levels:
276 int _totalVertices;
277 int _totalEdges;
278 int _totalFaces;
279 int _totalFaceVertices;
280 int _maxValence;
281
282 // Note the base level may be shared with another instance
283 bool _baseLevelOwned;
284
285 std::vector<Vtr::internal::Level *> _levels;
286 std::vector<Vtr::internal::Refinement *> _refinements;
287
288 std::vector<TopologyLevel> _farLevels;
289};
290
291
292 inline int
293 TopologyRefiner::GetNumFVarChannels() const {
294
295 return _levels[0]->getNumFVarChannels();
296}
297 inline Sdc::Options::FVarLinearInterpolation
298 TopologyRefiner::GetFVarLinearInterpolation(int channel) const {
299
300 return _levels[0]->getFVarOptions(channel).GetFVarLinearInterpolation();
301}
302
303} // end namespace Far
304
305} // end namespace OPENSUBDIV_VERSION
306 using namespace OPENSUBDIV_VERSION;
307} // end namespace OpenSubdiv
308
309#endif /* OPENSUBDIV3_FAR_TOPOLOGY_REFINER_H */
topologyLevel.h
options.h
OpenSubdiv
Definition limits.h:32
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:33
OpenSubdiv::OPENSUBDIV_VERSION::Far
Definition refinerSurfaceFactory.h:36
OpenSubdiv::OPENSUBDIV_VERSION::Far::ConstIndexArray
Vtr::ConstIndexArray ConstIndexArray
Definition types.h:47
OpenSubdiv::OPENSUBDIV_VERSION::Vtr
Definition topologyRefiner.h:40
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::SchemeType
SchemeType
Enumerated type for all subdivision schemes supported by OpenSubdiv.
Definition types.h:37
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyLevel
An interface for accessing data in a specific level of a refined topology hierarchy.
Definition topologyLevel.h:49
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::TopologyRefiner
TopologyRefiner(TopologyRefiner const &source)
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetMaxValence
int GetMaxValence() const
Returns the maximum vertex valence in all levels.
Definition topologyRefiner.h:77
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::getLevel
Vtr::internal::Level const & getLevel(int l) const
Definition topologyRefiner.h:237
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::HasHoles
bool HasHoles() const
Returns true if faces have been tagged as holes.
Definition topologyRefiner.h:80
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumLevels
int GetNumLevels() const
Returns the number of refinement levels.
Definition topologyRefiner.h:71
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::PrimvarRefinerReal
friend class PrimvarRefinerReal
Definition topologyRefiner.h:229
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::PtexIndices
friend class PtexIndices
Definition topologyRefiner.h:227
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::getRefinement
Vtr::internal::Refinement const & getRefinement(int l) const
Definition topologyRefiner.h:240
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetSchemeOptions
Sdc::Options GetSchemeOptions() const
Returns the subdivision options.
Definition topologyRefiner.h:65
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::getLevel
Vtr::internal::Level & getLevel(int l)
Definition topologyRefiner.h:236
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::IsUniform
bool IsUniform() const
Returns true if uniform refinement has been applied.
Definition topologyRefiner.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetSchemeType
Sdc::SchemeType GetSchemeType() const
Returns the subdivision scheme.
Definition topologyRefiner.h:62
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::TopologyRefinerFactoryBase
friend class TopologyRefinerFactoryBase
Definition topologyRefiner.h:224
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetMaxLevel
int GetMaxLevel() const
Returns the highest level of refinement.
Definition topologyRefiner.h:74
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::TopologyRefinerFactory
friend class TopologyRefinerFactory
Definition topologyRefiner.h:223
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::TopologyRefiner
TopologyRefiner(Sdc::SchemeType type, Sdc::Options options=Sdc::Options())
Constructor.
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumEdgesTotal
int GetNumEdgesTotal() const
Returns the total number of edges in all levels.
Definition topologyRefiner.h:86
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::PatchBuilder
friend class PatchBuilder
Definition topologyRefiner.h:226
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumFVarChannels
int GetNumFVarChannels() const
Returns the number of face-varying channels in the tables.
Definition topologyRefiner.h:293
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetUniformOptions
UniformOptions GetUniformOptions() const
Returns the options specified on refinement.
Definition topologyRefiner.h:149
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumFacesTotal
int GetNumFacesTotal() const
Returns the total number of edges in all levels.
Definition topologyRefiner.h:89
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumFaceVerticesTotal
int GetNumFaceVerticesTotal() const
Returns the total number of face vertices in all levels.
Definition topologyRefiner.h:92
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::getRefinement
Vtr::internal::Refinement & getRefinement(int l)
Definition topologyRefiner.h:239
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::RefineUniform
void RefineUniform(UniformOptions options)
Refine the topology uniformly.
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::~TopologyRefiner
~TopologyRefiner()
Destructor.
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::PatchTableBuilder
friend class PatchTableBuilder
Definition topologyRefiner.h:225
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:95
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumVerticesTotal
int GetNumVerticesTotal() const
Returns the total number of vertices in all levels.
Definition topologyRefiner.h:83
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::Unrefine
void Unrefine()
Unrefine the topology, keeping only the base level.
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetAdaptiveOptions
AdaptiveOptions GetAdaptiveOptions() const
Returns the options specified on refinement.
Definition topologyRefiner.h:196
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:298
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::RefineAdaptive
void RefineAdaptive(AdaptiveOptions options, ConstIndexArray selectedFaces=ConstIndexArray())
Feature Adaptive topology refinement.
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::UniformOptions
Uniform refinement options.
Definition topologyRefiner.h:118
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::UniformOptions::refinementLevel
unsigned int refinementLevel
Number of refinement iterations.
Definition topologyRefiner.h:128
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::UniformOptions::orderVerticesFromFacesFirst
unsigned int orderVerticesFromFacesFirst
Definition topologyRefiner.h:130
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::UniformOptions::SetRefinementLevel
void SetRefinementLevel(int level)
Set uniform refinement level.
Definition topologyRefiner.h:126
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::UniformOptions::fullTopologyInLastLevel
unsigned int fullTopologyInLastLevel
Definition topologyRefiner.h:131
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::UniformOptions::UniformOptions
UniformOptions(int level)
Definition topologyRefiner.h:120
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions
Adaptive refinement options.
Definition topologyRefiner.h:156
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::secondaryLevel
unsigned int secondaryLevel
Definition topologyRefiner.h:174
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::orderVerticesFromFacesFirst
unsigned int orderVerticesFromFacesFirst
Definition topologyRefiner.h:182
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::AdaptiveOptions
AdaptiveOptions(int level)
Definition topologyRefiner.h:158
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::isolationLevel
unsigned int isolationLevel
Definition topologyRefiner.h:172
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::useSingleCreasePatch
unsigned int useSingleCreasePatch
Definition topologyRefiner.h:176
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::useInfSharpPatch
unsigned int useInfSharpPatch
Definition topologyRefiner.h:178
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::SetIsolationLevel
void SetIsolationLevel(int level)
Set isolation level.
Definition topologyRefiner.h:167
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::considerFVarChannels
unsigned int considerFVarChannels
Definition topologyRefiner.h:180
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::SetSecondaryLevel
void SetSecondaryLevel(int level)
Set secondary isolation level.
Definition topologyRefiner.h:170
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Options
All supported options applying to subdivision scheme.
Definition options.h:51
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Options::FVarLinearInterpolation
FVarLinearInterpolation
Definition options.h:60
types.h
types.h