00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __GU_PrimNURBCurve_h__
00022 #define __GU_PrimNURBCurve_h__
00023
00024 #include "GU_API.h"
00025 #include "GU_Curve.h"
00026 #include <GA/GA_NUBBasis.h>
00027 #include <GEO/GEO_PrimNURBCurve.h>
00028 #include <UT/UT_Matrix.h>
00029
00030 class GU_Detail;
00031 class GU_PrimPoly;
00032 class GU_PrimRBezCurve;
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 class GU_API GU_PrimNURBCurve : public GEO_PrimNURBCurve, public GU_Curve
00046 {
00047 public:
00048
00049
00050 GU_PrimNURBCurve(GEO_Detail *gdp, GA_Offset offset=GA_INVALID_OFFSET)
00051 : GEO_PrimNURBCurve(gdp, offset)
00052 , GU_Curve()
00053 {
00054 }
00055
00056 #if 0
00057
00058
00059 GU_PrimNURBCurve(GU_Detail *gdp, int nelems, int order = 4,
00060 int closed = 0, int interpEnds = 1, int appendPoints = 1);
00061 #endif
00062 ~GU_PrimNURBCurve();
00063
00064 virtual const GA_PrimitiveDefinition &getTypeDef() const
00065 {
00066 UT_ASSERT(theDefinition);
00067 return *theDefinition;
00068 }
00069
00070
00071 virtual int64 getMemoryUsage() const;
00072
00073 GU_PrimPoly *makeGrevillePoly(GU_Detail *dest = 0);
00074
00075 virtual int intersectRay(const UT_Vector3 &o, const UT_Vector3 &d,
00076 float tmax = 1E17F, float tol = 1E-12F,
00077 float *distance = 0, UT_Vector3 *pos = 0,
00078 UT_Vector3 *nml = 0, int accurate = 0,
00079 float *u = 0, float *v = 0,
00080 int ignoretrim = 1) const;
00081
00082
00083 virtual void *castTo() const;
00084 virtual const GEO_Primitive *castToGeo(void) const;
00085
00086
00087
00088
00089
00090
00091
00092 static GU_PrimNURBCurve *build(GU_Detail *gudp, int nelems,
00093 int order = 4, int closed = 0,
00094 int interpEnds = 1, int appendPoints= 1);
00095
00096 GEO_Primitive *convertNew(GU_ConvertParms &parms);
00097 GU_PrimRBezCurve *convertToBezNew(GA_ElementWranglerCache &wranglers,
00098 GA_PointGroup *delpts=0,
00099 GA_PrimitiveGroup *delprims=0);
00100
00101
00102
00103
00104
00105
00106
00107 virtual GU_Curve *cut(float u1, float u2,
00108 int &ind1, int &ind2, int keep);
00109
00110
00111 virtual void openAt(float u);
00112
00113 virtual void rotateTo(float u);
00114
00115
00116
00117
00118 virtual GEO_Face *reconfigure(unsigned type, int order, bool open,
00119 bool interpends, bool nonrational) const;
00120
00121
00122
00123
00124
00125
00126 virtual int matchKnots(const UT_Vector &source,
00127 const UT_Vector &dest, float tol = 1e-2F);
00128
00129
00130 virtual int evaluateBreakpoint(int uidx, UT_Vector4 &pos,
00131 int du=0) const;
00132
00133
00134
00135
00136
00137
00138
00139 int removeEdges(const UT_BitArray &edgemap,
00140 UT_IntArray &removededges);
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 int removeKnot(int knotIdx, int num, int mult=0,
00155 float tol=1e-4F,GA_PointGroup *delGroup=0,
00156 int uniqueInteriorCvs=0);
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 void reduceKnots(const UT_Vector &parm, UT_Vector &error,
00168 float tol=1e-1F, int num=0,
00169 GA_PointGroup *deleteGroup=0);
00170
00171
00172
00173
00174
00175 int interpGlobal(const UT_PtrArray<GEO_Point *> &gpData,
00176 int order=4, int wrapped=0,
00177 GA_ParameterizationType parmType=GA_PARAMETERIZATION_CHORD,
00178 GA_KnotSpaceType knotSpaceType=GA_KNOT_SPACE_AVERAGING,
00179 const UT_Vector *parmValues = 0);
00180 int interpGlobal(const GA_Range &point_range,
00181 int order=4, int wrapped=0,
00182 GA_ParameterizationType parmType=GA_PARAMETERIZATION_CHORD,
00183 GA_KnotSpaceType knotSpaceType=GA_KNOT_SPACE_AVERAGING,
00184 const UT_Vector *parmValues = 0);
00185 int interpGlobal(const UT_Vector4Array &v4Data,
00186 int order=4, int wrapped=0,
00187 GA_ParameterizationType parmType=GA_PARAMETERIZATION_CHORD,
00188 GA_KnotSpaceType knotSpaceType=GA_KNOT_SPACE_AVERAGING,
00189 const UT_Vector *parmValues = 0);
00190
00191 int interpGlobal(const UT_MatrixF &pointData,
00192 const UT_MatrixF &derivData, int order=4,
00193 int wrapped = 0,
00194 GA_ParameterizationType parmType=GA_PARAMETERIZATION_CHORD,
00195 GA_KnotSpaceType knotSpaceType=GA_KNOT_SPACE_AVERAGING);
00196 int interpGlobal(const UT_MatrixF &pointData,
00197 const UT_MatrixF &derivData,
00198 const UT_MatrixF &deriv2Data, int order=6,
00199 int wrapped = 0,
00200 GA_ParameterizationType parmType=GA_PARAMETERIZATION_CHORD,
00201 GA_KnotSpaceType knotSpaceType=GA_KNOT_SPACE_AVERAGING);
00202
00203 void interpLocal(const UT_PtrArray<GEO_Point *> &gpData,
00204 int order=4, int wrapped=0, int corner=0);
00205 void interpLocal(const UT_Vector4Array &v4Data,
00206 int order=4, int wrapped=0, int corner=0);
00207
00208
00209 int interpBreakpoints(
00210 const UT_PtrArray<GEO_Point *> &gpData,
00211 int order=4, int wrapped=0,
00212 GA_ParameterizationType parmType=GA_PARAMETERIZATION_CHORD,
00213 const UT_Vector *parmValues = 0);
00214 int interpBreakpoints(
00215 const UT_Vector4Array &v4Data,
00216 int order=4, int wrapped=0,
00217 GA_ParameterizationType parmType=GA_PARAMETERIZATION_CHORD,
00218 const UT_Vector *parmValues = 0);
00219
00220
00221
00222
00223
00224 void approxGlobal(const UT_Vector4Array &v4Data,
00225 int order=4, int wrapped=0,
00226 float tol=1e-1f, float smooth=0.0F,
00227 int noMultipleKnots=1);
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 static int interpGlobal(const UT_MatrixF &dataPts,
00238 const UT_Vector ¶m,
00239 const GA_NUBBasis &basis,
00240 UT_MatrixF &cvs, int natural_end = 0);
00241
00242
00243
00244
00245 static int interpGlobal(const UT_MatrixF &dataPts,
00246 const UT_Vector ¶m,
00247 const GA_NUBBasis &basis,
00248 UT_MatrixF &cvs,
00249 const UT_IntArray &dervs);
00250
00251
00252 static int interpGlobal(const UT_MatrixF &dataPts,
00253 const UT_MatrixF &dataTans,
00254 const UT_Vector ¶m,
00255 const GA_NUBBasis &basis,
00256 UT_MatrixF &cvs);
00257
00258
00259 static int interpGlobal(const UT_MatrixF &dataPts,
00260 const UT_MatrixF &dataTans,
00261 const UT_MatrixF &dataCurvature,
00262 const UT_Vector ¶m,
00263 const GA_NUBBasis &basis,
00264 UT_MatrixF &cvs);
00265
00266
00267 virtual void getRangeBBox(const UT_Interval &u,
00268 UT_BoundingBox &bbox,
00269 const GA_ROHandleV4 &h) const;
00270
00271 private:
00272
00273
00274 virtual int translateBkptsFixed(const UT_IntArray &uindices,
00275 const UT_Vector3 &delta,
00276 GA_PointGroup *ptgroup = NULL,
00277 GEO_Delta *geodelta = 0);
00278 virtual int transformBkptsFixed(const UT_IntArray &uindices,
00279 const UT_Matrix4 &matx,
00280 GA_PointGroup *ptgroup = NULL,
00281 GEO_Delta *geodelta = 0);
00282
00283
00284
00285 int create(int nelems, int order=4, int closed = 0,
00286 int interpEnds = 1, int appendPoints = 1);
00287
00288
00289 void fit(const UT_Vector4Array &v4Data,
00290 UT_Vector *data, int curOrd, int prevEnd,
00291 int cvEnd, UT_Vector *coord, UT_Vector ¶m,
00292 UT_Vector &error, float smooth);
00293
00294 static GA_PrimitiveDefinition *theDefinition;
00295 friend class GU_PrimitiveFactory;
00296 };
00297
00298 #endif