OpenSubdiv
Toggle main menu visibility
Loading...
Searching...
No Matches
sparseSelector.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_VTR_SPARSE_SELECTOR_H
8
#define OPENSUBDIV3_VTR_SPARSE_SELECTOR_H
9
10
#include "../version.h"
11
12
#include "
../vtr/types.h
"
13
#include "
../vtr/refinement.h
"
14
15
#include <vector>
16
17
namespace
OpenSubdiv
{
18
namespace
OPENSUBDIV_VERSION
{
19
20
namespace
Vtr
{
21
namespace
internal {
22
23
//
24
// SparseSelector:
25
// Class supporting "selection" of components in a Level for sparse Refinement.
26
// The term "selection" here implies interest in the limit for that component, i.e.
27
// the limit point for a selected vertex, the limit patch for a face, etc. So this
28
// class is responsible for ensuring that all neighboring components required to
29
// support the limit of those selected are included in the refinement.
30
//
31
// This class is associated with (and constructed given) a Refinement and its role
32
// is to initialize that Refinement instance for eventual sparse refinement. So it
33
// is a friend of and expected to modify the Refinement as part of the selection.
34
// Given its simplicity and scope it may be worth nesting it in Vtr::Refinement.
35
//
36
// While all three component types -- vertices, edges and faces -- can be selected,
37
// only selection of faces is currently used and actively supported as part of the
38
// feature-adaptive refinement.
39
//
40
class
SparseSelector {
41
42
public
:
43
SparseSelector(Refinement& refine) : _refine(&refine), _selected(false) { }
44
~SparseSelector() { }
45
46
void
setRefinement(Refinement& refine) { _refine = &refine; }
47
Refinement& getRefinement()
const
{
return
*_refine; }
48
49
bool
isSelectionEmpty()
const
{
return
!_selected; }
50
51
//
52
// Methods for selecting (and marking) components for refinement. All component indices
53
// refer to components in the parent:
54
//
55
void
selectVertex(
Index
pVertex);
56
void
selectEdge(
Index
pEdge);
57
void
selectFace(
Index
pFace);
58
59
private
:
60
SparseSelector() : _refine(0), _selected(false) { }
61
62
bool
wasVertexSelected(
Index
pVertex)
const
{
return
_refine->getParentVertexSparseTag(pVertex)._selected; }
63
bool
wasEdgeSelected(
Index
pEdge)
const
{
return
_refine->getParentEdgeSparseTag(pEdge)._selected; }
64
bool
wasFaceSelected(
Index
pFace)
const
{
return
_refine->getParentFaceSparseTag(pFace)._selected; }
65
66
void
markVertexSelected(
Index
pVertex)
const
{ _refine->getParentVertexSparseTag(pVertex)._selected =
true
; }
67
void
markEdgeSelected(
Index
pEdge)
const
{ _refine->getParentEdgeSparseTag(pEdge)._selected =
true
; }
68
void
markFaceSelected(
Index
pFace)
const
{ _refine->getParentFaceSparseTag(pFace)._selected =
true
; }
69
70
void
initializeSelection();
71
72
private
:
73
Refinement* _refine;
74
bool
_selected;
75
};
76
77
}
// end namespace internal
78
}
// end namespace Vtr
79
80
}
// end namespace OPENSUBDIV_VERSION
81
using namespace
OPENSUBDIV_VERSION
;
82
}
// end namespace OpenSubdiv
83
84
#endif
/* OPENSUBDIV3_VTR_SPARSE_SELECTOR_H */
refinement.h
OpenSubdiv
Definition
limits.h:15
OpenSubdiv::OPENSUBDIV_VERSION
Definition
limits.h:16
OpenSubdiv::OPENSUBDIV_VERSION::Vtr
Definition
topologyRefiner.h:23
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::Index
int Index
Definition
types.h:37
types.h
opensubdiv
vtr
sparseSelector.h
Generated on
for OpenSubdiv by
1.18.0