mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-12-12 20:10:12 +00:00
107 lines
3.2 KiB
C++
107 lines
3.2 KiB
C++
//
|
|
// Copyright 2013 Pixar
|
|
//
|
|
// 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.
|
|
//
|
|
|
|
#ifndef PX_OSD_UTIL_MESH_H
|
|
#define PX_OSD_UTIL_MESH_H
|
|
|
|
#include "topology.h"
|
|
|
|
#include "../version.h"
|
|
#include <string>
|
|
#include <map>
|
|
|
|
// We forward declare the HbrMesh templated class here to avoid including
|
|
// hbr headers. Keep the hbr inclusions in the .cpp files to avoid
|
|
// conflicts with the amber/lib version of hbr and to reduce included code
|
|
// complexity.
|
|
//
|
|
// Note that a client who wants to access the HbrMesh should include hbr/mesh.h
|
|
// like this:
|
|
// #define HBR_ADAPTIVE
|
|
// #include <opensubdiv/hbr/mesh.h>
|
|
//
|
|
namespace OpenSubdiv {
|
|
namespace OPENSUBDIV_VERSION {
|
|
template <class T> class HbrMesh;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
// This class is reponsible for taking a topological description of a mesh
|
|
// defined by PxOsdUtilSubdivTopology and turn that into a halfedge mesh
|
|
// with detailed connectivity information for mesh traversal. A PxOsdUtilMesh
|
|
// object is used for uniform and feature adaptive refinement of subdivision
|
|
// surfaces (subdivs), which is itself a requirement for fast run-time
|
|
// evaluation of subdivs.
|
|
//
|
|
template <class T>
|
|
class PxOsdUtilMesh {
|
|
public:
|
|
|
|
PxOsdUtilMesh();
|
|
|
|
bool Initialize(
|
|
const PxOsdUtilSubdivTopology &topology,
|
|
std::string *errorMessage = NULL);
|
|
|
|
~PxOsdUtilMesh();
|
|
|
|
// Fetch the face varying attribute values on refined quads
|
|
// Traverse the hbrMesh gathering face varying data created
|
|
// by a refiner.
|
|
// XXX: this assumes uniform subdivision, should be moved
|
|
// into uniformRefiner?
|
|
void GetRefinedFVData(int subdivisionLevel,
|
|
const std::vector<std::string>& names,
|
|
std::vector<float>* fvdata);
|
|
|
|
OpenSubdiv::OPENSUBDIV_VERSION::HbrMesh<T> *GetHbrMesh() { return _hmesh;}
|
|
|
|
bool IsValid() { return _valid;}
|
|
|
|
const std::string &GetName() { return _name;}
|
|
|
|
const PxOsdUtilSubdivTopology &GetTopology() const {return _t;}
|
|
|
|
private:
|
|
|
|
PxOsdUtilSubdivTopology _t;
|
|
|
|
std::vector<int> _fvarwidths;
|
|
std::vector<int> _fvarindices;
|
|
std::map<std::string, int> _fvaroffsets;
|
|
|
|
OpenSubdiv::OPENSUBDIV_VERSION::HbrMesh<T> *_hmesh;
|
|
|
|
std::string _name;
|
|
|
|
bool _valid;
|
|
|
|
};
|
|
|
|
|
|
#endif /* PX_OSD_UTIL_MESH_H */
|