7#ifndef OPENSUBDIV3_VTR_REFINEMENT_H
8#define OPENSUBDIV3_VTR_REFINEMENT_H
10#include "../version.h"
23namespace OPENSUBDIV_VERSION {
55 Refinement(Level
const & parent, Level & child, Sdc::Options
const& schemeOptions);
56 virtual ~Refinement();
58 Level
const& parent()
const {
return *_parent; }
59 Level
const& child()
const {
return *_child; }
60 Level& child() {
return *_child; }
62 Sdc::Split getSplitType()
const {
return _splitType; }
63 int getRegularFaceSize()
const {
return _regFaceSize; }
64 Sdc::Options getOptions()
const {
return _options; }
67 int getNumFVarChannels()
const {
return (
int) _fvarChannels.size(); }
69 FVarRefinement
const & getFVarRefinement(
int c)
const {
return *_fvarChannels[c]; }
91 Options() : _sparse(false),
92 _faceVertsFirst(false),
93 _minimalTopology(false)
96 unsigned int _sparse : 1;
97 unsigned int _faceVertsFirst : 1;
98 unsigned int _minimalTopology : 1;
104 void refine(Options options = Options());
106 bool hasFaceVerticesFirst()
const {
return _faceVertsFirst; }
113 int getNumChildFacesFromFaces()
const {
return _childFaceFromFaceCount; }
114 int getNumChildEdgesFromFaces()
const {
return _childEdgeFromFaceCount; }
115 int getNumChildEdgesFromEdges()
const {
return _childEdgeFromEdgeCount; }
116 int getNumChildVerticesFromFaces()
const {
return _childVertFromFaceCount; }
117 int getNumChildVerticesFromEdges()
const {
return _childVertFromEdgeCount; }
118 int getNumChildVerticesFromVertices()
const {
return _childVertFromVertCount; }
120 Index getFirstChildFaceFromFaces()
const {
return _firstChildFaceFromFace; }
121 Index getFirstChildEdgeFromFaces()
const {
return _firstChildEdgeFromFace; }
122 Index getFirstChildEdgeFromEdges()
const {
return _firstChildEdgeFromEdge; }
123 Index getFirstChildVertexFromFaces()
const {
return _firstChildVertFromFace; }
124 Index getFirstChildVertexFromEdges()
const {
return _firstChildVertFromEdge; }
125 Index getFirstChildVertexFromVertices()
const {
return _firstChildVertFromVert; }
127 Index getFaceChildVertex(
Index f)
const {
return _faceChildVertIndex[f]; }
128 Index getEdgeChildVertex(
Index e)
const {
return _edgeChildVertIndex[e]; }
129 Index getVertexChildVertex(
Index v)
const {
return _vertChildVertIndex[v]; }
136 bool isChildVertexComplete(
Index v)
const {
return ! _childVertexTag[v]._incomplete; }
138 Index getChildFaceParentFace(
Index f)
const {
return _childFaceParentIndex[f]; }
139 int getChildFaceInParentFace(
Index f)
const {
return _childFaceTag[f]._indexInParent; }
141 Index getChildEdgeParentIndex(
Index e)
const {
return _childEdgeParentIndex[e]; }
143 Index getChildVertexParentIndex(
Index v)
const {
return _childVertexParentIndex[v]; }
173 SparseTag() : _selected(0), _transitional(0) { }
175 unsigned char _selected : 1;
176 unsigned char _transitional : 4;
182 unsigned char _incomplete : 1;
183 unsigned char _parentType : 2;
184 unsigned char _indexInParent : 2;
188 SparseTag
const & getParentFaceSparseTag(
Index f)
const {
return _parentFaceTag[f]; }
189 SparseTag
const & getParentEdgeSparseTag(
Index e)
const {
return _parentEdgeTag[e]; }
190 SparseTag
const & getParentVertexSparseTag(
Index v)
const {
return _parentVertexTag[v]; }
192 SparseTag & getParentFaceSparseTag(
Index f) {
return _parentFaceTag[f]; }
193 SparseTag & getParentEdgeSparseTag(
Index e) {
return _parentEdgeTag[e]; }
194 SparseTag & getParentVertexSparseTag(
Index v) {
return _parentVertexTag[v]; }
196 ChildTag
const & getChildFaceTag(
Index f)
const {
return _childFaceTag[f]; }
197 ChildTag
const & getChildEdgeTag(
Index e)
const {
return _childEdgeTag[e]; }
198 ChildTag
const & getChildVertexTag(
Index v)
const {
return _childVertexTag[v]; }
200 ChildTag & getChildFaceTag(
Index f) {
return _childFaceTag[f]; }
201 ChildTag & getChildEdgeTag(
Index e) {
return _childEdgeTag[e]; }
202 ChildTag & getChildVertexTag(
Index v) {
return _childVertexTag[v]; }
210 void populateParentToChildMapping();
211 void populateParentChildIndices();
212 void printParentToChildMapping()
const;
214 virtual void allocateParentChildIndices() = 0;
217 void initializeSparseSelectionTags();
218 void markSparseChildComponentIndices();
219 void markSparseVertexChildren();
220 void markSparseEdgeChildren();
222 virtual void markSparseFaceChildren() = 0;
224 void initializeChildComponentCounts();
229 void populateChildToParentMapping();
231 void populateFaceParentVectors(ChildTag
const initialChildTags[2][4]);
232 void populateFaceParentFromParentFaces(ChildTag
const initialChildTags[2][4]);
234 void populateEdgeParentVectors(ChildTag
const initialChildTags[2][4]);
235 void populateEdgeParentFromParentFaces(ChildTag
const initialChildTags[2][4]);
236 void populateEdgeParentFromParentEdges(ChildTag
const initialChildTags[2][4]);
238 void populateVertexParentVectors(ChildTag
const initialChildTags[2][4]);
239 void populateVertexParentFromParentFaces(ChildTag
const initialChildTags[2][4]);
240 void populateVertexParentFromParentEdges(ChildTag
const initialChildTags[2][4]);
241 void populateVertexParentFromParentVertices(ChildTag
const initialChildTags[2][4]);
246 void propagateComponentTags();
248 void populateFaceTagVectors();
249 void populateFaceTagsFromParentFaces();
251 void populateEdgeTagVectors();
252 void populateEdgeTagsFromParentFaces();
253 void populateEdgeTagsFromParentEdges();
255 void populateVertexTagVectors();
256 void populateVertexTagsFromParentFaces();
257 void populateVertexTagsFromParentEdges();
258 void populateVertexTagsFromParentVertices();
265 unsigned int _faceVertices : 1;
266 unsigned int _faceEdges : 1;
267 unsigned int _edgeVertices : 1;
268 unsigned int _edgeFaces : 1;
269 unsigned int _vertexFaces : 1;
270 unsigned int _vertexEdges : 1;
272 void setAll(
bool enable) {
273 _faceVertices = enable;
275 _edgeVertices = enable;
277 _vertexFaces = enable;
278 _vertexEdges = enable;
282 void subdivideTopology(Relations
const& relationsToSubdivide);
284 virtual void populateFaceVertexRelation() = 0;
285 virtual void populateFaceEdgeRelation() = 0;
286 virtual void populateEdgeVertexRelation() = 0;
287 virtual void populateEdgeFaceRelation() = 0;
288 virtual void populateVertexFaceRelation() = 0;
289 virtual void populateVertexEdgeRelation() = 0;
294 void subdivideSharpnessValues();
296 void subdivideVertexSharpness();
297 void subdivideEdgeSharpness();
298 void reclassifySemisharpVertices();
303 void subdivideFVarChannels();
307 friend void Level::print(
const Refinement *)
const;
315 Level
const * _parent;
317 Sdc::Options _options;
325 bool _faceVertsFirst;
330 int _childFaceFromFaceCount;
331 int _childEdgeFromFaceCount;
332 int _childEdgeFromEdgeCount;
333 int _childVertFromFaceCount;
334 int _childVertFromEdgeCount;
335 int _childVertFromVertCount;
337 int _firstChildFaceFromFace;
338 int _firstChildEdgeFromFace;
339 int _firstChildEdgeFromEdge;
340 int _firstChildVertFromFace;
341 int _firstChildVertFromEdge;
342 int _firstChildVertFromVert;
376 std::vector<ChildTag> _childFaceTag;
377 std::vector<ChildTag> _childEdgeTag;
378 std::vector<ChildTag> _childVertexTag;
383 std::vector<SparseTag> _parentFaceTag;
384 std::vector<SparseTag> _parentEdgeTag;
385 std::vector<SparseTag> _parentVertexTag;
390 std::vector<FVarRefinement*> _fvarChannels;
394Refinement::getFaceChildFaces(
Index parentFace)
const {
396 return ConstIndexArray(&_faceChildFaceIndices[_faceChildFaceCountsAndOffsets[2*parentFace+1]],
397 _faceChildFaceCountsAndOffsets[2*parentFace]);
401Refinement::getFaceChildFaces(
Index parentFace) {
403 return IndexArray(&_faceChildFaceIndices[_faceChildFaceCountsAndOffsets[2*parentFace+1]],
404 _faceChildFaceCountsAndOffsets[2*parentFace]);
408Refinement::getFaceChildEdges(
Index parentFace)
const {
410 return ConstIndexArray(&_faceChildEdgeIndices[_faceChildEdgeCountsAndOffsets[2*parentFace+1]],
411 _faceChildEdgeCountsAndOffsets[2*parentFace]);
414Refinement::getFaceChildEdges(
Index parentFace) {
416 return IndexArray(&_faceChildEdgeIndices[_faceChildEdgeCountsAndOffsets[2*parentFace+1]],
417 _faceChildEdgeCountsAndOffsets[2*parentFace]);
421Refinement::getEdgeChildEdges(
Index parentEdge)
const {
427Refinement::getEdgeChildEdges(
Index parentEdge) {
429 return IndexArray(&_edgeChildEdgeIndices[parentEdge*2], 2);
436using namespace OPENSUBDIV_VERSION;
std::vector< Index > IndexVector
ConstArray< Index > ConstIndexArray
Array< Index > IndexArray
Split
Enumerated type for all face splitting schemes.