HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_ConvertParms.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: GEO_ConvertParms.h (GEO Library, C++)
7  *
8  * COMMENTS: A series of classes for specifying options when converting
9  * between different primitive types. This was formerly in
10  * the GU library as GU_ConvertParms.h.
11  */
12 
13 #ifndef __GEO_ConvertParms__
14 #define __GEO_ConvertParms__
15 
16 #include "GEO_PrimTypeCompat.h"
17 #include "GEO_SurfaceType.h"
18 #include <GA/GA_ElementGroup.h>
19 #include <GA/GA_ElementWrangler.h>
20 #include <UT/UT_NonCopyable.h>
21 #include <UT/UT_UniquePtr.h>
22 #include <UT/UT_Vector3.h>
23 #include <stddef.h>
24 
25 class GA_Detail;
26 class GEO_Detail;
27 
29 {
30  GU_CONVERT_LOD = 0, // use float level of detail
31  GU_CONVERT_DIV = 1 // use integer divisions
32 };
33 
34 // Conversion styles for metaballs.
36 {
41 
43 };
44 
46 {
47 public:
49 
50  int isLOD() const { return style == GU_CONVERT_LOD; }
51  int isDiv() const { return style == GU_CONVERT_DIV; }
52 
53  void doLOD() { style = GU_CONVERT_LOD; }
54  void doDiv() { style = GU_CONVERT_DIV; }
55 
56  float getULOD() const { return isLOD() ? u.lod : u.div; }
57  float getVLOD() const { return isLOD() ? v.lod : v.div; }
58  float getTrimLOD() const { return isLOD() ? trim.lod : trim.div; }
59 
60  void setULOD(float lod) { doLOD(); u.lod = lod; }
61  void setVLOD(float lod) { doLOD(); v.lod = lod; }
62  void setTrimLOD(float lod) { doLOD(); trim.lod = lod; }
63 
64  int validULOD() const
65  { return !isLOD() || (isLOD() && (u.lod > 0)); }
66  int validVLOD() const
67  { return !isLOD() || (isLOD() && (v.lod > 0)); }
68  int validTrimLOD() const
69  { return !isLOD() || (isLOD() && (trim.lod > 0)); }
70 
71  int getUDiv() const { return u.div; }
72  int getVDiv() const { return v.div; }
73  int getTrimDiv() const { return trim.div; }
74 
75  void setUDiv(int div) { doDiv(); u.div = div; }
76  void setVDiv(int div) { doDiv(); v.div = div; }
77  void setTrimDiv(int div) { doDiv(); trim.div = div; }
78 
79  int validUDiv() const { return isDiv() && (u.div >= 0); }
80  int validVDiv() const { return isDiv() && (v.div >= 0); }
81  int validTrimDiv() const { return isDiv() && (trim.div >= 0); }
82 
83  static const int GEO_EXTRA_LOD = 12;
84  static int floatLODToIntLOD(float lod) { return int(lod * float(GEO_EXTRA_LOD)); }
85 
86 private:
87  typedef union
88  {
89  float lod;
90  int div;
91  } ConvertUnion;
92 
93  ConvertUnion u;
94  ConvertUnion v;
95  ConvertUnion trim;
96  GEO_ConvertStyle style;
97 };
98 
100 {
101 public:
104 
105  int orderu;
106  int orderv;
108 
109  /// @{
110  /// Accessors
111  int uOrder() const { return orderu; }
112  int vOrder() const { return orderv; }
113  void setUOrder(int o) { orderu = o; }
114  void setVOrder(int o) { orderv = o; }
115  GEO_SurfaceType surfaceType() const { return surface; }
116  void setSurfaceType(GEO_SurfaceType t) { surface = t; }
117  GEO_ConvertMethod convertMethod() const { return method; }
118  void setConvertMethod(GEO_ConvertMethod m) { method = m; }
119  bool interpolateHull() const { return interpHull; }
120  void setInterpolateHull(bool b) { interpHull = b; }
121  bool trimSurface() const { return trimmed; }
122  void setTrimSurface(bool b) { trimmed = b; }
123  bool sharedFaces() const { return mySharedFaces; }
124  void setSharedFaces(bool b) { mySharedFaces = b; }
125  bool metaClustering() const { return myMetaClusterFlag; }
126  void setMetaClustering(bool b) { myMetaClusterFlag = b; }
127  float metaOffset() const { return myOffset; }
128  void setMetaOffset(fpreal f) { myOffset = f; }
129  bool keepGroups() const { return preserveGroups; }
130  void setKeepGroups(bool f) { preserveGroups = f; }
131  const GEO_Detail *sourceDetail() const { return mySourceDetail; }
132  void setSourceDetail(const GEO_Detail *g) { mySourceDetail=g;}
133  GEO_Detail *destDetail() const { return myDestDetail; }
134  void setDestDetail(GEO_Detail *g) { myDestDetail = g;}
135  /// @}
136 
137  /// @{
138  /// If set, use the feature, if not set use the base
139  bool pastedFeatureCoord() const { return featureCoord; }
140  void setPastedFeatureCoord(bool b) { featureCoord = b; }
141  bool pastedFeatureAttrib() const { return featureAttrib; }
142  void setPastedFeatureAttrib(bool b) { featureAttrib = b; }
143  /// @}
144 
147  int trimmed; // trimmed spline surface
148  bool mySharedFaces; // Output shared faces from tets.
149 
150  int featureCoord; // 1 feature, 0 base (for pasting)
151  int featureAttrib; // 1 feature, 0 base (for pasting)
153 
154  float myOffset; // Used for biasing isosurfaces.
155 
157 
158  // Warning: This primGroup is potentially modified by the conversion
160 
163 
164  // If the gdp passed in is null, then no group will be created, the
165  // existing group (if any) will be returned.
166  // The user of the convert parms is required to blow these groups away
167  // TODO: Change these to take GA_Detail pointers instead
168  GA_PointGroup *getDeletePoints(GEO_Detail *gdp = nullptr);
169  GA_PrimitiveGroup *getDeletePrimitives(GEO_Detail *gdp = nullptr);
170  void clearGroups()
171  {
172  myDeletePoints = nullptr;
173  myDeletePrimitives = nullptr;
174  }
175 
176  /// Returns a GA_ElementWranglerCache using mySourceDetail and myDestDetail
178  {
179  UT_ASSERT(mySourceDetail && myDestDetail);
180  return getWranglers(*(GA_Detail*)myDestDetail,
181  (const GA_Detail*)mySourceDetail);
182  }
184  {
185  UT_ASSERT(mySourceDetail && myDestDetail);
186  return getGroupWranglers(*(GA_Detail*)myDestDetail,
187  (const GA_Detail *)mySourceDetail);
188  }
189 
191  GA_Detail &dest, const GA_Detail *src = nullptr)
192  {
193  cacheWranglers(myWranglers, dest, src, false);
194  return *myWranglers;
195  }
197  GA_Detail &dest, const GA_Detail *src = nullptr)
198  {
199  cacheWranglers(myGroupWranglers, dest, src, true);
200  return *myGroupWranglers;
201  }
202 
203  GA_PrimCompat::TypeMask fromType() const { return myFromType; }
205  { myFromType = t; }
206 
207  GA_PrimCompat::TypeMask toType() const { return myToType; }
209  { myToType = t; }
210 
211 private: // METHODS
212  void cacheWranglers(
214  &wranglers,
215  GA_Detail &dest,
216  const GA_Detail *src,
217  bool for_groups);
218 
219  GA_ElementWranglerCache *allocWranglerCache(
220  GA_Detail &dest,
221  const GA_Detail &src,
222  bool for_groups) const;
223 
224 private: // DATA
225  GA_PrimCompat::TypeMask myFromType;
226  GA_PrimCompat::TypeMask myToType;
227 
228 
229  GA_PointGroup *myDeletePoints; // Extra points to delete
230  GA_PrimitiveGroup *myDeletePrimitives; // Extra primitives to delete
231 
233  UT_UniquePtr<GA_ElementWranglerCache> myGroupWranglers;
234 };
235 
236 
237 inline void
238 GEO_ConvertParms::cacheWranglers(
240  GA_Detail &dest,
241  const GA_Detail *src,
242  bool for_groups)
243 {
244  if (!src)
245  src = &dest;
246 
247  // TODO: Include GEO_Detail.h?
248  if (!wranglers)
249  wranglers.reset(allocWranglerCache(dest, *src, for_groups));
250  else if (!wranglers->isValid(dest, *src))
251  wranglers->reset(dest, *src);
252 }
253 
254 // Conversion parameters for special metaball conversions. See documentation
255 // of Convert Meta SOP for more details.
257 {
258 public:
261 
264  int myDivs[3];
268  int myAxis;
272 
274 };
275 
276 #endif
bool pastedFeatureCoord() const
GEO_MetaConvertStyleType
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
void setTrimSurface(bool b)
GA_API const UT_StringHolder div
void setPastedFeatureAttrib(bool b)
void setPastedFeatureCoord(bool b)
GEO_MetaConvertStyleType myStyle
int uOrder() const
bool metaClustering() const
void setMetaClustering(bool b)
void setULOD(float lod)
GA_ElementWranglerCache & getGroupWranglers()
void setConvertMethod(GEO_ConvertMethod m)
const GLdouble * v
Definition: glcorearb.h:837
void setSourceDetail(const GEO_Detail *g)
void setInterpolateHull(bool b)
int isDiv() const
int isLOD() const
GLboolean GLboolean g
Definition: glcorearb.h:1222
void setDestDetail(GEO_Detail *g)
GLdouble s
Definition: glad.h:3009
GA_PrimitiveGroup * primGroup
GEO_Detail * destDetail() const
int validULOD() const
void setToType(const GA_PrimCompat::TypeMask &t)
float getULOD() const
GEO_ConvertMethod convertMethod() const
const GEO_Detail * mySourceDetail
GA_ElementWranglerCache & getWranglers(GA_Detail &dest, const GA_Detail *src=nullptr)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
void setUOrder(int o)
bool interpolateHull() const
bool sharedFaces() const
GLfloat f
Definition: glcorearb.h:1926
int getUDiv() const
GEO_Detail * myDestDetail
GEO_SurfaceType surfaceType() const
int validUDiv() const
float getTrimLOD() const
bool keepGroups() const
int getVDiv() const
void setSharedFaces(bool b)
#define GEO_API
Definition: GEO_API.h:14
GEO_SurfaceType surface
bool pastedFeatureAttrib() const
GA_PrimCompat::TypeMask fromType() const
void trim(std::string &s)
Definition: Name.h:83
GA_ElementWranglerCache & getWranglers()
Returns a GA_ElementWranglerCache using mySourceDetail and myDestDetail.
float metaOffset() const
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GA_PrimCompat::TypeMask toType() const
float getVLOD() const
GLdouble t
Definition: glad.h:2397
void setUDiv(int div)
void setFromType(const GA_PrimCompat::TypeMask &t)
void setMetaOffset(fpreal f)
int validVDiv() const
Contains transitional objects to provide some backward compatibility for code that references old GEO...
void setVOrder(int o)
GEO_ConvertStyle
void setVDiv(int div)
fpreal64 fpreal
Definition: SYS_Types.h:277
void setSurfaceType(GEO_SurfaceType t)
void setKeepGroups(bool f)
static int floatLODToIntLOD(float lod)
void setVLOD(float lod)
GEO_ConvertMethod method
GEO_SurfaceType
Container class for all geometry.
Definition: GA_Detail.h:96
GEO_ConvertMethod(GEO_ConvertStyle s=GU_CONVERT_LOD)
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
int validVLOD() const
void setTrimDiv(int div)
int vOrder() const
void setTrimLOD(float lod)
int validTrimDiv() const
GA_ElementWranglerCache & getGroupWranglers(GA_Detail &dest, const GA_Detail *src=nullptr)
const GEO_Detail * sourceDetail() const
bool trimSurface() const
int validTrimLOD() const
GLint lod
Definition: glcorearb.h:2765
int getTrimDiv() const
GLenum src
Definition: glcorearb.h:1793