HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_PrimVolume.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_PrimVolume.h ( GU Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GU_PrimVolume__
12 #define __GU_PrimVolume__
13 
14 #include "GU_API.h"
15 
16 #include <GEO/GEO_PrimVolume.h>
18 
19 #include "GU_Detail.h"
20 
21 class GEO_ConvertParms;
22 class GU_PrimVolumeCache;
24 class UT_MemoryCounter;
25 
27 {
28 protected:
29  /// NOTE: Primitives should not be deleted directly. They are managed
30  /// by the GA_PrimitiveList and the stash.
31  virtual ~GU_PrimVolume() {}
32 
33 public:
34  /// NOTE: This constructor should only be called via GU_PrimitiveFactory.
36  : GEO_PrimVolume(gdp, offset)
37  {}
38 
39  virtual const GA_PrimitiveDefinition &getTypeDef() const
40  {
41  UT_ASSERT(theDefinition);
42  return *theDefinition;
43  }
44 
45  /// Report approximate memory usage.
46  virtual int64 getMemoryUsage() const;
47 
48  /// Count memory usage using a UT_MemoryCounter in order to count
49  /// shared memory correctly.
50  /// NOTE: This should always include sizeof(*this).
51  virtual void countMemory(UT_MemoryCounter &counter) const;
52 
53  // Conversion Methods
54  virtual GEO_Primitive *convert(GEO_ConvertParms &parms,
55  GA_PointGroup *usedpts = 0);
56  virtual GEO_Primitive *convertNew(GEO_ConvertParms &parms);
57 
58  virtual void normal(NormalComp &output) const {}
59 
60  // NOTE: For static member functions please call in the following
61  // manner. <ptrvalue> = GU_PrimSphere::<functname>
62  // i.e. sphereptr = GU_PrimSphere::sphereBuild(params...);
63 
64  // Optional Build Method
65  static GEO_PrimVolume *build(GU_Detail *gdp);
66 
67  // Builds a GU_PrimVolume attached to the given gdp with values
68  // initialized from the callback function. This is intentionally similar
69  // to the GU_Detail::polyIsoSurface method.
70  // Note that sampling is done at centers of voxels!
71  static GEO_PrimVolume *buildFromFunction(GU_Detail *gdp,
72  float (*valAtPoint)(const UT_Vector3 &,
73  void *data),
74  void *data,
75  const UT_BoundingBox &bbox,
76  int xres, int yres, int zres);
77 
78  // A threadable version. This should be preferred as you can
79  // avoid using static data for callbacks.
80  // The jobinfo you receive can be queried to find how many
81  // threads and which one you are being called from.
82  // Setting allowthreading to false avoids threading.
83  static GEO_PrimVolume *buildFromFunction(GU_Detail *gdp,
84  float (*valAtPoint)(const UT_Vector3 &,
85  void *,
86  const UT_JobInfo &),
87  void *data,
88  const UT_BoundingBox &bbox,
89  int xres, int yres, int zres,
90  bool allowthreading = true);
91 
92  typedef float (*VolumeSampler)(const UT_Vector3 &, void *, const UT_JobInfo &);
93 protected:
94 
95  THREADED_METHOD5(GU_PrimVolume, vox->numTiles() > 1,
96  buildFromFunctionInternal,
97  UT_VoxelArrayF *, vox,
98  const UT_Matrix3 &, xform,
99  const UT_Vector3 &, center,
100  VolumeSampler, valAtPoint,
101  void *, data)
102 
103  void buildFromFunctionInternalPartial(UT_VoxelArrayF *vox,
104  const UT_Matrix3 &xform,
105  const UT_Vector3 &center,
106  VolumeSampler valAtPoint,
107  void *data,
108  const UT_JobInfo &info);
109 
110 private:
111  static GA_PrimitiveDefinition *theDefinition;
112  friend class GU_PrimitiveFactory;
113 
114 // Don't warn about overriding deprecated virtual methods
116 };
118 
119 #endif
#define SYS_DEPRECATED_PUSH_DISABLE()
#define SYS_DEPRECATED_POP_DISABLE()
3D Vector class.
virtual int64 getMemoryUsage() const
Definition: GA_Primitive.h:201
GU_PrimVolume(GU_Detail *gdp, GA_Offset offset=GA_INVALID_OFFSET)
NOTE: This constructor should only be called via GU_PrimitiveFactory.
Definition: GU_PrimVolume.h:35
virtual void normal(NormalComp &output) const
Definition: GU_PrimVolume.h:58
#define GA_INVALID_OFFSET
Definition: GA_Types.h:654
GA_Size GA_Offset
Definition: GA_Types.h:617
long long int64
Definition: SYS_Types.h:107
virtual void countMemory(UT_MemoryCounter &counter) const
GLintptr offset
Definition: glcorearb.h:664
#define THREADED_METHOD5(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5)
virtual const GA_PrimitiveDefinition & getTypeDef() const
Definition: GU_PrimVolume.h:39
#define GU_API
Definition: GU_API.h:12
GLboolean * data
Definition: glcorearb.h:130
virtual GEO_Primitive * convert(GEO_ConvertParms &parms, GA_PointGroup *usedpts=0)=0
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:126
virtual ~GU_PrimVolume()
Definition: GU_PrimVolume.h:31
Definition of a geometric primitive.
virtual GEO_Primitive * convertNew(GEO_ConvertParms &parms)=0