24#ifndef _SO_LDM_TOPO_OCTREE_
25#define _SO_LDM_TOPO_OCTREE_
27#include <Inventor/SbLinear.h>
28#include <Inventor/SbBox.h>
29#include <LDM/SoLDMTileID.h>
35#pragma warning( push )
36#pragma warning(disable:4251)
107 void init(
const SbVec3i32& dimension,
const int tileDim,
const int border=0)
109 init(dimension,
SbVec3i32(tileDim, tileDim, tileDim), border);
169 {
return (m_numFileIDs<=0); }
190 int level(
const LDM_TILE_ID_TYPE index )
const;
216 int opposite(
int locationMask)
const;
243 static const int s_allLocations[26];
250 SbVec3i32 getTileOrigin(
const LDM_TILE_ID_TYPE tileID )
const;
252 LDM_TILE_ID_TYPE parent(
const LDM_TILE_ID_TYPE index )
const;
253 inline LDM_TILE_ID_TYPE children(
const LDM_TILE_ID_TYPE index )
const;
255 LDM_TILE_ID_TYPE getNumTilesAtDepth(
const int level )
const;
256 LDM_TILE_ID_TYPE getSumTilesAtDepth(
const int level )
const;
258 int getNumFileIDsAtDepth(
const int level )
const;
259 int getSumFileIDsAtDepth(
const int level )
const;
260 int sizeofTiles(
const int numTile,
int tileDim )
const;
262 inline bool hasChildren(
const SoLDMTileID& tileId)
const;
265 const SbVec3i32& getTileDimAtLevel(
int l)
const
267 return m_tileDimAtLevel[l];
286 SbVec3i32 getTileSpacePos(
const LDM_TILE_ID_TYPE tileID ,
const int tileLevel )
const;
298 SoLDMOctreeNode* operator [](
const LDM_TILE_ID_TYPE tileID)
const;
299 SoLDMOctreeNode* operator ()(
const int fileID)
const;
307 inline static void getOrderedOctant(
int octantOrder[8],
const SbVec3f & viewVector);
310 void useThinOptim(
bool useThinVolumeOptim);
317 inline int getMaxNumChildren()
const
318 {
return m_maxNumChildren; }
324 void commonInit(
const SbVec3i32& dimension,
const SbVec3i32& tileDim,
const int border=0 );
326 const SbVec3i32& getVolumeDimensions()
const
333 void fillTileDimAtLevel();
336 SbVec3i32 getTileOrigin(
const LDM_TILE_ID_TYPE tileID,
int tileLevel )
const;
342 int getFileIDReverseTable(
const SoLDMTileID& tileID )
const;
349 static float computeLevelMax(
unsigned int maxDim,
unsigned int tileDim,
350 unsigned int border);
352 static const int MAX_OCTREE_DEPTH;
355 static const uint64_t s_numTilesAtDepth[LEVEL_MAX+1];
356 static const uint64_t s_sumTilesAtDepth[LEVEL_MAX+2];
363 int m_maxNumChildren;
364 LDM_TILE_ID_TYPE m_numTileIDs;
366 SoLDMOctreeNode *m_tileIDs;
368 int m_numFileIDsAtDepth[LEVEL_MAX+1];
369 int m_sumFileIDsAtDepth[LEVEL_MAX+1];
372 static const unsigned int TDimension;
374 std::vector<SbVec3i32> m_tileDimAtLevel;
377 bool m_useThinVolumeOptim;
385 return (
size_t)(m_numTileIDs);
390SoLDMTopoOctree::hasChildren(
const SoLDMTileID& tileId)
const
399 return level(
id.getID());
406 if ( child.
getID() >= m_numTileIDs )
409 LDM_TILE_ID_TYPE firstChild = children(parent.getID());
410 LDM_TILE_ID_TYPE childId = child.
getID();
411 return childId >= firstChild && childId < firstChild+8;
418 LDM_TILE_ID_TYPE childId = child.
getID();
419 LDM_TILE_ID_TYPE parentId = _parent.
getID();
420 if ( childId >= m_numTileIDs || childId < 0 )
422 else if ( childId == parentId)
426 LDM_TILE_ID_TYPE parentChildID = parent(childId);
427 if ( parentChildID == parentId )
430 return isInFamilyOf(_parent,parentChildID);
439 if ( tileID.
getID()<0 || tileID.
getID()>=m_numTileIDs)
444 return m_fileIDs[tileID.
getID()] - 1;
446 return getFileIDReverseTable(tileID);
451SoLDMTopoOctree::children(
const LDM_TILE_ID_TYPE index )
const
453 return (index << TDimension) + 1;
458SoLDMTopoOctree::getOrderedOctant(
int octantOrder[8],
const SbVec3f & viewVector)
461 for (
int i = 0; i < 3; i++ )
462 bitMask |= (viewVector[i] < 0) << i;
463 for (
unsigned int i = 0; i < 8; i++ )
464 octantOrder[i] = i^bitMask;
468#pragma warning( pop )
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D box class.
<a href="IconLegend.html"><img src="extLDM.gif" alt="Large Data Management" border="0"></a> Tile ID
LDM_TILE_ID_TYPE getID() const
Returns the tile ID.
<a href="IconLegend.html"><img src="extLDM.gif" alt="Large Data Management" border="0"></a> Octree t...
const SbVec3i32 & getTileSize() const
Return the tilesize used to setup this octree.
int getFileID(const SoLDMTileID &tileID) const
Given a tileID, returns the corresponding fileID.
SoLDMTileID getTileID(const int fileID) const
Given a fileID, returns the corresponding tileID.
size_t getNumTileIDs() const
Returns the number of tileIDs in the complete (conceptual) octree.
SbBox3i32 getTilePos(const SoLDMTileID &tileID) const
Returns the bounding box, in voxel/cell coordinates, of the specified tile.
SoLDMTileID getTileID(const SbVec3i32 &cellPos, const int resolutionLevel) const
Given the position of a voxel in full resolution voxel coordinates (i,j,k) and a resolution level,...
bool isEmpty() const
Returns false if the octree is empty.
void init(const SbVec3i32 &dimension, const SbVec3i32 &tileDim, const int border=0)
Initialize with the properties of the data set.
int level(const LDM_TILE_ID_TYPE index) const
Returns the tile level of the given tile Id.
int getLevelMax() const
Returns the maximum level of the octree tile hierarchy.
int level(const SoLDMTileID &id) const
Returns the tile level of the given tile Id.
int getNumFileIDs() const
Returns the number of fileIDs in the volume.
SoLDMTopoOctree()
Constructor.
void init(const SbVec3i32 &dimension, const int tileDim, const int border=0)
Initialize with the properties of the data set.