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:
102  /// Defaults to converting everything to polygons, without interpolating
103  /// through hulls, and does not keep groups.
106 
107  int orderu;
108  int orderv;
110 
111  /// @{
112  /// Accessors
113  int uOrder() const { return orderu; }
114  int vOrder() const { return orderv; }
115  void setUOrder(int o) { orderu = o; }
116  void setVOrder(int o) { orderv = o; }
117  GEO_SurfaceType surfaceType() const { return surface; }
119  GEO_ConvertMethod convertMethod() const { return method; }
120  void setConvertMethod(GEO_ConvertMethod m) { method = m; }
121  bool interpolateHull() const { return interpHull; }
122  void setInterpolateHull(bool b) { interpHull = b; }
123  bool trimSurface() const { return trimmed; }
124  void setTrimSurface(bool b) { trimmed = b; }
125  bool sharedFaces() const { return mySharedFaces; }
126  void setSharedFaces(bool b) { mySharedFaces = b; }
127  bool metaClustering() const { return myMetaClusterFlag; }
128  void setMetaClustering(bool b) { myMetaClusterFlag = b; }
129  float metaOffset() const { return myOffset; }
130  void setMetaOffset(fpreal f) { myOffset = f; }
131  bool keepGroups() const { return preserveGroups; }
132  void setKeepGroups(bool f) { preserveGroups = f; }
133  const GEO_Detail *sourceDetail() const { return mySourceDetail; }
134  void setSourceDetail(const GEO_Detail *g) { mySourceDetail=g;}
135  GEO_Detail *destDetail() const { return myDestDetail; }
136  void setDestDetail(GEO_Detail *g) { myDestDetail = g;}
137  /// @}
138 
139  /// @{
140  /// If set, use the feature, if not set use the base
141  bool pastedFeatureCoord() const { return featureCoord; }
142  void setPastedFeatureCoord(bool b) { featureCoord = b; }
143  bool pastedFeatureAttrib() const { return featureAttrib; }
144  void setPastedFeatureAttrib(bool b) { featureAttrib = b; }
145  /// @}
146 
149  int trimmed; // trimmed spline surface
150  bool mySharedFaces; // Output shared faces from tets.
151 
152  int featureCoord; // 1 feature, 0 base (for pasting)
153  int featureAttrib; // 1 feature, 0 base (for pasting)
155 
156  float myOffset; // Used for biasing isosurfaces.
157 
159 
160  // Warning: This primGroup is potentially modified by the conversion
162 
165 
166  // If the gdp passed in is null, then no group will be created, the
167  // existing group (if any) will be returned.
168  // The user of the convert parms is required to blow these groups away
169  // TODO: Change these to take GA_Detail pointers instead
170  GA_PointGroup *getDeletePoints(GEO_Detail *gdp = nullptr);
171  GA_PrimitiveGroup *getDeletePrimitives(GEO_Detail *gdp = nullptr);
172  void clearGroups()
173  {
174  myDeletePoints = nullptr;
175  myDeletePrimitives = nullptr;
176  }
177 
178  /// Returns a GA_ElementWranglerCache using mySourceDetail and myDestDetail
180  {
181  UT_ASSERT(mySourceDetail && myDestDetail);
182  return getWranglers(*(GA_Detail*)myDestDetail,
183  (const GA_Detail*)mySourceDetail);
184  }
186  {
187  UT_ASSERT(mySourceDetail && myDestDetail);
188  return getGroupWranglers(*(GA_Detail*)myDestDetail,
189  (const GA_Detail *)mySourceDetail);
190  }
191 
193  GA_Detail &dest, const GA_Detail *src = nullptr)
194  {
195  cacheWranglers(myWranglers, dest, src, false);
196  return *myWranglers;
197  }
199  GA_Detail &dest, const GA_Detail *src = nullptr)
200  {
201  cacheWranglers(myGroupWranglers, dest, src, true);
202  return *myGroupWranglers;
203  }
204 
205  GA_PrimCompat::TypeMask fromType() const { return myFromType; }
207  { myFromType = t; }
208 
209  GA_PrimCompat::TypeMask toType() const { return myToType; }
211  { myToType = t; }
212 
213 private: // METHODS
214  void cacheWranglers(
216  &wranglers,
217  GA_Detail &dest,
218  const GA_Detail *src,
219  bool for_groups);
220 
221  GA_ElementWranglerCache *allocWranglerCache(
222  GA_Detail &dest,
223  const GA_Detail &src,
224  bool for_groups) const;
225 
226 private: // DATA
227  GA_PrimCompat::TypeMask myFromType;
228  GA_PrimCompat::TypeMask myToType;
229 
230 
231  GA_PointGroup *myDeletePoints; // Extra points to delete
232  GA_PrimitiveGroup *myDeletePrimitives; // Extra primitives to delete
233 
235  UT_UniquePtr<GA_ElementWranglerCache> myGroupWranglers;
236 };
237 
238 
239 inline void
240 GEO_ConvertParms::cacheWranglers(
242  GA_Detail &dest,
243  const GA_Detail *src,
244  bool for_groups)
245 {
246  if (!src)
247  src = &dest;
248 
249  // TODO: Include GEO_Detail.h?
250  if (!wranglers)
251  wranglers.reset(allocWranglerCache(dest, *src, for_groups));
252  else if (!wranglers->isValid(dest, *src))
253  wranglers->reset(dest, *src);
254 }
255 
256 // Conversion parameters for special metaball conversions. See documentation
257 // of Convert Meta SOP for more details.
259 {
260 public:
263 
266  int myDivs[3];
270  int myAxis;
274 
276 };
277 
278 #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