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

Added createPage()/readPage() methods to VolumeDataPageAccessor interface and...

Added createPage()/readPage() methods to VolumeDataPageAccessor interface and re-implemented readPageAtPosition() as an inline method in terms of getChunkIndex() and readPage().
parent c1cf95ef
......@@ -637,7 +637,10 @@ public:
virtual int addReference() = 0;
virtual int removeReference() = 0;
virtual VolumeDataPage *readPageAtPosition(const int (&anPosition)[Dimensionality_Max]) = 0;
virtual VolumeDataPage *createPage(int64_t chunkIndex) = 0;
virtual VolumeDataPage *readPage(int64_t chunkIndex) = 0;
VolumeDataPage *readPageAtPosition(const int (&position)[Dimensionality_Max]) { return readPage(getChunkIndex(position)); }
virtual void commit() = 0;
};
......
......@@ -104,7 +104,19 @@ int VolumeDataPageAccessorImpl::removeReference()
return --m_references;
}
VolumeDataPage* VolumeDataPageAccessorImpl::readPageAtPosition(const int(&position)[Dimensionality_Max])
VolumeDataPage* VolumeDataPageAccessorImpl::createPage(int64_t chunk)
{
std::unique_lock<std::mutex> pageMutexLocker(m_pagesMutex);
if(!m_layer)
{
return nullptr;
}
return nullptr;
}
VolumeDataPage* VolumeDataPageAccessorImpl::readPage(int64_t chunk)
{
std::unique_lock<std::mutex> pageMutexLocker(m_pagesMutex);
......@@ -119,19 +131,6 @@ VolumeDataPage* VolumeDataPageAccessorImpl::readPageAtPosition(const int(&positi
return nullptr;
}
int32_t indexArray[Dimensionality_Max];
for(int32_t iDimension = 0; iDimension < Dimensionality_Max; iDimension++)
{
if(position[iDimension] < 0 || position[iDimension] >= m_layer->getDimensionNumSamples(iDimension))
{
return nullptr;
}
indexArray[iDimension] = m_layer->voxelToIndex(position[iDimension], iDimension);
}
int64_t chunk = m_layer->indexArrayToChunkIndex(indexArray);
for(auto page_it = m_pages.begin(); page_it != m_pages.end(); ++page_it)
{
if((*page_it)->getChunkIndex() == chunk)
......
......@@ -76,7 +76,8 @@ public:
int addReference() override;
int removeReference() override;
VolumeDataPage* readPageAtPosition(const int(&anPosition)[Dimensionality_Max]) override;
VolumeDataPage *createPage(int64_t chunk) override;
VolumeDataPage *readPage(int64_t chunk) override;
void commit() override;
......
Markdown is supported
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