00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __GOP_VexContext__
00020 #define __GOP_VexContext__
00021
00022 #include "GOP_API.h"
00023 #include <UT/UT_Dependency.h>
00024 #include <UT/UT_IntArray.h>
00025 #include <UT/UT_StringArray.h>
00026 #include <VEX/VEX_Instance.h>
00027 #include <VEX/VEX_ContextManager.h>
00028 #include <VEX/VEX_Context.h>
00029 #include <VEX/VEX_DataCache.h>
00030
00031 class VEX_StringSet;
00032 class GVEX_Map;
00033
00034 typedef enum {
00035 GOP_POS,
00036 GOP_POSW,
00037 GOP_VEL,
00038 GOP_ACCEL,
00039 GOP_AGE,
00040 GOP_LIFE,
00041 GOP_PSTATE,
00042 GOP_ID,
00043 GOP_PTNUM,
00044 GOP_COLOR,
00045 GOP_NORMAL,
00046
00047 GOP_NPT,
00048 GOP_TIME,
00049 GOP_FRAME,
00050 GOP_TIMEINC,
00051
00052 GOP_MAX_VARIABLES
00053 } GOP_Global;
00054
00055 class GB_PointGroup;
00056 class GEO_Point;
00057 class GU_Detail;
00058 class VEX_ProcArray;
00059 class GVEX_Atlas;
00060 class UT_Vector3;
00061 class UT_Vector4;
00062 class UT_Matrix3;
00063 class UT_Matrix4;
00064
00065 DECLARE_DEPENDENCY(GOP)
00066
00067 class GOP_API GOP_VariableMap {
00068 public:
00069 GOP_VariableMap();
00070 ~GOP_VariableMap();
00071
00072
00073
00074
00075 void initData(VEX_Instance *func);
00076
00077
00078
00079 int isTimeDep();
00080
00081
00082
00083
00084
00085
00086 int isObjXformDep();
00087
00088 void initExports(GU_Detail *gdp);
00089
00090
00091 void bind(VEX_Instance *func);
00092 void bindAtlas(const GVEX_Atlas *atlas,
00093 VEX_Instance *func,
00094 VEX_ProcArray *proc);
00095
00096
00097 void prepData(GU_Detail *gdp, const GB_PointGroup *ptgroup,
00098 UT_StringArray &groupnames,
00099 int numPoints, float time, float frame, float timeinc);
00100 void prepData(VEX_ProcArray *proc);
00101 void prepData(GEO_Point *ppt, int index);
00102
00103
00104 void extractData(VEX_ProcArray *proc);
00105
00106
00107
00108 void done(GU_Detail *gdp, bool last_thread);
00109
00110
00111 GB_PointGroup *newGroup(const char *groupName);
00112 void getBoundingBox(UT_Vector3 &xlate, UT_Vector3 &scale);
00113 void getBoundMinMax(UT_Vector3 &min, UT_Vector3 &max);
00114
00115 void setComputeNormal(int onoff)
00116 {
00117 myRecomputeNormal = onoff;
00118 }
00119
00120 void clearInputs();
00121 void setInput(int idx, const GU_Detail *gdp);
00122 const GU_Detail *getInput(int idx) const;
00123 const GEO_Point *getPoint(int idx) const { return myPoints[idx]; }
00124 GEO_Point *getPoint(int idx) { return myPoints[idx]; }
00125
00126
00127 UT_PtrArray<GEO_Point *> *getRingZero(int ptnum, int input=0);
00128
00129 void clearRingZeros();
00130
00131 GU_Detail *myDetail;
00132
00133 private:
00134 void *getData(GOP_Global id)
00135 { return myMap[id] >= 0 ? myData[id] : 0; }
00136
00137 UT_PtrArray<const GU_Detail *> myInputs;
00138
00139
00140 int isRead(GOP_Global id)
00141 { return myMap[id] >= 0 ? myFunc->isRead(myMap[id]) >= 0 : 0; }
00142 int isWritten(GOP_Global id)
00143 { return myMap[id] >= 0 ? myFunc->isWritten(myMap[id]) >= 0 : 0; }
00144
00145 void updateBoundingBox();
00146 void fillAttrib(char *data, int offset, int size, int npts);
00147 void fillAttribVal(char *data, char *val, int size, int npts);
00148 void fillStringAttrib(VEX_StringSet *set,
00149 const GVEX_Map *map, int npts);
00150 void extractAttrib(char *data, int offset, int size, int npts, int
00151 uniform = 0);
00152 void extractString(const VEX_StringSet *ss, const char *name,
00153 int npts, int uniform=0);
00154
00155 VEX_DataCache myDataCache;
00156 int myAttrOffset[GOP_MAX_VARIABLES];
00157 int myMap [GOP_MAX_VARIABLES];
00158 void *myData[GOP_MAX_VARIABLES];
00159 VEX_Instance *myFunc;
00160 GEO_Point **myPoints;
00161 UT_StringArray *myGroupNames;
00162 int myDestroyNormal;
00163 const GB_PointGroup *myPointGroup;
00164
00165 int myBBoxUpdated;
00166 UT_Vector3 myBBoxMin;
00167 UT_Vector3 myBBoxMax;
00168 UT_Vector3 myBBoxScale;
00169
00170 UT_IntArray myExports;
00171 UT_IntArray myPointMap;
00172
00173
00174 int myNumPts;
00175 float myTime;
00176 float myFrame;
00177 float myTimeInc;
00178 unsigned int myRecomputeNormal:2,
00179 myUpdateW:1;
00180
00181
00182 UT_PtrArray<UT_PtrArray<UT_PtrArray<GEO_Point *> *> *> myRingCache;
00183 };
00184
00185 class GOP_API GOP_VexContext : public VEX_Context {
00186 public:
00187 static const char **getRequiredVariables();
00188
00189 virtual int getGlobalVariableEntries() const;
00190 virtual const char *getGlobalVariableName(int id) const;
00191 virtual const char *getGlobalVariableDescription(int id) const;
00192 virtual VEX_Type getGlobalVariableType(int id) const;
00193 virtual VEX_Storage getGlobalVariableStorage(int id) const;
00194 virtual int getGlobalVariableReadWrite(int id) const;
00195
00196 private:
00197 GOP_VexContext(const char *name, int path);
00198 virtual ~GOP_VexContext();
00199
00200 static VEX_Context *getPopContext();
00201 static void clearPopContext();
00202
00203 static VEX_Context *getSopContext();
00204 static void clearSopContext();
00205
00206 virtual void addGlobalVariables(VEX_Assemble &as) const;
00207
00208 friend class GOP_DummyFriend;
00209
00210 VEX_DECLARE_CONTEXT(VEX_POP_CONTEXT)
00211 VEX_DECLARE_CONTEXT(VEX_SOP_CONTEXT)
00212 };
00213
00214 #endif