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);
59 
60  const Span *getFirstSpan(void) const
61  { return myHead; }
62 
63  int numSpans(void) const
64  { return myNSpans; }
65 
66  int containsCurve(void)
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(void);
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, UT_Interrupt *boss);
97 
98  Vector2 computeCenterTangent(Vector2 *d, int center);
99 
100  T *reparameterize(Vector2 *d, int first, int last,
101  T *u, CubicCurve fcurve);
102 
103  fpreal newtonRaphsonRootFind(CubicCurve Q, Vector2 P, fpreal u);
104 
105  Vector2 calcBezier2(Vector2 *V, fpreal t);
106  Vector2 calcBezier3(Vector2 *V, fpreal t);
107 
108 
109  fpreal computeBezierError(Vector2 *d, int first, int last,
110  CubicCurve fcurve, T *u, int *splitPoint);
111 
112  fpreal computeCubicError(Vector2 *d, int first, int last,
113  CubicCurve fcurve, int *splitPoint,
114  bool preserveExtrema);
115 
116  fpreal computeLineError(Vector2 *d, int first, int last,
117  CubicCurve fcurve, T *u, int *splitPoint);
118 
119  T *chordLengthParameterize(Vector2 *d,int f,int l);
120 
121  void generateBezier(Vector2 *d, int first, int last,
122  T *uPrime, Vector2 tHat1,
123  Vector2 tHat2, CubicCurve fcurve);
124 
125  void simpleCurve(Vector2 *d, int first, int last,
126  Vector2 tHat1, Vector2 tHat2,
127  CubicCurve rcurve);
128 
129  void findCorner(Vector2 *d, int first, int last,
130  int *splitPoint);
131 
132  int isSeamCorner(Vector2 *d, int last);
133 
134 
135  // inline multipliers
136 
137  fpreal BEZ_MULT_0(fpreal u)
138  {
139  fpreal tmp = 1.0F - u;
140  return (tmp * tmp * tmp);
141  }
142 
143  fpreal BEZ_MULT_1(fpreal u)
144  {
145  fpreal tmp = 1.0F - u;
146  return (3.0F * u * (tmp * tmp));
147  }
148 
149  fpreal BEZ_MULT_2(fpreal u)
150  {
151  fpreal tmp = 1.0F - u;
152  return (3.0F * u * u * tmp);
153  }
154 
155  fpreal BEZ_MULT_3(fpreal u)
156  {
157  return (u * u * u);
158 
159  }
160 
161  int myNumPoints;
162  int myClosed;
163  int myNSpans;
164 
165  utFitType myFitType;
166  utCurveType myCurveType;
167 };
168 
169 #include "UT_FitCubicImpl.h"
170 
174 typedef UT_FitCubicT<float> UT_FitCubic; // deprecated
175 
176 #endif
GLint first
Definition: glcorearb.h:404
UT_Vector2T< T > Vector2
Definition: UT_FitCubic.h:44
void setCurveType(utCurveType type)
Definition: UT_FitCubic.h:69
const Span * getFirstSpan(void) const
Definition: UT_FitCubic.h:60
2D Vector class.
Definition: UT_Vector2.h:138
int numSpans(void) const
Definition: UT_FitCubic.h:63
UT_FitCubicT< float > UT_FitCubic
Definition: UT_FitCubic.h:174
UT_FitCubicT< fpreal32 > UT_FitCubicF
Definition: UT_FitCubic.h:172
Vector2 point[3]
Definition: UT_FitCubic.h:51
int containsCurve(void)
Definition: UT_FitCubic.h:66
utCurveType
Definition: UT_FitCubic.h:29
GLfloat f
Definition: glcorearb.h:1925
static Vector2 calcCubic(Vector2 *V, fpreal t)
UT_FitCubicT< fpreal > UT_FitCubicR
Definition: UT_FitCubic.h:171
utFitType
Definition: UT_FitCubic.h:22
double fpreal
Definition: SYS_Types.h:270
Vector2 CubicCurve[4]
Definition: UT_FitCubic.h:45
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
int fitCurve(Vector2 *d, int nPts, int closed, fpreal error2, bool preserveExtrema)
UT_FitCubicT< fpreal64 > UT_FitCubicD
Definition: UT_FitCubic.h:173
void setType(utFitType type)
Definition: UT_FitCubic.h:72