HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_SoftTransformCache.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: Simple cache for distances between geometry elements
9  * during soft transforms. These structures are in essense
10  * groups that are not attached to the gdp. Along with
11  * each soft element of the group, we have a float value which
12  * stores the squared distance to the nearest hard element.
13  *
14  * Thus, with this cache we are able to store soft squared
15  * distances, and implicitly store connectivity information.
16  * Simply, if an element is not contained in the cache,
17  * it will not be affected by the soft operation.
18  */
19 
20 #ifndef __GU_SoftTransformCache_H__
21 #define __GU_SoftTransformCache_H__
22 
23 #include "GEO_API.h"
24 #include <GA/GA_Types.h>
25 #include <UT/UT_Array.h>
26 #include <UT/UT_FloatArray.h>
27 
29 {
30 public:
33 
35  { myHardArray.append(offset); }
36 
37  void appendSoftOffset(GA_Offset offset, float dist2)
38  {
39  mySoftArray.append(offset);
40  mySoftDistArray.append(dist2);
41  }
42 
44  { return myHardArray(i); }
45 
47  { return mySoftArray(i); }
48 
49  float getSoftDist2(exint i) const
50  { return mySoftDistArray(i); }
51 
52  /// Number of hard points
54  { return myHardArray.entries(); }
55 
56  /// Number of soft points
58  {
59  UT_ASSERT_P(mySoftArray.entries() == mySoftDistArray.entries());
60  return mySoftArray.entries();
61  }
62 
63  void clearCache()
64  {
65  myHardArray.setCapacity(0);
66  mySoftArray.setCapacity(0);
67  mySoftDistArray.setCapacity(0);
68  }
69 
70  // Access the arrays
71  UT_Array<GA_Offset> &hardArray() { return myHardArray; }
72  UT_Array<GA_Offset> &softArray() { return mySoftArray; }
73  UT_FloatArray& softDistArray() { return mySoftDistArray; }
74 
75 private:
76  UT_Array<GA_Offset> myHardArray;
77  UT_Array<GA_Offset> mySoftArray;
78  UT_FloatArray mySoftDistArray;
79 };
80 
81 #endif
exint hardEntries() const
Number of hard points.
int64 exint
Definition: SYS_Types.h:125
void setCapacity(exint new_capacity)
void appendSoftOffset(GA_Offset offset, float dist2)
GA_Size GA_Offset
Definition: GA_Types.h:641
GA_Offset getSoftOffset(exint i) const
GLintptr offset
Definition: glcorearb.h:665
UT_Array< GA_Offset > & softArray()
GA_Offset getHardOffset(exint i) const
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:155
void appendHardOffset(GA_Offset offset)
exint append()
Definition: UT_Array.h:142
exint softEntries() const
Number of soft points.
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:648
float getSoftDist2(exint i) const
UT_FloatArray & softDistArray()
UT_Array< GA_Offset > & hardArray()