diff --git a/3rdparty/.gitignore b/3rdparty/.gitignore index 6a93006923adf97d239d308cdf8a2de8cc452de6..29ebde6719caa5abac2c6e5668a397820abaafe6 100644 --- a/3rdparty/.gitignore +++ b/3rdparty/.gitignore @@ -16,3 +16,4 @@ java* google_nlohmann* libressl* dms* +cmakerc* diff --git a/examples/SliceDump/GenerateVDS.h b/examples/SliceDump/GenerateVDS.h index 807459eaa46f003f66c3a1b537f67dc566327a6a..6e7d41dd90f43a68a646028b32bc69bbdb92a9df 100644 --- a/examples/SliceDump/GenerateVDS.h +++ b/examples/SliceDump/GenerateVDS.h @@ -128,13 +128,11 @@ inline void fill3DVDSWithBitNoise(OpenVDS::VDS *vds, int32_t channel = 0) { for(int x = 0; x < size[0]; x++) { - int32_t byteIndex = z * pitch[2] + y * pitch[1] + (x / 8); - int32_t bitIndex = z * size[2] * size[1] * size[0] + y * size[1] * size[0] + x; - uint8_t byte = buffer[byteIndex]; - bool value = dist(gen); - if (value) - byte |= uint8_t(1) << (bitIndex % 8); - buffer[byteIndex] = byte; + size_t bitIndex = z * pitch[2] + y * pitch[1] + x; + if (dist(gen)) + { + buffer[bitIndex / 8] |= uint8_t(1 << (bitIndex % 8)); + } } } } diff --git a/java/cpp/src/MemoryVdsGenerator.cpp b/java/cpp/src/MemoryVdsGenerator.cpp index 37d7c0a2e4f108d8f836379607b390440d884582..1cce084d5cc1f9cf6b911ec5d84386b07f47ca3a 100644 --- a/java/cpp/src/MemoryVdsGenerator.cpp +++ b/java/cpp/src/MemoryVdsGenerator.cpp @@ -170,13 +170,11 @@ static void fill3DVDSWithBitNoise(OpenVDS::VDS *vds, int32_t channel = 0) { for(int x = 0; x < size[0]; x++) { - int32_t byteIndex = z * pitch[2] + y * pitch[1] + (x / 8); - int32_t bitIndex = z * size[2] * size[1] * size[0] + y * size[1] * size[0] + x; - uint8_t byte = buffer[byteIndex]; - bool value = dist(gen); - if (value) - byte |= uint8_t(1) << (bitIndex % 8); - buffer[byteIndex] = byte; + size_t bitIndex = z * pitch[2] + y * pitch[1] + x; + if (dist(gen)) + { + buffer[bitIndex / 8] |= uint8_t(1 << (bitIndex % 8)); + } } } } diff --git a/src/OpenVDS/VDS/VolumeDataPageAccessorImpl.cpp b/src/OpenVDS/VDS/VolumeDataPageAccessorImpl.cpp index 07317d9944255fcfe958e9a73bfd83f9eca7ca1f..dcfe09880f3876ddf7693a142ae48c8885e150ed 100644 --- a/src/OpenVDS/VDS/VolumeDataPageAccessorImpl.cpp +++ b/src/OpenVDS/VDS/VolumeDataPageAccessorImpl.cpp @@ -214,18 +214,29 @@ VolumeDataPage* VolumeDataPageAccessorImpl::CreatePage(int64_t chunk) return nullptr; } - int pitch[Dimensionality_Max] = {}; + int pitchND[Dimensionality_Max] = {}; for(int chunkDimension = 0; chunkDimension < m_layer->GetChunkDimensionality(); chunkDimension++) { int dimension = DimensionGroupUtil::GetDimension(m_layer->GetChunkDimensionGroup(), chunkDimension); assert(dimension >= 0 && dimension < Dimensionality_Max); - pitch[dimension] = dataBlock.Pitch[chunkDimension]; + pitchND[dimension] = dataBlock.Pitch[chunkDimension]; + + // Convert pitch to bitpitch for 1-bit data + if(m_layer->GetFormat() == VolumeDataChannelDescriptor::Format_1Bit) + { + assert(chunkDimension > 0 || pitchND[dimension] == 1); + + if(chunkDimension > 0) + { + pitchND[chunkDimension] *= 8; + } + } } pageListMutexLock.lock(); - page->SetBufferData(dataBlock, pitch, std::move(page_data)); + page->SetBufferData(dataBlock, pitchND, std::move(page_data)); page->MakeDirty(); m_pageReadCondition.notify_all(); diff --git a/src/OpenVDS/VDS/VolumeDataPageImpl.cpp b/src/OpenVDS/VDS/VolumeDataPageImpl.cpp index 028f97a312dad0dfa45cb525072ba19be3398c81..49a6dfab25676119061715d758d06b7a3c711008 100644 --- a/src/OpenVDS/VDS/VolumeDataPageImpl.cpp +++ b/src/OpenVDS/VDS/VolumeDataPageImpl.cpp @@ -104,7 +104,7 @@ VolumeDataPageImpl::VolumeDataPageImpl(VolumeDataPageAccessorImpl* volumeDataPag { for (int32_t iDimension = 0; iDimension < Dimensionality_Max; iDimension++) { - m_pitch[iDimension] = 0; + m_pitchND[iDimension] = 0; m_writtenMin[iDimension] = 0; m_writtenMax[iDimension] = 0; } @@ -156,12 +156,12 @@ void VolumeDataPageImpl::MakeDirty() m_isDirty = true; } -void VolumeDataPageImpl::SetBufferData(const DataBlock &dataBlock, int32_t (&pitch)[Dimensionality_Max], std::vector&& blob) +void VolumeDataPageImpl::SetBufferData(const DataBlock &dataBlock, int32_t (&pitchND)[Dimensionality_Max], std::vector&& blob) { //assert(m_volumeDataPageAccessor->m_pageListMutex.isLockedByCurrentThread()); m_dataBlock = dataBlock; - static_assert(sizeof(pitch) == sizeof(m_pitch), "Pitch of different size"); - memcpy(m_pitch, pitch, sizeof(m_pitch)); + static_assert(sizeof(pitchND) == sizeof(m_pitchND), "Pitch of different size"); + memcpy(m_pitchND, pitchND, sizeof(m_pitchND)); m_blob = std::move(blob); } @@ -174,13 +174,13 @@ void VolumeDataPageImpl::WriteBack(VolumeDataLayer const* volumeDataLayer, std:: layout->CompletePendingWriteChunkRequests(16); } -void* VolumeDataPageImpl::GetBufferInternal(int(&anPitch)[Dimensionality_Max], bool isReadWrite) +void* VolumeDataPageImpl::GetBufferInternal(int(&pitchND)[Dimensionality_Max], bool isReadWrite) { //assert(m_volumeDataPageAccessor->m_pageListMutex.isLockedByCurrentThread()); for(int32_t iDimension = 0; iDimension < Dimensionality_Max; iDimension++) { - anPitch[iDimension] = m_pitch[iDimension]; + pitchND[iDimension] = m_pitchND[iDimension]; } if(isReadWrite) diff --git a/src/OpenVDS/VDS/VolumeDataPageImpl.h b/src/OpenVDS/VDS/VolumeDataPageImpl.h index b11eb4d031f29fe9907b92759a7dc21064cef22f..ab59101cc8dff6ce1e850ef4023ba5701f08f7aa 100644 --- a/src/OpenVDS/VDS/VolumeDataPageImpl.h +++ b/src/OpenVDS/VDS/VolumeDataPageImpl.h @@ -38,7 +38,7 @@ private: int64_t m_chunk; DataBlock m_dataBlock; - int32_t m_pitch[Dimensionality_Max]; + int32_t m_pitchND[Dimensionality_Max]; std::vector m_blob; std::atomic_int m_pins; diff --git a/src/OpenVDS/VDS/VolumeDataRequestProcessor.cpp b/src/OpenVDS/VDS/VolumeDataRequestProcessor.cpp index 9032a58a6494c5378dffe42dba76d3bd15ef5747..b6c69aeb5a2bc0b0c169e3acd73811bb29ffabd5 100644 --- a/src/OpenVDS/VDS/VolumeDataRequestProcessor.cpp +++ b/src/OpenVDS/VDS/VolumeDataRequestProcessor.cpp @@ -558,6 +558,19 @@ static bool RequestSubsetProcessPage(VolumeDataPageImpl* page, const VolumeDataC int32_t copyDimensions = CombineAndReduceDimensions(sourceSize, sourceOffset, targetSize, targetOffset, overlapSize, globalSourceSize, globalSourceOffset, globalTargetSize, globalTargetOffset, globalOverlapSize); (void) copyDimensions; + // Multiply sizes and offsets by number of components since BlockCopy is not component-aware + if(chunk.layer->GetComponents() > 1) + { + for (int32_t dimension = 0; dimension < DataBlock::Dimensionality_Max; dimension++) + { + sourceSize [dimension] *= int(chunk.layer->GetComponents()); + sourceOffset[dimension] *= int(chunk.layer->GetComponents()); + targetSize [dimension] *= int(chunk.layer->GetComponents()); + targetOffset[dimension] *= int(chunk.layer->GetComponents()); + overlapSize [dimension] *= int(chunk.layer->GetComponents()); + } + } + void *source = page->GetRawBufferInternal(); DispatchBlockCopy(destinationFormat, destBuffer, targetOffset, targetSize, @@ -1538,9 +1551,12 @@ int64_t VolumeDataRequestProcessor::RequestVolumeTraces(void *buffer, VolumeData { VolumeDataSamplePos &volumeDataSamplePos = volumeDataSamplePositions->at(tracePos); - std::copy(&tracePositions[tracePos][0], &tracePositions[tracePos][Dimensionality_Max], volumeDataSamplePos.pos.Data); - volumeDataSamplePos.chunkIndex = volumeDataLayer->GetChunkIndexFromNDPos(volumeDataSamplePos.pos); + for(int dimension = 0; dimension < Dimensionality_Max; dimension++) + { + volumeDataSamplePos.pos.Data[dimension] = (dimension != traceDimension) ? tracePositions[tracePos][dimension] : 0; + } volumeDataSamplePos.originalSample = tracePos; + volumeDataSamplePos.chunkIndex = volumeDataLayer->GetChunkIndexFromNDPos(volumeDataSamplePos.pos); } std::sort(volumeDataSamplePositions->begin(), volumeDataSamplePositions->end()); diff --git a/tests/OpenVDS/RequestVolumeSubsetFormat.cpp b/tests/OpenVDS/RequestVolumeSubsetFormat.cpp index 5361724e345d61b6609b9b6120ff214bc0468573..22295b8069ee1b8c29916c947bf0bfad184c45bb 100644 --- a/tests/OpenVDS/RequestVolumeSubsetFormat.cpp +++ b/tests/OpenVDS/RequestVolumeSubsetFormat.cpp @@ -129,7 +129,7 @@ TEST_F(RequestVolumeSubsetFormat, test1Bit) } } -TEST(ReqeustVolumeSubsetFormat, source1Bit) +TEST_F(RequestVolumeSubsetFormat, source1Bit) { std::unique_ptr handle(generateSimpleInMemory3DVDS(60,60,60, OpenVDS::VolumeDataChannelDescriptor::Format_1Bit), OpenVDS::Close); fill3DVDSWithBitNoise(handle.get()); diff --git a/tests/utils/GenerateVDS.h b/tests/utils/GenerateVDS.h index 08ec90bc8fd55a7717c488a691a842a479fa31cc..ce83f421651af76d9730725716adece6d23f8d80 100644 --- a/tests/utils/GenerateVDS.h +++ b/tests/utils/GenerateVDS.h @@ -131,13 +131,11 @@ inline void fill3DVDSWithBitNoise(OpenVDS::VDS *vds, int32_t channel = 0) { for(int x = 0; x < size[0]; x++) { - int32_t byteIndex = z * pitch[2] + y * pitch[1] + (x / 8); - int32_t bitIndex = z * size[2] * size[1] * size[0] + y * size[1] * size[0] + x; - uint8_t byte = buffer[byteIndex]; - bool value = dist(gen); - if (value) - byte |= uint8_t(1) << (bitIndex % 8); - buffer[byteIndex] = byte; + size_t bitIndex = z * pitch[2] + y * pitch[1] + x; + if (dist(gen)) + { + buffer[bitIndex / 8] |= uint8_t(1 << (bitIndex % 8)); + } } } }