00001
00002
00003
00004
00005
00006
00007
00008 #ifndef SO_LDM_BORDER_READER_H
00009 #define SO_LDM_BORDER_READER_H
00010
00011 #include <Inventor/SbLinear.h>
00012 #include <Inventor/STL/map>
00013 #include <Inventor/STL/list>
00014
00015 #include <Inventor/nodes/SoNode.h>
00016 #include <Inventor/fields/SoSubField.h>
00017
00018 #include <Inventor/fields/SoSFNode.h>
00019 #include <Inventor/fields/SoSFInt32.h>
00020 #include <Inventor/fields/SoSFUInt32.h>
00021 #include <Inventor/fields/SoSFEnum.h>
00022 #include <Inventor/fields/SoSFFilePathString.h>
00023 #include <Inventor/threads/SbThread.h>
00024 #include <LDM/nodes/SoDataSet.h>
00025 #include <LDM/readers/SoVolumeReader.h>
00026 #include <LDM/readers/SoVRLdmFileReader.h>
00027 #include <LDM/SoLDMTopoOctree.h>
00028
00029 #ifdef _MSC_VER
00030 #pragma warning( push )
00031 #pragma warning(disable:4251)
00032 #endif
00033
00034 class SoLDMTopoOctree;
00035 class SoBufferObject;
00036
00046 class SoVRLdmFileBorderReader : public SoVRLdmFileReader
00047 {
00048 SO_FIELDCONTAINER_HEADER(SoVRLdmFileBorderReader);
00049
00050 public:
00051
00053 enum BuildTileMethod {
00055 DECIMATION,
00057 AVERAGE
00058 };
00059
00063 SoVRLdmFileBorderReader();
00064
00068 virtual int setFilename(const SbString& filename);
00069
00073 virtual SoVolumeReader::ReadError getDataChar( SbBox3f &size, SoDataSet::DataType &type, SbVec3i32 &dim );
00074
00079 virtual int getBorderFlag();
00080
00082 virtual SbBool getTileSize(SbVec3i32 &size);
00083
00085 virtual SoBufferObject* readTile(int index, const SbBox3i32& tilePosition);
00086
00088 virtual SbBool isThreadSafe();
00089
00094 void setBuildTileMethod(BuildTileMethod method);
00095
00097 BuildTileMethod getBuildTileMethod();
00098
00099 private:
00100
00102 void readTile(int index, const SbBox3i32& tilePosition, void* destBuffer);
00103
00104 private:
00106 ~SoVRLdmFileBorderReader();
00107
00108 private:
00111 class SoLDMBorderTopoOctree : public SoLDMTopoOctree
00112 {
00113 public:
00114 void init(const SbVec3i32& dimension, const int tileDim, const int border);
00115 SbBox3i32 getTilePos(const SoLDMTileID& tileID) const;
00116
00117 private:
00118 std::vector<int> m_deltaZOiv8;
00119 };
00120
00121
00122 SbVec3i32 m_tileSizePow2;
00123
00124 SoVRLdmFileReader* m_internalLdmReader;
00125
00127 SoLDMBorderTopoOctree* m_topoOctreeVirtual;
00128
00130 SoLDMBorderTopoOctree* m_topoOcotreeReal;
00131
00133 BuildTileMethod m_buildMethod;
00134
00136 bool getIntersectingTiles(const SbBox3i32 ®ion, int resolution, SoLDM::TileIdVector &tiles);
00137
00139 template<typename T>
00140 void copyBlock(void* destMem, void* srcMem, const SbVec3i32& blockDestPos, const SbBox3i32& blockSrcBox, const SbVec3i32& arrayDim);
00141
00142 template<typename T>
00143 void copyScaledBlockUV(void* destMem, void* srcMem, const SbBox3i32& blockDestPos,
00144 const SbBox3f& blockSrcUVWBox, const SbVec3i32& arrayDim);
00145
00147 SbBox3i32 getCroppedBox(const SbBox3i32& cropBox, const SbBox3i32& box, SbBox3i32& cropped);
00148
00150 void handleBorders(SbBox3i32& tileBox, int border);
00151
00152 SbBox3f computeBoxToExtract(const SbBox3i32& tileBox, const SbBox3i32& tileBoxCropped) const;
00153
00155 template<typename T>
00156 inline T getInterpolatedValue(T* src, const SbVec3i32& arrayDim,
00157 const SbVec3i32& ijk0, const SbVec3i32& ijk1,
00158 const SbVec3f& factor);
00159
00160 inline static float trilinearInterpolate(const SbVec3f& factor, float v000, float v100, float v010, float v110,
00161 float v001, float v101, float v011, float v111);
00162
00164 template<typename T>
00165 static T getValue(T* src, const SbVec3i32& ijkSrc, const SbVec3i32& arrayDim);
00166 };
00167
00168 #ifdef _MSC_VER
00169 #pragma warning( pop )
00170 #endif
00171
00172 #endif
00173
00174