HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_CatPolygonMesh.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GT_CatPolygonMesh.h (GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_CatPolygonMesh__
12 #define __GT_CatPolygonMesh__
13 
14 #include "GT_API.h"
15 #include "GT_Handles.h"
16 #include <UT/UT_Array.h>
17 #include <UT/UT_Matrix4.h>
18 
19 class GT_PrimPolygonMesh;
20 
21 /// Concatenate GT_PrimPolygonMesh objects into a single GT_PrimPolygonMesh
23 {
24 public:
25  GT_CatPolygonMesh(bool merge_detail_attribs = true,
26  int64 total_num_faces = SYS_INT64_MAX,
27  int64 max_meshes = SYS_INT64_MAX,
28  int64 max_mesh_face_count = SYS_INT64_MAX);
29 
31  bool merge_detail_attribs = true);
32 
33  /// If 'merge_detail_attribs' is true, the detail lists will be promoted
34  /// to uniform attributes. If false, only the first meshes detail attribs
35  /// are used (useful for merging meshes built from the same GU_Detail).
36  /// default is to merge.
37  void mergeDetailLists(bool merge_detail_lists)
38  { myMergeDetailLists = merge_detail_lists; }
39 
40  /// Limit the # of faces in the mesh. append will return false once full.
41  void setTotalFaceCount(int64 max_num_faces)
42  { myTotalFaceCount = max_num_faces; }
43  /// Limit the # of consituent meshes in the mesh. append will return false
44  /// once full.
45  void setMaxMeshCount(int64 max_meshes)
46  { myMaxMeshCount = max_meshes; }
47  /// Don't allow meshes larger than this size to be added.
48  void setMaxMeshFaceCount(int64 max_faces)
49  { myMaxMeshFaceCount = max_faces; }
50 
52  {
54  APPEND_UNSUPPORTED_TYPE,// not a poly mesh
55  APPEND_TOO_MANY_MESHES, // collected mesh exceeds the mesh count
56  APPEND_TOO_MANY_FACES, // collected mesh exceeds total #faces
57  APPEND_NO_FACES, // mesh has no faces
58  APPEND_MESH_TOO_LARGE, // mesh exceeds max mesh face count
59  APPEND_ATTRIB_MISMATCH // mesh attributes don't match collected mesh's
60  };
61 
62  /// Test if the primitive can be added, without adding it.
63  bool canAppend(const GT_PrimitiveHandle &prim,
64  gt_CatAppendReason *reason = NULL) const;
65 
66  /// Append a polygon mesh. Returns false if the primitive isn't valid
67  bool append(const GT_PrimitiveHandle &prim);
68 
69  /// Append a polygon mesh. Returns false if the primitive isn't valid
70  bool append(const GT_PrimitiveHandle &prim,
71  const GT_TransformHandle &prim_transform);
72  /// Replace mesh at the index with a new mesh.
73  bool replace(int idx,
74  const GT_PrimitiveHandle &prim);
75  // Remove the mesh at index.
76  bool remove(int idx);
77 
78  /// Clear the mesh at index, without shifting the list.
79  bool clearMesh(int idx);
80 
81  /// Reset and release all meshes.
82  void clearAllMeshes();
83 
84  void updateTransform(int idx, const UT_Matrix4F &transform);
85 
86  const GT_PrimPolygonMesh *getMesh(exint i) const;
87 
88  exint getNumSourceMeshes() const { return myNumSourceMeshes; }
89  int64 getNumSourceFaces() const { return myFaceCount; }
90 
91  /// Return the concatenation of all the polygon meshes
92  GT_PrimitiveHandle result(GT_AttributeListHandle detail_list = 0) const;
93 
94 private:
95  bool matchAttributes(const GT_PrimPolygonMesh &pmesh) const;
96  void mergeDetailLists(const UT_Array<GT_PrimitiveHandle> &meshes,
97  GT_AttributeListHandle &uniform,
98  GT_AttributeListHandle &detail) const;
99 
101  GT_DataArrayHandle myDetailTransforms;
102  int myNumSourceMeshes = 0;
103  bool myMergeDetailLists = false;
104  int myIsSubdivision = -1;
105  int myPrimIndex = 0;
106  int64 myFaceCount = 0;
107  int64 myTotalFaceCount = 0;
108  int64 myMaxMeshCount = 0;
109  int64 myMaxMeshFaceCount = 0;
110 };
111 
112 #endif
113 
exint getNumSourceMeshes() const
A mesh of polygons.
void mergeDetailLists(bool merge_detail_lists)
#define GT_API
Definition: GT_API.h:13
int64 exint
Definition: SYS_Types.h:125
#define SYS_INT64_MAX
Definition: SYS_Types.h:176
**But if you need a result
Definition: thread.h:622
std::string OIIO_UTIL_API replace(string_view str, string_view pattern, string_view replacement, bool global=false)
long long int64
Definition: SYS_Types.h:116
GA_API const UT_StringHolder transform
int64 getNumSourceFaces() const
void setMaxMeshFaceCount(int64 max_faces)
Don't allow meshes larger than this size to be added.
void setTotalFaceCount(int64 max_num_faces)
Limit the # of faces in the mesh. append will return false once full.
void setMaxMeshCount(int64 max_meshes)
Concatenate GT_PrimPolygonMesh objects into a single GT_PrimPolygonMesh.