HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 
72  exint getNumSourceMeshes() const { return myMeshes.entries(); }
73 
74  /// Return the concatenation of all the polygon meshes
75  GT_PrimitiveHandle result() const;
76 
77 private:
78  bool matchAttributes(const GT_PrimPolygonMesh &pmesh) const;
79  const GT_PrimPolygonMesh *getMesh(exint i) const
80  { return UTverify_cast<const GT_PrimPolygonMesh *>(myMeshes(i).get()); }
81 
83  bool myMergeDetailLists;
84  int64 myFaceCount;
85  int64 myTotalFaceCount;
86  int64 myMaxMeshCount;
87  int64 myMaxMeshFaceCount;
88 };
89 
90 #endif
91 
exint getNumSourceMeshes() const
A mesh of polygons.
void mergeDetailLists(bool merge_detail_lists)
#define GT_API
Definition: GT_API.h:11
#define SYS_INT64_MAX
Definition: SYS_Types.h:166
png_uint_32 i
Definition: png.h:2877
long long int64
Definition: SYS_Types.h:106
int64 exint
Definition: SYS_Types.h:115
SYS_FORCE_INLINE TO_T UTverify_cast(FROM_T from)
Definition: UT_Assert.h:175
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.