HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_PrimChannel.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_PrimChannel.h (C++)
7  *
8  * COMMENTS:
9  * Utilities for Channel Primitives
10  */
11 
12 #ifndef __GU_PrimChannel_h__
13 #define __GU_PrimChannel_h__
14 
15 #include "GU_API.h"
16 #include <GEO/GEO_PrimChannel.h>
17 #include "GU_Detail.h"
18 
19 class UT_MemoryCounter;
20 class CL_SimpleChannel;
21 
23 {
24 public:
26 
29 };
30 
31 class GU_PrimChannel;
32 
34 {
35 public:
36  GU_PrimChannelWriteHandle() : myChannel(nullptr), myPrimitive(nullptr) {}
38 
41 
43  {
44  myPrimitive = other.myPrimitive;
45  myChannel = other.myChannel;
46  other.myPrimitive = nullptr;
47  other.myChannel = nullptr;
48  }
49 
51  GU_PrimChannelWriteHandle &&other) noexcept
52  {
53  myPrimitive = other.myPrimitive;
54  myChannel = other.myChannel;
55  other.myPrimitive = nullptr;
56  other.myChannel = nullptr;
57 
58  return *this;
59  }
60 
61  /// Returns a pointer to a mutable CL_SimpleChannel
62  inline CL_SimpleChannel *get() const { return myChannel.get(); }
63  CL_SimpleChannel *operator->() const { return get(); }
64 
65 protected:
66  // Constructor should only be called by GU_PrimChannel
68  GU_PrimChannel *prim,
69  const UT_SharedPtr<CL_SimpleChannel> &channel);
70 
71 private:
73 
74  GU_PrimChannel *myPrimitive;
75 
76  friend class GU_PrimChannel;
77 };
78 
80 {
81 public:
82  // Only a read handle, so no need to bump the primitive dataID
84 
85  inline const CL_SimpleChannel *get() const { return myChannel.get(); }
86  const CL_SimpleChannel *operator->() const { return get(); }
87 
88 protected:
89  // Constructor should only be called by GU_PrimChannel
92 
93 private:
95 
96  friend class GU_PrimChannel;
97 };
98 
100 {
101 protected:
102  /// NOTE: Primitives should not be deleted directly. They are managed
103  /// by the GA_PrimitiveList and the stash.
104  ~GU_PrimChannel() override {}
105 
106 public:
107  /// NOTE: This constructor should only be called via GU_PrimitiveFactory.
109 
110  /// Report approximate memory usage.
111  int64 getMemoryUsage() const override;
112 
113  /// Count memory usage using a UT_MemoryCounter in order to count
114  /// shared memory correctly.
115  /// NOTE: This should always include sizeof(*this).
116  void countMemory(UT_MemoryCounter &counter) const override;
117 
118  const GA_PrimitiveDefinition &getTypeDef() const override
119  {
120  UT_ASSERT(theDefinition);
121  return *theDefinition;
122  }
123 
125  {
126  UT_ASSERT(theDefinition);
127  return theDefinition->getId();
128  }
129 
130  // Conversion Methods: to polygon, nurb curve, and bezier curve
132  GA_PointGroup *usedpts = nullptr) override;
133  GEO_Primitive *convertNew(GEO_ConvertParms &parms) override;
134 
135  void normal(NormalComp &output) const override;
136  void normal(NormalCompD &output) const override;
137 
138  int intersectRay(const UT_Vector3 &o, const UT_Vector3 &d,
139  float tmax = 1E17F, float tol = 1E-12F,
140  float *distance = nullptr,
141  UT_Vector3 *pos = nullptr,
142  UT_Vector3 *nml = nullptr, int accurate = 0,
143  float *u = nullptr, float *v = nullptr,
144  int ignoretrim = 1) const override;
145 
146  // Returns a read-write handle to the CH_Channel
147  GU_PrimChannelWriteHandle getChannelWriteHandle();
148  // Returns a read-only mutable handle to the CH_Channel
149  GU_PrimChannelReadHandle getChannelReadHandle() const;
150 
151  static GEO_Primitive *build(const GU_PrimChannelParms &parms,
152  fpreal value,
153  const UT_SharedPtr<CL_SimpleChannel> &channel);
154 
155 protected:
156 private:
157  static GA_PrimitiveDefinition *theDefinition;
158 
159  friend class GU_PrimitiveFactory;
161 };
163 
164 #endif
CL_SimpleChannel * operator->() const
GU_PrimChannelWriteHandle & operator=(GU_PrimChannelWriteHandle &&other) noexcept
static GA_PrimitiveTypeId typeId()
const GLdouble * v
Definition: glcorearb.h:837
#define SYS_DEPRECATED_PUSH_DISABLE()
#define SYS_DEPRECATED_POP_DISABLE()
virtual int64 getMemoryUsage() const
Definition: GA_Primitive.h:209
#define GA_INVALID_OFFSET
Definition: GA_Types.h:687
GA_Size GA_Offset
Definition: GA_Types.h:646
void normal(NormalComp &output) const override
GLintptr offset
Definition: glcorearb.h:665
static GEO_PrimChannel * build(GA_Detail *gdp, fpreal value, const UT_SharedPtr< CL_SimpleChannel > &channel)
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
virtual void countMemory(UT_MemoryCounter &counter) const
~GU_PrimChannel() override
long long int64
Definition: SYS_Types.h:116
#define GU_API
Definition: GU_API.h:14
const CL_SimpleChannel * operator->() const
GU_PrimChannelWriteHandle(GU_PrimChannelWriteHandle &&other) noexcept
virtual int intersectRay(const UT_Vector3 &o, const UT_Vector3 &d, float tmax=1E17F, float tol=1E-12F, float *distance=0, UT_Vector3 *pos=0, UT_Vector3 *nml=0, int accurate=0, float *u=0, float *v=0, int ignoretrim=1) const
fpreal64 fpreal
Definition: SYS_Types.h:277
LeafData & operator=(const LeafData &)=delete
const GA_PrimitiveDefinition & getTypeDef() const override
virtual GEO_Primitive * convert(GEO_ConvertParms &parms, GA_PointGroup *usedpts=0)=0
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
Definition: core.h:1131
Definition of a geometric primitive.
SIM_API const UT_StringHolder distance
virtual GEO_Primitive * convertNew(GEO_ConvertParms &parms)=0