Commit c838e209 authored by Morten Ofstad's avatar Morten Ofstad
Browse files

Update JSON handling to conform to new version of OpenVDS specification....

Update JSON handling to conform to new version of OpenVDS specification. Rename everywhere 'Lod' to LOD since it is an abbreviation and not a word.
parent 5dfef4b3
......@@ -624,7 +624,7 @@ protected:
public:
virtual VolumeDataLayout const *getLayout() const = 0;
virtual int getLod() const = 0;
virtual int getLOD() const = 0;
virtual int getChannelIndex() const = 0;
virtual VolumeDataChannelDescriptor const &getChannelDescriptor() const = 0;
virtual void getNumSamples(int (&numSamples)[Dimensionality_Max]) const = 0;
......
......@@ -227,5 +227,8 @@ public:
return VolumeDataChannelDescriptor(format, components, pName, pUnit, valueRangeMin, valueRangeMax, VolumeDataMapping::PerTrace, mappedValueCount, flags, noValue, 1.0f, 0.0f);
}
};
inline VolumeDataChannelDescriptor::Flags operator|(VolumeDataChannelDescriptor::Flags lhs, VolumeDataChannelDescriptor::Flags rhs) { return (VolumeDataChannelDescriptor::Flags)((int)lhs | (int)rhs); }
}
#endif //VOLUMEDATACHANNELDESCRIPTOR_H
......@@ -55,7 +55,7 @@ public:
enum Options
{
Options_None = 0,
Options_Create2DLods = (1 << 0),
Options_Create2DLODs = (1 << 0),
Options_ForceFullResolutionDimension = (1 << 1)
};
......@@ -64,7 +64,7 @@ private:
int m_negativeMargin;
int m_positiveMargin;
int m_brickSizeMultiplier2D;
int m_brickSize2DMultiplier;
LODLevels m_lodLevels;
......@@ -73,21 +73,24 @@ private:
int m_fullResolutionDimension;
public:
VolumeDataLayoutDescriptor() : m_brickSize(), m_negativeMargin(), m_positiveMargin(), m_brickSizeMultiplier2D(), m_lodLevels(), m_options(), m_fullResolutionDimension() {}
VolumeDataLayoutDescriptor(BrickSize brickSize, int negativeMargin, int positiveMargin, int brickSizeMultiplier2D, LODLevels lodLevels, Options options, int fullResolutionDimension = 0) : m_brickSize(brickSize), m_negativeMargin(negativeMargin), m_positiveMargin(positiveMargin), m_brickSizeMultiplier2D(brickSizeMultiplier2D), m_lodLevels(lodLevels), m_options(options), m_fullResolutionDimension(fullResolutionDimension) {}
VolumeDataLayoutDescriptor() : m_brickSize(), m_negativeMargin(), m_positiveMargin(), m_brickSize2DMultiplier(), m_lodLevels(), m_options(), m_fullResolutionDimension() {}
VolumeDataLayoutDescriptor(BrickSize brickSize, int negativeMargin, int positiveMargin, int brickSize2DMultiplier, LODLevels lodLevels, Options options, int fullResolutionDimension = 0) : m_brickSize(brickSize), m_negativeMargin(negativeMargin), m_positiveMargin(positiveMargin), m_brickSize2DMultiplier(brickSize2DMultiplier), m_lodLevels(lodLevels), m_options(options), m_fullResolutionDimension(fullResolutionDimension) {}
bool isValid() const { return m_brickSize != 0; }
BrickSize getBrickSize() const { return m_brickSize; }
int getNegativeMargin() const { return m_negativeMargin; }
int getPositiveMargin() const { return m_positiveMargin; }
int getBrickSizeMultiplier2D() const { return m_brickSizeMultiplier2D; }
int getBrickSizeMultiplier2D() const { return m_brickSize2DMultiplier; }
LODLevels getLODLevels() const { return m_lodLevels; }
bool isCreate2DLods() const { return (m_options & Options_Create2DLods) != 0; }
bool isCreate2DLODs() const { return (m_options & Options_Create2DLODs) != 0; }
bool isForceFullResolutionDimension() const { return (m_options & Options_ForceFullResolutionDimension) != 0; }
int getFullResolutionDimension() const { return m_fullResolutionDimension; }
};
inline VolumeDataLayoutDescriptor::Options operator|(VolumeDataLayoutDescriptor::Options lhs, VolumeDataLayoutDescriptor::Options rhs) { return (VolumeDataLayoutDescriptor::Options)((int)lhs | (int)rhs); }
}
#endif //VOLUMEDATALAYOUTDESCRIPTOR_H
\ No newline at end of file
......@@ -469,9 +469,9 @@ main(int argc, char *argv[])
int negativeMargin = 0;
int positiveMargin = 0;
int brickSizeMultiplier2D = 4;
int brickSize2DMultiplier = 4;
OpenVDS::VolumeDataLayoutDescriptor layoutDescriptor(brickSizeEnum, negativeMargin, positiveMargin, brickSizeMultiplier2D, lodLevels, layoutOptions);
OpenVDS::VolumeDataLayoutDescriptor layoutDescriptor(brickSizeEnum, negativeMargin, positiveMargin, brickSize2DMultiplier, lodLevels, layoutOptions);
// Create axis descriptors
......
This diff is collapsed.
......@@ -194,7 +194,7 @@ static VolumeDataLayer *getVolumeDataLayer(VolumeDataLayout const *layout, Dimen
return nullptr;
}
while(layer && layer->getLod() < lod)
while(layer && layer->getLOD() < lod)
{
layer = layer->getParentLayer();
}
......@@ -452,7 +452,7 @@ bool VolumeDataAccessManagerImpl::prepareReadChunkData(const VolumeDataChunk &ch
int32_t channel = chunk.layer->getChannelIndex();
const char *channelName = channel > 0 ? chunk.layer->getLayout()->getChannelName(chunk.layer->getChannelIndex()) : "";
int32_t lod = chunk.layer->getLod();
int32_t lod = chunk.layer->getLOD();
const char *dimensions_string = DimensionGroupUtil::getDimensionsGroupString(DimensionGroupUtil::getDimensionsNDFromDimensionGroup(chunk.layer->getChunkDimensionGroup()));
char layerURL[1000];
snprintf(layerURL, sizeof(layerURL), "%sDimensions_%sLOD%d", channelName, dimensions_string, lod);
......
......@@ -100,7 +100,7 @@ static bool operator<(const VolumeDataChunk &a, const VolumeDataChunk &b)
{
if (a.layer->getChunkDimensionGroup() == b.layer->getChunkDimensionGroup())
{
if (a.layer->getLod() == b.layer->getLod())
if (a.layer->getLOD() == b.layer->getLOD())
{
if (a.layer->getChannelIndex() == b.layer->getChannelIndex())
{
......@@ -113,7 +113,7 @@ static bool operator<(const VolumeDataChunk &a, const VolumeDataChunk &b)
}
else
{
return a.layer->getLod() < b.layer->getLod();
return a.layer->getLOD() < b.layer->getLOD();
}
}
return DimensionGroupUtil::getDimensionsNDFromDimensionGroup(a.layer->getChunkDimensionGroup()) < DimensionGroupUtil::getDimensionsNDFromDimensionGroup(b.layer->getChunkDimensionGroup());
......
......@@ -37,7 +37,7 @@ namespace OpenVDS
#define WAVELET_MIN_COMPRESSION_TOLERANCE 0.01f
#define WAVELET_ADAPTIVE_LEVELS 16
VolumeDataLayer::VolumeDataLayer(VolumeDataPartition const &volumeDataPartition, VolumeDataLayout *volumeDataLayout, int32_t channel, VolumeDataLayer *primaryChannelLayer, VolumeDataLayer *lowerLod, VolumeDataLayer::LayerType layerType, const VolumeDataChannelMapping *volumeDataChannelMapping)
VolumeDataLayer::VolumeDataLayer(VolumeDataPartition const &volumeDataPartition, VolumeDataLayout *volumeDataLayout, int32_t channel, VolumeDataLayer *primaryChannelLayer, VolumeDataLayer *lowerLOD, VolumeDataLayer::LayerType layerType, const VolumeDataChannelMapping *volumeDataChannelMapping)
: VolumeDataPartition(volumeDataPartition)
, m_volumeDataLayout(volumeDataLayout)
, m_layerID(volumeDataLayout->addDataLayer(this))
......@@ -46,25 +46,25 @@ VolumeDataLayer::VolumeDataLayer(VolumeDataPartition const &volumeDataPartition,
, m_layerType(layerType)
, m_primaryChannelLayer(primaryChannelLayer)
, m_nextChannelLayer(NULL)
, m_lowerLod(lowerLod)
, m_higherLod(NULL)
, m_lowerLOD(lowerLOD)
, m_higherLOD(NULL)
, m_remapFromLayer(this)
, m_produceStatus(ProduceStatusUnavailable)
, m_produceStatus(ProduceStatus_Unavailable)
{
assert(volumeDataLayout);
assert((channel == 0 && primaryChannelLayer == NULL) || (channel > 0 && primaryChannelLayer != NULL));
if(lowerLod)
if(lowerLOD)
{
assert(!lowerLod->m_higherLod);
assert(lowerLod->getLod() + 1 == getLod());
lowerLod->m_higherLod = this;
assert(!lowerLOD->m_higherLOD);
assert(lowerLOD->getLOD() + 1 == getLOD());
lowerLOD->m_higherLOD = this;
}
if(primaryChannelLayer)
{
assert(primaryChannelLayer->getLod() == getLod());
assert(primaryChannelLayer->getLOD() == getLOD());
VolumeDataLayer *link = primaryChannelLayer;
......@@ -267,7 +267,7 @@ CompressionMethod VolumeDataLayer::getEffectiveCompressionMethod() const
}
auto overallCompressionMethod = m_volumeDataLayout->getCompressionMethod();
if(getLod() > 0)
if(getLOD() > 0)
{
if(overallCompressionMethod == CompressionMethod::WaveletLossless)
{
......@@ -284,7 +284,7 @@ CompressionMethod VolumeDataLayer::getEffectiveCompressionMethod() const
float VolumeDataLayer::getEffectiveCompressionTolerance() const
{
auto &channelDescriptor = m_volumeDataLayout->getVolumeDataChannelDescriptor(m_channel);
//return m_volumeDataLayout->getVolumeDataChannelDescriptor(m_channel).getEffectiveCompressionTolerance(m_volumeDataLayout->m_compressionTolerance, getLod());
//return m_volumeDataLayout->getVolumeDataChannelDescriptor(m_channel).getEffectiveCompressionTolerance(m_volumeDataLayout->m_compressionTolerance, getLOD());
if(!channelDescriptor.isAllowLossyCompression())
{
return 0.0f;
......@@ -292,10 +292,10 @@ float VolumeDataLayer::getEffectiveCompressionTolerance() const
float effectiveCompressionTolerance = m_volumeDataLayout->getCompressionTolerance();
if(getLod() > 0)
if(getLOD() > 0)
{
effectiveCompressionTolerance = std::max(effectiveCompressionTolerance, 2.0f);// This means that lod 1 is never smaller than tolerance 4.0 and lod 2 8.0 ...... 0.5f);
effectiveCompressionTolerance *= 1 << (std::min(getLod(), 2));
effectiveCompressionTolerance *= 1 << (std::min(getLOD(), 2));
}
return effectiveCompressionTolerance;
......@@ -316,7 +316,7 @@ int32_t VolumeDataLayer::getEffectiveWaveletAdaptiveLoadLevel() const
if(!CompressionMethod_IsWavelet(getEffectiveCompressionMethod())) return -1;
// If we have lower lods, this layer is not the base layer
if(m_lowerLod)
if(m_lowerLOD)
{
assert(getBaseLayer().getEffectiveCompressionTolerance() == m_volumeDataLayout->getCompressionTolerance());
......
......@@ -46,7 +46,6 @@ public:
{
Renderable,
Auxiliary,
AuxiliaryNoRenderMargin, // This layer type is only used by the VirtualTextureViewContext! It doesn't have larger bricks at the start and end of the volume.
Virtual
};
......@@ -61,9 +60,9 @@ public:
enum ProduceStatus
{
// These are ordered, so greater values mean easier to produce
ProduceStatusUnavailable,
ProduceStatusRemapped,
ProduceStatusNormal
ProduceStatus_Unavailable,
ProduceStatus_Remapped,
ProduceStatus_Normal
};
private:
......@@ -78,8 +77,8 @@ private:
VolumeDataLayer * m_primaryChannelLayer;
VolumeDataLayer * m_nextChannelLayer;
VolumeDataLayer * m_lowerLod;
VolumeDataLayer * m_higherLod;
VolumeDataLayer * m_lowerLOD;
VolumeDataLayer * m_higherLOD;
mutable const VolumeDataLayer * m_remapFromLayer;
//bool m_isAllowRemapFromRemap;
......@@ -93,7 +92,7 @@ private:
uint64_t getFormatHash(VolumeDataChannelDescriptor::Format actualFormat, bool isReplaceNoValue, float replacementNoValue) const;
public:
VolumeDataLayer(VolumeDataPartition const& volumeDataPartition, VolumeDataLayout* volumeDataLayout, int32_t channel, VolumeDataLayer* primaryChannelLayer, VolumeDataLayer* lowerLod, LayerType layerType, const VolumeDataChannelMapping* volumeDataChannelMapping);
VolumeDataLayer(VolumeDataPartition const& volumeDataPartition, VolumeDataLayout* volumeDataLayout, int32_t channel, VolumeDataLayer* primaryChannelLayer, VolumeDataLayer* lowerLOD, LayerType layerType, const VolumeDataChannelMapping* volumeDataChannelMapping);
VolumeDataLayout *getLayout() const
{
......@@ -126,12 +125,12 @@ public:
VolumeDataLayer& getBaseLayer()
{
VolumeDataLayer* baseLayer = this; while (baseLayer->m_lowerLod) baseLayer = baseLayer->m_lowerLod; return *baseLayer;
VolumeDataLayer* baseLayer = this; while (baseLayer->m_lowerLOD) baseLayer = baseLayer->m_lowerLOD; return *baseLayer;
}
const VolumeDataLayer& getBaseLayer() const
{
VolumeDataLayer const* baseLayer = this; while (baseLayer->m_lowerLod) baseLayer = baseLayer->m_lowerLod; return *baseLayer;
VolumeDataLayer const* baseLayer = this; while (baseLayer->m_lowerLOD) baseLayer = baseLayer->m_lowerLOD; return *baseLayer;
}
VolumeDataLayer* getNextChannelLayer()
......@@ -146,22 +145,22 @@ public:
VolumeDataLayer* getParentLayer()
{
return m_higherLod;
return m_higherLOD;
}
const VolumeDataLayer* getParentLayer() const
{
return m_higherLod;
return m_higherLOD;
}
VolumeDataLayer* getChildLayer()
{
return m_lowerLod;
return m_lowerLOD;
}
const VolumeDataLayer* getChildLayer() const
{
return m_lowerLod;
return m_lowerLOD;
}
const VolumeDataLayer* getLayerToRemapFrom() const;
......
......@@ -334,15 +334,15 @@ void VolumeDataLayout::createRenderLayers(DimensionGroup dimensionGroup, int32_t
static IndexArray null;
VolumeDataLayer **lowerLod = (VolumeDataLayer **)alloca(channels * sizeof(VolumeDataLayer*));
VolumeDataLayer **lowerLOD = (VolumeDataLayer **)alloca(channels * sizeof(VolumeDataLayer*));
memset(lowerLod, 0, channels * sizeof(VolumeDataLayer*));
memset(lowerLOD, 0, channels * sizeof(VolumeDataLayer*));
bool isCreateMoreLods = true;
bool isCreateMoreLODs = true;
for(int32_t lod = 0; isCreateMoreLods; lod++)
for(int32_t lod = 0; isCreateMoreLODs; lod++)
{
isCreateMoreLods = (lod < physicalLODLevels - 1); // Always create all physical lods even if we get only one cube before the top level;
isCreateMoreLODs = (lod < physicalLODLevels - 1); // Always create all physical lods even if we get only one cube before the top level;
for(int32_t dimension = 0; dimension < array_size(brickSizeArray); dimension++)
{
......@@ -371,22 +371,22 @@ void VolumeDataLayout::createRenderLayers(DimensionGroup dimensionGroup, int32_t
VolumeDataChannelMapping const *volumeDataChannelMapping = nullptr;// = GetVolumeDataChannelMapping(channel);
VolumeDataLayer *volumeDataLayer = new VolumeDataLayer(VolumeDataPartition::staticMapPartition(primaryPartition, volumeDataChannelMapping, getMappedValueCount(channel)),
this, channel,primaryChannelLayer, lowerLod[channel], layerType, volumeDataChannelMapping);
this, channel,primaryChannelLayer, lowerLOD[channel], layerType, volumeDataChannelMapping);
if(channel == 0)
{
primaryChannelLayer = volumeDataLayer;
}
assert(volumeDataLayer->getLod() == lod);
assert(volumeDataLayer->getLOD() == lod);
lowerLod[channel] = volumeDataLayer;
lowerLOD[channel] = volumeDataLayer;
for(int32_t dimension = 0; dimension < Dimensionality_Max; dimension++)
{
if(volumeDataLayer->isDimensionChunked(dimension) && volumeDataLayer->getNumChunksInDimension(dimension) > 1 && dimension != m_fullResolutionDimension)
{
isCreateMoreLods = true;
isCreateMoreLODs = true;
break;
}
}
......@@ -400,7 +400,7 @@ void VolumeDataLayout::createRenderLayers(DimensionGroup dimensionGroup, int32_t
//// Default physical layers to NEVER_REMAP
//if(lod < physicalLODLevels) _apcPrimaryTopLayers[eDimensionGroup]->SetProduceMethod(VolumeDataLayer_c::NEVER_REMAP, 0);
if(lod < physicalLODLevels) m_primaryTopLayers[dimensionGroup]->setProduceStatus(VolumeDataLayer::ProduceStatusNormal);
if(lod < physicalLODLevels) m_primaryTopLayers[dimensionGroup]->setProduceStatus(VolumeDataLayer::ProduceStatus_Normal);
}
}
......
......@@ -163,7 +163,7 @@ public:
void createRenderLayers(DimensionGroup dimensions, int32_t brickSize, int32_t physicalLODLevels); //-> TODO: rename at some point
bool isDimensionLodDecimated(int32_t dimension) const { return dimension != m_fullResolutionDimension; }
bool isDimensionLODDecimated(int32_t dimension) const { return dimension != m_fullResolutionDimension; }
int32_t getFullResolutionDimension() const { return m_fullResolutionDimension; }
};
}
......
......@@ -45,9 +45,9 @@ VolumeDataLayout const* VolumeDataPageAccessorImpl::getLayout() const
return m_layer->getLayout();
}
int VolumeDataPageAccessorImpl::getLod() const
int VolumeDataPageAccessorImpl::getLOD() const
{
return m_layer->getLod();
return m_layer->getLOD();
}
int VolumeDataPageAccessorImpl::getChannelIndex() const
......@@ -112,7 +112,7 @@ VolumeDataPage* VolumeDataPageAccessorImpl::readPageAtPosition(const int(&positi
return NULL;
}
if (m_layer->getProduceStatus() == VolumeDataLayer::ProduceStatusUnavailable)
if (m_layer->getProduceStatus() == VolumeDataLayer::ProduceStatus_Unavailable)
{
fprintf(stderr, "The accessed dimension group or channel is unavailable (check produce status on VDS before accessing data)");
return nullptr;
......
......@@ -63,7 +63,7 @@ public:
VolumeDataLayout const* getLayout() const override;
VolumeDataLayer const * getLayer() const { return m_layer; }
int getLod() const override;
int getLOD() const override;
int getChannelIndex() const override;
VolumeDataChannelDescriptor const& getChannelDescriptor() const override;
void getNumSamples(int(&numSamples)[Dimensionality_Max]) const override;
......
......@@ -409,7 +409,7 @@ void VolumeDataPartition::getChunkVoxelSize(int64_t chunk, ChunkVoxelSize &size)
{
size[iDataBlockDimension] = 1;
}
else if (isDimensionLodDecimated(iDimension))
else if (isDimensionLODDecimated(iDimension))
{
size[iDataBlockDimension] = (anMax[iDimension] - anMin[iDimension] + (1 << m_lod) - 1) >> m_lod;
}
......@@ -440,7 +440,7 @@ int64_t VolumeDataPartition::getTotalVoxels(bool isIncludeMargins) const
{
int64_t nTotalLayerSize = 1;
int32_t lod = getLod();
int32_t lod = getLOD();
for(int32_t iDimension = 0; iDimension < Dimensionality_Max; iDimension++)
{
......
......@@ -97,12 +97,12 @@ public:
void chunkIndexToIndexArray(int64_t chunkIndex, IndexArray &indexArray) const;
int64_t indexArrayToChunkIndex(const IndexArray &indexArray) const;
int32_t getLod() const { return m_lod; }
int32_t getLOD() const { return m_lod; }
BorderMode getBorderMode() const { return m_borderMode; }
bool isDimensionChunked(int32_t dimension) const { return DimensionGroupUtil::isDimensionInGroup(m_chunkDimensionGroup, dimension); }
bool isDimensionLodDecimated(int32_t dimension) const { return DimensionGroupUtil::isDimensionInGroup(m_originalDimensionGroup, dimension) && dimension != m_fullResolutionDimension; }
bool isDimensionLODDecimated(int32_t dimension) const { return DimensionGroupUtil::isDimensionInGroup(m_originalDimensionGroup, dimension) && dimension != m_fullResolutionDimension; }
int32_t getNumChunksInDimension(int32_t dimension) const { assert(dimension >= 0 && dimension < Dimensionality_Max); return m_chunksInDimension[dimension]; }
int64_t getTotalChunkCount() const { return m_totalChunks; }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment