2014-09-05 22:07:46 +00:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
2015-05-19 18:22:37 +00:00
|
|
|
#ifndef OPENSUBDIV3_VTR_SPARSE_SELECTOR_H
|
|
|
|
#define OPENSUBDIV3_VTR_SPARSE_SELECTOR_H
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
#include "../version.h"
|
|
|
|
|
|
|
|
#include "../vtr/types.h"
|
|
|
|
#include "../vtr/refinement.h"
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace OpenSubdiv {
|
|
|
|
namespace OPENSUBDIV_VERSION {
|
|
|
|
|
|
|
|
namespace Vtr {
|
2015-05-26 03:34:50 +00:00
|
|
|
namespace internal {
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
//
|
|
|
|
// SparseSelector:
|
2014-09-24 01:24:29 +00:00
|
|
|
// Class supporting "selection" of components in a Level for sparse Refinement.
|
|
|
|
// The term "selection" here implies interest in the limit for that component, i.e.
|
|
|
|
// the limit point for a selected vertex, the limit patch for a face, etc. So this
|
|
|
|
// class is responsible for ensuring that all neighboring components required to
|
|
|
|
// support the limit of those selected are included in the refinement.
|
2014-09-05 22:07:46 +00:00
|
|
|
//
|
2014-09-24 01:24:29 +00:00
|
|
|
// This class is associated with (and constructed given) a Refinement and its role
|
|
|
|
// is to initialize that Refinement instance for eventual sparse refinement. So it
|
|
|
|
// is a friend of and expected to modify the Refinement as part of the selection.
|
|
|
|
// Given its simplicity and scope it may be worth nesting it in Vtr::Refinement.
|
2014-09-05 22:07:46 +00:00
|
|
|
//
|
2014-09-24 01:24:29 +00:00
|
|
|
// While all three component types -- vertices, edges and faces -- can be selected,
|
|
|
|
// only selection of faces is currently used and actively supported as part of the
|
|
|
|
// feature-adaptive refinement.
|
2014-09-05 22:07:46 +00:00
|
|
|
//
|
|
|
|
class SparseSelector {
|
|
|
|
|
|
|
|
public:
|
2014-09-24 01:24:29 +00:00
|
|
|
SparseSelector(Refinement& refine) : _refine(&refine), _selected(false) { }
|
2014-09-05 22:07:46 +00:00
|
|
|
~SparseSelector() { }
|
|
|
|
|
2014-09-24 01:24:29 +00:00
|
|
|
void setRefinement(Refinement& refine) { _refine = &refine; }
|
|
|
|
Refinement& getRefinement() const { return *_refine; }
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2014-09-24 01:24:29 +00:00
|
|
|
bool isSelectionEmpty() const { return !_selected; }
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Methods for selecting (and marking) components for refinement. All component indices
|
|
|
|
// refer to components in the parent:
|
|
|
|
//
|
|
|
|
void selectVertex(Index pVertex);
|
|
|
|
void selectEdge( Index pEdge);
|
|
|
|
void selectFace( Index pFace);
|
|
|
|
|
|
|
|
private:
|
2014-09-24 01:24:29 +00:00
|
|
|
SparseSelector() : _refine(0), _selected(false) { }
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2015-06-02 00:38:11 +00:00
|
|
|
bool wasVertexSelected(Index pVertex) const { return _refine->getParentVertexSparseTag(pVertex)._selected; }
|
|
|
|
bool wasEdgeSelected( Index pEdge) const { return _refine->getParentEdgeSparseTag(pEdge)._selected; }
|
|
|
|
bool wasFaceSelected( Index pFace) const { return _refine->getParentFaceSparseTag(pFace)._selected; }
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2015-06-02 00:38:11 +00:00
|
|
|
void markVertexSelected(Index pVertex) const { _refine->getParentVertexSparseTag(pVertex)._selected = true; }
|
|
|
|
void markEdgeSelected( Index pEdge) const { _refine->getParentEdgeSparseTag(pEdge)._selected = true; }
|
|
|
|
void markFaceSelected( Index pFace) const { _refine->getParentFaceSparseTag(pFace)._selected = true; }
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2014-09-24 01:24:29 +00:00
|
|
|
void initializeSelection();
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
private:
|
2014-09-24 01:24:29 +00:00
|
|
|
Refinement* _refine;
|
|
|
|
bool _selected;
|
2014-09-05 22:07:46 +00:00
|
|
|
};
|
|
|
|
|
2015-05-26 03:34:50 +00:00
|
|
|
} // end namespace internal
|
2014-09-05 22:07:46 +00:00
|
|
|
} // end namespace Vtr
|
|
|
|
|
|
|
|
} // end namespace OPENSUBDIV_VERSION
|
|
|
|
using namespace OPENSUBDIV_VERSION;
|
|
|
|
} // end namespace OpenSubdiv
|
|
|
|
|
2015-05-19 18:22:37 +00:00
|
|
|
#endif /* OPENSUBDIV3_VTR_SPARSE_SELECTOR_H */
|