HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_Vertex.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: Geometry Library (C++)
7  *
8  * COMMENTS:
9  * The vertex class. As opposed to GEO_Points, all vertices are unique.
10  *
11  * WARNING: Try to avoid using the assignment operator '=' because it is
12  * shallow in the attribute component!
13  *
14  */
15 
16 #ifndef __GEO_Vertex_H__
17 #define __GEO_Vertex_H__
18 
19 #include "GEO_API.h"
20 #include <GA/GA_GBElement.h>
21 
22 class GEO_Detail;
23 class GEO_Primitive;
24 
26 
27 /// Base class for GEO_Vertex.
28 ///
30 {
31 protected:
32  /// Protect the constructors as this is only a base class and cannot itself
33  /// be instantiated.
35  : GA_GBElement(index_map, offset) { }
37  : GA_GBElement() {}
39  : GA_GBElement(src) { }
40 
41  /// We protect the destructor as nobody has any business using a reference
42  /// to this class to delete an instance of a class derived from us.
44 
45 public:
46  // --------------------------------------------------------------------
47  //
48  // Methods from GB_Vertex
49  //
50  // --------------------------------------------------------------------
51  SYS_DEPRECATED_HDK(13.0)
53  SYS_DEPRECATED_HDK(13.0)
55 
56  SYS_DEPRECATED_HDK(13.0)
57  GA_Index getPointIndex() const;
58 
59  /// @{
60  /// Copy/Compare the vertex handle (not the vertex contents)
61  SYS_DEPRECATED_HDK(13.0)
62  GA_GBVertex &operator=(const GA_GBVertex &src)
63  {
65  return *this;
66  }
67  SYS_DEPRECATED_HDK(13.0)
68  bool operator==(const GA_GBVertex &src) const
69  {
70  return GA_GBElement::operator==(src);
71  }
72  /// @}
73 
74  // --------------------------------------------------------------------
75  //
76  // Methods from GEO_Vertex
77  //
78  // --------------------------------------------------------------------
79  SYS_DEPRECATED_HDK(13.0)
80  void copyVertex(const GA_GBVertex &src,
82  const GA_AttributeSet &dict)
83  {
84  setPointOffset(offset);
85  copyAttribData(src, dict);
86  }
87  SYS_DEPRECATED_HDK(13.0)
88  void copyVertex(const GA_GBVertex &src,
89  GA_GBElement *pt,
90  const GA_AttributeSet &dict)
91  {
92  copyVertex(src, pt->getMapOffset(), dict);
93  }
94  SYS_DEPRECATED_HDK(13.0)
95  void copyVertex(const GA_GBVertex &src,
96  const GA_AttributeSet &dict)
97  {
98  copyVertex(src, src.getPointOffset(), dict);
99  }
100 
101 protected:
102  /// @{
103  /// Get de-homogenized position (that is, without the homogeneous coordinate
104  /// multiplied through).
105  const UT_Vector4 getPos3D() const;
106  const UT_Vector3 getPos2D() const;
107  const UT_Vector2 getPos2() const;
108  float getPw() const;
109  /// @}
110 
111  void setPos3D(const UT_Vector4 &p);
112  void setPos3D(const UT_Vector3 &p);
113  void setPos3D(const UT_Vector3 &p, float w);
114  void setPos3D(float x, float y, float z, float w);
115 
116  void setPos2D(const UT_Vector3 &p);
117  void setPos2D(const UT_Vector2 &p);
118  void setPos2D(const UT_Vector2 &p, float w);
119  void setPos2D(float x, float y, float w);
120 
121  void setPw(float w);
122 };
123 
124 inline const UT_Vector4
126 {
127  UT_ASSERT_P(getIndexMap().getOwner() == GA_ATTRIB_VERTEX);
128  return getDetail().getPos4( getDetail().vertexPoint(getMapOffset()) );
129 }
130 inline const UT_Vector3
132 {
133  UT_ASSERT(getIndexMap().getOwner() == GA_ATTRIB_VERTEX);
134  return getDetail().getPos3( getDetail().vertexPoint(getMapOffset()) );
135 }
136 inline const UT_Vector2
138 {
139  UT_ASSERT(getIndexMap().getOwner() == GA_ATTRIB_VERTEX);
140  return getDetail().getPos2( getDetail().vertexPoint(getMapOffset()) );
141 }
142 inline float
144 {
145  UT_ASSERT(getIndexMap().getOwner() == GA_ATTRIB_VERTEX);
146  return getDetail().getPw( getDetail().vertexPoint(getMapOffset()) );
147 }
148 inline void
150 {
151  UT_ASSERT_P(getIndexMap().getOwner() == GA_ATTRIB_VERTEX);
152  getDetail().setPos4( getDetail().vertexPoint(getMapOffset()), p );
153 }
154 inline void
156 {
157  UT_ASSERT_P(getIndexMap().getOwner() == GA_ATTRIB_VERTEX);
158  return getDetail().setPos3(getDetail().vertexPoint(getMapOffset()),p);
159 }
160 inline void
162 {
163  UT_ASSERT_P(getIndexMap().getOwner() == GA_ATTRIB_VERTEX);
164  UT_Vector4 p4(p.x(), p.y(), p.z(), w);
165  return getDetail().setPos4( getDetail().vertexPoint(getMapOffset()),
166  p4);
167 }
168 inline void
169 GA_GBVertex::setPos3D(float x, float y, float z, float w)
170 {
171  UT_ASSERT_P(getIndexMap().getOwner() == GA_ATTRIB_VERTEX);
172  UT_Vector4 p4(x, y, z, w);
173  return getDetail().setPos4( getDetail().vertexPoint(getMapOffset()),
174  p4);
175 }
176 inline void
178 {
179  UT_ASSERT(getIndexMap().getOwner() == GA_ATTRIB_VERTEX);
180  getDetail().setPos3( getDetail().vertexPoint(getMapOffset()), p);
181 }
182 inline void
184 {
185  UT_ASSERT(getIndexMap().getOwner() == GA_ATTRIB_VERTEX);
186  return getDetail().setPos2(getDetail().vertexPoint(getMapOffset()),p);
187 }
188 inline void
190 {
191  UT_ASSERT(getIndexMap().getOwner() == GA_ATTRIB_VERTEX);
192  return getDetail().setPos3(getDetail().vertexPoint(getMapOffset()),
193  p.x(), p.y(), w);
194 }
195 inline void
196 GA_GBVertex::setPos2D(float x, float y, float w)
197 {
198  UT_ASSERT(getIndexMap().getOwner() == GA_ATTRIB_VERTEX);
199  return getDetail().setPos3(getDetail().vertexPoint(getMapOffset()),
200  x, y, w);
201 }
202 inline void
204 {
205  UT_ASSERT(getIndexMap().getOwner() == GA_ATTRIB_VERTEX);
206  getDetail().setPw( getDetail().vertexPoint(getMapOffset()), w );
207 }
208 
210 {
211 public:
212  SYS_DEPRECATED_HDK(13.0)
214  : GA_GBVertex(index, offset) {}
215  SYS_DEPRECATED_HDK(13.0)
217  : GA_GBVertex() {}
218 
219  SYS_DEPRECATED_HDK(13.0)
221  : GA_GBVertex(v) {}
222 
223  SYS_DEPRECATED_HDK(13.0)
225  {
227  return *this;
228  }
229  SYS_DEPRECATED_HDK(13.0)
230  bool operator==(const GEO_Vertex &src) const
231  {
232  return GA_GBVertex::operator==(src);
233  }
234 
235  /// @{
236  /// Return the primitive that owns this vertex (references the vertex).
237  /// This may return a NULL pointer if the topology attributes aren't built
238  SYS_DEPRECATED_HDK(13.0)
239  const GEO_Primitive *getPrimitive() const;
240  SYS_DEPRECATED_HDK(13.0)
241  GEO_Primitive *getPrimitive();
242  /// @}
243 
244  /// @{
245  /// Get de-homogenized position (that is, without the homogeneous coordinate
246  /// multiplied through).
247  SYS_DEPRECATED_HDK(13.0)
248  const UT_Vector4 getPos() const { return GA_GBVertex::getPos3D(); }
249  /// @}
250 
251  /// @{
252  /// Get and set the homogeneous coordinate
253  SYS_DEPRECATED_HDK(13.0)
254  fpreal64 getPw() const { return GA_GBVertex::getPw(); }
255  SYS_DEPRECATED_HDK(13.0)
256  void setPw(fpreal64 w) { return GA_GBVertex::setPw(w); }
257  /// @}
258 
259  SYS_DEPRECATED_HDK(13.0)
261  SYS_DEPRECATED_HDK(13.0)
263  { GA_GBVertex::setPos3D(p, w); }
264  SYS_DEPRECATED_HDK(13.0)
266  { GA_GBVertex::setPos3D(x,y,z,1); }
267  SYS_DEPRECATED_HDK(13.0)
269  { GA_GBVertex::setPos3D(x,y,z,w); }
270 
271  /// New GA methods which support getting/setting positons without affecting
272  /// the w (homogeneous) coordinate.
273  /// @{
274  SYS_DEPRECATED_HDK(13.0)
275  const UT_Vector3 getPos3() const
276  { return GA_GBVertex::getPos2D(); }
277  SYS_DEPRECATED_HDK(13.0)
278  void setPos3(const UT_Vector3 &p)
279  { GA_GBVertex::setPos2D(p); }
280  /// @}
281 
282 private:
283  /// @{
284  /// Prevent array allocation of vertex objects
285  void *operator new[](size_t size);
286 #if defined(WIN32)
287 protected:
288 #endif
289  void operator delete[](void *p);
290  /// @}
291  // Nothing.
292 };
293 
295 
296 #endif
UT_Vector2 getPos2(GA_Offset ptoff) const
The ptoff passed is the point offset.
Definition: GA_Detail.h:173
A class to manage an ordered array which has fixed offset handles.
Definition: GA_IndexMap.h:63
SYS_FORCE_INLINE GA_Offset getPointOffset(GA_Size i) const
Definition: GA_Primitive.h:254
GA_Offset getMapOffset() const
Definition: GA_GBElement.h:103
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:623
void
Definition: png.h:1083
const UT_Vector3 getPos2D() const
Definition: GEO_Vertex.h:131
const GLdouble * v
Definition: glcorearb.h:837
#define SYS_DEPRECATED_PUSH_DISABLE()
UT_Vector4 getPos4(GA_Offset ptoff) const
The ptoff passed is the point offset.
Definition: GA_Detail.h:292
#define SYS_DEPRECATED_POP_DISABLE()
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
SYS_FORCE_INLINE void setPointOffset(GA_Size i, GA_Offset ptoff)
Definition: GA_Primitive.h:260
constexpr SYS_FORCE_INLINE T & z() noexcept
Definition: UT_Vector3.h:667
GLint y
Definition: glcorearb.h:103
GA_GBElement & operator=(const GA_GBElement &src)
Definition: GA_GBElement.h:81
void setPw(float w)
Definition: GEO_Vertex.h:203
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Offset ptoff) const
The ptoff passed is the point offset.
Definition: GA_Detail.h:185
const UT_Vector2 getPos2() const
Definition: GEO_Vertex.h:137
const UT_Vector4 getPos3D() const
Definition: GEO_Vertex.h:125
void setPos3D(const UT_Vector4 &p)
Definition: GEO_Vertex.h:149
double fpreal64
Definition: SYS_Types.h:201
SYS_FORCE_INLINE UT_Vector3D getPos3D(GA_Size i) const
Definition: GA_Primitive.h:277
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector2.h:423
GA_Size GA_Offset
Definition: GA_Types.h:641
GLintptr offset
Definition: glcorearb.h:665
void setPos4(GA_Offset ptoff, const UT_Vector4 &pos)
Set P from a UT_Vector4.
Definition: GA_Detail.h:302
GA_GBVertex(const GA_GBVertex &src)
Definition: GEO_Vertex.h:38
bool operator==(const GA_GBVertex &src) const
Definition: GEO_Vertex.h:68
fpreal getPw(GA_Offset ptoff) const
Get the homogeneous coordinate for a point.
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:155
void setPw(GA_Offset ptoff, fpreal w)
Set the homogeneous coordinate for a point.
#define GEO_API
Definition: GEO_API.h:14
GA_Detail & getDetail() const
Provide access to the GA_Detail containing this element.
Definition: GA_GBElement.h:97
void setPos2D(const UT_Vector3 &p)
Definition: GEO_Vertex.h:177
#define SYS_DEPRECATED_HDK(__V__)
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:635
GLint GLenum GLint x
Definition: glcorearb.h:409
GA_GBVertex & operator=(const GA_GBVertex &src)
Definition: GEO_Vertex.h:62
SYS_FORCE_INLINE GA_Index getPointIndex(GA_Size i) const
Definition: GA_Primitive.h:268
GLsizeiptr size
Definition: glcorearb.h:664
SYS_FORCE_INLINE void setPos3(GA_Offset ptoff, const UT_Vector3 &pos)
Set P from a UT_Vector3.
Definition: GA_Detail.h:237
float getPw() const
Definition: GEO_Vertex.h:143
GLuint index
Definition: glcorearb.h:786
bool operator==(const GA_GBElement &src) const
Definition: GA_GBElement.h:87
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
#define const
Definition: zconf.h:214
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector3.h:665
void setPos2(GA_Offset ptoff, const UT_Vector2 &pos)
Set P from a UT_Vector2.
Definition: GA_Detail.h:225
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector2.h:425
GA_GBVertex(const GA_IndexMap &index_map, GA_Offset offset)
Definition: GEO_Vertex.h:34
GLenum src
Definition: glcorearb.h:1793
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector3.h:663
const GA_IndexMap & getIndexMap() const
Provide access to the GA_IndexMap containing this element.
Definition: GA_GBElement.h:99