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 
49  /// Count memory usage using a UT_MemoryCounter in order to count
50  /// shared memory correctly.
51  /// NOTE: This should always include sizeof(*this).
52  void countMemory(UT_MemoryCounter &counter) const override;
53 
54  // Conversion Methods
56  GA_PointGroup *usedpts = 0) override;
57  GEO_Primitive *convertNew(GEO_ConvertParms &parms) override;
58 
59  void normal(NormalComp &output) const override {}
60  void normal(NormalCompD &output) const override {}
61 
62  // NOTE: For static member functions please call in the following
63  // manner. <ptrvalue> = GU_PrimSphere::<functname>
64  // i.e. sphereptr = GU_PrimSphere::sphereBuild(params...);
65 
66  // Optional Build Method
67  static GEO_PrimVolume *build(GU_Detail *gdp, bool integers = false,
68  int comps = 1);
69 
70  // Builds a GU_PrimVolume attached to the given gdp with values
71  // initialized from the callback function. This is intentionally similar
72  // to the GU_Detail::polyIsoSurface method.
73  // Note that sampling is done at centers of voxels!
74  static GEO_PrimVolume *buildFromFunction(GU_Detail *gdp,
75  float (*valAtPoint)(const UT_Vector3 &,
76  void *data),
77  void *data,
78  const UT_BoundingBox &bbox,
79  int xres, int yres, int zres);
80 
81  // Builds a two-dimensional GU_PrimVolume attached to the given gdp from the
82  // provided layer.
83  static GEO_PrimVolume *buildFromLayer(GU_Detail *gdp,
85  static GEO_PrimVolume *buildFromLayer(GU_Detail *gdp,
87 
88  // Writes out into an already setup layer.
89  // Returns false if the write failed as it the layer isn't compatible.
90  bool writeVoxelsToLayer(IMX_Layer &layer) const;
91 
92  // A threadable version. This should be preferred as you can
93  // avoid using static data for callbacks.
94  // The jobinfo you receive can be queried to find how many
95  // threads and which one you are being called from.
96  // Setting allowthreading to false avoids threading.
97  static GEO_PrimVolume *buildFromFunction(GU_Detail *gdp,
98  float (*valAtPoint)(const UT_Vector3 &,
99  void *,
100  const UT_JobInfo &),
101  void *data,
102  const UT_BoundingBox &bbox,
103  int xres, int yres, int zres,
104  bool allowthreading = true);
105 
106  typedef float (*VolumeSampler)(const UT_Vector3 &, void *, const UT_JobInfo &);
107 protected:
108 
109  THREADED_METHOD5(GU_PrimVolume, vox->numTiles() > 1,
110  buildFromFunctionInternal,
111  UT_VoxelArrayF *, vox,
112  const UT_Matrix3 &, xform,
113  const UT_Vector3 &, center,
114  VolumeSampler, valAtPoint,
115  void *, data)
116 
117  void buildFromFunctionInternalPartial(UT_VoxelArrayF *vox,
118  const UT_Matrix3 &xform,
119  const UT_Vector3 &center,
120  VolumeSampler valAtPoint,
121  void *data,
122  const UT_JobInfo &info);
123 
124 private:
125  static GA_PrimitiveDefinition *theDefinition;
126  friend class GU_PrimitiveFactory;
127 
128 // Don't warn about overriding deprecated virtual methods
130 };
132 
133 #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
IMATH_NAMESPACE::V2f float
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:59
#define GU_API
Definition: GU_API.h:14
void normal(NormalCompD &output) const override
Definition: GU_PrimVolume.h:60
~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:895