| OpenSubdiv

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 Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24#ifndef OPENSUBDIV3_VTR_SPARSE_SELECTOR_H
25#define OPENSUBDIV3_VTR_SPARSE_SELECTOR_H
26
27#include "../version.h"
28
29#include "../vtr/types.h"
30#include "../vtr/refinement.h"
31
32#include <vector>
33
34 namespace OpenSubdiv {
35 namespace OPENSUBDIV_VERSION {
36
37 namespace Vtr {
38 namespace internal {
39
40//
41// SparseSelector:
42// Class supporting "selection" of components in a Level for sparse Refinement.
43// The term "selection" here implies interest in the limit for that component, i.e.
44// the limit point for a selected vertex, the limit patch for a face, etc. So this
45// class is responsible for ensuring that all neighboring components required to
46// support the limit of those selected are included in the refinement.
47//
48// This class is associated with (and constructed given) a Refinement and its role
49// is to initialize that Refinement instance for eventual sparse refinement. So it
50// is a friend of and expected to modify the Refinement as part of the selection.
51// Given its simplicity and scope it may be worth nesting it in Vtr::Refinement.
52//
53// While all three component types -- vertices, edges and faces -- can be selected,
54// only selection of faces is currently used and actively supported as part of the
55// feature-adaptive refinement.
56//
57 class SparseSelector {
58
59 public:
60 SparseSelector(Refinement& refine) : _refine(&refine), _selected(false) { }
61 ~SparseSelector() { }
62
63 void setRefinement(Refinement& refine) { _refine = &refine; }
64 Refinement& getRefinement() const { return *_refine; }
65
66 bool isSelectionEmpty() const { return !_selected; }
67
68 //
69 // Methods for selecting (and marking) components for refinement. All component indices
70 // refer to components in the parent:
71 //
72 void selectVertex(Index pVertex);
73 void selectEdge( Index pEdge);
74 void selectFace( Index pFace);
75
76 private:
77 SparseSelector() : _refine(0), _selected(false) { }
78
79 bool wasVertexSelected(Index pVertex) const { return _refine->getParentVertexSparseTag(pVertex)._selected; }
80 bool wasEdgeSelected( Index pEdge) const { return _refine->getParentEdgeSparseTag(pEdge)._selected; }
81 bool wasFaceSelected( Index pFace) const { return _refine->getParentFaceSparseTag(pFace)._selected; }
82
83 void markVertexSelected(Index pVertex) const { _refine->getParentVertexSparseTag(pVertex)._selected = true; }
84 void markEdgeSelected( Index pEdge) const { _refine->getParentEdgeSparseTag(pEdge)._selected = true; }
85 void markFaceSelected( Index pFace) const { _refine->getParentFaceSparseTag(pFace)._selected = true; }
86
87 void initializeSelection();
88
89 private:
90 Refinement* _refine;
91 bool _selected;
92};
93
94} // end namespace internal
95} // end namespace Vtr
96
97} // end namespace OPENSUBDIV_VERSION
98 using namespace OPENSUBDIV_VERSION;
99} // end namespace OpenSubdiv
100
101#endif /* OPENSUBDIV3_VTR_SPARSE_SELECTOR_H */
refinement.h
OpenSubdiv
Definition error.h:30
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::Index
int Index
Definition types.h:54
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::Refinement
Definition refinement.h:69
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::Refinement::getParentFaceSparseTag
SparseTag const & getParentFaceSparseTag(Index f) const
Definition refinement.h:205
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::Refinement::getParentVertexSparseTag
SparseTag const & getParentVertexSparseTag(Index v) const
Definition refinement.h:207
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::Refinement::getParentEdgeSparseTag
SparseTag const & getParentEdgeSparseTag(Index e) const
Definition refinement.h:206
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::Refinement::SparseTag::_selected
unsigned char _selected
Definition refinement.h:192
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::SparseSelector
Definition sparseSelector.h:57
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::SparseSelector::~SparseSelector
~SparseSelector()
Definition sparseSelector.h:61
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::SparseSelector::selectFace
void selectFace(Index pFace)
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::SparseSelector::isSelectionEmpty
bool isSelectionEmpty() const
Definition sparseSelector.h:66
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::SparseSelector::getRefinement
Refinement & getRefinement() const
Definition sparseSelector.h:64
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::SparseSelector::setRefinement
void setRefinement(Refinement &refine)
Definition sparseSelector.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::SparseSelector::SparseSelector
SparseSelector(Refinement &refine)
Definition sparseSelector.h:60
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::SparseSelector::selectEdge
void selectEdge(Index pEdge)
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::SparseSelector::selectVertex
void selectVertex(Index pVertex)
types.h