HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
meshWrapper.h
Go to the documentation of this file.
1 //
2 // Copyright 2017 Pixar
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 __GUSD_MESHWRAPPER_H__
25 #define __GUSD_MESHWRAPPER_H__
26 
27 #include "primWrapper.h"
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdGeom/mesh.h"
31 
33 
35 
37 {
38 public:
40  const GT_PrimitiveHandle& sourcePrim,
41  const UsdStagePtr& stage,
42  const SdfPath& path,
43  const GusdContext& ctxt,
44  bool isOverride = false );
45 
47  const UsdGeomMesh& mesh,
48  UsdTimeCode t,
49  GusdPurposeSet purposes );
50 
51  GusdMeshWrapper( const GusdMeshWrapper &in );
52 
53  ~GusdMeshWrapper() override;
54 
55  // GusdPrimWrapper interface -----------------------------------------------
56 
57 public:
58 
59  const UsdGeomImageable getUsdPrim() const override { return m_usdMesh; }
60 
61  bool redefine(
62  const UsdStagePtr& stage,
63  const SdfPath& path,
64  const GusdContext& ctxt,
65  const GT_PrimitiveHandle& sourcePrim ) override;
66 
67  const char* className() const override;
68 
69  void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const override;
70 
71  int getMotionSegments() const override;
72 
73  int64 getMemoryUsage() const override;
74 
75  GT_PrimitiveHandle doSoftCopy() const override;
76 
77  bool
78  updateFromGTPrim(const GT_PrimitiveHandle& sourcePrim,
79  const UT_Matrix4D& houXform,
80  const GusdContext& ctxt,
81  GusdSimpleXformCache& xformCache) override;
82 
83  bool isValid() const override;
84 
85  bool refine(GT_Refine& refiner,
86  const GT_RefineParms* parms=NULL) const override;
87 
88  // -------------------------------------------------------------------------
89 
90 public:
91 
92  bool setSubdivisionScheme(const TfToken& scheme);
93 
95 
96  static GT_PrimitiveHandle
97  defineForWrite(const GT_PrimitiveHandle& sourcePrim,
98  const UsdStagePtr& stage,
99  const SdfPath& path,
100  const GusdContext& ctxt);
101 
102  static GT_PrimitiveHandle
103  defineForRead( const UsdGeomImageable& sourcePrim,
105  GusdPurposeSet purposes );
106 
107 private:
108 
110  _RefineSubdiv(GT_Refine& refiner,
111  const TfToken& subdScheme,
112  const GT_DataArrayHandle& gtVertexCounts,
113  const GT_DataArrayHandle& gtIndices,
114  const GT_AttributeListHandle& gtPointAttrs,
115  const GT_AttributeListHandle& gtVertexAttrs,
116  const GT_AttributeListHandle& gtUniformAttrs,
117  const GT_AttributeListHandle& gtDetailAttrs,
118  const GT_RefineParms* parms) const;
119 
120  void _RefineSubdivCorners(GT_PrimSubdivisionMesh& mesh,
121  GT_Refine& refiner) const;
122 
123  void _RefineSubdivCreases(GT_PrimSubdivisionMesh& mesh,
124  GT_Refine& refiner) const;
125 
126  void _RefineSubdivHoles(GT_PrimSubdivisionMesh& mesh,
127  GT_Refine& refiner) const;
128 
129  void _RefineSubdivOsdTags(GT_PrimSubdivisionMesh& mesh,
130  GT_Refine& refiner) const;
131 
132  bool initUsdPrim(const UsdStagePtr& stage,
133  const SdfPath& path,
134  bool asOverride);
135 
136  void initialize( const GusdContext& ctxt, const GT_PrimitiveHandle& refPrim );
137 
138  UsdGeomMesh m_usdMesh;
139  bool m_forceCreateNewGeo;
140 };
141 
143 
144 #endif // __GUSD_MESHWRAPPER_H__
145 
A GT_Primitive that wraps a USD Prim.
Definition: primWrapper.h:90
const UsdGeomImageable getUsdPrim() const override
Definition: meshWrapper.h:59
GT_API const UT_StringHolder time
static GT_PrimitiveHandle defineForRead(const UsdGeomImageable &sourcePrim, UsdTimeCode time, GusdPurposeSet purposes)
int getMotionSegments() const override
static GT_PrimitiveHandle defineForWrite(const GT_PrimitiveHandle &sourcePrim, const UsdStagePtr &stage, const SdfPath &path, const GusdContext &ctxt)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
~GusdMeshWrapper() override
void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const override
bool setSubdivisionScheme(const TfToken &scheme)
Definition: token.h:87
long long int64
Definition: SYS_Types.h:116
GusdMeshWrapper(const GT_PrimitiveHandle &sourcePrim, const UsdStagePtr &stage, const SdfPath &path, const GusdContext &ctxt, bool isOverride=false)
Definition: path.h:290
GLdouble t
Definition: glad.h:2397
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
bool isValid() const override
Return true if the underlying USD prim is valid.
bool updateFromGTPrim(const GT_PrimitiveHandle &sourcePrim, const UT_Matrix4D &houXform, const GusdContext &ctxt, GusdSimpleXformCache &xformCache) override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const override
bool redefine(const UsdStagePtr &stage, const SdfPath &path, const GusdContext &ctxt, const GT_PrimitiveHandle &sourcePrim) override
Create a new USD prim to match GT primitive.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
TfToken getSubdivisionScheme() const
GT_PrimitiveHandle doSoftCopy() const override
int64 getMemoryUsage() const override
GusdPurposeSet
Definition: purpose.h:39
std::map< SdfPath, UT_Matrix4D > GusdSimpleXformCache
Definition: primWrapper.h:88
const char * className() const override