24#ifndef OPENSUBDIV3_VTR_REFINEMENT_H
25#define OPENSUBDIV3_VTR_REFINEMENT_H
27#include "../version.h"
29#include "../sdc/types.h"
30#include "../sdc/options.h"
31#include "../vtr/types.h"
32#include "../vtr/level.h"
40namespace OPENSUBDIV_VERSION {
72 Refinement(Level
const & parent, Level & child, Sdc::Options
const& schemeOptions);
73 virtual ~Refinement();
75 Level
const& parent()
const {
return *_parent; }
76 Level
const& child()
const {
return *_child; }
77 Level& child() {
return *_child; }
79 Sdc::Split getSplitType()
const {
return _splitType; }
80 int getRegularFaceSize()
const {
return _regFaceSize; }
81 Sdc::Options getOptions()
const {
return _options; }
84 int getNumFVarChannels()
const {
return (
int) _fvarChannels.size(); }
86 FVarRefinement
const & getFVarRefinement(
int c)
const {
return *_fvarChannels[c]; }
108 Options() : _sparse(false),
109 _faceVertsFirst(false),
110 _minimalTopology(false)
113 unsigned int _sparse : 1;
114 unsigned int _faceVertsFirst : 1;
115 unsigned int _minimalTopology : 1;
121 void refine(Options options = Options());
123 bool hasFaceVerticesFirst()
const {
return _faceVertsFirst; }
130 int getNumChildFacesFromFaces()
const {
return _childFaceFromFaceCount; }
131 int getNumChildEdgesFromFaces()
const {
return _childEdgeFromFaceCount; }
132 int getNumChildEdgesFromEdges()
const {
return _childEdgeFromEdgeCount; }
133 int getNumChildVerticesFromFaces()
const {
return _childVertFromFaceCount; }
134 int getNumChildVerticesFromEdges()
const {
return _childVertFromEdgeCount; }
135 int getNumChildVerticesFromVertices()
const {
return _childVertFromVertCount; }
137 Index getFirstChildFaceFromFaces()
const {
return _firstChildFaceFromFace; }
138 Index getFirstChildEdgeFromFaces()
const {
return _firstChildEdgeFromFace; }
139 Index getFirstChildEdgeFromEdges()
const {
return _firstChildEdgeFromEdge; }
140 Index getFirstChildVertexFromFaces()
const {
return _firstChildVertFromFace; }
141 Index getFirstChildVertexFromEdges()
const {
return _firstChildVertFromEdge; }
142 Index getFirstChildVertexFromVertices()
const {
return _firstChildVertFromVert; }
144 Index getFaceChildVertex(
Index f)
const {
return _faceChildVertIndex[f]; }
145 Index getEdgeChildVertex(
Index e)
const {
return _edgeChildVertIndex[e]; }
146 Index getVertexChildVertex(
Index v)
const {
return _vertChildVertIndex[v]; }
153 bool isChildVertexComplete(
Index v)
const {
return ! _childVertexTag[v]._incomplete; }
155 Index getChildFaceParentFace(
Index f)
const {
return _childFaceParentIndex[f]; }
156 int getChildFaceInParentFace(
Index f)
const {
return _childFaceTag[f]._indexInParent; }
158 Index getChildEdgeParentIndex(
Index e)
const {
return _childEdgeParentIndex[e]; }
160 Index getChildVertexParentIndex(
Index v)
const {
return _childVertexParentIndex[v]; }
190 SparseTag() : _selected(0), _transitional(0) { }
192 unsigned char _selected : 1;
193 unsigned char _transitional : 4;
199 unsigned char _incomplete : 1;
200 unsigned char _parentType : 2;
201 unsigned char _indexInParent : 2;
205 SparseTag
const & getParentFaceSparseTag(
Index f)
const {
return _parentFaceTag[f]; }
206 SparseTag
const & getParentEdgeSparseTag(
Index e)
const {
return _parentEdgeTag[e]; }
207 SparseTag
const & getParentVertexSparseTag(
Index v)
const {
return _parentVertexTag[v]; }
209 SparseTag & getParentFaceSparseTag(
Index f) {
return _parentFaceTag[f]; }
210 SparseTag & getParentEdgeSparseTag(
Index e) {
return _parentEdgeTag[e]; }
211 SparseTag & getParentVertexSparseTag(
Index v) {
return _parentVertexTag[v]; }
213 ChildTag
const & getChildFaceTag(
Index f)
const {
return _childFaceTag[f]; }
214 ChildTag
const & getChildEdgeTag(
Index e)
const {
return _childEdgeTag[e]; }
215 ChildTag
const & getChildVertexTag(
Index v)
const {
return _childVertexTag[v]; }
217 ChildTag & getChildFaceTag(
Index f) {
return _childFaceTag[f]; }
218 ChildTag & getChildEdgeTag(
Index e) {
return _childEdgeTag[e]; }
219 ChildTag & getChildVertexTag(
Index v) {
return _childVertexTag[v]; }
227 void populateParentToChildMapping();
228 void populateParentChildIndices();
229 void printParentToChildMapping()
const;
231 virtual void allocateParentChildIndices() = 0;
234 void initializeSparseSelectionTags();
235 void markSparseChildComponentIndices();
236 void markSparseVertexChildren();
237 void markSparseEdgeChildren();
239 virtual void markSparseFaceChildren() = 0;
241 void initializeChildComponentCounts();
246 void populateChildToParentMapping();
248 void populateFaceParentVectors(ChildTag
const initialChildTags[2][4]);
249 void populateFaceParentFromParentFaces(ChildTag
const initialChildTags[2][4]);
251 void populateEdgeParentVectors(ChildTag
const initialChildTags[2][4]);
252 void populateEdgeParentFromParentFaces(ChildTag
const initialChildTags[2][4]);
253 void populateEdgeParentFromParentEdges(ChildTag
const initialChildTags[2][4]);
255 void populateVertexParentVectors(ChildTag
const initialChildTags[2][4]);
256 void populateVertexParentFromParentFaces(ChildTag
const initialChildTags[2][4]);
257 void populateVertexParentFromParentEdges(ChildTag
const initialChildTags[2][4]);
258 void populateVertexParentFromParentVertices(ChildTag
const initialChildTags[2][4]);
263 void propagateComponentTags();
265 void populateFaceTagVectors();
266 void populateFaceTagsFromParentFaces();
268 void populateEdgeTagVectors();
269 void populateEdgeTagsFromParentFaces();
270 void populateEdgeTagsFromParentEdges();
272 void populateVertexTagVectors();
273 void populateVertexTagsFromParentFaces();
274 void populateVertexTagsFromParentEdges();
275 void populateVertexTagsFromParentVertices();
282 unsigned int _faceVertices : 1;
283 unsigned int _faceEdges : 1;
284 unsigned int _edgeVertices : 1;
285 unsigned int _edgeFaces : 1;
286 unsigned int _vertexFaces : 1;
287 unsigned int _vertexEdges : 1;
289 void setAll(
bool enable) {
290 _faceVertices = enable;
292 _edgeVertices = enable;
294 _vertexFaces = enable;
295 _vertexEdges = enable;
299 void subdivideTopology(Relations
const& relationsToSubdivide);
301 virtual void populateFaceVertexRelation() = 0;
302 virtual void populateFaceEdgeRelation() = 0;
303 virtual void populateEdgeVertexRelation() = 0;
304 virtual void populateEdgeFaceRelation() = 0;
305 virtual void populateVertexFaceRelation() = 0;
306 virtual void populateVertexEdgeRelation() = 0;
311 void subdivideSharpnessValues();
313 void subdivideVertexSharpness();
314 void subdivideEdgeSharpness();
315 void reclassifySemisharpVertices();
320 void subdivideFVarChannels();
324 friend void Level::print(
const Refinement *)
const;
332 Level
const * _parent;
334 Sdc::Options _options;
342 bool _faceVertsFirst;
347 int _childFaceFromFaceCount;
348 int _childEdgeFromFaceCount;
349 int _childEdgeFromEdgeCount;
350 int _childVertFromFaceCount;
351 int _childVertFromEdgeCount;
352 int _childVertFromVertCount;
354 int _firstChildFaceFromFace;
355 int _firstChildEdgeFromFace;
356 int _firstChildEdgeFromEdge;
357 int _firstChildVertFromFace;
358 int _firstChildVertFromEdge;
359 int _firstChildVertFromVert;
393 std::vector<ChildTag> _childFaceTag;
394 std::vector<ChildTag> _childEdgeTag;
395 std::vector<ChildTag> _childVertexTag;
400 std::vector<SparseTag> _parentFaceTag;
401 std::vector<SparseTag> _parentEdgeTag;
402 std::vector<SparseTag> _parentVertexTag;
407 std::vector<FVarRefinement*> _fvarChannels;
411Refinement::getFaceChildFaces(
Index parentFace)
const {
413 return ConstIndexArray(&_faceChildFaceIndices[_faceChildFaceCountsAndOffsets[2*parentFace+1]],
414 _faceChildFaceCountsAndOffsets[2*parentFace]);
418Refinement::getFaceChildFaces(
Index parentFace) {
420 return IndexArray(&_faceChildFaceIndices[_faceChildFaceCountsAndOffsets[2*parentFace+1]],
421 _faceChildFaceCountsAndOffsets[2*parentFace]);
425Refinement::getFaceChildEdges(
Index parentFace)
const {
427 return ConstIndexArray(&_faceChildEdgeIndices[_faceChildEdgeCountsAndOffsets[2*parentFace+1]],
428 _faceChildEdgeCountsAndOffsets[2*parentFace]);
431Refinement::getFaceChildEdges(
Index parentFace) {
433 return IndexArray(&_faceChildEdgeIndices[_faceChildEdgeCountsAndOffsets[2*parentFace+1]],
434 _faceChildEdgeCountsAndOffsets[2*parentFace]);
438Refinement::getEdgeChildEdges(
Index parentEdge)
const {
444Refinement::getEdgeChildEdges(
Index parentEdge) {
446 return IndexArray(&_edgeChildEdgeIndices[parentEdge*2], 2);
453using namespace OPENSUBDIV_VERSION;
std::vector< Index > IndexVector
ConstArray< Index > ConstIndexArray
Array< Index > IndexArray
Split
Enumerated type for all face splitting schemes.