HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_FitCubic.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: UT_FitCubic (C++)
7  *
8  * COMMENTS: Given a group within a detail, fit curves to
9  * each polygon.
10  *
11  */
12 
13 #ifndef __UT_FitCubic_H__
14 #define __UT_FitCubic_H__
15 
16 
17 #include "UT_API.h"
18 #include "UT_Vector2.h"
19 
20 class UT_Interrupt;
21 
23 {
26 
27 };
28 
30 {
34 };
35 
36 template <typename T>
38 {
39 public:
40 
41  UT_FitCubicT();
42  ~UT_FitCubicT();
43 
45  typedef Vector2 CubicCurve[4];
46 
47  // segment, last point will always
48  // match beginning of next segment
49  struct Span
50  {
52  int isLinear;
54  };
55 
56 
57  int fitCurve(Vector2 *d, int nPts, int closed, fpreal error2,
58  bool preserveExtrema, bool use_kupan_slopes=false);
59 
60  const Span *getFirstSpan() const
61  { return myHead; }
62 
63  int numSpans() const
64  { return myNSpans; }
65 
67  { return myContainsCurve; }
68 
70  { myCurveType = type; }
71 
73  { myFitType = type; }
74 
75  static Vector2 calcCubic(Vector2 *V, fpreal t);
76 
77 private:
78 
79  int myContainsCurve;
80  fpreal myError2;
81  Span *myHead;
82 
83  void destroySolution();
84 
85 
86  Span *appendCurve(CubicCurve fcurve, int islinear);
87 
88 
89  int fitLine(Vector2 *d, int first, int last,
90  Span **head, Span **tail,
91  int recurse);
92 
93  int fitCubic(Vector2 *d, int f, int l,Vector2 tHat1,
94  Vector2 tHat2,
95  Span **head, Span **tail,
96  bool preserveExtrema, bool use_kupan_slopes,
97  UT_Interrupt *boss);
98 
99  Vector2 computeCenterTangent(Vector2 *d, int center);
100  Vector2 computeMonotonicTangent(Vector2 *d, int center);
101 
102  T *reparameterize(Vector2 *d, int first, int last,
103  T *u, CubicCurve fcurve);
104 
105  fpreal newtonRaphsonRootFind(CubicCurve Q, Vector2 P, fpreal u);
106 
107  Vector2 calcBezier2(Vector2 *V, fpreal t);
108  Vector2 calcBezier3(Vector2 *V, fpreal t);
109 
110 
111  fpreal computeBezierError(Vector2 *d, int first, int last,
112  CubicCurve fcurve, T *u, int *splitPoint);
113 
114  fpreal computeCubicError(Vector2 *d, int first, int last,
115  CubicCurve fcurve, int *splitPoint,
116  bool preserveExtrema);
117 
118  fpreal computeLineError(Vector2 *d, int first, int last,
119  CubicCurve fcurve, T *u, int *splitPoint);
120 
121  T *chordLengthParameterize(Vector2 *d,int f,int l);
122 
123  void generateBezier(Vector2 *d, int first, int last,
124  T *uPrime, Vector2 tHat1,
125  Vector2 tHat2, CubicCurve fcurve);
126 
127  void simpleCurve(Vector2 *d, int first, int last,
128  Vector2 tHat1, Vector2 tHat2,
129  CubicCurve rcurve);
130 
131  void findCorner(Vector2 *d, int first, int last,
132  int *splitPoint);
133 
134  int isSeamCorner(Vector2 *d, int last);
135 
136 
137  // inline multipliers
138 
139  fpreal BEZ_MULT_0(fpreal u)
140  {
141  fpreal tmp = 1.0F - u;
142  return (tmp * tmp * tmp);
143  }
144 
145  fpreal BEZ_MULT_1(fpreal u)
146  {
147  fpreal tmp = 1.0F - u;
148  return (3.0F * u * (tmp * tmp));
149  }
150 
151  fpreal BEZ_MULT_2(fpreal u)
152  {
153  fpreal tmp = 1.0F - u;
154  return (3.0F * u * u * tmp);
155  }
156 
157  fpreal BEZ_MULT_3(fpreal u)
158  {
159  return (u * u * u);
160 
161  }
162 
163  int myNumPoints;
164  int myClosed;
165  int myNSpans;
166 
167  utFitType myFitType;
168  utCurveType myCurveType;
169 };
170 
171 #include "UT_FitCubicImpl.h"
172 
176 typedef UT_FitCubicT<float> UT_FitCubic; // deprecated
177 
178 #endif
GLint first
Definition: glcorearb.h:405
UT_Vector2T< T > Vector2
Definition: UT_FitCubic.h:44
UT_StringArray JOINTS head
void setCurveType(utCurveType type)
Definition: UT_FitCubic.h:69
2D Vector class.
Definition: UT_Vector2.h:159
UT_FitCubicT< float > UT_FitCubic
Definition: UT_FitCubic.h:176
UT_FitCubicT< fpreal32 > UT_FitCubicF
Definition: UT_FitCubic.h:174
Vector2 point[3]
Definition: UT_FitCubic.h:51
const Span * getFirstSpan() const
Definition: UT_FitCubic.h:60
utCurveType
Definition: UT_FitCubic.h:29
GLfloat f
Definition: glcorearb.h:1926
static Vector2 calcCubic(Vector2 *V, fpreal t)
Definition: Types.h:285
UT_FitCubicT< fpreal > UT_FitCubicR
Definition: UT_FitCubic.h:173
GLdouble t
Definition: glad.h:2397
__hostdev__ uint64_t last(uint32_t i) const
Definition: NanoVDB.h:5976
utFitType
Definition: UT_FitCubic.h:22
Vector2 CubicCurve[4]
Definition: UT_FitCubic.h:45
fpreal64 fpreal
Definition: SYS_Types.h:277
int containsCurve()
Definition: UT_FitCubic.h:66
int numSpans() const
Definition: UT_FitCubic.h:63
int fitCurve(Vector2 *d, int nPts, int closed, fpreal error2, bool preserveExtrema, bool use_kupan_slopes=false)
type
Definition: core.h:1059
UT_FitCubicT< fpreal64 > UT_FitCubicD
Definition: UT_FitCubic.h:175
void setType(utFitType type)
Definition: UT_FitCubic.h:72