00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Andrew Clinton 00008 * Side Effects Software Inc 00009 * 123 Front Street West, Suite 1401 00010 * Toronto, Ontario 00011 * Canada M5J 2M2 00012 * 416-504-9876 00013 * 00014 * NAME: GU_NamePartition.h (C++) 00015 * 00016 * COMMENTS: Primitive partitioning operation that splits primitives 00017 * into sets based on the "name" attribute. This is used to 00018 * consistently create attribute mappings for rendering of 00019 * volume primitives. 00020 */ 00021 00022 #ifndef __GU_NamePartition_h__ 00023 #define __GU_NamePartition_h__ 00024 00025 #include "GU_API.h" 00026 #include <UT/UT_RefArray.h> 00027 #include <UT/UT_StringArray.h> 00028 #include <UT/UT_IntArray.h> 00029 00030 class UT_BitArray; 00031 class GU_Detail; 00032 00033 class GU_API GU_NamePartition 00034 { 00035 public: 00036 GU_NamePartition() {} 00037 ~GU_NamePartition() {} 00038 00039 // Partition a set of primitives by the primitive "name" attribute. 00040 // Primitives with the same name will be allocated to different entries 00041 // in the list. Primitives with no name will be placed in their own 00042 // entry in the prims array. 00043 // 00044 // This operation recognizes vectors using the following component 00045 // syntax where val is any name: 00046 // - val 00047 // Non-vector (scalar) values 00048 // - val.x, val.y, val.z 00049 // A 3-component vector 00050 // - val.xx, val.xy, val.xz, 00051 // val.yx, val.yy, val.yz, 00052 // val.zx, val.zy, val.zz 00053 // A 3x3 matrix 00054 // 00055 // Parameters: 00056 // - mask: The group of primitives to be processed 00057 // - gdp: The geometry to partition 00058 void partitionByName(const UT_BitArray &mask, 00059 const GU_Detail *gdp, 00060 const char *noname_name = 0); 00061 00062 // Retrieve the vector names or vector sizes within each partition 00063 int nameCount() const { return myNames.entries(); } 00064 UT_String &getName(int name) { return myNames(name); } 00065 int getVectorSize(int name) { return mySizes(name); } 00066 00067 // Retrieve the primitives in a vector of a partition 00068 // 00069 // Usage is: 00070 // for (int i = 0; i < partition.entries(); i++) 00071 // { 00072 // for (int j = 0; j < partition.nameCount(); j++) 00073 // { 00074 // partition.getPrimitiveVector(i, j, prims); 00075 // // Do something with the primitive array 00076 // } 00077 // } 00078 int entries() const { return myPrims.entries(); } 00079 void getPrimitiveVector(int prim, int name, 00080 UT_IntArray &prims); 00081 00082 bool hasUnmatchedNames() const { return myUnmatchedNames; } 00083 00084 private: 00085 UT_RefArray<UT_IntArray> myPrims; 00086 UT_StringArray myNames; 00087 UT_IntArray mySizes; 00088 UT_IntArray myOffsets; 00089 bool myUnmatchedNames; 00090 }; 00091 00092 #endif
1.5.9