HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GA_AttributeRefMapDestHandle< DOwner > Class Template Reference

A handle to simplify manipulation of multiple attributes. More...

#include <GA_AttributeRefMapDestHandle.h>

Public Member Functions

 GA_AttributeRefMapDestHandle (const GA_AttributeRefMap &map)
 Minimal constructor. More...
 
 GA_AttributeRefMapDestHandle (const GA_AttributeRefMapDestHandle &src)
 Copy constructor. More...
 
 ~GA_AttributeRefMapDestHandle ()
 Destructor. More...
 
int entries () const
 Return the number of attributes in the list. More...
 
int entriesWithSourceP () const
 
void homogenize () const
 Homogenize any rational attributes of the current element. More...
 
void dehomogenize () const
 Dehomogenize any rational attributes of the current element. More...
 
void copy (GA_Offset offset) const
 
void add (GA_Offset source_index, fpreal scale=1) const
 
void sub (GA_Offset source_index) const
 
void mul (GA_Offset source_index) const
 
void lerp (GA_Offset s0, GA_Offset s1, fpreal t) const
 
void lerpH (GA_Offset s0, GA_Offset s1, fpreal t) const
 
void add (GA_WeightedSum &sum, GA_Offset source_index, fpreal w) const
 
void addH (GA_WeightedSum &sum, GA_Offset source_index, fpreal w) const
 
void barycentric (GA_Offset p0, GA_Offset p1, GA_Offset p2, fpreal u, fpreal v) const
 
void bilinear (GA_Offset u0v0, GA_Offset u1v0, GA_Offset u0v1, GA_Offset u1v1, fpreal u, fpreal v) const
 
void zero () const
 Zero an attribute. This is equivalent to a weighted sum of 0 elements. More...
 
void multiply (fpreal scale) const
 Multiply operation: More...
 
void dump (const char *msg,...) const
 Debug statement to dump all the attributes to stdout. More...
 
bool setElement (GA_Offset offset)
 
void copyExplicitPosition (const UT_Vector2 &p) const
 
void copyExplicitPosition (const UT_Vector2D &p) const
 
void copyExplicitPosition (const UT_Vector3 &p) const
 
void copyExplicitPosition (const UT_Vector3D &p) const
 
void copyExplicitPosition (const UT_Vector4 &p) const
 
void copyExplicitPosition (const UT_Vector4D &p) const
 
void startSum (const GA_WeightedSum &sum) const
 
void startHSum (const GA_WeightedSum &sum) const
 
void finishSum (const GA_WeightedSum &sum, fpreal normalization=1) const
 
void finishHSum (const GA_WeightedSum &sum, fpreal normalization=1) const
 
void transform (const UT_Matrix4 &m, const UT_Matrix4 &im) const
 
void transform (const UT_DMatrix4 &m, const UT_DMatrix4 &im) const
 
bool isEqual (GA_Offset cmp) const
 
bool isAlmostEqual (GA_Offset cmp) const
 
void copyDest (GA_Offset offset) const
 
void addDest (GA_Offset offset) const
 
void subDest (GA_Offset offset) const
 
void lerpDest (GA_Offset s0, GA_Offset s1, fpreal t) const
 
void addDest (GA_WeightedSum &sum, GA_Offset offset, fpreal w) const
 
void addHDest (GA_WeightedSum &sum, GA_Offset offset, fpreal w) const
 

Detailed Description

template<GA_AttributeOwner DOwner>
class GA_AttributeRefMapDestHandle< DOwner >

A handle to simplify manipulation of multiple attributes.

The GA_AttributeRefMapDestHandle class simplifies interaction with a GA_AttributeRefMap by tracking the current destination element.

When performing operations on object elements, all attribute classes which are uniquely identified by the owner of the object will be operated on. For example, when operating on a vertex, it is possible to uniquely identify a point object. Thus, when add() is called, vertex and point attributes on the source detail will be processed. When add() is called with the owner set to GA_ATTRIB_POINT, there may be multiple vertices which share the point. So, only point attributes will be processed.

This can be summarized by:

The same semantics are used when setting an element on the handle. If setPrimitive() is called, destination primitive and global attributes will be modified.

By default, operations on "P" are performed as with any other attribute. However, it's possible to turn on the homogeneous flag which will ensure that operations are done using homogeneous coordinates.

Definition at line 61 of file GA_AttributeRefMapDestHandle.h.

Constructor & Destructor Documentation

template<GA_AttributeOwner DOwner>
GA_AttributeRefMapDestHandle< DOwner >::GA_AttributeRefMapDestHandle ( const GA_AttributeRefMap map)
inline

Minimal constructor.

Definition at line 70 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
GA_AttributeRefMapDestHandle< DOwner >::GA_AttributeRefMapDestHandle ( const GA_AttributeRefMapDestHandle< DOwner > &  src)
inline

Copy constructor.

Definition at line 75 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
GA_AttributeRefMapDestHandle< DOwner >::~GA_AttributeRefMapDestHandle ( )
inline

