2012-06-08 18:18:20 +00:00
|
|
|
//
|
2013-07-18 21:19:50 +00:00
|
|
|
// Copyright 2013 Pixar
|
2012-06-08 18:18:20 +00:00
|
|
|
//
|
2013-07-18 21:19:50 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License
|
|
|
|
// and the following modification to it: Section 6 Trademarks.
|
|
|
|
// deleted and replaced with:
|
2012-06-08 18:18:20 +00:00
|
|
|
//
|
2013-07-18 21:19:50 +00:00
|
|
|
// 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 for reproducing
|
|
|
|
// the content of the NOTICE file.
|
2012-06-08 18:18:20 +00:00
|
|
|
//
|
2013-07-18 21:19:50 +00:00
|
|
|
// You may obtain a copy of the License at
|
2012-06-08 18:18:20 +00:00
|
|
|
//
|
2013-07-18 21:19:50 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing,
|
|
|
|
// software distributed under the License is distributed on an
|
|
|
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
|
|
// either express or implied. See the License for the specific
|
|
|
|
// language governing permissions and limitations under the
|
|
|
|
// License.
|
2012-06-08 18:18:20 +00:00
|
|
|
//
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2012-06-08 18:18:20 +00:00
|
|
|
#ifndef FAR_MESH_H
|
|
|
|
#define FAR_MESH_H
|
|
|
|
|
|
|
|
#include "../version.h"
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2012-09-18 01:41:48 +00:00
|
|
|
#include "../far/subdivisionTables.h"
|
2012-12-11 01:15:13 +00:00
|
|
|
#include "../far/patchTables.h"
|
2012-09-18 01:41:48 +00:00
|
|
|
#include "../far/vertexEditTables.h"
|
2013-03-08 01:50:15 +00:00
|
|
|
#include "../far/kernelBatch.h"
|
2012-06-08 18:18:20 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#include <cassert>
|
|
|
|
#include <vector>
|
|
|
|
|
2012-06-08 18:18:20 +00:00
|
|
|
namespace OpenSubdiv {
|
|
|
|
namespace OPENSUBDIV_VERSION {
|
|
|
|
|
2012-10-07 00:53:51 +00:00
|
|
|
/// \brief Feature Adaptive Mesh class.
|
|
|
|
///
|
|
|
|
/// FarMesh is a serialized instantiation of an HbrMesh. The HbrMesh contains
|
|
|
|
/// all the topological data in a highly interconnected data structure for
|
|
|
|
/// ease of access and modification. When instantiating a FarMesh, the factory
|
|
|
|
/// analyzes this data structure and serializes the topology into a linear
|
|
|
|
/// buffers that are ready for efficient parallel processing.
|
2013-05-07 02:05:50 +00:00
|
|
|
///
|
2012-09-18 01:41:48 +00:00
|
|
|
template <class U> class FarMesh {
|
2012-06-08 18:18:20 +00:00
|
|
|
public:
|
2012-08-04 02:51:27 +00:00
|
|
|
|
2012-06-08 18:18:20 +00:00
|
|
|
~FarMesh();
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns the subdivision method
|
2012-12-11 01:15:13 +00:00
|
|
|
FarSubdivisionTables<U> const * GetSubdivisionTables() const { return _subdivisionTables; }
|
2012-06-08 18:18:20 +00:00
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns patch tables
|
2013-05-16 00:53:40 +00:00
|
|
|
FarPatchTables const * GetPatchTables() const { return _patchTables; }
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns the total number of vertices in the mesh across across all depths
|
2013-05-16 21:21:11 +00:00
|
|
|
int GetNumVertices() const { return GetSubdivisionTables()->GetNumVertices(); }
|
2013-05-16 00:53:40 +00:00
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns the list of vertices in the mesh (from subdiv level 0 to N)
|
2012-06-08 18:18:20 +00:00
|
|
|
std::vector<U> & GetVertices() { return _vertices; }
|
2012-08-04 02:51:27 +00:00
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns a reference to the vertex at the given index
|
2013-05-07 02:05:50 +00:00
|
|
|
///
|
|
|
|
/// @param index the index fo the vertex
|
|
|
|
///
|
2012-06-08 18:18:20 +00:00
|
|
|
U & GetVertex(int index) { return _vertices[index]; }
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns the width of the interleaved face-varying data
|
2012-12-11 01:15:13 +00:00
|
|
|
int GetTotalFVarWidth() const { return _totalFVarWidth; }
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns vertex edit tables
|
2012-09-18 01:41:48 +00:00
|
|
|
FarVertexEditTables<U> const * GetVertexEdit() const { return _vertexEditTables; }
|
2012-08-04 02:51:27 +00:00
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns the total number of vertices in the mesh across across all depths
|
2013-05-10 02:16:51 +00:00
|
|
|
int GetNumPtexFaces() const { return _numPtexFaces; }
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief True if the mesh tables support the feature-adaptive mode.
|
2013-05-16 00:53:40 +00:00
|
|
|
bool IsFeatureAdaptive() const { return _patchTables->IsFeatureAdaptive(); }
|
2013-03-23 01:20:50 +00:00
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns an ordered vector of batches of compute kernels.
|
|
|
|
/// The kernels describe the sequence of computations required to apply the
|
|
|
|
/// subdivision scheme to the vertices in the mesh.
|
2013-03-08 01:50:15 +00:00
|
|
|
const FarKernelBatchVector & GetKernelBatches() const { return _batches; }
|
2012-06-08 18:18:20 +00:00
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
private:
|
2012-09-18 01:41:48 +00:00
|
|
|
// Note : the vertex classes are renamed <X,Y> so as not to shadow the
|
|
|
|
// declaration of the templated vertex class U.
|
|
|
|
template <class X, class Y> friend class FarMeshFactory;
|
2013-03-08 01:50:15 +00:00
|
|
|
template <class X, class Y> friend class FarMultiMeshFactory;
|
2012-06-08 18:18:20 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
FarMesh() : _subdivisionTables(0), _patchTables(0), _vertexEditTables(0) { }
|
2012-06-08 18:18:20 +00:00
|
|
|
|
|
|
|
// non-copyable, so these are not implemented:
|
2012-09-18 01:41:48 +00:00
|
|
|
FarMesh(FarMesh<U> const &);
|
|
|
|
FarMesh<U> & operator = (FarMesh<U> const &);
|
2012-06-08 18:18:20 +00:00
|
|
|
|
|
|
|
// subdivision method used in this mesh
|
2012-09-18 01:41:48 +00:00
|
|
|
FarSubdivisionTables<U> * _subdivisionTables;
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
// tables of vertex indices for feature adaptive patches
|
|
|
|
FarPatchTables * _patchTables;
|
|
|
|
|
2012-09-18 01:41:48 +00:00
|
|
|
// hierarchical vertex edit tables
|
|
|
|
FarVertexEditTables<U> * _vertexEditTables;
|
2012-06-08 18:18:20 +00:00
|
|
|
|
2013-03-08 01:50:15 +00:00
|
|
|
// kernel execution batches
|
|
|
|
FarKernelBatchVector _batches;
|
|
|
|
|
2012-06-08 18:18:20 +00:00
|
|
|
// list of vertices (up to N levels of subdivision)
|
|
|
|
std::vector<U> _vertices;
|
|
|
|
|
2013-05-16 00:53:40 +00:00
|
|
|
int _totalFVarWidth; // width of the face-varying data
|
2013-05-10 02:16:51 +00:00
|
|
|
|
|
|
|
int _numPtexFaces;
|
2012-06-08 18:18:20 +00:00
|
|
|
};
|
|
|
|
|
2012-09-18 01:41:48 +00:00
|
|
|
template <class U>
|
|
|
|
FarMesh<U>::~FarMesh()
|
2012-08-04 02:51:27 +00:00
|
|
|
{
|
2012-09-18 01:41:48 +00:00
|
|
|
delete _subdivisionTables;
|
2012-12-11 01:15:13 +00:00
|
|
|
delete _patchTables;
|
2012-09-18 01:41:48 +00:00
|
|
|
delete _vertexEditTables;
|
2012-06-08 18:18:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace OPENSUBDIV_VERSION
|
|
|
|
using namespace OPENSUBDIV_VERSION;
|
|
|
|
|
|
|
|
} // end namespace OpenSubdiv
|
|
|
|
|
|
|
|
#endif /* FAR_MESH_H */
|