00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GU_RayRBezSurf_h__
00021 #define __GU_RayRBezSurf_h__
00022
00023 #include "GU_API.h"
00024 #include <UT/UT_Matrix4.h>
00025 #include <UT/UT_Matrix3.h>
00026 #include <UT/UT_Vector3.h>
00027 #include <UT/UT_Vector4Array.h>
00028 #include <UT/UT_RefMatrix.h>
00029 #include <UT/UT_Matrix.h>
00030 #include <UT/UT_BoundingBox.h>
00031
00032 class GEO_Point;
00033 class GEO_Primitive;
00034 class GU_RayInfo;
00035 class GU_MinInfo;
00036 class GU_RayRBezCurve;
00037 class GU_RayRBezSurf;
00038 class UT_BoundingRect;
00039 class GU_IsectCurveSet;
00040 class GU_IsectCurve;
00041
00042
00043
00044
00045
00046 class GU_API GU_RayRBezSurf
00047 {
00048 public:
00049 GU_RayRBezSurf();
00050 ~GU_RayRBezSurf();
00051 void init(int uOrder, int vOrder,
00052 float uStart, float uLength,
00053 float vStart, float vLength, int isRational);
00054
00055 void buildBBox();
00056
00057
00058 int intersectBBox(const UT_Vector3 &org, const UT_Vector3 &dir,
00059 float tmax, float tol, float *t);
00060
00061
00062 int intersect(const UT_Vector3 &org,
00063 const UT_Vector3 &dir,
00064 GU_RayInfo &hitInfo, int depth,
00065 int noBBoxTest = 0 );
00066 int intersectQR(const UT_Vector3 &org,
00067 const UT_Vector3 &dir,
00068 GU_RayInfo &hitInfo, int depth,
00069 int noBBoxTest = 0 );
00070 int intersectAP(const UT_Vector3 &org,
00071 const UT_Vector3 &dir,
00072 GU_RayInfo &hitInfo);
00073 int intersect(GU_RayRBezSurf &surf, GU_RayInfo &hitinfo);
00074
00075
00076 int minimum(const UT_Vector3 &p,
00077 GU_MinInfo &mininfo, int depth,
00078 int noBBoxTest = 0 );
00079 int minimum(GU_RayRBezSurf &surf, GU_MinInfo &mininfo,
00080 int depth, int noBBoxTest = 0);
00081
00082
00083
00084 int pointInvert(const UT_Vector3 &p, float &u, float &v,
00085 float &d2, float tol);
00086
00087
00088 void carveU(float ustart, float uend);
00089 void carveV(float vstart, float vend);
00090
00091 void split(GU_RayRBezSurf *topLeft,
00092 GU_RayRBezSurf *bottomLeft,
00093 GU_RayRBezSurf *bottomRight,
00094 GU_RayRBezSurf *topRight) const;
00095 void evaluate(float u, float v, UT_Vector3 &pos) const;
00096 void evaluateHomogeneous(float u, float v, UT_Vector4 &pos,
00097 UT_Vector4 &derU, UT_Vector4 &derV) const;
00098 void evaluate(float u, float v, UT_Vector3 &pos,
00099 UT_Vector3 &derU, UT_Vector3 &derV,
00100 UT_Vector3 &derUV,
00101 UT_Vector3 &derUU, UT_Vector3 &derVV) const;
00102 void sortSubPatches(GU_RayRBezSurf **patches) const;
00103 void guessIntersection(const UT_Vector3 &org,
00104 const UT_Vector3 &dir,
00105 float &t, float &u, float &v) const;
00106 void guessIntersection(const UT_Vector3 &org,
00107 float &u, float &v) const;
00108
00109 void buildImplicit();
00110 private:
00111 void buildPowerCoeffs(UT_Matrix &A, int index) const;
00112
00113
00114
00115
00116
00117 int domainDecomposition(GU_IsectCurveSet &curveset,
00118 GU_RayRBezSurf &surf,
00119 const UT_BoundingRect &domain,
00120 UT_Vector4Array &points,
00121 float intersecttol = 1e-6F,
00122 float domaintol = 1e-2F,
00123 float steprate = 1e-2F, int dividedir=0);
00124
00125
00126
00127
00128
00129
00130 int traceIsectCurve(GU_IsectCurve &isectcurve,
00131 GU_RayRBezSurf &surf,
00132 const UT_BoundingRect &domain,
00133 const UT_Vector4 &start, const UT_Vector4 &end,
00134 float tol = 1e-6F, float domaintol = 1e-2F,
00135 float steprate = 1.0f/100.0f,
00136 int canreverse = 1, int direction = 1);
00137
00138
00139
00140
00141 int polishInV(GU_RayRBezSurf &surf, float u, float v,
00142 float &vresult, float &invu, float &invv,
00143 float tol = 1e-4F, int maxiter = 30);
00144 int polishInU(GU_RayRBezSurf &surf, float u, float v,
00145 float &uresult, float &invu, float &invv,
00146 float tol = 1e-4F, int maxiter = 30);
00147 int polishCurve(GU_RayRBezCurve &curve, float &t,
00148 float &invu, float &invv, float tol,
00149 int maxiter);
00150 int polishCurveSlow(GU_RayRBezCurve &curve, float &t, float tol,
00151 int maxiter);
00152
00153 void extractUIsoparm(GU_RayRBezCurve &curve, float u) const;
00154 void extractVIsoparm(GU_RayRBezCurve &curve, float v) const;
00155
00156 void isectEdges(GU_RayRBezSurf &surf,
00157 UT_Vector4Array &pointlist,
00158 float tol = 1e-6F, float ttol = 1e-2F);
00159 void isectIsoU(GU_RayRBezSurf &surf,
00160 float u, float vstart, float vend,
00161 UT_Vector4Array &pointlist,
00162 float tol = 1e-6F, float ttol = 1e-2F, int useAP=1);
00163 void isectIsoV(GU_RayRBezSurf &surf,
00164 float v, float ustart, float uend,
00165 UT_Vector4Array &pointlist,
00166 float tol = 1e-6F, float ttol = 1e-2F, int useAP=1);
00167
00168 public:
00169 UT_BoundingBox myBBox;
00170 UT_RefMatrix<UT_Vector4> myCV;
00171 float myUStart, myULength;
00172 float myVStart, myVLength;
00173 float sortValue;
00174 int myRational;
00175 GU_RayRBezSurf *myTopLeft, *myBottomLeft;
00176 GU_RayRBezSurf *myTopRight, *myBottomRight;
00177
00178 int myImplicitFlag;
00179
00180 int myEigenVectorCorrect;
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 UT_Matrix myXCoeff, myYCoeff, myZCoeff, myWCoeff;
00193 };
00194
00195
00196 #endif
00197