Destructor.

Definition at line 78 of file GA_AttributeRefMapDestHandle.h.

Member Function Documentation

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::add ( GA_Offset  source_index,
fpreal  scale = 1 
) const
inline

Add operation:

dest += source*scale

This is the generic add operation

Definition at line 136 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::add ( GA_WeightedSum sum,
GA_Offset  source_index,
fpreal  w 
) const
inline

Add a value into the weighted sum. This advances the weighted sum with the weight given.

Definition at line 194 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::addDest ( GA_Offset  offset) const
inline

Standard operations read the source and write to the destination. However. These operations operate by reading and writing the destination.

See Also
copyValue(), addValue(), subValue(), lerpValue()

Definition at line 270 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::addDest ( GA_WeightedSum sum,
GA_Offset  offset,
fpreal  w 
) const
inline

Standard operations read the source and write to the destination. However. These operations operate by reading and writing the destination.

See Also
copyValue(), addValue(), subValue(), lerpValue()

Definition at line 282 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::addH ( GA_WeightedSum sum,
GA_Offset  source_index,
fpreal  w 
) const
inline

Definition at line 201 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::addHDest ( GA_WeightedSum sum,
GA_Offset  offset,
fpreal  w 
) const
inline

Standard operations read the source and write to the destination. However. These operations operate by reading and writing the destination.

See Also
copyValue(), addValue(), subValue(), lerpValue()

Definition at line 288 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::barycentric ( GA_Offset  p0,
GA_Offset  p1,
GA_Offset  p2,
fpreal  u,
fpreal  v 
) const
inline

Compute barycentric coordinates for 3 values

result = (1 - u - v)*p0 + u*p1 + v*p2

Definition at line 211 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::bilinear ( GA_Offset  u0v0,
GA_Offset  u1v0,
GA_Offset  u0v1,
GA_Offset  u1v1,
fpreal  u,
fpreal  v 
) const
inline

Compute bilinear interpolation over 4 values of a quadrilateral. The math is the same as SYSbilerp():

(u=0,v=1) u0v1 u1v1 (u=1,v=1)
+--------+
| |
| |
+--------+
(u=0,v=0) u0v0 u1v0 (u=1,v=0)

Definition at line 227 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::copy ( GA_Offset  offset) const
inline

Copy operation:

dest = source

This is the generic copy operation

Definition at line 113 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::copyDest ( GA_Offset  offset) const
inline

Standard operations read the source and write to the destination. However. These operations operate by reading and writing the destination.

See Also
copyValue(), addValue(), subValue(), lerpValue()

Definition at line 267 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::copyExplicitPosition ( const UT_Vector2 p) const
inline

Copy operations:

dest = position

Sets any attributes that read the position attribute to an explicit value.

Definition at line 120 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::copyExplicitPosition ( const UT_Vector2D p) const
inline

Copy operations:

dest = position

Sets any attributes that read the position attribute to an explicit value.

Definition at line 122 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::copyExplicitPosition ( const UT_Vector3 p) const
inline

Copy operations:

dest = position

Sets any attributes that read the position attribute to an explicit value.

Definition at line 124 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::copyExplicitPosition ( const UT_Vector3D p) const
inline

Copy operations:

dest = position

Sets any attributes that read the position attribute to an explicit value.

Definition at line 126 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::copyExplicitPosition ( const UT_Vector4 p) const
inline

Copy operations:

dest = position

Sets any attributes that read the position attribute to an explicit value.

Definition at line 128 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::copyExplicitPosition ( const UT_Vector4D p) const
inline

Copy operations:

dest = position

Sets any attributes that read the position attribute to an explicit value.

Definition at line 130 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::dehomogenize ( ) const
inline

Dehomogenize any rational attributes of the current element.

Definition at line 108 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::dump ( const char *  msg,
  ... 
) const

Debug statement to dump all the attributes to stdout.

template<GA_AttributeOwner DOwner>
int GA_AttributeRefMapDestHandle< DOwner >::entries ( ) const
inline

Return the number of attributes in the list.

Definition at line 82 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
int GA_AttributeRefMapDestHandle< DOwner >::entriesWithSourceP ( ) const
inline

Return the number of attributes in the list that are paired with the source being P.

Definition at line 87 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::finishHSum ( const GA_WeightedSum sum,
fpreal  normalization = 1 
) const
inline

Weighted sum operation:

dest = sum(w[i]*s[i])
// Compute the average value of the P attribute and store in a
// global attribute "averageP".
int npts;
map.append( detail.findGlobalAttribute("averageP"),
detail.findPointAttribute("P") );
gah.startSum(sum);
for (GA_Iterator it = gdp.getPointRange(); !it.atEnd(); ++it)
gah.sumPoint(sum, it.getOffset(), 1);
npts = gdp.getNumPoints();
gah.finishSum(sum, npts ? 1./npts : 0);

