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 IMX_Layer;
25 class UT_MemoryCounter;
26 
28 {
29 protected:
30  /// NOTE: Primitives should not be deleted directly. They are managed
31  /// by the GA_PrimitiveList and the stash.
32  ~GU_PrimVolume() override {}
33 
34 public:
35  /// NOTE: This constructor should only be called via GU_PrimitiveFactory.
37  : GEO_PrimVolume(gdp, offset)
38  {}
39 
40  const GA_PrimitiveDefinition &getTypeDef() const override
41  {
42  UT_ASSERT(theDefinition);
43  return *theDefinition;
44  }
45 
46  /// Report approximate memory usage.
47  int64 getMemoryUsage() const override;
48  int64 getDeviceMemoryUsage() const override;
49 
50  /// Count memory usage using a UT_MemoryCounter in order to count
51  /// shared memory correctly.
52  /// NOTE: This should always include sizeof(*this).
53  void countMemory(UT_MemoryCounter &counter) const override;
54 
55  // Conversion Methods
57  GA_PointGroup *usedpts = 0) override;
59 
60  void normal(NormalComp &output) const override {}
61  void normal(NormalCompD &output) const override {}
62 
63  // NOTE: For static member functions please call in the following
64  // manner. <ptrvalue> = GU_PrimSphere::<functname>
65  // i.e. sphereptr = GU_PrimSphere::sphereBuild(params...);
66 
67  // Optional Build Method
68  static GEO_PrimVolume *build(GU_Detail *gdp, bool integers = false,
69  int comps = 1);
70 
71  // Builds a GU_PrimVolume attached to the given gdp with values
72  // initialized from the callback function. This is intentionally similar
73  // to the GU_Detail::polyIsoSurface method.
74  // Note that sampling is done at centers of voxels!
75  static GEO_PrimVolume *buildFromFunction(GU_Detail *gdp,
76  float (*valAtPoint)(const UT_Vector3 &,
77  void *data),
78  void *data,
79  const UT_BoundingBox &bbox,
80  int xres, int yres, int zres);
81 
82  // Builds a two-dimensional GU_PrimVolume attached to the given gdp from the
83  // provided layer.
84  static GEO_PrimVolume *buildFromLayer(GU_Detail *gdp,
86  static GEO_PrimVolume *buildFromLayer(GU_Detail *gdp,
88 
89  // Writes out into an already setup layer.
90  // Returns false if the write failed as it the layer isn't compatible.
91  // The layer may share the volume's IMX buffer if one was already available.
92  // Call makeBufferUnique() on the layer if planning to modify it.
93  bool writeVoxelsToLayer(IMX_Layer &layer) const;
94 
95  // A threadable version. This should be preferred as you can
96  // avoid using static data for callbacks.
97  // The jobinfo you receive can be queried to find how many
98  // threads and which one you are being called from.
99  // Setting allowthreading to false avoids threading.
100  static GEO_PrimVolume *buildFromFunction(GU_Detail *gdp,
101  float (*valAtPoint)(const UT_Vector3 &,
102  void *,
103  const UT_JobInfo &),
104  void *data,
105  const UT_BoundingBox &bbox,
106  int xres, int yres, int zres,
107  bool allowthreading = true);
108 
109  typedef float (*VolumeSampler)(const UT_Vector3 &, void *, const UT_JobInfo &);
110 protected:
111 
112  THREADED_METHOD5(GU_PrimVolume, vox->numTiles() > 1,
113  buildFromFunctionInternal,
114  UT_VoxelArrayF *, vox,
115  const UT_Matrix3 &, xform,
116  const UT_Vector3 &, center,
117  VolumeSampler, valAtPoint,
118  void *, data)
119 
120  void buildFromFunctionInternalPartial(UT_VoxelArrayF *vox,
121  const UT_Matrix3 &xform,
122  const UT_Vector3 &center,
123  VolumeSampler valAtPoint,
124  void *data,
125  const UT_JobInfo &info);
126 
127 private:
128  static GA_PrimitiveDefinition *theDefinition;
129  friend class GU_PrimitiveFactory;
130 
131 // Don't warn about overriding deprecated virtual methods
133 };
135 
136 #endif
GLboolean * data
Definition: glcorearb.h:131
#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:36
#define GA_INVALID_OFFSET
Definition: GA_Types.h:687
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
GA_Size GA_Offset
Definition: GA_Types.h:646
const GA_PrimitiveDefinition & getTypeDef() const override
Definition: GU_PrimVolume.h:40
GLintptr offset
Definition: glcorearb.h:665
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
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:60
#define GU_API
Definition: GU_API.h:14
virtual int64 getDeviceMemoryUsage() const
Definition: GA_Primitive.h:213
GA_API const UT_StringHolder parms
IMATH_NAMESPACE::V2f IMATH_NAMESPACE::Box2i std::string this attribute is obsolete as of OpenEXR v3 float
void normal(NormalCompD &output) const override
Definition: GU_PrimVolume.h:61
~GU_PrimVolume() override
Definition: GU_PrimVolume.h:32
virtual GEO_Primitive * convert(GEO_ConvertParms &parms, GA_PointGroup *usedpts=0)=0
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
Definition of a geometric primitive.
virtual GEO_Primitive * convertNew(GEO_ConvertParms &parms)=0
Definition: format.h:1821