HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GU_NamePartition.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: GU_NamePartition.h (C++)
7  *
8  * COMMENTS: Primitive partitioning operation that splits primitives
9  * into sets based on the "name" attribute. This is used to
10  * consistently create attribute mappings for rendering of
11  * volume primitives.
12  */
13 
14 #ifndef __GU_NamePartition_h__
15 #define __GU_NamePartition_h__
16 
17 #include "GU_API.h"
18 #include <UT/UT_Array.h>
19 #include <UT/UT_StringArray.h>
20 #include <UT/UT_IntArray.h>
21 
22 class UT_BitArray;
23 class GU_Detail;
24 
26 {
27 public:
30 
31  // Partition a set of primitives by the primitive "name" attribute.
32  // Primitives with the same name will be allocated to different entries
33  // in the list. Primitives with no name will be placed in their own
34  // entry in the prims array.
35  //
36  // This operation recognizes vectors using the following component
37  // syntax where val is any name:
38  // - val
39  // Non-vector (scalar) values
40  // - val.x, val.y, val.z
41  // A 3-component vector
42  // - val.xx, val.xy, val.xz,
43  // val.yx, val.yy, val.yz,
44  // val.zx, val.zy, val.zz
45  // A 3x3 matrix
46  //
47  // Parameters:
48  // - mask: The group of primitives to be processed
49  // - gdp: The geometry to partition
50  void partitionByName(const UT_BitArray &mask,
51  const GU_Detail *gdp,
52  const char *noname_name = 0);
53 
54  // Retrieve the vector names or vector sizes within each partition
55  int nameCount() const { return myNames.entries(); }
56  const UT_StringHolder &getName(int name) { return myNames(name); }
57  int getVectorSize(int name) { return mySizes(name); }
58 
59  // Retrieve the primitives in a vector of a partition
60  //
61  // Usage is:
62  // for (int i = 0; i < partition.entries(); i++)
63  // {
64  // for (int j = 0; j < partition.nameCount(); j++)
65  // {
66  // partition.getPrimitiveVector(i, j, prims);
67  // // Do something with the primitive array
68  // }
69  // }
70  int entries() const { return myPrims.entries(); }
71  void getPrimitiveVector(int prim, int name,
72  UT_IntArray &prims);
73 
74  bool hasUnmatchedNames() const { return myUnmatchedNames; }
75 
76 private:
77  UT_Array<UT_IntArray> myPrims;
78  UT_StringArray myNames;
79  UT_IntArray mySizes;
80  UT_IntArray myOffsets;
81  bool myUnmatchedNames;
82 };
83 
84 #endif
bool hasUnmatchedNames() const
GLint GLuint mask
Definition: glcorearb.h:123
const UT_StringHolder & getName(int name)
int nameCount() const
int entries() const
#define GU_API
Definition: GU_API.h:11
GLuint const GLchar * name
Definition: glcorearb.h:785
int getVectorSize(int name)