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 
18 class GT_PrimPolygonMesh;
19 
20 /// Concatenate GT_PrimPolygonMesh objects into a single GT_PrimPolygonMesh
22 {
23 public:
24  GT_CatPolygonMesh(bool merge_detail_attribs = true,
25  int64 total_num_faces = SYS_INT64_MAX,
26  int64 max_meshes = SYS_INT64_MAX,
27  int64 max_mesh_face_count = SYS_INT64_MAX);
28 
30  bool merge_detail_attribs = true);
31 
32  /// If 'merge_detail_attribs' is true, the detail lists will be promoted
33  /// to uniform attributes. If false, only the first meshes detail attribs
34  /// are used (useful for merging meshes built from the same GU_Detail).
35  /// default is to merge.
36  void mergeDetailLists(bool merge_detail_lists)
37  { myMergeDetailLists = merge_detail_lists; }
38 
39  /// Limit the # of faces in the mesh. append will return false once full.
40  void setTotalFaceCount(int64 max_num_faces)
41  { myTotalFaceCount = max_num_faces; }
42  /// Limit the # of consituent meshes in the mesh. append will return false
43  /// once full.
44  void setMaxMeshCount(int64 max_meshes)
45  { myMaxMeshCount = max_meshes; }
46  /// Don't allow meshes larger than this size to be added.
47  void setMaxMeshFaceCount(int64 max_faces)
48  { myMaxMeshFaceCount = max_faces; }
49 
51  {
53  APPEND_UNSUPPORTED_TYPE,// not a poly mesh
54  APPEND_TOO_MANY_MESHES, // collected mesh exceeds the mesh count
55  APPEND_TOO_MANY_FACES, // collected mesh exceeds total #faces
56  APPEND_NO_FACES, // mesh has no faces
57  APPEND_MESH_TOO_LARGE, // mesh exceeds max mesh face count
58  APPEND_ATTRIB_MISMATCH // mesh attributes don't match collected mesh's
59  };
60 
61  /// Test if the primitive can be added, without adding it.
62  bool canAppend(const GT_PrimitiveHandle &prim,
63  gt_CatAppendReason *reason = NULL) const;
64 
65  /// Append a polygon mesh. Returns false if the primitive isn't valid
66  bool append(const GT_PrimitiveHandle &prim);
67 
68  /// Append a polygon mesh. Returns false if the primitive isn't valid
69  bool append(const GT_PrimitiveHandle &prim,
70  const GT_TransformHandle &prim_transform);
71  /// Replace mesh at the index with a new mesh.
72  bool replace(int idx,
73  const GT_PrimitiveHandle &prim);
74  // Remove the mesh at index.
75  bool remove(int idx);
76 
77  /// Clear the mesh at index, without shifting the list.
78  bool clearMesh(int idx);
79 
80  /// Reset and release all meshes.
81  void clearAllMeshes();
82 
83  const GT_PrimPolygonMesh *getMesh(exint i) const;
84 
85  exint getNumSourceMeshes() const { return myNumSourceMeshes; }
86  int64 getNumSourceFaces() const { return myFaceCount; }
87 
88  /// Return the concatenation of all the polygon meshes
89  GT_PrimitiveHandle result(GT_AttributeListHandle detail_list = 0) const;
90 
91 private:
92  bool matchAttributes(const GT_PrimPolygonMesh &pmesh) const;
93  void mergeDetailLists(const UT_Array<GT_PrimitiveHandle> &meshes,
94  GT_AttributeListHandle &uniform,
95  GT_AttributeListHandle &detail) const;
96 
98  int myNumSourceMeshes;
99  bool myMergeDetailLists;
100  int myIsSubdivision;
101  int64 myFaceCount;
102  int64 myTotalFaceCount;
103  int64 myMaxMeshCount;
104  int64 myMaxMeshFaceCount;
105 };
106 
107 #endif
108 
exint getNumSourceMeshes() const
A mesh of polygons.
void mergeDetailLists(bool merge_detail_lists)
#define GT_API
Definition: GT_API.h:11
int64 exint
Definition: SYS_Types.h:125
#define SYS_INT64_MAX
Definition: SYS_Types.h:176
std::string OIIO_API replace(string_view str, string_view pattern, string_view replacement, bool global=false)
long long int64
Definition: SYS_Types.h:116
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.
GLuint64EXT * result
Definition: glew.h:14007
void setMaxMeshCount(int64 max_meshes)
Concatenate GT_PrimPolygonMesh objects into a single GT_PrimPolygonMesh.