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  ~GU_PrimVolume() override {}
32 
33 public:
34  /// NOTE: This constructor should only be called via GU_PrimitiveFactory.
36  : GEO_PrimVolume(gdp, offset)
37  {}
38 
39  const GA_PrimitiveDefinition &getTypeDef() const override
40  {
41  UT_ASSERT(theDefinition);
42  return *theDefinition;
43  }
44 
45  /// Report approximate memory usage.
46  int64 getMemoryUsage() const override;
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  void countMemory(UT_MemoryCounter &counter) const override;
52 
53  // Conversion Methods
55  GA_PointGroup *usedpts = 0) override;
56  GEO_Primitive *convertNew(GEO_ConvertParms &parms) override;
57 
58  void normal(NormalComp &output) const override {}
59  void normal(NormalCompD &output) const override {}
60 
61  // NOTE: For static member functions please call in the following
62  // manner. <ptrvalue> = GU_PrimSphere::<functname>
63  // i.e. sphereptr = GU_PrimSphere::sphereBuild(params...);
64 
65  // Optional Build Method
66  static GEO_PrimVolume *build(GU_Detail *gdp);
67 
68  // Builds a GU_PrimVolume attached to the given gdp with values
69  // initialized from the callback function. This is intentionally similar
70  // to the GU_Detail::polyIsoSurface method.
71  // Note that sampling is done at centers of voxels!
72  static GEO_PrimVolume *buildFromFunction(GU_Detail *gdp,
73  float (*valAtPoint)(const UT_Vector3 &,
74  void *data),
75  void *data,
76  const UT_BoundingBox &bbox,
77  int xres, int yres, int zres);
78 
79  // A threadable version. This should be preferred as you can
80  // avoid using static data for callbacks.
81  // The jobinfo you receive can be queried to find how many
82  // threads and which one you are being called from.
83  // Setting allowthreading to false avoids threading.
84  static GEO_PrimVolume *buildFromFunction(GU_Detail *gdp,
85  float (*valAtPoint)(const UT_Vector3 &,
86  void *,
87  const UT_JobInfo &),
88  void *data,
89  const UT_BoundingBox &bbox,
90  int xres, int yres, int zres,
91  bool allowthreading = true);
92 
93  typedef float (*VolumeSampler)(const UT_Vector3 &, void *, const UT_JobInfo &);
94 protected:
95 
96  THREADED_METHOD5(GU_PrimVolume, vox->numTiles() > 1,
97  buildFromFunctionInternal,
98  UT_VoxelArrayF *, vox,
99  const UT_Matrix3 &, xform,
100  const UT_Vector3 &, center,
101  VolumeSampler, valAtPoint,
102  void *, data)
103 
104  void buildFromFunctionInternalPartial(UT_VoxelArrayF *vox,
105  const UT_Matrix3 &xform,
106  const UT_Vector3 &center,
107  VolumeSampler valAtPoint,
108  void *data,
109  const UT_JobInfo &info);
110 
111 private:
112  static GA_PrimitiveDefinition *theDefinition;
113  friend class GU_PrimitiveFactory;
114 
115 // Don't warn about overriding deprecated virtual methods
117 };
119 
120 #endif
GLuint counter
Definition: glew.h:2745
#define SYS_DEPRECATED_PUSH_DISABLE()
#define SYS_DEPRECATED_POP_DISABLE()
virtual int64 getMemoryUsage() const
Definition: GA_Primitive.h:209
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
#define GA_INVALID_OFFSET
Definition: GA_Types.h:677
GA_Size GA_Offset
Definition: GA_Types.h:640
const GA_PrimitiveDefinition & getTypeDef() const override
Definition: GU_PrimVolume.h:39
virtual void countMemory(UT_MemoryCounter &counter) const
long long int64
Definition: SYS_Types.h:116
#define THREADED_METHOD5(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5)
void normal(NormalComp &output) const override
Definition: GU_PrimVolume.h:58
#define GU_API
Definition: GU_API.h:14
GLboolean * data
Definition: glcorearb.h:131
void normal(NormalCompD &output) const override
Definition: GU_PrimVolume.h:59
~GU_PrimVolume() override
Definition: GU_PrimVolume.h:31
virtual GEO_Primitive * convert(GEO_ConvertParms &parms, GA_PointGroup *usedpts=0)=0
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:153
GLintptr offset
Definition: glcorearb.h:665
Definition of a geometric primitive.
virtual GEO_Primitive * convertNew(GEO_ConvertParms &parms)=0
Definition: format.h:895