| 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 terms set forth in the LICENSE.txt file available at
5// https://opensubdiv.org/license.
6//
7#ifndef OPENSUBDIV3_FAR_TOPOLOGY_REFINER_H
8#define OPENSUBDIV3_FAR_TOPOLOGY_REFINER_H
9
10#include "../version.h"
11
12#include "../sdc/types.h"
13#include "../sdc/options.h"
14#include "../far/types.h"
15#include "../far/topologyLevel.h"
16
17#include <vector>
18
19
20 namespace OpenSubdiv {
21 namespace OPENSUBDIV_VERSION {
22
23 namespace Vtr { namespace internal { class SparseSelector; } }
24 namespace Far { namespace internal { class FeatureMask; } }
25
26 namespace Far {
27
28 template <typename REAL> class PrimvarRefinerReal;
29 template <class MESH> class TopologyRefinerFactory;
30
34 class TopologyRefiner {
35
36 public:
37
39 TopologyRefiner(Sdc::SchemeType type, Sdc::Options options = Sdc::Options());
40
42 ~TopologyRefiner();
43
45 Sdc::SchemeType GetSchemeType() const { return _subdivType; }
46
48 Sdc::Options GetSchemeOptions() const { return _subdivOptions; }
49
51 bool IsUniform() const { return _isUniform; }
52
54 int GetNumLevels() const { return (int)_farLevels.size(); }
55
57 int GetMaxLevel() const { return _maxLevel; }
58
60 int GetMaxValence() const { return _maxValence; }
61
63 bool HasHoles() const { return _hasHoles; }
64
66 int GetNumVerticesTotal() const { return _totalVertices; }
67
69 int GetNumEdgesTotal() const { return _totalEdges; }
70
72 int GetNumFacesTotal() const { return _totalFaces; }
73
75 int GetNumFaceVerticesTotal() const { return _totalFaceVertices; }
76
78 TopologyLevel const & GetLevel(int level) const { return _farLevels[level]; }
79
81
83
84 //
85 // Uniform refinement
86 //
87
101 struct UniformOptions {
102
103 UniformOptions(int level) :
104 refinementLevel(level & 0xf),
105 orderVerticesFromFacesFirst(false),
106 fullTopologyInLastLevel(false) { }
107
109 void SetRefinementLevel(int level) { refinementLevel = level & 0xf; }
110
111 unsigned int refinementLevel:4,
112 orderVerticesFromFacesFirst:1,
114 fullTopologyInLastLevel:1;
117 };
118
129 void RefineUniform(UniformOptions options);
130
132 UniformOptions GetUniformOptions() const { return _uniformOptions; }
133
134 //
135 // Adaptive refinement
136 //
137
139 struct AdaptiveOptions {
140
141 AdaptiveOptions(int level) :
142 isolationLevel(level & 0xf),
143 secondaryLevel(0xf),
144 useSingleCreasePatch(false),
145 useInfSharpPatch(false),
146 considerFVarChannels(false),
147 orderVerticesFromFacesFirst(false) { }
148
150 void SetIsolationLevel(int level) { isolationLevel = level & 0xf; }
151
153 void SetSecondaryLevel(int level) { secondaryLevel = level & 0xf; }
154
155 unsigned int isolationLevel:4;
157 unsigned int secondaryLevel:4;
159 unsigned int useSingleCreasePatch:1;
161 unsigned int useInfSharpPatch:1;
163 unsigned int considerFVarChannels:1;
165 unsigned int orderVerticesFromFacesFirst:1;
167 };
168
175 void RefineAdaptive(AdaptiveOptions options,
176 ConstIndexArray selectedFaces = ConstIndexArray());
177
179 AdaptiveOptions GetAdaptiveOptions() const { return _adaptiveOptions; }
180
182 void Unrefine();
183
184
186
188
190 int GetNumFVarChannels() const;
191
193 Sdc::Options::FVarLinearInterpolation GetFVarLinearInterpolation(int channel = 0) const;
194
196 int GetNumFVarValuesTotal(int channel = 0) const;
197
199
200 protected:
201
202 //
203 // Lower level protected methods intended strictly for internal use:
204 //
205 template <class MESH>
206 friend class TopologyRefinerFactory;
207 friend class TopologyRefinerFactoryBase;
208 friend class PatchTableBuilder;
209 friend class PatchBuilder;
210 friend class PtexIndices;
211 template <typename REAL>
212 friend class PrimvarRefinerReal;
213
214 // Copy constructor exposed via the factory class:
215 TopologyRefiner(TopologyRefiner const & source);
216
217 public:
218 // Levels and Refinements available internally (avoids need for more friends)
219 Vtr::internal::Level & getLevel(int l) { return *_levels[l]; }
220 Vtr::internal::Level const & getLevel(int l) const { return *_levels[l]; }
221
222 Vtr::internal::Refinement & getRefinement(int l) { return *_refinements[l]; }
223 Vtr::internal::Refinement const & getRefinement(int l) const { return *_refinements[l]; }
224
225 private:
226 // Not default constructible or copyable:
227 TopologyRefiner() : _uniformOptions(0), _adaptiveOptions(0) { }
228 TopologyRefiner & operator=(TopologyRefiner const &) { return *this; }
229
230 void selectFeatureAdaptiveComponents(Vtr::internal::SparseSelector& selector,
231 internal::FeatureMask const & mask,
232 ConstIndexArray selectedFaces);
233 void selectLinearIrregularFaces(Vtr::internal::SparseSelector& selector,
234 ConstIndexArray selectedFaces);
235
236 void initializeInventory();
237 void updateInventory(Vtr::internal::Level const & newLevel);
238
239 void appendLevel(Vtr::internal::Level & newLevel);
240 void appendRefinement(Vtr::internal::Refinement & newRefinement);
241 void assembleFarLevels();
242
243 private:
244
245 Sdc::SchemeType _subdivType;
246 Sdc::Options _subdivOptions;
247
248 unsigned int _isUniform : 1;
249 unsigned int _hasHoles : 1;
250 unsigned int _hasIrregFaces : 1;
251 unsigned int _regFaceSize : 3;
252 unsigned int _maxLevel : 4;
253
254 // Options assigned on refinement:
255 UniformOptions _uniformOptions;
256 AdaptiveOptions _adaptiveOptions;
257
258 // Cumulative properties of all levels:
259 int _totalVertices;
260 int _totalEdges;
261 int _totalFaces;
262 int _totalFaceVertices;
263 int _maxValence;
264
265 // Note the base level may be shared with another instance
266 bool _baseLevelOwned;
267
268 std::vector<Vtr::internal::Level *> _levels;
269 std::vector<Vtr::internal::Refinement *> _refinements;
270
271 std::vector<TopologyLevel> _farLevels;
272};
273
274
275 inline int
276 TopologyRefiner::GetNumFVarChannels() const {
277
278 return _levels[0]->getNumFVarChannels();
279}
280 inline Sdc::Options::FVarLinearInterpolation
281 TopologyRefiner::GetFVarLinearInterpolation(int channel) const {
282
283 return _levels[0]->getFVarOptions(channel).GetFVarLinearInterpolation();
284}
285
286} // end namespace Far
287
288} // end namespace OPENSUBDIV_VERSION
289 using namespace OPENSUBDIV_VERSION;
290} // end namespace OpenSubdiv
291
292#endif /* OPENSUBDIV3_FAR_TOPOLOGY_REFINER_H */
topologyLevel.h
options.h
OpenSubdiv
Definition limits.h:15
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:16
OpenSubdiv::OPENSUBDIV_VERSION::Far
Definition refinerSurfaceFactory.h:19
OpenSubdiv::OPENSUBDIV_VERSION::Far::ConstIndexArray
Vtr::ConstIndexArray ConstIndexArray
Definition types.h:30
OpenSubdiv::OPENSUBDIV_VERSION::Vtr
Definition topologyRefiner.h:23
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::SchemeType
SchemeType
Enumerated type for all subdivision schemes supported by OpenSubdiv.
Definition types.h:20
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyLevel
An interface for accessing data in a specific level of a refined topology hierarchy.
Definition topologyLevel.h:32
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:60
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::getLevel
Vtr::internal::Level const & getLevel(int l) const
Definition topologyRefiner.h:220
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::HasHoles
bool HasHoles() const
Returns true if faces have been tagged as holes.
Definition topologyRefiner.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumLevels
int GetNumLevels() const
Returns the number of refinement levels.
Definition topologyRefiner.h:54
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::PrimvarRefinerReal
friend class PrimvarRefinerReal
Definition topologyRefiner.h:212
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:210
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::getRefinement
Vtr::internal::Refinement const & getRefinement(int l) const
Definition topologyRefiner.h:223
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetSchemeOptions
Sdc::Options GetSchemeOptions() const
Returns the subdivision options.
Definition topologyRefiner.h:48
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::getLevel
Vtr::internal::Level & getLevel(int l)
Definition topologyRefiner.h:219
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::IsUniform
bool IsUniform() const
Returns true if uniform refinement has been applied.
Definition topologyRefiner.h:51
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetSchemeType
Sdc::SchemeType GetSchemeType() const
Returns the subdivision scheme.
Definition topologyRefiner.h:45
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::TopologyRefinerFactoryBase
friend class TopologyRefinerFactoryBase
Definition topologyRefiner.h:207
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetMaxLevel
int GetMaxLevel() const
Returns the highest level of refinement.
Definition topologyRefiner.h:57
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::TopologyRefinerFactory
friend class TopologyRefinerFactory
Definition topologyRefiner.h:206
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:69
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::PatchBuilder
friend class PatchBuilder
Definition topologyRefiner.h:209
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumFVarChannels
int GetNumFVarChannels() const
Returns the number of face-varying channels in the tables.
Definition topologyRefiner.h:276
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetUniformOptions
UniformOptions GetUniformOptions() const
Returns the options specified on refinement.
Definition topologyRefiner.h:132
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumFacesTotal
int GetNumFacesTotal() const
Returns the total number of edges in all levels.
Definition topologyRefiner.h:72
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumFaceVerticesTotal
int GetNumFaceVerticesTotal() const
Returns the total number of face vertices in all levels.
Definition topologyRefiner.h:75
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::getRefinement
Vtr::internal::Refinement & getRefinement(int l)
Definition topologyRefiner.h:222
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:208
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:78
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::GetNumVerticesTotal
int GetNumVerticesTotal() const
Returns the total number of vertices in all levels.
Definition topologyRefiner.h:66
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:179
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:281
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:101
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:113
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::UniformOptions::SetRefinementLevel
void SetRefinementLevel(int level)
Set uniform refinement level.
Definition topologyRefiner.h:109
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::UniformOptions::fullTopologyInLastLevel
unsigned int fullTopologyInLastLevel
Definition topologyRefiner.h:114
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::UniformOptions::UniformOptions
UniformOptions(int level)
Definition topologyRefiner.h:103
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions
Adaptive refinement options.
Definition topologyRefiner.h:139
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::secondaryLevel
unsigned int secondaryLevel
Definition topologyRefiner.h:157
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::orderVerticesFromFacesFirst
unsigned int orderVerticesFromFacesFirst
Definition topologyRefiner.h:165
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::AdaptiveOptions
AdaptiveOptions(int level)
Definition topologyRefiner.h:141
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::isolationLevel
unsigned int isolationLevel
Definition topologyRefiner.h:155
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::useSingleCreasePatch
unsigned int useSingleCreasePatch
Definition topologyRefiner.h:159
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::useInfSharpPatch
unsigned int useInfSharpPatch
Definition topologyRefiner.h:161
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::SetIsolationLevel
void SetIsolationLevel(int level)
Set isolation level.
Definition topologyRefiner.h:150
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::considerFVarChannels
unsigned int considerFVarChannels
Definition topologyRefiner.h:163
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::SetSecondaryLevel
void SetSecondaryLevel(int level)
Set secondary isolation level.
Definition topologyRefiner.h:153
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Options
All supported options applying to subdivision scheme.
Definition options.h:34
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Options::FVarLinearInterpolation
FVarLinearInterpolation
Definition options.h:43
types.h
types.h