00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GU_NURBPyramid_h__
00021 #define __GU_NURBPyramid_h__
00022
00023 #include "GU_API.h"
00024 #include <UT/UT_IntArray.h>
00025 #include <UT/UT_RefMatrix.h>
00026
00027 class UT_Vector4;
00028 class GEO_Hull;
00029 class GB_NUBBasis;
00030
00031 class GU_API GU_CVMesh
00032 {
00033 public:
00034 GU_CVMesh() { myVecCV = 0; myVtxCV = 0; }
00035 GU_CVMesh(UT_RefMatrix<UT_Vector4> *cv, int dir) { init(cv, dir); }
00036 GU_CVMesh(GEO_Hull *cv, int dir) { init(cv, dir); }
00037
00038 void init(UT_RefMatrix<UT_Vector4> *cv, int dir)
00039 {
00040 myVecCV = cv; myVtxCV = 0; myDir = dir;
00041 }
00042 void init(GEO_Hull *cv, int dir)
00043 {
00044 myVtxCV = cv; myVecCV = 0; myDir = dir;
00045 }
00046
00047 void setDir(int dir) { myDir = dir; }
00048
00049 unsigned int usedRows(void) const
00050 {
00051 if (myDir)
00052 {
00053 if (myVecCV) return myVecCV->usedCols();
00054 else return (unsigned)myVtxCV->getNumCols();
00055 }
00056 else
00057 {
00058 if (myVecCV) return myVecCV->usedRows();
00059 else return (unsigned)myVtxCV->getNumRows();
00060 }
00061 }
00062 unsigned int usedCols(void) const
00063 {
00064 if (!myDir)
00065 {
00066 if (myVecCV) return myVecCV->usedCols();
00067 else return (unsigned)myVtxCV->getNumCols();
00068 }
00069 else
00070 {
00071 if (myVecCV) return myVecCV->usedRows();
00072 else return (unsigned)myVtxCV->getNumRows();
00073 }
00074 }
00075 const UT_Vector4 &operator()(int i, int j) const
00076 {
00077 if (myDir)
00078 {
00079 if (myVecCV) return (*myVecCV)((unsigned)j, (unsigned)i);
00080 else return (*myVtxCV)((unsigned)j, (unsigned)i).getPos();
00081 }
00082 else
00083 {
00084 if (myVecCV) return (*myVecCV)((unsigned)i, (unsigned)j);
00085 else return (*myVtxCV)((unsigned)i, (unsigned)j).getPos();
00086 }
00087 }
00088 UT_Vector4 &operator()(int i, int j)
00089 {
00090 if (myDir)
00091 {
00092 if (myVecCV) return (*myVecCV)((unsigned)j, (unsigned)i);
00093 else return (*myVtxCV)((unsigned)j, (unsigned)i).getPos();
00094 }
00095 else
00096 {
00097 if (myVecCV) return (*myVecCV)((unsigned)i, (unsigned)j);
00098 else return (*myVtxCV)((unsigned)i, (unsigned)j).getPos();
00099 }
00100 }
00101
00102 private:
00103 int myDir;
00104 UT_RefMatrix<UT_Vector4> *myVecCV;
00105 GEO_Hull *myVtxCV;
00106 };
00107
00108 class GU_API GU_NURBPyramid
00109 {
00110 public:
00111 GU_NURBPyramid(GB_NUBBasis *basis, UT_RefMatrix<UT_Vector4> *cv, int dir)
00112 {
00113 myCV.init(cv, dir);
00114 start(basis, dir);
00115 }
00116 GU_NURBPyramid(GB_NUBBasis *basis, GEO_Hull *cv, int dir)
00117 {
00118 myCV.init(cv, dir);
00119 start(basis, dir);
00120 }
00121
00122 int next(UT_RefMatrix<UT_Vector4> *result,
00123 float &uStart, float &uEnd);
00124
00125 private:
00126 void start(GB_NUBBasis *basis, int dir);
00127
00128 int myDir;
00129
00130
00131 int myOrd, myDeg, myEnd;
00132 int myCVSize;
00133 UT_FloatArray myKnots;
00134 UT_IntArray myMultArr;
00135 GU_CVMesh myCV;
00136
00137
00138 UT_RefMatrix<UT_Vector4> myPyramidData;
00139 GU_CVMesh myPyramid;
00140
00141
00142 int myk;
00143 int mymultIdx;
00144 int mycvIdx;
00145 int mynewcv;
00146 };
00147
00148 #endif