00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GU_TPSurfCache_H__
00021 #define __GU_TPSurfCache_H__
00022
00023 #include "GU_API.h"
00024 #include <UT/UT_Vector4.h>
00025 #include <UT/UT_Vector4Array.h>
00026 #include <UT/UT_Vector3Array.h>
00027 #include <UT/UT_RefArray.h>
00028 #include <GB/GB_Attribute.h>
00029 #include "GU_AttribCache.h"
00030 #include "GU_DisplayCache.h"
00031
00032 class GEO_TPSurf;
00033 class GU_Detail;
00034 class GEO_Detail;
00035 class GEO_Point;
00036 class GU_TPSurfCacheParms;
00037 class GD_TrimLoop;
00038 class GU_TrimBaseTesselator;
00039 class GU_TrimTesselator;
00040 class GU_TrimPatch;
00041
00042 class GU_API GU_TPTrimSurfCache
00043 {
00044 public:
00045 GU_TPTrimSurfCache();
00046 ~GU_TPTrimSurfCache();
00047
00048 void resizeAttributes(GEO_Detail *gdp, int ptattrib = 1);
00049
00050
00051 GD_TrimLoop *myLoops;
00052 GU_TrimTesselator *myTesselator;
00053 GU_TrimPatch *myPatch;
00054 int myTrimmedState;
00055 int myAttribSize;
00056 int myAttribDict;
00057 UT_Vector4Array myPoints;
00058 UT_Vector3Array myNormals;
00059 UT_RefArray<GB_AttributeData> myAttribs;
00060 };
00061
00062
00063 class GU_API GU_TPSurfCache : public GU_DisplayCache
00064 {
00065 public:
00066 GU_TPSurfCache(void);
00067 virtual ~GU_TPSurfCache(void);
00068
00069
00070 void touchDomain(int ustart_idx, int ustop_idx,
00071 int vstart_idx, int vstop_idx);
00072
00073
00074
00075 GU_TrimTesselator *getTesselation();
00076
00077
00078 GU_TrimPatch *getPatch() { return (myPatches)?myPatches->myPatch:0;}
00079
00080
00081 int refresh(GU_TPSurfCacheParms &parms);
00082
00083
00084 GU_CacheMode builtAs(void) const { return theMode; }
00085
00086
00087
00088 void getCounts(int uwrapped, int vwrapped,
00089 int &nucurves, int &nupoints,
00090 int &nvcurves, int &nvpoints) const;
00091 void getCounts(int uwrapped, int vwrapped,
00092 int &nupoints, int &nvpoints) const;
00093
00094 int colorOffset (void) const { return theCdOffset; }
00095 int alphaOffset (void) const { return theAlphaOffset; }
00096 int textureOffset(void) const { return theTxtOffset; }
00097
00098
00099 int hasAttributes(GU_CacheMode mode) const
00100 {
00101 return (theCdOffset < 0 && mode != GU_CACHESHADED)
00102 ? 0
00103 : theCdOffset >= 0 || theTxtOffset>= 0 ||
00104 theAlphaOffset >= 0;
00105 }
00106
00107
00108 int getTrimmedState(void) const { return !myPatches ? 1 :
00109 myPatches->myTrimmedState; }
00110
00111 int getNewTrimIndex();
00112
00113 void evaluateTrimIndex(GEO_TPSurf *surf, int index,
00114 float u, float v);
00115
00116 GEO_Point *getPointAtIndex(GU_Detail *gdp, int index);
00117
00118 const UT_Vector4Array &points () const { return thePoints; }
00119 const UT_Vector3Array &normals() const { return theNormals;}
00120 const GU_AttribCache &attribs() const
00121 { return theAttribs;}
00122 const UT_Vector4Array &trimPoints () const
00123 { return myPatches->myPoints; }
00124 const UT_Vector3Array &trimNormals () const
00125 { return myPatches->myNormals;}
00126 const UT_RefArray<GB_AttributeData> &trimAttribs() const
00127 { return myPatches->myAttribs;}
00128
00129 protected:
00130
00131 virtual void initializeData(void);
00132
00133
00134
00135
00136 virtual void assimilateXform(void);
00137
00138 private:
00139 UT_Vector4Array thePoints;
00140 UT_Vector4Array theTrimPoints;
00141 UT_Vector3Array theNormals;
00142 GU_AttribCache theAttribs;
00143 GU_CacheMode theMode;
00144 GU_TPTrimSurfCache *myPatches;
00145
00146 int theUMin, theUMax;
00147 int theVMin, theVMax;
00148 int theUSpans, theVSpans;
00149 int theUBreakIdx, theVBreakIdx;
00150 int theCdOffset, theTxtOffset;
00151 int theAlphaOffset;
00152 int theAttribSize;
00153 int theAttribDict;
00154
00155
00156 void resizeAttributes(GEO_Detail *gdp, int ptattrib = 1);
00157
00158
00159 void buildFloatOffsets(void);
00160
00161
00162 int evaluateSurface(GEO_TPSurf *surf);
00163
00164
00165 void evaluateNormals(GEO_TPSurf *surf);
00166 };
00167
00168 class GU_API GU_TPSurfCacheParms : public GU_CacheParms
00169 {
00170 public:
00171 GU_TPSurfCacheParms(void) {}
00172 virtual ~GU_TPSurfCacheParms(void);
00173
00174 void surface(GEO_TPSurf *surf) { theTPSurf = surf; }
00175 GEO_TPSurf *surface(void) const { return theTPSurf; }
00176
00177 private:
00178 GEO_TPSurf *theTPSurf;
00179 };
00180
00181 #endif