Definition at line 187 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::finishSum ( const GA_WeightedSum sum,
fpreal  normalization = 1 
) const
inline

Weighted sum operation:

dest = sum(w[i]*s[i])
// Compute the average value of the P attribute and store in a
// global attribute "averageP".
int npts;
map.append( detail.findGlobalAttribute("averageP"),
detail.findPointAttribute("P") );
gah.startSum(sum);
for (GA_Iterator it = gdp.getPointRange(); !it.atEnd(); ++it)
gah.sumPoint(sum, it.getOffset(), 1);
npts = gdp.getNumPoints();
gah.finishSum(sum, npts ? 1./npts : 0);

Definition at line 184 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::homogenize ( ) const
inline

Homogenize any rational attributes of the current element.

Definition at line 105 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
bool GA_AttributeRefMapDestHandle< DOwner >::isAlmostEqual ( GA_Offset  cmp) const
inline

Compare value with another elements

Definition at line 258 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
bool GA_AttributeRefMapDestHandle< DOwner >::isEqual ( GA_Offset  cmp) const
inline

Compare value with another elements

Definition at line 256 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::lerp ( GA_Offset  s0,
GA_Offset  s1,
fpreal  t 
) const
inline

Linear interpolation operation:

dest = s0 + (s1 - s0)*t

Generic linear interpolation between two of the same elements

Definition at line 158 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::lerpDest ( GA_Offset  s0,
GA_Offset  s1,
fpreal  t 
) const
inline

Standard operations read the source and write to the destination. However. These operations operate by reading and writing the destination.

See Also
copyValue(), addValue(), subValue(), lerpValue()

Definition at line 276 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::lerpH ( GA_Offset  s0,
GA_Offset  s1,
fpreal  t 
) const
inline

Definition at line 160 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::mul ( GA_Offset  source_index) const
inline

Mul operation:

dest *= source

This is the generic mul operation

Definition at line 151 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::multiply ( fpreal  scale) const
inline

Multiply operation:

dest *= scale

Definition at line 239 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
bool GA_AttributeRefMapDestHandle< DOwner >::setElement ( GA_Offset  offset)
inline

Set the destination element. Operations will write to the element specified.

Only attributes which are fully qualified by the element will be operated on.

  • Point: Point and detail attributes
  • Vertex: Vertex, point, primitive and detail attributes
  • Primitive: Primitive and detail attributes
  • Global: Only global attributes

Definition at line 100 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::startHSum ( const GA_WeightedSum sum) const
inline

Weighted sum operation:

dest = sum(w[i]*s[i])
// Compute the average value of the P attribute and store in a
// global attribute "averageP".
int npts;
map.append( detail.findGlobalAttribute("averageP"),
detail.findPointAttribute("P") );
gah.startSum(sum);
for (GA_Iterator it = gdp.getPointRange(); !it.atEnd(); ++it)
gah.sumPoint(sum, it.getOffset(), 1);
npts = gdp.getNumPoints();
gah.finishSum(sum, npts ? 1./npts : 0);

Definition at line 182 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::startSum ( const GA_WeightedSum sum) const
inline

Weighted sum operation:

dest = sum(w[i]*s[i])
// Compute the average value of the P attribute and store in a
// global attribute "averageP".
int npts;
map.append( detail.findGlobalAttribute("averageP"),
detail.findPointAttribute("P") );
gah.startSum(sum);
for (GA_Iterator it = gdp.getPointRange(); !it.atEnd(); ++it)
gah.sumPoint(sum, it.getOffset(), 1);
npts = gdp.getNumPoints();
gah.finishSum(sum, npts ? 1./npts : 0);

Definition at line 180 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::sub ( GA_Offset  source_index) const
inline

Sub operation:

dest -= source

This is the generic sub operation

Definition at line 144 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::subDest ( GA_Offset  offset) const
inline

Standard operations read the source and write to the destination. However. These operations operate by reading and writing the destination.

See Also
copyValue(), addValue(), subValue(), lerpValue()

Definition at line 273 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::transform ( const UT_Matrix4 m,
const UT_Matrix4 im 
) const
inline

Transform attributes. This uses tags on the attribute to determine how to perform the transform.

Parameters
mThe transform matrix
imThe inverse of (i.e. m.invert(im) ) Transforms are independent of the source geometry.

Definition at line 248 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::transform ( const UT_DMatrix4 m,
const UT_DMatrix4 im 
) const
inline

Transform attributes. This uses tags on the attribute to determine how to perform the transform.

Parameters
mThe transform matrix
imThe inverse of (i.e. m.invert(im) ) Transforms are independent of the source geometry.

Definition at line 250 of file GA_AttributeRefMapDestHandle.h.

template<GA_AttributeOwner DOwner>
void GA_AttributeRefMapDestHandle< DOwner >::zero ( ) const
inline

Zero an attribute. This is equivalent to a weighted sum of 0 elements.

Definition at line 236 of file GA_AttributeRefMapDestHandle.h.


The documentation for this class was generated from the following file: