2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Copyright 2013 Pixar
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 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:
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +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 to comply with Section 4(c) of
|
|
|
|
// the License and to reproduce the content of the NOTICE file.
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// You may obtain a copy of the Apache License at
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2013-07-18 21:19:50 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 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.
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
|
|
|
|
2013-03-23 01:20:50 +00:00
|
|
|
#ifndef FAR_PATCH_TABLES_FACTORY_H
|
|
|
|
#define FAR_PATCH_TABLES_FACTORY_H
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
#include "../version.h"
|
|
|
|
|
|
|
|
#include "../far/patchTables.h"
|
|
|
|
|
|
|
|
namespace OpenSubdiv {
|
|
|
|
namespace OPENSUBDIV_VERSION {
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
// Forward declarations (for internal implementation purposes):
|
|
|
|
namespace Vtr { class Level; }
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
namespace Far {
|
2014-03-20 21:52:42 +00:00
|
|
|
|
2014-11-11 19:27:25 +00:00
|
|
|
class StencilTables;
|
2014-09-05 22:07:46 +00:00
|
|
|
class TopologyRefiner;
|
2014-11-11 19:27:25 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
template <typename T> struct PatchTypes;
|
|
|
|
struct PatchFaceTag;
|
2013-05-16 00:53:40 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
/// \brief A specialized factory for feature adaptive PatchTables
|
|
|
|
///
|
|
|
|
/// PatchTables contain the lists of vertices for each patch of an adaptive
|
|
|
|
/// mesh representation.
|
|
|
|
///
|
|
|
|
class PatchTablesFactory {
|
2013-05-16 00:53:40 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
public:
|
2013-05-16 00:53:40 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
struct Options {
|
2013-10-05 00:06:23 +00:00
|
|
|
|
2015-01-06 18:56:29 +00:00
|
|
|
Options(unsigned int maxIsolation=10) :
|
2014-11-11 19:27:25 +00:00
|
|
|
generateAllLevels(false),
|
|
|
|
triangulateQuads(false),
|
|
|
|
generateFVarTables(false),
|
|
|
|
useSingleCreasePatch(false),
|
2015-01-06 18:56:29 +00:00
|
|
|
maxIsolationLevel(maxIsolation),
|
2014-11-11 19:27:25 +00:00
|
|
|
adaptiveStencilTables(0) { }
|
2014-10-13 15:52:09 +00:00
|
|
|
|
|
|
|
unsigned int generateAllLevels : 1, ///< Include levels from 'firstLevel' to 'maxLevel' (Uniform mode only)
|
|
|
|
triangulateQuads : 1, ///< Triangulate 'QUADS' primitives (Uniform mode only)
|
|
|
|
generateFVarTables : 1, ///< Generate face-varying patch tables
|
|
|
|
useSingleCreasePatch : 1, ///< Use single crease patch
|
|
|
|
maxIsolationLevel : 4; ///< Cap the sharpnness of single creased patches to be consistent to other feature isolations.
|
2014-11-11 19:27:25 +00:00
|
|
|
|
|
|
|
StencilTables const * adaptiveStencilTables;
|
2014-09-05 22:07:46 +00:00
|
|
|
};
|
2014-06-30 20:25:33 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
/// \brief Factory constructor for PatchTables
|
2014-06-30 20:25:33 +00:00
|
|
|
///
|
2014-09-05 22:07:46 +00:00
|
|
|
/// @param refiner TopologyRefiner from which to generate patches
|
2014-06-30 20:25:33 +00:00
|
|
|
///
|
2014-09-05 22:07:46 +00:00
|
|
|
/// @param options Options controlling the creation of the tables
|
2014-06-30 20:25:33 +00:00
|
|
|
///
|
2014-09-05 22:07:46 +00:00
|
|
|
/// @return A new instance of PatchTables
|
2014-06-30 20:25:33 +00:00
|
|
|
///
|
2014-09-05 22:07:46 +00:00
|
|
|
static PatchTables * Create(TopologyRefiner const & refiner, Options options=Options());
|
2014-06-30 20:25:33 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
private:
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
typedef PatchTables::FVarPatchTables FVarPatchTables;
|
2013-10-05 00:06:23 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
static PatchTables * createUniform( TopologyRefiner const & refiner, Options options );
|
2013-05-09 00:06:59 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
static PatchTables * createAdaptive( TopologyRefiner const & refiner, Options options );
|
2013-10-05 00:06:23 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
// High-level methods for identifying and populating patches associated with faces:
|
2014-12-04 01:19:07 +00:00
|
|
|
static void identifyAdaptivePatches( TopologyRefiner const & refiner,
|
|
|
|
PatchTypes<int> & patchInventory,
|
2014-10-13 15:52:09 +00:00
|
|
|
std::vector<PatchFaceTag> & patchTags,
|
|
|
|
Options options );
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-12-04 01:19:07 +00:00
|
|
|
static void populateAdaptivePatches( TopologyRefiner const & refiner,
|
|
|
|
PatchTypes<int> const & patchInventory,
|
2014-09-05 22:07:46 +00:00
|
|
|
std::vector<PatchFaceTag> const & patchTags,
|
2014-12-04 01:19:07 +00:00
|
|
|
PatchTables * tables,
|
2014-10-13 15:52:09 +00:00
|
|
|
Options options );
|
2014-03-12 01:37:25 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
// Methods for allocating and managing the patch table data arrays:
|
2014-10-13 15:52:09 +00:00
|
|
|
static void allocateTables( PatchTables * tables, int nlevels, bool hasSharpness );
|
2013-10-05 00:06:23 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
static FVarPatchTables * allocateFVarTables( TopologyRefiner const & refiner,
|
|
|
|
PatchTables const & tables,
|
|
|
|
Options options );
|
2013-10-05 00:06:23 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
static PatchParam * computePatchParam( TopologyRefiner const & refiner, int level,
|
2014-10-13 15:52:09 +00:00
|
|
|
int face, int rotation, PatchParam * coord );
|
2013-05-09 00:06:59 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
static void getQuadOffsets(Vtr::Level const & level, int face, unsigned int * result);
|
2013-10-05 00:06:23 +00:00
|
|
|
|
2014-10-13 15:52:09 +00:00
|
|
|
static int assignSharpnessIndex( PatchTables *tables, float sharpness );
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
private:
|
2012-12-11 01:15:13 +00:00
|
|
|
};
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
} // end namespace Far
|
2013-11-16 01:42:57 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
} // end namespace OPENSUBDIV_VERSION
|
|
|
|
using namespace OPENSUBDIV_VERSION;
|
|
|
|
|
|
|
|
} // end namespace OpenSubdiv
|
|
|
|
|
2013-03-23 01:20:50 +00:00
|
|
|
#endif /* FAR_PATCH_TABLES_FACTORY_H */
|