Loading...
Searching...
No Matches
topologyRefiner.h
Go to the documentation of this file.
//
// Copyright 2014 DreamWorks Animation LLC.
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#ifndef OPENSUBDIV3_FAR_TOPOLOGY_REFINER_H
#define OPENSUBDIV3_FAR_TOPOLOGY_REFINER_H
#include "../version.h"
#include "../sdc/types.h"
#include "../sdc/options.h"
#include "../far/types.h"
#include "../far/topologyLevel.h"
#include <vector>
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
namespace Vtr { namespace internal { class SparseSelector; } }
namespace Far { namespace internal { class FeatureMask; } }
namespace Far {
template <typename REAL> class PrimvarRefinerReal;
template <class MESH> class TopologyRefinerFactory;
class TopologyRefiner {
public:
TopologyRefiner(Sdc::SchemeType type, Sdc::Options options = Sdc::Options());
~TopologyRefiner();
Sdc::SchemeType GetSchemeType() const { return _subdivType; }
Sdc::Options GetSchemeOptions() const { return _subdivOptions; }
bool IsUniform() const { return _isUniform; }
int GetNumLevels() const { return (int)_farLevels.size(); }
int GetMaxLevel() const { return _maxLevel; }
int GetMaxValence() const { return _maxValence; }
bool HasHoles() const { return _hasHoles; }
int GetNumVerticesTotal() const { return _totalVertices; }
int GetNumEdgesTotal() const { return _totalEdges; }
int GetNumFacesTotal() const { return _totalFaces; }
int GetNumFaceVerticesTotal() const { return _totalFaceVertices; }
TopologyLevel const & GetLevel(int level) const { return _farLevels[level]; }
//
// Uniform refinement
//
struct UniformOptions {
UniformOptions(int level) :
refinementLevel(level & 0xf),
orderVerticesFromFacesFirst(false),
fullTopologyInLastLevel(false) { }
void SetRefinementLevel(int level) { refinementLevel = level & 0xf; }
unsigned int refinementLevel:4,
orderVerticesFromFacesFirst:1,
fullTopologyInLastLevel:1;
};
void RefineUniform(UniformOptions options);
UniformOptions GetUniformOptions() const { return _uniformOptions; }
//
// Adaptive refinement
//
struct AdaptiveOptions {
AdaptiveOptions(int level) :
isolationLevel(level & 0xf),
secondaryLevel(0xf),
useSingleCreasePatch(false),
useInfSharpPatch(false),
considerFVarChannels(false),
orderVerticesFromFacesFirst(false) { }
void SetIsolationLevel(int level) { isolationLevel = level & 0xf; }
void SetSecondaryLevel(int level) { secondaryLevel = level & 0xf; }
unsigned int isolationLevel:4;
unsigned int secondaryLevel:4;
unsigned int useSingleCreasePatch:1;
unsigned int useInfSharpPatch:1;
unsigned int considerFVarChannels:1;
unsigned int orderVerticesFromFacesFirst:1;
};
void RefineAdaptive(AdaptiveOptions options,
ConstIndexArray selectedFaces = ConstIndexArray());
AdaptiveOptions GetAdaptiveOptions() const { return _adaptiveOptions; }
void Unrefine();
int GetNumFVarChannels() const;
Sdc::Options::FVarLinearInterpolation GetFVarLinearInterpolation(int channel = 0) const;
int GetNumFVarValuesTotal(int channel = 0) const;
protected:
//
// Lower level protected methods intended strictly for internal use:
//
template <class MESH>
friend class TopologyRefinerFactory;
friend class TopologyRefinerFactoryBase;
friend class PatchTableBuilder;
friend class PatchBuilder;
friend class PtexIndices;
template <typename REAL>
friend class PrimvarRefinerReal;
// Copy constructor exposed via the factory class:
TopologyRefiner(TopologyRefiner const & source);
public:
// Levels and Refinements available internally (avoids need for more friends)
Vtr::internal::Level & getLevel(int l) { return *_levels[l]; }
Vtr::internal::Level const & getLevel(int l) const { return *_levels[l]; }
Vtr::internal::Refinement & getRefinement(int l) { return *_refinements[l]; }
Vtr::internal::Refinement const & getRefinement(int l) const { return *_refinements[l]; }
private:
// Not default constructible or copyable:
TopologyRefiner() : _uniformOptions(0), _adaptiveOptions(0) { }
TopologyRefiner & operator=(TopologyRefiner const &) { return *this; }
void selectFeatureAdaptiveComponents(Vtr::internal::SparseSelector& selector,
internal::FeatureMask const & mask,
ConstIndexArray selectedFaces);
void selectLinearIrregularFaces(Vtr::internal::SparseSelector& selector,
ConstIndexArray selectedFaces);
void initializeInventory();
void updateInventory(Vtr::internal::Level const & newLevel);
void appendLevel(Vtr::internal::Level & newLevel);
void appendRefinement(Vtr::internal::Refinement & newRefinement);
void assembleFarLevels();
private:
Sdc::SchemeType _subdivType;
Sdc::Options _subdivOptions;
unsigned int _isUniform : 1;
unsigned int _hasHoles : 1;
unsigned int _hasIrregFaces : 1;
unsigned int _regFaceSize : 3;
unsigned int _maxLevel : 4;
// Options assigned on refinement:
UniformOptions _uniformOptions;
AdaptiveOptions _adaptiveOptions;
// Cumulative properties of all levels:
int _totalVertices;
int _totalEdges;
int _totalFaces;
int _totalFaceVertices;
int _maxValence;
// Note the base level may be shared with another instance
bool _baseLevelOwned;
std::vector<Vtr::internal::Level *> _levels;
std::vector<Vtr::internal::Refinement *> _refinements;
std::vector<TopologyLevel> _farLevels;
};
inline int
TopologyRefiner::GetNumFVarChannels() const {
return _levels[0]->getNumFVarChannels();
}
inline Sdc::Options::FVarLinearInterpolation
TopologyRefiner::GetFVarLinearInterpolation(int channel) const {
return _levels[0]->getFVarOptions(channel).GetFVarLinearInterpolation();
}
} // end namespace Far
} // end namespace OPENSUBDIV_VERSION
using namespace OPENSUBDIV_VERSION;
} // end namespace OpenSubdiv
#endif /* OPENSUBDIV3_FAR_TOPOLOGY_REFINER_H */
options.h
topologyLevel.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