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,
84  const IMX_Layer& layer);
85 
86  // A threadable version. This should be preferred as you can
87  // avoid using static data for callbacks.
88  // The jobinfo you receive can be queried to find how many
89  // threads and which one you are being called from.
90  // Setting allowthreading to false avoids threading.
91  static GEO_PrimVolume *buildFromFunction(GU_Detail *gdp,
92  float (*valAtPoint)(const UT_Vector3 &,
93  void *,
94  const UT_JobInfo &),
95  void *data,
96  const UT_BoundingBox &bbox,
97  int xres, int yres, int zres,
98  bool allowthreading = true);
99 
100  typedef float (*VolumeSampler)(const UT_Vector3 &, void *, const UT_JobInfo &);
101 protected:
102 
103  THREADED_METHOD5(GU_PrimVolume, vox->numTiles() > 1,
104  buildFromFunctionInternal,
105  UT_VoxelArrayF *, vox,
106  const UT_Matrix3 &, xform,
107  const UT_Vector3 &, center,
108  VolumeSampler, valAtPoint,
109  void *, data)
110 
111  void buildFromFunctionInternalPartial(UT_VoxelArrayF *vox,
112  const UT_Matrix3 &xform,
113  const UT_Vector3 &center,
114  VolumeSampler valAtPoint,
115  void *data,
116  const UT_JobInfo &info);
117 
118 private:
119  static GA_PrimitiveDefinition *theDefinition;
120  friend class GU_PrimitiveFactory;
121 
122 // Don't warn about overriding deprecated virtual methods
124 };
126 
127 #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:678
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
GA_Size GA_Offset
Definition: GA_Types.h:641
const GA_PrimitiveDefinition & getTypeDef() const override
Definition: GU_PrimVolume.h:40
GLintptr offset
Definition: glcorearb.h:665
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