00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __IFD_IPRTree__
00019 #define __IFD_IPRTree__
00020
00021 #include "IFD_API.h"
00022 #include <UT/UT_String.h>
00023 #include <UT/UT_PtrArray.h>
00024 #include "IFD_IPREvent.h"
00025
00026 class UT_HashTable;
00027 class UT_IStream;
00028 class IFD_IPRObject;
00029 class IFD_IPRObjectFactory;
00030 class IFD_IPRData;
00031 class ROP_IPRObject;
00032 class IFD_RenderStream;
00033 class IFD_StreamEvent;
00034
00035 class IFD_API IFD_IPRTree {
00036 public:
00037 IFD_IPRTree(const char *cachefile="", const char *cacheprefix="ipr");
00038 ~IFD_IPRTree();
00039
00040 int save(ostream &os);
00041 bool load(UT_IStream &is, IFD_IPRObjectFactory &factory,
00042 float now);
00043 void afterLoad(float now);
00044
00045 void setRenderer(const char *r) { myRenderer.harden(r); }
00046 const char *getRenderer() const { return myRenderer; }
00047
00048 void setRenderData(IFD_IPRData *rdata);
00049 IFD_IPRData *getRenderData() { return myRenderData; }
00050
00051
00052 const char *getIPRName() { return myIPRName; }
00053 void setIPRName(const char *name);
00054
00055 void setStream(IFD_RenderStream *stream);
00056 bool hasStream() const { return myRenderStream != 0; }
00057
00058 const char *getCacheFile() const { return myCacheFile; }
00059
00060 bool startRender(float now);
00061 bool finishRender(int status);
00062
00063 bool beingCreated() const { return myBeingCreated; }
00064 void forceRecreate() { myBeingCreated = true; }
00065
00066 bool isDirty() const { return myDirty; }
00067 void setDirty(bool onoff);
00068
00069 void setDestroyCache(bool onoff);
00070
00071 void clearAll();
00072
00073 bool lightDirty(int obj, const char *attribute);
00074 bool fogDirty(int obj, const char *attribute);
00075 bool detailDirty(int obj, const char *attribute);
00076 bool instanceDirty(int obj, const char *attribute);
00077
00078 bool containsLight(int obj);
00079 bool containsFog(int obj);
00080 bool containsDetail(int obj);
00081 bool containsInstance(int obj);
00082
00083
00084
00085
00086 void addLight(IFD_IPRObject *obj);
00087 void addFog(IFD_IPRObject *obj);
00088 void addDetail(IFD_IPRObject *obj);
00089 void addInstance(IFD_IPRObject *obj);
00090
00091
00092
00093 void addNewLight(IFD_IPRObject *obj);
00094 void addNewFog(IFD_IPRObject *obj);
00095
00096
00097
00098 IFD_IPRObject *findLight(int unique_id);
00099 IFD_IPRObject *findFog(int unique_id);
00100 IFD_IPRObject *findInstance(int unique_id);
00101 IFD_IPRObject *findDetail(int unique_id);
00102 ROP_IPRObject *findRopLight(int unique_id);
00103 ROP_IPRObject *findRopFog(int unique_id);
00104 ROP_IPRObject *findRopInstance(int unique_id);
00105 ROP_IPRObject *findRopDetail(int unique_id);
00106
00107
00108
00109 int getLightCount() const { return myLights.entries(); }
00110 int getFogCount() const { return myFogs.entries(); }
00111 int getDetailCount() const { return myDetails.entries(); }
00112 int getInstanceCount() const { return myInstances.entries(); }
00113
00114 IFD_IPRObject *getLight(int i) { return myLights(i); }
00115 IFD_IPRObject *getFog(int i) { return myFogs(i); }
00116 IFD_IPRObject *getDetail(int i) { return myDetails(i); }
00117 IFD_IPRObject *getInstance(int i) { return myInstances(i); }
00118
00119
00120
00121 void clearObjectUsedFlags();
00122
00123
00124
00125 void allocateMaps(int nlight, int nfog,
00126 int ndetail, int ninstances);
00127 void freeMaps();
00128
00129 int *getLightMap() { return myLightMap; }
00130 int *getFogMap() { return myFogMap; }
00131 int *getDetailMap() { return myDetailMap; }
00132 int *getInstanceMap() { return myInstanceMap; }
00133
00134 int getLightMapSize() { return myLightMapSize; }
00135 int getFogMapSize() { return myFogMapSize; }
00136 int getDetailMapSize() { return myDetailMapSize; }
00137 int getInstanceMapSize() { return myInstanceMapSize; }
00138
00139 void dump();
00140
00141 bool autogenDirty() const { return myAutoGenDirty; }
00142 void dirtyAutogen() { myAutoGenDirty = true; }
00143
00144 UT_NotifierImpl< IFD_IPREvent& >
00145 &getEventNotifier() { return myEventNotifier; }
00146
00147 private:
00148 void buildHashTables();
00149 void handleStreamEvent(IFD_StreamEvent &event);
00150
00151 UT_String myIPRName;
00152 UT_String myCacheFile;
00153 UT_String myRenderer;
00154 IFD_IPRData *myRenderData;
00155 IFD_RenderStream *myRenderStream;
00156
00157 UT_PtrArray<IFD_IPRObject *> myLights;
00158 UT_PtrArray<IFD_IPRObject *> myFogs;
00159 UT_PtrArray<IFD_IPRObject *> myDetails;
00160 UT_PtrArray<IFD_IPRObject *> myInstances;
00161 UT_PtrArray<IFD_IPRObject *> myNewLights;
00162 UT_PtrArray<IFD_IPRObject *> myNewFogs;
00163 UT_NotifierImpl<IFD_IPREvent &> myEventNotifier;
00164 UT_NotifierList myNotifierList;
00165
00166 UT_HashTable *myHashTable;
00167 UT_HashTable *myInstanceHash;
00168 UT_HashTable *myDetailHash;
00169
00170 int *myLightMap;
00171 int *myFogMap;
00172 int *myDetailMap;
00173 int *myInstanceMap;
00174
00175 int myLightMapSize;
00176 int myFogMapSize;
00177 int myDetailMapSize;
00178 int myInstanceMapSize;
00179
00180 bool myDirty;
00181 bool myBeingCreated;
00182 bool myTempCache;
00183 bool myDestroyCache;
00184 bool myPipeStream;
00185 bool myAutoGenDirty;
00186 bool myLoadedFromFile;
00187 int myPendingStreams;
00188 };
00189
00190 #endif