HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GU_Resample.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: GU_Resample.h ( GU Library, C++)
7  *
8  * COMMENTS: Resample polygons
9  */
10 
11 #pragma once
12 
13 #ifndef __GU_Resample__
14 #define __GU_Resample__
15 
16 #include "GU_API.h"
17 #include <UT/UT_Array.h>
18 #include <UT/UT_FloatArray.h>
19 #include <UT/UT_Lock.h>
21 #include <GA/GA_Handle.h>
22 #include <GA/GA_Types.h>
23 
24 class GEO_PrimPoly;
25 class GEO_Face;
26 class GEO_Detail;
27 class GA_PrimitiveGroup;
28 class GA_Attribute;
29 
31 {
32 public:
33  GU_Resample();
35 
36  //
37  // MeasureType controls how the segment length constraint is used:
38  // ARC means to measure along the *source* segments.
39  // CHORD means to measure along the *resampled* segments.
40  // EDGE means to measure along the *source* segments but to retain the
41  // original breakpoints.
42  //
43  enum MeasureType { ARC, CHORD, EDGE };
44  enum MethodType { DIST, X, Y, Z };
45  enum PolyCurvesAs { STRAIGHT, SUBD, INTERP };
46 
47  void setType(MeasureType type) { myType = type; }
48  void setMethod(MethodType type) { myMethod = type; }
50  { myTreatPolyCurvesAs = type; }
51  void setOutputAsSubD(bool outputassubd)
52  { myOutputAsSubD = outputassubd; }
53  void setAllEqual(bool allequal)
54  { myAllEqual = allequal; }
55  void setMaxSegments(int seg) { myMaxSegments = seg; }
56  void setMaxSegmentsAttrib(const GA_Attribute *attrib)
57  {
58  if (!attrib || attrib->getOwner() != GA_ATTRIB_PRIMITIVE)
59  return;
60  myMaxSegmentsAttrib.bind(attrib);
61  }
62  void setLength(float len) { mySegmentLength = len; }
63  void setLengthAttrib(const GA_Attribute *attrib)
64  {
65  if (!attrib || attrib->getOwner() != GA_ATTRIB_PRIMITIVE)
66  return;
67  mySegmentLengthAttrib.bind(attrib);
68  }
69  void setMaintainLast(int onoff) { myMaintain = onoff; }
70  void setLOD(float lod) { myLOD = lod; }
71 
72  class CreateAttrs {
73  public:
75  : ptdistattr(0)
76  , tangentattr(0)
77  , curveuattr(0)
78  , curvenumattr(0)
79  {}
80 
85  };
86 
87  void resampleFaces(
88  const GEO_Detail *src_gdp,
89  const GA_Offset *src_curve_offsets,
90  exint src_curve_count,
91  GEO_Detail *gdp,
92  const CreateAttrs &attrs,
93  bool onlypoints,
94  bool randomshift);
95 
96 private:
97  struct PrimInfo {
98  UT_FloatArray myUVals;
99  GA_Offset myPoly;
100  GA_Size myOff;
101  };
102 
104  prim_uvals.entries() > 1000,
105  resampleParametric,
106  UT_Array<PrimInfo> &, prim_uvals,
107  const GEO_Detail *, src_gdp,
108  const GA_Offset *, src_curve_offsets,
109  exint, src_curve_count,
110  bool, randomshift);
111 
112  void resampleParametricPartial(
113  UT_Array<PrimInfo> &prim_uvals,
114  const GEO_Detail *src_gdp,
115  const GA_Offset *src_curve_offsets,
116  exint src_curve_count,
117  bool randomshift,
118  const UT_JobInfo &info);
119 
121  prim_uvals.entries() > 1000,
122  fillAttributes,
123  UT_Array<PrimInfo> &, prim_uvals,
124  const GEO_Detail *, src_gdp,
125  const GA_Offset *, src_curve_offsets,
126  exint, src_curve_count,
127  GEO_Detail *, gdp,
128  const CreateAttrs &, attrs,
129  GA_Offset, ptoff);
130 
131  void fillAttributesPartial(
132  UT_Array<PrimInfo> &prim_uvals,
133  const GEO_Detail *src_gdp,
134  const GA_Offset *src_curve_offsets,
135  exint src_curve_count,
136  GEO_Detail *gdp,
137  const CreateAttrs &attrs,
138  GA_Offset ptoff,
139  const UT_JobInfo &info);
140 
141 private:
142  MeasureType myType;
143  MethodType myMethod;
144  int myMaxSegments;
145  GA_ROHandleI myMaxSegmentsAttrib;
146  float mySegmentLength;
147  GA_ROHandleF mySegmentLengthAttrib;
148  float myLOD;
149  PolyCurvesAs myTreatPolyCurvesAs;
150  bool myMaintain;
151  bool myOutputAsSubD;
152  bool myAllEqual;
153  UT_Lock myGroupCopyLock;
154 };
155 
156 #endif
157 
Definition of a geometry attribute.
Definition: GA_Attribute.h:189
#define THREADED_METHOD7(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5, PARMTYPE6, PARMNAME6, PARMTYPE7, PARMNAME7)
GA_Attribute * tangentattr
Definition: GU_Resample.h:82
GA_Attribute * curveuattr
Definition: GU_Resample.h:83
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:211
void setLength(float len)
Definition: GU_Resample.h:62
GA_Size GA_Offset
Definition: GA_Types.h:617
void setAllEqual(bool allequal)
Definition: GU_Resample.h:53
int64 exint
Definition: SYS_Types.h:109
void setType(MeasureType type)
Definition: GU_Resample.h:47
void setTreatPolyCurvesAs(PolyCurvesAs type)
Definition: GU_Resample.h:49
#define THREADED_METHOD5(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5)
void setMaxSegments(int seg)
Definition: GU_Resample.h:55
#define GU_API
Definition: GU_API.h:11
void setOutputAsSubD(bool outputassubd)
Definition: GU_Resample.h:51
void setLengthAttrib(const GA_Attribute *attrib)
Definition: GU_Resample.h:63
void setMethod(MethodType type)
Definition: GU_Resample.h:48
GA_AttributeOwner getOwner() const
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
GA_Attribute * ptdistattr
Definition: GU_Resample.h:81
void setMaxSegmentsAttrib(const GA_Attribute *attrib)
Definition: GU_Resample.h:56
void setMaintainLast(int onoff)
Definition: GU_Resample.h:69
GA_Attribute * curvenumattr
Definition: GU_Resample.h:84
void setLOD(float lod)
Definition: GU_Resample.h:70
GLint lod
Definition: glcorearb.h:2764